Fix NetBSD booting

git-svn-id: svn://coreboot.org/openbios/openbios-devel@278 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Blue Swirl
2008-12-01 18:04:16 +00:00
parent c77259ec3a
commit 1b49d198f1
4 changed files with 33 additions and 29 deletions

View File

@@ -57,23 +57,20 @@ int aout_load(struct sys_info *info, const char *filename, const void *romvec)
int image_retval;
struct exec ehdr;
unsigned long start, size;
unsigned int offset;
unsigned int offset = 512;
image_name = image_version = NULL;
if (!file_open(filename))
goto out;
for (offset = 0; offset < 16 * 512; offset += 512) {
file_seek(offset);
if (lfile_read(&ehdr, sizeof ehdr) != sizeof ehdr) {
debug("Can't read a.out header\n");
retval = LOADER_NOT_SUPPORT;
goto out;
}
if (!N_BADMAG(ehdr))
break;
}
if (N_BADMAG(ehdr)) {
debug("Not a bootable a.out image\n");

View File

@@ -20,6 +20,18 @@ uint32_t qemu_cmdline;
uint32_t cmdline_size;
char boot_device;
static void try_path(const char *path, char *param, const void *romvec)
{
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);
}
void boot(void)
{
char *path = pop_fstr_copy(), *param, *oldpath = path;
@@ -87,7 +99,7 @@ void boot(void)
obp_arg.argv[1] = param;
}
romvec = init_openprom(qemu_mem_size, path);
romvec = init_openprom(qemu_mem_size);
if (kernel_size) {
int (*entry)(const void *romvec_ptr, int p2, int p3, int p4, int p5);
@@ -103,20 +115,17 @@ void boot(void)
else
printk("without parameters.\n");
if (elf_load(&sys_info, path, param, romvec) == LOADER_NOT_SUPPORT)
if (linux_load(&sys_info, path, param) == LOADER_NOT_SUPPORT)
if (aout_load(&sys_info, path, romvec) == LOADER_NOT_SUPPORT) {
try_path(path, param, romvec);
snprintf(altpath, sizeof(altpath), "%s:d", path);
push_str(path);
PUSH(':');
fword("left-split");
snprintf(altpath, sizeof(altpath), "%s:d", pop_fstr_copy());
POP();
POP();
if (elf_load(&sys_info, altpath, param, romvec)
== LOADER_NOT_SUPPORT)
if (linux_load(&sys_info, altpath, param)
== LOADER_NOT_SUPPORT)
if (aout_load(&sys_info, altpath, romvec)
== LOADER_NOT_SUPPORT)
try_path(altpath, param, romvec);
printk("Unsupported image format\n");
}
free(path);
}

View File

@@ -24,10 +24,11 @@ extern struct context *__context;
unsigned int start_elf(unsigned long entry_point, unsigned long param);
// romvec.c
void *init_openprom(unsigned long memsize, const char *path);
void *init_openprom(unsigned long memsize);
// boot.c
extern struct sys_info sys_info;
extern const char *bootpath;
void boot(void);
// sys_info.c

View File

@@ -49,7 +49,7 @@ static int obp_devread(int dev_desc, char *buf, int nbytes);
static int obp_devseek(int dev_desc, int hi, int lo);
struct linux_arguments_v0 obp_arg;
static const char *bootpath;
const char *bootpath;
static const struct linux_arguments_v0 * const obp_argp = &obp_arg;
static void (*sync_hook)(void);
@@ -501,7 +501,7 @@ static void obp_fortheval_v2(char *str)
}
void *
init_openprom(unsigned long memsize, const char *path)
init_openprom(unsigned long memsize)
{
ptphys = totphys;
ptmap = totmap;
@@ -559,9 +559,6 @@ init_openprom(unsigned long memsize, const char *path)
romvec0.pv_v2devops.v2_dev_write = obp_devwrite;
romvec0.pv_v2devops.v2_dev_seek = obp_devseek;
push_str(path);
fword("pathres-resolve-aliases");
bootpath = pop_fstr_copy();
romvec0.pv_v2bootargs.bootpath = &bootpath;
romvec0.pv_v2bootargs.bootargs = &obp_arg.argv[1];