From: Igor V. Kovalenko igor.v.kovalenko@gmail.com
- arch_nvram_get: call ofmem_find_virtual to access kernel command line parameters from qemu
Signed-off-by: Igor V. Kovalenko igor.v.kovalenko@gmail.com --- arch/sparc64/openbios.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/arch/sparc64/openbios.c b/arch/sparc64/openbios.c index 03993b5..dd6151f 100644 --- a/arch/sparc64/openbios.c +++ b/arch/sparc64/openbios.c @@ -281,6 +281,7 @@ void arch_nvram_get(char *data) uint16_t machine_id; const char *stdin_path, *stdout_path; const char *kernel_cmdline; + ucell kernel_cmdline_addr;
fw_cfg_init();
@@ -302,12 +303,18 @@ void arch_nvram_get(char *data) kernel_size = fw_cfg_read_i32(FW_CFG_KERNEL_SIZE); if (kernel_size) kernel_image = fw_cfg_read_i64(FW_CFG_KERNEL_ADDR); - kernel_cmdline = (const char *) fw_cfg_read_i64(FW_CFG_KERNEL_CMDLINE); - if (kernel_cmdline) { - size = strlen(kernel_cmdline); - if (size > OBIO_CMDLINE_MAX - 1) - size = OBIO_CMDLINE_MAX - 1; - memcpy(&obio_cmdline, kernel_cmdline, size); + /* first read physical address of command line parameters */ + kernel_cmdline_addr = fw_cfg_read_i64(FW_CFG_KERNEL_CMDLINE); + if (kernel_cmdline_addr) { + /* find virtual address, expect it to be mapped by entry.S */ + kernel_cmdline_addr = ofmem_find_virtual(kernel_cmdline_addr); + if (kernel_cmdline_addr != (ucell)-1) { + kernel_cmdline = (const char*) kernel_cmdline_addr; + size = strlen(kernel_cmdline); + if (size > OBIO_CMDLINE_MAX - 1) + size = OBIO_CMDLINE_MAX - 1; + memcpy(&obio_cmdline, kernel_cmdline, size); + } } obio_cmdline[size] = '\0'; qemu_cmdline = (uint64_t)obio_cmdline;