Add an interrupt descriptor table.
Set up a very basic handler for divide by zero and general protection faults.
This commit is contained in:
parent
3e1a1f7485
commit
9fc1aa15ef
8 changed files with 132 additions and 2 deletions
56
zion/interrupt/interrupt_enter.s
Normal file
56
zion/interrupt/interrupt_enter.s
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
.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
|
||||
.endm
|
||||
|
||||
.macro interrupt_exit
|
||||
pop %rax
|
||||
pop %rbx
|
||||
pop %rcx
|
||||
pop %rdx
|
||||
pop %rsi
|
||||
pop %rdi
|
||||
pop %r8
|
||||
pop %r9
|
||||
pop %r10
|
||||
pop %r10
|
||||
pop %r10
|
||||
pop %r10
|
||||
pop %r10
|
||||
pop %r10
|
||||
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
|
||||
isr_handler protection_fault,1
|
||||
Loading…
Add table
Add a link
Reference in a new issue