mlsetup.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/x86_archext.h>
#include <sys/privregs.h>
#include <sys/machsystm.h>
#include <sys/bootconf.h>
#include <sys/archsystm.h>
#include <sys/bootconf.h>
#include <sys/kobj_lex.h>
#if defined(__amd64)
#include <sys/bootsvcs.h>
/*
* XX64 This stuff deals with switching stacks in case a trapping
* thread wants to call back into boot -after- boot has lost track
* of the mappings but before the kernel owns the console.
*
* (A better way to hide this would be to add a 'this' pointer to
* every boot syscall so that vmx could get at the resulting save
* area.)
*/
struct boot_syscalls *_vmx_sysp;
static struct boot_syscalls __kbootsvcs;
extern struct boot_syscalls *sysp;
extern void _stack_safe_putchar(int c);
#endif
/*
* some globals for patching the result of cpuid
* to solve problems w/ creative cpu vendors
*/
extern uint32_t cpuid_feature_ecx_include;
extern uint32_t cpuid_feature_ecx_exclude;
extern uint32_t cpuid_feature_edx_include;
extern uint32_t cpuid_feature_edx_exclude;
/*
* External Routines:
*/
extern void init_tables(void);
static uint32_t
cpuid_getval(char *name)
{
char prop[32];
return (0);
}
/*
* Setup routine called right before main(). Interposing this function
* before main() allows us to call it in a machine-independent fashion.
*/
void
{
extern struct classfuncs sys_classfuncs;
extern char t0stack[];
#if defined(__amd64)
#if (BS_VERSION > 4)
/*
* When new boot_syscalls are added to the vector, this routine
* must be modified to copy them into the kernel's copy of the
* vector.
*/
#endif /* (BS_VERSION > 4) */
/*
* XX64 This remaps vmx's putchar to use the kernel's version
* that switches stacks before diving into vmx
* See explanation/complaints in commentary above.
*/
sysp = &__kbootsvcs;
#endif
/*
* initialize cpu_self
*/
/*
* check if we've got special bits to clear or set
* when checking cpu features
*/
cpuid_getval("cpuid_feature_ecx_include");
cpuid_getval("cpuid_feature_ecx_exclude");
cpuid_getval("cpuid_feature_edx_include");
cpuid_getval("cpuid_feature_edx_exclude");
/*
* The first lightweight pass (pass0) through the cpuid data
* was done in locore before mlsetup was called. Do the next
* pass in C code.
*
* The x86_feature bits are set here on the basis of the capabilities
* of the boot CPU. Note that if we choose to support CPUs that have
* different feature sets (at which point we would almost certainly
* want to set the feature bits to correspond to the feature
* minimum) this value may be altered.
*/
/*
* Initialize idt0, gdt0, ldt0_default, ktss0 and dftss.
*/
init_tables();
#if defined(__amd64)
/*CSTYLED*/
{
/*
* setup %gs for the kernel
*/
/*
* XX64 We should never dereference off "other gsbase" or
* "fsbase". So, we should arrange to point FSBASE and
* KGSBASE somewhere truly awful e.g. point it at the last
* valid address below the hole so that any attempts to index
* off them cause an exception.
*
* For now, point it at 8G -- at least it should be unmapped
* until some 64-bit processes run.
*/
addr64 = 0x200000000ul;
}
/*
* enable large page support right here.
*/
if (x86_feature & X86_LARGEPAGE) {
if (x86_feature & X86_PGE)
}
/*
* Some i386 processors do not implement the rdtsc instruction,
* or at least they do not implement it correctly.
*
* For those that do, patch in the rdtsc instructions in
* various parts of the kernel right now while the text is
* still writable.
*/
if (x86_feature & X86_TSC)
patch_tsc();
#endif
/*
* initialize t0
*/
p0.p_stkpageszc = 0;
p0.p_brkpageszc = 0;
/*
* This must be done _after_ init_tables(), called above, has set up
* ldt0_default_desc.
*/
#if defined(__amd64)
/*
* ldt0_default64 contains all invalid entries. We use that as p0's LDT
* because p0 should never have any reason to use the LDT. This will
* catch things early if such a scenario should ever occur.
*/
#else
#endif /* __amd64 */
/*
* Kernel IDT.
*/
/*
*/
/*
* Initialize lists of available and active CPUs.
*/
/*
* Initialize the lgrp framework
*/
lgrp_init();
/*
* The lgroup code needs to at least know about a CPU's
* chip association, but it's too early to fully initialize
* cpu0_chip, since the device node for the boot CPU doesn't
* exist yet. Initialize enough of it to get by until formal
* initialization.
*/
prom_printf("unix: kernel halted by -h flag\n");
}
if (workaround_errata(CPU) != 0)
panic("critical workaround(s) missing for boot cpu");
}