From 216b2f35b38b582a930948fca76c272e424c9d96 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 4 Apr 2025 07:56:52 +0200 Subject: kernel, storage: important patches done to AHCI, PIO, PagingMgr, and DMA. Signed-off-by: Amlal El Mahrouss --- dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc') diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index 21d95b5d..f74db6c0 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -15,6 +15,7 @@ * */ +#include "NewKit/Defines.h" #include #include #include @@ -71,13 +72,13 @@ STATIC Void drv_compute_disk_ahci() noexcept kSATASectorCount = 0UL; /// Normally 512 bytes, but add an additional 512 bytes to make 1 KIB. - const UInt16 kSzIdent = kib_cast(1); + const UInt16 kSzIdent = 256; /// Push it to the stack - UInt8* identify_data ATTRIBUTE(aligned(4096)) = new UInt8[kSzIdent]; + UInt16* identify_data ATTRIBUTE(aligned(4096)) = new UInt16[kSzIdent]; /// Send AHCI command for identification. - drv_std_input_output_ahci(0, identify_data, kAHCISectorSize, kSzIdent); + drv_std_input_output_ahci(0, (UInt8*)identify_data, kAHCISectorSize, kSzIdent); /// Extract 48-bit LBA. @@ -90,6 +91,9 @@ STATIC Void drv_compute_disk_ahci() noexcept kSATASectorCount = (identify_data[61] << 16) | identify_data[60]; else kSATASectorCount = lba48_sectors; + + delete[] identify_data; + identify_data = nullptr; } /// @brief Finds a command slot for a HBA port. @@ -140,8 +144,10 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz /// Offset to specific command slot. command_header += slot; + /// check for command header. MUST_PASS(command_header); + /// 4kb per PRD. constexpr const UInt32 kMaxPRDSize = kib_cast(4); command_header->Cfl = sizeof(FisRegH2D) / sizeof(UInt32); -- cgit v1.2.3