From 1311cdcfaa7fad132196a615899fd38393f54daf Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 18 Mar 2025 05:20:57 +0100 Subject: feat(AHCI, HAL): Improve AHCI error handling & optimize HAL initialization - Refactored `sk_acquire_ahci_device(Int32 drv_index)` to return `ErrorOr` for proper error handling instead of returning a raw object. - Moved `sk_init_ahci_device(BOOL atapi)` into the `NeOS` namespace for better encapsulation. - Reduced `HbaMem::Ports` array size from `Ports[32]` to `Ports[1]` to optimize memory usage for single-port AHCI controllers. - Removed manual constructor initialization (`__CTOR_LIST__`, `__DTOR_LIST__`) from HAL, simplifying kernel startup. - Updated `hal_real_init()` to initialize AHCI storage (`sk_init_ahci_device(NO)`) before userland execution. - Refactored `hal_get_phys_address(void* virtual_address)` to use `VoidPtr` for type safety. - Fixed incorrect buffer size (`kSzIdent`) in AHCI driver initialization from `kib_cast(1)` to `512`, ensuring correct sector identification. - Removed redundant drive model string parsing logic. - Refactored AHCI PRD iteration loop to use `prd_i` instead of `i`, improving readability. - Optimized `drv_std_input_output` by simplifying wait loop logic. Overall, this commit improves AHCI error handling, reduces redundant initialization, optimizes memory usage, and cleans up HAL and storage code. Signed-off-by: Amlal El Mahrouss --- dev/Mod/AHCI/AHCI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dev/Mod') diff --git a/dev/Mod/AHCI/AHCI.h b/dev/Mod/AHCI/AHCI.h index d4f8ceb1..0b8971e2 100644 --- a/dev/Mod/AHCI/AHCI.h +++ b/dev/Mod/AHCI/AHCI.h @@ -265,7 +265,7 @@ typedef struct HbaMem final NeOS::UInt8 Resv0[0xA0 - 0x2C]; NeOS::UInt8 Vendor[0x100 - 0xA0]; - HbaPort Ports[32]; // 1 ~ 32, 32 is the max ahci devices per controller. + HbaPort Ports[1]; // 1 ~ 32, 32 is the max ahci devices per controller. } HbaMem; typedef struct HbaCmdHeader final -- cgit v1.2.3