summaryrefslogtreecommitdiffhomepage
path: root/Kernel/Sources/KernelHeap.cxx
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-06-06 10:27:55 +0000
committerAmlal <amlalelmahrouss@icloud.com>2024-06-06 10:27:55 +0000
commit4e75e05a20ddd0dbca982e8f3bc2ea8043ed3a3f (patch)
tree95409c0e32b644578b94a5c230417da684d79dc9 /Kernel/Sources/KernelHeap.cxx
parentf5081a8f9a8537ad5be5d639955cd1d0e68a9e1d (diff)
parent9994b8f3f88131f41be1061fb0947177e66dc7b0 (diff)
Merged in MHR-23 (pull request #14)
Draft: MHR-23
Diffstat (limited to 'Kernel/Sources/KernelHeap.cxx')
-rw-r--r--Kernel/Sources/KernelHeap.cxx27
1 files changed, 26 insertions, 1 deletions
diff --git a/Kernel/Sources/KernelHeap.cxx b/Kernel/Sources/KernelHeap.cxx
index a8ca467e..93f0c164 100644
--- a/Kernel/Sources/KernelHeap.cxx
+++ b/Kernel/Sources/KernelHeap.cxx
@@ -38,7 +38,10 @@ namespace NewOS
SizeT fTargetPtrSize;
/// @brief 64-bit target pointer.
UIntPtr fTargetPtr;
- UInt8 fPadding[kKernelHeapHeaderPaddingSz];
+ /// @brief Is this a page pointer?
+ Boolean fPagePtr;
+ /// @brief Padding bytes for header.
+ UInt8 fPadding[kKernelHeapHeaderPaddingSz];
};
typedef HeapInformationBlock* HeapInformationBlockPtr;
@@ -64,6 +67,7 @@ namespace NewOS
heapInfo->fMagic = kKernelHeapMagic;
heapInfo->fCRC32 = 0; // dont fill it for now.
heapInfo->fTargetPtr = wrapper.VirtualAddress();
+ heapInfo->fPagePtr = 0;
++kHeapCount;
@@ -71,6 +75,27 @@ namespace NewOS
sizeof(Detail::HeapInformationBlock));
}
+ /// @brief Makes a page heap.
+ /// @param heapPtr
+ /// @return
+ Int32 ke_make_ke_page(VoidPtr heapPtr)
+ {
+ if (kHeapCount < 1)
+ return -kErrorInternal;
+ if (((IntPtr)heapPtr - sizeof(Detail::HeapInformationBlock)) <= 0)
+ return -kErrorInternal;
+ if (((IntPtr)heapPtr - kBadPtr) < 0)
+ return -kErrorInternal;
+
+ Detail::HeapInformationBlockPtr virtualAddress =
+ reinterpret_cast<Detail::HeapInformationBlockPtr>(
+ (UIntPtr)heapPtr - sizeof(Detail::HeapInformationBlock));
+
+ virtualAddress->fPagePtr = 1;
+
+ return 0;
+ }
+
/// @brief Declare pointer as free.
/// @param heapPtr the pointer.
/// @return