xref: /titanic_51/usr/src/uts/i86pc/os/mlsetup.c (revision fb2f18f820d90b001aea4fb27dd654bc1263c440)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
541791439Sandrei  * Common Development and Distribution License (the "License").
641791439Sandrei  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*fb2f18f8Sesaxe  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #include <sys/types.h>
297c478bd9Sstevel@tonic-gate #include <sys/disp.h>
307c478bd9Sstevel@tonic-gate #include <sys/promif.h>
317c478bd9Sstevel@tonic-gate #include <sys/clock.h>
327c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h>
337c478bd9Sstevel@tonic-gate #include <sys/stack.h>
347c478bd9Sstevel@tonic-gate #include <vm/as.h>
357c478bd9Sstevel@tonic-gate #include <vm/hat.h>
367c478bd9Sstevel@tonic-gate #include <sys/reboot.h>
377c478bd9Sstevel@tonic-gate #include <sys/avintr.h>
387c478bd9Sstevel@tonic-gate #include <sys/vtrace.h>
397c478bd9Sstevel@tonic-gate #include <sys/proc.h>
407c478bd9Sstevel@tonic-gate #include <sys/thread.h>
417c478bd9Sstevel@tonic-gate #include <sys/cpupart.h>
427c478bd9Sstevel@tonic-gate #include <sys/pset.h>
437c478bd9Sstevel@tonic-gate #include <sys/copyops.h>
44*fb2f18f8Sesaxe #include <sys/pg.h>
457c478bd9Sstevel@tonic-gate #include <sys/disp.h>
467c478bd9Sstevel@tonic-gate #include <sys/debug.h>
477c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
487c478bd9Sstevel@tonic-gate #include <sys/x86_archext.h>
497c478bd9Sstevel@tonic-gate #include <sys/privregs.h>
507c478bd9Sstevel@tonic-gate #include <sys/machsystm.h>
517c478bd9Sstevel@tonic-gate #include <sys/ontrap.h>
527c478bd9Sstevel@tonic-gate #include <sys/bootconf.h>
537c478bd9Sstevel@tonic-gate #include <sys/kdi.h>
547c478bd9Sstevel@tonic-gate #include <sys/archsystm.h>
557c478bd9Sstevel@tonic-gate #include <sys/promif.h>
567c478bd9Sstevel@tonic-gate #include <sys/bootconf.h>
577c478bd9Sstevel@tonic-gate #include <sys/kobj.h>
587c478bd9Sstevel@tonic-gate #include <sys/kobj_lex.h>
59c88420b3Sdmick #include <sys/pci_cfgspace.h>
607c478bd9Sstevel@tonic-gate #if defined(__amd64)
617c478bd9Sstevel@tonic-gate #include <sys/bootsvcs.h>
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /*
647c478bd9Sstevel@tonic-gate  * XX64	This stuff deals with switching stacks in case a trapping
657c478bd9Sstevel@tonic-gate  *	thread wants to call back into boot -after- boot has lost track
667c478bd9Sstevel@tonic-gate  *	of the mappings but before the kernel owns the console.
677c478bd9Sstevel@tonic-gate  *
687c478bd9Sstevel@tonic-gate  *	(A better way to hide this would be to add a 'this' pointer to
697c478bd9Sstevel@tonic-gate  *	every boot syscall so that vmx could get at the resulting save
707c478bd9Sstevel@tonic-gate  *	area.)
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate struct boot_syscalls *_vmx_sysp;
747c478bd9Sstevel@tonic-gate static struct boot_syscalls __kbootsvcs;
757c478bd9Sstevel@tonic-gate extern struct boot_syscalls *sysp;
767c478bd9Sstevel@tonic-gate extern void _stack_safe_putchar(int c);
777c478bd9Sstevel@tonic-gate #endif
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate /*
807c478bd9Sstevel@tonic-gate  * some globals for patching the result of cpuid
817c478bd9Sstevel@tonic-gate  * to solve problems w/ creative cpu vendors
827c478bd9Sstevel@tonic-gate  */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate extern uint32_t cpuid_feature_ecx_include;
857c478bd9Sstevel@tonic-gate extern uint32_t cpuid_feature_ecx_exclude;
867c478bd9Sstevel@tonic-gate extern uint32_t cpuid_feature_edx_include;
877c478bd9Sstevel@tonic-gate extern uint32_t cpuid_feature_edx_exclude;
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate /*
904961a633Sdmick  * Dummy spl priority masks
914961a633Sdmick  */
924961a633Sdmick static unsigned char	dummy_cpu_pri[MAXIPL + 1] = {
934961a633Sdmick 	0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
944961a633Sdmick 	0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf
954961a633Sdmick };
964961a633Sdmick 
974961a633Sdmick /*
987c478bd9Sstevel@tonic-gate  * External Routines:
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate extern void init_tables(void);
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate static uint32_t
10541791439Sandrei bootprop_getval(char *name)
1067c478bd9Sstevel@tonic-gate {
1077c478bd9Sstevel@tonic-gate 	char prop[32];
1087c478bd9Sstevel@tonic-gate 	u_longlong_t ll;
1097c478bd9Sstevel@tonic-gate 	extern struct bootops *bootops;
1107c478bd9Sstevel@tonic-gate 	if ((BOP_GETPROPLEN(bootops, name) > sizeof (prop)) ||
1117c478bd9Sstevel@tonic-gate 	    (BOP_GETPROP(bootops, name, prop) < 0) ||
1127c478bd9Sstevel@tonic-gate 	    (kobj_getvalue(prop, &ll) == -1))
1137c478bd9Sstevel@tonic-gate 		return (0);
1147c478bd9Sstevel@tonic-gate 	return ((uint32_t)ll);
1157c478bd9Sstevel@tonic-gate }
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate /*
1187c478bd9Sstevel@tonic-gate  * Setup routine called right before main(). Interposing this function
1197c478bd9Sstevel@tonic-gate  * before main() allows us to call it in a machine-independent fashion.
1207c478bd9Sstevel@tonic-gate  */
1217c478bd9Sstevel@tonic-gate void
1227c478bd9Sstevel@tonic-gate mlsetup(struct regs *rp)
1237c478bd9Sstevel@tonic-gate {
1247c478bd9Sstevel@tonic-gate 	extern struct classfuncs sys_classfuncs;
1257c478bd9Sstevel@tonic-gate 	extern disp_t cpu0_disp;
1267c478bd9Sstevel@tonic-gate 	extern char t0stack[];
12741791439Sandrei 	int boot_ncpus;
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate 	ASSERT_STACK_ALIGNED();
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate #if defined(__amd64)
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate #if (BS_VERSION > 4)
1347c478bd9Sstevel@tonic-gate 	/*
1357c478bd9Sstevel@tonic-gate 	 * When new boot_syscalls are added to the vector, this routine
1367c478bd9Sstevel@tonic-gate 	 * must be modified to copy them into the kernel's copy of the
1377c478bd9Sstevel@tonic-gate 	 * vector.
1387c478bd9Sstevel@tonic-gate 	 */
1397c478bd9Sstevel@tonic-gate #error mlsetup() must be updated for amd64 to support new boot_syscalls
1407c478bd9Sstevel@tonic-gate #endif	/* (BS_VERSION > 4) */
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate 	/*
1437c478bd9Sstevel@tonic-gate 	 * XX64	This remaps vmx's putchar to use the kernel's version
1447c478bd9Sstevel@tonic-gate 	 *	that switches stacks before diving into vmx
1457c478bd9Sstevel@tonic-gate 	 *	See explanation/complaints in commentary above.
1467c478bd9Sstevel@tonic-gate 	 */
1477c478bd9Sstevel@tonic-gate 	_vmx_sysp = sysp;
1487c478bd9Sstevel@tonic-gate 	sysp = &__kbootsvcs;
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate 	sysp->bsvc_getchar = _vmx_sysp->bsvc_getchar;
1517c478bd9Sstevel@tonic-gate 	sysp->bsvc_putchar = _stack_safe_putchar;
1527c478bd9Sstevel@tonic-gate 	sysp->bsvc_ischar = _vmx_sysp->bsvc_ischar;
1537c478bd9Sstevel@tonic-gate #endif
1547c478bd9Sstevel@tonic-gate 	/*
1557c478bd9Sstevel@tonic-gate 	 * initialize cpu_self
1567c478bd9Sstevel@tonic-gate 	 */
1577c478bd9Sstevel@tonic-gate 	cpu[0]->cpu_self = cpu[0];
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate 	/*
1604961a633Sdmick 	 * Set up dummy cpu_pri_data values till psm spl code is
1614961a633Sdmick 	 * installed.  This allows splx() to work on amd64.
1624961a633Sdmick 	 */
1634961a633Sdmick 
1644961a633Sdmick 	cpu[0]->cpu_pri_data = dummy_cpu_pri;
1654961a633Sdmick 
1664961a633Sdmick 	/*
1677c478bd9Sstevel@tonic-gate 	 * check if we've got special bits to clear or set
1687c478bd9Sstevel@tonic-gate 	 * when checking cpu features
1697c478bd9Sstevel@tonic-gate 	 */
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate 	cpuid_feature_ecx_include =
17241791439Sandrei 	    bootprop_getval("cpuid_feature_ecx_include");
1737c478bd9Sstevel@tonic-gate 	cpuid_feature_ecx_exclude =
17441791439Sandrei 	    bootprop_getval("cpuid_feature_ecx_exclude");
1757c478bd9Sstevel@tonic-gate 	cpuid_feature_edx_include =
17641791439Sandrei 	    bootprop_getval("cpuid_feature_edx_include");
1777c478bd9Sstevel@tonic-gate 	cpuid_feature_edx_exclude =
17841791439Sandrei 	    bootprop_getval("cpuid_feature_edx_exclude");
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate 	/*
1817c478bd9Sstevel@tonic-gate 	 * The first lightweight pass (pass0) through the cpuid data
1827c478bd9Sstevel@tonic-gate 	 * was done in locore before mlsetup was called.  Do the next
1837c478bd9Sstevel@tonic-gate 	 * pass in C code.
1847c478bd9Sstevel@tonic-gate 	 *
1857c478bd9Sstevel@tonic-gate 	 * The x86_feature bits are set here on the basis of the capabilities
1867c478bd9Sstevel@tonic-gate 	 * of the boot CPU.  Note that if we choose to support CPUs that have
1877c478bd9Sstevel@tonic-gate 	 * different feature sets (at which point we would almost certainly
1887c478bd9Sstevel@tonic-gate 	 * want to set the feature bits to correspond to the feature
1897c478bd9Sstevel@tonic-gate 	 * minimum) this value may be altered.
1907c478bd9Sstevel@tonic-gate 	 */
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate 	x86_feature = cpuid_pass1(cpu[0]);
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate 	/*
1957c478bd9Sstevel@tonic-gate 	 * Initialize idt0, gdt0, ldt0_default, ktss0 and dftss.
1967c478bd9Sstevel@tonic-gate 	 */
1977c478bd9Sstevel@tonic-gate 	init_tables();
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate #if defined(__amd64)
2007c478bd9Sstevel@tonic-gate 	/*CSTYLED*/
2017c478bd9Sstevel@tonic-gate 	{
2027c478bd9Sstevel@tonic-gate 		/*
2037c478bd9Sstevel@tonic-gate 		 * setup %gs for the kernel
2047c478bd9Sstevel@tonic-gate 		 */
2050ac7d7d8Skucharsk 		wrmsr(MSR_AMD_GSBASE, (uint64_t)&cpus[0]);
2067c478bd9Sstevel@tonic-gate 		/*
2077c478bd9Sstevel@tonic-gate 		 * XX64 We should never dereference off "other gsbase" or
2087c478bd9Sstevel@tonic-gate 		 * "fsbase".  So, we should arrange to point FSBASE and
2097c478bd9Sstevel@tonic-gate 		 * KGSBASE somewhere truly awful e.g. point it at the last
2107c478bd9Sstevel@tonic-gate 		 * valid address below the hole so that any attempts to index
2117c478bd9Sstevel@tonic-gate 		 * off them cause an exception.
2127c478bd9Sstevel@tonic-gate 		 *
2137c478bd9Sstevel@tonic-gate 		 * For now, point it at 8G -- at least it should be unmapped
2147c478bd9Sstevel@tonic-gate 		 * until some 64-bit processes run.
2157c478bd9Sstevel@tonic-gate 		 */
2160ac7d7d8Skucharsk 		wrmsr(MSR_AMD_FSBASE, 0x200000000UL);
2170ac7d7d8Skucharsk 		wrmsr(MSR_AMD_KGSBASE, 0x200000000UL);
2187c478bd9Sstevel@tonic-gate 	}
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate #elif defined(__i386)
2217c478bd9Sstevel@tonic-gate 	/*
2227c478bd9Sstevel@tonic-gate 	 * enable large page support right here.
2237c478bd9Sstevel@tonic-gate 	 */
2247c478bd9Sstevel@tonic-gate 	if (x86_feature & X86_LARGEPAGE) {
2257c478bd9Sstevel@tonic-gate 		cr4_value |= CR4_PSE;
2267c478bd9Sstevel@tonic-gate 		if (x86_feature & X86_PGE)
2277c478bd9Sstevel@tonic-gate 			cr4_value |= CR4_PGE;
2287c478bd9Sstevel@tonic-gate 		setup_121_andcall(enable_big_page_support, cr4_value);
2297c478bd9Sstevel@tonic-gate 	}
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate 	/*
2327c478bd9Sstevel@tonic-gate 	 * Some i386 processors do not implement the rdtsc instruction,
2337c478bd9Sstevel@tonic-gate 	 * or at least they do not implement it correctly.
2347c478bd9Sstevel@tonic-gate 	 *
2357c478bd9Sstevel@tonic-gate 	 * For those that do, patch in the rdtsc instructions in
2367c478bd9Sstevel@tonic-gate 	 * various parts of the kernel right now while the text is
2377c478bd9Sstevel@tonic-gate 	 * still writable.
2387c478bd9Sstevel@tonic-gate 	 */
2397c478bd9Sstevel@tonic-gate 	if (x86_feature & X86_TSC)
2407c478bd9Sstevel@tonic-gate 		patch_tsc();
2417c478bd9Sstevel@tonic-gate #endif
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate 	/*
2447c478bd9Sstevel@tonic-gate 	 * initialize t0
2457c478bd9Sstevel@tonic-gate 	 */
2467c478bd9Sstevel@tonic-gate 	t0.t_stk = (caddr_t)rp - MINFRAME;
2477c478bd9Sstevel@tonic-gate 	t0.t_stkbase = t0stack;
2487c478bd9Sstevel@tonic-gate 	t0.t_pri = maxclsyspri - 3;
2497c478bd9Sstevel@tonic-gate 	t0.t_schedflag = TS_LOAD | TS_DONT_SWAP;
2507c478bd9Sstevel@tonic-gate 	t0.t_procp = &p0;
2517c478bd9Sstevel@tonic-gate 	t0.t_plockp = &p0lock.pl_lock;
2527c478bd9Sstevel@tonic-gate 	t0.t_lwp = &lwp0;
2537c478bd9Sstevel@tonic-gate 	t0.t_forw = &t0;
2547c478bd9Sstevel@tonic-gate 	t0.t_back = &t0;
2557c478bd9Sstevel@tonic-gate 	t0.t_next = &t0;
2567c478bd9Sstevel@tonic-gate 	t0.t_prev = &t0;
2577c478bd9Sstevel@tonic-gate 	t0.t_cpu = cpu[0];
2587c478bd9Sstevel@tonic-gate 	t0.t_disp_queue = &cpu0_disp;
2597c478bd9Sstevel@tonic-gate 	t0.t_bind_cpu = PBIND_NONE;
2607c478bd9Sstevel@tonic-gate 	t0.t_bind_pset = PS_NONE;
2617c478bd9Sstevel@tonic-gate 	t0.t_cpupart = &cp_default;
2627c478bd9Sstevel@tonic-gate 	t0.t_clfuncs = &sys_classfuncs.thread;
2637c478bd9Sstevel@tonic-gate 	t0.t_copyops = NULL;
2647c478bd9Sstevel@tonic-gate 	THREAD_ONPROC(&t0, CPU);
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate 	lwp0.lwp_thread = &t0;
2677c478bd9Sstevel@tonic-gate 	lwp0.lwp_regs = (void *) rp;
2687c478bd9Sstevel@tonic-gate 	lwp0.lwp_procp = &p0;
2697c478bd9Sstevel@tonic-gate 	t0.t_tid = p0.p_lwpcnt = p0.p_lwprcnt = p0.p_lwpid = 1;
2707c478bd9Sstevel@tonic-gate 
2717c478bd9Sstevel@tonic-gate 	p0.p_exec = NULL;
2727c478bd9Sstevel@tonic-gate 	p0.p_stat = SRUN;
2737c478bd9Sstevel@tonic-gate 	p0.p_flag = SSYS;
2747c478bd9Sstevel@tonic-gate 	p0.p_tlist = &t0;
2757c478bd9Sstevel@tonic-gate 	p0.p_stksize = 2*PAGESIZE;
2767c478bd9Sstevel@tonic-gate 	p0.p_stkpageszc = 0;
2777c478bd9Sstevel@tonic-gate 	p0.p_as = &kas;
2787c478bd9Sstevel@tonic-gate 	p0.p_lockp = &p0lock;
2797c478bd9Sstevel@tonic-gate 	p0.p_brkpageszc = 0;
2807c478bd9Sstevel@tonic-gate 	sigorset(&p0.p_ignore, &ignoredefault);
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate 	CPU->cpu_thread = &t0;
2837c478bd9Sstevel@tonic-gate 	bzero(&cpu0_disp, sizeof (disp_t));
2847c478bd9Sstevel@tonic-gate 	CPU->cpu_disp = &cpu0_disp;
2857c478bd9Sstevel@tonic-gate 	CPU->cpu_disp->disp_cpu = CPU;
2867c478bd9Sstevel@tonic-gate 	CPU->cpu_dispthread = &t0;
2877c478bd9Sstevel@tonic-gate 	CPU->cpu_idle_thread = &t0;
2887c478bd9Sstevel@tonic-gate 	CPU->cpu_flags = CPU_READY | CPU_RUNNING | CPU_EXISTS | CPU_ENABLE;
2897c478bd9Sstevel@tonic-gate 	CPU->cpu_dispatch_pri = t0.t_pri;
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate 	CPU->cpu_id = 0;
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate 	CPU->cpu_tss = &ktss0;
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate 	CPU->cpu_pri = 12;		/* initial PIL for the boot CPU */
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate 	CPU->cpu_gdt = gdt0;
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate 	/*
3000baeff3dSrab 	 * The kernel doesn't use LDTs unless a process explicitly requests one.
3017c478bd9Sstevel@tonic-gate 	 */
3020baeff3dSrab 	p0.p_ldt_desc = zero_sdesc;
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate 	/*
3057c478bd9Sstevel@tonic-gate 	 * Kernel IDT.
3067c478bd9Sstevel@tonic-gate 	 */
3077c478bd9Sstevel@tonic-gate 	CPU->cpu_idt = idt0;
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate 	/*
3107c478bd9Sstevel@tonic-gate 	 * Initialize thread/cpu microstate accounting here
3117c478bd9Sstevel@tonic-gate 	 */
3127c478bd9Sstevel@tonic-gate 	init_mstate(&t0, LMS_SYSTEM);
3137c478bd9Sstevel@tonic-gate 	init_cpu_mstate(CPU, CMS_SYSTEM);
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate 	/*
3167c478bd9Sstevel@tonic-gate 	 * Initialize lists of available and active CPUs.
3177c478bd9Sstevel@tonic-gate 	 */
3187c478bd9Sstevel@tonic-gate 	cpu_list_init(CPU);
3197c478bd9Sstevel@tonic-gate 
320affbd3ccSkchow 	cpu_vm_data_init(CPU);
321affbd3ccSkchow 
322c88420b3Sdmick 	/* lgrp_init() needs PCI config space access */
323c88420b3Sdmick 	pci_cfgspace_init();
324c88420b3Sdmick 
3257c478bd9Sstevel@tonic-gate 	/*
3267c478bd9Sstevel@tonic-gate 	 * Initialize the lgrp framework
3277c478bd9Sstevel@tonic-gate 	 */
3287c478bd9Sstevel@tonic-gate 	lgrp_init();
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate 	rp->r_fp = 0;	/* terminate kernel stack traces! */
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate 	prom_init("kernel", (void *)NULL);
3337c478bd9Sstevel@tonic-gate 
33441791439Sandrei 	boot_ncpus = bootprop_getval("boot-ncpus");
33541791439Sandrei 
33641791439Sandrei 	/*
33741791439Sandrei 	 * To avoid wasting kernel memory, we're temporarily limiting the
33841791439Sandrei 	 * total number of processors to 32 by default until we get the
33941791439Sandrei 	 * capability to scan ACPI tables early on boot to detect how many
34041791439Sandrei 	 * processors are actually present.  However, 64-bit systems
34141791439Sandrei 	 * can be booted with up to 64 processors by setting "boot-ncpus"
34241791439Sandrei 	 * boot property to 64.
34341791439Sandrei 	 */
34441791439Sandrei 	if (boot_ncpus <= 0 || boot_ncpus > NCPU)
34541791439Sandrei 		boot_ncpus = 32;
34641791439Sandrei 
34741791439Sandrei 	max_ncpus = boot_max_ncpus = boot_ncpus;
34841791439Sandrei 
3497c478bd9Sstevel@tonic-gate 	if (boothowto & RB_HALT) {
3507c478bd9Sstevel@tonic-gate 		prom_printf("unix: kernel halted by -h flag\n");
3517c478bd9Sstevel@tonic-gate 		prom_enter_mon();
3527c478bd9Sstevel@tonic-gate 	}
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate 	ASSERT_STACK_ALIGNED();
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate 	if (workaround_errata(CPU) != 0)
3577c478bd9Sstevel@tonic-gate 		panic("critical workaround(s) missing for boot cpu");
3587c478bd9Sstevel@tonic-gate }
359