diff options
author | Benji Dial <benji@benjidial.net> | 2024-05-19 13:27:11 -0400 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2024-05-19 13:27:11 -0400 |
commit | 649ff9636fe7289749c91141bbf32b2dcbe6dde4 (patch) | |
tree | 5da6e8ddfd449b012d8936040e292fa4de534cc0 /kernel/source/interrupts.cpp | |
parent | f8ff95f19289a88706935abebd71e317355641d4 (diff) | |
download | hilbert-os-649ff9636fe7289749c91141bbf32b2dcbe6dde4.tar.gz |
add serial logging for exceptions, fix virtualbox issue
Diffstat (limited to 'kernel/source/interrupts.cpp')
-rw-r--r-- | kernel/source/interrupts.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/kernel/source/interrupts.cpp b/kernel/source/interrupts.cpp index f8e613e..4046021 100644 --- a/kernel/source/interrupts.cpp +++ b/kernel/source/interrupts.cpp @@ -1,4 +1,5 @@ #include <hilbert/kernel/framebuffer.hpp> +#include <hilbert/kernel/serial.hpp> #include <hilbert/kernel/input.hpp> #include <hilbert/kernel/panic.hpp> @@ -36,13 +37,47 @@ struct [[gnu::packed]] exception_info_t { extern exception_info_t exception_info; +static inline void print_reg(const char *regname, uint64_t value) { + serial_putstr(" "); + serial_putstr(regname); + serial_putstr(" = 0x"); + serial_puthex<16>(value); + serial_putchar('\n'); +} + extern "C" [[noreturn]] void print_exception() { //so exception_info's type is known by gdb exception_info_t the_exception_info = exception_info; (void)the_exception_info; - //TODO: log exception, and recover if possible. + serial_putstr("exception 0x"); + serial_puthex<2>(exception_info.exception_number); + serial_putchar('\n'); + + if (exception_info.has_error) + print_reg("error code", exception_info.error); + + print_reg("rflags", exception_info.rflags); + print_reg("rip", exception_info.rip); + print_reg("cr2", exception_info.cr2); + print_reg("cr3", exception_info.cr3); + print_reg("rax", exception_info.rax); + print_reg("rbx", exception_info.rbx); + print_reg("rcx", exception_info.rcx); + print_reg("rdx", exception_info.rdx); + print_reg("rdi", exception_info.rdi); + print_reg("rsi", exception_info.rsi); + print_reg("rbp", exception_info.rbp); + print_reg("rsp", exception_info.rsp); + print_reg("r8 ", exception_info.r8 ); + print_reg("r9 ", exception_info.r9 ); + print_reg("r10", exception_info.r10); + print_reg("r11", exception_info.r11); + print_reg("r12", exception_info.r12); + print_reg("r13", exception_info.r13); + print_reg("r14", exception_info.r14); + print_reg("r15", exception_info.r15); panic(0xba40bb); |