diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-08 13:38:35 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-08 13:38:35 +0200 |
| commit | 2ac97283d813414973f83d177280aafa7fbaa66f (patch) | |
| tree | dfb189f320d8202bcaaea58c13e7d9e818f267ac /dev/kernel/HALKit/AMD64/Storage | |
| parent | daff01e877ba628370e506a56b4065aeb5814138 (diff) | |
kernel, storage, heap, abi: lots of improvements and tweaks.
- Please read the commit details for in-depth insights.
- Add stack smash prevention code.
- Better prevention in BitMap Mgr.
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.cc | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index e9c967dc..68a5b051 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -15,7 +15,6 @@ * */ -#include "NewKit/Defines.h" #include <KernelKit/DeviceMgr.h> #include <KernelKit/DriveMgr.h> #include <KernelKit/ProcessScheduler.h> @@ -70,7 +69,7 @@ STATIC Void drv_compute_disk_ahci() noexcept; namespace AHCI::Detail { template <typename RetType> - RetType* ahci_align_address(RetType* address, Int32 alignement) + STATIC RetType* ahci_align_address(RetType* address, Int32 alignement) { if (!address) return nullptr; @@ -91,7 +90,7 @@ STATIC Void drv_compute_disk_ahci() noexcept const UInt16 kSzIdent = 256; /// Push it to the stack - UInt16* identify_data ATTRIBUTE(aligned(kib_cast(1))) = AHCI::Detail::ahci_align_address<UInt16>(new UInt16[kSzIdent], kib_cast(1)); + UInt16* identify_data = AHCI::Detail::ahci_align_address<UInt16>(new UInt16[kSzIdent], kib_cast(1)); /// Send AHCI command for identification. drv_std_input_output_ahci<NO, YES, YES>(0, (UInt8*)identify_data, kAHCISectorSize, kSzIdent); @@ -198,8 +197,6 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz volatile FisRegH2D* h2d_fis = (volatile FisRegH2D*)(&command_table->Cfis[0]); - rt_set_memory((FisRegH2D*)h2d_fis, 0, sizeof(FisRegH2D)); - h2d_fis->FisType = kFISTypeRegH2D; h2d_fis->CmdOrCtrl = CommandOrCTRL; h2d_fis->Command = (Identify ? (kAHCICmdIdentify) : (Write ? kAHCICmdWriteDmaEx : kAHCICmdReadDmaEx)); @@ -287,40 +284,6 @@ STATIC BOOL ahci_enable_and_probe() break; } - // Command engine stopped, remap the AHCI port. - - auto port = &kSATAHba->Ports[kSATAIndex]; - - // Relocate Command List Base. - - VoidPtr const kAHCIBasePtr = AHCI::Detail::ahci_align_address<Void>(mm_new_heap(kib_cast(64), YES, NO, 0), kib_cast(1)); - UIntPtr const kAHCIBaseAddress = reinterpret_cast<UIntPtr>(kAHCIBasePtr); - - port->Clb = kAHCIBaseAddress + (kSATAIndex << 10); - port->Clbu = 0; - - // clean it. - rt_set_memory(reinterpret_cast<VoidPtr>(port->Clb), 0, 1024); - - // Relocate Frame Info Structure now. - - port->Fb = (UInt32)(UIntPtr)(UIntPtr*)AHCI::Detail::ahci_align_address<UInt32>((UInt32*)(kAHCIBaseAddress + (kSATAPortCnt << 10) + (kSATAIndex << 10)), kib_cast(1)); - port->Fbu = 0; - - // clean it. - rt_set_memory(reinterpret_cast<VoidPtr>(port->Fb), 0, 256); - - volatile HbaCmdHeader* cmd_hdr = reinterpret_cast<volatile HbaCmdHeader*>(port->Clb); - - for (Int32 i = 0; i < kSATAPortCnt; i++) - { - cmd_hdr[i].Prdtl = 8; - cmd_hdr[i].Ctba = (UInt32)(UIntPtr)(UIntPtr*)AHCI::Detail::ahci_align_address<UInt32>((UInt32*)(kAHCIBaseAddress + (40 << 10) + (kSATAPortCnt << 10) + (kSATAIndex << 10)), kib_cast(1)); - cmd_hdr[i].Ctbau = 0; - - rt_set_memory(reinterpret_cast<VoidPtr>(cmd_hdr[i].Ctba), 0, 256); - } - // Now we are ready. kSATAHba->Ports[kSATAIndex].Cmd |= kHBAPxCmdFre; |
