The PetaLogix machine read its endianness default from target_big_endian() in class_init. In a multi-target binary the target is not selected yet at class_init, so the default cannot be computed there. Set the property default to "unspecified" instead, and resolve it to big or little in petalogix_s3adsp1800_init(), where the target is known.
Until the machine is initialized, endianness reads back as "unspecified" rather than big or little. Signed-off-by: Yonggang Luo <[email protected]> --- hw/microblaze/petalogix_s3adsp1800_mmu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c index c5f64319009..4abb6e0f0bf 100644 --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c @@ -83,7 +83,13 @@ petalogix_s3adsp1800_init(MachineState *machine) MemoryRegion *phys_ram = g_new(MemoryRegion, 1); qemu_irq irq[32]; MemoryRegion *sysmem = get_system_memory(); - EndianMode endianness = psms->endianness; + EndianMode endianness; + + if (psms->endianness == ENDIAN_MODE_UNSPECIFIED) { + psms->endianness = target_big_endian() ? ENDIAN_MODE_BIG : + ENDIAN_MODE_LITTLE; + } + endianness = psms->endianness; cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU)); object_property_set_str(OBJECT(cpu), "version", "7.10.d", &error_abort); @@ -178,8 +184,7 @@ static void petalogix_s3adsp1800_machine_class_init(ObjectClass *oc, &EndianMode_lookup, machine_get_endianness, machine_set_endianness); - object_property_set_default_str(prop, target_big_endian() ? "big" - : "little"); + object_property_set_default_str(prop, "unspecified"); object_class_property_set_description(oc, "endianness", "Defines whether the machine runs in big or little endian mode"); } -- 2.55.0.windows.3
