keyboard interrupt (untested)
[ld45_start_nothing] / src / intr.inc
1 ; vi:filetype=nasm ts=8 sts=8 sw=8:
2
3 PIC1_CMD        equ 020h
4 PIC2_CMD        equ 0a0h
5 OCW2_EOI        equ 020h
6 OCW3_ISR        equ 00bh
7 IRQ_OFFSET      equ 32
8 %define IRQ_TO_INTR(x)  ((x) + IRQ_OFFSET)
9 %define INTR_TO_IRQ(x)  ((x) - IRQ_OFFSET)
10
11
12 %macro set_irq_vector 2
13         push dword IRQ_TO_INTR(%1)
14         push dword %2
15         call set_intr
16 %endmacro
17
18 %macro mask_irq 1
19 %if %1 < 8
20 %assign port PIC1_DATA
21 %assign mask (1 << %1)
22 %else
23 %assign port PIC2_DATA
24 %assign mask (1 << (%1 - 8))
25 %endif
26         in al, port
27         or al, mask
28         out port, al
29 %endmacro
30
31 %macro unmask_irq 1
32 %if %1 < 8
33 %assign port PIC1_DATA
34 %assign mask ~(1 << %1)
35 %else
36 %assign port PIC2_DATA
37 %assign mask ~(1 << (%1 - 8))
38 %endif
39         in al, port
40         and al, mask
41         out port, al
42 %endmacro
43
44 %macro end_of_irq 1
45         mov al, OCW2_EOI
46 %if %1 >= 8
47         out PIC2_CMD, al
48 %endif
49         out PIC1_CMD, al
50 %endmacro
51
52         extern idt
53
54 %ifndef INTR_ASM_
55         extern set_intr
56 %endif