118 lines
1.8 KiB
ArmAsm
118 lines
1.8 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
|
|
extern cpu_reg_state
|
|
extern stack_state
|
|
extern idt_ptr
|
|
|
|
global load_idt
|
|
load_idt:
|
|
lidt [idt_ptr]
|
|
ret
|
|
|
|
%macro no_err_handler 1
|
|
global no_err_handler_%1 ; defined in interrupts.h
|
|
no_err_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 err_code_handler_%1
|
|
err_code_handler_%1:
|
|
push dword %1
|
|
jmp common_int_handler
|
|
%endmacro
|
|
|
|
common_int_handler:
|
|
; save thigns before do our C-call
|
|
pushad
|
|
;push eax
|
|
;push ecx
|
|
;push edx
|
|
;push ebx
|
|
|
|
;push esp
|
|
;push ebp
|
|
;push esi
|
|
;push edi
|
|
|
|
;push ds
|
|
;push es
|
|
;push fs
|
|
;push gs
|
|
|
|
call interrupt_handler
|
|
|
|
; segments
|
|
pop gs
|
|
pop fs
|
|
pop es
|
|
pop ds
|
|
|
|
pop edi
|
|
pop esi
|
|
pop ebp
|
|
pop esp
|
|
|
|
pop ebx
|
|
pop edx
|
|
pop ecx
|
|
pop eax
|
|
|
|
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
|
|
|
|
no_err_handler 18
|
|
no_err_handler 19
|
|
no_err_handler 20
|
|
no_err_handler 21
|
|
no_err_handler 22
|
|
no_err_handler 23
|
|
no_err_handler 24
|
|
no_err_handler 25
|
|
no_err_handler 26
|
|
no_err_handler 27
|
|
no_err_handler 28
|
|
no_err_handler 29
|
|
no_err_handler 30
|
|
no_err_handler 31
|
|
no_err_handler 32
|