summaryrefslogtreecommitdiffhomepage
path: root/Private/Source/RuntimeCheck.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Private/Source/RuntimeCheck.cxx')
-rw-r--r--Private/Source/RuntimeCheck.cxx81
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