summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/HALKit/AMD64/Storage
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-05-07 11:14:25 +0200
committerAmlal <amlal@nekernel.org>2025-05-07 11:14:25 +0200
commit8acaf9b721973fdd852abc01fc44ba1152b8f72a (patch)
treed3626413ddc890445d431451439a9abe225f4e5f /dev/kernel/HALKit/AMD64/Storage
parenta3ee1df87feddec339c710068e0922a40c6fd494 (diff)
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 <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/HALKit/AMD64/Storage')
-rw-r--r--dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc18
1 files changed, 13 insertions, 5 deletions
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);