2023-05-17 22:54:37 -07:00
|
|
|
.macro interrupt_enter
|
|
|
|
push %rbp
|
|
|
|
push %r15
|
|
|
|
push %r14
|
|
|
|
push %r13
|
|
|
|
push %r12
|
|
|
|
push %r11
|
|
|
|
push %r10
|
|
|
|
push %r9
|
|
|
|
push %r8
|
|
|
|
push %rdi
|
|
|
|
push %rsi
|
|
|
|
push %rdx
|
|
|
|
push %rcx # (Return Address)
|
|
|
|
push %rbx
|
|
|
|
push %rax
|
2023-06-07 22:24:50 -07:00
|
|
|
mov %cr2, %rax
|
|
|
|
push %rax
|
2023-05-17 22:54:37 -07:00
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro interrupt_exit
|
2023-06-07 22:24:50 -07:00
|
|
|
add $8, %rsp
|
2023-05-17 22:54:37 -07:00
|
|
|
pop %rax
|
|
|
|
pop %rbx
|
|
|
|
pop %rcx
|
|
|
|
pop %rdx
|
|
|
|
pop %rsi
|
|
|
|
pop %rdi
|
|
|
|
pop %r8
|
|
|
|
pop %r9
|
|
|
|
pop %r10
|
2023-06-07 22:24:50 -07:00
|
|
|
pop %r11
|
|
|
|
pop %r12
|
|
|
|
pop %r13
|
|
|
|
pop %r14
|
|
|
|
pop %r15
|
2023-05-17 22:54:37 -07:00
|
|
|
pop %rbp
|
|
|
|
|
|
|
|
add $8, %rsp # Remove error code.
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro isr_handler name error_code=0
|
|
|
|
.global isr_\name
|
|
|
|
isr_\name:
|
|
|
|
.if \error_code
|
|
|
|
.else
|
|
|
|
push $0 # if we don't have an error code, equalize the stack.
|
|
|
|
.endif
|
|
|
|
interrupt_enter
|
|
|
|
sti
|
|
|
|
mov %rsp, %rdi
|
|
|
|
call interrupt_\name
|
|
|
|
cli
|
|
|
|
interrupt_exit
|
|
|
|
iretq
|
|
|
|
.endm
|
|
|
|
|
|
|
|
isr_handler divide_by_zero
|
2023-11-22 12:06:37 -08:00
|
|
|
isr_handler invalid_opcode
|
2023-05-17 22:54:37 -07:00
|
|
|
isr_handler protection_fault,1
|
2023-05-18 10:43:45 -07:00
|
|
|
isr_handler page_fault,1
|
2023-11-21 15:17:32 -08:00
|
|
|
isr_handler fpe_fault
|
2023-05-29 21:52:01 -07:00
|
|
|
|
|
|
|
isr_handler timer
|
2023-08-01 20:18:47 -07:00
|
|
|
isr_handler apic_timer
|
2023-11-25 11:13:25 -08:00
|
|
|
isr_handler keyboard
|
2023-06-12 19:01:09 -07:00
|
|
|
|
|
|
|
isr_handler pci1
|
|
|
|
isr_handler pci2
|
|
|
|
isr_handler pci3
|
|
|
|
isr_handler pci4
|
|
|
|
|