summaryrefslogtreecommitdiff
path: root/kernel/panic.c
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2021-04-12 15:10:16 +0000
committerAda Christine <adachristine18@gmail.com>2021-04-12 15:10:16 +0000
commitef1166f6e83d72df360a6dfc2f6643d826ce07ba (patch)
tree1363fee07ae473b2bf81bb863792e58b1d53bb90 /kernel/panic.c
parentce2c1768fc9c0537136ff0af563766e23f2e9355 (diff)
panic() and halt() now in kernel private interface
Diffstat (limited to 'kernel/panic.c')
-rw-r--r--kernel/panic.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/kernel/panic.c b/kernel/panic.c
new file mode 100644
index 0000000..7a3a729
--- /dev/null
+++ b/kernel/panic.c
@@ -0,0 +1,21 @@
+#include "panic.h"
+
+static char const *reason_strings[] = {
+ "general panic",
+ "unhandled fault",
+};
+
+noreturn void panic(enum panic_reason reason)
+{
+ // TODO: kprintf() and friends
+ kputs("kernel panic: ")
+ kputs(reason_strings[reason]);
+ kputs("\n");
+ halt();
+}
+
+noreturn void halt(void)
+{
+ __asm__ ("cli\n\t");
+ while (true) __asm__ ("hlt\n\t");
+}