forked from Bananymous/banan-os
Kernel: Make IDT exceptions use a single Kernel:Panic
This allows IDT to print exceptions even when we dont have TTY
This commit is contained in:
parent
af8d486893
commit
77e82de51e
|
@ -45,16 +45,17 @@ static void (*s_irq_handlers[0xFF])() { nullptr };
|
||||||
uint32_t cr0, cr2, cr3, cr4; \
|
uint32_t cr0, cr2, cr3, cr4; \
|
||||||
asm volatile("":"=a"(eax),"=b"(ebx),"=c"(ecx),"=d"(edx)); \
|
asm volatile("":"=a"(eax),"=b"(ebx),"=c"(ecx),"=d"(edx)); \
|
||||||
asm volatile("movl %%esp, %%eax":"=a"(esp)); \
|
asm volatile("movl %%esp, %%eax":"=a"(esp)); \
|
||||||
asm volatile("movl %%ebp, %%eax":"=a"(esp)); \
|
asm volatile("movl %%ebp, %%eax":"=a"(ebp)); \
|
||||||
asm volatile("movl %%cr0, %%eax":"=a"(cr0)); \
|
asm volatile("movl %%cr0, %%eax":"=a"(cr0)); \
|
||||||
asm volatile("movl %%cr2, %%eax":"=a"(cr2)); \
|
asm volatile("movl %%cr2, %%eax":"=a"(cr2)); \
|
||||||
asm volatile("movl %%cr3, %%eax":"=a"(cr3)); \
|
asm volatile("movl %%cr3, %%eax":"=a"(cr3)); \
|
||||||
asm volatile("movl %%cr4, %%eax":"=a"(cr4)); \
|
asm volatile("movl %%cr4, %%eax":"=a"(cr4)); \
|
||||||
kprintln("\n\e[31mRegister dump"); \
|
Kernel::Panic("Register dump\r\n" \
|
||||||
kprintln("eax=0x{8H}, ebx=0x{8H}, ecx=0x{8H}, edx=0x{8H}", eax, ebx, ecx, edx); \
|
"eax=0x{8H}, ebx=0x{8H}, ecx=0x{8H}, edx=0x{8H}\r\n" \
|
||||||
kprintln("esp=0x{8H}, ebp=0x{8H}", esp, ebp); \
|
"esp=0x{8H}, ebp=0x{8H}\r\n" \
|
||||||
kprintln("CR0=0x{8H} CR2=0x{8H} CR3=0x{8H} CR4=0x{8H}", cr0, cr2, cr3, cr4); \
|
"CR0=0x{8H} CR2=0x{8H} CR3=0x{8H} CR4=0x{8H}\r\n", \
|
||||||
Kernel::Panic(msg); \
|
msg, \
|
||||||
|
eax, ebx, ecx, edx, esp, ebp, cr0, cr2, cr3, cr4); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INTERRUPT_HANDLER_ERR(i, msg) \
|
#define INTERRUPT_HANDLER_ERR(i, msg) \
|
||||||
|
@ -66,17 +67,18 @@ static void (*s_irq_handlers[0xFF])() { nullptr };
|
||||||
uint32_t error_code; \
|
uint32_t error_code; \
|
||||||
asm volatile("":"=a"(eax),"=b"(ebx),"=c"(ecx),"=d"(edx)); \
|
asm volatile("":"=a"(eax),"=b"(ebx),"=c"(ecx),"=d"(edx)); \
|
||||||
asm volatile("movl %%esp, %%eax":"=a"(esp)); \
|
asm volatile("movl %%esp, %%eax":"=a"(esp)); \
|
||||||
asm volatile("movl %%ebp, %%eax":"=a"(esp)); \
|
asm volatile("movl %%ebp, %%eax":"=a"(ebp)); \
|
||||||
asm volatile("movl %%cr0, %%eax":"=a"(cr0)); \
|
asm volatile("movl %%cr0, %%eax":"=a"(cr0)); \
|
||||||
asm volatile("movl %%cr2, %%eax":"=a"(cr2)); \
|
asm volatile("movl %%cr2, %%eax":"=a"(cr2)); \
|
||||||
asm volatile("movl %%cr3, %%eax":"=a"(cr3)); \
|
asm volatile("movl %%cr3, %%eax":"=a"(cr3)); \
|
||||||
asm volatile("movl %%cr4, %%eax":"=a"(cr4)); \
|
asm volatile("movl %%cr4, %%eax":"=a"(cr4)); \
|
||||||
asm volatile("popl %%eax":"=a"(error_code)); \
|
asm volatile("popl %%eax":"=a"(error_code)); \
|
||||||
kprintln("\n\e[31mRegister dump"); \
|
Kernel::Panic("Register dump\r\n" \
|
||||||
kprintln("eax=0x{8H}, ebx=0x{8H}, ecx=0x{8H}, edx=0x{8H}", eax, ebx, ecx, edx); \
|
"eax=0x{8H}, ebx=0x{8H}, ecx=0x{8H}, edx=0x{8H}\r\n" \
|
||||||
kprintln("esp=0x{8H}, ebp=0x{8H}", esp, ebp); \
|
"esp=0x{8H}, ebp=0x{8H}\r\n" \
|
||||||
kprintln("CR0=0x{8H} CR2=0x{8H} CR3=0x{8H} CR4=0x{8H}", cr0, cr2, cr3, cr4); \
|
"CR0=0x{8H} CR2=0x{8H} CR3=0x{8H} CR4=0x{8H}\r\n" \
|
||||||
Kernel::Panic(msg " (error code: 0x{8H})", error_code); \
|
msg " (error code: 0x{8H})", \
|
||||||
|
eax, ebx, ecx, edx, esp, ebp, cr0, cr2, cr3, cr4, error_code); \
|
||||||
}
|
}
|
||||||
|
|
||||||
INTERRUPT_HANDLER____(0x00, "Division Error")
|
INTERRUPT_HANDLER____(0x00, "Division Error")
|
||||||
|
|
Loading…
Reference in New Issue