For legacy binaries, legacy_binary_is_big_endian() is equivalent of the compile time TARGET_BIG_ENDIAN definition.
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> --- hw/mips/mipssim.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c index f94dbdc428b..c0959a9e24f 100644 --- a/hw/mips/mipssim.c +++ b/hw/mips/mipssim.c @@ -47,12 +47,6 @@ #define BIOS_SIZE (4 * MiB) -#if TARGET_BIG_ENDIAN -#define BIOS_FILENAME "mips_bios.bin" -#else -#define BIOS_FILENAME "mipsel_bios.bin" -#endif - static struct _loaderparams { int ram_size; const char *kernel_filename; @@ -65,7 +59,7 @@ typedef struct ResetData { uint64_t vector; } ResetData; -static uint64_t load_kernel(void) +static uint64_t load_kernel(bool is_big_endian) { uint64_t entry, kernel_high, initrd_size; long kernel_size; @@ -75,7 +69,7 @@ static uint64_t load_kernel(void) cpu_mips_kseg0_to_phys, NULL, &entry, NULL, &kernel_high, NULL, - TARGET_BIG_ENDIAN ? ELFDATA2MSB : ELFDATA2LSB, + is_big_endian ? ELFDATA2MSB : ELFDATA2LSB, EM_MIPS, 1, 0); if (kernel_size < 0) { error_report("could not load kernel '%s': %s", @@ -153,14 +147,16 @@ mips_mipssim_init(MachineState *machine) CPUMIPSState *env; ResetData *reset_info; int bios_size; + bool is_big_endian = legacy_binary_is_big_endian(); + const char *default_bios_filename = is_big_endian ? "mips_bios.bin" + : "mipsel_bios.bin"; unsigned clock_hz = (legacy_binary_is_64bit() ? 6 : 12) * 1000 * 1000; cpuclk = clock_new(OBJECT(machine), "cpu-refclk"); clock_set_hz(cpuclk, clock_hz); /* Init CPUs. */ - cpu = mips_cpu_create_with_clock(machine->cpu_type, cpuclk, - TARGET_BIG_ENDIAN); + cpu = mips_cpu_create_with_clock(machine->cpu_type, cpuclk, is_big_endian); env = &cpu->env; reset_info = g_new0(ResetData, 1); @@ -177,7 +173,8 @@ mips_mipssim_init(MachineState *machine) /* Map the BIOS / boot exception handler. */ memory_region_add_subregion(address_space_mem, 0x1fc00000LL, bios); /* Load a BIOS / boot exception handler image. */ - filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware ?: BIOS_FILENAME); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware + ?: default_bios_filename); if (filename) { bios_size = load_image_targphys(filename, 0x1fc00000LL, BIOS_SIZE); g_free(filename); @@ -199,7 +196,7 @@ mips_mipssim_init(MachineState *machine) loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; - reset_info->vector = load_kernel(); + reset_info->vector = load_kernel(is_big_endian); } /* Init CPU internal devices. */ -- 2.47.1