summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/src
diff options
context:
space:
mode:
Diffstat (limited to 'dev/Kernel/src')
-rw-r--r--dev/Kernel/src/KernelPanic.cc128
-rw-r--r--dev/Kernel/src/UserProcessScheduler.cc1
-rw-r--r--dev/Kernel/src/Utils.cc67
3 files changed, 41 insertions, 155 deletions
diff --git a/dev/Kernel/src/KernelPanic.cc b/dev/Kernel/src/KernelPanic.cc
deleted file mode 100644
index d0119b5e..00000000
--- a/dev/Kernel/src/KernelPanic.cc
+++ /dev/null
@@ -1,128 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024, Theater Quality Corp, all rights reserved.
-
-------------------------------------------- */
-
-#include <NewKit/KernelPanic.h>
-#include <ArchKit/ArchKit.h>
-#include <KernelKit/Timer.h>
-#include <KernelKit/DebugOutput.h>
-#include <NewKit/KString.h>
-#include <FirmwareKit/Handover.h>
-#include <KernelKit/FileMgr.h>
-#include <Mod/GfxMgr/FBMgr.h>
-#include <Mod/GfxMgr/TextMgr.h>
-
-/* Each error code is attributed with an ID, which will prompt a string onto the
- * screen. Wait for debugger... */
-
-namespace Kernel
-{
- /***********************************************************************************/
- /// @brief Stops execution of the kernel.
- /// @param id kernel stop ID.
- /***********************************************************************************/
- Void ke_panic(const Kernel::Int32& id)
- {
- fb_init();
-
- auto panic_text = RGB(0xff, 0xff, 0xff);
-
- auto start_y = 50;
- auto x = 10;
-
- if (id != RUNTIME_CHECK_BOOTSTRAP)
- fb_render_string("Kernel Panic!", start_y, x, panic_text);
- else
- fb_render_string("Kernel Bootstrap:", start_y, x, panic_text);
-
- start_y += 10;
-
- fb_clear();
-
- // show text according to error id.
-
- switch (id)
- {
- case RUNTIME_CHECK_PROCESS: {
- fb_render_string("0x00000008: Invalid process behavior.", start_y, x, panic_text);
- break;
- }
- case RUNTIME_CHECK_ACPI: {
- fb_render_string("0x00000006: ACPI configuration error.", start_y, x, panic_text);
- break;
- }
- case RUNTIME_CHECK_PAGE: {
- fb_render_string("0x0000000B: Write/Read in non paged area.", start_y, x, panic_text);
- break;
- }
- case RUNTIME_CHECK_FILESYSTEM: {
- fb_render_string("0x0000000A: Filesystem driver error.", start_y, x, panic_text);
- break;
- }
- case RUNTIME_CHECK_POINTER: {
- fb_render_string("0x00000000: Pointer is invalid.", start_y, x, panic_text);
- break;
- }
- case RUNTIME_CHECK_BAD_BEHAVIOR: {
- fb_render_string("0x00000009: Bad behavior.", start_y, x, panic_text);
- break;
- }
- case RUNTIME_CHECK_BOOTSTRAP: {
- fb_render_string("0x0000000A: Kernel has finished running, running OSLdr...", start_y, x, panic_text);
- return;
- }
- case RUNTIME_CHECK_HANDSHAKE: {
- fb_render_string("0x00000005: Handshake fault.", start_y, x, panic_text);
- break;
- }
- case RUNTIME_CHECK_IPC: {
- fb_render_string("0x00000003: Bad LPC message.", start_y, x, panic_text);
- break;
- }
- case RUNTIME_CHECK_INVALID_PRIVILEGE: {
- fb_render_string("0x00000007: Privilege access violation.", start_y, x, panic_text);
- break;
- case RUNTIME_CHECK_UNEXCPECTED: {
- fb_render_string("0x0000000B: Unexpected violation.", start_y, x, panic_text);
- break;
- }
- case RUNTIME_CHECK_VIRTUAL_OUT_OF_MEM: {
- fb_render_string("0x10000001: Out of virtual memory.", start_y, x, panic_text);
-
- break;
- }
- case RUNTIME_CHECK_FAILED: {
- fb_render_string("0x10000001: Kernel Bug check appears to have failed, a dump has been written to the storage.", start_y, x, panic_text);
- break;
- }
- default: {
- fb_render_string("0xFFFFFFFC: Unknown Kernel Error code.", start_y, x, panic_text);
- break;
- }
- }
- };
-
- RecoveryFactory::Recover();
- }
-
- Void RecoveryFactory::Recover() noexcept
- {
- while (YES)
- {
- HAL::rt_halt();
- }
- }
-
- 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_panic(RUNTIME_CHECK_FAILED); // Runtime Check failed
- }
- }
-} // namespace Kernel
diff --git a/dev/Kernel/src/UserProcessScheduler.cc b/dev/Kernel/src/UserProcessScheduler.cc
index 831acf42..03fa58f6 100644
--- a/dev/Kernel/src/UserProcessScheduler.cc
+++ b/dev/Kernel/src/UserProcessScheduler.cc
@@ -12,7 +12,6 @@
/// @brief Low level/Ring-3 process scheduler.
/***********************************************************************************/
-#include "HALKit/AMD64/Processor.h"
#include <KernelKit/UserProcessScheduler.h>
#include <KernelKit/HardwareThreadScheduler.h>
#include <KernelKit/IPEFDLLObject.h>
diff --git a/dev/Kernel/src/Utils.cc b/dev/Kernel/src/Utils.cc
index 9f4a8609..9df612a3 100644
--- a/dev/Kernel/src/Utils.cc
+++ b/dev/Kernel/src/Utils.cc
@@ -109,7 +109,7 @@ namespace Kernel
return nullptr;
voidPtr v_src = reinterpret_cast<voidPtr>(const_cast<char*>(src));
- voidPtr v_dst = reinterpret_cast<voidPtr>(const_cast<char*>(string));
+ voidPtr v_dst = reinterpret_cast<voidPtr>(const_cast<char*>(string));
rt_copy_memory(v_src, v_dst, rt_string_len(src) + 1);
@@ -132,29 +132,6 @@ namespace Kernel
return character;
}
- Bool rt_to_string(Char* str, Int32 limit, Int32 base)
- {
- if (limit == 0)
- return false;
-
- Int copy_limit = limit;
- Int cnt = 0;
- Int ret = base;
-
- while (limit != 1)
- {
- ret = ret % 10;
- str[cnt] = ret;
-
- ++cnt;
- --limit;
- --ret;
- }
-
- str[copy_limit] = '\0';
- return true;
- }
-
Boolean is_space(Char chr)
{
return chr == ' ';
@@ -165,7 +142,7 @@ namespace Kernel
return chr == '\n';
}
- voidPtr rt_string_in_string(const Char* in, const Char* needle)
+ VoidPtr rt_string_in_string(const Char* in, const Char* needle)
{
for (SizeT i = 0; i < rt_string_len(in); ++i)
{
@@ -176,7 +153,45 @@ namespace Kernel
return nullptr;
}
- // @brief Checks for a string start at the character.
+ Char rt_to_char(UInt64 base, Int32 limit)
+ {
+ const Char kNumbers[17] = "0123456789ABCDEF";
+ return kNumbers[base % limit];
+ }
+
+ Bool rt_to_string(Char* str, UInt64 base, Int32 limit)
+ {
+#ifdef __ZKA_AMD64__
+ auto i = 0;
+
+ auto final_number = base;
+
+ auto mult = 1;
+ auto elems = 0L;
+
+ base /= 10;
+
+ while (base > 0)
+ {
+ elems++;
+ mult *= 10;
+ base /= 10;
+ }
+
+ while (elems > -1)
+ {
+ final_number = (final_number % mult) * 10 + final_number / mult;
+ str[i] = rt_to_char(final_number, limit);
+
+ --elems;
+ ++i;
+ }
+#endif
+
+ return YES;
+ }
+
+ /// @brief Checks for a string start at the character.
Char* rt_string_has_char(Char* str, const Char chr)
{