2 * Acess2 x86_64 Project
9 void MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs);
12 void Error_Handler(tRegs *Regs);
15 const char * const csaERROR_NAMES[] = {
16 "Divide By Zero", "Debug", "NMI Exception", "INT3",
17 "INTO", "Out of Bounds", "Invalid Opcode", "Coprocessor not avaliable",
18 "Double Fault", "Coprocessor Segment Overrun", "Bad TSS", "Segment Not Present",
19 "Stack Fault Exception", "GPF", "#PF", "Reserved",
20 "Floating Point Exception", "Alignment Check Exception", "Machine Check Exception", "Reserved",
21 "Reserved", "Reserved", "Reserved", "Reserved",
22 "Reserved", "Reserved", "Reserved", "Reserved",
23 "Reserved", "Reserved", "Reserved", "Reserved"
27 void Error_Handler(tRegs *Regs)
31 if( Regs->IntNum == 14 ) {
32 __asm__ __volatile__ ("mov %%cr2, %0":"=r"(cr));
33 MM_PageFault(cr, Regs->ErrorCode, Regs);
39 Log("CPU Error %x, Code: 0x%x", Regs->IntNum, Regs->ErrorCode);
40 Log(" - %s", csaERROR_NAMES[Regs->IntNum]);
41 Log(" CS:RIP = 0x%04x:%016x", Regs->CS, Regs->RIP);
42 Log(" SS:RSP = 0x%04x:%016x", Regs->SS, Regs->RSP);
43 Log(" RFLAGS = 0x%016x", Regs->RFlags);
45 Log(" RAX %016x RCX %016x RDX %016x RBX %016x",
46 Regs->RAX, Regs->RCX, Regs->RDX, Regs->RBX);
47 Log(" RSP %016x RBP %016x RSI %016x RDI %016x",
48 Regs->RSP, Regs->RBP, Regs->RSP, Regs->RDI);
49 Log(" R8 %016x R9 %016x R10 %016x R11 %016x",
50 Regs->R8, Regs->R9, Regs->R10, Regs->R11);
51 Log(" R12 %016x R13 %016x R14 %016x R15 %016x",
52 Regs->R12, Regs->R13, Regs->R14, Regs->R15);
53 Log(" FS %04x GS %04x", Regs->FS, Regs->GS);
57 __asm__ __volatile__ ("mov %%cr0, %0":"=r"(cr));
58 Warning(" CR0 0x%08x", cr);
59 __asm__ __volatile__ ("mov %%cr2, %0":"=r"(cr));
60 Warning(" CR2 0x%08x", cr);
61 __asm__ __volatile__ ("mov %%cr3, %0":"=r"(cr));
62 Warning(" CR3 0x%08x", cr);
63 __asm__ __volatile__ ("mov %%cr4, %0":"=r"(cr));
64 Warning(" CR4 0x%08x", cr);
66 switch( Regs->IntNum )
69 Warning(" Offending bytes: %02x %02x %02x %02x",
70 *(Uint8*)Regs->RIP+0, *(Uint8*)Regs->RIP+1,
71 *(Uint8*)Regs->RIP+2, *(Uint8*)Regs->RIP+3);
75 __asm__ __volatile__ ("cli");
77 __asm__ __volatile__ ("hlt");