37 lines
812 B
C
37 lines
812 B
C
#include <zinnia/irq.h>
|
|
#include <zinnia/panic.h>
|
|
#include <zinnia/percpu.h>
|
|
#include <zinnia/print.h>
|
|
#include <stdarg.h>
|
|
|
|
#define panic_log(msg, ...) kprintf("[ !!!! ] \e[31m" msg "\e[0m", ##__VA_ARGS__)
|
|
|
|
[[noreturn]]
|
|
void panic(const char* msg, ...) {
|
|
// TODO: Stop all other CPUs with IPI.
|
|
irq_set_state(false);
|
|
|
|
struct percpu* cpu = percpu_get();
|
|
struct task* current = cpu->sched.current;
|
|
kprintf(
|
|
"[ !!!! ] \e[31m"
|
|
"Kernel panic on CPU %zu (T%zu, \"%s\"): ",
|
|
cpu->id,
|
|
current ? current->id : 0,
|
|
current ? current->name : nullptr
|
|
);
|
|
|
|
va_list args;
|
|
va_start(args, msg);
|
|
kvprintf(msg, args);
|
|
va_end(args);
|
|
|
|
kprintf("\e[0m");
|
|
|
|
panic_log("End of panic message\n");
|
|
|
|
while (1) {
|
|
irq_wait();
|
|
}
|
|
}
|