diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-30 08:46:09 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-30 08:46:09 +0100 |
| commit | d7112cd6909640afd7609b3a142bc6ecf921ee25 (patch) | |
| tree | 55033ad28d58d536c4b3bad715d8635f00773bfd /Private/Source/RuntimeCheck.cxx | |
| parent | f22e69b8837b84548f79e0b8ca7bef24605c6611 (diff) | |
Kernel: Breaking changes, see source code.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/Source/RuntimeCheck.cxx')
| -rw-r--r-- | Private/Source/RuntimeCheck.cxx | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/Private/Source/RuntimeCheck.cxx b/Private/Source/RuntimeCheck.cxx new file mode 100644 index 00000000..09440a20 --- /dev/null +++ b/Private/Source/RuntimeCheck.cxx @@ -0,0 +1,81 @@ +/* + * ======================================================== + * + * HCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <ArchKit/Arch.hpp> +#include <KernelKit/DebugOutput.hpp> +#include <NewKit/RuntimeCheck.hpp> +#include <NewKit/String.hpp> + +extern "C" [[noreturn]] void wait_for_debugger() { + while (true) { + HCore::HAL::rt_cli(); + HCore::HAL::rt_halt(); + } +} + +/* Each error code is attributed with an ID, which will prompt a string onto the + * screen. Wait for debugger... */ + +namespace HCore { +void ke_stop(const HCore::Int &id) { + kcout << "*** STOP *** \r\n"; + kcout << "*** HCoreKrnl.exe has trigerred a runtime breakpoint. *** \r\n"; + + switch (id) { + case RUNTIME_CHECK_PROCESS: { + kcout << "*** CAUSE: RUNTIME_CHECK_PROCESS *** \r\n"; + break; + } + case RUNTIME_CHECK_ACPI: { + kcout << "*** CAUSE: RUNTIME_CHECK_ACPI *** \r\n"; + break; + } + case RUNTIME_CHECK_POINTER: { + kcout << "*** CAUSE: RUNTIME_CHECK_POINTER *** \r\n"; + break; + } + case RUNTIME_CHECK_BAD_BEHAVIOR: { + kcout << "*** CAUSE: RUNTIME_CHECK_BAD_BEHAVIOR *** \r\n"; + break; + } + case RUNTIME_CHECK_BOOTSTRAP: { + kcout << "*** CAUSE: RUNTIME_CHECK_BOOTSTRAP *** \r\n"; + break; + } + case RUNTIME_CHECK_HANDSHAKE: { + kcout << "*** CAUSE: RUNTIME_CHECK_HANDSHAKE *** \r\n"; + break; + } + case RUNTIME_CHECK_LD: { + kcout << "*** CAUSE: RUNTIME_CHECK_LD *** \r\n"; + break; + } + case RUNTIME_CHECK_INVALID_PRIVILEGE: { + kcout << "*** CAUSE: RUNTIME_CHECK_INVALID_PRIVILEGE *** \r\n"; + break; + } + }; + + DumpManager::Dump(); + wait_for_debugger(); +} + +void runtime_check(bool expr, const char *file, const char *line) { + if (!expr) { +#ifdef __DEBUG__ + kcout << "[KERNEL] Check Failed!\n"; + kcout << "[KERNEL] File: " << file << "\n"; + kcout << "[KERNEL] Where: " << line << "\n"; + +#endif // __DEBUG__ + + HCore::ke_stop(RUNTIME_CHECK_FAILED); // Runtime Check failed + } +} +} // namespace HCore |
