summaryrefslogtreecommitdiff
path: root/kc/core/panic.c
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2021-12-19 22:41:15 +0000
committerAda Christine <adachristine18@gmail.com>2021-12-19 22:41:15 +0000
commite303a03e7c96bc5bf7fa93f7b46ce63196893d7a (patch)
treef187b374feec85015d6df1f94db618a3f5cc893f /kc/core/panic.c
parentbff63a4337eb3388617d230970c5eb2684d6a215 (diff)
moving files around
Diffstat (limited to 'kc/core/panic.c')
-rw-r--r--kc/core/panic.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/kc/core/panic.c b/kc/core/panic.c
new file mode 100644
index 0000000..b0d9daf
--- /dev/null
+++ b/kc/core/panic.c
@@ -0,0 +1,25 @@
+#include "panic.h"
+#include "kprint.h"
+
+#include <stdbool.h>
+
+static char const *reason_strings[] = {
+ "general panic",
+ "unhandled fault",
+ "out of memory"
+};
+
+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");
+}