[Mammoth] Add an owned memory capability that cleans itself up.
This commit is contained in:
parent
7d48dd2b8b
commit
3e9923f227
5 changed files with 84 additions and 9 deletions
|
|
@ -21,8 +21,8 @@ void interrupt_thread(void* void_driver) {
|
|||
} // namespace
|
||||
|
||||
glcr::ErrorOr<glcr::UniquePtr<AhciDriver>> AhciDriver::Init(
|
||||
MappedMemoryRegion pci_region) {
|
||||
glcr::UniquePtr<AhciDriver> driver(new AhciDriver(pci_region));
|
||||
OwnedMemoryRegion&& pci_region) {
|
||||
glcr::UniquePtr<AhciDriver> driver(new AhciDriver(glcr::Move(pci_region)));
|
||||
// RET_ERR(driver->LoadCapabilities());
|
||||
RET_ERR(driver->LoadHbaRegisters());
|
||||
RET_ERR(driver->LoadDevices());
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
class AhciDriver {
|
||||
public:
|
||||
static glcr::ErrorOr<glcr::UniquePtr<AhciDriver>> Init(
|
||||
MappedMemoryRegion ahci_phys);
|
||||
OwnedMemoryRegion&& ahci_phys);
|
||||
glcr::ErrorCode RegisterIrq();
|
||||
|
||||
void InterruptLoop();
|
||||
|
|
@ -22,7 +22,7 @@ class AhciDriver {
|
|||
void DumpPorts();
|
||||
|
||||
private:
|
||||
MappedMemoryRegion pci_region_;
|
||||
OwnedMemoryRegion pci_region_;
|
||||
PciDeviceHeader* pci_device_header_ = nullptr;
|
||||
MappedMemoryRegion ahci_region_;
|
||||
AhciHba* ahci_hba_ = nullptr;
|
||||
|
|
@ -40,8 +40,8 @@ class AhciDriver {
|
|||
glcr::ErrorCode LoadHbaRegisters();
|
||||
glcr::ErrorCode LoadDevices();
|
||||
|
||||
AhciDriver(MappedMemoryRegion pci_region)
|
||||
: pci_region_(pci_region),
|
||||
AhciDriver(OwnedMemoryRegion&& pci_region)
|
||||
: pci_region_(glcr::Move(pci_region)),
|
||||
pci_device_header_(
|
||||
reinterpret_cast<PciDeviceHeader*>(pci_region_.vaddr())) {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ uint64_t main(uint64_t init_port_cap) {
|
|||
Empty empty;
|
||||
AhciInfo ahci;
|
||||
RET_ERR(stub.GetAhciInfo(empty, ahci));
|
||||
MappedMemoryRegion ahci_region =
|
||||
MappedMemoryRegion::FromCapability(ahci.ahci_region());
|
||||
ASSIGN_OR_RETURN(auto driver, AhciDriver::Init(ahci_region));
|
||||
OwnedMemoryRegion ahci_region =
|
||||
OwnedMemoryRegion::FromCapability(ahci.ahci_region());
|
||||
ASSIGN_OR_RETURN(auto driver, AhciDriver::Init(glcr::Move(ahci_region)));
|
||||
|
||||
ASSIGN_OR_RETURN(glcr::UniquePtr<DenaliServer> server,
|
||||
DenaliServer::Create(*driver));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue