xref: /onnv-gate/usr/src/uts/i86pc/os/mlsetup.c (revision 10574:c8621ef15d56)
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
52006Sandrei  * Common Development and Distribution License (the "License").
62006Sandrei  * 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 /*
228906SEric.Saxe@Sun.COM  * Copyright 2009 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/types.h>
273446Smrj #include <sys/sysmacros.h>
280Sstevel@tonic-gate #include <sys/disp.h>
290Sstevel@tonic-gate #include <sys/promif.h>
300Sstevel@tonic-gate #include <sys/clock.h>
310Sstevel@tonic-gate #include <sys/cpuvar.h>
320Sstevel@tonic-gate #include <sys/stack.h>
330Sstevel@tonic-gate #include <vm/as.h>
340Sstevel@tonic-gate #include <vm/hat.h>
350Sstevel@tonic-gate #include <sys/reboot.h>
360Sstevel@tonic-gate #include <sys/avintr.h>
370Sstevel@tonic-gate #include <sys/vtrace.h>
380Sstevel@tonic-gate #include <sys/proc.h>
390Sstevel@tonic-gate #include <sys/thread.h>
400Sstevel@tonic-gate #include <sys/cpupart.h>
410Sstevel@tonic-gate #include <sys/pset.h>
420Sstevel@tonic-gate #include <sys/copyops.h>
433434Sesaxe #include <sys/pg.h>
440Sstevel@tonic-gate #include <sys/disp.h>
450Sstevel@tonic-gate #include <sys/debug.h>
460Sstevel@tonic-gate #include <sys/sunddi.h>
470Sstevel@tonic-gate #include <sys/x86_archext.h>
480Sstevel@tonic-gate #include <sys/privregs.h>
490Sstevel@tonic-gate #include <sys/machsystm.h>
500Sstevel@tonic-gate #include <sys/ontrap.h>
510Sstevel@tonic-gate #include <sys/bootconf.h>
52*10574SSherry.Moore@Sun.COM #include <sys/boot_console.h>
533446Smrj #include <sys/kdi_machimpl.h>
540Sstevel@tonic-gate #include <sys/archsystm.h>
550Sstevel@tonic-gate #include <sys/promif.h>
56748Sdmick #include <sys/pci_cfgspace.h>
575084Sjohnlev #ifdef __xpv
585084Sjohnlev #include <sys/hypervisor.h>
5910175SStuart.Maybee@Sun.COM #else
6010175SStuart.Maybee@Sun.COM #include <sys/xpv_support.h>
615084Sjohnlev #endif
620Sstevel@tonic-gate 
630Sstevel@tonic-gate /*
640Sstevel@tonic-gate  * some globals for patching the result of cpuid
650Sstevel@tonic-gate  * to solve problems w/ creative cpu vendors
660Sstevel@tonic-gate  */
670Sstevel@tonic-gate 
680Sstevel@tonic-gate extern uint32_t cpuid_feature_ecx_include;
690Sstevel@tonic-gate extern uint32_t cpuid_feature_ecx_exclude;
700Sstevel@tonic-gate extern uint32_t cpuid_feature_edx_include;
710Sstevel@tonic-gate extern uint32_t cpuid_feature_edx_exclude;
720Sstevel@tonic-gate 
730Sstevel@tonic-gate /*
74783Sdmick  * Dummy spl priority masks
75783Sdmick  */
763446Smrj static unsigned char dummy_cpu_pri[MAXIPL + 1] = {
77783Sdmick 	0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
78783Sdmick 	0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf
79783Sdmick };
80783Sdmick 
81*10574SSherry.Moore@Sun.COM /*
82*10574SSherry.Moore@Sun.COM  * Set console mode
83*10574SSherry.Moore@Sun.COM  */
84*10574SSherry.Moore@Sun.COM static void
85*10574SSherry.Moore@Sun.COM set_console_mode(uint8_t val)
86*10574SSherry.Moore@Sun.COM {
87*10574SSherry.Moore@Sun.COM 	struct bop_regs rp = {0};
88*10574SSherry.Moore@Sun.COM 
89*10574SSherry.Moore@Sun.COM 	rp.eax.byte.ah = 0x0;
90*10574SSherry.Moore@Sun.COM 	rp.eax.byte.al = val;
91*10574SSherry.Moore@Sun.COM 	rp.ebx.word.bx = 0x0;
92*10574SSherry.Moore@Sun.COM 
93*10574SSherry.Moore@Sun.COM 	BOP_DOINT(bootops, 0x10, &rp);
94*10574SSherry.Moore@Sun.COM }
95*10574SSherry.Moore@Sun.COM 
960Sstevel@tonic-gate 
970Sstevel@tonic-gate /*
980Sstevel@tonic-gate  * Setup routine called right before main(). Interposing this function
990Sstevel@tonic-gate  * before main() allows us to call it in a machine-independent fashion.
1000Sstevel@tonic-gate  */
1010Sstevel@tonic-gate void
1020Sstevel@tonic-gate mlsetup(struct regs *rp)
1030Sstevel@tonic-gate {
1049053Sjonathan.chew@sun.com 	u_longlong_t prop_value;
1050Sstevel@tonic-gate 	extern struct classfuncs sys_classfuncs;
1060Sstevel@tonic-gate 	extern disp_t cpu0_disp;
1070Sstevel@tonic-gate 	extern char t0stack[];
108*10574SSherry.Moore@Sun.COM 	extern int post_fastreboot;
109*10574SSherry.Moore@Sun.COM 	extern int console;
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate 	ASSERT_STACK_ALIGNED();
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate 	/*
1140Sstevel@tonic-gate 	 * initialize cpu_self
1150Sstevel@tonic-gate 	 */
1160Sstevel@tonic-gate 	cpu[0]->cpu_self = cpu[0];
1170Sstevel@tonic-gate 
1185084Sjohnlev #if defined(__xpv)
1195084Sjohnlev 	/*
1205084Sjohnlev 	 * Point at the hypervisor's virtual cpu structure
1215084Sjohnlev 	 */
1225084Sjohnlev 	cpu[0]->cpu_m.mcpu_vcpu_info = &HYPERVISOR_shared_info->vcpu_info[0];
1235084Sjohnlev #endif
1245084Sjohnlev 
1250Sstevel@tonic-gate 	/*
126783Sdmick 	 * Set up dummy cpu_pri_data values till psm spl code is
127783Sdmick 	 * installed.  This allows splx() to work on amd64.
128783Sdmick 	 */
129783Sdmick 
130783Sdmick 	cpu[0]->cpu_pri_data = dummy_cpu_pri;
131783Sdmick 
132783Sdmick 	/*
1330Sstevel@tonic-gate 	 * check if we've got special bits to clear or set
1340Sstevel@tonic-gate 	 * when checking cpu features
1350Sstevel@tonic-gate 	 */
1360Sstevel@tonic-gate 
1379053Sjonathan.chew@sun.com 	if (bootprop_getval("cpuid_feature_ecx_include", &prop_value) != 0)
1389053Sjonathan.chew@sun.com 		cpuid_feature_ecx_include = 0;
1399053Sjonathan.chew@sun.com 	else
1409053Sjonathan.chew@sun.com 		cpuid_feature_ecx_include = (uint32_t)prop_value;
1419053Sjonathan.chew@sun.com 
1429053Sjonathan.chew@sun.com 	if (bootprop_getval("cpuid_feature_ecx_exclude", &prop_value) != 0)
1439053Sjonathan.chew@sun.com 		cpuid_feature_ecx_exclude = 0;
1449053Sjonathan.chew@sun.com 	else
1459053Sjonathan.chew@sun.com 		cpuid_feature_ecx_exclude = (uint32_t)prop_value;
1469053Sjonathan.chew@sun.com 
1479053Sjonathan.chew@sun.com 	if (bootprop_getval("cpuid_feature_edx_include", &prop_value) != 0)
1489053Sjonathan.chew@sun.com 		cpuid_feature_edx_include = 0;
1499053Sjonathan.chew@sun.com 	else
1509053Sjonathan.chew@sun.com 		cpuid_feature_edx_include = (uint32_t)prop_value;
1519053Sjonathan.chew@sun.com 
1529053Sjonathan.chew@sun.com 	if (bootprop_getval("cpuid_feature_edx_exclude", &prop_value) != 0)
1539053Sjonathan.chew@sun.com 		cpuid_feature_edx_exclude = 0;
1549053Sjonathan.chew@sun.com 	else
1559053Sjonathan.chew@sun.com 		cpuid_feature_edx_exclude = (uint32_t)prop_value;
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate 	/*
1580Sstevel@tonic-gate 	 * The first lightweight pass (pass0) through the cpuid data
1590Sstevel@tonic-gate 	 * was done in locore before mlsetup was called.  Do the next
1600Sstevel@tonic-gate 	 * pass in C code.
1610Sstevel@tonic-gate 	 *
1620Sstevel@tonic-gate 	 * The x86_feature bits are set here on the basis of the capabilities
1630Sstevel@tonic-gate 	 * of the boot CPU.  Note that if we choose to support CPUs that have
1640Sstevel@tonic-gate 	 * different feature sets (at which point we would almost certainly
1650Sstevel@tonic-gate 	 * want to set the feature bits to correspond to the feature
1660Sstevel@tonic-gate 	 * minimum) this value may be altered.
1670Sstevel@tonic-gate 	 */
1680Sstevel@tonic-gate 	x86_feature = cpuid_pass1(cpu[0]);
1690Sstevel@tonic-gate 
1700Sstevel@tonic-gate 	/*
1710Sstevel@tonic-gate 	 * Initialize idt0, gdt0, ldt0_default, ktss0 and dftss.
1720Sstevel@tonic-gate 	 */
1733446Smrj 	init_desctbls();
1740Sstevel@tonic-gate 
1755322Ssudheer #if !defined(__xpv)
1765322Ssudheer 
17710175SStuart.Maybee@Sun.COM 	if (get_hwenv() == HW_XEN_HVM)
17810175SStuart.Maybee@Sun.COM 		xen_hvm_init();
17910175SStuart.Maybee@Sun.COM 
1805322Ssudheer 	/*
1815322Ssudheer 	 * Patch the tsc_read routine with appropriate set of instructions,
1825322Ssudheer 	 * depending on the processor family and architecure, to read the
1835322Ssudheer 	 * time-stamp counter while ensuring no out-of-order execution.
1845322Ssudheer 	 * Patch it while the kernel text is still writable.
1855322Ssudheer 	 *
1865322Ssudheer 	 * Note: tsc_read is not patched for intel processors whose family
1875322Ssudheer 	 * is >6 and for amd whose family >f (in case they don't support rdtscp
1885322Ssudheer 	 * instruction, unlikely). By default tsc_read will use cpuid for
1895322Ssudheer 	 * serialization in such cases. The following code needs to be
1905322Ssudheer 	 * revisited if intel processors of family >= f retains the
1915322Ssudheer 	 * instruction serialization nature of mfence instruction.
1925338Ssudheer 	 * Note: tsc_read is not patched for x86 processors which do
1935338Ssudheer 	 * not support "mfence". By default tsc_read will use cpuid for
1945338Ssudheer 	 * serialization in such cases.
1955741Smrj 	 *
1965741Smrj 	 * The Xen hypervisor does not correctly report whether rdtscp is
1975741Smrj 	 * supported or not, so we must assume that it is not.
1985322Ssudheer 	 */
1999000SStuart.Maybee@Sun.COM 	if (get_hwenv() != HW_XEN_HVM && (x86_feature & X86_TSCP))
2005322Ssudheer 		patch_tsc_read(X86_HAVE_TSCP);
2015322Ssudheer 	else if (cpuid_getvendor(CPU) == X86_VENDOR_AMD &&
2025338Ssudheer 	    cpuid_getfamily(CPU) <= 0xf && (x86_feature & X86_SSE2) != 0)
2035322Ssudheer 		patch_tsc_read(X86_TSC_MFENCE);
2045322Ssudheer 	else if (cpuid_getvendor(CPU) == X86_VENDOR_Intel &&
2055338Ssudheer 	    cpuid_getfamily(CPU) <= 6 && (x86_feature & X86_SSE2) != 0)
2066642Ssudheer 		patch_tsc_read(X86_TSC_LFENCE);
2075322Ssudheer 
2085322Ssudheer #endif	/* !__xpv */
2090Sstevel@tonic-gate 
2105084Sjohnlev #if defined(__i386) && !defined(__xpv)
2110Sstevel@tonic-gate 	/*
2120Sstevel@tonic-gate 	 * Some i386 processors do not implement the rdtsc instruction,
2135322Ssudheer 	 * or at least they do not implement it correctly. Patch them to
2145322Ssudheer 	 * return 0.
2150Sstevel@tonic-gate 	 */
2165322Ssudheer 	if ((x86_feature & X86_TSC) == 0)
2175322Ssudheer 		patch_tsc_read(X86_NO_TSC);
2185084Sjohnlev #endif	/* __i386 && !__xpv */
2195084Sjohnlev 
2208377SBill.Holler@Sun.COM #if defined(__amd64) && !defined(__xpv)
2218377SBill.Holler@Sun.COM 	patch_memops(cpuid_getvendor(CPU));
2228377SBill.Holler@Sun.COM #endif	/* __amd64 && !__xpv */
2238377SBill.Holler@Sun.COM 
2245084Sjohnlev #if !defined(__xpv)
2255084Sjohnlev 	/* XXPV	what, if anything, should be dorked with here under xen? */
2263446Smrj 
2273446Smrj 	/*
2283446Smrj 	 * While we're thinking about the TSC, let's set up %cr4 so that
2293446Smrj 	 * userland can issue rdtsc, and initialize the TSC_AUX value
2303446Smrj 	 * (the cpuid) for the rdtscp instruction on appropriately
2313446Smrj 	 * capable hardware.
2323446Smrj 	 */
2333446Smrj 	if (x86_feature & X86_TSC)
2343446Smrj 		setcr4(getcr4() & ~CR4_TSD);
2353446Smrj 
2363446Smrj 	if (x86_feature & X86_TSCP)
2373446Smrj 		(void) wrmsr(MSR_AMD_TSCAUX, 0);
2383446Smrj 
2393446Smrj 	if (x86_feature & X86_DE)
2403446Smrj 		setcr4(getcr4() | CR4_DE);
2415084Sjohnlev #endif /* __xpv */
2420Sstevel@tonic-gate 
2430Sstevel@tonic-gate 	/*
2440Sstevel@tonic-gate 	 * initialize t0
2450Sstevel@tonic-gate 	 */
2460Sstevel@tonic-gate 	t0.t_stk = (caddr_t)rp - MINFRAME;
2470Sstevel@tonic-gate 	t0.t_stkbase = t0stack;
2480Sstevel@tonic-gate 	t0.t_pri = maxclsyspri - 3;
2490Sstevel@tonic-gate 	t0.t_schedflag = TS_LOAD | TS_DONT_SWAP;
2500Sstevel@tonic-gate 	t0.t_procp = &p0;
2510Sstevel@tonic-gate 	t0.t_plockp = &p0lock.pl_lock;
2520Sstevel@tonic-gate 	t0.t_lwp = &lwp0;
2530Sstevel@tonic-gate 	t0.t_forw = &t0;
2540Sstevel@tonic-gate 	t0.t_back = &t0;
2550Sstevel@tonic-gate 	t0.t_next = &t0;
2560Sstevel@tonic-gate 	t0.t_prev = &t0;
2570Sstevel@tonic-gate 	t0.t_cpu = cpu[0];
2580Sstevel@tonic-gate 	t0.t_disp_queue = &cpu0_disp;
2590Sstevel@tonic-gate 	t0.t_bind_cpu = PBIND_NONE;
2600Sstevel@tonic-gate 	t0.t_bind_pset = PS_NONE;
2616298Sakolb 	t0.t_bindflag = (uchar_t)default_binding_mode;
2620Sstevel@tonic-gate 	t0.t_cpupart = &cp_default;
2630Sstevel@tonic-gate 	t0.t_clfuncs = &sys_classfuncs.thread;
2640Sstevel@tonic-gate 	t0.t_copyops = NULL;
2650Sstevel@tonic-gate 	THREAD_ONPROC(&t0, CPU);
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate 	lwp0.lwp_thread = &t0;
2683446Smrj 	lwp0.lwp_regs = (void *)rp;
2690Sstevel@tonic-gate 	lwp0.lwp_procp = &p0;
2700Sstevel@tonic-gate 	t0.t_tid = p0.p_lwpcnt = p0.p_lwprcnt = p0.p_lwpid = 1;
2710Sstevel@tonic-gate 
2720Sstevel@tonic-gate 	p0.p_exec = NULL;
2730Sstevel@tonic-gate 	p0.p_stat = SRUN;
2740Sstevel@tonic-gate 	p0.p_flag = SSYS;
2750Sstevel@tonic-gate 	p0.p_tlist = &t0;
2760Sstevel@tonic-gate 	p0.p_stksize = 2*PAGESIZE;
2770Sstevel@tonic-gate 	p0.p_stkpageszc = 0;
2780Sstevel@tonic-gate 	p0.p_as = &kas;
2790Sstevel@tonic-gate 	p0.p_lockp = &p0lock;
2800Sstevel@tonic-gate 	p0.p_brkpageszc = 0;
2814426Saguzovsk 	p0.p_t1_lgrpid = LGRP_NONE;
2824426Saguzovsk 	p0.p_tr_lgrpid = LGRP_NONE;
2830Sstevel@tonic-gate 	sigorset(&p0.p_ignore, &ignoredefault);
2840Sstevel@tonic-gate 
2850Sstevel@tonic-gate 	CPU->cpu_thread = &t0;
2860Sstevel@tonic-gate 	bzero(&cpu0_disp, sizeof (disp_t));
2870Sstevel@tonic-gate 	CPU->cpu_disp = &cpu0_disp;
2880Sstevel@tonic-gate 	CPU->cpu_disp->disp_cpu = CPU;
2890Sstevel@tonic-gate 	CPU->cpu_dispthread = &t0;
2900Sstevel@tonic-gate 	CPU->cpu_idle_thread = &t0;
2910Sstevel@tonic-gate 	CPU->cpu_flags = CPU_READY | CPU_RUNNING | CPU_EXISTS | CPU_ENABLE;
2920Sstevel@tonic-gate 	CPU->cpu_dispatch_pri = t0.t_pri;
2930Sstevel@tonic-gate 
2940Sstevel@tonic-gate 	CPU->cpu_id = 0;
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate 	CPU->cpu_pri = 12;		/* initial PIL for the boot CPU */
2970Sstevel@tonic-gate 
2980Sstevel@tonic-gate 	/*
2991217Srab 	 * The kernel doesn't use LDTs unless a process explicitly requests one.
3000Sstevel@tonic-gate 	 */
3015084Sjohnlev 	p0.p_ldt_desc = null_sdesc;
3020Sstevel@tonic-gate 
3030Sstevel@tonic-gate 	/*
3043446Smrj 	 * Initialize thread/cpu microstate accounting
3050Sstevel@tonic-gate 	 */
3060Sstevel@tonic-gate 	init_mstate(&t0, LMS_SYSTEM);
3070Sstevel@tonic-gate 	init_cpu_mstate(CPU, CMS_SYSTEM);
3080Sstevel@tonic-gate 
3090Sstevel@tonic-gate 	/*
3100Sstevel@tonic-gate 	 * Initialize lists of available and active CPUs.
3110Sstevel@tonic-gate 	 */
3120Sstevel@tonic-gate 	cpu_list_init(CPU);
3130Sstevel@tonic-gate 
3148906SEric.Saxe@Sun.COM 	pg_cpu_bootstrap(CPU);
3158906SEric.Saxe@Sun.COM 
3163446Smrj 	/*
3173446Smrj 	 * Now that we have taken over the GDT, IDT and have initialized
3183446Smrj 	 * active CPU list it's time to inform kmdb if present.
3193446Smrj 	 */
3203446Smrj 	if (boothowto & RB_DEBUG)
3213446Smrj 		kdi_idt_sync();
3223446Smrj 
3233446Smrj 	/*
324*10574SSherry.Moore@Sun.COM 	 * Explicitly set console to text mode (0x3) if this is a boot
325*10574SSherry.Moore@Sun.COM 	 * post Fast Reboot, and the console is set to CONS_SCREEN_TEXT.
326*10574SSherry.Moore@Sun.COM 	 */
327*10574SSherry.Moore@Sun.COM 	if (post_fastreboot && console == CONS_SCREEN_TEXT)
328*10574SSherry.Moore@Sun.COM 		set_console_mode(0x3);
329*10574SSherry.Moore@Sun.COM 
330*10574SSherry.Moore@Sun.COM 	/*
3313446Smrj 	 * If requested (boot -d) drop into kmdb.
3323446Smrj 	 *
3333446Smrj 	 * This must be done after cpu_list_init() on the 64-bit kernel
3343446Smrj 	 * since taking a trap requires that we re-compute gsbase based
3353446Smrj 	 * on the cpu list.
3363446Smrj 	 */
3373446Smrj 	if (boothowto & RB_DEBUGENTER)
3383446Smrj 		kmdb_enter();
3393446Smrj 
340414Skchow 	cpu_vm_data_init(CPU);
341414Skchow 
342748Sdmick 	/* lgrp_init() needs PCI config space access */
3435084Sjohnlev #if defined(__xpv)
3445084Sjohnlev 	if (DOMAIN_IS_INITDOMAIN(xen_info))
3455084Sjohnlev 		pci_cfgspace_init();
3465084Sjohnlev #else
347748Sdmick 	pci_cfgspace_init();
3485084Sjohnlev #endif
349748Sdmick 
3500Sstevel@tonic-gate 	rp->r_fp = 0;	/* terminate kernel stack traces! */
3510Sstevel@tonic-gate 
3520Sstevel@tonic-gate 	prom_init("kernel", (void *)NULL);
3530Sstevel@tonic-gate 
3549053Sjonathan.chew@sun.com 	if (bootprop_getval("boot-ncpus", &prop_value) != 0)
3553446Smrj 		boot_ncpus = NCPU;
3569053Sjonathan.chew@sun.com 	else {
3579053Sjonathan.chew@sun.com 		boot_ncpus = (int)prop_value;
3589053Sjonathan.chew@sun.com 		if (boot_ncpus <= 0 || boot_ncpus > NCPU)
3599053Sjonathan.chew@sun.com 			boot_ncpus = NCPU;
3609053Sjonathan.chew@sun.com 	}
3612006Sandrei 
3622006Sandrei 	max_ncpus = boot_max_ncpus = boot_ncpus;
3632006Sandrei 
3646445Sjjc 	/*
3656445Sjjc 	 * Initialize the lgrp framework
3666445Sjjc 	 */
3676445Sjjc 	lgrp_init();
3686445Sjjc 
3690Sstevel@tonic-gate 	if (boothowto & RB_HALT) {
3700Sstevel@tonic-gate 		prom_printf("unix: kernel halted by -h flag\n");
3710Sstevel@tonic-gate 		prom_enter_mon();
3720Sstevel@tonic-gate 	}
3730Sstevel@tonic-gate 
3740Sstevel@tonic-gate 	ASSERT_STACK_ALIGNED();
3750Sstevel@tonic-gate 
3764581Ssherrym 	/*
3774581Ssherrym 	 * Fill out cpu_ucode_info.  Update microcode if necessary.
3784581Ssherrym 	 */
3794581Ssherrym 	ucode_check(CPU);
3804581Ssherrym 
3810Sstevel@tonic-gate 	if (workaround_errata(CPU) != 0)
3820Sstevel@tonic-gate 		panic("critical workaround(s) missing for boot cpu");
3830Sstevel@tonic-gate }
3845648Ssetje 
3855648Ssetje 
3865648Ssetje void
3875648Ssetje mach_modpath(char *path, const char *filename)
3885648Ssetje {
3895648Ssetje 	/*
3905648Ssetje 	 * Construct the directory path from the filename.
3915648Ssetje 	 */
3925648Ssetje 
3935648Ssetje 	int len;
3945648Ssetje 	char *p;
3955648Ssetje 	const char isastr[] = "/amd64";
3965648Ssetje 	size_t isalen = strlen(isastr);
3975648Ssetje 
3985648Ssetje 	if ((p = strrchr(filename, '/')) == NULL)
3995648Ssetje 		return;
4005648Ssetje 
4015648Ssetje 	while (p > filename && *(p - 1) == '/')
4025648Ssetje 		p--;	/* remove trailing '/' characters */
4035648Ssetje 	if (p == filename)
4045648Ssetje 		p++;	/* so "/" -is- the modpath in this case */
4055648Ssetje 
4065648Ssetje 	/*
4075648Ssetje 	 * Remove optional isa-dependent directory name - the module
4085648Ssetje 	 * subsystem will put this back again (!)
4095648Ssetje 	 */
4105648Ssetje 	len = p - filename;
4115648Ssetje 	if (len > isalen &&
4125648Ssetje 	    strncmp(&filename[len - isalen], isastr, isalen) == 0)
4135648Ssetje 		p -= isalen;
4145648Ssetje 
4155648Ssetje 	/*
4165648Ssetje 	 * "/platform/mumblefrotz" + " " + MOD_DEFPATH
4175648Ssetje 	 */
4185648Ssetje 	len += (p - filename) + 1 + strlen(MOD_DEFPATH) + 1;
4195648Ssetje 	(void) strncpy(path, filename, p - filename);
4205648Ssetje }
421