summaryrefslogtreecommitdiffhomepage
path: root/Private/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-25 16:43:00 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-25 16:43:00 +0100
commitbe29b406526c931a606d4d4de545f71e62bc893a (patch)
tree99a37a287dda888803653df9e13cb1336150cb85 /Private/Source
parentf5e0bc85b06c84e0c6bc1da471630d02ff2ed7a3 (diff)
Kernel: A lot of preliminary changes before AHCI and SMP support.
Diffstat (limited to 'Private/Source')
-rw-r--r--Private/Source/KernelHeap.cxx2
-rw-r--r--Private/Source/UserHeap.cxx16
2 files changed, 11 insertions, 7 deletions
diff --git a/Private/Source/KernelHeap.cxx b/Private/Source/KernelHeap.cxx
index 09f62004..a38156f4 100644
--- a/Private/Source/KernelHeap.cxx
+++ b/Private/Source/KernelHeap.cxx
@@ -70,6 +70,8 @@ Int32 ke_delete_ke_heap(VoidPtr heapPtr) {
(UIntPtr)heapPtr - sizeof(Detail::HeapInformationBlock));
if (virtualAddress && virtualAddress->hMagic == kHeapMagic) {
+ MUST_PASS(virtualAddress->hPresent);
+
if (virtualAddress->hCRC32 != 0) {
if (virtualAddress->hCRC32 !=
ke_calculate_crc32((Char *)virtualAddress->hAddress,
diff --git a/Private/Source/UserHeap.cxx b/Private/Source/UserHeap.cxx
index 83d40845..45b29d51 100644
--- a/Private/Source/UserHeap.cxx
+++ b/Private/Source/UserHeap.cxx
@@ -18,9 +18,9 @@
namespace HCore {
/**
* @brief Process Heap Header
- * @note Allocated per process, do not allocate twice!
+ * @note Allocated per process, it denotes the user's heap.
*/
-struct HeapHeader final {
+struct UserHeapHeader final {
UInt32 fMagic;
Int32 fFlags;
Boolean fFree;
@@ -66,7 +66,7 @@ STATIC VoidPtr ke_find_unused_heap(Int flags) {
!HeapManager::The()[index].Leak().Leak().Leak().Present()) {
HeapManager::Leak().Leak().TogglePresent(
HeapManager::The()[index].Leak().Leak(), true);
- kcout << "[ke_find_unused_heap] Done, trying now to make a pool\r\n";
+ kcout << "[ke_find_unused_heap] Done, trying to make a pool now...\r\n";
return ke_make_heap((VoidPtr)HeapManager::The()[index]
.Leak()
@@ -82,7 +82,7 @@ STATIC VoidPtr ke_find_unused_heap(Int flags) {
STATIC VoidPtr ke_make_heap(VoidPtr virtualAddress, Int flags) {
if (virtualAddress) {
- HeapHeader* poolHdr = reinterpret_cast<HeapHeader*>(virtualAddress);
+ UserHeapHeader* poolHdr = reinterpret_cast<UserHeapHeader*>(virtualAddress);
if (!poolHdr->fFree) {
kcout << "[ke_make_heap] poolHdr->fFree, HeapPtr already exists\n";
@@ -95,7 +95,7 @@ STATIC VoidPtr ke_make_heap(VoidPtr virtualAddress, Int flags) {
kcout << "[ke_make_heap] New allocation has been done.\n";
return reinterpret_cast<VoidPtr>(
- (reinterpret_cast<UIntPtr>(virtualAddress) + sizeof(HeapHeader)));
+ (reinterpret_cast<UIntPtr>(virtualAddress) + sizeof(UserHeapHeader)));
}
kcout << "[ke_make_heap] Address is invalid";
@@ -103,10 +103,12 @@ STATIC VoidPtr ke_make_heap(VoidPtr virtualAddress, Int flags) {
}
STATIC Void ke_free_heap_internal(VoidPtr virtualAddress) {
- HeapHeader* poolHdr = reinterpret_cast<HeapHeader*>(
- reinterpret_cast<UIntPtr>(virtualAddress) - sizeof(HeapHeader));
+ UserHeapHeader* poolHdr = reinterpret_cast<UserHeapHeader*>(
+ reinterpret_cast<UIntPtr>(virtualAddress) - sizeof(UserHeapHeader));
if (poolHdr->fMagic == kUserHeapMag) {
+ MUST_PASS(poolHdr->fFree);
+
poolHdr->fFree = false;
poolHdr->fFlags = 0;