From 2ead335ccc7afd8e1b2a6533e966c10f49fbdfe9 Mon Sep 17 00:00:00 2001 From: Amlal Date: Mon, 28 Apr 2025 09:06:35 +0200 Subject: dev, kernel: HeFS, Tooling: reworked the mkfs.hefs tool for the new filesystem. other/related: - Add new KPC codes. - Final refactors for HeFS's Format method. - Dma pool improvements. - Better standard disk I/O names. - Add mm_memory_fence function inside HalPagingMgrAMD64.cc Signed-off-by: Amlal --- dev/kernel/StorageKit/DmaPool.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'dev/kernel/StorageKit') diff --git a/dev/kernel/StorageKit/DmaPool.h b/dev/kernel/StorageKit/DmaPool.h index 9e59910a..09851a0c 100644 --- a/dev/kernel/StorageKit/DmaPool.h +++ b/dev/kernel/StorageKit/DmaPool.h @@ -23,6 +23,7 @@ #pragma once #include +#include "NewKit/Defines.h" #ifdef __NE_AMD64__ #define NE_DMA_POOL_START (0x1000000) @@ -30,11 +31,14 @@ namespace Kernel { /// @brief DMA pool base pointer, here we're sure that AHCI or whatever tricky standard sees it. -inline UInt8* kDmaPoolPtr = (UInt8*) NE_DMA_POOL_START; +inline UInt8* kDmaPoolPtr = (UInt8*) NE_DMA_POOL_START; +inline const UInt8* kDmaPoolEnd = (UInt8*) (NE_DMA_POOL_START + NE_DMA_POOL_SIZE); +/***********************************************************************************/ /// @brief allocate from the rtl_dma_alloc system. /// @param size the size of the chunk to allocate. /// @param align alignement of pointer. +/***********************************************************************************/ inline VoidPtr rtl_dma_alloc(SizeT size, SizeT align) { if (!size) { return nullptr; @@ -42,11 +46,14 @@ inline VoidPtr rtl_dma_alloc(SizeT size, SizeT align) { UIntPtr addr = (UIntPtr) kDmaPoolPtr; - /// here we just align the address according to a `align` variable, i'd rather be a power of two really. + /// here we just align the address according to a `align` variable, i'd rather be a power of two + /// really. addr = (addr + (align - 1)) & ~(align - 1); - if ((addr + size) >= (NE_DMA_POOL_START + NE_DMA_POOL_SIZE)) { - kout << "DMA Pool exhausted!\r"; + if ((addr + size) >= reinterpret_cast(kDmaPoolEnd)) { + kout << "DMA Pool is exhausted!\r"; + + err_global_get() = kErrorDmaExhausted; return nullptr; } @@ -55,12 +62,18 @@ inline VoidPtr rtl_dma_alloc(SizeT size, SizeT align) { return (VoidPtr) addr; } +/***********************************************************************************/ +/// @brief Free DMA pointer. +/***********************************************************************************/ inline Void rtl_dma_free(SizeT size) { if (!size) return; kDmaPoolPtr = (UInt8*) (kDmaPoolPtr - size); } +/***********************************************************************************/ +/// @brief Flush DMA pointer. +/***********************************************************************************/ inline Void rtl_dma_flush(VoidPtr ptr, SizeT size_buffer) { if (ptr > (Void*) (NE_DMA_POOL_START + NE_DMA_POOL_SIZE)) { return; -- cgit v1.2.3