2011-12-11 03:34:10 +04:00
|
|
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
|
|
|
*
|
|
|
|
* Panic functions
|
|
|
|
*/
|
2011-01-21 04:49:35 +03:00
|
|
|
#include <system.h>
|
|
|
|
|
2011-03-30 11:16:30 +04:00
|
|
|
void kernel_halt() {
|
2012-01-25 10:19:52 +04:00
|
|
|
kprintf("\n System Halted!\n\n");
|
2011-03-30 11:16:30 +04:00
|
|
|
|
|
|
|
while (1) {
|
2011-10-31 10:17:26 +04:00
|
|
|
IRQ_OFF;
|
|
|
|
PAUSE;
|
2011-03-30 11:16:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void halt_and_catch_fire(char * error_message, const char * file, int line, struct regs * regs) {
|
2011-10-31 10:17:26 +04:00
|
|
|
IRQ_OFF;
|
2011-12-15 11:46:22 +04:00
|
|
|
kprintf("\033[1;37;44m");
|
|
|
|
kprintf("HACF: %s\n", error_message);
|
|
|
|
kprintf("Proc: %d\n", getpid());
|
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
|
|
|
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-12-15 11:46:22 +04:00
|
|
|
kprintf("This process has been descheduled.\n");
|
|
|
|
kprintf("\033[0m");
|
2012-01-26 06:08:22 +04:00
|
|
|
kexit(1);
|
2011-01-21 04:49:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void assert_failed(const char *file, uint32_t line, const char *desc) {
|
2011-10-31 10:17:26 +04:00
|
|
|
IRQ_OFF;
|
2011-03-30 11:16:30 +04:00
|
|
|
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
|
|
|
}
|