summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/HALKit/AMD64/Storage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-13 08:04:32 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-04-13 08:22:23 +0200
commitf30470c40229806a33c914ebdd1dbdf037c9698d (patch)
treef67922ba36b8a4847b0f1854f77da4466e64f7e6 /dev/kernel/HALKit/AMD64/Storage
parent2d995049f660b7cee41d9e9bd2718fbcf76172e9 (diff)
dev, scheduler, ahci, dev: Refactor scheduler, and fix minor mistakes.
Add kDeviceTypeATA in DeviceMgr.h, making NeKernel aware that ATA devices can exist too. The scheduler now won't have to reimplement new classes, I refactor the names to signal that, and they're already generic enough to signal that. The AHCI-Generic driver got cleaned up of any irrelevant code, such as aligning the newly allocated pointer. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/HALKit/AMD64/Storage')
-rw-r--r--dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc20
1 files changed, 2 insertions, 18 deletions
diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
index f0893e2d..728b20ed 100644
--- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
+++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
@@ -66,22 +66,6 @@ STATIC Int32 drv_find_cmd_slot_ahci(HbaPort* port) noexcept;
STATIC Void drv_compute_disk_ahci() noexcept;
-namespace AHCI::Detail
-{
- template <typename RetType>
- STATIC RetType* ahci_align_address(RetType* address, Int32 alignement)
- {
- if (!address)
- return nullptr;
-
- UIntPtr addr = (UIntPtr)address;
-
- UIntPtr aligned_addr = (addr + alignement - 1) & (~alignement - 1);
-
- return (RetType*)aligned_addr;
- }
-} // namespace AHCI::Detail
-
STATIC Void drv_compute_disk_ahci() noexcept
{
kSATASectorCount = 0UL;
@@ -90,18 +74,18 @@ STATIC Void drv_compute_disk_ahci() noexcept
const UInt16 kSzIdent = 512;
/// Push it to the stack
- UInt16* identify_data = AHCI::Detail::ahci_align_address<UInt16>(new UInt16[kSzIdent], kib_cast(1));
+ UInt16* identify_data = new UInt16[kSzIdent];
/// Send AHCI command for identification.
drv_std_input_output_ahci<NO, YES, YES>(0, (UInt8*)identify_data, kAHCISectorSize, kSzIdent);
/// Extract 48-bit LBA.
-
UInt64 lba48_sectors = 0;
lba48_sectors |= (UInt64)identify_data[100];
lba48_sectors |= (UInt64)identify_data[101] << 16;
lba48_sectors |= (UInt64)identify_data[102] << 32;
+ /// Now verify if lba48
if (lba48_sectors == 0)
kSATASectorCount = (identify_data[61] << 16) | identify_data[60];
else