diff mbox series

[RFC,14/18] hw/xtensa/xtfpga: Check endianness via legacy_binary_is_big_endian()

Message ID 20250305153929.43687-15-philmd@linaro.org
State New
Headers show
Series hw/microblaze: Quick single binary proof of concept | expand

Commit Message

Philippe Mathieu-Daudé March 5, 2025, 3:39 p.m. UTC
For legacy binaries, legacy_binary_is_big_endian() is
equivalent of the compile time TARGET_BIG_ENDIAN definition.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/xtensa/xtfpga.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 3f3677f1c9a..7f0a849b795 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -27,6 +27,7 @@ 
 
 #include "qemu/osdep.h"
 #include "qemu/units.h"
+#include "qemu/legacy_binary_info.h"
 #include "qapi/error.h"
 #include "cpu.h"
 #include "system/system.h"
@@ -238,6 +239,7 @@  static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
     uint32_t freq = 10000000;
     int n;
     unsigned int smp_cpus = machine->smp.cpus;
+    bool is_big_endian = legacy_binary_is_big_endian();
 
     if (smp_cpus > 1) {
         mx_pic = xtensa_mx_pic_init(31);
@@ -311,7 +313,7 @@  static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (dinfo) {
-        flash = xtfpga_flash_init(system_io, board, dinfo, TARGET_BIG_ENDIAN);
+        flash = xtfpga_flash_init(system_io, board, dinfo, is_big_endian);
     }
 
     /* Use presence of kernel file name as 'boot from SRAM' switch. */
@@ -399,7 +401,7 @@  static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
         uint64_t elf_entry;
         int success = load_elf(kernel_filename, NULL, translate_phys_addr, cpu,
                                &elf_entry, NULL, NULL, NULL,
-                               TARGET_BIG_ENDIAN ? ELFDATA2MSB : ELFDATA2LSB,
+                               is_big_endian ? ELFDATA2MSB : ELFDATA2LSB,
                                EM_XTENSA, 0, 0);
         if (success > 0) {
             entry_point = elf_entry;
@@ -437,9 +439,9 @@  static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
                 0x21, 0xfe, 0xff,       /* l32r a2, entry_a2 */
                 0xa0, 0x00, 0x00,       /* jx   a0 */
             };
-            const size_t boot_sz = TARGET_BIG_ENDIAN ? sizeof(boot_be)
-                                                     : sizeof(boot_le);
-            uint8_t *boot = TARGET_BIG_ENDIAN ? boot_be : boot_le;
+            const size_t boot_sz = is_big_endian ? sizeof(boot_be)
+                                                 : sizeof(boot_le);
+            uint8_t *boot = is_big_endian ? boot_be : boot_le;
             uint32_t entry_pc = tswap32(entry_point);
             uint32_t entry_a2 = tswap32(tagptr);