From 5b30cacacf0f0ca6fb06bb34389f04b05ceb2b15 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 25 May 2025 09:56:46 +0200 Subject: kernel!: lots of changes, see commit details. refactor(hal): unify file naming and drop redundant architecture suffixes feat(build): rename kernel and bootloader to 'ne_kernel' and 'ne_bootz' refactor(memory): replace mm_get_phys_address with mm_get_page_addr feat(bitmap): track bitmap allocator usage and add out-of-memory error fix(heap): correct heap magic naming and alignment logic chore(fs): downgrade HeFS disk size check to warning chore(tools): clean up formatting in 'ping' and 'manual' docs(design): update OS_DESIGN.drawio to reflect Hypr86 and new layout Signed-off-by: Amlal El Mahrouss --- dev/kernel/src/BitMapMgr.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'dev/kernel/src/BitMapMgr.cc') diff --git a/dev/kernel/src/BitMapMgr.cc b/dev/kernel/src/BitMapMgr.cc index 4301ce5b..df678d41 100644 --- a/dev/kernel/src/BitMapMgr.cc +++ b/dev/kernel/src/BitMapMgr.cc @@ -22,6 +22,8 @@ namespace Kernel { namespace HAL { namespace Detail { + STATIC SizeT kBitMapCursor = 0UL; + /***********************************************************************************/ /// \brief Proxy Interface to manage a bitmap allocator. /***********************************************************************************/ @@ -47,6 +49,8 @@ namespace HAL { UIntPtr* ptr_bit_set = reinterpret_cast(page_ptr); + kBitMapCursor += ptr_bit_set[kBitMapSizeIdx]; + ptr_bit_set[kBitMapMagIdx] = kBitMapMagic; ptr_bit_set[kBitMapUsedIdx] = No; @@ -59,7 +63,6 @@ namespace HAL { UInt32 flags = kMMFlagsPresent; if (wr) flags |= kMMFlagsWr; - if (user) flags |= kMMFlagsUser; return flags; @@ -77,11 +80,18 @@ namespace HAL { auto FindBitMap(VoidPtr base_ptr, SizeT size, Bool wr, Bool user, SizeT pad) -> VoidPtr { if (!size) return nullptr; + if (kBitMapCursor > kKernelBitMpSize) { + err_global_get() = kErrorOutOfBitMapMemory; + + (Void)(kout << "Bitmap limit reached, can't allocate more bitmaps." << kendl); + return nullptr; + } + VoidPtr base = reinterpret_cast((UIntPtr) base_ptr); MUST_PASS(base); - static SizeT biggest = 0UL; + STATIC SizeT biggest = 0UL; while (YES) { UIntPtr* ptr_bit_set = reinterpret_cast(base); @@ -99,6 +109,8 @@ namespace HAL { if (biggest < (size + pad)) biggest = size + pad; + kBitMapCursor += size + pad; + return (VoidPtr) ptr_bit_set; } } else if (ptr_bit_set[kBitMapMagIdx] != kBitMapMagic) { @@ -113,6 +125,8 @@ namespace HAL { if (biggest < (size + pad)) biggest = (size + pad); + kBitMapCursor += size + pad; + return (VoidPtr) ptr_bit_set; } -- cgit v1.2.3