2025-06-16 04:52:05 +00:00
|
|
|
; Interrupts.s - Implementations of IA32 interrupts.
|
|
|
|
|
|
|
|
|
|
;Let's make an interrupt pointer table so C can reference it and build the IDT.
|
|
|
|
|
|
2025-06-17 02:40:02 +00:00
|
|
|
global isr_ptrs
|
|
|
|
|
extern generic_isr_handler
|
2025-06-16 04:52:05 +00:00
|
|
|
|
2025-06-17 02:40:02 +00:00
|
|
|
;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
|
2025-06-16 04:52:05 +00:00
|
|
|
|
2025-06-17 02:40:02 +00:00
|
|
|
%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
|
2025-06-28 04:14:42 +00:00
|
|
|
%rep 255
|
2025-06-17 02:40:02 +00:00
|
|
|
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:
|
2025-06-16 04:52:05 +00:00
|
|
|
%assign i 0
|
2025-06-28 04:14:42 +00:00
|
|
|
%rep 255
|
2025-06-17 02:40:02 +00:00
|
|
|
dd isr_ %+ i
|
|
|
|
|
%assign i i+1
|
|
|
|
|
%endrep
|
|
|
|
|
isr_ptrs_end:
|
|
|
|
|
|
2025-06-16 04:52:05 +00:00
|
|
|
|