On 11/5/24 13:04, Philippe Mathieu-Daudé wrote:
-static void petalogix_s3adsp1800_machine_class_init(ObjectClass *oc,
void *data)
+static void petalogix_s3adsp1800_machine_class_init_be(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ PetalogixS3adsp1800MachineClass *pmc = PETALOGIX_S3ADSP1800_MACHINE_CLASS(oc);
- mc->desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800";
+ pmc->little_endian = false;
+ mc->desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (big
endian)";
mc->init = petalogix_s3adsp1800_init;
+#if TARGET_BIG_ENDIAN
mc->is_default = true;
+ mc->alias = "petalogix-s3adsp1800";
+#endif
+}
+
+static void petalogix_s3adsp1800_machine_class_init_le(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ PetalogixS3adsp1800MachineClass *pmc = PETALOGIX_S3ADSP1800_MACHINE_CLASS(oc);
+
+ pmc->little_endian = true;
+ mc->desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (little
endian)";
+ mc->init = petalogix_s3adsp1800_init;
+#if !TARGET_BIG_ENDIAN
+ mc->is_default = true;
+ mc->alias = "petalogix-s3adsp1800";
+#endif
}
These can be C if's, instead of preprocessor #if, at which point you can share code.
static void petalogix_s3adsp1800_machine_class_init(ObjectClass *oc, bool little_endian)
{
MachineClass *mc = MACHINE_CLASS(oc);
PetalogixS3adsp1800MachineClass *pmc = PETALOGIX_S3ADSP1800_MACHINE_CLASS(oc);
mc->init = petalogix_s3adsp1800_init;
pmc->little_endian = little_endian;
mc->desc = little_endian
? "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (little
endian)"
: "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (big
endian)";
if (little_endian == !TARGET_BIG_ENDIAN) {
mc->is_default = true;
mc->alias = "petalogix-s3adsp1800";
}
}
static void petalogix_s3adsp1800_machine_class_init_be(ObjectClass *oc, void *data)
{
petalogix_s3adsp1800_machine_class_init(oc, false);
}
With that,
Reviewed-by: Richard Henderson <richard.henderson(a)linaro.org>
r~