mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
try_chrp_script() now accepts a third parameter which indicates the
script to be loaded and parsed. It will also terminate parsing on the '</chrp-boot>' tag, which makes locating embedded data after the script easier. Signed-off-by: Steven Noonan <steven@uplinklabs.net> (laurent: remove XCOFF placeholder) git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@544 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
committed by
Laurent Vivier
parent
b1070a239f
commit
a734a346f2
@@ -223,21 +223,21 @@ try_path(const char *path, const char *param)
|
|||||||
http://playground.sun.com/1275/bindings/chrp/chrp1_7a.ps
|
http://playground.sun.com/1275/bindings/chrp/chrp1_7a.ps
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
try_bootinfo(const char *path, const char *param)
|
try_chrp_script(const char *of_path, const char *param, const char *script_path)
|
||||||
{
|
{
|
||||||
int fd, len, tag, taglen, script, scriptlen, entity;
|
int fd, len, tag, taglen, script, scriptlen, entity;
|
||||||
char tagbuf[256], bootscript[256], c;
|
char tagbuf[256], bootscript[256], c;
|
||||||
char *device, *filename, *directory;
|
char *device, *filename, *directory;
|
||||||
int partition;
|
int partition;
|
||||||
|
|
||||||
device = get_device(path);
|
device = get_device(of_path);
|
||||||
partition = get_partition(path);
|
partition = get_partition(of_path);
|
||||||
filename = get_filename(path, &directory);
|
filename = get_filename(of_path, &directory);
|
||||||
|
|
||||||
/* read boot script */
|
/* read boot script */
|
||||||
|
|
||||||
snprintf(bootscript, sizeof(bootscript), "%s:%d,ppc\\bootinfo.txt",
|
snprintf(bootscript, sizeof(bootscript), "%s:%d,%s",
|
||||||
device, partition);
|
device, partition, script_path);
|
||||||
|
|
||||||
ELF_DPRINTF("Trying %s\n", bootscript);
|
ELF_DPRINTF("Trying %s\n", bootscript);
|
||||||
if ((fd = open_io(bootscript)) == -1) {
|
if ((fd = open_io(bootscript)) == -1) {
|
||||||
@@ -267,10 +267,10 @@ try_bootinfo(const char *path, const char *param)
|
|||||||
tagbuf[taglen] = '\0';
|
tagbuf[taglen] = '\0';
|
||||||
if (strcasecmp(tagbuf, "boot-script") == 0)
|
if (strcasecmp(tagbuf, "boot-script") == 0)
|
||||||
script = 1;
|
script = 1;
|
||||||
else if (strcasecmp(tagbuf, "/boot-script") == 0) {
|
else if (strcasecmp(tagbuf, "/boot-script") == 0)
|
||||||
bootscript[scriptlen] = '\0';
|
bootscript[scriptlen] = '\0';
|
||||||
|
else if (strcasecmp(tagbuf, "/chrp-boot") == 0)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
} else if (tag && taglen < sizeof(tagbuf)) {
|
} else if (tag && taglen < sizeof(tagbuf)) {
|
||||||
tagbuf[taglen++] = c;
|
tagbuf[taglen++] = c;
|
||||||
} else if (script && c == '&') {
|
} else if (script && c == '&') {
|
||||||
@@ -292,8 +292,8 @@ try_bootinfo(const char *path, const char *param)
|
|||||||
strcpy(bootscript + scriptlen, filename);
|
strcpy(bootscript + scriptlen, filename);
|
||||||
scriptlen += strlen(filename);
|
scriptlen += strlen(filename);
|
||||||
} else if (strcasecmp(tagbuf, "full-path") == 0) {
|
} else if (strcasecmp(tagbuf, "full-path") == 0) {
|
||||||
strcpy(bootscript + scriptlen, path);
|
strcpy(bootscript + scriptlen, of_path);
|
||||||
scriptlen += strlen(path);
|
scriptlen += strlen(of_path);
|
||||||
} else { /* unknown, keep it */
|
} else { /* unknown, keep it */
|
||||||
bootscript[scriptlen] = '&';
|
bootscript[scriptlen] = '&';
|
||||||
strcpy(bootscript + scriptlen + 1, tagbuf);
|
strcpy(bootscript + scriptlen + 1, tagbuf);
|
||||||
@@ -310,7 +310,7 @@ try_bootinfo(const char *path, const char *param)
|
|||||||
|
|
||||||
ELF_DPRINTF("got bootscript %s\n", bootscript);
|
ELF_DPRINTF("got bootscript %s\n", bootscript);
|
||||||
|
|
||||||
encode_bootpath(path, param);
|
encode_bootpath(of_path, param);
|
||||||
|
|
||||||
feval(bootscript);
|
feval(bootscript);
|
||||||
badf:
|
badf:
|
||||||
@@ -386,7 +386,8 @@ quik_startup( void )
|
|||||||
static void
|
static void
|
||||||
yaboot_startup( void )
|
yaboot_startup( void )
|
||||||
{
|
{
|
||||||
static const char * const paths[] = { "hd:2,\\ofclient", "hd:2,\\yaboot" };
|
static const char * const chrp_paths[] = { "ppc\\bootinfo.txt", "System\\Library\\CoreServices\\BootX" };
|
||||||
|
static const char * const elf_paths[] = { "hd:2,\\ofclient", "hd:2,\\yaboot" };
|
||||||
static const char * const args[] = { "", "conf=hd:2,\\yaboot.conf" };
|
static const char * const args[] = { "", "conf=hd:2,\\yaboot.conf" };
|
||||||
char *path = pop_fstr_copy(), *param;
|
char *path = pop_fstr_copy(), *param;
|
||||||
int i;
|
int i;
|
||||||
@@ -420,7 +421,9 @@ yaboot_startup( void )
|
|||||||
param = pop_fstr_copy();
|
param = pop_fstr_copy();
|
||||||
}
|
}
|
||||||
try_path(path, param);
|
try_path(path, param);
|
||||||
try_bootinfo(path, param);
|
for( i=0; i < sizeof(chrp_paths) / sizeof(chrp_paths[0]); i++ ) {
|
||||||
|
try_chrp_script(path, param, chrp_paths[i]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
|
uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
|
||||||
switch (boot_device) {
|
switch (boot_device) {
|
||||||
@@ -432,15 +435,19 @@ yaboot_startup( void )
|
|||||||
path = strdup("cd:0");
|
path = strdup("cd:0");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try_bootinfo(path, NULL);
|
for( i=0; i < sizeof(chrp_paths) / sizeof(chrp_paths[0]); i++ ) {
|
||||||
|
try_chrp_script(path, param, chrp_paths[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ELF_DPRINTF("Entering boot, path %s\n", path);
|
ELF_DPRINTF("Entering boot, path %s\n", path);
|
||||||
try_path(path, param);
|
try_path(path, param);
|
||||||
try_bootinfo(path, param);
|
for( i=0; i < sizeof(chrp_paths) / sizeof(chrp_paths[0]); i++ ) {
|
||||||
|
try_chrp_script(path, param, chrp_paths[i]);
|
||||||
}
|
}
|
||||||
for( i=0; i < sizeof(paths) / sizeof(paths[0]); i++ ) {
|
}
|
||||||
try_path(paths[i], args[i]);
|
for( i=0; i < sizeof(elf_paths) / sizeof(elf_paths[0]); i++ ) {
|
||||||
|
try_path(elf_paths[i], args[i]);
|
||||||
}
|
}
|
||||||
printk("*** Boot failure! No secondary bootloader specified ***\n");
|
printk("*** Boot failure! No secondary bootloader specified ***\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user