summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dev/Boot/amd64-desktop.make4
-rw-r--r--dev/Boot/src/HEL/AMD64/BootATA.cc4
-rw-r--r--dev/Kernel/FSKit/NeFS.h8
-rw-r--r--dev/Kernel/FirmwareKit/EFI/EFI.h28
-rw-r--r--dev/Kernel/HALKit/AMD64/PCI/Device.cc2
-rw-r--r--dev/Kernel/HALKit/AMD64/Storage/ATA.cc4
-rw-r--r--dev/Kernel/HALKit/AMD64/Storage/SATA.cc174
-rw-r--r--dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc6
-rw-r--r--dev/Kernel/KernelKit/HardwareThreadScheduler.h2
-rw-r--r--dev/Kernel/KernelKit/LoaderInterface.h6
-rw-r--r--dev/Kernel/KernelKit/PCI/DMA.h2
-rw-r--r--dev/Kernel/KernelKit/UserProcessScheduler.h2
-rw-r--r--dev/Kernel/NewKit/Macros.h2
-rw-r--r--dev/Kernel/src/FS/NeFS.cc8
-rw-r--r--dev/Mod/AHCI/AHCI.h8
15 files changed, 131 insertions, 129 deletions
diff --git a/dev/Boot/amd64-desktop.make b/dev/Boot/amd64-desktop.make
index c257243c..73d5a0cc 100644
--- a/dev/Boot/amd64-desktop.make
+++ b/dev/Boot/amd64-desktop.make
@@ -83,13 +83,13 @@ compile-amd64:
.PHONY: run-efi-amd64-ahci
run-efi-amd64-ahci:
$(EMU) $(EMU_FLAGS) -M q35 -drive file=$(IMG),format=raw,if=none,id=disk \
- -device ich9-ahci,id=ahci \
+ -device ahci,id=ahci \
-device ide-hd,drive=disk,bus=ahci.0 \
-s -S
.PHONY: run-efi-amd64-ata
run-efi-amd64-ata:
- $(EMU) $(EMU_FLAGS) -M q35 -enable-kvm -device piix4-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -s -S
+ $(EMU) $(EMU_FLAGS) -M q35 -device piix4-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -s -S
# img_2 is the rescue disk. img is the bootable disk, as provided by the Zeta specs.
.PHONY: epm-img
diff --git a/dev/Boot/src/HEL/AMD64/BootATA.cc b/dev/Boot/src/HEL/AMD64/BootATA.cc
index ca0f79e6..9b649b36 100644
--- a/dev/Boot/src/HEL/AMD64/BootATA.cc
+++ b/dev/Boot/src/HEL/AMD64/BootATA.cc
@@ -124,7 +124,7 @@ Void boot_ata_read(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeUTF8* Buf,
rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz));
- rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ rt_out8(IO + ATA_REG_LBA0, (Lba)&0xFF);
rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);
@@ -154,7 +154,7 @@ Void boot_ata_write(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeUTF8* Buf,
rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + (SectorSz)) / SectorSz));
- rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ rt_out8(IO + ATA_REG_LBA0, (Lba)&0xFF);
rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);
diff --git a/dev/Kernel/FSKit/NeFS.h b/dev/Kernel/FSKit/NeFS.h
index 26529241..fc2351de 100644
--- a/dev/Kernel/FSKit/NeFS.h
+++ b/dev/Kernel/FSKit/NeFS.h
@@ -276,8 +276,8 @@ namespace Kernel
/// @param name the fork name.
/// @return the fork.
_Output NFS_FORK_STRUCT* FindFork(_Input NFS_CATALOG_STRUCT* catalog,
- _Input const Char* name,
- Boolean data);
+ _Input const Char* name,
+ Boolean data);
_Output Void RemoveFork(_Input NFS_FORK_STRUCT* fork);
@@ -287,7 +287,7 @@ namespace Kernel
_Output NFS_CATALOG_STRUCT* GetCatalog(_Input const Char* name);
- _Output NFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name,
+ _Output NFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name,
_Input const Int32& flags,
_Input const Int32& kind);
@@ -302,7 +302,7 @@ namespace Kernel
_Output VoidPtr ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
_Input Bool isRsrcFork,
_Input SizeT dataSz,
- _Input const Char* forkName);
+ _Input const Char* forkName);
_Output Bool Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off);
diff --git a/dev/Kernel/FirmwareKit/EFI/EFI.h b/dev/Kernel/FirmwareKit/EFI/EFI.h
index bef18e33..4f601d29 100644
--- a/dev/Kernel/FirmwareKit/EFI/EFI.h
+++ b/dev/Kernel/FirmwareKit/EFI/EFI.h
@@ -52,7 +52,7 @@ typedef Char16 EfiChar16Type;
/// Self is like NT's Win32 HANDLE type.
typedef struct EfiHandle
{
-}* EfiHandlePtr;
+} * EfiHandlePtr;
/* UEFI uses wide characters by default. */
typedef WideChar EfiCharType;
@@ -582,15 +582,15 @@ typedef struct
typedef EfiStatusType(EFI_API* EfiInputReadKey)(
IN EfiSimpleTextInputProtocol* This,
- OUT EfiInputKey* Key);
+ OUT EfiInputKey* Key);
typedef EfiStatusType(EFI_API* EfiInputReset)(
IN EfiSimpleTextInputProtocol* This,
IN Boolean ExtendedChk);
typedef EfiStatusType(EFI_API* EfiWaitForEvent)(
- IN UInt32 NumberOfEvents,
- IN VoidPtr Event,
+ IN UInt32 NumberOfEvents,
+ IN VoidPtr Event,
OUT UInt32* Index);
typedef struct EfiSimpleTextInputProtocol
@@ -646,7 +646,7 @@ typedef struct EfiSystemTable
{
EfiGUID VendorGUID;
VoidPtr VendorTable;
- }* ConfigurationTable;
+ } * ConfigurationTable;
} EfiSystemTable;
#define kEfiOk 0
@@ -878,11 +878,11 @@ typedef struct _EfiProcessorInformation
typedef EfiStatusType EFI_API (*EfiMpServicesGetNumberOfProcessors)(
IN struct _EfiMpServicesProtocol* Self,
- OUT UInt32* NumberOfProcessors,
- OUT UInt32* NumberOfEnabledProcessors);
+ OUT UInt32* NumberOfProcessors,
+ OUT UInt32* NumberOfEnabledProcessors);
typedef EfiStatusType EFI_API (*EfiMpServicesGetProcessorInfo)(
- IN struct _EfiMpServicesProtocol* Self,
+ IN struct _EfiMpServicesProtocol* Self,
IN UInt32* ProcessorNumber,
OUT struct _EfiProcessorInformation* NumberOfEnabledProcessors);
@@ -895,8 +895,8 @@ typedef EfiStatusType EFI_API (*EfiMpServicesStartupAllAPS)(
IN Boolean SingleThread,
IN VoidPtr WaitEvent OPTIONAL, // EFI_EVENT first, but unused here.
IN UInt32 TimeoutInMicroSeconds,
- IN Void* ProcedureArgument OPTIONAL,
- OUT UInt32** FailedCpuList OPTIONAL);
+ IN Void* ProcedureArgument OPTIONAL,
+ OUT UInt32** FailedCpuList OPTIONAL);
typedef EfiStatusType EFI_API (*EfiMpServicesSwitchBSP)(
IN struct _EfiMpServicesProtocol* Self,
@@ -909,18 +909,18 @@ typedef EfiStatusType EFI_API (*EfiMpServicesStartupThisAP)(
IN UInt32 ProcessorNumber,
IN VoidPtr WaitEvent OPTIONAL,
IN UInt32 TimeoutInMicroseconds,
- IN Void* ProcedureArgument OPTIONAL,
- OUT Boolean* Finished OPTIONAL);
+ IN Void* ProcedureArgument OPTIONAL,
+ OUT Boolean* Finished OPTIONAL);
typedef EfiStatusType EFI_API (*EfiMpServicesDisableThisAP)(
IN struct _EfiMpServicesProtocol* Self,
IN UInt32 ProcessorNumber,
IN Boolean EnableAP,
- IN UInt32* HealthFlag OPTIONAL);
+ IN UInt32* HealthFlag OPTIONAL);
typedef EfiStatusType EFI_API (*EfiMpServicesWhoAmI)(
IN struct _EfiMpServicesProtocol* Self,
- OUT UInt32* ProcessorNumber);
+ OUT UInt32* ProcessorNumber);
typedef struct _EfiMpServicesProtocol
{
diff --git a/dev/Kernel/HALKit/AMD64/PCI/Device.cc b/dev/Kernel/HALKit/AMD64/PCI/Device.cc
index 7b0f64b3..d02c7e22 100644
--- a/dev/Kernel/HALKit/AMD64/PCI/Device.cc
+++ b/dev/Kernel/HALKit/AMD64/PCI/Device.cc
@@ -106,7 +106,7 @@ namespace Kernel::PCI
void Device::EnableMmio(UInt32 bar_in)
{
- bool enable = Read(bar_in, sizeof(UChar)) | (1 << 1);
+ bool enable = Read(bar_in, sizeof(UShort)) | (1 << 1);
Write(bar_in, enable, sizeof(UShort));
}
diff --git a/dev/Kernel/HALKit/AMD64/Storage/ATA.cc b/dev/Kernel/HALKit/AMD64/Storage/ATA.cc
index 0e1120a2..9b16d866 100644
--- a/dev/Kernel/HALKit/AMD64/Storage/ATA.cc
+++ b/dev/Kernel/HALKit/AMD64/Storage/ATA.cc
@@ -157,7 +157,7 @@ Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorSz
rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz - 1) / SectorSz));
- rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ rt_out8(IO + ATA_REG_LBA0, (Lba)&0xFF);
rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);
@@ -209,7 +209,7 @@ Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorS
rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + (SectorSz - 1)) / SectorSz));
- rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ rt_out8(IO + ATA_REG_LBA0, (Lba)&0xFF);
rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);
diff --git a/dev/Kernel/HALKit/AMD64/Storage/SATA.cc b/dev/Kernel/HALKit/AMD64/Storage/SATA.cc
index 66793b3e..71161ed4 100644
--- a/dev/Kernel/HALKit/AMD64/Storage/SATA.cc
+++ b/dev/Kernel/HALKit/AMD64/Storage/SATA.cc
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
------------------------------------------- */
@@ -15,7 +15,6 @@
*
*/
-#include <stdint.h>
#include <KernelKit/UserProcessScheduler.h>
#include <KernelKit/LPC.h>
@@ -48,10 +47,9 @@ enum
};
STATIC Kernel::PCI::Device kPCIDevice;
-STATIC HbaMem* kSATAPort = nullptr;
+STATIC HbaMem* kSATAPort = nullptr;
STATIC Kernel::SizeT kSATAPortIdx = 0UL;
STATIC Kernel::Lba kCurrentDiskSectorCount = 0UL;
-STATIC Kernel::Char kModel[41] = {0};
template <BOOL Write, BOOL CommandOrCTRL, BOOL Identify>
static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buffer, Kernel::SizeT sector_sz, Kernel::SizeT size_buffer) noexcept;
@@ -64,28 +62,14 @@ static Kernel::Void drv_calculate_disk_geometry() noexcept
{
kCurrentDiskSectorCount = 0UL;
- Kernel::UInt8 identify_data[256] = {0};
+ Kernel::UInt8 identify_data[kib_cast(4)] = {};
- drv_std_input_output<NO, YES, YES>(0, identify_data, 0, 256);
+ drv_std_input_output<NO, YES, YES>(0, identify_data, 0, kib_cast(8));
- Kernel::UInt32 lba28_sectors = (identify_data[61] << 16) | identify_data[60];
+ kCurrentDiskSectorCount = (identify_data[61] << 16) | identify_data[60];
- kCurrentDiskSectorCount = lba28_sectors;
-
- Kernel::UInt32 i = 0;
-
- for (i = 0; i < 20; i++)
- {
- // 20 words = 40 bytes
- kModel[i * 2] = identify_data[27 + i] >> 8; // High byte first
- kModel[i * 2 + 1] = identify_data[27 + i] & 0xFF; // Low byte
- }
-
- kModel[40] = '\0'; // Null-terminate
-
- kcout << "Disk Model: " << kModel << endl;
kcout << "Disk Size: " << Kernel::number(drv_get_size()) << endl;
- kcout << "Disk Highest LBA: " << Kernel::number(kCurrentDiskSectorCount) << endl;
+ kcout << "Highest Disk LBA: " << Kernel::number(kCurrentDiskSectorCount) << endl;
}
/// @brief Initializes an AHCI disk.
@@ -105,11 +89,11 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented)
if (kPCIDevice.Subclass() == kSATASubClass &&
kPCIDevice.ProgIf() == kSATAProgIfAHCI)
{
- HbaMem* mem_ahci = (HbaMem*)kPCIDevice.Bar(kSATABar5);
-
kPCIDevice.EnableMmio(kSATABar5); // Enable the memory index_byte/o for this ahci device.
kPCIDevice.BecomeBusMaster(kSATABar5); // Become bus master for this ahci device, so that we can control it.
+ HbaMem* mem_ahci = (HbaMem*)kPCIDevice.Bar(kSATABar5);
+
Kernel::UInt32 ports_implemented = mem_ahci->Pi;
Kernel::UInt16 ahci_index = 0;
@@ -131,42 +115,72 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented)
if (mem_ahci->Ports[ahci_index].Sig == kSATASignature && det == 3 && ipm == 1)
{
- kcout << "Port is SATA.\r";
+ kcout << "Port is implemented as SATA.\r";
kSATAPortIdx = ahci_index;
kSATAPort = mem_ahci;
- // Enable AHCI Mode FIRST
- kSATAPort->Ghc |= (1 << 31);
+ kSATAPort->Ports[kSATAPortIdx].Cmd &= ~kHBAPxCmdST;
+ kSATAPort->Ports[kSATAPortIdx].Cmd &= ~kHBAPxCmdFre;
- const int timeout = 1000000;
- int attempts = 0;
- while ((kSATAPort->Ports[kSATAPortIdx].Tfd & 0x80) && (attempts < timeout))
+ while (YES)
{
- attempts++;
+ if (kSATAPort->Ports[kSATAPortIdx].Cmd & kHBAPxCmdFR)
+ continue;
+
+ if (kSATAPort->Ports[kSATAPortIdx].Cmd & kHBAPxCmdCR)
+ continue;
+
+ break;
}
- if (attempts == timeout)
+
+ const auto kAHCIBaseAddress = mib_cast(4);
+
+ kSATAPort->Ports[kSATAPortIdx].Clb = kAHCIBaseAddress + (kSATAPortIdx << 10);
+ kSATAPort->Ports[kSATAPortIdx].Clbu = 0;
+
+ rt_set_memory((VoidPtr)((UIntPtr)kSATAPort->Ports[kSATAPortIdx].Clb), 0, 1024);
+
+ kSATAPort->Ports[kSATAPortIdx].Fb = kAHCIBaseAddress + (32 << 10) + (kSATAPortIdx << 8);
+ kSATAPort->Ports[kSATAPortIdx].Fbu = 0;
+
+ rt_set_memory((VoidPtr)((UIntPtr)kSATAPort->Ports[kSATAPortIdx].Fb), 0, 256);
+
+ HbaCmdHeader* cmd_header = (HbaCmdHeader*)((UIntPtr)kSATAPort->Ports[kSATAPortIdx].Clb);
+
+ for (Int32 i = 0; i < 32; i++)
{
- kcout << "Error: Drive is still busy after waiting.\r";
- return NO;
+ cmd_header[i].Prdtl = 8;
+
+ cmd_header[i].Ctba = kAHCIBaseAddress + (40 << 10) + (kSATAPortIdx << 13) + (i << 8);
+ cmd_header[i].Ctbau = 0;
+
+ rt_set_memory((VoidPtr)(UIntPtr)cmd_header[i].Ctba, 0, 256);
}
- kSATAPort->Ports[kSATAPortIdx].Cmd |= kHBAPxCmdST;
+ while (kSATAPort->Ports[kSATAPortIdx].Cmd & kHBAPxCmdCR)
+ ;
+
kSATAPort->Ports[kSATAPortIdx].Cmd |= kHBAPxCmdFre;
+ kSATAPort->Ports[kSATAPortIdx].Cmd |= kHBAPxCmdST;
drv_calculate_disk_geometry();
- return YES;
+ detected = YES;
+
+ break;
}
}
ports_implemented >>= 1;
++ahci_index;
}
+
+ return detected;
}
}
- return NO;
+ return No;
}
Kernel::Boolean drv_std_detected(Kernel::Void)
@@ -189,14 +203,14 @@ static Kernel::Int32 drv_find_cmd_slot(HbaPort* port) noexcept
if (port == nullptr)
return -1;
- kcout << "Finding a slot...\r";
-
Kernel::UInt32 slots = (kSATAPort->Ports[kSATAPortIdx].Sact | kSATAPort->Ports[kSATAPortIdx].Ci);
for (Kernel::Int32 i = 0; i < ((kSATAPort->Cap & 0x1F) + 1); i++)
{
- if ((slots & (1 << i)) == 0)
+ if ((slots & 1) == 0)
return i;
+
+ slots >>= 1;
}
return -1;
@@ -205,6 +219,11 @@ static Kernel::Int32 drv_find_cmd_slot(HbaPort* port) noexcept
template <BOOL Write, BOOL CommandOrCTRL, BOOL Identify>
static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buffer, Kernel::SizeT sector_sz, Kernel::SizeT size_buffer) noexcept
{
+ if (!CommandOrCTRL)
+ return;
+
+ kSATAPort->Ports[kSATAPortIdx].Is = -1;
+
auto slot = 0L;
slot = drv_find_cmd_slot(&kSATAPort->Ports[kSATAPortIdx]);
@@ -212,43 +231,35 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff
if (slot == -1)
return;
- if (size_buffer > kib_cast(8))
- return;
+ volatile HbaCmdHeader* command_header = ((volatile HbaCmdHeader*)((Kernel::UInt64)kSATAPort->Ports[kSATAPortIdx].Clb + kSATAPort->Ports[kSATAPortIdx].Clbu));
- volatile HbaCmdHeader* command_header = ((volatile HbaCmdHeader*)((Kernel::UInt64)kSATAPort->Ports[kSATAPortIdx].Clb));
command_header += slot;
MUST_PASS(command_header);
command_header->Cfl = sizeof(FisRegH2D) / sizeof(Kernel::UInt32);
command_header->Write = Write;
- command_header->Prdtl = (Kernel::UInt16)(kib_cast(8) - 1) >> 4 + 1;
-
- volatile HbaCmdTbl* command_table = (volatile HbaCmdTbl*)((Kernel::UInt64)command_header->Ctba);
+ command_header->Prdtl = (Kernel::UInt16)((size_buffer - 1) >> 4) + 1;
- Kernel::rt_set_memory((void*)command_table, 0, sizeof(HbaCmdTbl));
+ volatile HbaCmdTbl* command_table = (volatile HbaCmdTbl*)((Kernel::UInt64)command_header->Ctba + command_header->Ctbau);
MUST_PASS(command_table);
- Kernel::UInt8* buffer_ahci = new Kernel::UInt8[kib_cast(8)];
-
- Kernel::Int32 i = 0;
-
- command_table->Prdt[0].Dba = (uint32_t)(uint64_t)buffer_ahci & 0xFFFFFFFF;
- command_table->Prdt[0].Dbau = (uint32_t)(uint64_t)buffer_ahci >> 32;
- command_table->Prdt[0].Dbc = (size_buffer << 9) - 1; // 512 bytes per sector
- command_table->Prdt[0].InterruptBit = 1;
+ for (Kernel::SizeT i = 0; i < (command_header->Prdtl - 1); i++)
+ {
+ command_table->PrdtEntries[i].Dba = ((Kernel::UInt32)(Kernel::UInt64)buffer & 0xFFFFFFFF);
+ command_table->PrdtEntries[i].Dbau = (((Kernel::UInt64)buffer >> 32) & 0xFFFFFFFF);
+ command_table->PrdtEntries[i].Dbc = (size_buffer - 1);
+ command_table->PrdtEntries[i].InterruptBit = YES;
- kcout << "LBA: " << Kernel::hex_number(lba) << endl;
- kcout << "PRDT Entry - Dba (Low): " << Kernel::hex_number(command_table->Prdt[0].Dba) << endl;
- kcout << "PRDT Entry - DbaU (High): " << Kernel::hex_number(command_table->Prdt[0].Dbau) << endl;
- kcout << "PRDT Entry - Dbc: " << Kernel::hex_number(command_table->Prdt[0].Dbc) << endl;
+ size_buffer -= 16;
+ buffer += kib_cast(4);
+ }
- volatile FisRegH2D* h2d_fis = (volatile FisRegH2D*)(&command_table->Cfis);
+ volatile FisRegH2D* h2d_fis = (volatile FisRegH2D*)((Kernel::UInt64)command_table->Cfis);
- Kernel::rt_set_memory((void*)h2d_fis, 0, sizeof(FisRegH2D));
+ h2d_fis->FisType = kFISTypeRegH2D;
- h2d_fis->FisType = 0x27; // H2D
h2d_fis->CmdOrCtrl = CommandOrCTRL;
h2d_fis->Command = Write ? kAHCICmdWriteDmaEx : kAHCICmdReadDmaEx;
@@ -256,45 +267,36 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff
if (Identify)
h2d_fis->Command = kAHCICmdIdentify;
- h2d_fis->Lba0 = (Kernel::UInt32)(lba) & 0xFF;
- h2d_fis->Lba1 = (Kernel::UInt8)(lba >> 8) & 0xFF;
- h2d_fis->Lba2 = (Kernel::UInt8)(lba >> 16) & 0xFF;
+ h2d_fis->Lba0 = lba;
+ h2d_fis->Lba1 = lba >> 8;
+ h2d_fis->Lba2 = lba >> 16;
+ h2d_fis->Lba3 = lba >> 24;
- h2d_fis->Lba3 = (Kernel::UInt8)(lba >> 24) & 0xFF;
- h2d_fis->Lba4 = (Kernel::UInt8)(lba >> 32) & 0xFF;
- h2d_fis->Lba5 = (Kernel::UInt8)(lba >> 40) & 0xFF;
+ h2d_fis->Device = kSataLBAMode;
- h2d_fis->Device = 0; // master device.
+ // 28-bit LBA mode, fis is done being configured.
h2d_fis->CountLow = sector_sz & 0xFF;
h2d_fis->CountHigh = (sector_sz >> 8) & 0xFF;
while ((kSATAPort->Ports[kSATAPortIdx].Tfd & (kAhciSRBsy | kAhciSRDrq)))
{
- kcout << "waiting for slot to be ready\r\n";
+ kcout << "Waiting for slot to be ready...\r\n";
}
- Kernel::UInt32 ahci_status = kSATAPort->Ports[kSATAPortIdx].Tfd;
- kcout << "AHCI Status Before Write: " << Kernel::hex_number(ahci_status) << endl;
+ if (kSATAPort->Is & kHBAErrTaskFile)
+ Kernel::ke_panic(RUNTIME_CHECK_BAD_BEHAVIOR, "AHCI Read disk failure, faulty component.");
- kSATAPort->Ports[kSATAPortIdx].Ci = 1 << slot;
+ // send fis/cmdtbl/cmdhdr.
+ kSATAPort->Ports[kSATAPortIdx].Ci |= 1 << slot;
while (kSATAPort->Ports[kSATAPortIdx].Ci & (1 << slot))
+ ;
+
+ while ((kSATAPort->Ports[kSATAPortIdx].Tfd & (kAhciSRBsy | kAhciSRDrq)))
{
- Kernel::UInt32 tfd = kSATAPort->Ports[kSATAPortIdx].Tfd;
- kcout << "AHCI TFD: " << Kernel::number(tfd) << endl;
+ kcout << "Waiting for slot to be ready...\r\n";
}
-
- kcout << "Last Command Sent: " << (int)Kernel::number(h2d_fis->Command) << endl;
-
- ahci_status = kSATAPort->Ports[kSATAPortIdx].Tfd;
-
- kcout << "AHCI Status After Write: " << Kernel::hex_number(ahci_status) << endl;
- kcout << "AHCI STSS: " << Kernel::hex_number(kSATAPort->Ports[kSATAPortIdx].Ssts) << endl;
- kcout << "AHCI SERR: " << Kernel::hex_number(kSATAPort->Ports[kSATAPortIdx].Serr) << endl;
-
- Kernel::rt_copy_memory(buffer_ahci, buffer, size_buffer);
- delete[] buffer_ahci;
}
/***
diff --git a/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc b/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc
index bcde2435..6b4d7ab4 100644
--- a/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc
+++ b/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc
@@ -22,9 +22,9 @@ namespace Kernel
constexpr auto kFlashBridgeMagic = "FLSH";
constexpr auto kFlashBridgeRevision = 1;
- STATIC BOOL kFlashEnabled = NO;
- STATIC SizeT kFlashSize[kMaxFlashSlots] = {};
- STATIC SizeT kFlashSectorSz[kMaxFlashSlots] = {};
+ STATIC BOOL kFlashEnabled = NO;
+ STATIC SizeT kFlashSize[kMaxFlashSlots] = {};
+ STATIC SizeT kFlashSectorSz[kMaxFlashSlots] = {};
STATIC IMBCIHost* kFlashMetaPackets[kMaxFlashSlots] = {};
STATIC IMBCIHost* kFlashDataPackets[kMaxFlashSlots] = {};
diff --git a/dev/Kernel/KernelKit/HardwareThreadScheduler.h b/dev/Kernel/KernelKit/HardwareThreadScheduler.h
index 81a137e1..56fc57ff 100644
--- a/dev/Kernel/KernelKit/HardwareThreadScheduler.h
+++ b/dev/Kernel/KernelKit/HardwareThreadScheduler.h
@@ -105,7 +105,7 @@ namespace Kernel
public:
Ref<HardwareThread*> operator[](const SizeT& idx);
bool operator!() noexcept;
- operator bool() noexcept;
+ operator bool() noexcept;
const Bool IsUser() override
{
diff --git a/dev/Kernel/KernelKit/LoaderInterface.h b/dev/Kernel/KernelKit/LoaderInterface.h
index 29a1b928..c2c9a595 100644
--- a/dev/Kernel/KernelKit/LoaderInterface.h
+++ b/dev/Kernel/KernelKit/LoaderInterface.h
@@ -25,9 +25,9 @@ namespace Kernel
public:
virtual _Output ErrorOr<VoidPtr> GetBlob() = 0;
- virtual _Output const Char* AsString() = 0;
- virtual _Output const Char* MIME() = 0;
- virtual _Output const Char* Path() = 0;
+ virtual _Output const Char* AsString() = 0;
+ virtual _Output const Char* MIME() = 0;
+ virtual _Output const Char* Path() = 0;
virtual _Output ErrorOr<VoidPtr> FindStart() = 0;
virtual _Output VoidPtr FindSymbol(_Input const Char* name, _Input Int32 kind) = 0;
};
diff --git a/dev/Kernel/KernelKit/PCI/DMA.h b/dev/Kernel/KernelKit/PCI/DMA.h
index 0ad2c344..b4bbc570 100644
--- a/dev/Kernel/KernelKit/PCI/DMA.h
+++ b/dev/Kernel/KernelKit/PCI/DMA.h
@@ -52,7 +52,7 @@ namespace Kernel
T* Get(const UIntPtr off = 0);
public:
- operator bool();
+ operator bool();
bool operator!();
public:
diff --git a/dev/Kernel/KernelKit/UserProcessScheduler.h b/dev/Kernel/KernelKit/UserProcessScheduler.h
index 98488226..b1022fb1 100644
--- a/dev/Kernel/KernelKit/UserProcessScheduler.h
+++ b/dev/Kernel/KernelKit/UserProcessScheduler.h
@@ -288,7 +288,7 @@ namespace Kernel
ZKA_COPY_DEFAULT(UserProcessScheduler)
- operator bool();
+ operator bool();
bool operator!();
public:
diff --git a/dev/Kernel/NewKit/Macros.h b/dev/Kernel/NewKit/Macros.h
index f2a92b68..236201be 100644
--- a/dev/Kernel/NewKit/Macros.h
+++ b/dev/Kernel/NewKit/Macros.h
@@ -11,7 +11,7 @@
#endif
#ifndef kib_cast
-#define kib_cast(X) (Kernel::UInt64)((X) * 1024)
+#define kib_cast(X) (Kernel::UInt64)((X)*1024)
#endif
#ifndef MIB
diff --git a/dev/Kernel/src/FS/NeFS.cc b/dev/Kernel/src/FS/NeFS.cc
index e0561d21..ecfafab4 100644
--- a/dev/Kernel/src/FS/NeFS.cc
+++ b/dev/Kernel/src/FS/NeFS.cc
@@ -168,8 +168,8 @@ _Output BOOL NeFileSystemParser::CreateFork(_Input NFS_FORK_STRUCT& the_fork)
/// @return the fork.
/***********************************************************************************/
_Output NFS_FORK_STRUCT* NeFileSystemParser::FindFork(_Input NFS_CATALOG_STRUCT* catalog,
- _Input const Char* name,
- Boolean isDataFork)
+ _Input const Char* name,
+ Boolean isDataFork)
{
auto drive = kMountpoint.A();
NFS_FORK_STRUCT* the_fork = nullptr;
@@ -234,7 +234,7 @@ _Output NFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char*
/// @param kind the catalog kind.
/// @return catalog pointer.
/***********************************************************************************/
-_Output NFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char* name,
+_Output NFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char* name,
_Input const Int32& flags,
_Input const Int32& kind)
{
@@ -943,7 +943,7 @@ Boolean NeFileSystemParser::RemoveCatalog(_Input const Char* catalog_name)
VoidPtr NeFileSystemParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
_Input Bool is_rsrc_fork,
_Input SizeT dataSz,
- _Input const Char* forkName)
+ _Input const Char* forkName)
{
if (!catalog)
{
diff --git a/dev/Mod/AHCI/AHCI.h b/dev/Mod/AHCI/AHCI.h
index 4845491b..6788fb3a 100644
--- a/dev/Mod/AHCI/AHCI.h
+++ b/dev/Mod/AHCI/AHCI.h
@@ -325,10 +325,10 @@ typedef struct HbaPrdtEntry final
typedef struct HbaCmdTbl final
{
- Kernel::UInt8 Cfis[64]; // Command FIS
- Kernel::UInt8 Acmd[16]; // ATAPI command, 12 or 16 bytes
- Kernel::UInt8 Rsv[48]; // Reserved
- struct HbaPrdtEntry Prdt[1]; // Physical region descriptor table entries, 0 ~ 65535
+ Kernel::UInt8 Cfis[64]; // Command FIS
+ Kernel::UInt8 Acmd[16]; // ATAPI command, 12 or 16 bytes
+ Kernel::UInt8 Rsv[48]; // Reserved
+ struct HbaPrdtEntry PrdtEntries[1]; // Physical region descriptor table entries, 0 ~ 65535
} HbaCmdTbl;
/// @brief Initializes an AHCI disk.