From a6eb9a77787f63f08470c3ff12ac0517b482ea65 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sun, 29 Sep 2024 12:29:21 +0200 Subject: IMP: Design changes and reworked WM to PDM. - Refactor other modules and drivers as well. - AMD64 HAL code improvements as well. The last thing left is the paging API and driver loading internal API. Signed-off-by: Amlal --- dev/zka/src/FS/NeFS.cxx | 2 +- dev/zka/src/IPEFDLLObject.cxx | 36 +++++----- dev/zka/src/KernelCheck.cxx | 155 ------------------------------------------ dev/zka/src/LPC.cxx | 2 +- dev/zka/src/LockDelegate.cxx | 4 +- dev/zka/src/PEFCodeMgr.cxx | 2 +- dev/zka/src/Stop.cxx | 148 ++++++++++++++++++++++++++++++++++++++++ dev/zka/src/User.cxx | 4 +- 8 files changed, 173 insertions(+), 180 deletions(-) delete mode 100644 dev/zka/src/KernelCheck.cxx create mode 100644 dev/zka/src/Stop.cxx (limited to 'dev/zka/src') diff --git a/dev/zka/src/FS/NeFS.cxx b/dev/zka/src/FS/NeFS.cxx index 69b0c401..61a18ae2 100644 --- a/dev/zka/src/FS/NeFS.cxx +++ b/dev/zka/src/FS/NeFS.cxx @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dev/zka/src/IPEFDLLObject.cxx b/dev/zka/src/IPEFDLLObject.cxx index a8505eb3..22645dde 100644 --- a/dev/zka/src/IPEFDLLObject.cxx +++ b/dev/zka/src/IPEFDLLObject.cxx @@ -18,7 +18,7 @@ Revision History: - 01/02/24: Rework shared sharedObj ABI, except a rtl_init_dll and + 01/02/24: Rework shared dll_obj ABI, except a rtl_init_dll and rtl_fini_dll (amlel) 15/02/24: Breaking changes, changed the name of the routines. (amlel) @@ -39,62 +39,62 @@ using namespace Kernel; EXTERN_C IDLL rtl_init_dll(UserProcess* header) { - IDLL sharedObj = tls_new_class(); + IDLL dll_obj = tls_new_class(); - if (!sharedObj) + if (!dll_obj) { header->Crash(); return nullptr; } - sharedObj->Mount(tls_new_class()); + dll_obj->Mount(tls_new_class()); - if (!sharedObj->Get()) + if (!dll_obj->Get()) { header->Crash(); return nullptr; } - sharedObj->Get()->fImageObject = + dll_obj->Get()->fImageObject = header->Image; - if (!sharedObj->Get()->fImageObject) + if (!dll_obj->Get()->fImageObject) { header->Crash(); return nullptr; } - sharedObj->Get()->fImageEntrypointOffset = - sharedObj->Load(kPefStart, rt_string_len(kPefStart, 0), kPefCode); + dll_obj->Get()->fImageEntrypointOffset = + dll_obj->Load(kPefStart, rt_string_len(kPefStart, 0), kPefCode); - return sharedObj; + return dll_obj; } /***********************************************************************************/ -/** @brief Frees the sharedObj. */ -/** @note Please check if the lib got freed! */ -/** @param lib The sharedObj to free. */ +/** @brief Frees the dll_obj. */ +/** @note Please check if the dll_obj got freed! */ +/** @param dll_obj The dll_obj to free. */ /** @param successful Reports if successful or not. */ /***********************************************************************************/ -EXTERN_C Void rtl_fini_dll(UserProcess* header, IDLL lib, Bool* successful) +EXTERN_C Void rtl_fini_dll(UserProcess* header, IDLL dll_obj, Bool* successful) { MUST_PASS(successful); // sanity check (will also trigger a bug check if this fails) - if (lib == nullptr) + if (dll_obj == nullptr) { *successful = false; header->Crash(); } - delete lib->Get(); - delete lib; + delete dll_obj->Get(); + delete dll_obj; - lib = nullptr; + dll_obj = nullptr; *successful = true; } diff --git a/dev/zka/src/KernelCheck.cxx b/dev/zka/src/KernelCheck.cxx deleted file mode 100644 index 49ca5edf..00000000 --- a/dev/zka/src/KernelCheck.cxx +++ /dev/null @@ -1,155 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SetMem(dst, byte, sz) Kernel::rt_set_memory((Kernel::VoidPtr)dst, byte, sz) -#define CopyMem(dst, src, sz) Kernel::rt_copy_memory((Kernel::VoidPtr)src, (Kernel::VoidPtr)dst, sz) -#define MoveMem(dst, src, sz) Kernel::rt_copy_memory((Kernel::VoidPtr)src, (Kernel::VoidPtr)dst, sz) - -#define cWebsiteMacro "https://help.el-mahrouss-logic.com/" - -/* Each error code is attributed with an ID, which will prompt a string onto the - * screen. Wait for debugger... */ - -namespace Kernel -{ - void ke_stop(const Kernel::Int& id) - { - CGInit(); - - auto panicTxt = RGB(0xff, 0xff, 0xff); - - CG::CGFillBackground(); - - auto start_y = 10; - auto x = 10; - - CGDrawString("newoskrnl.exe Stopped working properly so it had to stop.", start_y, x, panicTxt); - start_y += 10; - - // simply offset from previous string and then write the website. - CGDrawString("Please visit: ", start_y, x, panicTxt); - CGDrawString(cWebsiteMacro, start_y, x + (FONT_SIZE_X * rt_string_len("Please visit: ")), panicTxt); - - CGFini(); - - start_y += 10; - - // show text according to error id. - - switch (id) - { - 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: { - CGDrawString("0x00000006 ACPI configuration error.", start_y, x, panicTxt); - RecoveryFactory::Recover(); - break; - } - case RUNTIME_CHECK_PAGE: { - CGDrawString("0x0000000B Write/Read in non paged area.", start_y, x, panicTxt); - RecoveryFactory::Recover(); - } - case RUNTIME_CHECK_FILESYSTEM: { - CGDrawString("0x0000000A Filesystem error.", start_y, x, panicTxt); - - PowerFactoryInterface power(nullptr); - power.Shutdown(); - break; - } - case RUNTIME_CHECK_POINTER: { - CGDrawString("0x00000000 Heap error, the heap is corrupted.", start_y, x, panicTxt); - - PowerFactoryInterface power(nullptr); - power.Shutdown(); - break; - } - case RUNTIME_CHECK_BAD_BEHAVIOR: { - CGDrawString("0x00000009 CPU access error.", start_y, x, panicTxt); - - PowerFactoryInterface power(nullptr); - power.Shutdown(); - break; - } - case RUNTIME_CHECK_BOOTSTRAP: { - CGDrawString("0x0000000A Boot Processor finished executing.", start_y, x, panicTxt); - - PowerFactoryInterface power(nullptr); - power.Shutdown(); - break; - } - case RUNTIME_CHECK_HANDSHAKE: { - CGDrawString("0x00000005 Handshake fault.", start_y, x, panicTxt); - RecoveryFactory::Recover(); - break; - } - case RUNTIME_CHECK_IPC: { - CGDrawString("0x00000003 Bad IPC/XPCOM message.", start_y, x, panicTxt); - RecoveryFactory::Recover(); - break; - } - case RUNTIME_CHECK_INVALID_PRIVILEGE: { - CGDrawString("0x00000007 Privilege access violation.", start_y, x, panicTxt); - RecoveryFactory::Recover(); - break; - case RUNTIME_CHECK_UNEXCPECTED: { - CGDrawString("0x0000000B Kernel access violation.", start_y, x, panicTxt); - break; - } - case RUNTIME_CHECK_VIRTUAL_OUT_OF_MEM: { - CGDrawString("0x10000001 Out of virtual memory.", start_y, x, panicTxt); - RecoveryFactory::Recover(); - break; - } - case RUNTIME_CHECK_FAILED: { - CGDrawString("0x10000001 Kernel Bug check failed.", start_y, x, panicTxt); - RecoveryFactory::Recover(); - break; - } - default: { - RecoveryFactory::Recover(); - CGDrawString("0xFFFFFFFC Unknown Kernel error.", start_y, x, panicTxt); - break; - } - } - }; - - PowerFactoryInterface power(nullptr); - power.Reboot(); - } - - Void RecoveryFactory::Recover() noexcept - { - PowerFactoryInterface power(nullptr); - power.Reboot(); - } - - void ke_runtime_check(bool expr, const Char* file, const Char* line) - { - if (!expr) - { - kcout << "FAILED: FILE: " << file << endl; - kcout << "FAILED: LINE: " << line << endl; - - ke_stop(RUNTIME_CHECK_FAILED); // Runtime Check failed - } - } -} // namespace Kernel diff --git a/dev/zka/src/LPC.cxx b/dev/zka/src/LPC.cxx index 46f621bb..46814bbd 100644 --- a/dev/zka/src/LPC.cxx +++ b/dev/zka/src/LPC.cxx @@ -5,7 +5,7 @@ ------------------------------------------- */ #include -#include +#include namespace Kernel { diff --git a/dev/zka/src/LockDelegate.cxx b/dev/zka/src/LockDelegate.cxx index f23c46d3..74b819b0 100644 --- a/dev/zka/src/LockDelegate.cxx +++ b/dev/zka/src/LockDelegate.cxx @@ -8,5 +8,5 @@ namespace Kernel { - /// Leave it empty for now. -} // namespace Kernel \ No newline at end of file + /// @note Leave it empty for now. +} // namespace Kernel diff --git a/dev/zka/src/PEFCodeMgr.cxx b/dev/zka/src/PEFCodeMgr.cxx index 80bd9206..b1690abf 100644 --- a/dev/zka/src/PEFCodeMgr.cxx +++ b/dev/zka/src/PEFCodeMgr.cxx @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include diff --git a/dev/zka/src/Stop.cxx b/dev/zka/src/Stop.cxx new file mode 100644 index 00000000..9fdc982a --- /dev/null +++ b/dev/zka/src/Stop.cxx @@ -0,0 +1,148 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define cWebsiteMacro "https://help.el-mahrouss-logic.com/" + +/* Each error code is attributed with an ID, which will prompt a string onto the + * screen. Wait for debugger... */ + +namespace Kernel +{ + void ke_stop(const Kernel::Int& id) + { + CGInit(); + + auto panicTxt = RGB(0xff, 0xff, 0xff); + + auto start_y = 10; + auto x = 10; + + CGDrawString("newoskrnl.exe Stopped working properly so it had to stop.", start_y, x, panicTxt); + start_y += 10; + + // simply offset from previous string and then write the website. + CGDrawString("Please visit: ", start_y, x, panicTxt); + CGDrawString(cWebsiteMacro, start_y, x + (FONT_SIZE_X * rt_string_len("Please visit: ")), panicTxt); + + CGFini(); + + start_y += 10; + + // show text according to error id. + + switch (id) + { + 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: { + CGDrawString("0x00000006 ACPI configuration error.", start_y, x, panicTxt); + RecoveryFactory::Recover(); + break; + } + case RUNTIME_CHECK_PAGE: { + CGDrawString("0x0000000B Write/Read in non paged area.", start_y, x, panicTxt); + RecoveryFactory::Recover(); + } + case RUNTIME_CHECK_FILESYSTEM: { + CGDrawString("0x0000000A Filesystem error.", start_y, x, panicTxt); + + PowerFactoryInterface power(nullptr); + power.Shutdown(); + break; + } + case RUNTIME_CHECK_POINTER: { + CGDrawString("0x00000000 Heap error, the heap is corrupted.", start_y, x, panicTxt); + + PowerFactoryInterface power(nullptr); + power.Shutdown(); + break; + } + case RUNTIME_CHECK_BAD_BEHAVIOR: { + CGDrawString("0x00000009 CPU access error.", start_y, x, panicTxt); + + PowerFactoryInterface power(nullptr); + power.Shutdown(); + break; + } + case RUNTIME_CHECK_BOOTSTRAP: { + CGDrawString("0x0000000A Boot Processor finished executing.", start_y, x, panicTxt); + + PowerFactoryInterface power(nullptr); + power.Shutdown(); + break; + } + case RUNTIME_CHECK_HANDSHAKE: { + CGDrawString("0x00000005 Handshake fault.", start_y, x, panicTxt); + RecoveryFactory::Recover(); + break; + } + case RUNTIME_CHECK_IPC: { + CGDrawString("0x00000003 Bad IPC/XPCOM message.", start_y, x, panicTxt); + RecoveryFactory::Recover(); + break; + } + case RUNTIME_CHECK_INVALID_PRIVILEGE: { + CGDrawString("0x00000007 Privilege access violation.", start_y, x, panicTxt); + RecoveryFactory::Recover(); + break; + case RUNTIME_CHECK_UNEXCPECTED: { + CGDrawString("0x0000000B Kernel access violation.", start_y, x, panicTxt); + break; + } + case RUNTIME_CHECK_VIRTUAL_OUT_OF_MEM: { + CGDrawString("0x10000001 Out of virtual memory.", start_y, x, panicTxt); + RecoveryFactory::Recover(); + break; + } + case RUNTIME_CHECK_FAILED: { + CGDrawString("0x10000001 Kernel Bug check failed.", start_y, x, panicTxt); + RecoveryFactory::Recover(); + break; + } + default: { + RecoveryFactory::Recover(); + CGDrawString("0xFFFFFFFC Unknown Kernel error.", start_y, x, panicTxt); + break; + } + } + }; + + PowerFactoryInterface power(nullptr); + power.Reboot(); + } + + Void RecoveryFactory::Recover() noexcept + { + PowerFactoryInterface power(nullptr); + power.Reboot(); + } + + void ke_runtime_check(bool expr, const Char* file, const Char* line) + { + if (!expr) + { + kcout << "FAILED: FILE: " << file << endl; + kcout << "FAILED: LINE: " << line << endl; + + ke_stop(RUNTIME_CHECK_FAILED); // Runtime Check failed + } + } +} // namespace Kernel diff --git a/dev/zka/src/User.cxx b/dev/zka/src/User.cxx index 066a3e06..1e4f9df9 100644 --- a/dev/zka/src/User.cxx +++ b/dev/zka/src/User.cxx @@ -10,9 +10,9 @@ * ======================================================== */ -#include #include -#include +#include +#include #include #include -- cgit v1.2.3