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/sysmacros.h> 30 #include <sys/prom_plat.h> 31 #include <sys/prom_debug.h> 32 #include <vm/hat_sfmmu.h> 33 #include <vm/seg_kp.h> 34 #include <vm/seg_kmem.h> 35 #include <sys/machsystm.h> 36 #include <sys/callb.h> 37 #include <sys/cpu_module.h> 38 #include <sys/chip.h> 39 #include <sys/dtrace.h> 40 #include <sys/reboot.h> 41 #include <sys/kdi.h> 42 43 #ifdef TRAPTRACE 44 #include <sys/traptrace.h> 45 #include <sys/bootconf.h> 46 #endif /* TRAPTRACE */ 47 48 #include <sys/cpu_sgnblk_defs.h> 49 50 extern void cpu_intrq_setup(struct cpu *); 51 extern void cpu_intrq_register(struct cpu *); 52 53 struct cpu *cpus; /* pointer to other cpus; dynamically allocate */ 54 struct cpu *cpu[NCPU]; /* pointers to all CPUs */ 55 uint64_t cpu_pa[NCPU]; /* pointers to all CPUs in PA */ 56 cpu_core_t cpu_core[NCPU]; /* cpu_core structures */ 57 58 #ifdef TRAPTRACE 59 caddr_t ttrace_buf; /* bop alloced traptrace for all cpus except 0 */ 60 #endif /* TRAPTRACE */ 61 62 /* bit mask of cpus ready for x-calls, protected by cpu_lock */ 63 cpuset_t cpu_ready_set; 64 65 /* bit mask used to communicate with cpus during bringup */ 66 static cpuset_t proxy_ready_set; 67 68 static void slave_startup(void); 69 70 /* 71 * Defined in $KARCH/os/mach_mp_startup.c 72 */ 73 #pragma weak init_cpu_info 74 75 /* 76 * Amount of time (in milliseconds) we should wait before giving up on CPU 77 * initialization and assuming that the CPU we're trying to wake up is dead 78 * or out of control. 79 */ 80 #define CPU_WAKEUP_GRACE_MSEC 1000 81 82 /* 83 * MP configurations may reserve additional interrupt request entries. 84 * intr_add_{div,max} can be modified to tune memory usage. 85 */ 86 87 uint_t intr_add_div = 1; /* 1=worst case memory usage */ 88 size_t intr_add_max = 0; 89 90 /* intr_add_{pools,head,tail} calculated based on intr_add_{div,max} */ 91 92 size_t intr_add_pools = 0; /* additional pools per cpu */ 93 struct intr_req *intr_add_head = (struct intr_req *)NULL; 94 #ifdef DEBUG 95 struct intr_req *intr_add_tail = (struct intr_req *)NULL; 96 #endif /* DEBUG */ 97 98 99 #ifdef TRAPTRACE 100 /* 101 * This function bop allocs traptrace buffers for all cpus 102 * other than boot cpu. 103 */ 104 caddr_t 105 trap_trace_alloc(caddr_t base) 106 { 107 caddr_t vaddr; 108 extern int max_ncpus; 109 110 if (max_ncpus == 1) { 111 return (base); 112 } 113 114 if ((vaddr = (caddr_t)BOP_ALLOC(bootops, base, (TRAP_TBUF_SIZE * 115 (max_ncpus - 1)), TRAP_TBUF_SIZE)) == NULL) { 116 panic("traptrace_alloc: can't bop alloc"); 117 } 118 ttrace_buf = vaddr; 119 PRM_DEBUG(ttrace_buf); 120 return (vaddr + (TRAP_TBUF_SIZE * (max_ncpus - 1))); 121 } 122 #endif /* TRAPTRACE */ 123 124 /* 125 * common slave cpu initialization code 126 */ 127 void 128 common_startup_init(cpu_t *cp, int cpuid) 129 { 130 kthread_id_t tp; 131 sfmmu_t *sfmmup; 132 caddr_t sp; 133 134 /* 135 * Allocate and initialize the startup thread for this CPU. 136 */ 137 tp = thread_create(NULL, 0, slave_startup, NULL, 0, &p0, 138 TS_STOPPED, maxclsyspri); 139 140 /* 141 * Set state to TS_ONPROC since this thread will start running 142 * as soon as the CPU comes online. 143 * 144 * All the other fields of the thread structure are setup by 145 * thread_create(). 146 */ 147 THREAD_ONPROC(tp, cp); 148 tp->t_preempt = 1; 149 tp->t_bound_cpu = cp; 150 tp->t_affinitycnt = 1; 151 tp->t_cpu = cp; 152 tp->t_disp_queue = cp->cpu_disp; 153 154 sfmmup = astosfmmu(&kas); 155 CPUSET_ADD(sfmmup->sfmmu_cpusran, cpuid); 156 157 /* 158 * Setup thread to start in slave_startup. 159 */ 160 sp = tp->t_stk; 161 tp->t_pc = (uintptr_t)slave_startup - 8; 162 tp->t_sp = (uintptr_t)((struct rwindow *)sp - 1) - STACK_BIAS; 163 164 cp->cpu_id = cpuid; 165 cp->cpu_self = cp; 166 cp->cpu_thread = tp; 167 cp->cpu_lwp = NULL; 168 cp->cpu_dispthread = tp; 169 cp->cpu_dispatch_pri = DISP_PRIO(tp); 170 cp->cpu_startup_thread = tp; 171 } 172 173 /* 174 * parametric flag setting functions. these routines set the cpu 175 * state just prior to releasing the slave cpu. 176 */ 177 void 178 cold_flag_set(int cpuid) 179 { 180 cpu_t *cp; 181 182 ASSERT(MUTEX_HELD(&cpu_lock)); 183 184 cp = cpu[cpuid]; 185 cp->cpu_flags |= CPU_RUNNING | CPU_ENABLE | CPU_EXISTS; 186 cpu_add_active(cp); 187 /* 188 * Add CPU_READY after the cpu_add_active() call 189 * to avoid pausing cp. 190 */ 191 cp->cpu_flags |= CPU_READY; /* ready */ 192 cpu_set_state(cp); 193 } 194 195 static void 196 warm_flag_set(int cpuid) 197 { 198 cpu_t *cp; 199 200 ASSERT(MUTEX_HELD(&cpu_lock)); 201 202 /* 203 * warm start activates cpus into the OFFLINE state 204 */ 205 cp = cpu[cpuid]; 206 cp->cpu_flags |= CPU_RUNNING | CPU_READY | CPU_EXISTS 207 | CPU_OFFLINE | CPU_QUIESCED; 208 cpu_set_state(cp); 209 } 210 211 /* 212 * Internal cpu startup sequencer 213 * The sequence is as follows: 214 * 215 * MASTER SLAVE 216 * ------- ---------- 217 * assume the kernel data is initialized 218 * clear the proxy bit 219 * start the slave cpu 220 * wait for the slave cpu to set the proxy 221 * 222 * the slave runs slave_startup and then sets the proxy 223 * the slave waits for the master to add slave to the ready set 224 * 225 * the master finishes the initialization and 226 * adds the slave to the ready set 227 * 228 * the slave exits the startup thread and is running 229 */ 230 void 231 start_cpu(int cpuid, void(*flag_func)(int)) 232 { 233 extern caddr_t cpu_startup; 234 int timout; 235 236 ASSERT(MUTEX_HELD(&cpu_lock)); 237 238 /* 239 * Before we begin the dance, tell DTrace that we're about to start 240 * a CPU. 241 */ 242 if (dtrace_cpustart_init != NULL) 243 (*dtrace_cpustart_init)(); 244 245 /* start the slave cpu */ 246 CPUSET_DEL(proxy_ready_set, cpuid); 247 if (prom_test("SUNW,start-cpu-by-cpuid") == 0) { 248 (void) prom_startcpu_bycpuid(cpuid, (caddr_t)&cpu_startup, 249 cpuid); 250 } else { 251 /* "by-cpuid" interface didn't exist. Do it the old way */ 252 pnode_t nodeid = cpunodes[cpuid].nodeid; 253 254 ASSERT(nodeid != (pnode_t)0); 255 (void) prom_startcpu(nodeid, (caddr_t)&cpu_startup, cpuid); 256 } 257 258 /* wait for the slave cpu to check in. */ 259 for (timout = CPU_WAKEUP_GRACE_MSEC; timout; timout--) { 260 if (CPU_IN_SET(proxy_ready_set, cpuid)) 261 break; 262 DELAY(1000); 263 } 264 if (timout == 0) { 265 panic("cpu%d failed to start (2)", cpuid); 266 } 267 268 /* 269 * The slave has started; we can tell DTrace that it's safe again. 270 */ 271 if (dtrace_cpustart_fini != NULL) 272 (*dtrace_cpustart_fini)(); 273 274 /* run the master side of stick synchronization for the slave cpu */ 275 sticksync_master(); 276 277 /* 278 * deal with the cpu flags in a phase-specific manner 279 * for various reasons, this needs to run after the slave 280 * is checked in but before the slave is released. 281 */ 282 (*flag_func)(cpuid); 283 284 /* release the slave */ 285 CPUSET_ADD(cpu_ready_set, cpuid); 286 } 287 288 #ifdef TRAPTRACE 289 int trap_tr0_inuse = 1; /* it is always used on the boot cpu */ 290 int trap_trace_inuse[NCPU]; 291 #endif /* TRAPTRACE */ 292 293 #define cpu_next_free cpu_prev 294 295 /* 296 * Routine to set up a CPU to prepare for starting it up. 297 */ 298 void 299 setup_cpu_common(int cpuid) 300 { 301 struct cpu *cp = NULL; 302 kthread_id_t tp; 303 #ifdef TRAPTRACE 304 int tt_index; 305 TRAP_TRACE_CTL *ctlp; 306 caddr_t newbuf; 307 #endif /* TRAPTRACE */ 308 309 extern void idle(); 310 extern void init_intr_threads(struct cpu *); 311 312 ASSERT(MUTEX_HELD(&cpu_lock)); 313 ASSERT(cpu[cpuid] == NULL); 314 315 ASSERT(ncpus <= max_ncpus); 316 317 #ifdef TRAPTRACE 318 /* 319 * allocate a traptrace buffer for this CPU. 320 */ 321 ctlp = &trap_trace_ctl[cpuid]; 322 if (!trap_tr0_inuse) { 323 trap_tr0_inuse = 1; 324 newbuf = trap_tr0; 325 tt_index = -1; 326 } else { 327 for (tt_index = 0; tt_index < (max_ncpus-1); tt_index++) 328 if (!trap_trace_inuse[tt_index]) 329 break; 330 ASSERT(tt_index < max_ncpus - 1); 331 trap_trace_inuse[tt_index] = 1; 332 newbuf = (caddr_t)(ttrace_buf + (tt_index * TRAP_TBUF_SIZE)); 333 } 334 ctlp->d.vaddr_base = newbuf; 335 ctlp->d.offset = ctlp->d.last_offset = 0; 336 ctlp->d.limit = trap_trace_bufsize; 337 ctlp->d.paddr_base = va_to_pa(newbuf); 338 ASSERT(ctlp->d.paddr_base != (uint64_t)-1); 339 /* 340 * initialize HV trap trace buffer for other cpus 341 */ 342 htrap_trace_setup((newbuf + TRAP_TSIZE), cpuid); 343 #endif /* TRAPTRACE */ 344 345 /* 346 * Obtain pointer to the appropriate cpu structure. 347 */ 348 if (cpu0.cpu_flags == 0) { 349 cp = &cpu0; 350 } else { 351 /* 352 * When dynamically allocating cpu structs, 353 * cpus is used as a pointer to a list of freed 354 * cpu structs. 355 */ 356 if (cpus) { 357 /* grab the first cpu struct on the free list */ 358 cp = cpus; 359 if (cp->cpu_next_free) 360 cpus = cp->cpu_next_free; 361 else 362 cpus = NULL; 363 } 364 } 365 366 if (cp == NULL) 367 cp = vmem_xalloc(static_alloc_arena, CPU_ALLOC_SIZE, 368 CPU_ALLOC_SIZE, 0, 0, NULL, NULL, VM_SLEEP); 369 370 bzero(cp, sizeof (*cp)); 371 372 cp->cpu_id = cpuid; 373 cp->cpu_self = cp; 374 375 /* 376 * Initialize ptl1_panic stack 377 */ 378 ptl1_init_cpu(cp); 379 380 /* 381 * Initialize the dispatcher for this CPU. 382 */ 383 disp_cpu_init(cp); 384 385 cpu_vm_data_init(cp); 386 387 /* 388 * Now, initialize per-CPU idle thread for this CPU. 389 */ 390 tp = thread_create(NULL, 0, idle, NULL, 0, &p0, TS_ONPROC, -1); 391 392 cp->cpu_idle_thread = tp; 393 394 tp->t_preempt = 1; 395 tp->t_bound_cpu = cp; 396 tp->t_affinitycnt = 1; 397 tp->t_cpu = cp; 398 tp->t_disp_queue = cp->cpu_disp; 399 400 /* 401 * Registering a thread in the callback table is usually 402 * done in the initialization code of the thread. In this 403 * case, we do it right after thread creation to avoid 404 * blocking idle thread while registering itself. It also 405 * avoids the possibility of reregistration in case a CPU 406 * restarts its idle thread. 407 */ 408 CALLB_CPR_INIT_SAFE(tp, "idle"); 409 410 init_cpu_info(cp); 411 412 /* 413 * Initialize the interrupt threads for this CPU 414 */ 415 init_intr_pool(cp); 416 init_intr_threads(cp); 417 418 /* 419 * Add CPU to list of available CPUs. 420 * It'll be on the active list after it is started. 421 */ 422 cpu_add_unit(cp); 423 424 /* 425 * Allocate and init cpu module private data structures, 426 * including scrubber. 427 */ 428 cpu_init_private(cp); 429 430 /* 431 * Associate this CPU with a physical processor 432 */ 433 chip_cpu_init(cp); 434 435 cpu_intrq_setup(cp); 436 } 437 438 /* 439 * Routine to clean up a CPU after shutting it down. 440 */ 441 int 442 cleanup_cpu_common(int cpuid) 443 { 444 struct cpu *cp; 445 #ifdef TRAPTRACE 446 int i; 447 TRAP_TRACE_CTL *ctlp; 448 caddr_t newbuf; 449 #endif /* TRAPTRACE */ 450 451 ASSERT(MUTEX_HELD(&cpu_lock)); 452 ASSERT(cpu[cpuid] != NULL); 453 454 cp = cpu[cpuid]; 455 456 /* Free cpu module private data structures, including scrubber. */ 457 cpu_uninit_private(cp); 458 459 cpu_vm_data_destroy(cp); 460 461 /* 462 * Remove CPU from list of available CPUs. 463 */ 464 cpu_del_unit(cpuid); 465 466 /* 467 * Clean up the interrupt pool. 468 */ 469 cleanup_intr_pool(cp); 470 471 /* 472 * At this point, the only threads bound to this CPU should be 473 * special per-cpu threads: it's idle thread, it's pause thread, 474 * and it's interrupt threads. Clean these up. 475 */ 476 cpu_destroy_bound_threads(cp); 477 478 /* 479 * Free the interrupt stack. 480 */ 481 segkp_release(segkp, cp->cpu_intr_stack); 482 483 #ifdef TRAPTRACE 484 /* 485 * Free the traptrace buffer for this CPU. 486 */ 487 ctlp = &trap_trace_ctl[cpuid]; 488 newbuf = ctlp->d.vaddr_base; 489 i = (newbuf - ttrace_buf) / (TRAP_TBUF_SIZE); 490 if (((newbuf - ttrace_buf) % (TRAP_TBUF_SIZE) == 0) && 491 ((i >= 0) && (i < (max_ncpus-1)))) { 492 /* 493 * This CPU got it's trap trace buffer from the 494 * boot-alloc'd bunch of them. 495 */ 496 trap_trace_inuse[i] = 0; 497 bzero(newbuf, (TRAP_TBUF_SIZE)); 498 } else if (newbuf == trap_tr0) { 499 trap_tr0_inuse = 0; 500 bzero(trap_tr0, (TRAP_TBUF_SIZE)); 501 } else { 502 cmn_err(CE_WARN, "failed to free trap trace buffer from cpu%d", 503 cpuid); 504 } 505 bzero(ctlp, sizeof (*ctlp)); 506 #endif /* TRAPTRACE */ 507 508 /* 509 * There is a race condition with mutex_vector_enter() which 510 * caches a cpu pointer. The race is detected by checking cpu_next. 511 */ 512 disp_cpu_fini(cp); 513 cpu_pa[cpuid] = 0; 514 bzero(cp, sizeof (*cp)); 515 516 /* 517 * Place the freed cpu structure on the list of freed cpus. 518 */ 519 if (cp != &cpu0) { 520 if (cpus) { 521 cp->cpu_next_free = cpus; 522 cpus = cp; 523 } 524 else 525 cpus = cp; 526 } 527 528 return (0); 529 } 530 531 /* 532 * This routine is used to start a previously powered off processor. 533 * Note that restarted cpus are initialized into the offline state. 534 */ 535 void 536 restart_other_cpu(int cpuid) 537 { 538 struct cpu *cp; 539 kthread_id_t tp; 540 caddr_t sp; 541 extern void idle(); 542 543 ASSERT(MUTEX_HELD(&cpu_lock)); 544 ASSERT(cpuid < NCPU && cpu[cpuid] != NULL); 545 546 /* 547 * Obtain pointer to the appropriate cpu structure. 548 */ 549 cp = cpu[cpuid]; 550 551 common_startup_init(cp, cpuid); 552 553 /* 554 * idle thread t_lock is held when the idle thread is suspended. 555 * Manually unlock the t_lock of idle loop so that we can resume 556 * the suspended idle thread. 557 * Also adjust the PC of idle thread for re-retry. 558 */ 559 cp->cpu_intr_actv = 0; /* clear the value from previous life */ 560 cp->cpu_m.mutex_ready = 0; /* we are not ready yet */ 561 lock_clear(&cp->cpu_idle_thread->t_lock); 562 tp = cp->cpu_idle_thread; 563 564 sp = tp->t_stk; 565 tp->t_sp = (uintptr_t)((struct rwindow *)sp - 1) - STACK_BIAS; 566 tp->t_pc = (uintptr_t)idle - 8; 567 568 /* 569 * restart the cpu now 570 */ 571 promsafe_pause_cpus(); 572 start_cpu(cpuid, warm_flag_set); 573 start_cpus(); 574 575 /* call cmn_err outside pause_cpus/start_cpus to avoid deadlock */ 576 cmn_err(CE_CONT, "!cpu%d initialization complete - restarted\n", 577 cpuid); 578 } 579 580 /* 581 * Startup function executed on 'other' CPUs. This is the first 582 * C function after cpu_start sets up the cpu registers. 583 */ 584 static void 585 slave_startup(void) 586 { 587 struct cpu *cp = CPU; 588 ushort_t original_flags = cp->cpu_flags; 589 590 #ifdef TRAPTRACE 591 htrap_trace_register(cp->cpu_id); 592 #endif 593 cpu_intrq_register(CPU); 594 cp->cpu_m.mutex_ready = 1; 595 cp->cpu_m.poke_cpu_outstanding = B_FALSE; 596 597 /* acknowledge that we are done with initialization */ 598 CPUSET_ADD(proxy_ready_set, cp->cpu_id); 599 600 /* synchronize STICK */ 601 sticksync_slave(); 602 603 if (boothowto & RB_DEBUG) 604 kdi_dvec_cpu_init(cp); 605 606 /* 607 * the slave will wait here forever -- assuming that the master 608 * will get back to us. if it doesn't we've got bigger problems 609 * than a master not replying to this slave. 610 * the small delay improves the slave's responsiveness to the 611 * master's ack and decreases the time window between master and 612 * slave operations. 613 */ 614 while (!CPU_IN_SET(cpu_ready_set, cp->cpu_id)) 615 DELAY(1); 616 617 /* enable interrupts */ 618 (void) spl0(); 619 620 /* 621 * Signature block update to indicate that this CPU is in OS now. 622 * This needs to be done after the PIL is lowered since on 623 * some platforms the update code may block. 624 */ 625 CPU_SIGNATURE(OS_SIG, SIGST_RUN, SIGSUBST_NULL, cp->cpu_id); 626 627 /* 628 * park the slave thread in a safe/quiet state and wait for the master 629 * to finish configuring this CPU before proceeding to thread_exit(). 630 */ 631 while (((volatile ushort_t)cp->cpu_flags) & CPU_QUIESCED) 632 DELAY(1); 633 634 /* 635 * Initialize CPC CPU state. 636 */ 637 kcpc_hw_startup_cpu(original_flags); 638 639 /* 640 * Notify the CMT subsystem that the slave has started 641 */ 642 chip_cpu_startup(CPU); 643 644 /* 645 * Now we are done with the startup thread, so free it up. 646 */ 647 thread_exit(); 648 cmn_err(CE_PANIC, "slave_startup: cannot return"); 649 /*NOTREACHED*/ 650 } 651 652 /* 653 * 4163850 changes the allocation method for cpu structs. cpu structs 654 * are dynamically allocated. This routine now determines if additional 655 * per-cpu intr_req entries need to be allocated. 656 */ 657 int 658 ndata_alloc_cpus(struct memlist *ndata) 659 { 660 size_t real_sz; 661 extern int niobus; 662 663 if (niobus > 1) { 664 665 /* 666 * Allocate additional intr_req entries if we have more than 667 * one io bus. The memory to allocate is calculated from four 668 * variables: niobus, max_ncpus, intr_add_div, and intr_add_max. 669 * Allocate multiple of INTR_POOL_SIZE bytes (512). Each cpu 670 * already reserves 512 bytes in its machcpu structure, so the 671 * worst case is (512 * (niobus - 1) * max_ncpus) add'l bytes. 672 * 673 * While niobus and max_ncpus reflect the h/w, the following 674 * may be tuned (before boot): 675 * 676 * intr_add_div - divisor for scaling the number of 677 * additional intr_req entries. use '1' 678 * for worst case memory, '2' for half, 679 * etc. 680 * 681 * intr_add_max - upper limit on bytes of memory to reserve 682 */ 683 684 real_sz = INTR_POOL_SIZE * (niobus - 1) * max_ncpus; 685 686 /* tune memory usage by applying divisor and maximum */ 687 688 if (intr_add_max == 0) 689 intr_add_max = max_ncpus * INTR_POOL_SIZE; 690 real_sz = MIN(intr_add_max, real_sz / MAX(intr_add_div, 1)); 691 692 /* round down to multiple of (max_ncpus * INTR_POOL_SIZE) */ 693 694 intr_add_pools = real_sz / (max_ncpus * INTR_POOL_SIZE); 695 real_sz = intr_add_pools * (max_ncpus * INTR_POOL_SIZE); 696 697 /* actually reserve the space */ 698 699 intr_add_head = ndata_alloc(ndata, real_sz, ecache_alignsize); 700 if (intr_add_head == NULL) 701 return (-1); 702 703 PRM_DEBUG(intr_add_head); 704 #ifdef DEBUG 705 intr_add_tail = (struct intr_req *) 706 ((uintptr_t)intr_add_head + real_sz); 707 #endif /* DEBUG */ 708 } 709 710 return (0); 711 } 712 713 714 extern struct cpu *cpu[NCPU]; /* pointers to all CPUs */ 715 716 extern void setup_cpu_common(int); 717 extern void common_startup_init(cpu_t *, int); 718 extern void start_cpu(int, void(*func)(int)); 719 extern void cold_flag_set(int cpuid); 720 721 /* 722 * cpu_bringup_set is a tunable (via /etc/system, debugger, etc.) that 723 * can be used during debugging to control which processors are brought 724 * online at boot time. The variable represents a bitmap of the id's 725 * of the processors that will be brought online. The initialization 726 * of this variable depends on the type of cpuset_t, which varies 727 * depending on the number of processors supported (see cpuvar.h). 728 */ 729 cpuset_t cpu_bringup_set; 730 731 732 /* 733 * Generic start-all cpus entry. Typically used during cold initialization. 734 * Note that cold start cpus are initialized into the online state. 735 */ 736 /*ARGSUSED*/ 737 void 738 start_other_cpus(int flag) 739 { 740 int cpuid; 741 extern void idlestop_init(void); 742 int bootcpu; 743 744 /* 745 * Check if cpu_bringup_set has been explicitly set before 746 * initializing it. 747 */ 748 if (CPUSET_ISNULL(cpu_bringup_set)) { 749 #ifdef MPSAS 750 /* just CPU 0 */ 751 CPUSET_ADD(cpu_bringup_set, 0); 752 #else 753 CPUSET_ALL(cpu_bringup_set); 754 #endif 755 } 756 757 if (&cpu_feature_init) 758 cpu_feature_init(); 759 760 /* 761 * Initialize CPC. 762 */ 763 kcpc_hw_init(); 764 765 mutex_enter(&cpu_lock); 766 767 /* 768 * Initialize our own cpu_info. 769 */ 770 init_cpu_info(CPU); 771 772 /* 773 * Initialize CPU 0 cpu module private data area, including scrubber. 774 */ 775 cpu_init_private(CPU); 776 777 /* 778 * perform such initialization as is needed 779 * to be able to take CPUs on- and off-line. 780 */ 781 cpu_pause_init(); 782 xc_init(); /* initialize processor crosscalls */ 783 idlestop_init(); 784 785 if (!use_mp) { 786 mutex_exit(&cpu_lock); 787 cmn_err(CE_CONT, "?***** Not in MP mode\n"); 788 return; 789 } 790 /* 791 * should we be initializing this cpu? 792 */ 793 bootcpu = getprocessorid(); 794 795 /* 796 * launch all the slave cpus now 797 */ 798 for (cpuid = 0; cpuid < NCPU; cpuid++) { 799 pnode_t nodeid = cpunodes[cpuid].nodeid; 800 801 if (nodeid == (pnode_t)0) 802 continue; 803 804 if (cpuid == bootcpu) { 805 if (!CPU_IN_SET(cpu_bringup_set, cpuid)) { 806 cmn_err(CE_WARN, "boot cpu not a member " 807 "of cpu_bringup_set, adding it"); 808 CPUSET_ADD(cpu_bringup_set, cpuid); 809 } 810 continue; 811 } 812 if (!CPU_IN_SET(cpu_bringup_set, cpuid)) 813 continue; 814 815 ASSERT(cpu[cpuid] == NULL); 816 817 setup_cpu_common(cpuid); 818 819 common_startup_init(cpu[cpuid], cpuid); 820 821 start_cpu(cpuid, cold_flag_set); 822 /* 823 * Because slave_startup() gets fired off after init() 824 * starts, we can't use the '?' trick to do 'boot -v' 825 * printing - so we always direct the 'cpu .. online' 826 * messages to the log. 827 */ 828 cmn_err(CE_CONT, "!cpu%d initialization complete - online\n", 829 cpuid); 830 831 /* 832 * XXX: register_cpu_setup() callbacks should be called here 833 * with a new setup code, CPU_BOOT (or something). 834 */ 835 if (dtrace_cpu_init != NULL) 836 (*dtrace_cpu_init)(cpuid); 837 } 838 839 /* 840 * since all the cpus are online now, redistribute interrupts to them. 841 */ 842 intr_redist_all_cpus(); 843 844 mutex_exit(&cpu_lock); 845 846 /* 847 * Start the Ecache scrubber. Must be done after all calls to 848 * cpu_init_private for every cpu (including CPU 0). 849 */ 850 cpu_init_cache_scrub(); 851 852 if (&cpu_mp_init) 853 cpu_mp_init(); 854 } 855