hw/riscv: Widen OpenSBI dynamic info struct Since fw_dynamic_info is only used for non 32 bit targets, target_long is int64_t anyway. Rename struct to fw_dynamic_info64 and use int64_t. Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Anton Johansson <anjo@rev.ng> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20251027-feature-single-binary-hw-v1-v2-3-44478d589ae9@rev.ng> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index 9510fca..75f3428 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c
@@ -388,7 +388,8 @@ uint64_t kernel_entry) { struct fw_dynamic_info32 dinfo32; - struct fw_dynamic_info dinfo; + struct fw_dynamic_info64 dinfo64; + void *dinfo_ptr = NULL; size_t dinfo_len; if (riscv_is_32bit(harts)) { @@ -398,15 +399,17 @@ dinfo32.next_addr = cpu_to_le32(kernel_entry); dinfo32.options = 0; dinfo32.boot_hart = 0; + dinfo_ptr = &dinfo32; dinfo_len = sizeof(dinfo32); } else { - dinfo.magic = cpu_to_le64(FW_DYNAMIC_INFO_MAGIC_VALUE); - dinfo.version = cpu_to_le64(FW_DYNAMIC_INFO_VERSION); - dinfo.next_mode = cpu_to_le64(FW_DYNAMIC_INFO_NEXT_MODE_S); - dinfo.next_addr = cpu_to_le64(kernel_entry); - dinfo.options = 0; - dinfo.boot_hart = 0; - dinfo_len = sizeof(dinfo); + dinfo64.magic = cpu_to_le64(FW_DYNAMIC_INFO_MAGIC_VALUE); + dinfo64.version = cpu_to_le64(FW_DYNAMIC_INFO_VERSION); + dinfo64.next_mode = cpu_to_le64(FW_DYNAMIC_INFO_NEXT_MODE_S); + dinfo64.next_addr = cpu_to_le64(kernel_entry); + dinfo64.options = 0; + dinfo64.boot_hart = 0; + dinfo_ptr = &dinfo64; + dinfo_len = sizeof(dinfo64); } /** @@ -420,8 +423,7 @@ } rom_add_blob_fixed_as("mrom.finfo", - riscv_is_32bit(harts) ? - (void *)&dinfo32 : (void *)&dinfo, + dinfo_ptr, dinfo_len, rom_base + reset_vec_size, &address_space_memory);
diff --git a/include/hw/riscv/boot_opensbi.h b/include/hw/riscv/boot_opensbi.h index 18664a1..ab9999b 100644 --- a/include/hw/riscv/boot_opensbi.h +++ b/include/hw/riscv/boot_opensbi.h
@@ -29,17 +29,17 @@ }; /** Representation dynamic info passed by previous booting stage */ -struct fw_dynamic_info { +struct fw_dynamic_info64 { /** Info magic */ - target_long magic; + int64_t magic; /** Info version */ - target_long version; + int64_t version; /** Next booting stage address */ - target_long next_addr; + int64_t next_addr; /** Next booting stage mode */ - target_long next_mode; + int64_t next_mode; /** Options for OpenSBI library */ - target_long options; + int64_t options; /** * Preferred boot HART id * @@ -55,7 +55,7 @@ * stage can set it to -1UL which will force the FW_DYNAMIC firmware * to use the relocation lottery mechanism. */ - target_long boot_hart; + int64_t boot_hart; }; /** Representation dynamic info passed by previous booting stage */