mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
arm: drop intermediate cpu_model -> cpu type parsing and use cpu type directly
there are 2 use cases to deal with: 1: fixed CPU models per board/soc 2: boards with user configurable cpu_model and fallback to default cpu_model if user hasn't specified one explicitly For the 1st drop intermediate cpu_model parsing and use const cpu type directly, which replaces: typename = object_class_get_name( cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) object_new(typename) with object_new(FOO_CPU_TYPE_NAME) or cpu_generic_init(BASE_CPU_TYPE, "my cpu model") with cpu_create(FOO_CPU_TYPE_NAME) as result 1st use case doesn't have to invoke not necessary translation and not needed code is removed. For the 2nd 1: set default cpu type with MachineClass::default_cpu_type and 2: use generic cpu_model parsing that done before machine_init() is run and: 2.1: drop custom cpu_model parsing where pattern is: typename = object_class_get_name( cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) [parse_features(typename, cpu_model, &err) ] 2.2: or replace cpu_generic_init() which does what 2.1 does + create_cpu(typename) with just create_cpu(machine->cpu_type) as result cpu_name -> cpu_type translation is done using generic machine code one including parsing optional features if supported/present (removes a bunch of duplicated cpu_model parsing code) and default cpu type is defined in an uniform way within machine_class_init callbacks instead of adhoc places in boadr's machine_init code. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <1505318697-77161-6-git-send-email-imammedo@redhat.com> Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
311ca98d16
commit
ba1ba5cca3
33 changed files with 115 additions and 265 deletions
|
@ -186,7 +186,7 @@ typedef struct {
|
|||
|
||||
typedef void DBoardInitFn(const VexpressMachineState *machine,
|
||||
ram_addr_t ram_size,
|
||||
const char *cpu_model,
|
||||
const char *cpu_type,
|
||||
qemu_irq *pic);
|
||||
|
||||
struct VEDBoardInfo {
|
||||
|
@ -202,22 +202,16 @@ struct VEDBoardInfo {
|
|||
DBoardInitFn *init;
|
||||
};
|
||||
|
||||
static void init_cpus(const char *cpu_model, const char *privdev,
|
||||
static void init_cpus(const char *cpu_type, const char *privdev,
|
||||
hwaddr periphbase, qemu_irq *pic, bool secure)
|
||||
{
|
||||
ObjectClass *cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);
|
||||
DeviceState *dev;
|
||||
SysBusDevice *busdev;
|
||||
int n;
|
||||
|
||||
if (!cpu_oc) {
|
||||
fprintf(stderr, "Unable to find CPU definition\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Create the actual CPUs */
|
||||
for (n = 0; n < smp_cpus; n++) {
|
||||
Object *cpuobj = object_new(object_class_get_name(cpu_oc));
|
||||
Object *cpuobj = object_new(cpu_type);
|
||||
|
||||
if (!secure) {
|
||||
object_property_set_bool(cpuobj, false, "has_el3", NULL);
|
||||
|
@ -262,7 +256,7 @@ static void init_cpus(const char *cpu_model, const char *privdev,
|
|||
|
||||
static void a9_daughterboard_init(const VexpressMachineState *vms,
|
||||
ram_addr_t ram_size,
|
||||
const char *cpu_model,
|
||||
const char *cpu_type,
|
||||
qemu_irq *pic)
|
||||
{
|
||||
MemoryRegion *sysmem = get_system_memory();
|
||||
|
@ -270,10 +264,6 @@ static void a9_daughterboard_init(const VexpressMachineState *vms,
|
|||
MemoryRegion *lowram = g_new(MemoryRegion, 1);
|
||||
ram_addr_t low_ram_size;
|
||||
|
||||
if (!cpu_model) {
|
||||
cpu_model = "cortex-a9";
|
||||
}
|
||||
|
||||
if (ram_size > 0x40000000) {
|
||||
/* 1GB is the maximum the address space permits */
|
||||
fprintf(stderr, "vexpress-a9: cannot model more than 1GB RAM\n");
|
||||
|
@ -295,7 +285,7 @@ static void a9_daughterboard_init(const VexpressMachineState *vms,
|
|||
memory_region_add_subregion(sysmem, 0x60000000, ram);
|
||||
|
||||
/* 0x1e000000 A9MPCore (SCU) private memory region */
|
||||
init_cpus(cpu_model, TYPE_A9MPCORE_PRIV, 0x1e000000, pic, vms->secure);
|
||||
init_cpus(cpu_type, TYPE_A9MPCORE_PRIV, 0x1e000000, pic, vms->secure);
|
||||
|
||||
/* Daughterboard peripherals : 0x10020000 .. 0x20000000 */
|
||||
|
||||
|
@ -351,17 +341,13 @@ static VEDBoardInfo a9_daughterboard = {
|
|||
|
||||
static void a15_daughterboard_init(const VexpressMachineState *vms,
|
||||
ram_addr_t ram_size,
|
||||
const char *cpu_model,
|
||||
const char *cpu_type,
|
||||
qemu_irq *pic)
|
||||
{
|
||||
MemoryRegion *sysmem = get_system_memory();
|
||||
MemoryRegion *ram = g_new(MemoryRegion, 1);
|
||||
MemoryRegion *sram = g_new(MemoryRegion, 1);
|
||||
|
||||
if (!cpu_model) {
|
||||
cpu_model = "cortex-a15";
|
||||
}
|
||||
|
||||
{
|
||||
/* We have to use a separate 64 bit variable here to avoid the gcc
|
||||
* "comparison is always false due to limited range of data type"
|
||||
|
@ -380,7 +366,7 @@ static void a15_daughterboard_init(const VexpressMachineState *vms,
|
|||
memory_region_add_subregion(sysmem, 0x80000000, ram);
|
||||
|
||||
/* 0x2c000000 A15MPCore private memory region (GIC) */
|
||||
init_cpus(cpu_model, TYPE_A15MPCORE_PRIV, 0x2c000000, pic, vms->secure);
|
||||
init_cpus(cpu_type, TYPE_A15MPCORE_PRIV, 0x2c000000, pic, vms->secure);
|
||||
|
||||
/* A15 daughterboard peripherals: */
|
||||
|
||||
|
@ -560,7 +546,7 @@ static void vexpress_common_init(MachineState *machine)
|
|||
const hwaddr *map = daughterboard->motherboard_map;
|
||||
int i;
|
||||
|
||||
daughterboard->init(vms, machine->ram_size, machine->cpu_model, pic);
|
||||
daughterboard->init(vms, machine->ram_size, machine->cpu_type, pic);
|
||||
|
||||
/*
|
||||
* If a bios file was provided, attempt to map it into memory
|
||||
|
@ -761,6 +747,7 @@ static void vexpress_a9_class_init(ObjectClass *oc, void *data)
|
|||
VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);
|
||||
|
||||
mc->desc = "ARM Versatile Express for Cortex-A9";
|
||||
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9");
|
||||
|
||||
vmc->daughterboard = &a9_daughterboard;
|
||||
}
|
||||
|
@ -771,6 +758,7 @@ static void vexpress_a15_class_init(ObjectClass *oc, void *data)
|
|||
VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);
|
||||
|
||||
mc->desc = "ARM Versatile Express for Cortex-A15";
|
||||
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
|
||||
|
||||
vmc->daughterboard = &a15_daughterboard;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue