jankos/interrupt_entry.s

97 lines
1.5 KiB
ArmAsm

; Dispatching to our interrupt handler code from assembly because some of this is
; enourmous pain in C
; Save the register state
; call the C handler
; executes iret(expects the stack to look like struct stack_state)
; If the interrupt we need to handle doesn't produce an error code then must provide a 0
; for consistency
extern interrupt_handler
%macro no_err_handler 1
global interrupt_handler_%1 ; defined in interrupts.h
interrupt_handler_%1:
push dword 0
push dword %1
jmp common_int_handler
%endmacro
; deals with the intterrupts that do give us an error code
%macro err_code_handler 1
global interrupt_handler_%1
interrupt_handler_%1:
push dword %1
jmp common_int_handler
%endmacro
common_int_handler:
; save thigns before do our C-call
push eax
push ebx
push ecx
push edx
push cs
push ds
push es
push fs
push gs
push ss
push esi
push edi
push ebp
push esp
call interrupt_handler
; restore state to the function
pop eax
pop ebx
pop ecx
pop edx
pop cs
pop ds
pop es
pop fs
pop gs
pop ss
pop esi
pop edi
pop ebp
pop esp
add esp, 8
; special instruction which lets us jump back to code
; which was previously interrupted
iret
no_err_handler 1
no_err_handler 2
no_err_handler 3
no_err_handler 4
no_err_handler 5
no_err_handler 6
no_err_handler 7
err_code_handler 8
no_err_handler 9
err_code_handler 10
err_code_handler 11
err_code_handler 12
err_code_handler 13
err_code_handler 14
no_err_handler 15
no_err_handler 16
err_code_handler 17