loader: implement new loader type for CHRP/Apple partition bootcode (%BOOT)
One of the primary reasons that issues with the quik bootloader were not detected earlier was because arch/ppc/qemu/main.c has a separate code path for forcing an old-world boot when -boot c is passed to QEMU. This commit implements the bootcode loader as a core OpenBIOS loader which enables old-world payloads such as quik to be executed using: load hd:,%BOOT go Note that we also fix a bug in mac-parts.c to ensure that we don't try and interpose a filesystem package when %BOOT is passed as a filename. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> CC: Alexander Graf <agraf@suse.de> CC: Andreas Färber <afaerber@suse.de> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@1105 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
parent
5f3211f652
commit
59f6bd12ba
|
@ -26,6 +26,7 @@
|
|||
<option name="CONFIG_VGA_DEPTH" type="integer" value="8"/>
|
||||
<option name="CONFIG_LOADER_AOUT" type="boolean" value="false"/>
|
||||
<option name="CONFIG_LOADER_BOOTINFO" type="boolean" value="true"/>
|
||||
<option name="CONFIG_LOADER_BOOTCODE" type="boolean" value="true"/>
|
||||
<option name="CONFIG_LOADER_ELF" type="boolean" value="true"/>
|
||||
<option name="CONFIG_LOADER_FCODE" type="boolean" value="false"/>
|
||||
<option name="CONFIG_LOADER_FORTH" type="boolean" value="false"/>
|
||||
|
|
|
@ -27,6 +27,9 @@ create saved-program-state saved-program-state.size allot
|
|||
variable state-valid
|
||||
0 state-valid !
|
||||
|
||||
variable want-bootcode
|
||||
0 want-bootcode !
|
||||
|
||||
variable file-size
|
||||
|
||||
: !load-size file-size ! ;
|
||||
|
@ -44,6 +47,7 @@ variable file-size
|
|||
5 constant aout
|
||||
10 constant fcode
|
||||
11 constant forth
|
||||
12 constant bootcode
|
||||
|
||||
|
||||
: init-program ( -- )
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Creation Date: <2010/03/22 18:00:00 mcayland>
|
||||
* Time-stamp: <2010/03/22 18:00:00 mcayland>
|
||||
*
|
||||
* <bootcode_load.h>
|
||||
*
|
||||
* Raw bootcode (%BOOT) loader
|
||||
*
|
||||
* Copyright (C) 2013 Mark Cave-Ayland (mark.cave-ayland@ilande.co.uk)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_BOOTCODELOAD
|
||||
#define _H_BOOTCODELOAD
|
||||
|
||||
extern int bootcode_load(ihandle_t dev);
|
||||
|
||||
#endif /* _H__H_BOOTCODELOAD */
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Raw bootcode loader (CHRP/Apple %BOOT)
|
||||
* Written by Mark Cave-Ayland 2013
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "kernel/kernel.h"
|
||||
#include "libopenbios/bindings.h"
|
||||
#include "libopenbios/bootcode_load.h"
|
||||
#include "libc/diskio.h"
|
||||
#include "drivers/drivers.h"
|
||||
#define printf printk
|
||||
#define debug printk
|
||||
|
||||
#define OLDWORLD_BOOTCODE_BASEADDR (0x3f4000)
|
||||
|
||||
int
|
||||
bootcode_load(ihandle_t dev)
|
||||
{
|
||||
int retval = -1, count = 0, fd;
|
||||
unsigned long bootcode, loadbase, offset;
|
||||
|
||||
/* Mark the saved-program-state as invalid */
|
||||
feval("0 state-valid !");
|
||||
|
||||
fd = open_ih(dev);
|
||||
if (fd == -1) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Default to loading at load-base */
|
||||
fword("load-base");
|
||||
loadbase = POP();
|
||||
|
||||
#ifdef CONFIG_PPC
|
||||
/* However Old World Macs need to load to a different address */
|
||||
if (is_oldworld()) {
|
||||
loadbase = OLDWORLD_BOOTCODE_BASEADDR;
|
||||
}
|
||||
#endif
|
||||
|
||||
bootcode = loadbase;
|
||||
offset = 0;
|
||||
|
||||
while(1) {
|
||||
if (seek_io(fd, offset) == -1)
|
||||
break;
|
||||
count = read_io(fd, (void *)bootcode, 512);
|
||||
offset += count;
|
||||
bootcode += count;
|
||||
}
|
||||
|
||||
/* If we didn't read anything then exit */
|
||||
if (!count) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Initialise saved-program-state */
|
||||
PUSH(loadbase);
|
||||
feval("saved-program-state >sps.entry !");
|
||||
PUSH(offset);
|
||||
feval("saved-program-state >sps.file-size !");
|
||||
feval("bootcode saved-program-state >sps.file-type !");
|
||||
|
||||
feval("-1 state-valid !");
|
||||
|
||||
out:
|
||||
close_io(fd);
|
||||
return retval;
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
<library name="openbios" type="static" target="target">
|
||||
<object source="aout_load.c" condition="LOADER_AOUT"/>
|
||||
<object source="bindings.c"/>
|
||||
<object source="bootcode_load.c" condition="LOADER_BOOTCODE"/>
|
||||
<object source="bootinfo_load.c" condition="LOADER_BOOTINFO"/>
|
||||
<object source="client.c"/>
|
||||
<object source="console_common.c"/>
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
#include "libopenbios/forth_load.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOADER_BOOTCODE
|
||||
#include "libopenbios/bootcode_load.h"
|
||||
#endif
|
||||
|
||||
|
||||
struct sys_info sys_info;
|
||||
void *elf_boot_notes = NULL;
|
||||
|
@ -92,4 +96,13 @@ void load(ihandle_t dev)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOADER_BOOTCODE
|
||||
/* Check for a "raw" %BOOT bootcode payload */
|
||||
feval("want-bootcode @");
|
||||
valid = POP();
|
||||
if (valid) {
|
||||
bootcode_load(dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -89,8 +89,12 @@ macparts_open( macparts_info_t *di )
|
|||
parnum = atol(parstr);
|
||||
|
||||
/* Detect if we are looking for the bootcode */
|
||||
if (strcmp(argstr, "%BOOT") == 0)
|
||||
if (strcmp(argstr, "%BOOT") == 0) {
|
||||
want_bootcode = 1;
|
||||
feval("1 want-bootcode !");
|
||||
} else {
|
||||
feval("0 want-bootcode !");
|
||||
}
|
||||
}
|
||||
|
||||
DPRINTF("parstr: %s argstr: %s parnum: %d\n", parstr, argstr, parnum);
|
||||
|
@ -286,15 +290,9 @@ macparts_open( macparts_info_t *di )
|
|||
set_property(chosen_ph, "bootpath", bootpath, strlen(bootpath) + 1);
|
||||
}
|
||||
|
||||
/* If the filename was %BOOT then it's not a real filename, so clear argstr before
|
||||
attempting interpose */
|
||||
if (want_bootcode) {
|
||||
argstr = strdup("");
|
||||
}
|
||||
|
||||
/* If we have been asked to open a particular file, interpose the filesystem package with
|
||||
the passed filename as an argument */
|
||||
if (strlen(argstr)) {
|
||||
if (!want_bootcode && strlen(argstr)) {
|
||||
push_str( argstr );
|
||||
PUSH_ph( ph );
|
||||
fword("interpose");
|
||||
|
|
Loading…
Reference in New Issue