summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/Boot/src/HEL/AMD64/EFIBootStartup.cc2
-rw-r--r--dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc2
-rw-r--r--dev/Kernel/HALKit/AMD64/Storage/SATA-DMA.cc67
-rw-r--r--dev/Kernel/src/DriveMgr.cc4
4 files changed, 29 insertions, 46 deletions
diff --git a/dev/Boot/src/HEL/AMD64/EFIBootStartup.cc b/dev/Boot/src/HEL/AMD64/EFIBootStartup.cc
index 5b05e1bb..f2d6276b 100644
--- a/dev/Boot/src/HEL/AMD64/EFIBootStartup.cc
+++ b/dev/Boot/src/HEL/AMD64/EFIBootStartup.cc
@@ -218,7 +218,6 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr image_handle,
syschk_thread->SetName("BootZ: System Recovery Check");
}
-#if 0
Boot::BDiskFormatFactory<BootDeviceATA> partition_factory;
if (syschk_thread->Start(handover_hdr, NO) != kEfiOk)
@@ -245,7 +244,6 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr image_handle,
fb_clear();
}
}
-#endif
// ------------------------------------------ //
// null these fields, to avoid being reused later.
diff --git a/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc b/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc
index b9da351a..ea8840eb 100644
--- a/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc
+++ b/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc
@@ -121,7 +121,7 @@ Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorSz
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/HALKit/AMD64/Storage/SATA-DMA.cc b/dev/Kernel/HALKit/AMD64/Storage/SATA-DMA.cc
index a3c1474d..5d3acd16 100644
--- a/dev/Kernel/HALKit/AMD64/Storage/SATA-DMA.cc
+++ b/dev/Kernel/HALKit/AMD64/Storage/SATA-DMA.cc
@@ -15,6 +15,7 @@
*
*/
+#include "NewKit/Defines.h"
#include <KernelKit/UserProcessScheduler.h>
#include <KernelKit/LPC.h>
@@ -166,65 +167,53 @@ Kernel::Boolean drv_std_detected(Kernel::Void)
Kernel::Void drv_std_write(Kernel::UInt64 lba, Kernel::Char* buffer, Kernel::SizeT sector_cnt, Kernel::SizeT size_buffer)
{
+ lba /= sector_cnt;
+
drv_std_input_output<YES, YES, NO>(lba, (Kernel::UInt8*)buffer, sector_cnt, size_buffer);
}
Kernel::Void drv_std_read(Kernel::UInt64 lba, Kernel::Char* buffer, Kernel::SizeT sector_cnt, Kernel::SizeT size_buffer)
{
+ lba /= sector_cnt;
+
drv_std_input_output<NO, YES, NO>(lba, (Kernel::UInt8*)buffer, sector_cnt, size_buffer);
}
template <BOOL Write, BOOL CommandOrCTRL, BOOL Identify>
static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buffer, Kernel::SizeT sector_cnt, Kernel::SizeT size_buffer)
{
- Kernel::SizeT port = 0;
- Kernel::UInt32 slots = (kAhciPort->Sact | kAhciPort->Ci);
-
- for (; port < slots; ++port)
- {
- if ((slots & 1) == 0)
- break;
-
- slots >>= 1;
- }
+ volatile HbaCmdHeader* command_header = *(HbaCmdHeader**)&kAhciPort->Clb;
- if (slots == 0)
- return;
-
- Kernel::UInt32* command_list = new Kernel::UInt32[kib_cast(1)];
- Kernel::UInt32* command_table = new Kernel::UInt32[kib_cast(4)];
-
- Kernel::rt_set_memory(command_list, 0, kib_cast(1));
- Kernel::rt_set_memory(command_table, 0, kib_cast(4));
+ command_header->Cfl = sizeof(FisRegH2D) / sizeof(Kernel::UInt32);
- auto command_table_deref = *(Kernel::UInt32*)&command_table;
+ command_header->Write = Write;
+ command_header->Prdtl = (Kernel::UInt16)((size_buffer - 1) >> 4) + 1;
- command_table[0] = *(Kernel::UInt32*)&buffer;
+ HbaCmdTbl* command_table = (HbaCmdTbl*)(command_header->Ctba);
- command_list[0] = command_table_deref;
- command_list[1] = size_buffer;
+ command_table->PrdtEntries[0].Dba = *(Kernel::UInt32*)&buffer;
+ command_table->PrdtEntries[0].Dbc = size_buffer;
+ command_table->PrdtEntries[0].InterruptBit = 1;
- volatile Kernel::UInt32* command_header = (Kernel::UInt32*)kAhciPort + 0x10;
+ FisRegH2D* h2d_fis = (FisRegH2D*)(&command_table->Cfis);
- auto command_list_deref = *(Kernel::UInt32*)&command_list;
+ h2d_fis->Command = Write ? kAHCICmdWriteDmaEx : kAHCICmdReadDmaEx;
+ h2d_fis->FisType = kFISTypeRegH2D;
+ h2d_fis->CmdOrCtrl = CommandOrCTRL;
- command_header[0] = 5 | 0 | (Write ? kAHCICmdWriteDma : kAHCICmdReadDma) | 0 | 00000000 | 1 | 00000000000;
- command_header[0] = command_header[0] | (lba & __UINT32_MAX__);
-
- command_header[1] = command_list_deref;
+ h2d_fis->Lba0 = lba & 0xFF;
+ h2d_fis->Lba1 = lba >> 8;
+ h2d_fis->Lba2 = lba >> 16;
- Kernel::UInt32* fis = command_list;
+ h2d_fis->Device = 1 << 6;
- fis[0] = kFISTypeRegH2D;
- fis[1] = CommandOrCTRL;
+ h2d_fis->Lba3 = lba >> 24;
+ h2d_fis->Lba4 = lba >> 32;
+ h2d_fis->Lba5 = lba >> 40;
- fis[2] = Identify ? kAHCICmdIdentify : kAHCICmdReadDmaEx;
+ h2d_fis->CountLow = sector_cnt & 0xFF;
+ h2d_fis->CountHigh = (sector_cnt >> 8) & 0xFF;
- if (Write)
- fis[2] = kAHCICmdWriteDmaEx;
-
- // 5. Issue the command
- // Write command issue bit
kAhciPort->Ci |= (1 << 0); // Command Issue
while (kAhciPort->Ci & (1 << 0))
@@ -251,10 +240,6 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff
return;
}
-
- delete[] command_table;
-
- command_table = nullptr;
}
/***
diff --git a/dev/Kernel/src/DriveMgr.cc b/dev/Kernel/src/DriveMgr.cc
index 4c279d0f..95e5b988 100644
--- a/dev/Kernel/src/DriveMgr.cc
+++ b/dev/Kernel/src/DriveMgr.cc
@@ -176,7 +176,7 @@ namespace Kernel
trait->fPacket.fPacketReadOnly = NO;
trait->fKind = kMassStorageDisc | kEPMDrive;
- kcout << "Formatted Disk is EPM (and Mass Storage too.)\r";
+ kcout << "Formatted Disk is EPM (Mass Storage)\r";
}
else
{
@@ -186,7 +186,7 @@ namespace Kernel
kcout << "Scheme Found: " << block_struct.Name << endl;
if (block_struct.Name[0] == 0)
- kcout << "Disk partition is unknown (Was set to Read Only.)\r";
+ kcout << "Disk partition is unknown (Read Only)\r";
}
rt_copy_memory((VoidPtr) "*/*", trait->fPacket.fPacketMime,