Fix up NVRAM settings for boot-device and boot-args.

This patch originally started as a fix for PPC, in that the NVRAM initialiser wasn't been run on startup (this is why printenv 
on PPC always showed much much less than on SPARC). However, it also showed up some inconsistent logic for boot device 
selection, which must also happen *before* boot is called in order for load to work correctly. With this patch applied, bootpath 
and bootargs are set from boot-device and boot-args respectively on startup for SPARC32, SPARC64 and PPC.

Note: there is a small chance SPARC32 may break on some images - please let me know if it does.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>


git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@805 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Mark Cave-Ayland
2010-06-28 11:58:28 +00:00
committed by Mark Cave-Ayland
parent 6afdc00000
commit 004dc4cf85
7 changed files with 102 additions and 57 deletions

View File

@@ -714,9 +714,39 @@ arch_of_init( void )
stdout_path = "screen";
}
/* Setup nvram variables */
push_str("/options");
fword("find-device");
uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
switch (boot_device) {
case 'c':
push_str("hd:");
break;
default:
case 'd':
push_str("cd:");
break;
}
fword("encode-string");
push_str("boot-device");
fword("property");
/* Set up other properties */
push_str("/chosen");
fword("find-device");
/* 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(stdin_path);
fword("open-dev");
fword("encode-int");

View File

@@ -221,43 +221,19 @@ newworld_boot( void )
if (!path) {
NEWWORLD_DPRINTF("Entering boot, no path\n");
push_str("boot-device");
push_str("/options");
/* No path specified, so grab defaults from /chosen */
push_str("bootpath");
push_str("/chosen");
fword("(find-dev)");
POP();
fword("get-package-property");
if (!POP()) {
POP();
path = pop_fstr_copy();
param = strchr(path, ' ');
if (param) {
*param = '\0';
param++;
} else {
push_str("boot-args");
push_str("/options");
fword("(find-dev)");
POP();
fword("get-package-property");
POP();
param = pop_fstr_copy();
}
try_path(path, NULL, param);
for (i = 0; chrp_path[i]; i++)
try_path(path, chrp_path[i], param);
} else {
uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
switch (boot_device) {
case 'c':
path = strdup("hd:");
break;
default:
case 'd':
path = strdup("cd:");
break;
}
for (i = 0; chrp_path[i]; i++)
try_path(path, chrp_path[i], param);
}
} else {
NEWWORLD_DPRINTF("Entering boot, path %s\n", path);
try_path(path, NULL, param);

View File

@@ -56,3 +56,7 @@
stdout @ encode-int " stdout" property
device-end
;
:noname
set-defaults
; PREPOST-initializer

View File

@@ -21,6 +21,9 @@
#include "openbios.h"
#include "boot.h"
#include "packages/video.h"
#define NO_QEMU_PROTOS
#define NO_OPENBIOS_PROTOS
#include "arch/common/fw_cfg.h"
#define MEMORY_SIZE (128*1024) /* 16K ram for hosted system */
#define DICTIONARY_SIZE (256*1024) /* 256K for the dictionary */
@@ -149,6 +152,20 @@ arch_init( void )
#endif
device_end();
/* Set up other properties */
push_str("/chosen");
fword("find-device");
/* 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");
bind_func("platform-boot", boot );
}

View File

@@ -151,30 +151,14 @@ void boot(void)
}
if(!path) {
push_str("boot-device");
push_str("/options");
/* No path specified, so grab defaults from /chosen */
push_str("bootpath");
push_str("/chosen");
fword("(find-dev)");
POP();
fword("get-package-property");
if (!POP()) {
POP();
path = pop_fstr_copy();
} else {
switch (boot_device) {
case 'a':
path = strdup("/obio/SUNW,fdtwo");
break;
case 'c':
path = strdup("disk");
break;
default:
case 'd':
path = strdup("cdrom");
break;
case 'n':
path = strdup("net");
break;
}
}
}
param = strchr(path, ' ');

View File

@@ -468,6 +468,31 @@ void arch_nvram_get(char *data)
ob_mmu_init(cpu->name, ram_size);
/* Setup nvram variables */
push_str("/options");
fword("find-device");
switch (boot_device) {
case 'a':
push_str("/obio/SUNW,fdtwo");
break;
case 'c':
push_str("disk");
break;
default:
case 'd':
push_str("cdrom");
break;
case 'n':
push_str("net");
break;
}
fword("encode-string");
push_str("boot-device");
fword("property");
/* Set up other properties */
push_str("/chosen");
fword("find-device");
@@ -480,6 +505,16 @@ void arch_nvram_get(char *data)
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");

View File

@@ -329,7 +329,6 @@ s" true" s" scroll-lock" bool-config
[IFDEF] CONFIG_PPC
\ ---- PPC ----
s" disk" s" boot-device" str-config \ 7.4.3.5
s" false" s" little-endian?" bool-config
s" false" s" real-mode?" bool-config
s" -1" s" real-base" int-config
@@ -341,7 +340,6 @@ s" -1" s" virt-size" int-config
[IFDEF] CONFIG_X86
\ ---- X86 ----
s" disk" s" boot-device" str-config \ 7.4.3.5
s" true" s" little-endian?" bool-config
[THEN]
@@ -367,6 +365,7 @@ s" false" s" little-endian?" bool-config
s" " s" boot-screen" str-config
s" " s" boot-script" str-config
s" false" s" use-generic?" bool-config
s" disk" s" boot-device" str-config \ 7.4.3.5
s" " s" boot-args" str-config \ ???
\ defers