[panic] Add separate kernel-mode panic handler
Created the framework for using different loadable panic handlers, loaded by the bootloader. Initial panic handler is panic.serial, which contains its own serial driver and stacktrace code. Other related changes: - Asserts are now based on the NMI handler - panic handlers get installed as the NMI interrupt handler - Changed symbol table generation: now use nm's own demangling and sorting, and include symbol size in the table - Move the linker script argument out of the kernel target, and into the kernel's specific module, so that other programs (ie, panic handlers) can use the kernel target as well - Some asm changes to boot.s to help GDB see stack frames - but this might not actually be all that useful - Renamed user_rsp to just rsp in cpu_state - everything in there is describing the 'user' state
This commit is contained in:
27
src/kernel/panic.serial/main.cpp
Normal file
27
src/kernel/panic.serial/main.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "display.h"
|
||||
#include "serial.h"
|
||||
#include "symbol_table.h"
|
||||
|
||||
struct cpu_state;
|
||||
|
||||
extern "C"
|
||||
void panic_handler(
|
||||
const char *message,
|
||||
const void *symbol_data,
|
||||
const cpu_state *regs)
|
||||
{
|
||||
panic::serial_port com1(panic::COM1);
|
||||
panic::symbol_table syms(symbol_data);
|
||||
|
||||
panic::frame const *fp = nullptr;
|
||||
asm ( "mov %%rbp, %0" : "=r" (fp) );
|
||||
|
||||
// Skip the panic handler itself
|
||||
if (fp) fp = fp->prev;
|
||||
|
||||
print_header(com1, message);
|
||||
print_callstack(com1, syms, fp);
|
||||
print_cpu_state(com1, *regs);
|
||||
|
||||
while (1) asm ("hlt");
|
||||
}
|
||||
Reference in New Issue
Block a user