Author: mcayland Date: Mon Jun 28 13:58:28 2010 New Revision: 805 URL: http://tracker.coreboot.org/trac/openbios/changeset/805
Log: 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
Modified: trunk/openbios-devel/arch/ppc/qemu/init.c trunk/openbios-devel/arch/ppc/qemu/main.c trunk/openbios-devel/arch/ppc/qemu/qemu.fs trunk/openbios-devel/arch/sparc32/openbios.c trunk/openbios-devel/arch/sparc64/boot.c trunk/openbios-devel/arch/sparc64/openbios.c trunk/openbios-devel/forth/admin/nvram.fs
Modified: trunk/openbios-devel/arch/ppc/qemu/init.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/init.c Mon Jun 28 07:18:47 2010 (r804) +++ trunk/openbios-devel/arch/ppc/qemu/init.c Mon Jun 28 13:58:28 2010 (r805) @@ -714,9 +714,39 @@ 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");
Modified: trunk/openbios-devel/arch/ppc/qemu/main.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/main.c Mon Jun 28 07:18:47 2010 (r804) +++ trunk/openbios-devel/arch/ppc/qemu/main.c Mon Jun 28 13:58:28 2010 (r805) @@ -221,43 +221,19 @@
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()) { - 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); - } + POP(); + path = pop_fstr_copy(); + + 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);
Modified: trunk/openbios-devel/arch/ppc/qemu/qemu.fs ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/qemu.fs Mon Jun 28 07:18:47 2010 (r804) +++ trunk/openbios-devel/arch/ppc/qemu/qemu.fs Mon Jun 28 13:58:28 2010 (r805) @@ -56,3 +56,7 @@ stdout @ encode-int " stdout" property device-end ; + +:noname + set-defaults +; PREPOST-initializer
Modified: trunk/openbios-devel/arch/sparc32/openbios.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/openbios.c Mon Jun 28 07:18:47 2010 (r804) +++ trunk/openbios-devel/arch/sparc32/openbios.c Mon Jun 28 13:58:28 2010 (r805) @@ -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 @@ #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 ); }
Modified: trunk/openbios-devel/arch/sparc64/boot.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/boot.c Mon Jun 28 07:18:47 2010 (r804) +++ trunk/openbios-devel/arch/sparc64/boot.c Mon Jun 28 13:58:28 2010 (r805) @@ -151,30 +151,14 @@ }
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()) { - 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; - } - } + POP(); + path = pop_fstr_copy(); }
param = strchr(path, ' ');
Modified: trunk/openbios-devel/arch/sparc64/openbios.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/openbios.c Mon Jun 28 07:18:47 2010 (r804) +++ trunk/openbios-devel/arch/sparc64/openbios.c Mon Jun 28 13:58:28 2010 (r805) @@ -468,6 +468,31 @@
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 @@ 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");
Modified: trunk/openbios-devel/forth/admin/nvram.fs ============================================================================== --- trunk/openbios-devel/forth/admin/nvram.fs Mon Jun 28 07:18:47 2010 (r804) +++ trunk/openbios-devel/forth/admin/nvram.fs Mon Jun 28 13:58:28 2010 (r805) @@ -329,7 +329,6 @@
[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 @@
[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" " 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