acadia/sys/denali/ahci/ahci_driver.h

42 lines
854 B
C
Raw Normal View History

#pragma once
2023-06-21 18:38:11 -07:00
#include <glacier/status/error_or.h>
#include <mammoth/thread.h>
#include <ztypes.h>
#include "ahci/ahci.h"
#include "ahci/ahci_device.h"
class AhciDriver {
public:
2023-06-21 18:38:11 -07:00
glcr::ErrorCode Init();
void InterruptLoop();
2023-06-21 18:38:11 -07:00
glcr::ErrorOr<AhciDevice*> GetDevice(uint64_t id);
2023-06-15 16:20:29 -07:00
void DumpCapabilities();
void DumpPorts();
private:
MappedMemoryRegion pci_region_;
PciDeviceHeader* pci_device_header_ = nullptr;
MappedMemoryRegion ahci_region_;
AhciHba* ahci_hba_ = nullptr;
// TODO: Allocate these dynamically.
AhciDevice* devices_[32];
Thread irq_thread_;
uint64_t irq_port_cap_ = 0;
uint64_t num_ports_;
uint64_t num_commands_;
2023-06-21 18:38:11 -07:00
glcr::ErrorCode LoadPciDeviceHeader();
glcr::ErrorCode LoadCapabilities();
glcr::ErrorCode RegisterIrq();
glcr::ErrorCode LoadHbaRegisters();
glcr::ErrorCode LoadDevices();
};