This provides an alternative mechanism for supporting boot device order information from QEMU compared with the legacy FW_CFG_BOOT_DEVICE functionality specified via -boot.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- arch/sparc64/boot.c | 2 +- arch/sparc64/boot.h | 2 +- arch/sparc64/openbios.c | 38 ++++++++++++++++++++++++++++++++------ 3 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/arch/sparc64/boot.c b/arch/sparc64/boot.c index 7a287f2..54f6f7a 100644 --- a/arch/sparc64/boot.c +++ b/arch/sparc64/boot.c @@ -15,7 +15,7 @@ uint64_t kernel_image; uint64_t kernel_size; uint64_t qemu_cmdline; uint64_t cmdline_size; -char boot_device; +char *boot_device;
extern int sparc64_of_client_interface( int *params );
diff --git a/arch/sparc64/boot.h b/arch/sparc64/boot.h index e1b8717..88beb1c 100644 --- a/arch/sparc64/boot.h +++ b/arch/sparc64/boot.h @@ -14,7 +14,7 @@ extern uint64_t kernel_image; extern uint64_t kernel_size; extern uint64_t qemu_cmdline; extern uint64_t cmdline_size; -extern char boot_device; +extern char *boot_device; extern void boot(void);
// sys_info.c diff --git a/arch/sparc64/openbios.c b/arch/sparc64/openbios.c index e9e08fd..b2e79d0 100644 --- a/arch/sparc64/openbios.c +++ b/arch/sparc64/openbios.c @@ -26,6 +26,7 @@ #include "arch/common/fw_cfg.h" #include "arch/sparc64/ofmem_sparc64.h" #include "spitfire.h" +#include "libc/vsprintf.h"
#define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
@@ -538,6 +539,8 @@ void arch_nvram_get(char *data) uint32_t clock_frequency; uint16_t machine_id; const char *stdin_path, *stdout_path; + char *bootorder_file, *boot_path; + uint32_t bootorder_sz, sz;
fw_cfg_init();
@@ -570,7 +573,6 @@ void arch_nvram_get(char *data) } qemu_cmdline = (uint64_t)obio_cmdline; cmdline_size = size; - boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
if (kernel_size) printk("kernel addr %llx size %llx\n", kernel_image, kernel_size); @@ -630,7 +632,11 @@ void arch_nvram_get(char *data) push_str("/options"); fword("find-device");
- switch (boot_device) { + /* Boot order */ + bootorder_file = fw_cfg_read_file("bootorder", &bootorder_sz); + + if (bootorder_file == NULL) { + switch (fw_cfg_read_i16(FW_CFG_BOOT_DEVICE)) { case 'a': push_str("/obio/SUNW,fdtwo"); break; @@ -644,11 +650,31 @@ void arch_nvram_get(char *data) case 'n': push_str("net"); break; - } + }
- fword("encode-string"); - push_str("boot-device"); - fword("property"); + fword("encode-string"); + push_str("boot-device"); + fword("property"); + } else { + sz = bootorder_sz * (3 * 2); + boot_device = malloc(sz); + memset(boot_device, 0, sz); + + while ((boot_path = strsep(&bootorder_file, "\n")) != NULL) { + snprintf(buf, sizeof(buf), + "%s:f " + "%s:a " + "%s ", + boot_path, boot_path, boot_path); + + strncat(boot_device, buf, sz); + } + + push_str(boot_device); + fword("encode-string"); + push_str("boot-device"); + fword("property"); + }
push_str(obio_cmdline); fword("encode-string");