diff options
| author | Amlal <amlal@nekernel.org> | 2025-04-27 23:31:27 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-04-27 23:31:27 +0200 |
| commit | 8a7396493c3effb356d2dc4484b993b4698bc422 (patch) | |
| tree | 1726a7342eaf1ae3adaefbfe019e20cff9b9ab09 /dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | |
| parent | 11dd858e1d9da71a182bc707ca3a481dafbccbe4 (diff) | |
dev, kernel: HeFS had to be redesigned to be less problematic with hard-drives.
why?
the struct were way too big to fit wihin a sector.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc')
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index deea30e1..06c7781c 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -162,7 +162,7 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz SizeT prdt_index = 0; UIntPtr buffer_phys = (UIntPtr) ptr; - while (bytes_remaining > 0 && prdt_index < 8) { + while (bytes_remaining > 0) { SizeT chunk_size = bytes_remaining; if (chunk_size > kib_cast(32)) chunk_size = kib_cast(32); @@ -234,9 +234,11 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz err_global_get() = kErrorDiskIsCorrupted; return; } else { - rtl_dma_flush(ptr, size_buffer); - rt_copy_memory(ptr, buffer, size_buffer); - rtl_dma_flush(ptr, size_buffer); + if (!Write) { + rtl_dma_flush(ptr, size_buffer); + rt_copy_memory(ptr, buffer, size_buffer); + rtl_dma_flush(ptr, size_buffer); + } rtl_dma_free(size_buffer); @@ -424,7 +426,7 @@ Bool drv_std_detected_ahci() { /// //////////////////////////////////////////////////// Void drv_std_write(UInt64 lba, Char* buffer, SizeT sector_sz, SizeT size_buffer) { - drv_std_input_output_ahci<YES, YES, NO>(lba, reinterpret_cast<UInt8*>(buffer), sector_sz, + drv_std_input_output_ahci<YES, YES, NO>(lba / sector_sz, reinterpret_cast<UInt8*>(buffer), sector_sz, size_buffer); } @@ -432,7 +434,7 @@ Void drv_std_write(UInt64 lba, Char* buffer, SizeT sector_sz, SizeT size_buffer) /// //////////////////////////////////////////////////// Void drv_std_read(UInt64 lba, Char* buffer, SizeT sector_sz, SizeT size_buffer) { - drv_std_input_output_ahci<NO, YES, NO>(lba, reinterpret_cast<UInt8*>(buffer), sector_sz, + drv_std_input_output_ahci<NO, YES, NO>(lba / sector_sz, reinterpret_cast<UInt8*>(buffer), sector_sz, size_buffer); } @@ -499,7 +501,7 @@ namespace Detail { err_global_get() = kErrorSuccess; - drv_std_input_output_ahci<NO, YES, NO>(disk->fPacket.fPacketLba, + drv_std_input_output_ahci<NO, YES, NO>(disk->fPacket.fPacketLba / kAHCISectorSize, (UInt8*) disk->fPacket.fPacketContent, kAHCISectorSize, disk->fPacket.fPacketSize); } @@ -521,7 +523,7 @@ namespace Detail { err_global_get() = kErrorSuccess; - drv_std_input_output_ahci<YES, YES, NO>(disk->fPacket.fPacketLba, + drv_std_input_output_ahci<YES, YES, NO>(disk->fPacket.fPacketLba / kAHCISectorSize, (UInt8*) disk->fPacket.fPacketContent, kAHCISectorSize, disk->fPacket.fPacketSize); } |
