From c95f8d146849ac1a5a0eb550e08b6010ae7234aa Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Fri, 16 Feb 2024 12:52:09 -0600 Subject: kernel: add a panic function Add a panic function that stops the current CPU and prints an error message into the ring buffer. Signed-off-by: Danny Holman --- include/kernel/panic.h | 6 ++++++ kernel/panic.c | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 include/kernel/panic.h create mode 100644 kernel/panic.c diff --git a/include/kernel/panic.h b/include/kernel/panic.h new file mode 100644 index 0000000..529702b --- /dev/null +++ b/include/kernel/panic.h @@ -0,0 +1,6 @@ +#ifndef KERNEL_PANIC_H +#define KERNEL_PANIC_H + +void panic(const char *str); + +#endif diff --git a/kernel/panic.c b/kernel/panic.c new file mode 100644 index 0000000..c75fafb --- /dev/null +++ b/kernel/panic.c @@ -0,0 +1,8 @@ +#include +#include + +void panic(const char *str) { + kprintf("KERNEL PANIC\n"); + kprintf("ERROR: %s\n", str); + while (1); +} -- cgit v1.2.3