Untitled_Kernel/src/interrupts.s

52 lines
1.3 KiB
ArmAsm
Raw Normal View History

; Interrupts.s - Implementations of IA32 interrupts.
;Let's make an interrupt pointer table so C can reference it and build the IDT.
global isr_ptrs
extern generic_isr_handler
;By the time we get here, we actually have a rather consistent stack:
; dword [Interrupt ID]
; dword [Error code (0 if int has no error code field)]
; dword [EIP]
; dword [CS]
; dword [EFLAGS]
; We can pass this to C. First, we might want to push all of our registers or something.
isr_common:
pusha
push esp ;Throwing a pointer to ESP in there for referencing the aforementioned stuff as a struct
call generic_isr_handler
add esp,4 ;Remove that esp ref from the stack
popad ;restore our gp registers
add esp,4 ;deallocate the error code from the stack before heading out
iret
%macro ISR_ENTRY 1
isr_%1:
cli
%if %1 = 8 || %1 = 10 || %1 = 11 || %1 = 12 || %1 = 13 || %1 = 14 || %1 = 17 || %1 = 21
%else
push dword 0
%endif
push dword %1 ; saving our interrupt so C knows
jmp isr_common
%endmacro
%assign j 0
%rep 32
isr_ %+ j:
ISR_ENTRY j
%assign j j+1
%endrep
; Generate a table of pointers that point to each of our ISRs. This will be accessed from C to setup our IDT.
isr_ptrs:
%assign i 0
%rep 32
dd isr_ %+ i
%assign i i+1
%endrep
isr_ptrs_end: