Added register dump to Trap IRQs

This commit is contained in:
2026-03-22 14:26:53 +01:00
parent 421a83d202
commit e8d5a8be35
2 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ struct isr_int_frame {
// Pushed by CPU // Pushed by CPU
uint64_t rip, cs, rflags, user_rsp, user_ss; uint64_t rip, cs, rflags, user_rsp, user_ss;
}; } __packed;
typedef void (*isr_handler_ptr)(struct isr_int_frame* iframe); typedef void (*isr_handler_ptr)(struct isr_int_frame* iframe);
int isr_init(void); int isr_init(void);
+11 -2
View File
@@ -75,7 +75,7 @@ int isr_init(void) {
} }
idt_set_gate(0x03, isr_redirect_table[3], IDT_FLAG_USER); // Allow breakpoints idt_set_gate(0x03, isr_redirect_table[3], IDT_FLAG_USER); // Allow breakpoints
idt_set_gate(0x80, isr128, IDT_FLAG_USER); // Syscall idt_set_gate(0x80, isr128, IDT_FLAG_USER); // Syscall
//
pic_remap(); pic_remap();
// TODO: apic_init(); // TODO: apic_init();
@@ -99,7 +99,16 @@ void isr_handle_interrupt(size_t rsp) {
struct isr_int_frame* iframe = (void*)rsp; struct isr_int_frame* iframe = (void*)rsp;
if (iframe->interrupt < 32) { if (iframe->interrupt < 32) {
if (iframe->error) debugf("[kernel] Error code: 0x%08x\n", iframe->error); debugf("[kernel] Register Dump:\n");
debugf("\tRAX: %016lu RBX: %016lu RCX: %016lx\n", iframe->rax, iframe->rbx, iframe->rcx);
debugf("\tRDX: %016lu RSI: %016lu RDI: %016lx\n", iframe->rdx, iframe->rsi, iframe->rdi);
debugf("\tR08: %016lu R09: %016lu R10: %016lx\n", iframe->r8, iframe->r9, iframe->r10);
debugf("\tR11: %016lu R12: %016lu R13: %016lx\n", iframe->r11, iframe->r12, iframe->r13);
debugf("\tR14: %016lu R15: %016lu DS/ES: %016lx\n", iframe->r14, iframe->r15, iframe->ds);
debugf("\tRBP: %016lu RSP: %016lu SS: %016lx\n", iframe->rbp, iframe->user_rsp, iframe->user_ss);
debugf("\tRIP: %016lu RFLAGS: %016lx CS: %016lx\n", iframe->rip, iframe->rflags, iframe->cs);
if (iframe->error) debugf("[kernel] Error code: 0x%lx\n", iframe->error);
panic(exceptions[iframe->interrupt]); panic(exceptions[iframe->interrupt]);
} else if (iframe->interrupt >= 32 && iframe->interrupt < 48) { } else if (iframe->interrupt >= 32 && iframe->interrupt < 48) {
// ISRs 32-47 - Hardware interrupts // ISRs 32-47 - Hardware interrupts