/* * This file implements the kernel panic routine. It prints the error message * to the debug port then halts the system. Since nothing runs after this, it * is essentially a shutdown routine. In an idea kernel, this wouldn't need to * be compiled in. */ #include #include /* Kernel panic */ _Noreturn void panic(char *fmt, ...) { outb(0xE9, '\033'); outb(0xE9, '['); outb(0xE9, '3'); outb(0xE9, '1'); outb(0xE9, 'm'); char buf[1024], *p = buf; /* Print error to serial port */ va_list args; va_start(args, fmt); vsprintf(buf, fmt, args); va_end(args); while (*p) outb(0xE9, *p++); outb(0xE9, '\n'); /* Halt processor */ asm volatile("cli"); while (1) asm volatile("hlt"); __builtin_unreachable(); }