10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51592Sgirish * Common Development and Distribution License (the "License"). 61592Sgirish * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 225864Sesaxe * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #include <sys/machsystm.h> 270Sstevel@tonic-gate #include <sys/archsystm.h> 280Sstevel@tonic-gate #include <sys/vm.h> 290Sstevel@tonic-gate #include <sys/cpu.h> 301772Sjl139090 #include <sys/cpupart.h> 31*8408SEric.Saxe@Sun.COM #include <sys/cmt.h> 32*8408SEric.Saxe@Sun.COM #include <sys/bitset.h> 330Sstevel@tonic-gate #include <sys/reboot.h> 340Sstevel@tonic-gate #include <sys/kdi.h> 350Sstevel@tonic-gate #include <sys/bootconf.h> 360Sstevel@tonic-gate #include <sys/memlist_plat.h> 370Sstevel@tonic-gate #include <sys/memlist_impl.h> 380Sstevel@tonic-gate #include <sys/prom_plat.h> 390Sstevel@tonic-gate #include <sys/prom_isa.h> 400Sstevel@tonic-gate #include <sys/autoconf.h> 410Sstevel@tonic-gate #include <sys/intreg.h> 420Sstevel@tonic-gate #include <sys/ivintr.h> 430Sstevel@tonic-gate #include <sys/fpu/fpusystm.h> 440Sstevel@tonic-gate #include <sys/iommutsb.h> 450Sstevel@tonic-gate #include <vm/vm_dep.h> 460Sstevel@tonic-gate #include <vm/seg_kmem.h> 470Sstevel@tonic-gate #include <vm/seg_kpm.h> 480Sstevel@tonic-gate #include <vm/seg_map.h> 490Sstevel@tonic-gate #include <vm/seg_kp.h> 500Sstevel@tonic-gate #include <sys/sysconf.h> 510Sstevel@tonic-gate #include <vm/hat_sfmmu.h> 520Sstevel@tonic-gate #include <sys/kobj.h> 530Sstevel@tonic-gate #include <sys/sun4asi.h> 540Sstevel@tonic-gate #include <sys/clconf.h> 550Sstevel@tonic-gate #include <sys/platform_module.h> 560Sstevel@tonic-gate #include <sys/panic.h> 570Sstevel@tonic-gate #include <sys/cpu_sgnblk_defs.h> 580Sstevel@tonic-gate #include <sys/clock.h> 590Sstevel@tonic-gate #include <sys/fpras_impl.h> 600Sstevel@tonic-gate #include <sys/prom_debug.h> 610Sstevel@tonic-gate #include <sys/traptrace.h> 620Sstevel@tonic-gate #include <sys/memnode.h> 630Sstevel@tonic-gate #include <sys/mem_cage.h> 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* 660Sstevel@tonic-gate * fpRAS implementation structures. 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate struct fpras_chkfn *fpras_chkfnaddrs[FPRAS_NCOPYOPS]; 690Sstevel@tonic-gate struct fpras_chkfngrp *fpras_chkfngrps; 700Sstevel@tonic-gate struct fpras_chkfngrp *fpras_chkfngrps_base; 710Sstevel@tonic-gate int fpras_frequency = -1; 720Sstevel@tonic-gate int64_t fpras_interval = -1; 730Sstevel@tonic-gate 741772Sjl139090 /* 751772Sjl139090 * Halt idling cpus optimization 761772Sjl139090 * 771772Sjl139090 * This optimation is only enabled in platforms that have 781772Sjl139090 * the CPU halt support. The cpu_halt_cpu() support is provided 791772Sjl139090 * in the cpu module and it is referenced here with a pragma weak. 801772Sjl139090 * The presence of this routine automatically enable the halt idling 811772Sjl139090 * cpus functionality if the global switch enable_halt_idle_cpus 821772Sjl139090 * is set (default is set). 831772Sjl139090 * 841772Sjl139090 */ 851772Sjl139090 #pragma weak cpu_halt_cpu 861772Sjl139090 extern void cpu_halt_cpu(); 871772Sjl139090 885864Sesaxe /* 895864Sesaxe * Defines for the idle_state_transition DTrace probe 905864Sesaxe * 915864Sesaxe * The probe fires when the CPU undergoes an idle state change (e.g. halting) 925864Sesaxe * The agument passed is the state to which the CPU is transitioning. 935864Sesaxe * 945864Sesaxe * The states are defined here. 955864Sesaxe */ 965864Sesaxe #define IDLE_STATE_NORMAL 0 975864Sesaxe #define IDLE_STATE_HALTED 1 985864Sesaxe 991772Sjl139090 int enable_halt_idle_cpus = 1; /* global switch */ 1001772Sjl139090 1010Sstevel@tonic-gate void 1020Sstevel@tonic-gate setup_trap_table(void) 1030Sstevel@tonic-gate { 1040Sstevel@tonic-gate intr_init(CPU); /* init interrupt request free list */ 1050Sstevel@tonic-gate setwstate(WSTATE_KERN); 1060Sstevel@tonic-gate prom_set_traptable(&trap_table); 1070Sstevel@tonic-gate } 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate void 1100Sstevel@tonic-gate mach_fpras() 1110Sstevel@tonic-gate { 1120Sstevel@tonic-gate if (fpras_implemented && !fpras_disable) { 1130Sstevel@tonic-gate int i; 1140Sstevel@tonic-gate struct fpras_chkfngrp *fcgp; 1150Sstevel@tonic-gate size_t chkfngrpsallocsz; 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate /* 1180Sstevel@tonic-gate * Note that we size off of NCPU and setup for 1190Sstevel@tonic-gate * all those possibilities regardless of whether 1200Sstevel@tonic-gate * the cpu id is present or not. We do this so that 1210Sstevel@tonic-gate * we don't have any construction or destruction 1220Sstevel@tonic-gate * activity to perform at DR time, and it's not 1230Sstevel@tonic-gate * costly in memory. We require block alignment. 1240Sstevel@tonic-gate */ 1250Sstevel@tonic-gate chkfngrpsallocsz = NCPU * sizeof (struct fpras_chkfngrp); 1260Sstevel@tonic-gate fpras_chkfngrps_base = kmem_alloc(chkfngrpsallocsz, KM_SLEEP); 1270Sstevel@tonic-gate if (IS_P2ALIGNED((uintptr_t)fpras_chkfngrps_base, 64)) { 1280Sstevel@tonic-gate fpras_chkfngrps = fpras_chkfngrps_base; 1290Sstevel@tonic-gate } else { 1300Sstevel@tonic-gate kmem_free(fpras_chkfngrps_base, chkfngrpsallocsz); 1310Sstevel@tonic-gate chkfngrpsallocsz += 64; 1320Sstevel@tonic-gate fpras_chkfngrps_base = kmem_alloc(chkfngrpsallocsz, 1330Sstevel@tonic-gate KM_SLEEP); 1340Sstevel@tonic-gate fpras_chkfngrps = (struct fpras_chkfngrp *) 1350Sstevel@tonic-gate P2ROUNDUP((uintptr_t)fpras_chkfngrps_base, 64); 1360Sstevel@tonic-gate } 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate /* 1390Sstevel@tonic-gate * Copy our check function into place for each copy operation 1400Sstevel@tonic-gate * and each cpu id. 1410Sstevel@tonic-gate */ 1420Sstevel@tonic-gate fcgp = &fpras_chkfngrps[0]; 1430Sstevel@tonic-gate for (i = 0; i < FPRAS_NCOPYOPS; ++i) 1440Sstevel@tonic-gate bcopy((void *)fpras_chkfn_type1, &fcgp->fpras_fn[i], 1450Sstevel@tonic-gate sizeof (struct fpras_chkfn)); 1460Sstevel@tonic-gate for (i = 1; i < NCPU; ++i) 1470Sstevel@tonic-gate *(&fpras_chkfngrps[i]) = *fcgp; 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate /* 1500Sstevel@tonic-gate * At definition fpras_frequency is set to -1, and it will 1510Sstevel@tonic-gate * still have that value unless changed in /etc/system (not 1520Sstevel@tonic-gate * strictly supported, but not preventable). The following 1530Sstevel@tonic-gate * both sets the default and sanity checks anything from 1540Sstevel@tonic-gate * /etc/system. 1550Sstevel@tonic-gate */ 1560Sstevel@tonic-gate if (fpras_frequency < 0) 1570Sstevel@tonic-gate fpras_frequency = FPRAS_DEFAULT_FREQUENCY; 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate /* 1600Sstevel@tonic-gate * Now calculate fpras_interval. When fpras_interval 1610Sstevel@tonic-gate * becomes non-negative fpras checks will commence 1620Sstevel@tonic-gate * (copies before this point in boot will bypass fpras). 1630Sstevel@tonic-gate * Our stores of instructions must be visible; no need 1640Sstevel@tonic-gate * to flush as they're never been executed before. 1650Sstevel@tonic-gate */ 1660Sstevel@tonic-gate membar_producer(); 1670Sstevel@tonic-gate fpras_interval = (fpras_frequency == 0) ? 1680Sstevel@tonic-gate 0 : sys_tick_freq / fpras_frequency; 1690Sstevel@tonic-gate } 1700Sstevel@tonic-gate } 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate void 1730Sstevel@tonic-gate mach_hw_copy_limit(void) 1740Sstevel@tonic-gate { 1750Sstevel@tonic-gate if (!fpu_exists) { 1760Sstevel@tonic-gate use_hw_bcopy = 0; 1770Sstevel@tonic-gate hw_copy_limit_1 = 0; 1780Sstevel@tonic-gate hw_copy_limit_2 = 0; 1790Sstevel@tonic-gate hw_copy_limit_4 = 0; 1800Sstevel@tonic-gate hw_copy_limit_8 = 0; 1810Sstevel@tonic-gate use_hw_bzero = 0; 1820Sstevel@tonic-gate } 1830Sstevel@tonic-gate } 1840Sstevel@tonic-gate 1850Sstevel@tonic-gate void 1860Sstevel@tonic-gate load_tod_module() 1870Sstevel@tonic-gate { 1880Sstevel@tonic-gate /* 1890Sstevel@tonic-gate * Load tod driver module for the tod part found on this system. 1900Sstevel@tonic-gate * Recompute the cpu frequency/delays based on tod as tod part 1910Sstevel@tonic-gate * tends to keep time more accurately. 1920Sstevel@tonic-gate */ 1930Sstevel@tonic-gate if (tod_module_name == NULL || modload("tod", tod_module_name) == -1) 1940Sstevel@tonic-gate halt("Can't load tod module"); 1950Sstevel@tonic-gate } 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate void 1980Sstevel@tonic-gate mach_memscrub(void) 1990Sstevel@tonic-gate { 2000Sstevel@tonic-gate /* 2010Sstevel@tonic-gate * Startup memory scrubber, if not running fpu emulation code. 2020Sstevel@tonic-gate */ 2030Sstevel@tonic-gate 2041772Sjl139090 #ifndef _HW_MEMSCRUB_SUPPORT 2050Sstevel@tonic-gate if (fpu_exists) { 2060Sstevel@tonic-gate if (memscrub_init()) { 2070Sstevel@tonic-gate cmn_err(CE_WARN, 2080Sstevel@tonic-gate "Memory scrubber failed to initialize"); 2090Sstevel@tonic-gate } 2100Sstevel@tonic-gate } 2111772Sjl139090 #endif /* _HW_MEMSCRUB_SUPPORT */ 2121772Sjl139090 } 2131772Sjl139090 2141772Sjl139090 /* 2151772Sjl139090 * Halt the calling CPU until awoken via an interrupt 2161772Sjl139090 * This routine should only be invoked if cpu_halt_cpu() 2171772Sjl139090 * exists and is supported, see mach_cpu_halt_idle() 2181772Sjl139090 */ 2191772Sjl139090 static void 2201772Sjl139090 cpu_halt(void) 2211772Sjl139090 { 2221772Sjl139090 cpu_t *cpup = CPU; 223*8408SEric.Saxe@Sun.COM processorid_t cpu_sid = cpup->cpu_seqid; 2241772Sjl139090 cpupart_t *cp = cpup->cpu_part; 2251772Sjl139090 int hset_update = 1; 2261772Sjl139090 uint_t pstate; 2271772Sjl139090 extern uint_t getpstate(void); 2281772Sjl139090 extern void setpstate(uint_t); 2291772Sjl139090 2301772Sjl139090 /* 2311772Sjl139090 * If this CPU is online, and there's multiple CPUs 2321772Sjl139090 * in the system, then we should notate our halting 2331772Sjl139090 * by adding ourselves to the partition's halted CPU 234*8408SEric.Saxe@Sun.COM * bitset. This allows other CPUs to find/awaken us when 2351772Sjl139090 * work becomes available. 2361772Sjl139090 */ 2371772Sjl139090 if (CPU->cpu_flags & CPU_OFFLINE || ncpus == 1) 2381772Sjl139090 hset_update = 0; 2391772Sjl139090 2401772Sjl139090 /* 241*8408SEric.Saxe@Sun.COM * Add ourselves to the partition's halted CPU bitset 2421772Sjl139090 * and set our HALTED flag, if necessary. 2431772Sjl139090 * 2441772Sjl139090 * When a thread becomes runnable, it is placed on the queue 245*8408SEric.Saxe@Sun.COM * and then the halted cpu bitset is checked to determine who 2461772Sjl139090 * (if anyone) should be awoken. We therefore need to first 247*8408SEric.Saxe@Sun.COM * add ourselves to the halted cpu bitset, and then check if there 248*8408SEric.Saxe@Sun.COM * is any work available. The order is important to prevent a race 249*8408SEric.Saxe@Sun.COM * that can lead to work languishing on a run queue somewhere while 250*8408SEric.Saxe@Sun.COM * this CPU remains halted. 251*8408SEric.Saxe@Sun.COM * 252*8408SEric.Saxe@Sun.COM * Either the producing CPU will see we're halted and will awaken us, 253*8408SEric.Saxe@Sun.COM * or this CPU will see the work available in disp_anywork() 2541772Sjl139090 */ 2551772Sjl139090 if (hset_update) { 2561772Sjl139090 cpup->cpu_disp_flags |= CPU_DISP_HALTED; 2571772Sjl139090 membar_producer(); 258*8408SEric.Saxe@Sun.COM bitset_atomic_add(&cp->cp_haltset, cpu_sid); 2591772Sjl139090 } 2601772Sjl139090 2611772Sjl139090 /* 2621772Sjl139090 * Check to make sure there's really nothing to do. 2631772Sjl139090 * Work destined for this CPU may become available after 2641772Sjl139090 * this check. We'll be notified through the clearing of our 265*8408SEric.Saxe@Sun.COM * bit in the halted CPU bitset, and a poke. 2661772Sjl139090 */ 2671772Sjl139090 if (disp_anywork()) { 2681772Sjl139090 if (hset_update) { 2691772Sjl139090 cpup->cpu_disp_flags &= ~CPU_DISP_HALTED; 270*8408SEric.Saxe@Sun.COM bitset_atomic_del(&cp->cp_haltset, cpu_sid); 2711772Sjl139090 } 2721772Sjl139090 return; 2731772Sjl139090 } 2741772Sjl139090 2751772Sjl139090 /* 2761772Sjl139090 * We're on our way to being halted. 2771772Sjl139090 * 2781772Sjl139090 * Disable interrupts now, so that we'll awaken immediately 2791772Sjl139090 * after halting if someone tries to poke us between now and 2801772Sjl139090 * the time we actually halt. 2811772Sjl139090 * 2821772Sjl139090 * We check for the presence of our bit after disabling interrupts. 2831772Sjl139090 * If it's cleared, we'll return. If the bit is cleared after 2841772Sjl139090 * we check then the poke will pop us out of the halted state. 2851772Sjl139090 * 2861772Sjl139090 * The ordering of the poke and the clearing of the bit by cpu_wakeup 2871772Sjl139090 * is important. 2881772Sjl139090 * cpu_wakeup() must clear, then poke. 2891772Sjl139090 * cpu_halt() must disable interrupts, then check for the bit. 2901772Sjl139090 */ 2911772Sjl139090 pstate = getpstate(); 2921772Sjl139090 setpstate(pstate & ~PSTATE_IE); 2931772Sjl139090 294*8408SEric.Saxe@Sun.COM if (hset_update && bitset_in_set(&cp->cp_haltset, cpu_sid) == 0) { 2951772Sjl139090 cpup->cpu_disp_flags &= ~CPU_DISP_HALTED; 2961772Sjl139090 setpstate(pstate); 2971772Sjl139090 return; 2981772Sjl139090 } 2991772Sjl139090 3001772Sjl139090 /* 3011772Sjl139090 * The check for anything locally runnable is here for performance 3021772Sjl139090 * and isn't needed for correctness. disp_nrunnable ought to be 3031772Sjl139090 * in our cache still, so it's inexpensive to check, and if there 3041772Sjl139090 * is anything runnable we won't have to wait for the poke. 3051772Sjl139090 */ 3061772Sjl139090 if (cpup->cpu_disp->disp_nrunnable != 0) { 3071772Sjl139090 if (hset_update) { 3081772Sjl139090 cpup->cpu_disp_flags &= ~CPU_DISP_HALTED; 309*8408SEric.Saxe@Sun.COM bitset_atomic_del(&cp->cp_haltset, cpu_sid); 3101772Sjl139090 } 3111772Sjl139090 setpstate(pstate); 3121772Sjl139090 return; 3131772Sjl139090 } 3141772Sjl139090 3151772Sjl139090 /* 3161772Sjl139090 * Halt the strand. 3171772Sjl139090 */ 3185864Sesaxe if (&cpu_halt_cpu) { 3195864Sesaxe DTRACE_PROBE1(idle__state__transition, 3205864Sesaxe uint_t, IDLE_STATE_HALTED); 3215864Sesaxe 3221772Sjl139090 cpu_halt_cpu(); 3231772Sjl139090 3245864Sesaxe DTRACE_PROBE1(idle__state__transition, 3255864Sesaxe uint_t, IDLE_STATE_NORMAL); 3265864Sesaxe } 3275864Sesaxe 3281772Sjl139090 /* 3291772Sjl139090 * We're no longer halted 3301772Sjl139090 */ 3311772Sjl139090 setpstate(pstate); 3321772Sjl139090 if (hset_update) { 3331772Sjl139090 cpup->cpu_disp_flags &= ~CPU_DISP_HALTED; 334*8408SEric.Saxe@Sun.COM bitset_atomic_del(&cp->cp_haltset, cpu_sid); 3351772Sjl139090 } 3361772Sjl139090 } 3371772Sjl139090 3381772Sjl139090 /* 3391772Sjl139090 * If "cpu" is halted, then wake it up clearing its halted bit in advance. 3401772Sjl139090 * Otherwise, see if other CPUs in the cpu partition are halted and need to 3411772Sjl139090 * be woken up so that they can steal the thread we placed on this CPU. 3421772Sjl139090 * This function is only used on MP systems. 3431772Sjl139090 * This function should only be invoked if cpu_halt_cpu() 3441772Sjl139090 * exists and is supported, see mach_cpu_halt_idle() 3451772Sjl139090 */ 3461772Sjl139090 static void 3471772Sjl139090 cpu_wakeup(cpu_t *cpu, int bound) 3481772Sjl139090 { 3491772Sjl139090 uint_t cpu_found; 350*8408SEric.Saxe@Sun.COM processorid_t cpu_sid; 3511772Sjl139090 cpupart_t *cp; 3521772Sjl139090 3531772Sjl139090 cp = cpu->cpu_part; 354*8408SEric.Saxe@Sun.COM cpu_sid = cpu->cpu_seqid; 355*8408SEric.Saxe@Sun.COM if (bitset_in_set(&cp->cp_haltset, cpu_sid)) { 3561772Sjl139090 /* 3571772Sjl139090 * Clear the halted bit for that CPU since it will be 3581772Sjl139090 * poked in a moment. 3591772Sjl139090 */ 360*8408SEric.Saxe@Sun.COM bitset_atomic_del(&cp->cp_haltset, cpu_sid); 3611772Sjl139090 /* 362*8408SEric.Saxe@Sun.COM * We may find the current CPU present in the halted cpu bitset 3631772Sjl139090 * if we're in the context of an interrupt that occurred 3641772Sjl139090 * before we had a chance to clear our bit in cpu_halt(). 3651772Sjl139090 * Poking ourself is obviously unnecessary, since if 3661772Sjl139090 * we're here, we're not halted. 3671772Sjl139090 */ 3681772Sjl139090 if (cpu != CPU) 3691772Sjl139090 poke_cpu(cpu->cpu_id); 3701772Sjl139090 return; 3711772Sjl139090 } else { 3721772Sjl139090 /* 3731772Sjl139090 * This cpu isn't halted, but it's idle or undergoing a 3741772Sjl139090 * context switch. No need to awaken anyone else. 3751772Sjl139090 */ 3761772Sjl139090 if (cpu->cpu_thread == cpu->cpu_idle_thread || 3771772Sjl139090 cpu->cpu_disp_flags & CPU_DISP_DONTSTEAL) 3781772Sjl139090 return; 3791772Sjl139090 } 3801772Sjl139090 3811772Sjl139090 /* 382*8408SEric.Saxe@Sun.COM * No need to wake up other CPUs if this is for a bound thread. 3831772Sjl139090 */ 3841772Sjl139090 if (bound) 3851772Sjl139090 return; 3861772Sjl139090 3871772Sjl139090 /* 388*8408SEric.Saxe@Sun.COM * The CPU specified for wakeup isn't currently halted, so check 389*8408SEric.Saxe@Sun.COM * to see if there are any other halted CPUs in the partition, 390*8408SEric.Saxe@Sun.COM * and if there are then awaken one. 391*8408SEric.Saxe@Sun.COM * 392*8408SEric.Saxe@Sun.COM * If possible, try to select a CPU close to the target, since this 393*8408SEric.Saxe@Sun.COM * will likely trigger a migration. 3941772Sjl139090 */ 3951772Sjl139090 do { 396*8408SEric.Saxe@Sun.COM cpu_found = bitset_find(&cp->cp_haltset); 397*8408SEric.Saxe@Sun.COM if (cpu_found == (uint_t)-1) 3981772Sjl139090 return; 399*8408SEric.Saxe@Sun.COM } while (bitset_atomic_test_and_del(&cp->cp_haltset, cpu_found) < 0); 4001772Sjl139090 401*8408SEric.Saxe@Sun.COM if (cpu_found != CPU->cpu_seqid) 402*8408SEric.Saxe@Sun.COM poke_cpu(cpu_seq[cpu_found]->cpu_id); 4030Sstevel@tonic-gate } 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate void 4060Sstevel@tonic-gate mach_cpu_halt_idle() 4070Sstevel@tonic-gate { 4081772Sjl139090 if (enable_halt_idle_cpus) { 4091772Sjl139090 if (&cpu_halt_cpu) { 4101772Sjl139090 idle_cpu = cpu_halt; 4111772Sjl139090 disp_enq_thread = cpu_wakeup; 4121772Sjl139090 } 4131772Sjl139090 } 4140Sstevel@tonic-gate } 4150Sstevel@tonic-gate 4160Sstevel@tonic-gate /*ARGSUSED*/ 4174050Sjb145095 int 4180Sstevel@tonic-gate cpu_intrq_setup(struct cpu *cp) 4190Sstevel@tonic-gate { 4200Sstevel@tonic-gate /* Interrupt mondo queues not applicable to sun4u */ 4214050Sjb145095 return (0); 4220Sstevel@tonic-gate } 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate /*ARGSUSED*/ 4250Sstevel@tonic-gate void 4261991Sheppo cpu_intrq_cleanup(struct cpu *cp) 4271991Sheppo { 4281991Sheppo /* Interrupt mondo queues not applicable to sun4u */ 4291991Sheppo } 4301991Sheppo 4311991Sheppo /*ARGSUSED*/ 4321991Sheppo void 4330Sstevel@tonic-gate cpu_intrq_register(struct cpu *cp) 4340Sstevel@tonic-gate { 4350Sstevel@tonic-gate /* Interrupt/error queues not applicable to sun4u */ 4360Sstevel@tonic-gate } 4370Sstevel@tonic-gate 4380Sstevel@tonic-gate /*ARGSUSED*/ 4390Sstevel@tonic-gate void 4401077Ssvemuri mach_htraptrace_setup(int cpuid) 4410Sstevel@tonic-gate { 4420Sstevel@tonic-gate /* Setup hypervisor traptrace buffer, not applicable to sun4u */ 4430Sstevel@tonic-gate } 4440Sstevel@tonic-gate 4450Sstevel@tonic-gate /*ARGSUSED*/ 4460Sstevel@tonic-gate void 4471077Ssvemuri mach_htraptrace_configure(int cpuid) 4481077Ssvemuri { 4491077Ssvemuri /* enable/ disable hypervisor traptracing, not applicable to sun4u */ 4501077Ssvemuri } 4511077Ssvemuri 4521077Ssvemuri /*ARGSUSED*/ 4531077Ssvemuri void 4541077Ssvemuri mach_htraptrace_cleanup(int cpuid) 4551077Ssvemuri { 4561077Ssvemuri /* cleanup hypervisor traptrace buffer, not applicable to sun4u */ 4571077Ssvemuri } 4580Sstevel@tonic-gate 4590Sstevel@tonic-gate void 4601991Sheppo mach_descrip_startup_init(void) 4611991Sheppo { 4621991Sheppo /* 4631991Sheppo * Only for sun4v. 4641991Sheppo * Initialize Machine description framework during startup. 4651991Sheppo */ 4661991Sheppo } 4671991Sheppo void 4681991Sheppo mach_descrip_startup_fini(void) 4691991Sheppo { 4701991Sheppo /* 4711991Sheppo * Only for sun4v. 4721991Sheppo * Clean up Machine Description framework during startup. 4731991Sheppo */ 4741991Sheppo } 4751991Sheppo 4761991Sheppo void 4770Sstevel@tonic-gate mach_descrip_init(void) 4780Sstevel@tonic-gate { 4791991Sheppo /* 4801991Sheppo * Only for sun4v. 4811991Sheppo * Initialize Machine description framework. 4821991Sheppo */ 4830Sstevel@tonic-gate } 4840Sstevel@tonic-gate 4851592Sgirish void 4861592Sgirish hsvc_setup(void) 4871592Sgirish { 4881592Sgirish /* Setup hypervisor services, not applicable to sun4u */ 4891592Sgirish } 4901592Sgirish 4911991Sheppo void 4921991Sheppo load_mach_drivers(void) 4931991Sheppo { 4941991Sheppo /* Currently no machine class (sun4u) specific drivers to load */ 4951991Sheppo } 4961991Sheppo 4970Sstevel@tonic-gate /* 4980Sstevel@tonic-gate * Return true if the machine we're running on is a Positron. 4990Sstevel@tonic-gate * (Positron is an unsupported developers platform.) 5000Sstevel@tonic-gate */ 5010Sstevel@tonic-gate int 5020Sstevel@tonic-gate iam_positron(void) 5030Sstevel@tonic-gate { 5040Sstevel@tonic-gate char model[32]; 5050Sstevel@tonic-gate const char proto_model[] = "SUNW,501-2732"; 506789Sahrens pnode_t root = prom_rootnode(); 5070Sstevel@tonic-gate 5080Sstevel@tonic-gate if (prom_getproplen(root, "model") != sizeof (proto_model)) 5090Sstevel@tonic-gate return (0); 5100Sstevel@tonic-gate 5110Sstevel@tonic-gate (void) prom_getprop(root, "model", model); 5120Sstevel@tonic-gate if (strcmp(model, proto_model) == 0) 5130Sstevel@tonic-gate return (1); 5140Sstevel@tonic-gate return (0); 5150Sstevel@tonic-gate } 5160Sstevel@tonic-gate 5170Sstevel@tonic-gate /* 5180Sstevel@tonic-gate * Find a physically contiguous area of twice the largest ecache size 5190Sstevel@tonic-gate * to be used while doing displacement flush of ecaches. 5200Sstevel@tonic-gate */ 5210Sstevel@tonic-gate uint64_t 5220Sstevel@tonic-gate ecache_flush_address(void) 5230Sstevel@tonic-gate { 5240Sstevel@tonic-gate struct memlist *pmem; 5250Sstevel@tonic-gate uint64_t flush_size; 5260Sstevel@tonic-gate uint64_t ret_val; 5270Sstevel@tonic-gate 5280Sstevel@tonic-gate flush_size = ecache_size * 2; 5290Sstevel@tonic-gate for (pmem = phys_install; pmem; pmem = pmem->next) { 5300Sstevel@tonic-gate ret_val = P2ROUNDUP(pmem->address, ecache_size); 5310Sstevel@tonic-gate if (ret_val + flush_size <= pmem->address + pmem->size) 5320Sstevel@tonic-gate return (ret_val); 5330Sstevel@tonic-gate } 5340Sstevel@tonic-gate return ((uint64_t)-1); 5350Sstevel@tonic-gate } 5360Sstevel@tonic-gate 5370Sstevel@tonic-gate /* 5380Sstevel@tonic-gate * Called with the memlist lock held to say that phys_install has 5390Sstevel@tonic-gate * changed. 5400Sstevel@tonic-gate */ 5410Sstevel@tonic-gate void 5420Sstevel@tonic-gate phys_install_has_changed(void) 5430Sstevel@tonic-gate { 5440Sstevel@tonic-gate /* 5450Sstevel@tonic-gate * Get the new address into a temporary just in case panicking 5460Sstevel@tonic-gate * involves use of ecache_flushaddr. 5470Sstevel@tonic-gate */ 5480Sstevel@tonic-gate uint64_t new_addr; 5490Sstevel@tonic-gate 5500Sstevel@tonic-gate new_addr = ecache_flush_address(); 5510Sstevel@tonic-gate if (new_addr == (uint64_t)-1) { 5520Sstevel@tonic-gate cmn_err(CE_PANIC, 5530Sstevel@tonic-gate "ecache_flush_address(): failed, ecache_size=%x", 5540Sstevel@tonic-gate ecache_size); 5550Sstevel@tonic-gate /*NOTREACHED*/ 5560Sstevel@tonic-gate } 5570Sstevel@tonic-gate ecache_flushaddr = new_addr; 5580Sstevel@tonic-gate membar_producer(); 5590Sstevel@tonic-gate } 560