npx.c revision 26373
1/*- 2 * Copyright (c) 1990 William Jolitz. 3 * Copyright (c) 1991 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by the University of 17 * California, Berkeley and its contributors. 18 * 4. Neither the name of the University nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 35 * $Id: npx.c,v 1.44 1997/05/31 09:27:31 peter Exp $ 36 */ 37 38#include "npx.h" 39#if NNPX > 0 40 41#include "opt_cpu.h" 42#include "opt_math_emulate.h" 43#include "opt_smp.h" 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/kernel.h> 48#include <sys/sysctl.h> 49#include <sys/conf.h> 50#include <sys/file.h> 51#include <sys/proc.h> 52#ifdef NPX_DEBUG 53#include <sys/syslog.h> 54#endif 55#include <sys/signalvar.h> 56 57#include <machine/asmacros.h> 58#include <machine/cpu.h> 59#include <machine/ipl.h> 60#include <machine/md_var.h> 61#include <machine/pcb.h> 62#include <machine/trap.h> 63#include <machine/clock.h> 64#include <machine/specialreg.h> 65#if defined(APIC_IO) 66#include <machine/apic.h> 67#include <machine/mpapic.h> 68#endif /* APIC_IO */ 69 70#include <i386/isa/icu.h> 71#include <i386/isa/isa_device.h> 72#include <i386/isa/intr_machdep.h> 73#include <i386/isa/isa.h> 74 75/* 76 * 387 and 287 Numeric Coprocessor Extension (NPX) Driver. 77 */ 78 79/* Configuration flags. */ 80#define NPX_DISABLE_I586_OPTIMIZED_BCOPY (1 << 0) 81#define NPX_DISABLE_I586_OPTIMIZED_BZERO (1 << 1) 82#define NPX_DISABLE_I586_OPTIMIZED_COPYIO (1 << 2) 83 84/* XXX - should be in header file. */ 85extern void (*bcopy_vector) __P((const void *from, void *to, size_t len)); 86extern void (*ovbcopy_vector) __P((const void *from, void *to, size_t len)); 87extern int (*copyin_vector) __P((const void *udaddr, void *kaddr, size_t len)); 88extern int (*copyout_vector) __P((const void *kaddr, void *udaddr, size_t len)); 89 90void i586_bcopy __P((const void *from, void *to, size_t len)); 91void i586_bzero __P((void *buf, size_t len)); 92int i586_copyin __P((const void *udaddr, void *kaddr, size_t len)); 93int i586_copyout __P((const void *kaddr, void *udaddr, size_t len)); 94 95#ifdef __GNUC__ 96 97#define fldcw(addr) __asm("fldcw %0" : : "m" (*(addr))) 98#define fnclex() __asm("fnclex") 99#define fninit() __asm("fninit") 100#define fnop() __asm("fnop") 101#define fnsave(addr) __asm("fnsave %0" : "=m" (*(addr))) 102#define fnstcw(addr) __asm("fnstcw %0" : "=m" (*(addr))) 103#define fnstsw(addr) __asm("fnstsw %0" : "=m" (*(addr))) 104#define fp_divide_by_0() __asm("fldz; fld1; fdiv %st,%st(1); fnop") 105#define frstor(addr) __asm("frstor %0" : : "m" (*(addr))) 106#define start_emulating() __asm("smsw %%ax; orb %0,%%al; lmsw %%ax" \ 107 : : "n" (CR0_TS) : "ax") 108#define stop_emulating() __asm("clts") 109 110#else /* not __GNUC__ */ 111 112void fldcw __P((caddr_t addr)); 113void fnclex __P((void)); 114void fninit __P((void)); 115void fnop __P((void)); 116void fnsave __P((caddr_t addr)); 117void fnstcw __P((caddr_t addr)); 118void fnstsw __P((caddr_t addr)); 119void fp_divide_by_0 __P((void)); 120void frstor __P((caddr_t addr)); 121void start_emulating __P((void)); 122void stop_emulating __P((void)); 123 124#endif /* __GNUC__ */ 125 126typedef u_char bool_t; 127 128static int npxattach __P((struct isa_device *dvp)); 129static int npxprobe __P((struct isa_device *dvp)); 130static int npxprobe1 __P((struct isa_device *dvp)); 131 132struct isa_driver npxdriver = { 133 npxprobe, npxattach, "npx", 134}; 135 136int hw_float; /* XXX currently just alias for npx_exists */ 137 138SYSCTL_INT(_hw,HW_FLOATINGPT, floatingpoint, 139 CTLFLAG_RD, &hw_float, 0, 140 "Floatingpoint instructions executed in hardware"); 141 142static u_int npx0_imask = SWI_CLOCK_MASK; 143#ifdef SMP 144#define npxproc (SMPnpxproc[cpunumber()]) 145struct proc *SMPnpxproc[NCPU]; 146#else 147struct proc *npxproc; 148#endif 149 150static bool_t npx_ex16; 151static bool_t npx_exists; 152static struct gate_descriptor npx_idt_probeintr; 153static int npx_intrno; 154static volatile u_int npx_intrs_while_probing; 155static bool_t npx_irq13; 156static volatile u_int npx_traps_while_probing; 157 158/* 159 * Special interrupt handlers. Someday intr0-intr15 will be used to count 160 * interrupts. We'll still need a special exception 16 handler. The busy 161 * latch stuff in probeintr() can be moved to npxprobe(). 162 */ 163inthand_t probeintr; 164 165#if defined(APIC_IO) 166 167asm 168(" 169 .text 170 .p2align 2,0x90 171" __XSTRING(CNAME(probeintr)) ": 172 ss 173 incl " __XSTRING(CNAME(npx_intrs_while_probing)) " 174 pushl %eax 175 movl " __XSTRING(CNAME(apic_base)) ",%eax # EOI to local APIC 176 movl $0,0xb0(,%eax,1) # movl $0, APIC_EOI(%eax) 177 movb $0,%al 178 outb %al,$0xf0 # clear BUSY# latch 179 popl %eax 180 iret 181"); 182 183#else 184 185asm 186(" 187 .text 188 .p2align 2,0x90 189" __XSTRING(CNAME(probeintr)) ": 190 ss 191 incl " __XSTRING(CNAME(npx_intrs_while_probing)) " 192 pushl %eax 193 movb $0x20,%al # EOI (asm in strings loses cpp features) 194 outb %al,$0xa0 # IO_ICU2 195 outb %al,$0x20 # IO_ICU1 196 movb $0,%al 197 outb %al,$0xf0 # clear BUSY# latch 198 popl %eax 199 iret 200"); 201 202#endif /* APIC_IO */ 203 204inthand_t probetrap; 205asm 206(" 207 .text 208 .p2align 2,0x90 209" __XSTRING(CNAME(probetrap)) ": 210 ss 211 incl " __XSTRING(CNAME(npx_traps_while_probing)) " 212 fnclex 213 iret 214"); 215 216/* 217 * Probe routine. Initialize cr0 to give correct behaviour for [f]wait 218 * whether the device exists or not (XXX should be elsewhere). Set flags 219 * to tell npxattach() what to do. Modify device struct if npx doesn't 220 * need to use interrupts. Return 1 if device exists. 221 */ 222static int 223npxprobe(dvp) 224 struct isa_device *dvp; 225{ 226 int result; 227 u_long save_eflags; 228#if defined(APIC_IO) 229 u_int save_apic_mask; 230#else 231 u_char save_icu1_mask; 232 u_char save_icu2_mask; 233#endif /* APIC_IO */ 234 struct gate_descriptor save_idt_npxintr; 235 struct gate_descriptor save_idt_npxtrap; 236 /* 237 * This routine is now just a wrapper for npxprobe1(), to install 238 * special npx interrupt and trap handlers, to enable npx interrupts 239 * and to disable other interrupts. Someday isa_configure() will 240 * install suitable handlers and run with interrupts enabled so we 241 * won't need to do so much here. 242 */ 243 npx_intrno = NRSVIDT + ffs(dvp->id_irq) - 1; 244 save_eflags = read_eflags(); 245 disable_intr(); 246#if defined(APIC_IO) 247 save_apic_mask = INTRGET(); 248#else 249 save_icu1_mask = inb(IO_ICU1 + 1); 250 save_icu2_mask = inb(IO_ICU2 + 1); 251#endif /* APIC_IO */ 252 save_idt_npxintr = idt[npx_intrno]; 253 save_idt_npxtrap = idt[16]; 254#if defined(APIC_IO) 255 INTRSET( ~dvp->id_irq ); 256#else 257 outb(IO_ICU1 + 1, ~(IRQ_SLAVE | dvp->id_irq)); 258 outb(IO_ICU2 + 1, ~(dvp->id_irq >> 8)); 259#endif /* APIC_IO */ 260 setidt(16, probetrap, SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); 261 setidt(npx_intrno, probeintr, SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); 262 npx_idt_probeintr = idt[npx_intrno]; 263 enable_intr(); 264 result = npxprobe1(dvp); 265 disable_intr(); 266#if defined(APIC_IO) 267 INTRSET( save_apic_mask ); 268#else 269 outb(IO_ICU1 + 1, save_icu1_mask); 270 outb(IO_ICU2 + 1, save_icu2_mask); 271#endif /* APIC_IO */ 272 idt[npx_intrno] = save_idt_npxintr; 273 idt[16] = save_idt_npxtrap; 274 write_eflags(save_eflags); 275 return (result); 276} 277 278static int 279npxprobe1(dvp) 280 struct isa_device *dvp; 281{ 282 u_short control; 283 u_short status; 284 285 /* 286 * Partially reset the coprocessor, if any. Some BIOS's don't reset 287 * it after a warm boot. 288 */ 289 outb(0xf1, 0); /* full reset on some systems, NOP on others */ 290 outb(0xf0, 0); /* clear BUSY# latch */ 291 /* 292 * Prepare to trap all ESC (i.e., NPX) instructions and all WAIT 293 * instructions. We must set the CR0_MP bit and use the CR0_TS 294 * bit to control the trap, because setting the CR0_EM bit does 295 * not cause WAIT instructions to trap. It's important to trap 296 * WAIT instructions - otherwise the "wait" variants of no-wait 297 * control instructions would degenerate to the "no-wait" variants 298 * after FP context switches but work correctly otherwise. It's 299 * particularly important to trap WAITs when there is no NPX - 300 * otherwise the "wait" variants would always degenerate. 301 * 302 * Try setting CR0_NE to get correct error reporting on 486DX's. 303 * Setting it should fail or do nothing on lesser processors. 304 */ 305 load_cr0(rcr0() | CR0_MP | CR0_NE); 306 /* 307 * But don't trap while we're probing. 308 */ 309 stop_emulating(); 310 /* 311 * Finish resetting the coprocessor, if any. If there is an error 312 * pending, then we may get a bogus IRQ13, but probeintr() will handle 313 * it OK. Bogus halts have never been observed, but we enabled 314 * IRQ13 and cleared the BUSY# latch early to handle them anyway. 315 */ 316 fninit(); 317 /* 318 * Don't use fwait here because it might hang. 319 * Don't use fnop here because it usually hangs if there is no FPU. 320 */ 321 DELAY(1000); /* wait for any IRQ13 */ 322#ifdef DIAGNOSTIC 323 if (npx_intrs_while_probing != 0) 324 printf("fninit caused %u bogus npx interrupt(s)\n", 325 npx_intrs_while_probing); 326 if (npx_traps_while_probing != 0) 327 printf("fninit caused %u bogus npx trap(s)\n", 328 npx_traps_while_probing); 329#endif 330 /* 331 * Check for a status of mostly zero. 332 */ 333 status = 0x5a5a; 334 fnstsw(&status); 335 if ((status & 0xb8ff) == 0) { 336 /* 337 * Good, now check for a proper control word. 338 */ 339 control = 0x5a5a; 340 fnstcw(&control); 341 if ((control & 0x1f3f) == 0x033f) { 342 hw_float = npx_exists = 1; 343 /* 344 * We have an npx, now divide by 0 to see if exception 345 * 16 works. 346 */ 347 control &= ~(1 << 2); /* enable divide by 0 trap */ 348 fldcw(&control); 349 npx_traps_while_probing = npx_intrs_while_probing = 0; 350 fp_divide_by_0(); 351 if (npx_traps_while_probing != 0) { 352 /* 353 * Good, exception 16 works. 354 */ 355 npx_ex16 = 1; 356 dvp->id_irq = 0; /* zap the interrupt */ 357 /* 358 * special return value to flag that we do not 359 * actually use any I/O registers 360 */ 361 return (-1); 362 } 363 if (npx_intrs_while_probing != 0) { 364 /* 365 * Bad, we are stuck with IRQ13. 366 */ 367 npx_irq13 = 1; 368 /* 369 * npxattach would be too late to set npx0_imask. 370 */ 371 npx0_imask |= dvp->id_irq; 372 return (IO_NPXSIZE); 373 } 374 /* 375 * Worse, even IRQ13 is broken. Use emulator. 376 */ 377 } 378 } 379 /* 380 * Probe failed, but we want to get to npxattach to initialize the 381 * emulator and say that it has been installed. XXX handle devices 382 * that aren't really devices better. 383 */ 384 dvp->id_irq = 0; 385 /* 386 * special return value to flag that we do not 387 * actually use any I/O registers 388 */ 389 return (-1); 390} 391 392/* 393 * Attach routine - announce which it is, and wire into system 394 */ 395int 396npxattach(dvp) 397 struct isa_device *dvp; 398{ 399 /* The caller has printed "irq 13" for the npx_irq13 case. */ 400 if (!npx_irq13) { 401 printf("npx%d: ", dvp->id_unit); 402 if (npx_ex16) 403 printf("INT 16 interface\n"); 404#if defined(MATH_EMULATE) || defined(GPL_MATH_EMULATE) 405 else if (npx_exists) { 406 printf("error reporting broken; using 387 emulator\n"); 407 hw_float = npx_exists = 0; 408 } else 409 printf("387 emulator\n"); 410#else 411 else 412 printf("no 387 emulator in kernel!\n"); 413#endif 414 } 415 npxinit(__INITIAL_NPXCW__); 416 417#if defined(I586_CPU) && !defined(SMP) 418 /* FPU not working under SMP yet */ 419 if (cpu_class == CPUCLASS_586 && npx_ex16) { 420 if (!(dvp->id_flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY)) { 421 bcopy_vector = i586_bcopy; 422 ovbcopy_vector = i586_bcopy; 423 } 424 if (!(dvp->id_flags & NPX_DISABLE_I586_OPTIMIZED_BZERO)) 425 bzero = i586_bzero; 426 if (!(dvp->id_flags & NPX_DISABLE_I586_OPTIMIZED_COPYIO)) { 427 copyin_vector = i586_copyin; 428 copyout_vector = i586_copyout; 429 } 430 } 431#endif 432 433 return (1); /* XXX unused */ 434} 435 436/* 437 * Initialize floating point unit. 438 */ 439void 440npxinit(control) 441 u_short control; 442{ 443 struct save87 dummy; 444 445 if (!npx_exists) 446 return; 447 /* 448 * fninit has the same h/w bugs as fnsave. Use the detoxified 449 * fnsave to throw away any junk in the fpu. npxsave() initializes 450 * the fpu and sets npxproc = NULL as important side effects. 451 */ 452 npxsave(&dummy); 453 stop_emulating(); 454 fldcw(&control); 455 if (curpcb != NULL) 456 fnsave(&curpcb->pcb_savefpu); 457 start_emulating(); 458} 459 460/* 461 * Free coprocessor (if we have it). 462 */ 463void 464npxexit(p) 465 struct proc *p; 466{ 467 468 if (p == npxproc) 469 npxsave(&curpcb->pcb_savefpu); 470#ifdef NPX_DEBUG 471 if (npx_exists) { 472 u_int masked_exceptions; 473 474 masked_exceptions = curpcb->pcb_savefpu.sv_env.en_cw 475 & curpcb->pcb_savefpu.sv_env.en_sw & 0x7f; 476 /* 477 * Log exceptions that would have trapped with the old 478 * control word (overflow, divide by 0, and invalid operand). 479 */ 480 if (masked_exceptions & 0x0d) 481 log(LOG_ERR, 482 "pid %d (%s) exited with masked floating point exceptions 0x%02x\n", 483 p->p_pid, p->p_comm, masked_exceptions); 484 } 485#endif 486} 487 488/* 489 * Preserve the FP status word, clear FP exceptions, then generate a SIGFPE. 490 * 491 * Clearing exceptions is necessary mainly to avoid IRQ13 bugs. We now 492 * depend on longjmp() restoring a usable state. Restoring the state 493 * or examining it might fail if we didn't clear exceptions. 494 * 495 * XXX there is no standard way to tell SIGFPE handlers about the error 496 * state. The old interface: 497 * 498 * void handler(int sig, int code, struct sigcontext *scp); 499 * 500 * is broken because it is non-ANSI and because the FP state is not in 501 * struct sigcontext. 502 * 503 * XXX the FP state is not preserved across signal handlers. So signal 504 * handlers cannot afford to do FP unless they preserve the state or 505 * longjmp() out. Both preserving the state and longjmp()ing may be 506 * destroyed by IRQ13 bugs. Clearing FP exceptions is not an acceptable 507 * solution for signals other than SIGFPE. 508 */ 509void 510npxintr(unit) 511 int unit; 512{ 513 int code; 514 struct intrframe *frame; 515 516 if (npxproc == NULL || !npx_exists) { 517 printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n", 518 npxproc, curproc, npx_exists); 519 panic("npxintr from nowhere"); 520 } 521 if (npxproc != curproc) { 522 printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n", 523 npxproc, curproc, npx_exists); 524 panic("npxintr from non-current process"); 525 } 526 527 outb(0xf0, 0); 528 fnstsw(&curpcb->pcb_savefpu.sv_ex_sw); 529 fnclex(); 530 fnop(); 531 532 /* 533 * Pass exception to process. 534 */ 535 frame = (struct intrframe *)&unit; /* XXX */ 536 if (ISPL(frame->if_cs) == SEL_UPL) { 537 /* 538 * Interrupt is essentially a trap, so we can afford to call 539 * the SIGFPE handler (if any) as soon as the interrupt 540 * returns. 541 * 542 * XXX little or nothing is gained from this, and plenty is 543 * lost - the interrupt frame has to contain the trap frame 544 * (this is otherwise only necessary for the rescheduling trap 545 * in doreti, and the frame for that could easily be set up 546 * just before it is used). 547 */ 548 curproc->p_md.md_regs = (struct trapframe *)&frame->if_es; 549#ifdef notyet 550 /* 551 * Encode the appropriate code for detailed information on 552 * this exception. 553 */ 554 code = XXX_ENCODE(curpcb->pcb_savefpu.sv_ex_sw); 555#else 556 code = 0; /* XXX */ 557#endif 558 trapsignal(curproc, SIGFPE, code); 559 } else { 560 /* 561 * Nested interrupt. These losers occur when: 562 * o an IRQ13 is bogusly generated at a bogus time, e.g.: 563 * o immediately after an fnsave or frstor of an 564 * error state. 565 * o a couple of 386 instructions after 566 * "fstpl _memvar" causes a stack overflow. 567 * These are especially nasty when combined with a 568 * trace trap. 569 * o an IRQ13 occurs at the same time as another higher- 570 * priority interrupt. 571 * 572 * Treat them like a true async interrupt. 573 */ 574 psignal(curproc, SIGFPE); 575 } 576} 577 578/* 579 * Implement device not available (DNA) exception 580 * 581 * It would be better to switch FP context here (if curproc != npxproc) 582 * and not necessarily for every context switch, but it is too hard to 583 * access foreign pcb's. 584 */ 585int 586npxdna() 587{ 588 if (!npx_exists) 589 return (0); 590 if (npxproc != NULL) { 591 printf("npxdna: npxproc = %p, curproc = %p\n", 592 npxproc, curproc); 593 panic("npxdna"); 594 } 595 stop_emulating(); 596 /* 597 * Record new context early in case frstor causes an IRQ13. 598 */ 599 npxproc = curproc; 600 curpcb->pcb_savefpu.sv_ex_sw = 0; 601 /* 602 * The following frstor may cause an IRQ13 when the state being 603 * restored has a pending error. The error will appear to have been 604 * triggered by the current (npx) user instruction even when that 605 * instruction is a no-wait instruction that should not trigger an 606 * error (e.g., fnclex). On at least one 486 system all of the 607 * no-wait instructions are broken the same as frstor, so our 608 * treatment does not amplify the breakage. On at least one 609 * 386/Cyrix 387 system, fnclex works correctly while frstor and 610 * fnsave are broken, so our treatment breaks fnclex if it is the 611 * first FPU instruction after a context switch. 612 */ 613 frstor(&curpcb->pcb_savefpu); 614 615 return (1); 616} 617 618/* 619 * Wrapper for fnsave instruction to handle h/w bugs. If there is an error 620 * pending, then fnsave generates a bogus IRQ13 on some systems. Force 621 * any IRQ13 to be handled immediately, and then ignore it. This routine is 622 * often called at splhigh so it must not use many system services. In 623 * particular, it's much easier to install a special handler than to 624 * guarantee that it's safe to use npxintr() and its supporting code. 625 */ 626void 627npxsave(addr) 628 struct save87 *addr; 629{ 630#if defined(APIC_IO) 631 u_int apic_mask; 632 u_int old_apic_mask; 633#else 634 u_char icu1_mask; 635 u_char icu2_mask; 636 u_char old_icu1_mask; 637 u_char old_icu2_mask; 638#endif /* APIC_IO */ 639 struct gate_descriptor save_idt_npxintr; 640 641 disable_intr(); 642#if defined(APIC_IO) 643 old_apic_mask = INTRGET(); 644#else 645 old_icu1_mask = inb(IO_ICU1 + 1); 646 old_icu2_mask = inb(IO_ICU2 + 1); 647#endif /* APIC_IO */ 648 save_idt_npxintr = idt[npx_intrno]; 649#if defined(APIC_IO) 650 /** FIXME: try clrIoApicMaskBit( npx0_imask ); */ 651 INTRSET( old_apic_mask & ~(npx0_imask & 0xffff) ); 652#else 653 outb(IO_ICU1 + 1, old_icu1_mask & ~(IRQ_SLAVE | npx0_imask)); 654 outb(IO_ICU2 + 1, old_icu2_mask & ~(npx0_imask >> 8)); 655#endif /* APIC_IO */ 656 idt[npx_intrno] = npx_idt_probeintr; 657 enable_intr(); 658 stop_emulating(); 659 fnsave(addr); 660 fnop(); 661 start_emulating(); 662 npxproc = NULL; 663 disable_intr(); 664#if defined(APIC_IO) 665 apic_mask = INTRGET(); /* masks may have changed */ 666 INTRSET( (apic_mask & ~(npx0_imask & 0xffff)) | 667 (old_apic_mask & (npx0_imask & 0xffff))); 668#else 669 icu1_mask = inb(IO_ICU1 + 1); /* masks may have changed */ 670 icu2_mask = inb(IO_ICU2 + 1); 671 outb(IO_ICU1 + 1, 672 (icu1_mask & ~npx0_imask) | (old_icu1_mask & npx0_imask)); 673 outb(IO_ICU2 + 1, 674 (icu2_mask & ~(npx0_imask >> 8)) 675 | (old_icu2_mask & (npx0_imask >> 8))); 676#endif /* APIC_IO */ 677 idt[npx_intrno] = save_idt_npxintr; 678 enable_intr(); /* back to usual state */ 679} 680 681#endif /* NNPX > 0 */ 682