From c2d2679a37ccf98e1294dcf041610addec9a60ee Mon Sep 17 00:00:00 2001 From: Alan Jian Date: Fri, 21 Jun 2024 09:36:15 +0800 Subject: [PATCH] Hang the system in kernel panic --- include/hang.h | 6 ++++++ src/log.c | 2 ++ src/syscalls/reboot.c | 6 +----- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 include/hang.h diff --git a/include/hang.h b/include/hang.h new file mode 100644 index 0000000..1f55e74 --- /dev/null +++ b/include/hang.h @@ -0,0 +1,6 @@ +#pragma once + +[[noreturn]] static inline void hang() { + while (true) + ; +} diff --git a/src/log.c b/src/log.c index e0404ed..75ddd54 100644 --- a/src/log.c +++ b/src/log.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -80,6 +81,7 @@ void klogf(log_severity_t severity, const char *fmt, ...) { break; case LOG_SEVERITY_PANIC: kprintf("[\x1B[41mpanic\x1B[0m] "); + hang(); break; } kvprintf(fmt, args); diff --git a/src/syscalls/reboot.c b/src/syscalls/reboot.c index 2d47247..089a6c6 100644 --- a/src/syscalls/reboot.c +++ b/src/syscalls/reboot.c @@ -1,6 +1,7 @@ #include #include +#include #include typedef enum { @@ -9,11 +10,6 @@ typedef enum { REBOOT_TYPE_HANG = 2, } reboot_type_t; -[[noreturn]] void hang(void) { - while (true) - ; -} - isize sys_reboot(const trapframe_t *frame) { reboot_type_t type = frame->a0;