1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 #include <sys/types.h> 30 #include <sys/t_lock.h> 31 #include <sys/param.h> 32 #include <sys/sysmacros.h> 33 #include <sys/signal.h> 34 #include <sys/systm.h> 35 #include <sys/user.h> 36 #include <sys/mman.h> 37 #include <sys/vm.h> 38 39 #include <sys/disp.h> 40 #include <sys/class.h> 41 42 #include <sys/proc.h> 43 #include <sys/buf.h> 44 #include <sys/kmem.h> 45 46 #include <sys/reboot.h> 47 #include <sys/uadmin.h> 48 #include <sys/callb.h> 49 50 #include <sys/cred.h> 51 #include <sys/vnode.h> 52 #include <sys/file.h> 53 54 #include <sys/procfs.h> 55 #include <sys/acct.h> 56 57 #include <sys/vfs.h> 58 #include <sys/dnlc.h> 59 #include <sys/var.h> 60 #include <sys/cmn_err.h> 61 #include <sys/utsname.h> 62 #include <sys/debug.h> 63 #include <sys/kdi_impl.h> 64 65 #include <sys/dumphdr.h> 66 #include <sys/bootconf.h> 67 #include <sys/varargs.h> 68 #include <sys/promif.h> 69 #include <sys/modctl.h> 70 71 #include <sys/consdev.h> 72 #include <sys/frame.h> 73 74 #include <sys/sunddi.h> 75 #include <sys/ddidmareq.h> 76 #include <sys/psw.h> 77 #include <sys/regset.h> 78 #include <sys/privregs.h> 79 #include <sys/clock.h> 80 #include <sys/tss.h> 81 #include <sys/cpu.h> 82 #include <sys/stack.h> 83 #include <sys/trap.h> 84 #include <sys/pic.h> 85 #include <sys/mmu.h> 86 #include <vm/hat.h> 87 #include <vm/anon.h> 88 #include <vm/as.h> 89 #include <vm/page.h> 90 #include <vm/seg.h> 91 #include <vm/seg_kmem.h> 92 #include <vm/seg_map.h> 93 #include <vm/seg_vn.h> 94 #include <vm/seg_kp.h> 95 #include <vm/hat_i86.h> 96 #include <sys/swap.h> 97 #include <sys/thread.h> 98 #include <sys/sysconf.h> 99 #include <sys/vm_machparam.h> 100 #include <sys/archsystm.h> 101 #include <sys/machsystm.h> 102 #include <sys/machlock.h> 103 #include <sys/x_call.h> 104 #include <sys/instance.h> 105 106 #include <sys/time.h> 107 #include <sys/smp_impldefs.h> 108 #include <sys/psm_types.h> 109 #include <sys/atomic.h> 110 #include <sys/panic.h> 111 #include <sys/cpuvar.h> 112 #include <sys/dtrace.h> 113 #include <sys/bl.h> 114 #include <sys/nvpair.h> 115 #include <sys/x86_archext.h> 116 #include <sys/pool_pset.h> 117 #include <sys/autoconf.h> 118 #include <sys/kdi.h> 119 120 #ifdef TRAPTRACE 121 #include <sys/traptrace.h> 122 #endif /* TRAPTRACE */ 123 124 #ifdef C2_AUDIT 125 extern void audit_enterprom(int); 126 extern void audit_exitprom(int); 127 #endif 128 129 /* 130 * The panicbuf array is used to record messages and state: 131 */ 132 char panicbuf[PANICBUFSIZE]; 133 134 /* 135 * maxphys - used during physio 136 * klustsize - used for klustering by swapfs and specfs 137 */ 138 int maxphys = 56 * 1024; /* XXX See vm_subr.c - max b_count in physio */ 139 int klustsize = 56 * 1024; 140 141 caddr_t p0_va; /* Virtual address for accessing physical page 0 */ 142 int pokefault = 0; 143 144 /* 145 * defined here, though unused on x86, 146 * to make kstat_fr.c happy. 147 */ 148 int vac; 149 150 void stop_other_cpus(); 151 void debug_enter(char *); 152 153 int procset = 1; 154 155 /* 156 * Flags set by mdboot if we're panicking and we invoke mdboot on a CPU which 157 * is not the boot CPU. When set, panic_idle() on the boot CPU will invoke 158 * mdboot with the corresponding arguments. 159 */ 160 161 #define BOOT_WAIT -1 /* Flag indicating we should idle */ 162 163 volatile int cpu_boot_cmd = BOOT_WAIT; 164 volatile int cpu_boot_fcn = BOOT_WAIT; 165 166 extern void pm_cfb_check_and_powerup(void); 167 extern void pm_cfb_rele(void); 168 169 /* 170 * Machine dependent code to reboot. 171 * "mdep" is interpreted as a character pointer; if non-null, it is a pointer 172 * to a string to be used as the argument string when rebooting. 173 */ 174 /*ARGSUSED*/ 175 void 176 mdboot(int cmd, int fcn, char *mdep) 177 { 178 extern void mtrr_resync(void); 179 180 /* 181 * The PSMI guarantees the implementor of psm_shutdown that it will 182 * only be called on the boot CPU. This was needed by Corollary 183 * because the hardware does not allow other CPUs to reset the 184 * boot CPU. So before rebooting, we switch over to the boot CPU. 185 * If we are panicking, the other CPUs are at high spl spinning in 186 * panic_idle(), so we set the cpu_boot_* variables and wait for 187 * the boot CPU to re-invoke mdboot() for us. 188 */ 189 if (!panicstr) { 190 kpreempt_disable(); 191 affinity_set(getbootcpuid()); 192 } else if (CPU->cpu_id != getbootcpuid()) { 193 cpu_boot_cmd = cmd; 194 cpu_boot_fcn = fcn; 195 for (;;); 196 } 197 198 /* 199 * XXX - rconsvp is set to NULL to ensure that output messages 200 * are sent to the underlying "hardware" device using the 201 * monitor's printf routine since we are in the process of 202 * either rebooting or halting the machine. 203 */ 204 rconsvp = NULL; 205 206 /* 207 * Print the reboot message now, before pausing other cpus. 208 * There is a race condition in the printing support that 209 * can deadlock multiprocessor machines. 210 */ 211 if (!(fcn == AD_HALT || fcn == AD_POWEROFF)) 212 prom_printf("rebooting...\n"); 213 214 /* 215 * We can't bring up the console from above lock level, so do it now 216 */ 217 pm_cfb_check_and_powerup(); 218 219 /* make sure there are no more changes to the device tree */ 220 devtree_freeze(); 221 222 /* 223 * stop other cpus and raise our priority. since there is only 224 * one active cpu after this, and our priority will be too high 225 * for us to be preempted, we're essentially single threaded 226 * from here on out. 227 */ 228 (void) spl6(); 229 if (!panicstr) { 230 mutex_enter(&cpu_lock); 231 pause_cpus(NULL); 232 mutex_exit(&cpu_lock); 233 } 234 235 /* 236 * try and reset leaf devices. reset_leaves() should only 237 * be called when there are no other threads that could be 238 * accessing devices 239 */ 240 reset_leaves(); 241 242 (void) spl8(); 243 (*psm_shutdownf)(cmd, fcn); 244 245 mtrr_resync(); 246 247 if (fcn == AD_HALT || fcn == AD_POWEROFF) 248 halt((char *)NULL); 249 else 250 prom_reboot(""); 251 /*NOTREACHED*/ 252 } 253 254 /* mdpreboot - may be called prior to mdboot while root fs still mounted */ 255 /*ARGSUSED*/ 256 void 257 mdpreboot(int cmd, int fcn, char *mdep) 258 { 259 (*psm_preshutdownf)(cmd, fcn); 260 } 261 262 void 263 idle_other_cpus() 264 { 265 int cpuid = CPU->cpu_id; 266 cpuset_t xcset; 267 268 ASSERT(cpuid < NCPU); 269 CPUSET_ALL_BUT(xcset, cpuid); 270 xc_capture_cpus(xcset); 271 } 272 273 void 274 resume_other_cpus() 275 { 276 ASSERT(CPU->cpu_id < NCPU); 277 278 xc_release_cpus(); 279 } 280 281 extern void mp_halt(char *); 282 283 void 284 stop_other_cpus() 285 { 286 int cpuid = CPU->cpu_id; 287 cpuset_t xcset; 288 289 ASSERT(cpuid < NCPU); 290 291 /* 292 * xc_trycall will attempt to make all other CPUs execute mp_halt, 293 * and will return immediately regardless of whether or not it was 294 * able to make them do it. 295 */ 296 CPUSET_ALL_BUT(xcset, cpuid); 297 xc_trycall(NULL, NULL, NULL, xcset, (int (*)())mp_halt); 298 } 299 300 /* 301 * Machine dependent abort sequence handling 302 */ 303 void 304 abort_sequence_enter(char *msg) 305 { 306 if (abort_enable == 0) { 307 #ifdef C2_AUDIT 308 if (audit_active) 309 audit_enterprom(0); 310 #endif /* C2_AUDIT */ 311 return; 312 } 313 #ifdef C2_AUDIT 314 if (audit_active) 315 audit_enterprom(1); 316 #endif /* C2_AUDIT */ 317 debug_enter(msg); 318 #ifdef C2_AUDIT 319 if (audit_active) 320 audit_exitprom(1); 321 #endif /* C2_AUDIT */ 322 } 323 324 /* 325 * Enter debugger. Called when the user types ctrl-alt-d or whenever 326 * code wants to enter the debugger and possibly resume later. 327 */ 328 void 329 debug_enter( 330 char *msg) /* message to print, possibly NULL */ 331 { 332 if (dtrace_debugger_init != NULL) 333 (*dtrace_debugger_init)(); 334 335 if (msg) 336 prom_printf("%s\n", msg); 337 338 if (boothowto & RB_DEBUG) 339 kdi_dvec_enter(); 340 341 if (dtrace_debugger_fini != NULL) 342 (*dtrace_debugger_fini)(); 343 } 344 345 void 346 reset(void) 347 { 348 ushort_t *bios_memchk; 349 350 /* 351 * Can't use psm_map_phys before the hat is initialized. 352 */ 353 if (khat_running) { 354 bios_memchk = (ushort_t *)psm_map_phys(0x472, 355 sizeof (ushort_t), PROT_READ | PROT_WRITE); 356 if (bios_memchk) 357 *bios_memchk = 0x1234; /* bios memory check disable */ 358 } 359 360 pc_reset(); 361 /*NOTREACHED*/ 362 } 363 364 /* 365 * Halt the machine and return to the monitor 366 */ 367 void 368 halt(char *s) 369 { 370 stop_other_cpus(); /* send stop signal to other CPUs */ 371 if (s) 372 prom_printf("(%s) \n", s); 373 prom_exit_to_mon(); 374 /*NOTREACHED*/ 375 } 376 377 /* 378 * Enter monitor. Called via cross-call from stop_other_cpus(). 379 */ 380 void 381 mp_halt(char *msg) 382 { 383 if (msg) 384 prom_printf("%s\n", msg); 385 386 /*CONSTANTCONDITION*/ 387 while (1) 388 ; 389 } 390 391 /* 392 * Initiate interrupt redistribution. 393 */ 394 void 395 i_ddi_intr_redist_all_cpus() 396 { 397 } 398 399 /* 400 * XXX These probably ought to live somewhere else 401 * XXX They are called from mem.c 402 */ 403 404 /* 405 * Convert page frame number to an OBMEM page frame number 406 * (i.e. put in the type bits -- zero for this implementation) 407 */ 408 pfn_t 409 impl_obmem_pfnum(pfn_t pf) 410 { 411 return (pf); 412 } 413 414 #ifdef NM_DEBUG 415 int nmi_test = 0; /* checked in intentry.s during clock int */ 416 int nmtest = -1; 417 nmfunc1(arg, rp) 418 int arg; 419 struct regs *rp; 420 { 421 printf("nmi called with arg = %x, regs = %x\n", arg, rp); 422 nmtest += 50; 423 if (arg == nmtest) { 424 printf("ip = %x\n", rp->r_pc); 425 return (1); 426 } 427 return (0); 428 } 429 430 #endif 431 432 #include <sys/bootsvcs.h> 433 434 /* Hacked up initialization for initial kernel check out is HERE. */ 435 /* The basic steps are: */ 436 /* kernel bootfuncs definition/initialization for KADB */ 437 /* kadb bootfuncs pointer initialization */ 438 /* putchar/getchar (interrupts disabled) */ 439 440 /* kadb bootfuncs pointer initialization */ 441 442 int 443 sysp_getchar() 444 { 445 int i; 446 int s; 447 448 if (cons_polledio == NULL) { 449 /* Uh oh */ 450 prom_printf("getchar called with no console\n"); 451 for (;;) 452 /* LOOP FOREVER */; 453 } 454 455 s = clear_int_flag(); 456 i = cons_polledio->cons_polledio_getchar( 457 cons_polledio->cons_polledio_argument); 458 restore_int_flag(s); 459 return (i); 460 } 461 462 void 463 sysp_putchar(int c) 464 { 465 int s; 466 467 /* 468 * We have no alternative but to drop the output on the floor. 469 */ 470 if (cons_polledio == NULL) 471 return; 472 473 s = clear_int_flag(); 474 cons_polledio->cons_polledio_putchar( 475 cons_polledio->cons_polledio_argument, c); 476 restore_int_flag(s); 477 } 478 479 int 480 sysp_ischar() 481 { 482 int i; 483 int s; 484 485 if (cons_polledio == NULL) 486 return (0); 487 488 s = clear_int_flag(); 489 i = cons_polledio->cons_polledio_ischar( 490 cons_polledio->cons_polledio_argument); 491 restore_int_flag(s); 492 return (i); 493 } 494 495 int 496 goany(void) 497 { 498 prom_printf("Type any key to continue "); 499 (void) prom_getchar(); 500 prom_printf("\n"); 501 return (1); 502 } 503 504 static struct boot_syscalls kern_sysp = { 505 sysp_getchar, /* unchar (*getchar)(); 7 */ 506 sysp_putchar, /* int (*putchar)(); 8 */ 507 sysp_ischar, /* int (*ischar)(); 9 */ 508 }; 509 510 void 511 kadb_uses_kernel() 512 { 513 /* 514 * This routine is now totally misnamed, since it does not in fact 515 * control kadb's I/O; it only controls the kernel's prom_* I/O. 516 */ 517 sysp = &kern_sysp; 518 } 519 520 /* 521 * the interface to the outside world 522 */ 523 524 /* 525 * poll_port -- wait for a register to achieve a 526 * specific state. Arguments are a mask of bits we care about, 527 * and two sub-masks. To return normally, all the bits in the 528 * first sub-mask must be ON, all the bits in the second sub- 529 * mask must be OFF. If about seconds pass without the register 530 * achieving the desired bit configuration, we return 1, else 531 * 0. 532 */ 533 int 534 poll_port(ushort_t port, ushort_t mask, ushort_t onbits, ushort_t offbits) 535 { 536 int i; 537 ushort_t maskval; 538 539 for (i = 500000; i; i--) { 540 maskval = inb(port) & mask; 541 if (((maskval & onbits) == onbits) && 542 ((maskval & offbits) == 0)) 543 return (0); 544 drv_usecwait(10); 545 } 546 return (1); 547 } 548 549 /* 550 * set_idle_cpu is called from idle() when a CPU becomes idle. 551 */ 552 /*LINTED: static unused */ 553 static uint_t last_idle_cpu; 554 555 /*ARGSUSED*/ 556 void 557 set_idle_cpu(int cpun) 558 { 559 last_idle_cpu = cpun; 560 (*psm_set_idle_cpuf)(cpun); 561 } 562 563 /* 564 * unset_idle_cpu is called from idle() when a CPU is no longer idle. 565 */ 566 /*ARGSUSED*/ 567 void 568 unset_idle_cpu(int cpun) 569 { 570 (*psm_unset_idle_cpuf)(cpun); 571 } 572 573 /* 574 * This routine is almost correct now, but not quite. It still needs the 575 * equivalent concept of "hres_last_tick", just like on the sparc side. 576 * The idea is to take a snapshot of the hi-res timer while doing the 577 * hrestime_adj updates under hres_lock in locore, so that the small 578 * interval between interrupt assertion and interrupt processing is 579 * accounted for correctly. Once we have this, the code below should 580 * be modified to subtract off hres_last_tick rather than hrtime_base. 581 * 582 * I'd have done this myself, but I don't have source to all of the 583 * vendor-specific hi-res timer routines (grrr...). The generic hook I 584 * need is something like "gethrtime_unlocked()", which would be just like 585 * gethrtime() but would assume that you're already holding CLOCK_LOCK(). 586 * This is what the GET_HRTIME() macro is for on sparc (although it also 587 * serves the function of making time available without a function call 588 * so you don't take a register window overflow while traps are disabled). 589 */ 590 void 591 pc_gethrestime(timestruc_t *tp) 592 { 593 int lock_prev; 594 timestruc_t now; 595 int nslt; /* nsec since last tick */ 596 int adj; /* amount of adjustment to apply */ 597 598 loop: 599 lock_prev = hres_lock; 600 now = hrestime; 601 nslt = (int)(gethrtime() - hres_last_tick); 602 if (nslt < 0) { 603 /* 604 * nslt < 0 means a tick came between sampling 605 * gethrtime() and hres_last_tick; restart the loop 606 */ 607 608 goto loop; 609 } 610 now.tv_nsec += nslt; 611 if (hrestime_adj != 0) { 612 if (hrestime_adj > 0) { 613 adj = (nslt >> ADJ_SHIFT); 614 if (adj > hrestime_adj) 615 adj = (int)hrestime_adj; 616 } else { 617 adj = -(nslt >> ADJ_SHIFT); 618 if (adj < hrestime_adj) 619 adj = (int)hrestime_adj; 620 } 621 now.tv_nsec += adj; 622 } 623 while ((unsigned long)now.tv_nsec >= NANOSEC) { 624 625 /* 626 * We might have a large adjustment or have been in the 627 * debugger for a long time; take care of (at most) four 628 * of those missed seconds (tv_nsec is 32 bits, so 629 * anything >4s will be wrapping around). However, 630 * anything more than 2 seconds out of sync will trigger 631 * timedelta from clock() to go correct the time anyway, 632 * so do what we can, and let the big crowbar do the 633 * rest. A similar correction while loop exists inside 634 * hres_tick(); in all cases we'd like tv_nsec to 635 * satisfy 0 <= tv_nsec < NANOSEC to avoid confusing 636 * user processes, but if tv_sec's a little behind for a 637 * little while, that's OK; time still monotonically 638 * increases. 639 */ 640 641 now.tv_nsec -= NANOSEC; 642 now.tv_sec++; 643 } 644 if ((hres_lock & ~1) != lock_prev) 645 goto loop; 646 647 *tp = now; 648 } 649 650 void 651 gethrestime_lasttick(timespec_t *tp) 652 { 653 int s; 654 655 s = hr_clock_lock(); 656 *tp = hrestime; 657 hr_clock_unlock(s); 658 } 659 660 time_t 661 gethrestime_sec(void) 662 { 663 timestruc_t now; 664 665 gethrestime(&now); 666 return (now.tv_sec); 667 } 668 669 /* 670 * Initialize a kernel thread's stack 671 */ 672 673 caddr_t 674 thread_stk_init(caddr_t stk) 675 { 676 ASSERT(((uintptr_t)stk & (STACK_ALIGN - 1)) == 0); 677 return (stk - SA(MINFRAME)); 678 } 679 680 /* 681 * Initialize lwp's kernel stack. 682 */ 683 684 #ifdef TRAPTRACE 685 /* 686 * There's a tricky interdependency here between use of sysenter and 687 * TRAPTRACE which needs recording to avoid future confusion (this is 688 * about the third time I've re-figured this out ..) 689 * 690 * Here's how debugging lcall works with TRAPTRACE. 691 * 692 * 1 We're in userland with a breakpoint on the lcall instruction. 693 * 2 We execute the instruction - the instruction pushes the userland 694 * %ss, %esp, %efl, %cs, %eip on the stack and zips into the kernel 695 * via the call gate. 696 * 3 The hardware raises a debug trap in kernel mode, the hardware 697 * pushes %efl, %cs, %eip and gets to dbgtrap via the idt. 698 * 4 dbgtrap pushes the error code and trapno and calls cmntrap 699 * 5 cmntrap finishes building a trap frame 700 * 6 The TRACE_REGS macros in cmntrap copy a REGSIZE worth chunk 701 * off the stack into the traptrace buffer. 702 * 703 * This means that the traptrace buffer contains the wrong values in 704 * %esp and %ss, but everything else in there is correct. 705 * 706 * Here's how debugging sysenter works with TRAPTRACE. 707 * 708 * a We're in userland with a breakpoint on the sysenter instruction. 709 * b We execute the instruction - the instruction pushes -nothing- 710 * on the stack, but sets %cs, %eip, %ss, %esp to prearranged 711 * values to take us to sys_sysenter, at the top of the lwp's 712 * stack. 713 * c goto 3 714 * 715 * At this point, because we got into the kernel without the requisite 716 * five pushes on the stack, if we didn't make extra room, we'd 717 * end up with the TRACE_REGS macro fetching the saved %ss and %esp 718 * values from negative (unmapped) stack addresses -- which really bites. 719 * That's why we do the '-= 8' below. 720 * 721 * XXX Note that reading "up" lwp0's stack works because t0 is declared 722 * right next to t0stack in locore.s 723 */ 724 #endif 725 726 caddr_t 727 lwp_stk_init(klwp_t *lwp, caddr_t stk) 728 { 729 caddr_t oldstk; 730 struct pcb *pcb = &lwp->lwp_pcb; 731 732 oldstk = stk; 733 stk -= SA(sizeof (struct regs) + SA(MINFRAME)); 734 #ifdef TRAPTRACE 735 stk -= 2 * sizeof (greg_t); /* space for phony %ss:%sp (see above) */ 736 #endif 737 stk = (caddr_t)((uintptr_t)stk & ~(STACK_ALIGN - 1ul)); 738 bzero(stk, oldstk - stk); 739 lwp->lwp_regs = (void *)(stk + SA(MINFRAME)); 740 741 /* 742 * Arrange that the virtualized %fs and %gs GDT descriptors 743 * have a well-defined initial state (present, ring 3 744 * and of type data). 745 */ 746 #if defined(__amd64) 747 if (lwp_getdatamodel(lwp) == DATAMODEL_NATIVE) 748 pcb->pcb_fsdesc = pcb->pcb_gsdesc = zero_udesc; 749 else 750 pcb->pcb_fsdesc = pcb->pcb_gsdesc = zero_u32desc; 751 #elif defined(__i386) 752 pcb->pcb_fsdesc = pcb->pcb_gsdesc = zero_udesc; 753 #endif /* __i386 */ 754 lwp_installctx(lwp); 755 return (stk); 756 } 757 758 /*ARGSUSED*/ 759 void 760 lwp_stk_fini(klwp_t *lwp) 761 {} 762 763 /* 764 * If we're not the panic CPU, we wait in panic_idle for reboot. If we're 765 * the boot CPU, then we are responsible for actually doing the reboot, so 766 * we watch for cpu_boot_cmd to be set. 767 */ 768 static void 769 panic_idle(void) 770 { 771 splx(ipltospl(CLOCK_LEVEL)); 772 (void) setjmp(&curthread->t_pcb); 773 774 if (CPU->cpu_id == getbootcpuid()) { 775 while (cpu_boot_cmd == BOOT_WAIT || cpu_boot_fcn == BOOT_WAIT) 776 drv_usecwait(10); 777 778 mdboot(cpu_boot_cmd, cpu_boot_fcn, NULL); 779 } 780 781 for (;;); 782 } 783 784 /* 785 * Stop the other CPUs by cross-calling them and forcing them to enter 786 * the panic_idle() loop above. 787 */ 788 /*ARGSUSED*/ 789 void 790 panic_stopcpus(cpu_t *cp, kthread_t *t, int spl) 791 { 792 processorid_t i; 793 cpuset_t xcset; 794 795 (void) splzs(); 796 797 CPUSET_ALL_BUT(xcset, cp->cpu_id); 798 xc_trycall(NULL, NULL, NULL, xcset, (int (*)())panic_idle); 799 800 for (i = 0; i < NCPU; i++) { 801 if (i != cp->cpu_id && cpu[i] != NULL && 802 (cpu[i]->cpu_flags & CPU_EXISTS)) 803 cpu[i]->cpu_flags |= CPU_QUIESCED; 804 } 805 } 806 807 /* 808 * Platform callback following each entry to panicsys(). 809 */ 810 /*ARGSUSED*/ 811 void 812 panic_enter_hw(int spl) 813 { 814 /* Nothing to do here */ 815 } 816 817 /* 818 * Platform-specific code to execute after panicstr is set: we invoke 819 * the PSM entry point to indicate that a panic has occurred. 820 */ 821 /*ARGSUSED*/ 822 void 823 panic_quiesce_hw(panic_data_t *pdp) 824 { 825 psm_notifyf(PSM_PANIC_ENTER); 826 827 #ifdef TRAPTRACE 828 /* 829 * Turn off TRAPTRACE 830 */ 831 TRAPTRACE_FREEZE; 832 #endif /* TRAPTRACE */ 833 } 834 835 /* 836 * Platform callback prior to writing crash dump. 837 */ 838 /*ARGSUSED*/ 839 void 840 panic_dump_hw(int spl) 841 { 842 /* Nothing to do here */ 843 } 844 845 /*ARGSUSED*/ 846 void 847 plat_tod_fault(enum tod_fault_type tod_bad) 848 { 849 } 850 851 /*ARGSUSED*/ 852 int 853 blacklist(int cmd, const char *scheme, nvlist_t *fmri, const char *class) 854 { 855 return (ENOTSUP); 856 } 857 858 /* 859 * The underlying console output routines are protected by raising IPL in case 860 * we are still calling into the early boot services. Once we start calling 861 * the kernel console emulator, it will disable interrupts completely during 862 * character rendering (see sysp_putchar, for example). Refer to the comments 863 * and code in common/os/console.c for more information on these callbacks. 864 */ 865 /*ARGSUSED*/ 866 int 867 console_enter(int busy) 868 { 869 return (splzs()); 870 } 871 872 /*ARGSUSED*/ 873 void 874 console_exit(int busy, int spl) 875 { 876 splx(spl); 877 } 878 879 /* 880 * Allocate a region of virtual address space, unmapped. 881 * Stubbed out except on sparc, at least for now. 882 */ 883 /*ARGSUSED*/ 884 void * 885 boot_virt_alloc(void *addr, size_t size) 886 { 887 return (addr); 888 } 889 890 volatile unsigned long tenmicrodata; 891 892 void 893 tenmicrosec(void) 894 { 895 extern int tsc_gethrtime_initted; 896 int i; 897 898 if (tsc_gethrtime_initted) { 899 hrtime_t start, end; 900 start = end = gethrtime(); 901 while ((end - start) < (10 * (NANOSEC / MICROSEC))) { 902 SMT_PAUSE(); 903 end = gethrtime(); 904 } 905 } else { 906 /* 907 * Artificial loop to induce delay. 908 */ 909 for (i = 0; i < microdata; i++) 910 tenmicrodata = microdata; 911 } 912 } 913