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

@@ -56,7 +56,6 @@ static int check_mem_ranges(struct sys_info *info,
int aout_load(struct sys_info *info, const char *filename, const void *romvec)
{
int retval = -1;
int image_retval;
struct exec ehdr;
unsigned long start, size;
unsigned int offset = 512;
@@ -134,18 +133,6 @@ int aout_load(struct sys_info *info, const char *filename, const void *romvec)
feval("-1 state-valid !");
printf("Jumping to entry point...\n");
#if 1
{
int (*entry)(const void *romvec_ptr, int p2, int p3, int p4, int p5);
entry = (void *) addr_fixup(start);
image_retval = entry(romvec, 0, 0, 0, 0);
}
#endif
printf("Image returned with return value %#x\n", image_retval);
retval = 0;
out:

View File

@@ -4,7 +4,6 @@
#undef BOOTSTRAP
#include "config.h"
#include "libopenbios/bindings.h"
#include "libopenbios/elfload.h"
#include "arch/common/nvram.h"
#include "drivers/drivers.h"
#include "libc/diskio.h"
@@ -19,25 +18,78 @@ uint32_t kernel_size;
uint32_t qemu_cmdline;
uint32_t cmdline_size;
char boot_device;
int (*entry)(const void *romvec_ptr, int p2, int p3, int p4, int p5);
static void try_path(const char *path, char *param, const void *romvec)
static int try_path(const char *path, char *param, const void *romvec)
{
ucell valid, address, type, size;
int image_retval = 0;
push_str(path);
fword("pathres-resolve-aliases");
bootpath = pop_fstr_copy();
printk("Trying %s (%s)\n", path, bootpath);
elf_load(&sys_info, path, param, romvec);
linux_load(&sys_info, path, param);
aout_load(&sys_info, path, romvec);
/* ELF Boot loader */
elf_load(&sys_info, path, param, romvec);
feval("state-valid @");
valid = POP();
if (valid)
goto start_image;
/* Linux loader (not using Forth) */
linux_load(&sys_info, path, param);
/* a.out loader */
aout_load(&sys_info, path, romvec);
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 */
entry = (void *) address;
image_retval = entry(romvec, 0, 0, 0, 0);
break;
case 0x5:
/* Start a.out image */
entry = (void *) address;
image_retval = entry(romvec, 0, 0, 0, 0);
break;
}
printk("Image returned with return value %#x\n", image_retval);
return -1;
}
void boot(void)
{
char *path = pop_fstr_copy(), *param, altpath[256];
const char *oldpath = path;
int unit = 0;
const void *romvec;
int result;
if(!path) {
push_str("boot-device");
@@ -102,8 +154,6 @@ void boot(void)
romvec = init_openprom();
if (kernel_size) {
int (*entry)(const void *romvec_ptr, int p2, int p3, int p4, int p5);
printk("[sparc] Kernel already loaded\n");
entry = (void *) kernel_image;
entry(romvec, 0, 0, 0, 0);
@@ -115,17 +165,19 @@ void boot(void)
else
printk("without parameters.\n");
try_path(path, param, romvec);
result = try_path(path, param, romvec);
if (!result) {
push_str(path);
PUSH(':');
fword("left-split");
snprintf(altpath, sizeof(altpath), "%s:d", pop_fstr_copy());
POP();
POP();
try_path(altpath, param, romvec);
}
push_str(path);
PUSH(':');
fword("left-split");
snprintf(altpath, sizeof(altpath), "%s:d", pop_fstr_copy());
POP();
POP();
try_path(altpath, param, romvec);
printk("Unsupported image format\n");
printk("Unsupported image format\n");
free(path);
}

View File

@@ -312,7 +312,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;
unsigned int offset;
image_name = image_version = NULL;
@@ -394,21 +393,6 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline,
feval("-1 state-valid !");
printf("Jumping to entry point...\n");
#if 1
{
int (*entry)(const void *romvec_ptr, int p2, int p3, int p4, int p5);
entry = (void *) addr_fixup(ehdr.e_entry);
image_retval = entry(romvec, 0, 0, 0, 0);
}
#else
image_retval = start_elf(addr_fixup(ehdr.e_entry), virt_to_phys(boot_notes));
#endif
// console_init(); FIXME
printf("Image returned with return value %#x\n", image_retval);
retval = 0;
out:

View File

@@ -68,9 +68,6 @@ int forth_load(const char *filename)
feval("-1 state-valid !");
PUSH ( (ucell)forthtext );
PUSH ( (ucell)forthsize );
fword("eval2");
retval=0;
out:

View File

@@ -57,7 +57,6 @@ static int check_mem_ranges(struct sys_info *info,
int aout_load(struct sys_info *info, const char *filename)
{
int retval = -1;
int image_retval;
struct exec ehdr;
unsigned long start, size;
unsigned int offset;
@@ -138,14 +137,6 @@ int aout_load(struct sys_info *info, const char *filename)
feval("-1 state-valid !");
printf("Jumping to entry point...\n");
{
extern int sparc64_of_client_interface( int *params );
image_retval = start_client_image(addr_fixup(start), (uint64_t)&sparc64_of_client_interface);
}
printf("Image returned with return value %#x\n", image_retval);
retval = 0;
out:

View File

@@ -4,7 +4,6 @@
#undef BOOTSTRAP
#include "config.h"
#include "libopenbios/bindings.h"
#include "libopenbios/elfload.h"
#include "arch/common/nvram.h"
#include "libc/diskio.h"
#include "libc/vsprintf.h"
@@ -17,16 +16,88 @@ uint64_t kernel_size;
uint64_t qemu_cmdline;
uint64_t cmdline_size;
char boot_device;
extern int sparc64_of_client_interface( int *params );
static int try_path(const char *path, char *param)
{
void *boot_notes = NULL;
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);
/* a.out loader */
aout_load(&sys_info, path);
feval("state-valid @");
valid = POP();
if (valid)
goto start_image;
/* Fcode loader */
fcode_load(path);
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, (uint64_t)boot_notes);
break;
case 0x5:
/* Start a.out image */
image_retval = start_client_image(address, (uint64_t)&sparc64_of_client_interface);
break;
case 0x10:
/* Start Fcode image */
printk("Evaluating FCode...\n");
PUSH(address);
PUSH(1);
fword("byte-load");
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;
char altpath[256];
int result;
if (kernel_size) {
void (*entry)(unsigned long p1, unsigned long p2, unsigned long p3,
unsigned long p4, unsigned long p5);
extern int sparc64_of_client_interface( int *params );
unsigned long p4, unsigned long p5);;
printk("[sparc64] Kernel already loaded\n");
entry = (void *) (unsigned long)kernel_image;
@@ -82,24 +153,13 @@ void boot(void)
else
printk("without parameters.\n");
result = try_path(path, param);
if (!result) {
snprintf(altpath, sizeof(altpath), "%s:f", path);
try_path(altpath, param);
}
if (elf_load(&sys_info, path, param) == LOADER_NOT_SUPPORT)
if (linux_load(&sys_info, path, param) == LOADER_NOT_SUPPORT)
if (aout_load(&sys_info, path) == LOADER_NOT_SUPPORT)
if (fcode_load(path) == LOADER_NOT_SUPPORT) {
snprintf(altpath, sizeof(altpath), "%s:f", path);
if (elf_load(&sys_info, altpath, param)
== LOADER_NOT_SUPPORT)
if (linux_load(&sys_info, altpath, param)
== LOADER_NOT_SUPPORT)
if (aout_load(&sys_info, altpath)
== LOADER_NOT_SUPPORT)
if (fcode_load(altpath)
== LOADER_NOT_SUPPORT)
printk("Unsupported image format\n");
}
printk("Unsupported image format\n");
free(path);
}

View File

@@ -311,7 +311,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;
unsigned int offset;
image_name = image_version = NULL;
@@ -393,27 +392,6 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
feval("-1 state-valid !");
printf("Jumping to entry point...\n");
#if 0
{
extern unsigned int qemu_mem_size;
extern char boot_device;
void *init_openprom(unsigned long memsize, const char *cmdline, char boot_device);
int (*entry)(const void *romvec, int p2, int p3, int p4, int p5);
const void *romvec;
romvec = init_openprom(qemu_mem_size, cmdline, boot_device);
entry = (void *) addr_fixup(ehdr.e_entry);
image_retval = entry(romvec, 0, 0, 0, 0);
}
#else
image_retval = start_elf(addr_fixup(ehdr.e_entry), virt_to_phys(boot_notes));
#endif
// console_init(); FIXME
printf("Image returned with return value %#x\n", image_retval);
retval = 0;
out:

View File

@@ -74,11 +74,7 @@ int fcode_load(const char *filename)
feval("saved-program-state >sps.file-size !");
feval("fcode saved-program-state >sps.file-type !");
printf("Evaluating FCode...\n");
PUSH(start);
PUSH(1);
fword("byte-load");
feval("-1 state-valid !");
retval = 0;

View File

@@ -68,9 +68,6 @@ int forth_load(const char *filename)
feval("-1 state-valid !");
PUSH ( (ucell)forthtext );
PUSH ( (ucell)forthsize );
fword("eval2");
retval=0;
out:

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);

View File

@@ -35,6 +35,11 @@ typedef uint32_t ucell;
typedef long long dcell;
typedef unsigned long long ducell;
#define FMT_cell "%ld"
#define FMT_ucell "%lu"
#define FMT_ucellx "%08x"
#define FMT_ucellX "%08X"
#define bitspercell (sizeof(cell)<<3)
#define bitsperdcell (sizeof(dcell)<<3)

View File

@@ -24,6 +24,11 @@ typedef uint32_t ucell;
typedef int64_t dcell;
typedef uint64_t ducell;
#define FMT_cell "%ld"
#define FMT_ucell "%lu"
#define FMT_ucellx "%08x"
#define FMT_ucellX "%08X"
#define bitspercell (sizeof(cell)<<3)
#define bitsperdcell (sizeof(dcell)<<3)