The syscall/sysret instructions don't swap stacks. This was bad but passable until syscalls caused the scheduler to run, and scheduling a task that paused due to interrupt. Adding a new (hopefully temporary) syscall interrupt `int 0xee` to allow me to test syscalls without stack issues before I tackle the syscall/sysret issue. Also implemented a basic `pause` syscall that causes the calling process to become unready. Because nothing can wake a process yet, it never returns.
66 lines
965 B
ArmAsm
66 lines
965 B
ArmAsm
%include "push_all.inc"
|
|
|
|
extern isr_handler
|
|
global isr_handler_prelude
|
|
isr_handler_prelude:
|
|
push_all_and_segments
|
|
|
|
mov rdi, 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
|
|
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
|
|
%define UISR(i, name) EMIT_ISR name, i
|
|
%define ISR(i, name) EMIT_ISR name, i
|
|
%define IRQ(i, q, name) EMIT_IRQ name, i
|
|
|
|
section .isrs
|
|
%include "interrupt_isrs.inc"
|