Pass exception stack frame pointer to exception handler
Show exception stack frame contents on exception
This commit is contained in:
parent
01c73f8474
commit
2fa4193517
@ -9,9 +9,21 @@ import hulk.fb;
|
||||
import hulk.console;
|
||||
import hulk.klog;
|
||||
import hulk.apic;
|
||||
import hulk.cpu;
|
||||
|
||||
struct Idt
|
||||
{
|
||||
static struct ExceptionStackFrame
|
||||
{
|
||||
ulong rip;
|
||||
ulong cs;
|
||||
ulong rflags;
|
||||
ulong rsp;
|
||||
ulong ss;
|
||||
}
|
||||
|
||||
public static enum ulong EXC_PAGE_FAULT = 14;
|
||||
|
||||
/* The I/O APIC is configured to map IRQ 0 to interrupt 64 (0x40). */
|
||||
public static enum ulong INT_APIC_BASE = 0x40u; /* IRQ 0 */
|
||||
public static enum ulong INT_APIC_COUNT = 24u;
|
||||
@ -74,10 +86,13 @@ struct Idt
|
||||
pushq %rdi
|
||||
pushq %rsi
|
||||
pushq %rax
|
||||
pushq %rdx
|
||||
mov $$", isr, ", %rdi
|
||||
" ~ (isr_has_error_code(isr) ? "mov 0x18(%rsp), %rsi" : "") ~ "
|
||||
" ~ (isr_has_error_code(isr) ? "mov 0x20(%rsp), %rsi" : "") ~ "
|
||||
" ~ (isr_has_error_code(isr) ? "lea 0x28(%rsp), %rdx" : "lea 0x20(%rsp), %rdx") ~ "
|
||||
movabs $$isr, %rax
|
||||
callq *%rax
|
||||
popq %rdx
|
||||
popq %rax
|
||||
popq %rsi
|
||||
popq %rdi
|
||||
@ -102,7 +117,7 @@ struct Idt
|
||||
}
|
||||
}
|
||||
|
||||
public extern(C) void isr(ulong vector, ulong arg)
|
||||
public extern(C) void isr(ulong vector, ulong arg, Idt.ExceptionStackFrame * stack_frame)
|
||||
{
|
||||
if ((vector >= Idt.INT_APIC_BASE) && (vector < (Idt.INT_APIC_BASE + Idt.INT_APIC_COUNT)))
|
||||
{
|
||||
@ -122,7 +137,13 @@ public extern(C) void isr(ulong vector, ulong arg)
|
||||
default:
|
||||
Console.clear();
|
||||
Fb.clear(0xFF8000u);
|
||||
Klog.writefln("ISR %u, 0x%x", vector, arg);
|
||||
Klog.writefln("ISR %u, error code 0x%x", vector, arg);
|
||||
Klog.writefln("RIP = 0x%p", stack_frame.rip);
|
||||
Klog.writefln("CS = 0x%x", stack_frame.cs);
|
||||
Klog.writefln("RFLAGS = 0x%x", stack_frame.rflags);
|
||||
Klog.writefln("RSP = 0x%x", stack_frame.rsp);
|
||||
Klog.writefln("SS = 0x%x", stack_frame.ss);
|
||||
Klog.writefln("CR2 = 0x%p", read_cr2());
|
||||
__asm("cli", "");
|
||||
for (;;)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user