]> wirehaze git hosting - BOS.git/blob - kernel/krl_incs/pic.inc

wirehaze git hosting

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