]> wirehaze git hosting - BOS.git/blob - kernel/init/pic.asm

wirehaze git hosting

fat12 structures, constants and general framework done
[BOS.git] / kernel / init / pic.asm
1 ;----------------------------------------------------------;
2 ; BOS 0.04 Christoffer Bubach, 2004. ;
3 ;----------------------------------------------------------;
4 ; ;
5 ; PIC/IRQ handling. ;
6 ; ;
7 ;----------------------------------------------------------;
8
9
10 ;-------------------------------------------;
11 ; remap PICs ;
12 ; in: cl = pic1 ;
13 ; ch = pic2 ;
14 ;-------------------------------------------;
15 remap_pics:
16 push ax
17 push dx
18
19 mov al, 0x11 ; IWC1
20 out 0x20, al
21 out 0xA0, al
22
23 mov al, cl ; IWC2
24 out 0x21, al
25 mov al, ch
26 out 0xA1, al
27
28 mov al, 0x04 ; IWC3
29 out 0x21, al
30 mov al, 0x02
31 out 0xA1, al
32
33 mov al, 0x01 ; IWC4
34 out 0x21, al
35 out 0xA1, al
36
37 pop dx
38 pop ax
39 ret
40
41
42 ;----------------------;
43 ; disable all IRQs. ;
44 ;----------------------;
45 disable_irqs:
46 push ax
47
48 mov al, 0xFF
49 out 0x21, al
50 out 0xA1, al
51
52 pop ax
53 ret
54
55
56 ;---------------------;
57 ; enable all IRQs. ;
58 ;---------------------;
59 enable_irqs:
60 push ax
61
62 mov al, 0x00
63 out 0x21, al
64 out 0xA1, al
65
66 pop ax
67 ret
68
69
70 ;-----------------------------;
71 ; enable an IRQ. cl = irq ;
72 ;-----------------------------;
73 enable_irq:
74 push ax
75 push cx
76
77 cmp cl, 8
78 jb .master
79
80 sub cl, 8
81 mov ah, 1
82 shl ah, cl
83 xor ah, 0xFF
84
85 in al, 0xA1
86 and al, ah
87 out 0xA1, al
88
89 pop cx
90 pop ax
91 ret
92 .master:
93 mov ah, 1
94 shl ah, cl
95 xor ah, 0xFF
96
97 in al, 0x21
98 and al, ah
99 out 0x21, al
100
101 pop cx
102 pop ax
103 ret
104
105
106 ;------------------------------;
107 ; disable an IRQ. ;
108 ; in: cl = irq ;
109 ;------------------------------;
110 disable_irq:
111 push ax
112 push cx
113
114 cmp cl, 8
115 jb .master
116
117 sub cl, 8
118 mov ah, 1
119 shl ah, cl
120
121 in al, 0xA1
122 or al, ah
123 out 0xA1, al
124
125 pop cx
126 pop ax
127 ret
128 .master:
129 mov ah, 1
130 shl ah, cl
131
132 in al, 0x21
133 or al, ah
134 out 0x21, al
135
136 pop cx
137 pop ax
138 ret