mlsetup.c revision d5d7cf4e084ada61ab475b433429da88487a6725
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/archsystm.h>
#include <sys/machsystm.h>
#include <sys/autoconf.h>
#include <sys/prom_plat.h>
#include <sys/promimpl.h>
#include <sys/platform_module.h>
#include <vm/hat_sfmmu.h>
#include <sys/sysmacros.h>
#include <sys/machtrap.h>
#include <sys/privregs.h>
#include <sys/cpu_module.h>
#include <sys/prom_debug.h>
#include <sys/traptrace.h>
#include <sys/kobj_impl.h>
#include <sys/kdi_machimpl.h>
/*
* External Routines:
*/
extern void map_wellknown_devices(void);
extern void hsvc_setup(void);
extern void mach_descrip_startup_init(void);
extern void mach_soft_state_init(void);
int dcache_size;
int dcache_linesize;
int icache_size;
int icache_linesize;
int ecache_size;
int ecache_alignsize;
int ecache_associativity;
int ecache_setsize; /* max possible e$ setsize */
int cpu_setsize; /* max e$ setsize of configured cpus */
int dcache_line_mask; /* spitfire only */
int vac_size; /* cache size in bytes */
int vac_shift; /* log2(vac_size) for ppmapout() */
int vac = 0; /* virtual address cache type (none == 0) */
/*
* fpRAS. An individual sun4* machine class (or perhaps subclass,
* the fpRAS feature. The feature can be suppressed by setting fpras_disable
* or the mechanism can be disabled for individual copy operations with
* fpras_disableids. All these are checked in post_startup() code so
* definitions will need to move up to the common level.
*/
int fpras_implemented;
int fpras_disable;
int fpras_disableids;
/*
* Static Routines:
*/
static void kern_splr_preprom(void);
static void kern_splx_postprom(void);
/*
* Setup routine called right before main(). Interposing this function
* before main() allows us to call it in a machine-independent fashion.
*/
void
{
extern char t0stack[];
extern struct classfuncs sys_classfuncs;
unsigned long long pa;
#ifdef TRAPTRACE
#endif /* TRAPTRACE */
/* drop into kmdb on boot -d */
if (boothowto & RB_DEBUGENTER)
kmdb_enter();
/*
* initialize cpu_self
*/
/*
* initialize t0
*/
/* Can't use va_to_pa here - wait until prom_ initialized */
p0.p_stkpageszc = 0;
p0.p_brkpageszc = 0;
/*
*/
/*
* Initialize lists of available and active CPUs.
*/
(void) prom_set_preprom(kern_splr_preprom);
(void) prom_set_postprom(kern_splx_postprom);
PRM_INFO("mlsetup: now ok to call prom_printf");
/*
* Claim the physical and virtual resources used by panicbuf,
* then map panicbuf. This operation removes the phys and
* virtual addresses from the free lists.
*/
prom_panic("Can't claim panicbuf virtual address");
prom_panic("Can't allocate retained panicbuf physical address");
prom_panic("Can't map panicbuf");
/*
* Negotiate hypervisor services, if any
*/
hsvc_setup();
#ifdef TRAPTRACE
/*
* initialize the trap trace buffer for the boot cpu
* XXX todo, dynamically allocate this buffer too
*/
#endif /* TRAPTRACE */
/*
* Initialize the Machine Description kernel framework
*/
/*
* initialize HV trap trace buffer for the boot cpu
*/
/*
* lgroup framework initialization. This must be done prior
* to devices being mapped.
*/
cpu_setup();
prom_printf("unix: kernel halted by -h flag\n");
}
setcputype();
setcpudelay();
}
/*
* These routines are called immediately before and
* immediately after calling into the firmware. The
* firmware is significantly confused by preemption -
* particularly on MP machines - but also on UP's too.
*/
static int saved_spl;
static void
kern_splr_preprom(void)
{
}
static void
kern_splx_postprom(void)
{
}
/*
* WARNING
* The code fom here to the end of mlsetup.c runs before krtld has
* knitted unix and genunix together. It can call routines in unix,
* but calls into genunix will fail spectacularly. More specifically,
* calls to prom_*, bop_* and str* will work, everything else is
* caveat emptor.
*
* Also note that while #ifdef sun4u is generally a bad idea, they
* exist here to concentrate the dangerous code into a single file.
*/
static char *
getcpulist(void)
{
/* big enough for OBP_NAME and for a reasonably sized OBP_COMPATIBLE. */
#ifdef sun4u
char dname[OBP_MAXDRVNAME];
#endif
prom_panic("no name in cpu node");
/* nlen includes the terminating null character */
#ifdef sun4v
#else /* sun4u */
/*
* For the CMT case, need check the parent "core"
* node for the compatible property.
*/
node != OBP_BADNODE &&
#endif
prom_panic("cpu node \"compatible\" too long");
/* read in compatible, leaving space for ':' */
prom_panic("cpu node \"compatible\" error");
/* convert all null characters to ':' */
clen--; /* except the final one... */
for (i = 0; i < clen; i++)
if (cpubuf[i] == '\0')
cpubuf[i] = ':';
}
#ifdef sun4u
/*
* Some PROMs return SUNW,UltraSPARC when they actually have
* SUNW,UltraSPARC-II cpus. SInce we're now filtering out all
* SUNW,UltraSPARC systems during the boot phase, we can safely
* point the auxv CPU value at SUNW,UltraSPARC-II.
*/
#endif
return (cpubuf);
} else
return (NULL);
}
/*
* called immediately from _start to stich the
* primary modules together
*/
void
kobj_start(void *cif)
{
int i;
bop_init();
#ifdef DEBUG
#endif
prom_panic("no ELF image");
for (i = 0; i < BA_NUM; i++)
break;
}
}
/* kernel stitched together; we can now test #pragma's */
if (&plat_setprop_enter != NULL) {
}
}
/*
* Create modpath from kernel name.
* If we booted:
* or
*
* then make the modpath:
* /platform/`uname -i`/kernel /platform/`uname -m`/kernel
*
* otherwise, make the modpath the dir the kernel was
* loaded from, minus any sparcv9 extension
*
* symlink is available as a shortcut.
*/
void
{
char *p;
const char prefix[] = "/platform/";
char platname[MAXPATHLEN];
#ifdef sun4u
char defname[] = "sun4u";
#else
char defname[] = "sun4v";
#endif
const char suffix[] = "/kernel";
const char isastr[] = "/sparcv9";
/*
* check for /platform
*/
p = (char *)fname;
goto nopath;
p += sizeof (prefix) - 1;
/*
* check for the default name or the platform name.
* also see if we used the 'compatible' name
* (platname == default)
*/
p += len;
p += sizeof (defname) - 1;
else
goto nopath;
/*
*/
goto nopath;
p += sizeof (suffix) - 1;
p += sizeof (isastr) - 1;
/*
* check we're at the last component
*/
goto nopath;
/*
* everything is kosher; setup modpath
*/
if (!compat) {
}
return;
/*
* Construct the directory path from the filename.
*/
return;
p--; /* remove trailing '/' characters */
if (p == fname)
p++; /* so "/" -is- the modpath in this case */
/*
* Remove optional isa-dependent directory name - the module
* subsystem will put this back again (!)
*/
sizeof (isastr) - 1) == 0)
p -= sizeof (isastr) - 1;
}