toaruos/kernel/core/panic.c

40 lines
1.1 KiB
C
Raw Normal View History

2011-01-21 04:49:35 +03:00
#include <system.h>
2011-03-30 11:16:30 +04:00
void kernel_halt() {
settextcolor(4,15);
2011-04-16 03:42:31 +04:00
kprintf("\n \x13 System Halted!\n\n");
2011-03-30 11:16:30 +04:00
while (1) {
__asm__ __volatile__ ("cli");
__asm__ __volatile__ ("hlt");
}
}
void halt_and_catch_fire(char * error_message, const char * file, int line, struct regs * regs) {
2011-01-21 04:49:35 +03:00
__asm__ __volatile__("cli");
settextcolor(14,4);
kprintf("PANIC! %s\n", error_message);
kprintf("File: %s\n", file);
kprintf("Line: %d\n", line);
2011-03-30 11:16:30 +04:00
if (regs) {
kprintf("Registers at interrupt:\n");
kprintf("eax=0x%x ebx=0x%x\n", regs->eax, regs->ebx);
kprintf("ecx=0x%x edx=0x%x\n", regs->ecx, regs->edx);
kprintf("esp=0x%x ebp=0x%x\n", regs->esp, regs->ebp);
kprintf("Error code: 0x%x\n", regs->err_code);
kprintf("EFLAGS: 0x%x\n", regs->eflags);
kprintf("User ESP: 0x%x\n", regs->useresp);
kprintf("eip=0x%x\n", regs->eip);
2011-03-30 00:47:18 +04:00
}
2011-03-30 11:16:30 +04:00
kernel_halt();
2011-01-21 04:49:35 +03:00
}
void assert_failed(const char *file, uint32_t line, const char *desc) {
__asm__ __volatile__("cli");
2011-03-30 11:16:30 +04:00
settextcolor(14,3);
kprintf("Kernel Assertion Failed: %s\n", desc);
2011-01-21 04:49:35 +03:00
kprintf("File: %s\n", file);
kprintf("Line: %d\n", line);
2011-03-30 11:16:30 +04:00
kernel_halt();
2011-01-21 04:49:35 +03:00
}