From bbdc9527d81cbafa74375ed108009f30e340d1b0 Mon Sep 17 00:00:00 2001 From: Amlal Date: Tue, 29 Apr 2025 16:52:05 +0200 Subject: dev(kernel, HeFS): reworking filesystem to find an hybrid solution regarding memory footprint (unstable changes) Signed-off-by: Amlal --- dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 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 b767e79c..d09fd71a 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -130,6 +130,11 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz lba /= sector_sz; + if (lba > kSATASectorCount) { + err_global_get() = kErrorDisk; + return; + } + if (!buffer || size_buffer == 0) { kout << "Invalid buffer for AHCI I/O.\r"; err_global_get() = kErrorDisk; @@ -146,7 +151,7 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz volatile HbaCmdHeader* command_header = (volatile HbaCmdHeader*) ((UInt64) kSATAHba->Ports[kSATAIndex].Clb); - + command_header += slot; MUST_PASS(command_header); @@ -196,7 +201,7 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz return; } - command_header->Prdtl = prdt_index; + command_header->Prdtl = prdt_index; command_header->HbaFlags.Struct.Cfl = sizeof(FisRegH2D) / sizeof(UInt32); command_header->HbaFlags.Struct.Write = Write; @@ -241,6 +246,7 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz rtl_dma_free(size_buffer); err_global_get() = kErrorDiskIsCorrupted; + return; } else { if (!Write) { -- cgit v1.2.3