fixes for fp context switching
[unix-history] / usr / src / sys / i386 / isa / icu.s
CommitLineData
c37f7e1f 1/*-
d91e594a 2 * Copyright (c) 1989, 1990 William F. Jolitz.
c37f7e1f
WN
3 * Copyright (c) 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * William Jolitz.
8 *
d0d290ad 9 * %sccs.include.redist.c%
c37f7e1f 10 *
26f2721b 11 * @(#)icu.s 7.3 (Berkeley) %G%
c37f7e1f
WN
12 */
13
14/*
15 * AT/386
16 * Vector interrupt control section
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)
26f2721b 93 DONET(NETISR_ARP,_arpintr)
4686adac
BJ
94#endif
95#ifdef IMP
96 DONET(NETISR_IMP,_impintr)
97#endif
98#ifdef NS
99 DONET(NETISR_NS,_nsintr)
100#endif
26f2721b
KS
101#ifdef ISO
102 DONET(NETISR_ISO,_clnlintr)
103#endif
104#ifdef CCITT
105 DONET(NETISR_CCITT,_hdintr)
106#endif
4686adac
BJ
107
108 popl %eax
109 movw %ax,_cpl
110 orw _imen,%ax
111 NOP
112 outb %al,$ IO_ICU1+1 # re-enable intr?
113 NOP
114 movb %ah,%al
115 NOP
116 outb %al,$ IO_ICU2+1
117 NOP
d0d290ad 118 inb $0x84,%al
4686adac
BJ
119
120 # btrl $ NETISR_SCLK,_netisr
121 movl $ NETISR_SCLK,%eax # stupid assembler, as usual
122 btrl %eax,_netisr
123 jnb 1f
124 # back to an interrupt frame for a moment
125 call _splsoftclock
126 pushl %eax
127 pushl $0xff # dummy intr
128 call _softclock
129 popl %eax
130 call _splx
131 popl %eax
132
133 jmp 2f
134
135 /* 1: btrl $NETISR_AST,_netisr*/
1361:
137 cmpw $0x1f,13*4(%esp) # to user?
138 jne 2f # nope, leave
139 movl $ NETISR_AST,%eax # stupid assembler, as usual
140 btrl %eax,_netisr
141 jnb 2f
142 call _trap
143
1442: pop %es
145 pop %ds
146 popal
147 addl $8,%esp
148 iret
149
150/*
151 * Interrupt priority mechanism
152 *
153 * Two flavors -- imlXX masks relative to ISA noemenclature (for PC compat sw)
154 * -- splXX masks with group mechanism for BSD purposes
155 */
c37f7e1f 156
c37f7e1f
WN
157 .globl _splhigh
158 .globl _splclock
c37f7e1f
WN
159_splhigh:
160_splclock:
161 cli # disable interrupts
162 movw $0xffff,%ax # set new priority level
163 movw %ax,%dx
83e0d013 164 # orw _imen,%ax # mask off those not enabled yet
c37f7e1f
WN
165 movw %ax,%cx
166 NOP
4686adac 167 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
168 NOP
169 movb %ah,%al
170 NOP
4686adac 171 outb %al,$ IO_ICU2+1
c37f7e1f 172 NOP
d0d290ad 173 inb $0x84,%al
c37f7e1f
WN
174 movzwl _cpl,%eax # return old priority
175 movw %dx,_cpl # set new priority level
83e0d013 176 sti # enable interrupts
c37f7e1f
WN
177 ret
178
c37f7e1f 179 .globl _spltty # block clists
c37f7e1f
WN
180_spltty:
181 cli # disable interrupts
83e0d013
DA
182 movw _cpl,%ax
183 orw _ttymask,%ax
c37f7e1f
WN
184 movw %ax,%dx
185 orw _imen,%ax # mask off those not enabled yet
186 movw %ax,%cx
187 NOP
4686adac 188 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
189 NOP
190 movb %ah,%al
191 NOP
4686adac 192 outb %al,$ IO_ICU2+1
c37f7e1f 193 NOP
d0d290ad 194 inb $0x84,%al
c37f7e1f
WN
195 movzwl _cpl,%eax # return old priority
196 movw %dx,_cpl # set new priority level
83e0d013 197 sti # enable interrupts
c37f7e1f
WN
198 ret
199
4686adac
BJ
200 .globl _splimp
201 .globl _splnet
202_splimp:
203_splnet:
c37f7e1f 204 cli # disable interrupts
4686adac
BJ
205 movw _cpl,%ax
206 orw _netmask,%ax
c37f7e1f
WN
207 movw %ax,%dx
208 orw _imen,%ax # mask off those not enabled yet
209 movw %ax,%cx
210 NOP
4686adac 211 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
212 NOP
213 movb %ah,%al
214 NOP
4686adac 215 outb %al,$ IO_ICU2+1
c37f7e1f 216 NOP
d0d290ad 217 inb $0x84,%al
c37f7e1f
WN
218 movzwl _cpl,%eax # return old priority
219 movw %dx,_cpl # set new priority level
83e0d013 220 sti # enable interrupts
c37f7e1f
WN
221 ret
222
4686adac
BJ
223 .globl _splbio
224_splbio:
c37f7e1f 225 cli # disable interrupts
dd22fcce 226 movw _cpl,%ax
4686adac 227 orw _biomask,%ax
c37f7e1f
WN
228 movw %ax,%dx
229 orw _imen,%ax # mask off those not enabled yet
230 movw %ax,%cx
231 NOP
4686adac 232 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
233 NOP
234 movb %ah,%al
235 NOP
4686adac 236 outb %al,$ IO_ICU2+1
c37f7e1f 237 NOP
d0d290ad 238 inb $0x84,%al
c37f7e1f
WN
239 movzwl _cpl,%eax # return old priority
240 movw %dx,_cpl # set new priority level
83e0d013 241 sti # enable interrupts
c37f7e1f
WN
242 ret
243
4686adac
BJ
244 .globl _splsoftclock
245_splsoftclock:
c37f7e1f 246 cli # disable interrupts
4686adac
BJ
247 movw _cpl,%ax
248 orw $0x8000,%ax # set new priority level
c37f7e1f
WN
249 movw %ax,%dx
250 orw _imen,%ax # mask off those not enabled yet
251 movw %ax,%cx
252 NOP
4686adac 253 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
254 NOP
255 movb %ah,%al
256 NOP
4686adac 257 outb %al,$ IO_ICU2+1
c37f7e1f 258 NOP
d0d290ad 259 inb $0x84,%al
c37f7e1f
WN
260 movzwl _cpl,%eax # return old priority
261 movw %dx,_cpl # set new priority level
262 sti # enable interrupts
263 ret
264
4686adac
BJ
265 .globl _splnone
266 .globl _spl0
267_splnone:
268_spl0:
c37f7e1f 269 cli # disable interrupts
4686adac
BJ
270 pushl _cpl # save old priority
271 movw _cpl,%ax
272 orw _netmask,%ax # mask off those network devices
273 movw %ax,_cpl # set new priority level
c37f7e1f 274 orw _imen,%ax # mask off those not enabled yet
c37f7e1f 275 NOP
4686adac 276 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
277 NOP
278 movb %ah,%al
279 NOP
4686adac 280 outb %al,$ IO_ICU2+1
c37f7e1f 281 NOP
d0d290ad 282 inb $0x84,%al
c37f7e1f 283 sti # enable interrupts
c37f7e1f 284
4686adac
BJ
285 DONET(NETISR_RAW,_rawintr)
286#ifdef INET
287 DONET(NETISR_IP,_ipintr)
288#endif
c37f7e1f 289 cli # disable interrupts
4686adac
BJ
290 popl _cpl # save old priority
291 movw $0,%ax # set new priority level
c37f7e1f
WN
292 movw %ax,%dx
293 orw _imen,%ax # mask off those not enabled yet
294 movw %ax,%cx
295 NOP
4686adac 296 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
297 NOP
298 movb %ah,%al
299 NOP
4686adac 300 outb %al,$ IO_ICU2+1
c37f7e1f 301 NOP
d0d290ad 302 inb $0x84,%al
c37f7e1f
WN
303 movzwl _cpl,%eax # return old priority
304 movw %dx,_cpl # set new priority level
305 sti # enable interrupts
306 ret
307
4686adac
BJ
308 .globl _splx
309_splx:
c37f7e1f 310 cli # disable interrupts
4686adac 311 movw 4(%esp),%ax # new priority level
c37f7e1f 312 movw %ax,%dx
4686adac
BJ
313 cmpw $0,%dx
314 je _spl0 # going to "zero level" is special
315
c37f7e1f
WN
316 orw _imen,%ax # mask off those not enabled yet
317 movw %ax,%cx
318 NOP
4686adac 319 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
320 NOP
321 movb %ah,%al
322 NOP
4686adac 323 outb %al,$ IO_ICU2+1
c37f7e1f 324 NOP
d0d290ad 325 inb $0x84,%al
c37f7e1f
WN
326 movzwl _cpl,%eax # return old priority
327 movw %dx,_cpl # set new priority level
328 sti # enable interrupts
329 ret
330
4686adac
BJ
331#ifdef notyet
332 .globl _iml8 # mask off all but irq0-1
333_iml8:
c37f7e1f 334 cli # disable interrupts
4686adac 335 movw $0xfffc,%ax # set new priority level
c37f7e1f
WN
336 movw %ax,%dx
337 orw _imen,%ax # mask off those not enabled yet
338 movw %ax,%cx
339 NOP
4686adac 340 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
341 NOP
342 movb %ah,%al
343 NOP
4686adac 344 outb %al,$ IO_ICU2+1
c37f7e1f
WN
345 NOP
346 movzwl _cpl,%eax # return old priority
347 movw %dx,_cpl # set new priority level
83e0d013 348 sti # enable interrupts
c37f7e1f
WN
349 ret
350
4686adac
BJ
351 .globl _iml10 # mask off all but irq0-1,8-9
352_iml10:
c37f7e1f 353 cli # disable interrupts
4686adac 354 movw $0xfcf8,%ax # set new priority level
c37f7e1f
WN
355 movw %ax,%dx
356 orw _imen,%ax # mask off those not enabled yet
357 movw %ax,%cx
358 NOP
4686adac 359 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
360 NOP
361 movb %ah,%al
362 NOP
4686adac 363 outb %al,$ IO_ICU2+1
c37f7e1f
WN
364 NOP
365 movzwl _cpl,%eax # return old priority
366 movw %dx,_cpl # set new priority level
367 sti # enable interrupts
368 ret
369
4686adac
BJ
370 .globl _iml11 # mask off all but irq0-1,8-10
371_iml11:
c37f7e1f 372 cli # disable interrupts
4686adac 373 movw $0xf8f8,%ax # set new priority level
c37f7e1f
WN
374 movw %ax,%dx
375 orw _imen,%ax # mask off those not enabled yet
376 movw %ax,%cx
377 NOP
4686adac 378 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
379 NOP
380 movb %ah,%al
381 NOP
4686adac 382 outb %al,$ IO_ICU2+1
c37f7e1f
WN
383 NOP
384 movzwl _cpl,%eax # return old priority
385 movw %dx,_cpl # set new priority level
386 sti # enable interrupts
387 ret
388
4686adac
BJ
389 .globl _iml12 # mask off all but irq0-1,8-11
390_iml12:
c37f7e1f 391 cli # disable interrupts
4686adac 392 movw $0xf0f8,%ax # set new priority level
c37f7e1f
WN
393 movw %ax,%dx
394 orw _imen,%ax # mask off those not enabled yet
395 movw %ax,%cx
396 NOP
4686adac 397 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
398 NOP
399 movb %ah,%al
400 NOP
4686adac 401 outb %al,$ IO_ICU2+1
c37f7e1f
WN
402 NOP
403 movzwl _cpl,%eax # return old priority
404 movw %dx,_cpl # set new priority level
405 sti # enable interrupts
406 ret
407
4686adac
BJ
408 .globl _iml13 # mask off all but irq0-1,8-12
409_iml13:
c37f7e1f 410 cli # disable interrupts
4686adac 411 movw $0xe0f8,%ax # set new priority level
c37f7e1f
WN
412 movw %ax,%dx
413 orw _imen,%ax # mask off those not enabled yet
414 movw %ax,%cx
415 NOP
4686adac 416 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
417 NOP
418 movb %ah,%al
419 NOP
4686adac 420 outb %al,$ IO_ICU2+1
c37f7e1f
WN
421 NOP
422 movzwl _cpl,%eax # return old priority
423 movw %dx,_cpl # set new priority level
424 sti # enable interrupts
425 ret
426
4686adac
BJ
427 .globl _iml15 # mask off all but irq0-1,8-14
428_iml15:
c37f7e1f 429 cli # disable interrupts
4686adac 430 movw $0x80f8,%ax # set new priority level
c37f7e1f
WN
431 movw %ax,%dx
432 orw _imen,%ax # mask off those not enabled yet
433 movw %ax,%cx
434 NOP
4686adac 435 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
436 NOP
437 movb %ah,%al
438 NOP
4686adac 439 outb %al,$ IO_ICU2+1
c37f7e1f
WN
440 NOP
441 movzwl _cpl,%eax # return old priority
442 movw %dx,_cpl # set new priority level
443 sti # enable interrupts
444 ret
445
4686adac
BJ
446 .globl _iml3 # mask off all but irq0-1,8-15
447_iml3:
c37f7e1f 448 cli # disable interrupts
4686adac 449 movw $0x00f8,%ax # set new priority level
c37f7e1f
WN
450 movw %ax,%dx
451 orw _imen,%ax # mask off those not enabled yet
452 movw %ax,%cx
453 NOP
4686adac 454 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
455 NOP
456 movb %ah,%al
457 NOP
4686adac 458 outb %al,$ IO_ICU2+1
c37f7e1f
WN
459 NOP
460 movzwl _cpl,%eax # return old priority
461 movw %dx,_cpl # set new priority level
83e0d013 462 sti # enable interrupts
c37f7e1f
WN
463 ret
464
4686adac
BJ
465 .globl _iml4 # mask off all but irq0-1,8-15,3
466_iml4:
c37f7e1f 467 cli # disable interrupts
4686adac
BJ
468 movw $0x00f0,%ax # set new priority level
469 movw %ax,%dx
dd22fcce 470 orw _imen,%ax # mask off those not enabled yet
4686adac 471 movw %ax,%cx
dd22fcce 472 NOP
4686adac 473 outb %al,$ IO_ICU1+1 /* update icu's */
dd22fcce
BJ
474 NOP
475 movb %ah,%al
476 NOP
4686adac 477 outb %al,$ IO_ICU2+1
dd22fcce 478 NOP
4686adac
BJ
479 movzwl _cpl,%eax # return old priority
480 movw %dx,_cpl # set new priority level
dd22fcce 481 sti # enable interrupts
4686adac 482 ret
dd22fcce 483
4686adac
BJ
484 .globl _iml5 # mask off all but irq0-1,8-15,3-4
485_iml5:
dd22fcce 486 cli # disable interrupts
4686adac 487 movw $0x00e0,%ax # set new priority level
c37f7e1f
WN
488 movw %ax,%dx
489 orw _imen,%ax # mask off those not enabled yet
490 movw %ax,%cx
491 NOP
4686adac 492 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
493 NOP
494 movb %ah,%al
495 NOP
4686adac 496 outb %al,$ IO_ICU2+1
c37f7e1f
WN
497 NOP
498 movzwl _cpl,%eax # return old priority
499 movw %dx,_cpl # set new priority level
500 sti # enable interrupts
501 ret
502
4686adac
BJ
503 .globl _iml6 # mask off all but irq0-1,8-15,3-5
504_iml6:
c37f7e1f 505 cli # disable interrupts
4686adac 506 movw $0x00c0,%ax # set new priority level
c37f7e1f
WN
507 movw %ax,%dx
508 orw _imen,%ax # mask off those not enabled yet
509 movw %ax,%cx
510 NOP
4686adac 511 outb %al,$ IO_ICU1+1 /* update icu's */
c37f7e1f
WN
512 NOP
513 movb %ah,%al
514 NOP
4686adac 515 outb %al,$ IO_ICU2+1
c37f7e1f
WN
516 NOP
517 movzwl _cpl,%eax # return old priority
518 movw %dx,_cpl # set new priority level
c37f7e1f 519 sti # enable interrupts
c37f7e1f 520 ret
dd22fcce 521
4686adac
BJ
522#endif notyet
523
524 /* hardware interrupt catcher (IDT 32 - 47) */
525 .globl _isa_strayintr
526
527IDTVEC(intr0)
d0d290ad 528 INTR(0, _highmask, 0) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
529
530IDTVEC(intr1)
d0d290ad 531 INTR(1, _highmask, 1) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
532
533IDTVEC(intr2)
d0d290ad 534 INTR(2, _highmask, 2) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
535
536IDTVEC(intr3)
d0d290ad 537 INTR(3, _highmask, 3) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
538
539IDTVEC(intr4)
d0d290ad 540 INTR(4, _highmask, 4) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
541
542IDTVEC(intr5)
d0d290ad 543 INTR(5, _highmask, 5) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
544
545IDTVEC(intr6)
d0d290ad 546 INTR(6, _highmask, 6) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
547
548IDTVEC(intr7)
d0d290ad 549 INTR(7, _highmask, 7) ; call _isa_strayintr ; INTREXIT1
4686adac
BJ
550
551
552IDTVEC(intr8)
d0d290ad 553 INTR(8, _highmask, 8) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
554
555IDTVEC(intr9)
d0d290ad 556 INTR(9, _highmask, 9) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
557
558IDTVEC(intr10)
d0d290ad 559 INTR(10, _highmask, 10) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
560
561IDTVEC(intr11)
d0d290ad 562 INTR(11, _highmask, 11) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
563
564IDTVEC(intr12)
d0d290ad 565 INTR(12, _highmask, 12) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
566
567IDTVEC(intr13)
d0d290ad 568 INTR(13, _highmask, 13) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
569
570IDTVEC(intr14)
d0d290ad 571 INTR(14, _highmask, 14) ; call _isa_strayintr ; INTREXIT2
4686adac
BJ
572
573IDTVEC(intr15)
d0d290ad 574 INTR(15, _highmask, 15) ; call _isa_strayintr ; INTREXIT2
4686adac 575