From ef1166f6e83d72df360a6dfc2f6643d826ce07ba Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Mon, 12 Apr 2021 15:10:16 +0000 Subject: panic() and halt() now in kernel private interface --- kernel/panic.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 kernel/panic.c (limited to 'kernel/panic.c') 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"); +} -- cgit v1.3.1-1-g115d