Kernel: Rewrite IDT exception kernel panic message
This commit is contained in:
parent
fc05642b74
commit
f51ca4b642
|
@ -37,46 +37,46 @@ static GateDescriptor s_idt[0x100];
|
|||
|
||||
static void (*s_irq_handlers[0xFF])() { nullptr };
|
||||
|
||||
#define INTERRUPT_HANDLER____(i, msg) \
|
||||
static void interrupt ## i () \
|
||||
{ \
|
||||
uint32_t eax, ebx, ecx, edx; \
|
||||
uint32_t esp, ebp; \
|
||||
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 %%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 (hex)"); \
|
||||
kprintln("eax={8H}, ebx={8H}, ecx={8H}, edx={8H}", eax, ebx, ecx, edx); \
|
||||
kprintln("esp={8H}, ebp={8H}", esp, ebp); \
|
||||
kprintln("CR0={8H} CR2={8H} CR3={8H} CR4={8H}", cr0, cr2, cr3, cr4); \
|
||||
Kernel::panic(msg); \
|
||||
#define INTERRUPT_HANDLER____(i, msg) \
|
||||
static void interrupt ## i () \
|
||||
{ \
|
||||
uint32_t eax, ebx, ecx, edx; \
|
||||
uint32_t esp, ebp; \
|
||||
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 %%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); \
|
||||
}
|
||||
|
||||
#define INTERRUPT_HANDLER_ERR(i, msg) \
|
||||
static void interrupt ## i () \
|
||||
{ \
|
||||
uint32_t eax, ebx, ecx, edx; \
|
||||
uint32_t esp, ebp; \
|
||||
uint32_t cr0, cr2, cr3, cr4; \
|
||||
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 %%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 (hex)"); \
|
||||
kprintln("eax={8H}, ebx={8H}, ecx={8H}, edx={8H}", eax, ebx, ecx, edx); \
|
||||
kprintln("esp={8H}, ebp={8H}", esp, ebp); \
|
||||
kprintln("CR0={8H} CR2={8H} CR3={8H} CR4={8H}", cr0, cr2, cr3, cr4); \
|
||||
Kernel::panic(msg " (error: {})", error_code); \
|
||||
#define INTERRUPT_HANDLER_ERR(i, msg) \
|
||||
static void interrupt ## i () \
|
||||
{ \
|
||||
uint32_t eax, ebx, ecx, edx; \
|
||||
uint32_t esp, ebp; \
|
||||
uint32_t cr0, cr2, cr3, cr4; \
|
||||
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 %%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); \
|
||||
}
|
||||
|
||||
INTERRUPT_HANDLER____(0x00, "Division Error")
|
||||
|
|
Loading…
Reference in New Issue