1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +00:00

Kernel: Refactor AHCIController to propagate more errors

Before, the mapping of our HBA region would be done in the constructor.
Since this can fail, I moved it into initialize().

Additionally, we now use the TypedMapping helper for mapping the HBA
instead of doing it manually. This actually uncovered a bug where we
would ignore any possible offset into the page we were mapping, which
caused us to miss the mapped registers entirely.
This commit is contained in:
Julian Offenhäuser 2023-03-14 15:23:49 +01:00 committed by Andreas Kling
parent 5541dfd9f8
commit f31a9e9374
2 changed files with 10 additions and 8 deletions

View file

@ -9,6 +9,7 @@
#include <AK/OwnPtr.h>
#include <AK/Types.h>
#include <Kernel/Library/LockRefPtr.h>
#include <Kernel/Memory/TypedMapping.h>
#include <Kernel/Sections.h>
#include <Kernel/Storage/ATA/AHCI/Definitions.h>
#include <Kernel/Storage/ATA/ATAController.h>
@ -49,11 +50,11 @@ private:
LockRefPtr<StorageDevice> device_by_port(u32 index) const;
volatile AHCI::PortRegisters& port(size_t port_number) const;
NonnullOwnPtr<Memory::Region> default_hba_region() const;
ErrorOr<Memory::TypedMapping<AHCI::HBA volatile>> map_default_hba_region(PCI::DeviceIdentifier const&);
volatile AHCI::HBA& hba() const;
Array<LockRefPtr<AHCIPort>, 32> m_ports;
NonnullOwnPtr<Memory::Region> m_hba_region;
Memory::TypedMapping<AHCI::HBA volatile> m_hba_mapping;
AHCI::HBADefinedCapabilities m_hba_capabilities;
// FIXME: There could be multiple IRQ (MSI) handlers for AHCI. Find a way to use all of them.