41 lines
753 B
NASM
41 lines
753 B
NASM
|
[bits 32]
|
||
|
global idt_load
|
||
|
global common_isr_stub
|
||
|
|
||
|
extern isr_handler
|
||
|
extern _push_regs
|
||
|
extern _pop_regs
|
||
|
|
||
|
idt_load:
|
||
|
mov eax, [esp + 4]
|
||
|
lidt [eax]
|
||
|
ret
|
||
|
|
||
|
common_isr_stub:
|
||
|
call _push_regs ; Push all general-purpose registers
|
||
|
push ds
|
||
|
push es
|
||
|
push fs
|
||
|
push gs
|
||
|
|
||
|
mov ax, 0x10 ; Load kernel data segment
|
||
|
mov ds, ax
|
||
|
mov es, ax
|
||
|
mov fs, ax
|
||
|
mov gs, ax
|
||
|
|
||
|
push esp ; Pass pointer to the register state
|
||
|
call isr_handler ; Call your C ISR handler
|
||
|
|
||
|
add esp, 4 ; Clean up stack from push esp
|
||
|
pop gs
|
||
|
pop fs
|
||
|
pop es
|
||
|
pop ds
|
||
|
|
||
|
call _pop_regs ; restore all general-purpose registers
|
||
|
|
||
|
add esp, 8 ; Remove int_no and err_code
|
||
|
sti
|
||
|
iret
|