mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
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:
committed by
Mark Cave-Ayland
parent
f4564e0dc0
commit
f9bdcf050c
@@ -8,10 +8,6 @@
|
||||
#include "libc/diskio.h"
|
||||
#include "libc/vsprintf.h"
|
||||
#include "libopenbios/sys_info.h"
|
||||
#include "libopenbios/elf_load.h"
|
||||
#include "libopenbios/aout_load.h"
|
||||
#include "libopenbios/fcode_load.h"
|
||||
#include "libopenbios/forth_load.h"
|
||||
#include "boot.h"
|
||||
|
||||
uint64_t kernel_image;
|
||||
@@ -19,68 +15,10 @@ uint64_t kernel_size;
|
||||
uint64_t qemu_cmdline;
|
||||
uint64_t cmdline_size;
|
||||
char boot_device;
|
||||
void *boot_notes = NULL;
|
||||
void *elf_boot_notes = NULL;
|
||||
extern int sparc64_of_client_interface( int *params );
|
||||
|
||||
|
||||
static int try_path(const char *path, char *param)
|
||||
{
|
||||
ucell valid;
|
||||
ihandle_t dev;
|
||||
|
||||
/* Open device used by this path */
|
||||
dev = open_dev(path);
|
||||
|
||||
#ifdef CONFIG_LOADER_ELF
|
||||
/* ELF Boot loader */
|
||||
elf_load(&sys_info, path, param, &boot_notes);
|
||||
feval("state-valid @");
|
||||
valid = POP();
|
||||
if (valid)
|
||||
goto start_image;
|
||||
#endif
|
||||
|
||||
/* Linux loader (not using Forth) */
|
||||
linux_load(&sys_info, path, param);
|
||||
|
||||
#ifdef CONFIG_LOADER_AOUT
|
||||
/* a.out loader */
|
||||
aout_load(&sys_info, dev);
|
||||
feval("state-valid @");
|
||||
valid = POP();
|
||||
if (valid)
|
||||
goto start_image;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOADER_FCODE
|
||||
/* Fcode loader */
|
||||
fcode_load(dev);
|
||||
feval("state-valid @");
|
||||
valid = POP();
|
||||
if (valid)
|
||||
goto start_image;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOADER_FORTH
|
||||
/* Forth loader */
|
||||
forth_load(dev);
|
||||
feval("state-valid @");
|
||||
valid = POP();
|
||||
if (valid)
|
||||
goto start_image;
|
||||
#endif
|
||||
|
||||
close_dev(dev);
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
start_image:
|
||||
go();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void go(void)
|
||||
{
|
||||
ucell address, type, size;
|
||||
@@ -99,7 +37,7 @@ void go(void)
|
||||
switch (type) {
|
||||
case 0x0:
|
||||
/* Start ELF boot image */
|
||||
image_retval = start_elf(address, (uint64_t)&boot_notes);
|
||||
image_retval = start_elf(address, (uint64_t)&elf_boot_notes);
|
||||
break;
|
||||
|
||||
case 0x1:
|
||||
@@ -136,19 +74,23 @@ void go(void)
|
||||
|
||||
void boot(void)
|
||||
{
|
||||
char *path=pop_fstr_copy(), *param;
|
||||
char altpath[256];
|
||||
int result;
|
||||
char *path, *param;
|
||||
|
||||
/* Copy the incoming path */
|
||||
fword("2dup");
|
||||
path = pop_fstr_copy();
|
||||
|
||||
/* Boot preloaded kernel */
|
||||
if (kernel_size) {
|
||||
void (*entry)(unsigned long p1, unsigned long p2, unsigned long p3,
|
||||
unsigned long p4, unsigned long p5);;
|
||||
unsigned long p4, unsigned long p5);
|
||||
|
||||
printk("[sparc64] Kernel already loaded\n");
|
||||
entry = (void *) (unsigned long)kernel_image;
|
||||
entry(0, 0, 0, 0, (unsigned long)&sparc64_of_client_interface);
|
||||
}
|
||||
|
||||
/* Invoke Linux directly -- probably not supported */
|
||||
if(!path) {
|
||||
/* No path specified, so grab defaults from /chosen */
|
||||
push_str("bootpath");
|
||||
@@ -175,20 +117,9 @@ void boot(void)
|
||||
POP();
|
||||
param = pop_fstr_copy();
|
||||
}
|
||||
|
||||
printk("[sparc64] Booting file '%s' ", path);
|
||||
if (param)
|
||||
printk("with parameters '%s'\n", param);
|
||||
else
|
||||
printk("without parameters.\n");
|
||||
|
||||
result = try_path(path, param);
|
||||
if (!result) {
|
||||
snprintf(altpath, sizeof(altpath), "%s:f", path);
|
||||
try_path(altpath, param);
|
||||
}
|
||||
|
||||
printk("Unsupported image format\n");
|
||||
|
||||
/* Invoke platform-specific Linux loader */
|
||||
linux_load(&sys_info, path, param);
|
||||
|
||||
free(path);
|
||||
}
|
||||
|
||||
@@ -618,6 +618,12 @@ int linux_load(struct sys_info *info, const char *file, const char *cmdline)
|
||||
return LOADER_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
debug("[sparc64] Booting kernel '%s' ", file);
|
||||
if (cmdline)
|
||||
debug("with parameters '%s'\n", cmdline);
|
||||
else
|
||||
debug("without parameters.\n");
|
||||
|
||||
params = phys_to_virt(LINUX_PARAM_LOC);
|
||||
init_linux_params(params, &hdr);
|
||||
set_memory_size(params, info);
|
||||
|
||||
@@ -374,7 +374,6 @@ void arch_nvram_get(char *data)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
const struct cpudef *cpu;
|
||||
const char *bootpath;
|
||||
char buf[256];
|
||||
uint32_t temp;
|
||||
uint64_t ram_size;
|
||||
@@ -492,34 +491,15 @@ void arch_nvram_get(char *data)
|
||||
push_str("boot-device");
|
||||
fword("property");
|
||||
|
||||
push_str(obio_cmdline);
|
||||
fword("encode-string");
|
||||
push_str("boot-file");
|
||||
fword("property");
|
||||
|
||||
/* Set up other properties */
|
||||
push_str("/chosen");
|
||||
fword("find-device");
|
||||
|
||||
if (boot_device == 'c')
|
||||
bootpath = "disk:a";
|
||||
else
|
||||
bootpath = "cdrom:a";
|
||||
push_str(bootpath);
|
||||
fword("encode-string");
|
||||
push_str("bootpath");
|
||||
fword("property");
|
||||
|
||||
/* bootpath/bootargs should be set to NVRAM default */
|
||||
fword("boot-device");
|
||||
fword("encode-string");
|
||||
push_str("bootpath");
|
||||
fword("property");
|
||||
fword("boot-args");
|
||||
fword("encode-string");
|
||||
push_str("bootargs");
|
||||
fword("property");
|
||||
|
||||
push_str(obio_cmdline);
|
||||
fword("encode-string");
|
||||
push_str("bootargs");
|
||||
fword("property");
|
||||
|
||||
if (fw_cfg_read_i16(FW_CFG_NOGRAPHIC)) {
|
||||
stdin_path = stdout_path = "ttya";
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user