toaruos/kernel/sys/panic.c

54 lines
1.7 KiB
C
Raw Normal View History

2014-06-08 10:51:01 +04:00
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* This file is part of ToaruOS and is released under the terms
* of the NCSA / University of Illinois License - see LICENSE.md
* Copyright (C) 2011-2014 Kevin Lange
*
* Panic functions
*/
2011-01-21 04:49:35 +03:00
#include <system.h>
2014-04-06 02:23:17 +04:00
#include <logging.h>
#include <printf.h>
2011-03-30 11:16:30 +04:00
void halt_and_catch_fire(char * error_message, const char * file, int line, struct regs * regs) {
IRQ_OFF;
2014-04-06 02:23:17 +04:00
debug_print(ERROR, "HACF: %s", error_message);
debug_print(ERROR, "Proc: %d", getpid());
debug_print(ERROR, "File: %s", file);
debug_print(ERROR, "Line: %d", line);
2011-03-30 11:16:30 +04:00
if (regs) {
2014-04-06 02:23:17 +04:00
debug_print(ERROR, "Registers at interrupt:");
debug_print(ERROR, "eax=0x%x ebx=0x%x", regs->eax, regs->ebx);
debug_print(ERROR, "ecx=0x%x edx=0x%x", regs->ecx, regs->edx);
debug_print(ERROR, "esp=0x%x ebp=0x%x", regs->esp, regs->ebp);
debug_print(ERROR, "Error code: 0x%x", regs->err_code);
debug_print(ERROR, "EFLAGS: 0x%x", regs->eflags);
debug_print(ERROR, "User ESP: 0x%x", regs->useresp);
debug_print(ERROR, "eip=0x%x", regs->eip);
2011-03-30 00:47:18 +04:00
}
2014-04-06 02:23:17 +04:00
debug_print(ERROR, "This process has been descheduled.");
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) {
IRQ_OFF;
2014-04-06 02:23:17 +04:00
debug_print(INSANE, "Kernel Assertion Failed: %s", desc);
debug_print(INSANE, "File: %s", file);
debug_print(INSANE, "Line: %d", line);
debug_print(INSANE, "System Halted!");
if (debug_video_crash) {
2014-06-01 12:32:33 +04:00
char msg[4][256];
sprintf(msg[0], "Kernel Assertion Failed: %s", desc);
sprintf(msg[1], "File: %s", file);
sprintf(msg[2], "Line: %d", line);
sprintf(msg[3], "System Halted!");
char * msgs[] = {msg[0], msg[1], msg[2], msg[3], NULL};
debug_video_crash(msgs);
}
2014-04-06 02:23:17 +04:00
while (1) {
IRQ_OFF;
PAUSE;
}
2011-01-21 04:49:35 +03:00
}