diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-29 12:53:57 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-29 12:53:57 -0400 |
| commit | c2788174198632e0c8bdbfa7762081f595460bdf (patch) | |
| tree | 373b1f5c7cfe0e87f29c1c8956579c58b4f22bf9 /arch/x86_64/panic/panic.c | |
| parent | 8de23ca36173cfdb3c609074496115ebd9045887 (diff) | |
| download | jove-kernel-c2788174198632e0c8bdbfa7762081f595460bdf.tar.gz jove-kernel-c2788174198632e0c8bdbfa7762081f595460bdf.tar.bz2 jove-kernel-c2788174198632e0c8bdbfa7762081f595460bdf.zip | |
move process code into proc. add panic folder
Diffstat (limited to 'arch/x86_64/panic/panic.c')
| -rw-r--r-- | arch/x86_64/panic/panic.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/arch/x86_64/panic/panic.c b/arch/x86_64/panic/panic.c new file mode 100644 index 0000000..a19f807 --- /dev/null +++ b/arch/x86_64/panic/panic.c @@ -0,0 +1,45 @@ +#include "panic/panic.h" +#include "arch/x86_64/hal/idt.h" +#include "arch/x86_64/x86_64.h" +#include "arch/x86_64/hal/paging.h" +#include "lib/printf.h" + +__attribute__((naked)) +void* +__panic_get_bp(void) +{ + asm("movq %%rbp, %%rax; \ + retq"::: "memory"); +} + +void* +__panic_print_istate(void *state) +{ + struct int_stackframe *int_state = state; + kprintf("RIP: %p | RSP: %p\n", int_state->int_rip, int_state->int_rsp); + + print_state(&int_state->state); + return (void*)int_state->state.rbp; +} + +void +__panic_stack_trace(void *bp) +{ + uintmax_t *rbp = (uintmax_t*)bp; + kprintf("\nStack trace:\n"); + + while(rbp) { + kprintf("%p:\n", rbp[1]); + uintmax_t *next = (uintmax_t*)rbp[0]; + ptrdiff_t dist = (next - rbp); + + if((uintptr_t)next < IDENT_VIRT_BASE) break; + if(dist > 0) { + for(size_t i = 0; i < dist; i++) { + kprintf(" %p\n", rbp[i]); + } + } + + rbp = next; + } +} |
