cleaning pass, removed dead code, updated comments, found boners
[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 *
d0d290ad 8 * %sccs.include.redist.c%
c37f7e1f 9 *
d0d290ad 10 * @(#)icu.s 7.1 (Berkeley) %G%
c37f7e1f
WN
11 */
12
13/*
14 * AT/386
15 * Vector interrupt control section
dd22fcce 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
42 popl %eax # get previous priority
43 # now interrupt frame is a trap frame!
44 movw %ax,%cx
45 movw %ax,_cpl
46 orw _imen,%ax
47 NOP
48 outb %al,$ IO_ICU1+1 # re-enable intr?
49 NOP
50 movb %ah,%al
51 NOP
52 outb %al,$ IO_ICU2+1
53 NOP
d0d290ad 54 inb $0x84,%al
4686adac
BJ
55
56 andw $0xffff,%cx
57 cmpw $0,%cx # returning to zero?
58 je 1f
59
60 pop %es # nope, going to non-zero level
61 pop %ds
62 popa
63 addl $8,%esp
64 iret
65
661: cmpl $0,_netisr # check for softint s/traps
67 jne 1f
68
69 pop %es # none, going back to base pri
70 pop %ds
71 popa
72 addl $8,%esp
73 iret
74
75#include "../net/netisr.h"
76
771:
78
79#define DONET(s, c) ; \
80 .globl c ; \
81 movl $ s ,%eax ; \
82 btrl %eax,_netisr ; \
83 jnb 1f ; \
84 call c ; \
851:
86
87 call _splnet
88 pushl %eax
89
90 DONET(NETISR_RAW,_rawintr)
91#ifdef INET
92 DONET(NETISR_IP,_ipintr)
93#endif
94#ifdef IMP
95 DONET(NETISR_IMP,_impintr)
96#endif
97#ifdef NS
98 DONET(NETISR_NS,_nsintr)
99#endif
100
101 popl %eax
102 movw %ax,_cpl
103 orw _imen,%ax
104 NOP
105 outb %al,$ IO_ICU1+1 # re-enable intr?
106 NOP
107 movb %ah,%al
108 NOP
109 outb %al,$ IO_ICU2+1
110 NOP
d0d290ad 111 inb $0x84,%al
4686adac
BJ
112
113 # btrl $ NETISR_SCLK,_netisr
114 movl $ NETISR_SCLK,%eax # stupid assembler, as usual
115 btrl %eax,_netisr
116 jnb 1f
117 # back to an interrupt frame for a moment
118 call _splsoftclock
119 pushl %eax
120 pushl $0xff # dummy intr
121 call _softclock
122 popl %eax
123 call _splx
124 popl %eax
125
126 jmp 2f
127
128 /* 1: btrl $NETISR_AST,_netisr*/
1291:
130 cmpw $0x1f,13*4(%esp) # to user?
131 jne 2f # nope, leave
132 movl $ NETISR_AST,%eax # stupid assembler, as usual
133 btrl %eax,_netisr
134 jnb 2f
135 call _trap
136
1372: pop %es
138 pop %ds
139 popal
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
WN
158 movw %ax,%cx
159 NOP
4686adac 160 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
161 NOP
162 movb %ah,%al
163 NOP
4686adac 164 outb %al,$ IO_ICU2+1
c37f7e1f 165 NOP
d0d290ad 166 inb $0x84,%al
c37f7e1f
WN
167 movzwl _cpl,%eax # return old priority
168 movw %dx,_cpl # set new priority level
83e0d013 169 sti # enable interrupts
c37f7e1f
WN
170 ret
171
c37f7e1f 172 .globl _spltty # block clists
c37f7e1f
WN
173_spltty:
174 cli # disable interrupts
83e0d013
DA
175 movw _cpl,%ax
176 orw _ttymask,%ax
c37f7e1f
WN
177 movw %ax,%dx
178 orw _imen,%ax # mask off those not enabled yet
179 movw %ax,%cx
180 NOP
4686adac 181 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
182 NOP
183 movb %ah,%al
184 NOP
4686adac 185 outb %al,$ IO_ICU2+1
c37f7e1f 186 NOP
d0d290ad 187 inb $0x84,%al
c37f7e1f
WN
188 movzwl _cpl,%eax # return old priority
189 movw %dx,_cpl # set new priority level
83e0d013 190 sti # enable interrupts
c37f7e1f
WN
191 ret
192
4686adac
BJ
193 .globl _splimp
194 .globl _splnet
195_splimp:
196_splnet:
c37f7e1f 197 cli # disable interrupts
4686adac
BJ
198 movw _cpl,%ax
199 orw _netmask,%ax
c37f7e1f
WN
200 movw %ax,%dx
201 orw _imen,%ax # mask off those not enabled yet
202 movw %ax,%cx
203 NOP
4686adac 204 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
205 NOP
206 movb %ah,%al
207 NOP
4686adac 208 outb %al,$ IO_ICU2+1
c37f7e1f 209 NOP
d0d290ad 210 inb $0x84,%al
c37f7e1f
WN
211 movzwl _cpl,%eax # return old priority
212 movw %dx,_cpl # set new priority level
83e0d013 213 sti # enable interrupts
c37f7e1f
WN
214 ret
215
4686adac
BJ
216 .globl _splbio
217_splbio:
c37f7e1f 218 cli # disable interrupts
dd22fcce 219 movw _cpl,%ax
4686adac 220 orw _biomask,%ax
c37f7e1f
WN
221 movw %ax,%dx
222 orw _imen,%ax # mask off those not enabled yet
223 movw %ax,%cx
224 NOP
4686adac 225 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
226 NOP
227 movb %ah,%al
228 NOP
4686adac 229 outb %al,$ IO_ICU2+1
c37f7e1f 230 NOP
d0d290ad 231 inb $0x84,%al
c37f7e1f
WN
232 movzwl _cpl,%eax # return old priority
233 movw %dx,_cpl # set new priority level
83e0d013 234 sti # enable interrupts
c37f7e1f
WN
235 ret
236
4686adac
BJ
237 .globl _splsoftclock
238_splsoftclock:
c37f7e1f 239 cli # disable interrupts
4686adac
BJ
240 movw _cpl,%ax
241 orw $0x8000,%ax # set new priority level
c37f7e1f
WN
242 movw %ax,%dx
243 orw _imen,%ax # mask off those not enabled yet
244 movw %ax,%cx
245 NOP
4686adac 246 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
247 NOP
248 movb %ah,%al
249 NOP
4686adac 250 outb %al,$ IO_ICU2+1
c37f7e1f 251 NOP
d0d290ad 252 inb $0x84,%al
c37f7e1f
WN
253 movzwl _cpl,%eax # return old priority
254 movw %dx,_cpl # set new priority level
255 sti # enable interrupts
256 ret
257
4686adac
BJ
258 .globl _splnone
259 .globl _spl0
260_splnone:
261_spl0:
c37f7e1f 262 cli # disable interrupts
4686adac
BJ
263 pushl _cpl # save old priority
264 movw _cpl,%ax
265 orw _netmask,%ax # mask off those network devices
266 movw %ax,_cpl # set new priority level
c37f7e1f 267 orw _imen,%ax # mask off those not enabled yet
c37f7e1f 268 NOP
4686adac 269 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
270 NOP
271 movb %ah,%al
272 NOP
4686adac 273 outb %al,$ IO_ICU2+1
c37f7e1f 274 NOP
d0d290ad 275 inb $0x84,%al
c37f7e1f 276 sti # enable interrupts
c37f7e1f 277
4686adac
BJ
278 DONET(NETISR_RAW,_rawintr)
279#ifdef INET
280 DONET(NETISR_IP,_ipintr)
281#endif
c37f7e1f 282 cli # disable interrupts
4686adac
BJ
283 popl _cpl # save old priority
284 movw $0,%ax # set new priority level
c37f7e1f
WN
285 movw %ax,%dx
286 orw _imen,%ax # mask off those not enabled yet
287 movw %ax,%cx
288 NOP
4686adac 289 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
290 NOP
291 movb %ah,%al
292 NOP
4686adac 293 outb %al,$ IO_ICU2+1
c37f7e1f 294 NOP
d0d290ad 295 inb $0x84,%al
c37f7e1f
WN
296 movzwl _cpl,%eax # return old priority
297 movw %dx,_cpl # set new priority level
298 sti # enable interrupts
299 ret
300
4686adac
BJ
301 .globl _splx
302_splx:
c37f7e1f 303 cli # disable interrupts
4686adac 304 movw 4(%esp),%ax # new priority level
c37f7e1f 305 movw %ax,%dx
4686adac
BJ
306 cmpw $0,%dx
307 je _spl0 # going to "zero level" is special
308
c37f7e1f
WN
309 orw _imen,%ax # mask off those not enabled yet
310 movw %ax,%cx
311 NOP
4686adac 312 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
313 NOP
314 movb %ah,%al
315 NOP
4686adac 316 outb %al,$ IO_ICU2+1
c37f7e1f 317 NOP
d0d290ad 318 inb $0x84,%al
c37f7e1f
WN
319 movzwl _cpl,%eax # return old priority
320 movw %dx,_cpl # set new priority level
321 sti # enable interrupts
322 ret
323
4686adac
BJ
324#ifdef notyet
325 .globl _iml8 # mask off all but irq0-1
326_iml8:
c37f7e1f 327 cli # disable interrupts
4686adac 328 movw $0xfffc,%ax # set new priority level
c37f7e1f
WN
329 movw %ax,%dx
330 orw _imen,%ax # mask off those not enabled yet
331 movw %ax,%cx
332 NOP
4686adac 333 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
334 NOP
335 movb %ah,%al
336 NOP
4686adac 337 outb %al,$ IO_ICU2+1
c37f7e1f
WN
338 NOP
339 movzwl _cpl,%eax # return old priority
340 movw %dx,_cpl # set new priority level
83e0d013 341 sti # enable interrupts
c37f7e1f
WN
342 ret
343
4686adac
BJ
344 .globl _iml10 # mask off all but irq0-1,8-9
345_iml10:
c37f7e1f 346 cli # disable interrupts
4686adac 347 movw $0xfcf8,%ax # set new priority level
c37f7e1f
WN
348 movw %ax,%dx
349 orw _imen,%ax # mask off those not enabled yet
350 movw %ax,%cx
351 NOP
4686adac 352 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
353 NOP
354 movb %ah,%al
355 NOP
4686adac 356 outb %al,$ IO_ICU2+1
c37f7e1f
WN
357 NOP
358 movzwl _cpl,%eax # return old priority
359 movw %dx,_cpl # set new priority level
360 sti # enable interrupts
361 ret
362
4686adac
BJ
363 .globl _iml11 # mask off all but irq0-1,8-10
364_iml11:
c37f7e1f 365 cli # disable interrupts
4686adac 366 movw $0xf8f8,%ax # set new priority level
c37f7e1f
WN
367 movw %ax,%dx
368 orw _imen,%ax # mask off those not enabled yet
369 movw %ax,%cx
370 NOP
4686adac 371 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
372 NOP
373 movb %ah,%al
374 NOP
4686adac 375 outb %al,$ IO_ICU2+1
c37f7e1f
WN
376 NOP
377 movzwl _cpl,%eax # return old priority
378 movw %dx,_cpl # set new priority level
379 sti # enable interrupts
380 ret
381
4686adac
BJ
382 .globl _iml12 # mask off all but irq0-1,8-11
383_iml12:
c37f7e1f 384 cli # disable interrupts
4686adac 385 movw $0xf0f8,%ax # set new priority level
c37f7e1f
WN
386 movw %ax,%dx
387 orw _imen,%ax # mask off those not enabled yet
388 movw %ax,%cx
389 NOP
4686adac 390 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
391 NOP
392 movb %ah,%al
393 NOP
4686adac 394 outb %al,$ IO_ICU2+1
c37f7e1f
WN
395 NOP
396 movzwl _cpl,%eax # return old priority
397 movw %dx,_cpl # set new priority level
398 sti # enable interrupts
399 ret
400
4686adac
BJ
401 .globl _iml13 # mask off all but irq0-1,8-12
402_iml13:
c37f7e1f 403 cli # disable interrupts
4686adac 404 movw $0xe0f8,%ax # set new priority level
c37f7e1f
WN
405 movw %ax,%dx
406 orw _imen,%ax # mask off those not enabled yet
407 movw %ax,%cx
408 NOP
4686adac 409 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
410 NOP
411 movb %ah,%al
412 NOP
4686adac 413 outb %al,$ IO_ICU2+1
c37f7e1f
WN
414 NOP
415 movzwl _cpl,%eax # return old priority
416 movw %dx,_cpl # set new priority level
417 sti # enable interrupts
418 ret
419
4686adac
BJ
420 .globl _iml15 # mask off all but irq0-1,8-14
421_iml15:
c37f7e1f 422 cli # disable interrupts
4686adac 423 movw $0x80f8,%ax # set new priority level
c37f7e1f
WN
424 movw %ax,%dx
425 orw _imen,%ax # mask off those not enabled yet
426 movw %ax,%cx
427 NOP
4686adac 428 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
429 NOP
430 movb %ah,%al
431 NOP
4686adac 432 outb %al,$ IO_ICU2+1
c37f7e1f
WN
433 NOP
434 movzwl _cpl,%eax # return old priority
435 movw %dx,_cpl # set new priority level
436 sti # enable interrupts
437 ret
438
4686adac
BJ
439 .globl _iml3 # mask off all but irq0-1,8-15
440_iml3:
c37f7e1f 441 cli # disable interrupts
4686adac 442 movw $0x00f8,%ax # set new priority level
c37f7e1f
WN
443 movw %ax,%dx
444 orw _imen,%ax # mask off those not enabled yet
445 movw %ax,%cx
446 NOP
4686adac 447 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
448 NOP
449 movb %ah,%al
450 NOP
4686adac 451 outb %al,$ IO_ICU2+1
c37f7e1f
WN
452 NOP
453 movzwl _cpl,%eax # return old priority
454 movw %dx,_cpl # set new priority level
83e0d013 455 sti # enable interrupts
c37f7e1f
WN
456 ret
457
4686adac
BJ
458 .globl _iml4 # mask off all but irq0-1,8-15,3
459_iml4:
c37f7e1f 460 cli # disable interrupts
4686adac
BJ
461 movw $0x00f0,%ax # set new priority level
462 movw %ax,%dx
dd22fcce 463 orw _imen,%ax # mask off those not enabled yet
4686adac 464 movw %ax,%cx
dd22fcce 465 NOP
4686adac 466 outb %al,$ IO_ICU1+1 /* update icu's */
dd22fcce
BJ
467 NOP
468 movb %ah,%al
469 NOP
4686adac 470 outb %al,$ IO_ICU2+1
dd22fcce 471 NOP
4686adac
BJ
472 movzwl _cpl,%eax # return old priority
473 movw %dx,_cpl # set new priority level
dd22fcce 474 sti # enable interrupts
4686adac 475 ret
dd22fcce 476
4686adac
BJ
477 .globl _iml5 # mask off all but irq0-1,8-15,3-4
478_iml5:
dd22fcce 479 cli # disable interrupts
4686adac 480 movw $0x00e0,%ax # set new priority level
c37f7e1f
WN
481 movw %ax,%dx
482 orw _imen,%ax # mask off those not enabled yet
483 movw %ax,%cx
484 NOP
4686adac 485 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
486 NOP
487 movb %ah,%al
488 NOP
4686adac 489 outb %al,$ IO_ICU2+1
c37f7e1f
WN
490 NOP
491 movzwl _cpl,%eax # return old priority
492 movw %dx,_cpl # set new priority level
493 sti # enable interrupts
494 ret
495
4686adac
BJ
496 .globl _iml6 # mask off all but irq0-1,8-15,3-5
497_iml6:
c37f7e1f 498 cli # disable interrupts
4686adac 499 movw $0x00c0,%ax # set new priority level
c37f7e1f
WN
500 movw %ax,%dx
501 orw _imen,%ax # mask off those not enabled yet
502 movw %ax,%cx
503 NOP
4686adac 504 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
505 NOP
506 movb %ah,%al
507 NOP
4686adac 508 outb %al,$ IO_ICU2+1
c37f7e1f
WN
509 NOP
510 movzwl _cpl,%eax # return old priority
511 movw %dx,_cpl # set new priority level
c37f7e1f 512 sti # enable interrupts
c37f7e1f 513 ret
dd22fcce 514
4686adac
BJ
515#endif notyet
516
517 /* hardware interrupt catcher (IDT 32 - 47) */
518 .globl _isa_strayintr
519
520IDTVEC(intr0)
d0d290ad 521 INTR(0, _highmask, 0) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
522
523IDTVEC(intr1)
d0d290ad 524 INTR(1, _highmask, 1) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
525
526IDTVEC(intr2)
d0d290ad 527 INTR(2, _highmask, 2) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
528
529IDTVEC(intr3)
d0d290ad 530 INTR(3, _highmask, 3) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
531
532IDTVEC(intr4)
d0d290ad 533 INTR(4, _highmask, 4) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
534
535IDTVEC(intr5)
d0d290ad 536 INTR(5, _highmask, 5) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
537
538IDTVEC(intr6)
d0d290ad 539 INTR(6, _highmask, 6) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
540
541IDTVEC(intr7)
d0d290ad 542 INTR(7, _highmask, 7) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
543
544
545IDTVEC(intr8)
d0d290ad 546 INTR(8, _highmask, 8) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
547
548IDTVEC(intr9)
d0d290ad 549 INTR(9, _highmask, 9) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
550
551IDTVEC(intr10)
d0d290ad 552 INTR(10, _highmask, 10) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
553
554IDTVEC(intr11)
d0d290ad 555 INTR(11, _highmask, 11) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
556
557IDTVEC(intr12)
d0d290ad 558 INTR(12, _highmask, 12) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
559
560IDTVEC(intr13)
d0d290ad 561 INTR(13, _highmask, 13) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
562
563IDTVEC(intr14)
d0d290ad 564 INTR(14, _highmask, 14) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
565
566IDTVEC(intr15)
d0d290ad 567 INTR(15, _highmask, 15) ; call _isa_strayintr ; INTREXIT2
4686adac 568