From e303a03e7c96bc5bf7fa93f7b46ce63196893d7a Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Sun, 19 Dec 2021 22:41:15 +0000 Subject: moving files around --- kc/core/panic.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 kc/core/panic.c (limited to 'kc/core/panic.c') 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 + +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"); +} -- cgit v1.3.1-1-g115d