[Denali] Update HBA pointers to volatile. Store CommandList in arrayview.
This commit is contained in:
parent
c530921bda
commit
5a18d7d559
|
@ -10,7 +10,9 @@ class ArrayView {
|
|||
ArrayView() : data_(nullptr), size_(0) {}
|
||||
|
||||
ArrayView(const ArrayView&) = default;
|
||||
ArrayView& operator=(const ArrayView&) = default;
|
||||
ArrayView(ArrayView&&) = default;
|
||||
ArrayView& operator=(ArrayView&&) = default;
|
||||
|
||||
ArrayView(T* data, uint64_t size) : data_(data), size_(size) {}
|
||||
|
||||
|
|
|
@ -155,10 +155,12 @@ glcr::ErrorCode AhciController::LoadCapabilities() {
|
|||
dbgln("No caps!");
|
||||
return glcr::FAILED_PRECONDITION;
|
||||
}
|
||||
uint8_t* base = reinterpret_cast<uint8_t*>(pci_device_header_);
|
||||
volatile uint8_t* base =
|
||||
reinterpret_cast<volatile uint8_t*>(pci_device_header_);
|
||||
uint16_t offset = pci_device_header_->cap_ptr;
|
||||
do {
|
||||
uint16_t* cap = reinterpret_cast<uint16_t*>(base + offset);
|
||||
volatile uint16_t* cap =
|
||||
reinterpret_cast<volatile uint16_t*>(base + offset);
|
||||
switch (*cap & 0xFF) {
|
||||
case 0x01:
|
||||
dbgln("Power Management");
|
||||
|
|
|
@ -23,7 +23,7 @@ class AhciController {
|
|||
|
||||
private:
|
||||
mmth::OwnedMemoryRegion pci_region_;
|
||||
PciDeviceHeader* pci_device_header_ = nullptr;
|
||||
volatile PciDeviceHeader* pci_device_header_ = nullptr;
|
||||
mmth::OwnedMemoryRegion ahci_region_;
|
||||
volatile AhciHba* ahci_hba_ = nullptr;
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ AhciDevice::AhciDevice(AhciPort* port) : port_struct_(port) {
|
|||
port_struct_->fis_base = paddr + 0x400;
|
||||
port_struct_->command |= kCommand_FIS_Receive_Enable;
|
||||
|
||||
command_tables_ =
|
||||
reinterpret_cast<CommandTable*>(command_structures_.vaddr() + 0x500);
|
||||
command_tables_ = glcr::ArrayView(
|
||||
reinterpret_cast<CommandTable*>(command_structures_.vaddr() + 0x500), 32);
|
||||
|
||||
for (uint64_t i = 0; i < 32; i++) {
|
||||
// This leaves space for 2 prdt entries.
|
||||
|
@ -50,7 +50,6 @@ glcr::ErrorCode AhciDevice::IssueCommand(Command* command) {
|
|||
dbgln("All slots full");
|
||||
return glcr::INTERNAL;
|
||||
}
|
||||
CommandTable* command_table = command_tables_ + slot;
|
||||
command->PopulateFis(command_tables_[slot].command_fis);
|
||||
command->PopulatePrdt(command_tables_[slot].prdt);
|
||||
|
||||
|
@ -61,8 +60,8 @@ glcr::ErrorCode AhciDevice::IssueCommand(Command* command) {
|
|||
|
||||
commands_[slot] = command;
|
||||
|
||||
commands_issued_ |= 1 << slot;
|
||||
port_struct_->command_issue |= 1 << slot;
|
||||
commands_issued_ |= (1 << slot);
|
||||
port_struct_->command_issue |= (1 << slot);
|
||||
|
||||
return glcr::OK;
|
||||
}
|
||||
|
@ -96,7 +95,8 @@ void AhciDevice::HandleIrq() {
|
|||
// TODO: Do something with this information.
|
||||
if (int_status & 0x1) {
|
||||
// Device to host.
|
||||
DeviceToHostRegisterFis& fis = received_fis_->device_to_host_register_fis;
|
||||
volatile DeviceToHostRegisterFis& fis =
|
||||
received_fis_->device_to_host_register_fis;
|
||||
if (fis.fis_type != FIS_TYPE_REG_D2H) {
|
||||
dbgln("BAD FIS TYPE (exp,act): {x}, {x}",
|
||||
static_cast<uint64_t>(FIS_TYPE_REG_D2H),
|
||||
|
@ -110,7 +110,7 @@ void AhciDevice::HandleIrq() {
|
|||
}
|
||||
if (int_status & 0x2) {
|
||||
// PIO.
|
||||
PioSetupFis& fis = received_fis_->pio_set_fis;
|
||||
volatile PioSetupFis& fis = received_fis_->pio_set_fis;
|
||||
if (fis.fis_type != FIS_TYPE_PIO_SETUP) {
|
||||
dbgln("BAD FIS TYPE (exp,act): {x}, {x}",
|
||||
static_cast<uint64_t>(FIS_TYPE_PIO_SETUP),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/container/array_view.h>
|
||||
#include <glacier/status/error.h>
|
||||
#include <mammoth/util/memory_region.h>
|
||||
#include <ztypes.h>
|
||||
|
@ -25,13 +26,13 @@ class AhciDevice {
|
|||
AhciDevice& operator=(const AhciDevice&) = delete;
|
||||
|
||||
private:
|
||||
AhciPort* port_struct_ = nullptr;
|
||||
volatile AhciPort* port_struct_ = nullptr;
|
||||
mmth::OwnedMemoryRegion command_structures_;
|
||||
|
||||
CommandList* command_list_ = nullptr;
|
||||
ReceivedFis* received_fis_ = nullptr;
|
||||
CommandTable* command_tables_ = nullptr;
|
||||
volatile CommandList* command_list_ = nullptr;
|
||||
volatile ReceivedFis* received_fis_ = nullptr;
|
||||
glcr::ArrayView<CommandTable> command_tables_;
|
||||
|
||||
Command* commands_[32];
|
||||
volatile uint32_t commands_issued_ = 0;
|
||||
uint32_t commands_issued_ = 0;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue