mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-20 00:22:02 -06:00
hw/microblaze: Add endianness property to the petalogix_s3adsp1800 machine
Since the microblaze target can now handle both endianness, big and little, we should provide a config knob for the user to select the desired endianness. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Thomas Huth <thuth@redhat.com> Message-ID: <20250515132019.569365-2-thuth@redhat.com>
This commit is contained in:
parent
9f7cf938ef
commit
141ec228de
1 changed files with 37 additions and 5 deletions
|
@ -58,9 +58,20 @@
|
||||||
#define TYPE_PETALOGIX_S3ADSP1800_MACHINE \
|
#define TYPE_PETALOGIX_S3ADSP1800_MACHINE \
|
||||||
MACHINE_TYPE_NAME("petalogix-s3adsp1800")
|
MACHINE_TYPE_NAME("petalogix-s3adsp1800")
|
||||||
|
|
||||||
|
struct S3Adsp1800MachineState {
|
||||||
|
MachineState parent_class;
|
||||||
|
|
||||||
|
EndianMode endianness;
|
||||||
|
};
|
||||||
|
|
||||||
|
OBJECT_DECLARE_TYPE(S3Adsp1800MachineState, MachineClass,
|
||||||
|
PETALOGIX_S3ADSP1800_MACHINE)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
petalogix_s3adsp1800_init(MachineState *machine)
|
petalogix_s3adsp1800_init(MachineState *machine)
|
||||||
{
|
{
|
||||||
|
S3Adsp1800MachineState *psms = PETALOGIX_S3ADSP1800_MACHINE(machine);
|
||||||
ram_addr_t ram_size = machine->ram_size;
|
ram_addr_t ram_size = machine->ram_size;
|
||||||
DeviceState *dev;
|
DeviceState *dev;
|
||||||
MicroBlazeCPU *cpu;
|
MicroBlazeCPU *cpu;
|
||||||
|
@ -71,13 +82,12 @@ petalogix_s3adsp1800_init(MachineState *machine)
|
||||||
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
|
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
|
||||||
qemu_irq irq[32];
|
qemu_irq irq[32];
|
||||||
MemoryRegion *sysmem = get_system_memory();
|
MemoryRegion *sysmem = get_system_memory();
|
||||||
EndianMode endianness = TARGET_BIG_ENDIAN ? ENDIAN_MODE_BIG
|
EndianMode endianness = psms->endianness;
|
||||||
: ENDIAN_MODE_LITTLE;
|
|
||||||
|
|
||||||
cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
|
cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
|
||||||
object_property_set_str(OBJECT(cpu), "version", "7.10.d", &error_abort);
|
object_property_set_str(OBJECT(cpu), "version", "7.10.d", &error_abort);
|
||||||
object_property_set_bool(OBJECT(cpu), "little-endian",
|
object_property_set_bool(OBJECT(cpu), "little-endian",
|
||||||
!TARGET_BIG_ENDIAN, &error_abort);
|
endianness == ENDIAN_MODE_LITTLE, &error_abort);
|
||||||
qdev_realize(DEVICE(cpu), NULL, &error_abort);
|
qdev_realize(DEVICE(cpu), NULL, &error_abort);
|
||||||
|
|
||||||
/* Attach emulated BRAM through the LMB. */
|
/* Attach emulated BRAM through the LMB. */
|
||||||
|
@ -135,20 +145,41 @@ petalogix_s3adsp1800_init(MachineState *machine)
|
||||||
|
|
||||||
create_unimplemented_device("xps_gpio", GPIO_BASEADDR, 0x10000);
|
create_unimplemented_device("xps_gpio", GPIO_BASEADDR, 0x10000);
|
||||||
|
|
||||||
microblaze_load_kernel(cpu, !TARGET_BIG_ENDIAN, ddr_base, ram_size,
|
microblaze_load_kernel(cpu, endianness == ENDIAN_MODE_LITTLE, ddr_base,
|
||||||
machine->initrd_filename,
|
ram_size, machine->initrd_filename,
|
||||||
BINARY_DEVICE_TREE_FILE,
|
BINARY_DEVICE_TREE_FILE,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int machine_get_endianness(Object *obj, Error **errp G_GNUC_UNUSED)
|
||||||
|
{
|
||||||
|
S3Adsp1800MachineState *ms = PETALOGIX_S3ADSP1800_MACHINE(obj);
|
||||||
|
return ms->endianness;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void machine_set_endianness(Object *obj, int endianness, Error **errp)
|
||||||
|
{
|
||||||
|
S3Adsp1800MachineState *ms = PETALOGIX_S3ADSP1800_MACHINE(obj);
|
||||||
|
ms->endianness = endianness;
|
||||||
|
}
|
||||||
|
|
||||||
static void petalogix_s3adsp1800_machine_class_init(ObjectClass *oc,
|
static void petalogix_s3adsp1800_machine_class_init(ObjectClass *oc,
|
||||||
const void *data)
|
const void *data)
|
||||||
{
|
{
|
||||||
MachineClass *mc = MACHINE_CLASS(oc);
|
MachineClass *mc = MACHINE_CLASS(oc);
|
||||||
|
ObjectProperty *prop;
|
||||||
|
|
||||||
mc->desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800";
|
mc->desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800";
|
||||||
mc->init = petalogix_s3adsp1800_init;
|
mc->init = petalogix_s3adsp1800_init;
|
||||||
mc->is_default = true;
|
mc->is_default = true;
|
||||||
|
|
||||||
|
prop = object_class_property_add_enum(oc, "endianness", "EndianMode",
|
||||||
|
&EndianMode_lookup,
|
||||||
|
machine_get_endianness,
|
||||||
|
machine_set_endianness);
|
||||||
|
object_property_set_default_str(prop, TARGET_BIG_ENDIAN ? "big" : "little");
|
||||||
|
object_class_property_set_description(oc, "endianness",
|
||||||
|
"Defines whether the machine runs in big or little endian mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo petalogix_s3adsp1800_machine_types[] = {
|
static const TypeInfo petalogix_s3adsp1800_machine_types[] = {
|
||||||
|
@ -156,6 +187,7 @@ static const TypeInfo petalogix_s3adsp1800_machine_types[] = {
|
||||||
.name = TYPE_PETALOGIX_S3ADSP1800_MACHINE,
|
.name = TYPE_PETALOGIX_S3ADSP1800_MACHINE,
|
||||||
.parent = TYPE_MACHINE,
|
.parent = TYPE_MACHINE,
|
||||||
.class_init = petalogix_s3adsp1800_machine_class_init,
|
.class_init = petalogix_s3adsp1800_machine_class_init,
|
||||||
|
.instance_size = sizeof(S3Adsp1800MachineState),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue