[Mammoth] Move most classes to the mmth namespace.
This commit is contained in:
parent
5f8d577948
commit
8d730c67c1
42 changed files with 130 additions and 60 deletions
|
|
@ -14,7 +14,8 @@ AhciDevice::AhciDevice(AhciPort* port) : port_struct_(port) {
|
|||
// 0x400-0x500 -> Received FIS
|
||||
// 0x500-0x2500 -> Command Tables (0x100 each) (Max PRDT Length is 8 for now)
|
||||
uint64_t paddr;
|
||||
command_structures_ = OwnedMemoryRegion::ContiguousPhysical(0x2500, &paddr);
|
||||
command_structures_ =
|
||||
mmth::OwnedMemoryRegion::ContiguousPhysical(0x2500, &paddr);
|
||||
|
||||
command_list_ = reinterpret_cast<CommandList*>(command_structures_.vaddr());
|
||||
port_struct_->command_list_base = paddr;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class AhciDevice {
|
|||
|
||||
private:
|
||||
AhciPort* port_struct_ = nullptr;
|
||||
OwnedMemoryRegion command_structures_;
|
||||
mmth::OwnedMemoryRegion command_structures_;
|
||||
|
||||
CommandList* command_list_ = nullptr;
|
||||
ReceivedFis* received_fis_ = nullptr;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ void interrupt_thread(void* void_driver) {
|
|||
} // namespace
|
||||
|
||||
glcr::ErrorOr<glcr::UniquePtr<AhciDriver>> AhciDriver::Init(
|
||||
OwnedMemoryRegion&& pci_region) {
|
||||
mmth::OwnedMemoryRegion&& pci_region) {
|
||||
glcr::UniquePtr<AhciDriver> driver(new AhciDriver(glcr::Move(pci_region)));
|
||||
// RET_ERR(driver->LoadCapabilities());
|
||||
RET_ERR(driver->LoadHbaRegisters());
|
||||
|
|
@ -191,8 +191,8 @@ glcr::ErrorCode AhciDriver::RegisterIrq() {
|
|||
}
|
||||
|
||||
glcr::ErrorCode AhciDriver::LoadHbaRegisters() {
|
||||
ahci_region_ =
|
||||
OwnedMemoryRegion ::DirectPhysical(pci_device_header_->abar, 0x1100);
|
||||
ahci_region_ = mmth::OwnedMemoryRegion ::DirectPhysical(
|
||||
pci_device_header_->abar, 0x1100);
|
||||
ahci_hba_ = reinterpret_cast<AhciHba*>(ahci_region_.vaddr());
|
||||
num_ports_ = (ahci_hba_->capabilities & 0x1F) + 1;
|
||||
num_commands_ = ((ahci_hba_->capabilities & 0x1F00) >> 8) + 1;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
class AhciDriver {
|
||||
public:
|
||||
static glcr::ErrorOr<glcr::UniquePtr<AhciDriver>> Init(
|
||||
OwnedMemoryRegion&& ahci_phys);
|
||||
mmth::OwnedMemoryRegion&& ahci_phys);
|
||||
glcr::ErrorCode RegisterIrq();
|
||||
|
||||
void InterruptLoop();
|
||||
|
|
@ -22,9 +22,9 @@ class AhciDriver {
|
|||
void DumpPorts();
|
||||
|
||||
private:
|
||||
OwnedMemoryRegion pci_region_;
|
||||
mmth::OwnedMemoryRegion pci_region_;
|
||||
PciDeviceHeader* pci_device_header_ = nullptr;
|
||||
OwnedMemoryRegion ahci_region_;
|
||||
mmth::OwnedMemoryRegion ahci_region_;
|
||||
AhciHba* ahci_hba_ = nullptr;
|
||||
|
||||
// TODO: Allocate these dynamically.
|
||||
|
|
@ -40,7 +40,7 @@ class AhciDriver {
|
|||
glcr::ErrorCode LoadHbaRegisters();
|
||||
glcr::ErrorCode LoadDevices();
|
||||
|
||||
AhciDriver(OwnedMemoryRegion&& pci_region)
|
||||
AhciDriver(mmth::OwnedMemoryRegion&& pci_region)
|
||||
: pci_region_(glcr::Move(pci_region)),
|
||||
pci_device_header_(
|
||||
reinterpret_cast<PciDeviceHeader*>(pci_region_.vaddr())) {}
|
||||
|
|
|
|||
|
|
@ -32,5 +32,5 @@ class DmaReadCommand : public Command {
|
|||
uint64_t paddr_;
|
||||
// TODO: Make this owned by the device so that we don't have to create a new
|
||||
// one with the kernel every time a command is issued.
|
||||
Semaphore callback_semaphore_;
|
||||
mmth::Semaphore callback_semaphore_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ uint64_t main(uint64_t init_port_cap) {
|
|||
Empty empty;
|
||||
AhciInfo ahci;
|
||||
RET_ERR(stub.GetAhciInfo(empty, ahci));
|
||||
OwnedMemoryRegion ahci_region =
|
||||
OwnedMemoryRegion::FromCapability(ahci.ahci_region());
|
||||
mmth::OwnedMemoryRegion ahci_region =
|
||||
mmth::OwnedMemoryRegion::FromCapability(ahci.ahci_region());
|
||||
ASSIGN_OR_RETURN(auto driver, AhciDriver::Init(glcr::Move(ahci_region)));
|
||||
|
||||
ASSIGN_OR_RETURN(glcr::UniquePtr<DenaliServer> server,
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ glcr::ErrorCode DenaliServer::HandleRead(const ReadRequest& req,
|
|||
ASSIGN_OR_RETURN(AhciDevice * device, driver_.GetDevice(req.device_id()));
|
||||
|
||||
uint64_t paddr;
|
||||
OwnedMemoryRegion region =
|
||||
OwnedMemoryRegion::ContiguousPhysical(req.size() * 512, &paddr);
|
||||
mmth::OwnedMemoryRegion region =
|
||||
mmth::OwnedMemoryRegion::ContiguousPhysical(req.size() * 512, &paddr);
|
||||
|
||||
DmaReadCommand command(req.lba(), req.size(), paddr);
|
||||
device->IssueCommand(&command);
|
||||
|
|
@ -44,8 +44,8 @@ glcr::ErrorCode DenaliServer::HandleReadMany(const ReadManyRequest& req,
|
|||
sector_cnt += req.sector_cnt().at(i);
|
||||
}
|
||||
uint64_t region_paddr;
|
||||
OwnedMemoryRegion region =
|
||||
OwnedMemoryRegion::ContiguousPhysical(sector_cnt * 512, ®ion_paddr);
|
||||
mmth::OwnedMemoryRegion region = mmth::OwnedMemoryRegion::ContiguousPhysical(
|
||||
sector_cnt * 512, ®ion_paddr);
|
||||
|
||||
for (uint64_t i = 0; i < req.lba().size(); i++) {
|
||||
uint64_t lba = req.lba().at(i);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue