Skip to content

Commit

Permalink
Hang the system in kernel panic
Browse files Browse the repository at this point in the history
  • Loading branch information
alanjian85 committed Jun 25, 2024
1 parent a04347e commit c2d2679
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 6 additions & 0 deletions include/hang.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

[[noreturn]] static inline void hang() {
while (true)
;
}
2 changes: 2 additions & 0 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <config.h>
#include <dev.h>
#include <driver.h>
#include <hang.h>
#include <init.h>
#include <module.h>
#include <stdarg.h>
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions src/syscalls/reboot.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <syscall.h>

#include <errno.h>
#include <hang.h>
#include <sbi.h>

typedef enum {
Expand All @@ -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;

Expand Down

0 comments on commit c2d2679

Please sign in to comment.