[Mammoth] Add an owned memory capability that cleans itself up.

This commit is contained in:
Drew Galbraith 2023-11-19 17:54:28 -08:00
parent 7d48dd2b8b
commit 3e9923f227
5 changed files with 84 additions and 9 deletions

View file

@ -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())) {}
};