diff mbox series

[08/20] target/sh4: Expose CPUSH4State::little_endian property

Message ID 20241204202602.58083-9-philmd@linaro.org
State New
Headers show
Series target: Implement CPUClass::datapath_is_big_endian() handlers | expand

Commit Message

Philippe Mathieu-Daudé Dec. 4, 2024, 8:25 p.m. UTC
SH4 CPUs endianness is set with an external pin in a power-on reset.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/sh4/cpu.h | 6 ++++++
 target/sh4/cpu.c | 8 ++++++++
 2 files changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
index d928bcf0067..2502ddba102 100644
--- a/target/sh4/cpu.h
+++ b/target/sh4/cpu.h
@@ -198,6 +198,12 @@  typedef struct CPUArchState {
     /* Fields from here on are preserved over CPU reset. */
     int id;                     /* CPU model */
 
+    /*
+     * The endian is set with an external pin in a power-on reset.
+     * The endian cannot be changed dynamically.
+     */
+    bool little_endian;
+
     /* The features that we should emulate. See sh_features above.  */
     uint32_t features;
 
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
index 8f07261dcfd..f54005644c9 100644
--- a/target/sh4/cpu.c
+++ b/target/sh4/cpu.c
@@ -23,6 +23,7 @@ 
 #include "qapi/error.h"
 #include "qemu/qemu-print.h"
 #include "cpu.h"
+#include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "exec/exec-all.h"
 #include "fpu/softfloat-helpers.h"
@@ -231,6 +232,12 @@  static void superh_cpu_initfn(Object *obj)
     env->movcal_backup_tail = &(env->movcal_backup);
 }
 
+static Property superh_cpu_properties[] = {
+    DEFINE_PROP_BOOL("little-endian", SuperHCPU,
+                     env.little_endian, !TARGET_BIG_ENDIAN),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 #ifndef CONFIG_USER_ONLY
 static const VMStateDescription vmstate_sh_cpu = {
     .name = "cpu",
@@ -270,6 +277,7 @@  static void superh_cpu_class_init(ObjectClass *oc, void *data)
 
     device_class_set_parent_realize(dc, superh_cpu_realizefn,
                                     &scc->parent_realize);
+    device_class_set_props(dc, superh_cpu_properties);
 
     resettable_class_set_parent_phases(rc, NULL, superh_cpu_reset_hold, NULL,
                                        &scc->parent_phases);