86 lines
1.5 KiB
NASM
86 lines
1.5 KiB
NASM
[bits 32]
|
|
global isr_stub_table
|
|
global isr0, isr1, isr2, isr3, isr4, isr5, isr6, isr7
|
|
global isr8, isr9, isr10, isr11, isr12, isr13, isr14, isr15
|
|
global isr16, isr17, isr18, isr19, isr20, isr21, isr22, isr23
|
|
global isr24, isr25, isr26, isr27, isr28, isr29, isr30, isr31
|
|
|
|
extern isr_handler
|
|
extern _push_regs
|
|
extern _pop_regs
|
|
|
|
%macro ISR_NOERR 1
|
|
isr%1:
|
|
cli
|
|
push dword 0 ; Fake error code
|
|
push dword %1 ; Interrupt number
|
|
jmp isr_common_stub
|
|
%endmacro
|
|
|
|
%macro ISR_ERR 1
|
|
isr%1:
|
|
cli
|
|
push dword %1 ; Interrupt number
|
|
jmp isr_common_stub
|
|
%endmacro
|
|
|
|
; ISRs 0-31 (exceptions)
|
|
ISR_NOERR 0
|
|
ISR_NOERR 1
|
|
ISR_NOERR 2
|
|
ISR_NOERR 3
|
|
ISR_NOERR 4
|
|
ISR_NOERR 5
|
|
ISR_NOERR 6
|
|
ISR_NOERR 7
|
|
ISR_ERR 8 ; Double fault
|
|
ISR_NOERR 9
|
|
ISR_ERR 10 ; Invalid TSS
|
|
ISR_ERR 11 ; Segment not present
|
|
ISR_ERR 12 ; Stack segment fault
|
|
ISR_ERR 13 ; General protection fault
|
|
ISR_ERR 14 ; Page fault
|
|
ISR_NOERR 15
|
|
ISR_NOERR 16
|
|
ISR_NOERR 17
|
|
ISR_NOERR 18
|
|
ISR_NOERR 19
|
|
ISR_NOERR 20
|
|
ISR_NOERR 21
|
|
ISR_NOERR 22
|
|
ISR_NOERR 23
|
|
ISR_NOERR 24
|
|
ISR_NOERR 25
|
|
ISR_NOERR 26
|
|
ISR_NOERR 27
|
|
ISR_NOERR 28
|
|
ISR_NOERR 29
|
|
ISR_ERR 30 ; Security exception
|
|
ISR_NOERR 31
|
|
|
|
isr_common_stub:
|
|
call _push_regs
|
|
push ds
|
|
push es
|
|
push fs
|
|
push gs
|
|
|
|
mov ax, 0x10
|
|
mov ds, ax
|
|
mov es, ax
|
|
mov fs, ax
|
|
mov gs, ax
|
|
|
|
push esp
|
|
call isr_handler
|
|
add esp, 4
|
|
|
|
pop gs
|
|
pop fs
|
|
pop es
|
|
pop ds
|
|
call _pop_regs
|
|
add esp, 8
|
|
sti
|
|
iret
|