handlers.S (1284B)
1handle_exception: 2 push %r15 3 push %r14 4 push %r13 5 push %r12 6 push %r11 7 push %r10 8 push %r9 9 push %r8 10 11 push %rdi 12 push %rsi 13 push %rbp 14 push %rbx 15 push %rdx 16 push %rcx 17 push %rax 18 mov %rsp, %rdi 19 20 call route_exception 21 22 pop %rax 23 pop %rcx 24 pop %rdx 25 pop %rbx 26 pop %rbp 27 pop %rsi 28 pop %rdi 29 pop %r8 30 pop %r9 31 pop %r10 32 pop %r11 33 pop %r12 34 pop %r13 35 pop %r14 36 pop %r15 37 38 /* Discard vector and error code. */ 39 add $16, %rsp 40 iretq 41 42/* 43 * Build the handle_exception wrappers which push the vector/error code on the 44 * stack and an array of pointers to those wrappers. 45 */ 46.pushsection .rodata 47.globl idt_handlers 48idt_handlers: 49.popsection 50 51.macro HANDLERS has_error from to 52 vector = \from 53 .rept \to - \from + 1 54 .align 8 55 56 /* Fetch current address and append it to idt_handlers. */ 57666 : 58.pushsection .rodata 59 .quad 666b 60.popsection 61 62 .if ! \has_error 63 pushq $0 64 .endif 65 pushq $vector 66 jmp handle_exception 67 vector = vector + 1 68 .endr 69.endm 70 71.global idt_handler_code 72idt_handler_code: 73 HANDLERS has_error=0 from=0 to=7 74 HANDLERS has_error=1 from=8 to=8 75 HANDLERS has_error=0 from=9 to=9 76 HANDLERS has_error=1 from=10 to=14 77 HANDLERS has_error=0 from=15 to=16 78 HANDLERS has_error=1 from=17 to=17 79 HANDLERS has_error=0 from=18 to=255 80 81.section .note.GNU-stack, "", %progbits