swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 1 | [bits 32] |
| 2 | [global idt_flush] |
| 3 | |
| 4 | idt_flush: |
| 5 | mov eax, [esp + 4] |
| 6 | lidt [eax] |
| 7 | ret |
| 8 | |
| 9 | %macro ISRNOERR 1 |
| 10 | [global isr%1] |
| 11 | isr%1: |
| 12 | cli |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 13 | push 0 |
| 14 | push %1 |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 15 | jmp isr_common |
| 16 | %endmacro |
| 17 | |
| 18 | %macro ISRERR 1 |
| 19 | [global isr%1] |
| 20 | isr%1: |
| 21 | cli |
| 22 | push byte %1 |
| 23 | jmp isr_common |
| 24 | %endmacro |
| 25 | |
| 26 | ISRNOERR 0 |
| 27 | ISRNOERR 1 |
| 28 | ISRNOERR 2 |
| 29 | ISRNOERR 3 |
| 30 | ISRNOERR 4 |
| 31 | ISRNOERR 5 |
| 32 | ISRNOERR 6 |
| 33 | ISRNOERR 7 |
| 34 | ISRERR 8 |
| 35 | ISRNOERR 9 |
| 36 | ISRERR 10 |
| 37 | ISRERR 11 |
| 38 | ISRERR 12 |
| 39 | ISRERR 13 |
| 40 | ISRERR 14 |
| 41 | ISRNOERR 15 |
| 42 | ISRNOERR 16 |
| 43 | ISRNOERR 17 |
| 44 | ISRNOERR 18 |
| 45 | ISRNOERR 19 |
| 46 | ISRNOERR 20 |
| 47 | ISRNOERR 21 |
| 48 | ISRNOERR 22 |
| 49 | ISRNOERR 23 |
| 50 | ISRNOERR 24 |
| 51 | ISRNOERR 25 |
| 52 | ISRNOERR 26 |
| 53 | ISRNOERR 27 |
| 54 | ISRNOERR 28 |
| 55 | ISRNOERR 29 |
| 56 | ISRNOERR 30 |
| 57 | ISRNOERR 31 |
| 58 | |
| 59 | |
| 60 | [extern isr_handler] |
| 61 | isr_common: |
| 62 | pusha ; Save all registers |
| 63 | |
swissChili | defeb0d | 2021-02-18 15:28:36 -0800 | [diff] [blame] | 64 | mov ax, ds ; Save data segment |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 65 | push eax |
| 66 | |
swissChili | defeb0d | 2021-02-18 15:28:36 -0800 | [diff] [blame] | 67 | mov ax, 0x10 ; New segments |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 68 | mov ds, ax |
| 69 | mov es, ax |
| 70 | mov fs, ax |
| 71 | mov gs, ax |
| 72 | |
| 73 | call isr_handler |
| 74 | |
swissChili | defeb0d | 2021-02-18 15:28:36 -0800 | [diff] [blame] | 75 | pop eax ; Reset segments |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 76 | mov ds, ax |
| 77 | mov es, ax |
| 78 | mov fs, ax |
| 79 | mov gs, ax |
| 80 | |
| 81 | popa |
| 82 | add esp, 8 ; Passed arguments |
| 83 | sti |
| 84 | iret ; Return from interrupt |