Switch the loaders for x86, sparc64 and sparc32 over to use the new saved-program-state in boot() rather than try to execute the

device payload directly. This is the first stage in isolating the OF "load" and "go" words, and in preparation for moving the 
majority of the loaders into libopenbios.

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


git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@709 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Mark Cave-Ayland
2010-03-26 22:33:50 +00:00
committed by Mark Cave-Ayland
parent 8a6d445d38
commit 6dd0574272
14 changed files with 218 additions and 128 deletions

View File

@@ -9,7 +9,6 @@
#undef BOOTSTRAP
#include "config.h"
#include "libopenbios/bindings.h"
#include "libopenbios/elfload.h"
#include "arch/common/nvram.h"
#include "libc/diskio.h"
#include "libopenbios/sys_info.h"
@@ -17,6 +16,62 @@
struct sys_info sys_info;
static int try_path(const char *path, char *param)
{
ucell valid, address, type, size;
int image_retval = 0;;
/* ELF Boot loader */
elf_load(&sys_info, path, param);
feval("state-valid @");
valid = POP();
if (valid)
goto start_image;
/* Linux loader (not using Forth) */
linux_load(&sys_info, path, param);
/* Forth loader */
forth_load(&sys_info, path, param);
feval("state-valid @");
valid = POP();
if (valid)
goto start_image;
return 0;
start_image:
/* Get the entry point and the type (see forth/debugging/client.fs) */
feval("saved-program-state >sps.entry @");
address = POP();
feval("saved-program-state >sps.file-type @");
type = POP();
feval("saved-program-state >sps.file-size @");
size = POP();
printk("Jumping to entry point " FMT_ucellx " for type " FMT_ucellx "...\n", address, type);
switch (type) {
case 0x0:
/* Start ELF boot image */
image_retval = start_elf(address, (uint32_t)NULL);
break;
case 0x11:
/* Start Forth image */
PUSH(address);
PUSH(size);
fword("eval2");
image_retval = 0;
break;
}
printk("Image returned with return value %#x\n", image_retval);
return -1;
}
void boot(void)
{
char *path=pop_fstr_copy(), *param;
@@ -34,15 +89,9 @@ void boot(void)
printk("[x86] Booting file '%s' with parameters '%s'\n",path, param);
if (elf_load(&sys_info, path, param) != LOADER_NOT_SUPPORT)
goto loaded;
if (linux_load(&sys_info, path, param) != LOADER_NOT_SUPPORT)
goto loaded;
if (forth_load(&sys_info, path, param) != LOADER_NOT_SUPPORT)
goto loaded;
try_path(path, param);
printk("Unsupported image format\n");
loaded:
free(path);
}

View File

@@ -313,7 +313,6 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
unsigned short checksum = 0;
Elf_Bhdr *boot_notes = NULL;
int retval = -1;
int image_retval;
image_name = image_version = NULL;
@@ -379,7 +378,7 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
debug("entry point is %#x\n", ehdr.e_entry);
// Initialise saved-program-state
PUSH(ehdr.e_entry);
PUSH(ehdr.e_entry & ADDRMASK);
feval("saved-program-state >sps.entry !");
PUSH(file_size);
feval("saved-program-state >sps.file-size !");
@@ -387,11 +386,6 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
feval("-1 state-valid !");
printk("Jumping to entry point...\n");
image_retval = start_elf(ehdr.e_entry & ADDRMASK, virt_to_phys(boot_notes));
// console_init(); FIXME
printk("Image returned with return value %#x\n", image_retval);
retval = 0;
out:

View File

@@ -68,11 +68,6 @@ int forth_load(struct sys_info *info, const char *filename, const char *cmdline)
feval("-1 state-valid !");
PUSH ( (ucell)forthtext );
PUSH ( (ucell)forthsize );
fword("eval2");
retval=0;
out:
//if (forthtext)
// free(forthtext);