diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-12-31 15:24:18 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-12-31 15:24:18 +0100 |
| commit | 510c659355d9227d1b75edfe50c1b8691ea2f982 (patch) | |
| tree | 56b5cc1b536555c5b313d4fb104410f9cf04fff0 /dev/Kernel/HALKit/AMD64/HalKernelPanic.cc | |
| parent | e48bf6e7af428f34bd85b733060554cfec6591d5 (diff) | |
IMPL: Better panic screen, fixing CUSA as in the gh issue.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/HALKit/AMD64/HalKernelPanic.cc')
| -rw-r--r-- | dev/Kernel/HALKit/AMD64/HalKernelPanic.cc | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/dev/Kernel/HALKit/AMD64/HalKernelPanic.cc b/dev/Kernel/HALKit/AMD64/HalKernelPanic.cc new file mode 100644 index 00000000..ac41f7fa --- /dev/null +++ b/dev/Kernel/HALKit/AMD64/HalKernelPanic.cc @@ -0,0 +1,93 @@ +/* ------------------------------------------- + + 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> +#include <NewKit/Utils.h> + +/* Each error code is attributed with an ID, which will prompt a string onto the + * screen. Wait for debugger... */ + +namespace Kernel +{ + /// @brief Dumping factory class. + class RecoveryFactory final + { + public: + STATIC Void Recover() noexcept; + }; + + /***********************************************************************************/ + /// @brief Stops execution of the kernel. + /// @param id kernel stop ID. + /***********************************************************************************/ + Void ke_panic(const Kernel::Int32& id, const Char* message) + { + fb_init(); + + auto panic_text = RGB(0xff, 0xff, 0xff); + + auto y = 10; + auto x = 10; + + Char* message_apicid = new Char[128]; + rt_set_memory(message_apicid, 0, 128); + + rt_copy_memory((VoidPtr) "panic id: ", message_apicid, rt_string_len("panic id: ")); + rt_to_string(message_apicid + rt_string_len("panic id: "), (UIntPtr)id, 10); + + fb_render_string(message_apicid, y, x, panic_text); + + y += 10; + + fb_render_string((message ? message : "message: panic raised, going nowhere after this!"), y, x, panic_text); + + y += 10; + + Char* message_cr2 = new Char[128]; + rt_set_memory(message_cr2, 0, 128); + + rt_copy_memory((VoidPtr) "cr2: ", message_cr2, rt_string_len("cr2: ")); + rt_to_string(message_cr2 + rt_string_len("cr2: "), (UIntPtr)hal_read_cr2(), 10); + + fb_render_string(message_cr2, y, x, panic_text); + + kcout << message_apicid; + kcout << message_cr2; + + y += 10; + + fb_clear(); + + 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, file); // Runtime Check failed + } + } +} // namespace Kernel |
