summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKAKit/src
diff options
context:
space:
mode:
Diffstat (limited to 'dev/ZKAKit/src')
-rw-r--r--dev/ZKAKit/src/Heap.cc58
-rw-r--r--dev/ZKAKit/src/UserProcessScheduler.cc24
2 files changed, 38 insertions, 44 deletions
diff --git a/dev/ZKAKit/src/Heap.cc b/dev/ZKAKit/src/Heap.cc
index 15b532e8..01c35096 100644
--- a/dev/ZKAKit/src/Heap.cc
+++ b/dev/ZKAKit/src/Heap.cc
@@ -88,8 +88,6 @@ namespace Kernel
typedef HEAP_INFORMATION_BLOCK* HEAP_INFORMATION_BLOCK_PTR;
} // namespace Detail
- Detail::HEAP_INFORMATION_BLOCK_PTR kLatestAllocation = nullptr;
-
/// @brief Declare a new size for ptr_heap.
/// @param ptr_heap the pointer.
/// @return Newly allocated heap header.
@@ -141,7 +139,7 @@ namespace Kernel
auto result = reinterpret_cast<VoidPtr>(heap_info_ptr->fHeapPtr);
- kLatestAllocation = heap_info_ptr;
+ kcout << "Created Heap address: " << hex_number(reinterpret_cast<UIntPtr>(heap_info_ptr)) << endl;
return result;
}
@@ -154,14 +152,16 @@ namespace Kernel
if (Detail::mm_check_heap_address(heap_ptr) == No)
return -kErrorHeapNotPresent;
- Detail::HEAP_INFORMATION_BLOCK_PTR heap_blk =
+ Detail::HEAP_INFORMATION_BLOCK_PTR heap_info_ptr =
reinterpret_cast<Detail::HEAP_INFORMATION_BLOCK_PTR>(
(UIntPtr)heap_ptr - sizeof(Detail::HEAP_INFORMATION_BLOCK));
if (!heap_ptr)
return -kErrorHeapNotPresent;
- heap_blk->fPage = true;
+ heap_info_ptr->fPage = true;
+
+ kcout << "Created Page address: " << hex_number(reinterpret_cast<UIntPtr>(heap_info_ptr)) << endl;
return kErrorSuccess;
}
@@ -174,46 +174,46 @@ namespace Kernel
if (Detail::mm_check_heap_address(heap_ptr) == No)
return -kErrorHeapNotPresent;
- Detail::HEAP_INFORMATION_BLOCK_PTR heap_blk =
+ Detail::HEAP_INFORMATION_BLOCK_PTR heap_info_ptr =
reinterpret_cast<Detail::HEAP_INFORMATION_BLOCK_PTR>(
(UIntPtr)(heap_ptr) - sizeof(Detail::HEAP_INFORMATION_BLOCK));
- if (heap_blk && heap_blk->fMagic == kKernelHeapMagic)
+ if (heap_info_ptr && heap_info_ptr->fMagic == kKernelHeapMagic)
{
- if (!heap_blk->fPresent)
+ if (!heap_info_ptr->fPresent)
{
return -kErrorHeapNotPresent;
}
- if (heap_blk->fCRC32 != 0)
+ if (heap_info_ptr->fCRC32 != 0)
{
- if (heap_blk->fCRC32 !=
- ke_calculate_crc32((Char*)heap_blk->fHeapPtr,
- heap_blk->fHeapSize))
+ if (heap_info_ptr->fCRC32 !=
+ ke_calculate_crc32((Char*)heap_info_ptr->fHeapPtr,
+ heap_info_ptr->fHeapSize))
{
- if (!heap_blk->fUser)
+ if (!heap_info_ptr->fUser)
{
ke_stop(RUNTIME_CHECK_POINTER);
}
}
}
- heap_blk->fHeapSize = 0UL;
- heap_blk->fPresent = No;
- heap_blk->fHeapPtr = 0;
- heap_blk->fCRC32 = 0;
- heap_blk->fWr = No;
- heap_blk->fUser = No;
- heap_blk->fMagic = 0;
+ heap_info_ptr->fHeapSize = 0UL;
+ heap_info_ptr->fPresent = No;
+ heap_info_ptr->fHeapPtr = 0;
+ heap_info_ptr->fCRC32 = 0;
+ heap_info_ptr->fWr = No;
+ heap_info_ptr->fUser = No;
+ heap_info_ptr->fMagic = 0;
- PTEWrapper pageWrapper(No, No, No, reinterpret_cast<UIntPtr>(heap_blk) - sizeof(Detail::HEAP_INFORMATION_BLOCK));
+ PTEWrapper pageWrapper(No, No, No, reinterpret_cast<UIntPtr>(heap_info_ptr) - sizeof(Detail::HEAP_INFORMATION_BLOCK));
Ref<PTEWrapper> pteAddress{pageWrapper};
- kcout << "Freeing pointer address: " << hex_number(reinterpret_cast<UIntPtr>(heap_blk) - sizeof(Detail::HEAP_INFORMATION_BLOCK)) << endl;
-
PageMgr heap_mgr;
heap_mgr.Free(pteAddress);
+ kcout << "Freed Heap address: " << hex_number(reinterpret_cast<UIntPtr>(heap_info_ptr)) << endl;
+
return kErrorSuccess;
}
@@ -227,11 +227,11 @@ namespace Kernel
{
if (heap_ptr)
{
- Detail::HEAP_INFORMATION_BLOCK_PTR heap_blk =
+ Detail::HEAP_INFORMATION_BLOCK_PTR heap_info_ptr =
reinterpret_cast<Detail::HEAP_INFORMATION_BLOCK_PTR>(
(UIntPtr)(heap_ptr) - sizeof(Detail::HEAP_INFORMATION_BLOCK));
- if (heap_blk && heap_blk->fPresent && heap_blk->fMagic == kKernelHeapMagic)
+ if (heap_info_ptr && heap_info_ptr->fPresent && heap_info_ptr->fMagic == kKernelHeapMagic)
{
return Yes;
}
@@ -247,14 +247,14 @@ namespace Kernel
{
if (heap_ptr)
{
- Detail::HEAP_INFORMATION_BLOCK_PTR heap_blk =
+ Detail::HEAP_INFORMATION_BLOCK_PTR heap_info_ptr =
reinterpret_cast<Detail::HEAP_INFORMATION_BLOCK_PTR>(
(UIntPtr)heap_ptr - sizeof(Detail::HEAP_INFORMATION_BLOCK));
- if (heap_ptr && heap_blk->fPresent && kKernelHeapMagic == heap_blk->fMagic)
+ if (heap_ptr && heap_info_ptr->fPresent && kKernelHeapMagic == heap_info_ptr->fMagic)
{
- heap_blk->fCRC32 =
- ke_calculate_crc32((Char*)heap_blk->fHeapPtr, heap_blk->fHeapSize);
+ heap_info_ptr->fCRC32 =
+ ke_calculate_crc32((Char*)heap_info_ptr->fHeapPtr, heap_info_ptr->fHeapSize);
return Yes;
}
diff --git a/dev/ZKAKit/src/UserProcessScheduler.cc b/dev/ZKAKit/src/UserProcessScheduler.cc
index dfa04537..61f6ba7b 100644
--- a/dev/ZKAKit/src/UserProcessScheduler.cc
+++ b/dev/ZKAKit/src/UserProcessScheduler.cc
@@ -320,7 +320,7 @@ namespace Kernel
return -kErrorInvalidData;
#ifdef __ZKA_AMD64__
- process.VMRegister = reinterpret_cast<UIntPtr>(HAL::mm_alloc_bitmap(Yes, Yes, sizeof(PDE), Yes));
+ process.VMRegister = reinterpret_cast<UIntPtr>(mm_new_heap(sizeof(PDE), No, Yes));
#endif // __ZKA_AMD64__
process.StackFrame = reinterpret_cast<HAL::StackFramePtr>(mm_new_heap(sizeof(HAL::StackFrame), Yes, Yes));
@@ -339,16 +339,13 @@ namespace Kernel
if (!process.Image)
{
- if (process.Kind != UserProcess::kExectuableDLLKind)
- {
- process.Crash();
- return -kErrorProcessFault;
- }
+ process.Crash();
+ return -kErrorProcessFault;
}
// Get preferred stack size by app.
- const auto cMaxStackSize = process.StackSize;
- process.StackReserve = reinterpret_cast<UInt8*>(mm_new_heap(sizeof(UInt8) * cMaxStackSize, Yes, Yes));
+ const auto kMaxStackSize = process.StackSize;
+ process.StackReserve = reinterpret_cast<UInt8*>(mm_new_heap(sizeof(UInt8) * kMaxStackSize, Yes, Yes));
if (!process.StackReserve)
{
@@ -424,12 +421,14 @@ namespace Kernel
SizeT process_index = 0; //! we store this guy to tell the scheduler how many
//! things we have scheduled.
- if (mTeam.mProcessAmount < 1)
+ if (mTeam.mProcessAmount == 0)
{
kcout << "UserProcessScheduler::Run(): This team doesn't have any process!\r";
return 0;
}
+ kcout << "UserProcessScheduler::Run(): This team has process # " << number(mTeam.mProcessAmount) << endl;
+
for (; process_index < mTeam.AsArray().Capacity(); ++process_index)
{
auto& process = mTeam.AsArray()[process_index];
@@ -500,12 +499,7 @@ namespace Kernel
process.Status == ProcessStatusKind::kDead)
return No;
- if (process.Status == ProcessStatusKind::kStarting &&
- process.Image)
- return Yes;
-
- if (!process.Image &&
- process.Kind == UserProcess::kExectuableKind)
+ if (!process.Image)
return No;
return process.PTime < 1 && process.Status == ProcessStatusKind::kRunning;