diff options
| author | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-11 08:52:00 +0200 |
|---|---|---|
| committer | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-11 08:52:00 +0200 |
| commit | f37c8cb8c86b73843b23d3690f1e251ec40a70b5 (patch) | |
| tree | a6737d9577a8cebdfc4c914bf334f14a6745ac5b /dev/ZKA/HALKit | |
| parent | f2aee187a4e6f4cd0743d3f2a1de19fdcb1856c6 (diff) | |
IMP: Add FreeBitMap method in IBitMapAllocator.
IMP: Using a better memory strategy than a pre-allocated chunk of memory.
FIX: Moved compile_flags.txt only at root directory.
FIX: Refactor HandoverInformationHeader to HANDOVER_INFO_HEADER.
IMP: Handover version 1.16.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/ZKA/HALKit')
| -rw-r--r-- | dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx | 63 | ||||
| -rw-r--r-- | dev/ZKA/HALKit/AMD64/HalKernelMain.cxx | 2 | ||||
| -rw-r--r-- | dev/ZKA/HALKit/ARM64/HalKernelMain.cxx | 2 | ||||
| -rw-r--r-- | dev/ZKA/HALKit/compile_flags.txt | 6 |
4 files changed, 35 insertions, 38 deletions
diff --git a/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx b/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx index 71c8cb61..57565b5b 100644 --- a/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx +++ b/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx @@ -23,8 +23,35 @@ namespace Kernel { namespace Detail { - struct AllocatorTraits final + struct IBitMapAllocator final { + Bool FreeBitMap(VoidPtr page_ptr) + { + if (!page_ptr) return No; + + UIntPtr* ptr_bit_set = reinterpret_cast<UIntPtr*>(page_ptr); + + if (!ptr_bit_set[0] || + ptr_bit_set[0] != cBitMpMagic) + return No; + + kcout << "BMPMgr: Freed Range!\r"; + kcout << "Magic Number: " << hex_number(ptr_bit_set[0]) << endl; + kcout << "Size of pointer (B): " << number(ptr_bit_set[1]) << endl; + kcout << "Size of pointer (KIB): " << number(KIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (MIB): " << number(MIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (GIB): " << number(GIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (TIB): " << number(TIB(ptr_bit_set[1])) << endl; + kcout << "Address Of Header: " << hex_number((UIntPtr)ptr_bit_set) << endl; + + ptr_bit_set[0] = cBitMpMagic; + ptr_bit_set[2] = No; + + mm_map_page(page_ptr, ~eFlagsPresent); + + return Yes; + } + /// @brief Iterate over availables pages for a free one. /// @return The new address which was found. VoidPtr FindBitMap(VoidPtr base_ptr, SizeT size, Bool rw, Bool user) noexcept @@ -35,8 +62,6 @@ namespace Kernel { UIntPtr* ptr_bit_set = reinterpret_cast<UIntPtr*>(base_ptr); - mm_map_page(ptr_bit_set, eFlagsPresent | eFlagsRw); - if (ptr_bit_set[0] == cBitMpMagic) { if (ptr_bit_set[1] != 0 && @@ -97,9 +122,6 @@ namespace Kernel } base_ptr = reinterpret_cast<VoidPtr>(reinterpret_cast<UIntPtr>(base_ptr) + (ptr_bit_set[0] != cBitMpMagic ? size : ptr_bit_set[1])); - - if (reinterpret_cast<UIntPtr>(base_ptr) >= (kHandoverHeader->f_BitMapSize + base)) - ke_stop(RUNTIME_CHECK_VIRTUAL_OUT_OF_MEM); } return nullptr; @@ -113,8 +135,8 @@ namespace Kernel /// @return auto mm_alloc_bitmap(Boolean rw, Boolean user, SizeT size) -> VoidPtr { - VoidPtr ptr_new = nullptr; - Detail::AllocatorTraits traits; + VoidPtr ptr_new = nullptr; + Detail::IBitMapAllocator traits; ptr_new = traits.FindBitMap(kKernelVirtualStart, size, rw, user); @@ -124,29 +146,10 @@ namespace Kernel auto mm_free_bitmap(VoidPtr page_ptr) -> Bool { if (!page_ptr) - return false; - - UIntPtr* ptr_bit_set = reinterpret_cast<UIntPtr*>(page_ptr); - - if (!ptr_bit_set[0] || - ptr_bit_set[0] != cBitMpMagic) - return false; - - kcout << "BMPMgr: Freed Range!\r"; - kcout << "Magic Number: " << hex_number(ptr_bit_set[0]) << endl; - kcout << "Size of pointer (B): " << number(ptr_bit_set[1]) << endl; - kcout << "Size of pointer (KIB): " << number(KIB(ptr_bit_set[1])) << endl; - kcout << "Size of pointer (MIB): " << number(MIB(ptr_bit_set[1])) << endl; - kcout << "Size of pointer (GIB): " << number(GIB(ptr_bit_set[1])) << endl; - kcout << "Size of pointer (TIB): " << number(TIB(ptr_bit_set[1])) << endl; - kcout << "Address Of Header: " << hex_number((UIntPtr)ptr_bit_set) << endl; - - ptr_bit_set[0] = cBitMpMagic; - ptr_bit_set[2] = No; - - mm_map_page(page_ptr, ~eFlagsPresent); + return No; - return true; + Detail::IBitMapAllocator traits; + return traits.FreeBitMap(page_ptr); } } // namespace HAL } // namespace Kernel diff --git a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx index 4f9e8bac..9b9e0ac1 100644 --- a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx +++ b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx @@ -63,7 +63,7 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void); /// @brief Kernel init procedure. EXTERN_C void hal_init_platform( - Kernel::HEL::HandoverInformationHeader* HandoverHeader) + Kernel::HEL::HANDOVER_INFO_HEADER* HandoverHeader) { kHandoverHeader = HandoverHeader; diff --git a/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx b/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx index c617c45d..1bfaa879 100644 --- a/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx +++ b/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx @@ -56,7 +56,7 @@ Kernel::Void hal_real_init(Kernel::Void) noexcept; EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void); EXTERN_C void hal_init_platform( - Kernel::HEL::HandoverInformationHeader* HandoverHeader) + Kernel::HEL::HANDOVER_INFO_HEADER* HandoverHeader) { /* Setup globals. */ diff --git a/dev/ZKA/HALKit/compile_flags.txt b/dev/ZKA/HALKit/compile_flags.txt deleted file mode 100644 index d6e35511..00000000 --- a/dev/ZKA/HALKit/compile_flags.txt +++ /dev/null @@ -1,6 +0,0 @@ --nostdlib --ffreestanding --std=c++20 --I./ --I../ --D__ZKA_AMD64__ |
