From 8acaf9b721973fdd852abc01fc44ba1152b8f72a Mon Sep 17 00:00:00 2001 From: Amlal Date: Wed, 7 May 2025 11:14:25 +0200 Subject: feat(kernel): HeFS fixes, AHCI improvements, and MBCI tweaks. why? - Some parts were causing issues on the filesystem. - The slot probe code was naive. - Made the current MBCI implementation clearer. Signed-off-by: Amlal --- dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'dev/kernel/HALKit/AMD64/Storage') diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index cf1841bd..4b0270ab 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -154,10 +154,18 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz UIntPtr slot = drv_find_cmd_slot_ahci(&kSATAHba->Ports[kSATAIndex]); - if (slot == ~0UL) { - kout << "No free command slot!\r"; - err_global_get() = kErrorDisk; - return; + UInt16 timeout = 0; + + while (slot == ~0UL) { + kout << "No free command slot found, AHCI disk is busy!\r"; + + if (timeout > 0x1000) { + err_global_get() = kErrorDisk; + return; + } + + slot = drv_find_cmd_slot_ahci(&kSATAHba->Ports[kSATAIndex]); + ++timeout; } volatile HbaCmdHeader* command_header = @@ -173,7 +181,7 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz rt_set_memory((VoidPtr) command_table, 0, sizeof(HbaCmdTbl)); - VoidPtr ptr = rtl_dma_alloc(size_buffer, 4096); + VoidPtr ptr = rtl_dma_alloc(size_buffer, kib_cast(4)); rtl_dma_flush(ptr, size_buffer); -- cgit v1.2.3