From 6ad1b899ed93f8bc110cdec7a722c8740f9f8d66 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 31 Jul 2023 22:24:29 +0300 Subject: start working on irqs --- common/panic.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 common/panic.c (limited to 'common/panic.c') diff --git a/common/panic.c b/common/panic.c new file mode 100644 index 0000000..c2b6948 --- /dev/null +++ b/common/panic.c @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: copyleft-next-0.3.1 */ + +/** + * @file panic.c + * Kernel panic handler implementation. + */ + +#include +#include + +void kernel_panic(void *pc, void *addr, long cause) +{ + /* could be useful to print out register values as well? */ + error("kernel paniced at pc: %p with address %p and cause %lx\n", + pc, addr, cause); + + info("attempting to reboot\n"); + + poweroff(COLD_REBOOT); + + /* spin if poweroff failed for some reason */ + error("reboot failed, spinning in place\n"); + while (1); +} -- cgit v1.3