Files
jsix/src/kernel/interrupts.s
Justin C. Miller 8c32471e0d Pass CPU state as a pointer
Previously CPU statue was passed on the stack, but the compiler is
allowed to clobber values passed to it on the stack in the SysV x86 ABI.
So now leave the state on the stack but pass a pointer to it into the
ISR functions.
2019-02-07 17:47:42 -08:00

68 lines
1.0 KiB
ArmAsm

%include "push_all.inc"
extern isr_handler
global isr_handler_prelude
isr_handler_prelude:
push_all_and_segments
mov rdi, rsp
mov rsi, rsp
call isr_handler
mov rsp, rax
pop_all_and_segments
add rsp, 16 ; because the ISRs added err/num
sti
iretq
extern irq_handler
global irq_handler_prelude
irq_handler_prelude:
push_all_and_segments
mov rdi, rsp
mov rsi, rsp
call irq_handler
mov rsp, rax
pop_all_and_segments
add rsp, 16 ; because the ISRs added err/num
sti
iretq
%macro EMIT_ISR 2
global %1
%1:
cli
push 0
push %2
jmp isr_handler_prelude
%endmacro
%macro EMIT_EISR 2
global %1
%1:
cli
push %2
jmp isr_handler_prelude
%endmacro
%macro EMIT_IRQ 2
global %1
%1:
cli
push 0
push %2
jmp irq_handler_prelude
%endmacro
%define EISR(i, name) EMIT_EISR name, i ; ISR with error code
%define UISR(i, name) EMIT_ISR name, i ; ISR callable from user space
%define ISR(i, name) EMIT_ISR name, i
%define IRQ(i, q, name) EMIT_IRQ name, i
section .isrs
%include "interrupt_isrs.inc"