From 79886caeb4bf17b01fcc42c0891a61bcd5863a75 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 8 Apr 2024 17:41:48 +0200 Subject: Kernel: Thoroughly document code. --- Private/KernelKit/KernelHeap.hpp | 18 ++++++++++++++++++ Private/Source/KernelHeap.cxx | 6 +++--- Public/Developer/FragLib/.gitkeep | 0 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 Public/Developer/FragLib/.gitkeep diff --git a/Private/KernelKit/KernelHeap.hpp b/Private/KernelKit/KernelHeap.hpp index 69c84b7f..5358236e 100644 --- a/Private/KernelKit/KernelHeap.hpp +++ b/Private/KernelKit/KernelHeap.hpp @@ -13,8 +13,26 @@ #include namespace NewOS { + +/// @brief Declare pointer as free. +/// @param heapPtr the pointer. +/// @return Int32 ke_delete_ke_heap(voidPtr allocatedPtr); + +/// @brief Check if pointer is a valid kernel pointer. +/// @param heapPtr the pointer +/// @return if it exists. Boolean ke_is_valid_heap(VoidPtr ptr); + +/// @brief allocate chunk of memory. +/// @param sz size of pointer +/// @param rw read write (true to enable it) +/// @param user is it accesible by user processes? +/// @return the pointer voidPtr ke_new_ke_heap(SizeT sz, const bool rw, const bool user); + +/// @brief Protect the heap pointer with a CRC32. +/// @param heapPtr HIB pointer. +/// @return if it valid: point has crc now., otherwise fail. Boolean ke_protect_ke_heap(VoidPtr heapPtr); } // namespace NewOS diff --git a/Private/Source/KernelHeap.cxx b/Private/Source/KernelHeap.cxx index 0f2f57dd..72d291a8 100644 --- a/Private/Source/KernelHeap.cxx +++ b/Private/Source/KernelHeap.cxx @@ -127,15 +127,15 @@ Boolean ke_is_valid_heap(VoidPtr heapPtr) { } /// @brief Protect the heap pointer with a CRC32. -/// @param heapPtr -/// @return +/// @param heapPtr HIB pointer. +/// @return if it valid: point has crc now., otherwise fail. Boolean ke_protect_ke_heap(VoidPtr heapPtr) { if (heapPtr) { Detail::HeapInformationBlockPtr virtualAddress = reinterpret_cast( (UIntPtr)heapPtr - sizeof(Detail::HeapInformationBlock)); - if (virtualAddress->fPresent && virtualAddress->fMagic == kKernelHeapMagic) { + if (virtualAddress->fPresent && kKernelHeapMagic == virtualAddress->fMagic) { virtualAddress->fCRC32 = ke_calculate_crc32((Char *)heapPtr, virtualAddress->fTargetPtrSize); return true; diff --git a/Public/Developer/FragLib/.gitkeep b/Public/Developer/FragLib/.gitkeep new file mode 100644 index 00000000..e69de29b -- cgit v1.2.3