aboutsummaryrefslogtreecommitdiff
path: root/common/panic.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-07-31 22:24:29 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-07-31 22:24:29 +0300
commit6ad1b899ed93f8bc110cdec7a722c8740f9f8d66 (patch)
tree99fe36028ffc4583c59e77d03bea2ade7a6c5ace /common/panic.c
parent3212707a9ab549119ad0ad6441a07fe774c99f3b (diff)
downloadkmi-6ad1b899ed93f8bc110cdec7a722c8740f9f8d66.tar.gz
kmi-6ad1b899ed93f8bc110cdec7a722c8740f9f8d66.zip
start working on irqs
Diffstat (limited to 'common/panic.c')
-rw-r--r--common/panic.c24
1 files changed, 24 insertions, 0 deletions
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 <kmi/power.h>
+#include <kmi/debug.h>
+
+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);
+}