This likely represents cleanups done by Bill Jolitz Sept 3 '91
[unix-history] / usr / src / sys / i386 / isa / icu.s
CommitLineData
c37f7e1f
WN
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
3d730fd8 8 * %sccs.include.386.c%
c37f7e1f 9 *
3d730fd8 10 * @(#)icu.s 7.4 (Berkeley) %G%
c37f7e1f
WN
11 */
12
13/*
14 * AT/386
15 * Vector interrupt control section
3d730fd8 16 * Copyright (C) 1989,90 W. Jolitz
c37f7e1f
WN
17 */
18
19 .data
20 .globl _imen
21 .globl _cpl
83e0d013 22_cpl: .long 0xffff # current priority level (all off)
c37f7e1f 23_imen: .long 0xffff # interrupt mask enable (all off)
4686adac
BJ
24 .globl _highmask
25_highmask: .long 0xffff
83e0d013 26 .globl _ttymask
dd22fcce 27_ttymask: .long 0
83e0d013 28 .globl _biomask
dd22fcce
BJ
29_biomask: .long 0
30 .globl _netmask
31_netmask: .long 0
d0d290ad
WN
32 .globl _isa_intr
33_isa_intr: .space 16*4
4686adac 34
c37f7e1f 35 .text
4686adac
BJ
36/*
37 * Handle return from interrupt after device handler finishes
38 */
39doreti:
40 cli
41 popl %ebx # remove intr number
3d730fd8 42 nop
4686adac 43 popl %eax # get previous priority
3d730fd8 44 nop
4686adac
BJ
45 # now interrupt frame is a trap frame!
46 movw %ax,%cx
47 movw %ax,_cpl
48 orw _imen,%ax
4686adac 49 outb %al,$ IO_ICU1+1 # re-enable intr?
4686adac 50 movb %ah,%al
4686adac 51 outb %al,$ IO_ICU2+1
4686adac 52
3d730fd8 53 # andw $0xffff,%cx
4686adac
BJ
54 cmpw $0,%cx # returning to zero?
55 je 1f
56
3d730fd8
KS
572: popl %es # nope, going to non-zero level
58 nop
59 popl %ds
60 nop
61 popal
62 nop
4686adac
BJ
63 addl $8,%esp
64 iret
65
661: cmpl $0,_netisr # check for softint s/traps
3d730fd8 67 je 2b
4686adac 68
4686adac
BJ
69#include "../net/netisr.h"
70
711:
72
73#define DONET(s, c) ; \
74 .globl c ; \
3d730fd8 75 btrl $ s ,_netisr ; \
4686adac
BJ
76 jnb 1f ; \
77 call c ; \
781:
79
80 call _splnet
81 pushl %eax
82
3d730fd8 83
4686adac
BJ
84 DONET(NETISR_RAW,_rawintr)
85#ifdef INET
86 DONET(NETISR_IP,_ipintr)
26f2721b 87 DONET(NETISR_ARP,_arpintr)
4686adac
BJ
88#endif
89#ifdef IMP
90 DONET(NETISR_IMP,_impintr)
91#endif
92#ifdef NS
93 DONET(NETISR_NS,_nsintr)
94#endif
26f2721b
KS
95#ifdef ISO
96 DONET(NETISR_ISO,_clnlintr)
97#endif
98#ifdef CCITT
99 DONET(NETISR_CCITT,_hdintr)
100#endif
4686adac 101
3d730fd8
KS
102 /* restore interrupt state, but don't turn them on just yet */
103 cli
4686adac 104 popl %eax
3d730fd8 105 nop
4686adac
BJ
106 movw %ax,_cpl
107 orw _imen,%ax
4686adac 108 outb %al,$ IO_ICU1+1 # re-enable intr?
4686adac 109 movb %ah,%al
4686adac 110 outb %al,$ IO_ICU2+1
4686adac 111
3d730fd8 112 btrl $ NETISR_SCLK,_netisr
4686adac
BJ
113 jnb 1f
114 # back to an interrupt frame for a moment
115 call _splsoftclock
116 pushl %eax
117 pushl $0xff # dummy intr
118 call _softclock
119 popl %eax
3d730fd8 120 nop
4686adac
BJ
121 call _splx
122 popl %eax
3d730fd8 123 nop
4686adac
BJ
124
125 jmp 2f
126
4686adac
BJ
1271:
128 cmpw $0x1f,13*4(%esp) # to user?
129 jne 2f # nope, leave
3d730fd8 130 btrl $ NETISR_AST ,_netisr
4686adac
BJ
131 jnb 2f
132 call _trap
133
1342: pop %es
3d730fd8 135 nop
4686adac 136 pop %ds
3d730fd8 137 nop
4686adac 138 popal
3d730fd8 139 nop
4686adac
BJ
140 addl $8,%esp
141 iret
142
143/*
144 * Interrupt priority mechanism
145 *
146 * Two flavors -- imlXX masks relative to ISA noemenclature (for PC compat sw)
147 * -- splXX masks with group mechanism for BSD purposes
148 */
c37f7e1f 149
c37f7e1f
WN
150 .globl _splhigh
151 .globl _splclock
c37f7e1f
WN
152_splhigh:
153_splclock:
154 cli # disable interrupts
155 movw $0xffff,%ax # set new priority level
156 movw %ax,%dx
83e0d013 157 # orw _imen,%ax # mask off those not enabled yet
c37f7e1f 158 movw %ax,%cx
4686adac 159 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f 160 movb %ah,%al
4686adac 161 outb %al,$ IO_ICU2+1
c37f7e1f
WN
162 movzwl _cpl,%eax # return old priority
163 movw %dx,_cpl # set new priority level
83e0d013 164 sti # enable interrupts
c37f7e1f
WN
165 ret
166
c37f7e1f 167 .globl _spltty # block clists
c37f7e1f
WN
168_spltty:
169 cli # disable interrupts
83e0d013
DA
170 movw _cpl,%ax
171 orw _ttymask,%ax
c37f7e1f
WN
172 movw %ax,%dx
173 orw _imen,%ax # mask off those not enabled yet
174 movw %ax,%cx
4686adac 175 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f 176 movb %ah,%al
4686adac 177 outb %al,$ IO_ICU2+1
c37f7e1f
WN
178 movzwl _cpl,%eax # return old priority
179 movw %dx,_cpl # set new priority level
83e0d013 180 sti # enable interrupts
c37f7e1f
WN
181 ret
182
4686adac
BJ
183 .globl _splimp
184 .globl _splnet
185_splimp:
186_splnet:
c37f7e1f 187 cli # disable interrupts
4686adac
BJ
188 movw _cpl,%ax
189 orw _netmask,%ax
c37f7e1f
WN
190 movw %ax,%dx
191 orw _imen,%ax # mask off those not enabled yet
192 movw %ax,%cx
4686adac 193 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f 194 movb %ah,%al
4686adac 195 outb %al,$ IO_ICU2+1
c37f7e1f
WN
196 movzwl _cpl,%eax # return old priority
197 movw %dx,_cpl # set new priority level
83e0d013 198 sti # enable interrupts
c37f7e1f
WN
199 ret
200
4686adac
BJ
201 .globl _splbio
202_splbio:
c37f7e1f 203 cli # disable interrupts
dd22fcce 204 movw _cpl,%ax
4686adac 205 orw _biomask,%ax
c37f7e1f
WN
206 movw %ax,%dx
207 orw _imen,%ax # mask off those not enabled yet
208 movw %ax,%cx
4686adac 209 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f 210 movb %ah,%al
4686adac 211 outb %al,$ IO_ICU2+1
c37f7e1f
WN
212 movzwl _cpl,%eax # return old priority
213 movw %dx,_cpl # set new priority level
83e0d013 214 sti # enable interrupts
c37f7e1f
WN
215 ret
216
4686adac
BJ
217 .globl _splsoftclock
218_splsoftclock:
c37f7e1f 219 cli # disable interrupts
4686adac
BJ
220 movw _cpl,%ax
221 orw $0x8000,%ax # set new priority level
c37f7e1f
WN
222 movw %ax,%dx
223 orw _imen,%ax # mask off those not enabled yet
224 movw %ax,%cx
4686adac 225 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f 226 movb %ah,%al
4686adac 227 outb %al,$ IO_ICU2+1
c37f7e1f
WN
228 movzwl _cpl,%eax # return old priority
229 movw %dx,_cpl # set new priority level
230 sti # enable interrupts
231 ret
232
4686adac
BJ
233 .globl _splnone
234 .globl _spl0
235_splnone:
236_spl0:
c37f7e1f 237 cli # disable interrupts
4686adac
BJ
238 pushl _cpl # save old priority
239 movw _cpl,%ax
240 orw _netmask,%ax # mask off those network devices
241 movw %ax,_cpl # set new priority level
c37f7e1f 242 orw _imen,%ax # mask off those not enabled yet
4686adac 243 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f 244 movb %ah,%al
4686adac 245 outb %al,$ IO_ICU2+1
c37f7e1f 246 sti # enable interrupts
c37f7e1f 247
4686adac
BJ
248 DONET(NETISR_RAW,_rawintr)
249#ifdef INET
250 DONET(NETISR_IP,_ipintr)
3d730fd8
KS
251 DONET(NETISR_ARP,_arpintr)
252#endif
253#ifdef IMP
254 DONET(NETISR_IMP,_impintr)
255#endif
256#ifdef NS
257 DONET(NETISR_NS,_nsintr)
258#endif
259#ifdef ISO
260 DONET(NETISR_ISO,_clnlintr)
261#endif
262#ifdef CCITT
263 DONET(NETISR_CCITT,_hdintr)
4686adac 264#endif
3d730fd8 265
c37f7e1f 266 cli # disable interrupts
4686adac 267 popl _cpl # save old priority
3d730fd8
KS
268 nop
269
4686adac 270 movw $0,%ax # set new priority level
c37f7e1f
WN
271 movw %ax,%dx
272 orw _imen,%ax # mask off those not enabled yet
273 movw %ax,%cx
4686adac 274 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f 275 movb %ah,%al
4686adac 276 outb %al,$ IO_ICU2+1
c37f7e1f
WN
277 movzwl _cpl,%eax # return old priority
278 movw %dx,_cpl # set new priority level
279 sti # enable interrupts
280 ret
281
4686adac
BJ
282 .globl _splx
283_splx:
c37f7e1f 284 cli # disable interrupts
4686adac 285 movw 4(%esp),%ax # new priority level
c37f7e1f 286 movw %ax,%dx
4686adac
BJ
287 cmpw $0,%dx
288 je _spl0 # going to "zero level" is special
289
c37f7e1f
WN
290 orw _imen,%ax # mask off those not enabled yet
291 movw %ax,%cx
4686adac 292 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f 293 movb %ah,%al
4686adac 294 outb %al,$ IO_ICU2+1
c37f7e1f
WN
295 movzwl _cpl,%eax # return old priority
296 movw %dx,_cpl # set new priority level
297 sti # enable interrupts
298 ret
299
4686adac
BJ
300 /* hardware interrupt catcher (IDT 32 - 47) */
301 .globl _isa_strayintr
302
303IDTVEC(intr0)
d0d290ad 304 INTR(0, _highmask, 0) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
305
306IDTVEC(intr1)
d0d290ad 307 INTR(1, _highmask, 1) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
308
309IDTVEC(intr2)
d0d290ad 310 INTR(2, _highmask, 2) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
311
312IDTVEC(intr3)
d0d290ad 313 INTR(3, _highmask, 3) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
314
315IDTVEC(intr4)
d0d290ad 316 INTR(4, _highmask, 4) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
317
318IDTVEC(intr5)
d0d290ad 319 INTR(5, _highmask, 5) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
320
321IDTVEC(intr6)
d0d290ad 322 INTR(6, _highmask, 6) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
323
324IDTVEC(intr7)
d0d290ad 325 INTR(7, _highmask, 7) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
326
327
328IDTVEC(intr8)
d0d290ad 329 INTR(8, _highmask, 8) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
330
331IDTVEC(intr9)
d0d290ad 332 INTR(9, _highmask, 9) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
333
334IDTVEC(intr10)
d0d290ad 335 INTR(10, _highmask, 10) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
336
337IDTVEC(intr11)
d0d290ad 338 INTR(11, _highmask, 11) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
339
340IDTVEC(intr12)
d0d290ad 341 INTR(12, _highmask, 12) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
342
343IDTVEC(intr13)
d0d290ad 344 INTR(13, _highmask, 13) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
345
346IDTVEC(intr14)
d0d290ad 347 INTR(14, _highmask, 14) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
348
349IDTVEC(intr15)
d0d290ad 350 INTR(15, _highmask, 15) ; call _isa_strayintr ; INTREXIT2
4686adac 351