summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/Sources
diff options
context:
space:
mode:
Diffstat (limited to 'dev/ZKA/Sources')
-rw-r--r--dev/ZKA/Sources/DLLMain.cxx16
-rw-r--r--dev/ZKA/Sources/FS/NewFS.cxx4
-rw-r--r--dev/ZKA/Sources/Framebuffer.cxx2
-rw-r--r--dev/ZKA/Sources/Heap.cxx43
-rw-r--r--dev/ZKA/Sources/KernelCheck.cxx13
-rw-r--r--dev/ZKA/Sources/MP.cxx4
-rw-r--r--dev/ZKA/Sources/NewFS+FileManager.cxx1
-rw-r--r--dev/ZKA/Sources/PageAllocator.cxx13
-rw-r--r--dev/ZKA/Sources/PageManager.cxx30
-rw-r--r--dev/ZKA/Sources/ThreadLocalStorage.cxx2
-rw-r--r--dev/ZKA/Sources/User.cxx1
-rw-r--r--dev/ZKA/Sources/UserProcessScheduler.cxx29
12 files changed, 60 insertions, 98 deletions
diff --git a/dev/ZKA/Sources/DLLMain.cxx b/dev/ZKA/Sources/DLLMain.cxx
index 934f418c..84c58b3a 100644
--- a/dev/ZKA/Sources/DLLMain.cxx
+++ b/dev/ZKA/Sources/DLLMain.cxx
@@ -150,14 +150,12 @@ namespace Kernel::Detail
};
} // namespace Kernel::Detail
-namespace Kernel
+EXTERN_C ATTRIBUTE(naked) Kernel::Void HangCPU(Kernel::Void)
{
- EXTERN UserProcessScheduler* cProcessScheduler;
-} // namespace Kernel
+ while (Yes)
+ {
-EXTERN_C Kernel::Void HangCPU(Kernel::Void)
-{
- while (1);
+ }
}
/// @brief Application entrypoint.
@@ -189,10 +187,6 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.exe: Running System Component: ", 10, 10, RGB(0, 0, 0));
CG::CGDrawStringToWnd(cKernelWnd, kSysDrv, 10, 10 + (FONT_SIZE_X * Kernel::rt_string_len("newoskrnl.exe: Running System Component: ")), RGB(0, 0, 0));
- /// @note BThread doesn't parse the symbols so doesn't nullify them, .bss is though.
- Kernel::cProcessScheduler = nullptr;
- Kernel::UserProcessHelper::StartScheduling();
-
CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.exe: Starting ZKA System...", 20, 10, RGB(0, 0, 0));
Kernel::sched_execute_thread(HangCPU, "HANG TEST");
@@ -201,6 +195,4 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
{
Kernel::UserProcessHelper::StartScheduling();
}
-
- Kernel::ke_stop(RUNTIME_CHECK_BOOTSTRAP);
}
diff --git a/dev/ZKA/Sources/FS/NewFS.cxx b/dev/ZKA/Sources/FS/NewFS.cxx
index bf55a56f..e3ec6184 100644
--- a/dev/ZKA/Sources/FS/NewFS.cxx
+++ b/dev/ZKA/Sources/FS/NewFS.cxx
@@ -1035,11 +1035,11 @@ namespace Kernel::Detail
sMountpointInterface.C() = io_construct_drive();
sMountpointInterface.D() = io_construct_drive();
- kcout << "newoskrnl.exe: Testing main drive...\r";
+ kcout << "newoskrnl.exe: Testing A:\r";
sMountpointInterface.A().fVerify(&sMountpointInterface.A().fPacket);
- kcout << "newoskrnl.exe: Testing main drive [ OK ]...\r";
+ kcout << "newoskrnl.exe: Testing A: [ OK ]\r";
return true;
}
diff --git a/dev/ZKA/Sources/Framebuffer.cxx b/dev/ZKA/Sources/Framebuffer.cxx
index 76fe7172..3794e458 100644
--- a/dev/ZKA/Sources/Framebuffer.cxx
+++ b/dev/ZKA/Sources/Framebuffer.cxx
@@ -44,7 +44,7 @@ namespace Kernel
{
return fFrameBufferAddr.Leak()->fBase != 0 &&
fColour != FramebufferColorKind::INVALID &&
- fFrameBufferAddr.Leak()->fBase != kBadPtr;
+ fFrameBufferAddr.Leak()->fBase != kInvalidAddress;
}
/// @brief Set color kind of framebuffer.
diff --git a/dev/ZKA/Sources/Heap.cxx b/dev/ZKA/Sources/Heap.cxx
index bd7e299b..e036badb 100644
--- a/dev/ZKA/Sources/Heap.cxx
+++ b/dev/ZKA/Sources/Heap.cxx
@@ -85,10 +85,10 @@ namespace Kernel
return allocatedPtr;
}
- /// @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?
+ /// @brief Allocate chunk of memory.
+ /// @param sz Size of pointer
+ /// @param rw Read Write bit.
+ /// @param user User enable bit.
/// @return The newly allocated pointer.
VoidPtr mm_new_ke_heap(const SizeT sz, const bool rw, const bool user)
{
@@ -99,28 +99,29 @@ namespace Kernel
if (szFix == 0)
++szFix;
- auto wrapper = kHeapPageManager.Request(rw, user, false, szFix);
+ auto wrapper = kHeapPageManager.Request(rw, user, No, szFix);
Detail::HEAP_INFORMATION_BLOCK_PTR heap_info_ptr =
reinterpret_cast<Detail::HEAP_INFORMATION_BLOCK_PTR>(
- wrapper.VirtualAddress());
+ wrapper.VirtualAddress() + sizeof(Detail::HEAP_INFORMATION_BLOCK));
heap_info_ptr->fHeapSize = szFix;
- heap_info_ptr->fMagic = kKernelHeapMagic;
- heap_info_ptr->fCRC32 = 0U; // dont fill it for now.
- heap_info_ptr->fHeapPtr = wrapper.VirtualAddress() + sizeof(Detail::HEAP_INFORMATION_BLOCK);
- heap_info_ptr->fPage = 0UL;
- heap_info_ptr->fUser = user;
- heap_info_ptr->fPresent = true;
+ heap_info_ptr->fMagic = kKernelHeapMagic;
+ heap_info_ptr->fCRC32 = 0U; // dont fill it for now.
+ heap_info_ptr->fHeapPtr = wrapper.VirtualAddress() + sizeof(Detail::HEAP_INFORMATION_BLOCK);
+ heap_info_ptr->fPage = 0UL;
+ heap_info_ptr->fUser = user;
+ heap_info_ptr->fPresent = true;
++kHeapCount;
+ auto result = reinterpret_cast<VoidPtr>(heap_info_ptr->fHeapPtr);
+
kLatestAllocation = heap_info_ptr;
Detail::mm_alloc_fini_timeout();
- return reinterpret_cast<VoidPtr>(heap_info_ptr +
- sizeof(Detail::HEAP_INFORMATION_BLOCK));
+ return result;
}
/// @brief Makes a page heap.
@@ -132,7 +133,7 @@ namespace Kernel
return -kErrorInternal;
if (((IntPtr)heap_ptr - sizeof(Detail::HEAP_INFORMATION_BLOCK)) <= 0)
return -kErrorInternal;
- if (((IntPtr)heap_ptr - kBadPtr) < 0)
+ if (((IntPtr)heap_ptr - kInvalidAddress) < 0)
return -kErrorInternal;
Detail::mm_alloc_init_timeout();
@@ -157,7 +158,7 @@ namespace Kernel
return -kErrorInternal;
if (((IntPtr)heap_ptr - sizeof(Detail::HEAP_INFORMATION_BLOCK)) <= 0)
return -kErrorInternal;
- if (((IntPtr)heap_ptr - kBadPtr) < 0)
+ if (((IntPtr)heap_ptr - kInvalidAddress) < 0)
return -kErrorInternal;
Detail::mm_alloc_init_timeout();
@@ -188,12 +189,12 @@ namespace Kernel
}
heapInfoBlk->fHeapSize = 0UL;
- heapInfoBlk->fPresent = false;
- heapInfoBlk->fHeapPtr = 0;
- heapInfoBlk->fCRC32 = 0;
- heapInfoBlk->fMagic = 0;
+ heapInfoBlk->fPresent = false;
+ heapInfoBlk->fHeapPtr = 0;
+ heapInfoBlk->fCRC32 = 0;
+ heapInfoBlk->fMagic = 0;
- PTEWrapper pageWrapper(false, false, false, reinterpret_cast<UIntPtr>(heapInfoBlk));
+ PTEWrapper pageWrapper(false, false, false, reinterpret_cast<UIntPtr>(heapInfoBlk) - sizeof(Detail::HEAP_INFORMATION_BLOCK));
Ref<PTEWrapper*> pteAddress{&pageWrapper};
kHeapPageManager.Free(pteAddress);
diff --git a/dev/ZKA/Sources/KernelCheck.cxx b/dev/ZKA/Sources/KernelCheck.cxx
index a05c265a..0ed96593 100644
--- a/dev/ZKA/Sources/KernelCheck.cxx
+++ b/dev/ZKA/Sources/KernelCheck.cxx
@@ -56,6 +56,7 @@ namespace Kernel
{
case RUNTIME_CHECK_PROCESS: {
CGDrawString("0x00000008 No more processes to run, this is because that ZKA ran out of processes.", start_y, x, panicTxt);
+ RecoveryFactory::Recover();
break;
}
case RUNTIME_CHECK_ACPI: {
@@ -102,7 +103,7 @@ namespace Kernel
break;
}
case RUNTIME_CHECK_FAILED: {
- CGDrawString("0x10000001 Assertion failed.", start_y, x, panicTxt);
+ CGDrawString("0x10000001 Kernel bug-check failure.", start_y, x, panicTxt);
RecoveryFactory::Recover();
break;
}
@@ -120,13 +121,6 @@ namespace Kernel
Void RecoveryFactory::Recover() noexcept
{
- const auto cMaxSeconds = Seconds(4);
-
- HardwareTimer timer(cMaxSeconds);
- timer.Wait();
-
- kcout << "newoskrnl.exe: Shutting down computer...\r";
-
PowerFactoryInterface power(nullptr);
power.Shutdown();
}
@@ -135,6 +129,9 @@ namespace Kernel
{
if (!expr)
{
+ kcout << "ASSERTION FAILED: FILE: " << file << endl;
+ kcout << "ASSERTION FAILED: LINE: " << line << endl;
+
ke_stop(RUNTIME_CHECK_FAILED); // Runtime Check failed
}
}
diff --git a/dev/ZKA/Sources/MP.cxx b/dev/ZKA/Sources/MP.cxx
index b3b62609..7429751f 100644
--- a/dev/ZKA/Sources/MP.cxx
+++ b/dev/ZKA/Sources/MP.cxx
@@ -125,12 +125,12 @@ namespace Kernel
///! @brief Default constructor.
HardwareThreadScheduler::HardwareThreadScheduler()
{
- kcout << "newoskrnl.exe: initializing HardwareThreadScheduler." << endl;
+ kcout << "newoskrnl.exe: Initializing HardwareThreadScheduler." << endl;
cSMPCoreName.GetKey() += "Property\\MPClass";
cSMPCoreName.GetValue() = (PropertyId)this;
- kcout << "newoskrnl.exe: initialized HardwareThreadScheduler." << endl;
+ kcout << "newoskrnl.exe: Initialized HardwareThreadScheduler." << endl;
}
///! @brief Default destructor.
diff --git a/dev/ZKA/Sources/NewFS+FileManager.cxx b/dev/ZKA/Sources/NewFS+FileManager.cxx
index 98e0e3af..20fb623d 100644
--- a/dev/ZKA/Sources/NewFS+FileManager.cxx
+++ b/dev/ZKA/Sources/NewFS+FileManager.cxx
@@ -19,6 +19,7 @@ namespace Kernel
{
MUST_PASS(Detail::fs_init_newfs());
fImpl = new NewFSParser();
+ MUST_PASS(fImpl);
kcout << "newoskrnl.exe: We are done here... (NewFilesystemManager).\r";
}
diff --git a/dev/ZKA/Sources/PageAllocator.cxx b/dev/ZKA/Sources/PageAllocator.cxx
index dec6c470..e68d0659 100644
--- a/dev/ZKA/Sources/PageAllocator.cxx
+++ b/dev/ZKA/Sources/PageAllocator.cxx
@@ -11,19 +11,6 @@
/// @brief Internal namespace, used internally by Kernel.
namespace Kernel::Detail
{
- VoidPtr create_page_wrapper(Boolean rw, Boolean user, SizeT pageSz)
- {
- auto addr = HAL::hal_alloc_page(rw, user, pageSz);
-
- if (addr == kBadAddress)
- {
- kcout << "[create_page_wrapper] kBadAddress returned\n";
- ke_stop(RUNTIME_CHECK_POINTER);
- }
-
- return addr;
- }
-
void exec_disable(UIntPtr VirtualAddr)
{
#ifdef __ZKA_SUPPORT_NX__
diff --git a/dev/ZKA/Sources/PageManager.cxx b/dev/ZKA/Sources/PageManager.cxx
index d14130ff..dd18709f 100644
--- a/dev/ZKA/Sources/PageManager.cxx
+++ b/dev/ZKA/Sources/PageManager.cxx
@@ -35,11 +35,8 @@ namespace Kernel
/// @brief Flush virtual address.
/// @param VirtAddr
- Void PageManager::FlushTLB(UIntPtr VirtAddr)
+ Void PageManager::FlushTLB()
{
- if (VirtAddr == kBadAddress)
- return;
-
hal_flush_tlb();
}
@@ -64,31 +61,20 @@ namespace Kernel
PTEWrapper PageManager::Request(Boolean Rw, Boolean User, Boolean ExecDisable, SizeT Sz)
{
// Store PTE wrapper right after PTE.
- VoidPtr ptr = Kernel::HAL::hal_alloc_page(Rw, User, Sz);
-
- if (ptr == kBadAddress)
- {
- kcout << "[create_page_wrapper] kBadAddress returned\n";
- ke_stop(RUNTIME_CHECK_POINTER);
- }
+ VoidPtr ptr = Kernel::HAL::mm_alloc_bitmap(Rw, User, Sz);
return PTEWrapper{Rw, User, ExecDisable, reinterpret_cast<UIntPtr>(ptr)};
}
- /// @brief Disable PTE.
+ /// @brief Disable BitMap.
/// @param wrapper the wrapper.
- /// @return
- bool PageManager::Free(Ref<PTEWrapper*>& wrapper)
+ /// @return If the page bitmap was cleared or not.
+ Bool PageManager::Free(Ref<PTEWrapper*>& wrapper)
{
- if (wrapper)
- {
- if (!Kernel::HAL::hal_free_page((VoidPtr)wrapper->VirtualAddress()))
- return false;
+ if (!Kernel::HAL::mm_free_bitmap((VoidPtr)wrapper->VirtualAddress()))
+ return false;
- return true;
- }
-
- return false;
+ return true;
}
/// @brief Virtual PTE address.
diff --git a/dev/ZKA/Sources/ThreadLocalStorage.cxx b/dev/ZKA/Sources/ThreadLocalStorage.cxx
index f4794bdd..e68593f6 100644
--- a/dev/ZKA/Sources/ThreadLocalStorage.cxx
+++ b/dev/ZKA/Sources/ThreadLocalStorage.cxx
@@ -21,7 +21,7 @@
using namespace Kernel;
-namespace Detail
+namespace Kernel::Detail
{
/// \brief UserProcess thread information header.
struct THREAD_HEADER_BLOCK final
diff --git a/dev/ZKA/Sources/User.cxx b/dev/ZKA/Sources/User.cxx
index 5a4c2335..871d011f 100644
--- a/dev/ZKA/Sources/User.cxx
+++ b/dev/ZKA/Sources/User.cxx
@@ -77,7 +77,6 @@ namespace Kernel
SizeT len = rt_string_len(password_to_fill);
Char* password = new Char[len];
-
MUST_PASS(password);
// fill data first, generate hash.
diff --git a/dev/ZKA/Sources/UserProcessScheduler.cxx b/dev/ZKA/Sources/UserProcessScheduler.cxx
index dc142b18..26d8be79 100644
--- a/dev/ZKA/Sources/UserProcessScheduler.cxx
+++ b/dev/ZKA/Sources/UserProcessScheduler.cxx
@@ -28,13 +28,13 @@ namespace Kernel
/// @brief Exit Code global variable.
/***********************************************************************************/
- UInt32 cLastExitCode = 0U;
+ STATIC UInt32 cLastExitCode = 0U;
/***********************************************************************************/
/// @brief UserProcess scheduler instance.
/***********************************************************************************/
- UserProcessScheduler* cProcessScheduler = nullptr;
+ STATIC UserProcessScheduler* cProcessScheduler;
/// @brief Gets the last exit code.
/// @note Not thread-safe.
@@ -53,11 +53,9 @@ namespace Kernel
if (this->Name == 0)
return;
- kcout << this->Name << ": crashed. (id = " << number(kErrorProcessFault) << endl;
+ kcout << this->Name << ": crashed, ID = " << number(kErrorProcessFault) << endl;
this->Exit(kErrorProcessFault);
-
- UserProcessHelper::StartScheduling();
}
/// @brief Gets the local last exit code.
@@ -246,8 +244,12 @@ namespace Kernel
}
process.StackFrame = new HAL::StackFrame();
-
- MUST_PASS(process.StackFrame);
+
+ if (!process.StackFrame)
+ {
+ process.Crash();
+ return -kErrorProcessFault;
+ }
if (process.Image)
{
@@ -291,6 +293,11 @@ namespace Kernel
UserProcessScheduler& UserProcessScheduler::The()
{
+ if (!cProcessScheduler)
+ {
+ cProcessScheduler = new UserProcessScheduler();
+ }
+
MUST_PASS(cProcessScheduler);
return *cProcessScheduler;
}
@@ -414,14 +421,6 @@ namespace Kernel
SizeT UserProcessHelper::StartScheduling()
{
- if (!cProcessScheduler)
- {
- cProcessScheduler = new UserProcessScheduler();
- MUST_PASS(cProcessScheduler);
-
- kcout << "newoskrnl.exe: Team capacity: " << number(cProcessScheduler->CurrentTeam().AsArray().Capacity()) << endl;
- }
-
SizeT ret = cProcessScheduler->Run();
return ret;
}