Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3742 → Rev 3743

/branches/sparc/boot/arch/sparc64/loader/main.c
56,8 → 56,8
char *timestamp = "";
#endif
 
/** UltraSPARC subarchitecture - 1 for US, 3 for US3 */
uint8_t subarchitecture;
/** UltraSPARC subarchitecture - 1 for US, 3 for US3, 0 for other */
uint8_t subarchitecture = 0;
 
/**
* mask of the MID field inside the ICBUS_CONFIG register shifted by
82,8 → 82,51
/* UltraSPARC IIIi processor implementation code */
#define US_IIIi_CODE 0x15
 
/* max. length of the "compatible" property of the root node */
#define COMPATIBLE_PROP_MAXLEN 64
 
/*
* HelenOS bootloader will use these constants to distinguish particular
* UltraSPARC architectures
*/
#define COMPATIBLE_SUN4U 10
#define COMPATIBLE_SUN4V 20
 
/** US architecture. COMPATIBLE_SUN4U for sun4v, COMPATIBLE_SUN4V for sun4u */
static uint8_t architecture;
 
/**
* Sets the global variables "subarchitecture" and "mid_mask" to
* Detects the UltraSPARC architecture (sun4u and sun4v currently supported)
* by inspecting the property called "compatible" in the OBP root node.
*/
static void detect_architecture(void)
{
phandle root = ofw_find_device("/");
char compatible[COMPATIBLE_PROP_MAXLEN];
 
if (ofw_get_property(root, "compatible", compatible,
COMPATIBLE_PROP_MAXLEN) <= 0) {
printf("Unable to determine architecture, default: sun4u.\n");
architecture = COMPATIBLE_SUN4U;
return;
}
 
if (strcmp(compatible, "sun4v") == 0) {
architecture = COMPATIBLE_SUN4V;
} else {
/*
* As not all sun4u machines have "sun4u" in their "compatible"
* OBP property (e.g. Serengeti's OBP "compatible" property is
* "SUNW,Serengeti"), we will by default fallback to sun4u if
* an unknown value of the "compatible" property is encountered.
*/
architecture = COMPATIBLE_SUN4U;
}
}
 
/**
* Detects the subarchitecture (US, US3) of the sun4u
* processor. Sets the global variables "subarchitecture" and "mid_mask" to
* correct values.
*/
static void detect_subarchitecture(void)
106,6 → 149,36
}
}
 
/**
* Performs sun4u-specific initialization. The components are expected
* to be already copied and boot allocator initialized.
*/
static void bootstrap_sun4u(void)
{
printf("\nCanonizing OpenFirmware device tree...");
bootinfo.ofw_root = ofw_tree_build();
printf("done.\n");
 
detect_subarchitecture();
 
#ifdef CONFIG_SMP
printf("\nChecking for secondary processors...");
if (!ofw_cpu())
printf("Error: unable to get CPU properties\n");
printf("done.\n");
#endif
 
setup_palette();
}
 
/**
* Performs sun4v-specific initialization. The components are expected
* to be already copied and boot allocator initialized.
*/
static void bootstrap_sun4v(void)
{
}
 
void bootstrap(void)
{
void *base = (void *) KERNEL_VIRTUAL_ADDRESS;
113,9 → 186,7
unsigned int top = 0;
int i, j;
 
version_print();
detect_subarchitecture();
detect_architecture();
init_components(components);
 
if (!ofw_get_physmem_start(&bootinfo.physmem_start)) {
256,19 → 327,16
(void) ofw_map(balloc_base, balloc_base, BALLOC_MAX_SIZE, -1);
balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base);
 
printf("\nCanonizing OpenFirmware device tree...");
bootinfo.ofw_root = ofw_tree_build();
printf("done.\n");
/* perform architecture-specific initialization */
if (architecture == COMPATIBLE_SUN4U) {
bootstrap_sun4u();
} else if (architecture == COMPATIBLE_SUN4V) {
bootstrap_sun4v();
} else {
printf("Unknown architecture.\n");
halt();
}
 
#ifdef CONFIG_SMP
printf("\nChecking for secondary processors...");
if (!ofw_cpu())
printf("Error: unable to get CPU properties\n");
printf("done.\n");
#endif
 
setup_palette();
 
printf("\nBooting the kernel...\n");
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS,
bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo,