summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/HALKit/AMD64/Storage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-11 17:52:52 +0200
committerGitHub <noreply@github.com>2025-04-11 17:52:52 +0200
commitc1d9fbd3925d6e10919a7793fc214c9f1a01b2ab (patch)
treea74bdf6f87d07a24496effbc157f74d379d25007 /dev/kernel/HALKit/AMD64/Storage
parent8988b6f166d1087615b21229df651e0bcc0fa048 (diff)
parentc3856eddb5a8146751dac82ad1ba4433f5ca6d6d (diff)
Merge pull request #14 from amlel-el-mahrouss/dev
tweak kernel, boot: use -Wall, -Werror, -Wpedantic now
Diffstat (limited to 'dev/kernel/HALKit/AMD64/Storage')
-rw-r--r--dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc19
-rw-r--r--dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc5
2 files changed, 13 insertions, 11 deletions
diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
index 41aabca2..f0893e2d 100644
--- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
+++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
@@ -76,7 +76,7 @@ namespace AHCI::Detail
UIntPtr addr = (UIntPtr)address;
- UIntPtr aligned_addr = (addr + alignement - 1) & ~alignement - 1;
+ UIntPtr aligned_addr = (addr + alignement - 1) & (~alignement - 1);
return (RetType*)aligned_addr;
}
@@ -87,7 +87,7 @@ 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 = 256;
+ const UInt16 kSzIdent = 512;
/// Push it to the stack
UInt16* identify_data = AHCI::Detail::ahci_align_address<UInt16>(new UInt16[kSzIdent], kib_cast(1));
@@ -107,6 +107,8 @@ STATIC Void drv_compute_disk_ahci() noexcept
else
kSATASectorCount = lba48_sectors;
+ (Void)(kout << "Device: " << kCurrentDiskModel << kendl);
+
delete[] identify_data;
identify_data = nullptr;
}
@@ -141,7 +143,7 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz
slot = drv_find_cmd_slot_ahci(&kSATAHba->Ports[kSATAIndex]);
- if (slot == ~0)
+ if (slot == ~0UL)
{
err_global_get() = kErrorDisk;
return;
@@ -166,11 +168,8 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz
/// 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);
- command_header->Write = Write;
+ command_header->Struc.Cfl = sizeof(FisRegH2D) / sizeof(UInt32);
+ command_header->Struc.Write = Write;
command_header->Prdtl = 1;
auto ctba_phys = ((UInt64)command_header->Ctbau << 32) | command_header->Ctba;
@@ -186,7 +185,7 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz
command_table->Prdt[0].Dba = (UInt32)(buffer_phys & 0xFFFFFFFF);
command_table->Prdt[0].Dbau = (UInt32)(buffer_phys >> 32);
command_table->Prdt[0].Dbc = bytes_remaining - 1;
- command_table->Prdt[0].Ie = 1;
+ command_table->Prdt[0].Ie = NO;
volatile FisRegH2D* h2d_fis = (volatile FisRegH2D*)(&command_table->Cfis[0]);
@@ -300,6 +299,8 @@ STATIC Bool drv_std_init_ahci(UInt16& pi, BOOL& atapi)
kSATADev.EnableMmio();
kSATADev.BecomeBusMaster();
+ HAL::mm_map_page((VoidPtr)mem_ahci, (VoidPtr)mem_ahci, HAL::kMMFlagsPresent | HAL::kMMFlagsWr | HAL::kMMFlagsUncached);
+
UInt32 ports_implemented = mem_ahci->Pi;
UInt16 ahci_index = 0;
diff --git a/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc
index fc608e94..cc8c92d8 100644
--- a/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc
+++ b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc
@@ -28,7 +28,6 @@ using namespace Kernel::HAL;
#define kATADataLen 256
STATIC Boolean kATADetected = false;
-STATIC Int32 kATADeviceType = kATADeviceCount;
STATIC UInt16 kATAIdentifyData[kATADataLen] = {0};
STATIC Char kATADiskModel[50] = {"GENERIC PIO"};
@@ -67,6 +66,8 @@ Boolean drv_pio_std_init(UInt16 Bus, UInt8 Drive, UInt16& OutBus, UInt8& OutMast
{
UInt16 IO = Bus;
+ NE_UNUSED(Drive);
+
drv_pio_std_select(IO);
// Bus init, NEIN bit.
@@ -107,7 +108,7 @@ ATAInit_Retry:
kATADiskModel[40] = '\0';
- kout << "Drive Model: " << kATADiskModel << kendl;
+ (void)(kout << "Drive Model: " << kATADiskModel << kendl);
return true;
}