diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c index a459baa..8e16120 100644 --- a/arch/ppc/qemu/init.c +++ b/arch/ppc/qemu/init.c @@ -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"); diff --git a/arch/ppc/qemu/main.c b/arch/ppc/qemu/main.c index ef1a4da..06e5692 100644 --- a/arch/ppc/qemu/main.c +++ b/arch/ppc/qemu/main.c @@ -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()) { - 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); diff --git a/arch/ppc/qemu/qemu.fs b/arch/ppc/qemu/qemu.fs index 75f09f2..339a5e9 100644 --- a/arch/ppc/qemu/qemu.fs +++ b/arch/ppc/qemu/qemu.fs @@ -56,3 +56,7 @@ stdout @ encode-int " stdout" property device-end ; + +:noname + set-defaults +; PREPOST-initializer diff --git a/arch/sparc32/openbios.c b/arch/sparc32/openbios.c index 6910666..e94d62a 100644 --- a/arch/sparc32/openbios.c +++ b/arch/sparc32/openbios.c @@ -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 ); } diff --git a/arch/sparc64/boot.c b/arch/sparc64/boot.c index d65715c..c2d2972 100644 --- a/arch/sparc64/boot.c +++ b/arch/sparc64/boot.c @@ -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()) { - 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, ' '); diff --git a/arch/sparc64/openbios.c b/arch/sparc64/openbios.c index 23faa29..1196ed5 100644 --- a/arch/sparc64/openbios.c +++ b/arch/sparc64/openbios.c @@ -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"); diff --git a/forth/admin/nvram.fs b/forth/admin/nvram.fs index d027eae..20f6462 100644 --- a/forth/admin/nvram.fs +++ b/forth/admin/nvram.fs @@ -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