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:
Bananymous 2023-01-13 14:39:49 +02:00
parent af8d486893
commit 77e82de51e
1 changed files with 14 additions and 12 deletions

View File

@ -45,16 +45,17 @@ static void (*s_irq_handlers[0xFF])() { nullptr };
uint32_t cr0, cr2, cr3, cr4; \
asm volatile("":"=a"(eax),"=b"(ebx),"=c"(ecx),"=d"(edx)); \
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 %%cr2, %%eax":"=a"(cr2)); \
asm volatile("movl %%cr3, %%eax":"=a"(cr3)); \
asm volatile("movl %%cr4, %%eax":"=a"(cr4)); \
kprintln("\n\e[31mRegister dump"); \
kprintln("eax=0x{8H}, ebx=0x{8H}, ecx=0x{8H}, edx=0x{8H}", eax, ebx, ecx, edx); \
kprintln("esp=0x{8H}, ebp=0x{8H}", esp, ebp); \
kprintln("CR0=0x{8H} CR2=0x{8H} CR3=0x{8H} CR4=0x{8H}", cr0, cr2, cr3, cr4); \
Kernel::Panic(msg); \
Kernel::Panic("Register dump\r\n" \
"eax=0x{8H}, ebx=0x{8H}, ecx=0x{8H}, edx=0x{8H}\r\n" \
"esp=0x{8H}, ebp=0x{8H}\r\n" \
"CR0=0x{8H} CR2=0x{8H} CR3=0x{8H} CR4=0x{8H}\r\n", \
msg, \
eax, ebx, ecx, edx, esp, ebp, cr0, cr2, cr3, cr4); \
}
#define INTERRUPT_HANDLER_ERR(i, msg) \
@ -66,17 +67,18 @@ static void (*s_irq_handlers[0xFF])() { nullptr };
uint32_t error_code; \
asm volatile("":"=a"(eax),"=b"(ebx),"=c"(ecx),"=d"(edx)); \
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 %%cr2, %%eax":"=a"(cr2)); \
asm volatile("movl %%cr3, %%eax":"=a"(cr3)); \
asm volatile("movl %%cr4, %%eax":"=a"(cr4)); \
asm volatile("popl %%eax":"=a"(error_code)); \
kprintln("\n\e[31mRegister dump"); \
kprintln("eax=0x{8H}, ebx=0x{8H}, ecx=0x{8H}, edx=0x{8H}", eax, ebx, ecx, edx); \
kprintln("esp=0x{8H}, ebp=0x{8H}", esp, ebp); \
kprintln("CR0=0x{8H} CR2=0x{8H} CR3=0x{8H} CR4=0x{8H}", cr0, cr2, cr3, cr4); \
Kernel::Panic(msg " (error code: 0x{8H})", error_code); \
Kernel::Panic("Register dump\r\n" \
"eax=0x{8H}, ebx=0x{8H}, ecx=0x{8H}, edx=0x{8H}\r\n" \
"esp=0x{8H}, ebp=0x{8H}\r\n" \
"CR0=0x{8H} CR2=0x{8H} CR3=0x{8H} CR4=0x{8H}\r\n" \
msg " (error code: 0x{8H})", \
eax, ebx, ecx, edx, esp, ebp, cr0, cr2, cr3, cr4, error_code); \
}
INTERRUPT_HANDLER____(0x00, "Division Error")