summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-04 08:04:54 +0200
committerGitHub <noreply@github.com>2025-04-04 08:04:54 +0200
commitc1a67bfb86ce452383eddfdbe14135935f3ddcb3 (patch)
treecc8d6f2b41a081e20ad2a4a30b4430722ff9edde /dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
parentf7e742096821e7d0f53f3c3cd1912b5a4987ee92 (diff)
parent84f641139c7f28133a0ea44bccb02e9d2ac524d8 (diff)
Merge pull request #9 from amlel-el-mahrouss/dev
kernel, storage/pr: merging important patches.
Diffstat (limited to 'dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc')
-rw-r--r--dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc12
1 files changed, 9 insertions, 3 deletions
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 <KernelKit/DeviceMgr.h>
#include <KernelKit/DriveMgr.h>
#include <KernelKit/ProcessScheduler.h>
@@ -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<NO, YES, YES>(0, identify_data, kAHCISectorSize, kSzIdent);
+ drv_std_input_output_ahci<NO, YES, YES>(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);