1 2 #ifndef __TRAP_H__ 3 #define __TRAP_H__ 4 5 #define T_DE 0 /* Divide Error Exception */ 6 #define T_DB 1 /* Debug Exception */ 7 #define T_NMI 2 /* NMI Interrupt */ 8 #define T_BP 3 /* Breakpoint Exception */ 9 #define T_OF 4 /* Overflow Exception */ 10 #define T_BR 5 /* BOUND Range Exceeded Exception */ 11 #define T_UD 6 /* Invalid Opcode Exception */ 12 #define T_NM 7 /* Device Not Available Exception */ 13 #define T_DF 8 /* Double Fault Exception */ 14 #define T_TS 10 /* Invalid TSS Exception */ 15 #define T_NP 11 /* Segment Not Present */ 16 #define T_SS 12 /* Stack Fault Exception */ 17 #define T_GP 13 /* General Protection Exception */ 18 #define T_PF 14 /* Page-Fault Exception */ 19 #define T_MF 16 /* x87 FPU Floating-Point Error */ 20 #define T_AC 17 /* Alignment Check Exception */ 21 #define T_MC 18 /* Machine-Check Exception */ 22 #define T_XF 19 /* SIMB Floating-Point Exception */ 23 #define T_VE 20 /* Virtualization Exception */ 24 25 #define T_CPU_LAST T_VE 26 27 // IRQs 28 #define T_IRQ_BASE 32 29 #define T_IRQ_LEN 24 30 #define T_IRQ_MAX (T_IRQ_BASE + T_IRQ_LEN - 1) 31 32 #define T_IRQ_TIMER (T_IRQ_BASE + 0) 33 #define T_IRQ_KBD (T_IRQ_BASE + 1) 34 #define T_IRQ_COM1 (T_IRQ_BASE + 4) 35 #define T_IRQ_MOUSE (T_IRQ_BASE + 12) 36 37 // LAPIC Special Vectors 38 #define T_IRQ_SPURIOUS (T_IRQ_BASE + 24) 39 #define T_IRQ_ERROR (T_IRQ_BASE + 25) 40 #define T_IRQ_THERMAL (T_IRQ_BASE + 26) 41 42 #define T_SYSCALL 60 /* System Call */ 43 #define T_CROSSCALL 61 /* Cross Call (IPI) */ 44 #define T_DEBUGIPI 62 /* Kernel Debugger Halt (IPI) */ 45 46 #define T_UNKNOWN 63 /* Unknown Trap */ 47 48 #define T_MAX 64 49 50 typedef struct TrapFrame 51 { 52 uint64_t r15; 53 uint64_t r14; 54 uint64_t r13; 55 uint64_t r12; 56 uint64_t r11; 57 uint64_t r10; 58 uint64_t r9; 59 uint64_t r8; 60 uint64_t rbp; 61 uint64_t rdi; 62 uint64_t rsi; 63 uint64_t rdx; 64 uint64_t rcx; 65 uint64_t rbx; 66 uint64_t ds; 67 uint64_t rax; 68 69 uint64_t vector; 70 uint32_t errcode; 71 uint32_t _unused0; 72 uint64_t rip; 73 uint16_t cs; 74 uint16_t _unused1; 75 uint16_t _unused2; 76 uint16_t _unused3; 77 uint64_t rflags; 78 uint64_t rsp; 79 uint16_t ss; 80 uint16_t _unused4; 81 uint16_t _unused5; 82 uint16_t _unused6; 83 } TrapFrame; 84 85 void Trap_Init(); 86 void Trap_InitAP(); 87 void Trap_Dump(TrapFrame *tf); 88 void Trap_Pop(TrapFrame *tf); 89 90 #endif /* __TRAP_H__ */ 91 92