Rework the OpenBIOS internals so that boot, load and init-program now all use the unified libopenbios loader code with improved

IEEE-1275 spec compliance.

This patch implements the following:

1) Fix bootpath/bootargs handling so that default values are read from NVRAM, and allow multiple space-separated values to be 
specified.
2) With correct bootargs handling in place, move the ELF loader over to the new libopenbios unified loaders.
3) Remove all the loader code from all architecture directories sine we don't need it anymore.
4) Simplify the boot word so it invokes platform-specific code where required, then calls load and go as per the specification.

Tested on all my available images for SPARC32, SPARC64 and PPC, and compile-tested on x86.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>


git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@828 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Mark Cave-Ayland
2010-08-01 15:13:48 +00:00
committed by Mark Cave-Ayland
parent f4564e0dc0
commit f9bdcf050c
15 changed files with 253 additions and 463 deletions

View File

@@ -39,16 +39,9 @@
#define ELF_DPRINTF(fmt, args...) SUBSYS_DPRINTF("ELF", fmt, ##args)
#define NEWWORLD_DPRINTF(fmt, args...) SUBSYS_DPRINTF("NEWWORLD", fmt, ##args)
static void
load(const char *path, const char *param)
{
char buffer[1024];
if (param)
sprintf(buffer, "load %s %s", path, param);
else
sprintf(buffer, "load %s", path);
feval(buffer);
}
struct sys_info sys_info;
void *elf_boot_notes = NULL;
static char *
get_device( const char *path )
@@ -115,6 +108,7 @@ get_filename( const char * path , char **dirname)
return filename;
}
static void
encode_bootpath( const char *spec, const char *args )
{
@@ -123,6 +117,9 @@ encode_bootpath( const char *spec, const char *args )
char *filename, *directory;
int partition;
if (spec)
return;
filename = get_filename(spec, &directory);
partition = get_partition(spec);
if (partition == -1)
@@ -138,28 +135,6 @@ encode_bootpath( const char *spec, const char *args )
set_property( chosen_ph, "bootargs", args, strlen(args)+1 );
}
/************************************************************************/
/* qemu booting */
/************************************************************************/
static void
try_path(const char *device, const char* filename, const char *param)
{
char path[1024];
if (filename)
snprintf(path, sizeof(path), "%s%s", device, filename);
else
snprintf(path, sizeof(path), "%s", device);
ELF_DPRINTF("Trying %s %s\n", path, param);
load(path, param);
update_nvram();
ELF_DPRINTF("Transfering control to %s %s\n",
path, param);
feval("go");
}
#define OLDWORLD_BOOTCODE_BASEADDR (0x3f4000)
static void
@@ -203,46 +178,6 @@ oldworld_boot( void )
return;
}
static void
newworld_boot( void )
{
static const char * const chrp_path[] = { "\\\\:tbxi",
"ppc\\bootinfo.txt",
NULL
};
char *path = pop_fstr_copy(), *param;
int i;
param = strchr(path, ' ');
if (param) {
*param = 0;
param++;
}
if (!path) {
NEWWORLD_DPRINTF("Entering boot, no path\n");
/* No path specified, so grab defaults from /chosen */
push_str("bootpath");
push_str("/chosen");
fword("(find-dev)");
POP();
fword("get-package-property");
POP();
path = pop_fstr_copy();
for (i = 0; chrp_path[i]; i++)
try_path(path, chrp_path[i], param);
} else {
NEWWORLD_DPRINTF("Entering boot, path %s\n", path);
try_path(path, NULL, param);
for (i = 0; chrp_path[i]; i++)
try_path(path, chrp_path[i], param);
}
printk("*** Boot failure! No secondary bootloader specified ***\n");
}
static void check_preloaded_kernel(void)
{
unsigned long kernel_image, kernel_size;
@@ -281,8 +216,10 @@ boot( void )
if (boot_device == 'm') {
check_preloaded_kernel();
}
if (boot_device == 'c') {
oldworld_boot();
}
newworld_boot();
update_nvram();
}