diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-03-25 15:35:28 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-03-25 15:35:28 +0100 |
| commit | 0ead895f52d24dad009f738037a7795d4e3d840a (patch) | |
| tree | 863fd1c881fc7bf26ab78b932421e6416bbef288 /dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc | |
| parent | 59dbe4cffc7c633709ef8b45f49c46daf7f74e92 (diff) | |
kernel: Refactor AHCI I/O path, enhance memory allocators, and cleanup obsolete script
- Removed unused `build_gcc.sh` script.
- Namespaced CPU feature flags under `NeOS` and transitioned from enum to unnamed enum for scoping.
- Renamed `drv_std_input_output` to `drv_std_input_output_ahci` for clarity.
- Improved AHCI driver documentation and added zeroing for read buffers.
- Added optional `pad` parameter to memory allocators: `mm_alloc_bitmap`, `mm_new_heap`, `PageMgr::Request`, etc.
- Updated bitmap allocator to correctly handle and align with padded sizes.
- Added `fPad` field to memory header block.
- Fixed `ATA-DMA` mode comment, corrected PRD usage and logic.
- Improved code documentation and formatting in `UserProcessScheduler`, `PageMgr`, and related components.
- Enhanced safety in process memory cleanup (e.g., `StackReserve` cleanup).
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc')
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc index 0a03dafc..9624ea5b 100644 --- a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc @@ -7,7 +7,7 @@ /** * @file ATA-PIO.cc * @author Amlal EL Mahrouss (amlal@nekernel.org) - * @brief ATA driver (PIO mode). + * @brief ATA driver (DMA mode). * @version 0.1 * @date 2024-02-02 * @@ -131,17 +131,15 @@ Boolean drv_std_init(UInt16 Bus, UInt8 Drive, UInt16& OutBus, UInt8& OutMaster) return NO; } -namespace Detail +namespace NeOS::Detail { - using namespace NeOS; - struct PRDEntry { UInt32 mAddress; UInt16 mByteCount; UInt16 mFlags; }; -} // namespace Detail +} // namespace NeOS::Detail static UIntPtr kReadAddr = mib_cast(2); static UIntPtr kWriteAddr = mib_cast(4); @@ -151,7 +149,7 @@ Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorSz Lba /= SectorSz; if (Size > kib_cast(64)) - ke_panic(RUNTIME_CHECK_FAILED, "ATA-DMA only supports < 64kb DMA transfers."); + return; UInt8 Command = ((!Master) ? 0xE0 : 0xF0); @@ -168,7 +166,7 @@ Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorSz rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); - Detail::PRDEntry* prd = (Detail::PRDEntry*)(kATADevice.Bar(0x20) + 4); // The PRDEntry is not correct. + NeOS::Detail::PRDEntry* prd = (NeOS::Detail::PRDEntry*)(kATADevice.Bar(0x20) + 4); // The PRDEntry is not correct. prd->mAddress = (UInt32)(UIntPtr)kReadAddr; prd->mByteCount = Size - 1; @@ -196,7 +194,7 @@ Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorS Lba /= SectorSz; if (Size > kib_cast(64)) - ke_panic(RUNTIME_CHECK_FAILED, "ATA-DMA only supports < 64kb DMA transfers."); + return; UInt8 Command = ((!Master) ? 0xE0 : 0xF0); @@ -211,10 +209,11 @@ Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorS rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); - Detail::PRDEntry* prd = (Detail::PRDEntry*)(kATADevice.Bar(0x20) + 4); - prd->mAddress = (UInt32)(UIntPtr)kWriteAddr; - prd->mByteCount = Size - 1; - prd->mFlags = 0x8000; + NeOS::Detail::PRDEntry* prd = (NeOS::Detail::PRDEntry*)(kATADevice.Bar(0x20) + 4); + + prd->mAddress = (UInt32)(UIntPtr)kWriteAddr; + prd->mByteCount = Size - 1; + prd->mFlags = 0x8000; rt_out32(kATADevice.Bar(0x20) + 0x04, (UInt32)(UIntPtr)prd); rt_out8(kATADevice.Bar(0x20) + ATA_REG_COMMAND, ATA_CMD_WRITE_DMA); @@ -230,21 +229,28 @@ Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorS prd = nullptr; } -/// @brief is ATA detected? +/***********************************************************************************/ +/// @brief Is ATA detected? +/***********************************************************************************/ Boolean drv_std_detected(Void) { return kATADetected; } +/***********************************************************************************/ /*** - @brief Getter, gets the number of sectors inside the drive. + @brief Gets the number of sectors inside the drive. + @return Number of sectors, or zero. */ +/***********************************************************************************/ NeOS::SizeT drv_get_sector_count() { return (kATAData[61] << 16) | kATAData[60]; } -/// @brief Get the drive size. +/***********************************************************************************/ +/// @brief Get the size of the current drive. +/***********************************************************************************/ NeOS::SizeT drv_get_size() { return (drv_get_sector_count()) * kATASectorSize; |
