@@ -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;
@@ -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);
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(+)