Message ID | 20200427181649.26851-8-edgar.iglesias@gmail.com |
---|---|
State | New |
Headers | show |
Series | hw/arm: versal: Add SD and the RTC | expand |
On Mon, Apr 27, 2020 at 11:20 AM Edgar E. Iglesias <edgar.iglesias@gmail.com> wrote: > > From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> > > Embedd the APUs into the SoC type. > > Suggested-by: Peter Maydell <peter.maydell@linaro.org> > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > hw/arm/xlnx-versal-virt.c | 4 ++-- > hw/arm/xlnx-versal.c | 19 +++++-------------- > include/hw/arm/xlnx-versal.h | 2 +- > 3 files changed, 8 insertions(+), 17 deletions(-) > > diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c > index 8a608074d1..d7be1ad494 100644 > --- a/hw/arm/xlnx-versal-virt.c > +++ b/hw/arm/xlnx-versal-virt.c > @@ -469,9 +469,9 @@ static void versal_virt_init(MachineState *machine) > s->binfo.get_dtb = versal_virt_get_dtb; > s->binfo.modify_dtb = versal_virt_modify_dtb; > if (machine->kernel_filename) { > - arm_load_kernel(s->soc.fpd.apu.cpu[0], machine, &s->binfo); > + arm_load_kernel(&s->soc.fpd.apu.cpu[0], machine, &s->binfo); > } else { > - AddressSpace *as = arm_boot_address_space(s->soc.fpd.apu.cpu[0], > + AddressSpace *as = arm_boot_address_space(&s->soc.fpd.apu.cpu[0], > &s->binfo); > /* Some boot-loaders (e.g u-boot) don't like blobs at address 0 (NULL). > * Offset things by 4K. */ > diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c > index ebd2dc51be..c8a296e2e0 100644 > --- a/hw/arm/xlnx-versal.c > +++ b/hw/arm/xlnx-versal.c > @@ -31,19 +31,11 @@ static void versal_create_apu_cpus(Versal *s) > > for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) { > Object *obj; > - char *name; > - > - obj = object_new(XLNX_VERSAL_ACPU_TYPE); > - if (!obj) { > - error_report("Unable to create apu.cpu[%d] of type %s", > - i, XLNX_VERSAL_ACPU_TYPE); > - exit(EXIT_FAILURE); > - } > - > - name = g_strdup_printf("apu-cpu[%d]", i); > - object_property_add_child(OBJECT(s), name, obj, &error_fatal); > - g_free(name); > > + object_initialize_child(OBJECT(s), "apu-cpu[*]", > + &s->fpd.apu.cpu[i], sizeof(s->fpd.apu.cpu[i]), > + XLNX_VERSAL_ACPU_TYPE, &error_abort, NULL); > + obj = OBJECT(&s->fpd.apu.cpu[i]); > object_property_set_int(obj, s->cfg.psci_conduit, > "psci-conduit", &error_abort); > if (i) { > @@ -57,7 +49,6 @@ static void versal_create_apu_cpus(Versal *s) > object_property_set_link(obj, OBJECT(&s->fpd.apu.mr), "memory", > &error_abort); > object_property_set_bool(obj, true, "realized", &error_fatal); > - s->fpd.apu.cpu[i] = ARM_CPU(obj); > } > } > > @@ -95,7 +86,7 @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic) > } > > for (i = 0; i < nr_apu_cpus; i++) { > - DeviceState *cpudev = DEVICE(s->fpd.apu.cpu[i]); > + DeviceState *cpudev = DEVICE(&s->fpd.apu.cpu[i]); > int ppibase = XLNX_VERSAL_NR_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS; > qemu_irq maint_irq; > int ti; > diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h > index 94b7826fd4..426b66449d 100644 > --- a/include/hw/arm/xlnx-versal.h > +++ b/include/hw/arm/xlnx-versal.h > @@ -36,7 +36,7 @@ typedef struct Versal { > struct { > struct { > MemoryRegion mr; > - ARMCPU *cpu[XLNX_VERSAL_NR_ACPUS]; > + ARMCPU cpu[XLNX_VERSAL_NR_ACPUS]; > GICv3State gic; > } apu; > } fpd; > -- > 2.20.1 > >
On 4/27/20 8:16 PM, Edgar E. Iglesias wrote: > From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> > > Embedd the APUs into the SoC type. > > Suggested-by: Peter Maydell <peter.maydell@linaro.org> > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> > --- > hw/arm/xlnx-versal-virt.c | 4 ++-- > hw/arm/xlnx-versal.c | 19 +++++-------------- > include/hw/arm/xlnx-versal.h | 2 +- > 3 files changed, 8 insertions(+), 17 deletions(-) > > diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c > index 8a608074d1..d7be1ad494 100644 > --- a/hw/arm/xlnx-versal-virt.c > +++ b/hw/arm/xlnx-versal-virt.c > @@ -469,9 +469,9 @@ static void versal_virt_init(MachineState *machine) > s->binfo.get_dtb = versal_virt_get_dtb; > s->binfo.modify_dtb = versal_virt_modify_dtb; > if (machine->kernel_filename) { > - arm_load_kernel(s->soc.fpd.apu.cpu[0], machine, &s->binfo); > + arm_load_kernel(&s->soc.fpd.apu.cpu[0], machine, &s->binfo); > } else { > - AddressSpace *as = arm_boot_address_space(s->soc.fpd.apu.cpu[0], > + AddressSpace *as = arm_boot_address_space(&s->soc.fpd.apu.cpu[0], > &s->binfo); > /* Some boot-loaders (e.g u-boot) don't like blobs at address 0 (NULL). > * Offset things by 4K. */ > diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c > index ebd2dc51be..c8a296e2e0 100644 > --- a/hw/arm/xlnx-versal.c > +++ b/hw/arm/xlnx-versal.c > @@ -31,19 +31,11 @@ static void versal_create_apu_cpus(Versal *s) > > for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) { > Object *obj; > - char *name; > - > - obj = object_new(XLNX_VERSAL_ACPU_TYPE); > - if (!obj) { > - error_report("Unable to create apu.cpu[%d] of type %s", > - i, XLNX_VERSAL_ACPU_TYPE); > - exit(EXIT_FAILURE); > - } > - > - name = g_strdup_printf("apu-cpu[%d]", i); > - object_property_add_child(OBJECT(s), name, obj, &error_fatal); > - g_free(name); > > + object_initialize_child(OBJECT(s), "apu-cpu[*]", > + &s->fpd.apu.cpu[i], sizeof(s->fpd.apu.cpu[i]), > + XLNX_VERSAL_ACPU_TYPE, &error_abort, NULL); :) Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > + obj = OBJECT(&s->fpd.apu.cpu[i]); > object_property_set_int(obj, s->cfg.psci_conduit, > "psci-conduit", &error_abort); > if (i) { > @@ -57,7 +49,6 @@ static void versal_create_apu_cpus(Versal *s) > object_property_set_link(obj, OBJECT(&s->fpd.apu.mr), "memory", > &error_abort); > object_property_set_bool(obj, true, "realized", &error_fatal); > - s->fpd.apu.cpu[i] = ARM_CPU(obj); > } > } > > @@ -95,7 +86,7 @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic) > } > > for (i = 0; i < nr_apu_cpus; i++) { > - DeviceState *cpudev = DEVICE(s->fpd.apu.cpu[i]); > + DeviceState *cpudev = DEVICE(&s->fpd.apu.cpu[i]); > int ppibase = XLNX_VERSAL_NR_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS; > qemu_irq maint_irq; > int ti; > diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h > index 94b7826fd4..426b66449d 100644 > --- a/include/hw/arm/xlnx-versal.h > +++ b/include/hw/arm/xlnx-versal.h > @@ -36,7 +36,7 @@ typedef struct Versal { > struct { > struct { > MemoryRegion mr; > - ARMCPU *cpu[XLNX_VERSAL_NR_ACPUS]; > + ARMCPU cpu[XLNX_VERSAL_NR_ACPUS]; > GICv3State gic; > } apu; > } fpd; >
On 4/27/20 8:16 PM, Edgar E. Iglesias wrote: > From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> > > Embedd the APUs into the SoC type. > > Suggested-by: Peter Maydell <peter.maydell@linaro.org> > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Reviewed-by: Luc Michel <luc.michel@greensocs.com> > --- > hw/arm/xlnx-versal-virt.c | 4 ++-- > hw/arm/xlnx-versal.c | 19 +++++-------------- > include/hw/arm/xlnx-versal.h | 2 +- > 3 files changed, 8 insertions(+), 17 deletions(-) > > diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c > index 8a608074d1..d7be1ad494 100644 > --- a/hw/arm/xlnx-versal-virt.c > +++ b/hw/arm/xlnx-versal-virt.c > @@ -469,9 +469,9 @@ static void versal_virt_init(MachineState *machine) > s->binfo.get_dtb = versal_virt_get_dtb; > s->binfo.modify_dtb = versal_virt_modify_dtb; > if (machine->kernel_filename) { > - arm_load_kernel(s->soc.fpd.apu.cpu[0], machine, &s->binfo); > + arm_load_kernel(&s->soc.fpd.apu.cpu[0], machine, &s->binfo); > } else { > - AddressSpace *as = arm_boot_address_space(s->soc.fpd.apu.cpu[0], > + AddressSpace *as = arm_boot_address_space(&s->soc.fpd.apu.cpu[0], > &s->binfo); > /* Some boot-loaders (e.g u-boot) don't like blobs at address 0 (NULL). > * Offset things by 4K. */ > diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c > index ebd2dc51be..c8a296e2e0 100644 > --- a/hw/arm/xlnx-versal.c > +++ b/hw/arm/xlnx-versal.c > @@ -31,19 +31,11 @@ static void versal_create_apu_cpus(Versal *s) > > for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) { > Object *obj; > - char *name; > - > - obj = object_new(XLNX_VERSAL_ACPU_TYPE); > - if (!obj) { > - error_report("Unable to create apu.cpu[%d] of type %s", > - i, XLNX_VERSAL_ACPU_TYPE); > - exit(EXIT_FAILURE); > - } > - > - name = g_strdup_printf("apu-cpu[%d]", i); > - object_property_add_child(OBJECT(s), name, obj, &error_fatal); > - g_free(name); > > + object_initialize_child(OBJECT(s), "apu-cpu[*]", > + &s->fpd.apu.cpu[i], sizeof(s->fpd.apu.cpu[i]), > + XLNX_VERSAL_ACPU_TYPE, &error_abort, NULL); > + obj = OBJECT(&s->fpd.apu.cpu[i]); > object_property_set_int(obj, s->cfg.psci_conduit, > "psci-conduit", &error_abort); > if (i) { > @@ -57,7 +49,6 @@ static void versal_create_apu_cpus(Versal *s) > object_property_set_link(obj, OBJECT(&s->fpd.apu.mr), "memory", > &error_abort); > object_property_set_bool(obj, true, "realized", &error_fatal); > - s->fpd.apu.cpu[i] = ARM_CPU(obj); > } > } > > @@ -95,7 +86,7 @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic) > } > > for (i = 0; i < nr_apu_cpus; i++) { > - DeviceState *cpudev = DEVICE(s->fpd.apu.cpu[i]); > + DeviceState *cpudev = DEVICE(&s->fpd.apu.cpu[i]); > int ppibase = XLNX_VERSAL_NR_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS; > qemu_irq maint_irq; > int ti; > diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h > index 94b7826fd4..426b66449d 100644 > --- a/include/hw/arm/xlnx-versal.h > +++ b/include/hw/arm/xlnx-versal.h > @@ -36,7 +36,7 @@ typedef struct Versal { > struct { > struct { > MemoryRegion mr; > - ARMCPU *cpu[XLNX_VERSAL_NR_ACPUS]; > + ARMCPU cpu[XLNX_VERSAL_NR_ACPUS]; > GICv3State gic; > } apu; > } fpd; >
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c index 8a608074d1..d7be1ad494 100644 --- a/hw/arm/xlnx-versal-virt.c +++ b/hw/arm/xlnx-versal-virt.c @@ -469,9 +469,9 @@ static void versal_virt_init(MachineState *machine) s->binfo.get_dtb = versal_virt_get_dtb; s->binfo.modify_dtb = versal_virt_modify_dtb; if (machine->kernel_filename) { - arm_load_kernel(s->soc.fpd.apu.cpu[0], machine, &s->binfo); + arm_load_kernel(&s->soc.fpd.apu.cpu[0], machine, &s->binfo); } else { - AddressSpace *as = arm_boot_address_space(s->soc.fpd.apu.cpu[0], + AddressSpace *as = arm_boot_address_space(&s->soc.fpd.apu.cpu[0], &s->binfo); /* Some boot-loaders (e.g u-boot) don't like blobs at address 0 (NULL). * Offset things by 4K. */ diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c index ebd2dc51be..c8a296e2e0 100644 --- a/hw/arm/xlnx-versal.c +++ b/hw/arm/xlnx-versal.c @@ -31,19 +31,11 @@ static void versal_create_apu_cpus(Versal *s) for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) { Object *obj; - char *name; - - obj = object_new(XLNX_VERSAL_ACPU_TYPE); - if (!obj) { - error_report("Unable to create apu.cpu[%d] of type %s", - i, XLNX_VERSAL_ACPU_TYPE); - exit(EXIT_FAILURE); - } - - name = g_strdup_printf("apu-cpu[%d]", i); - object_property_add_child(OBJECT(s), name, obj, &error_fatal); - g_free(name); + object_initialize_child(OBJECT(s), "apu-cpu[*]", + &s->fpd.apu.cpu[i], sizeof(s->fpd.apu.cpu[i]), + XLNX_VERSAL_ACPU_TYPE, &error_abort, NULL); + obj = OBJECT(&s->fpd.apu.cpu[i]); object_property_set_int(obj, s->cfg.psci_conduit, "psci-conduit", &error_abort); if (i) { @@ -57,7 +49,6 @@ static void versal_create_apu_cpus(Versal *s) object_property_set_link(obj, OBJECT(&s->fpd.apu.mr), "memory", &error_abort); object_property_set_bool(obj, true, "realized", &error_fatal); - s->fpd.apu.cpu[i] = ARM_CPU(obj); } } @@ -95,7 +86,7 @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic) } for (i = 0; i < nr_apu_cpus; i++) { - DeviceState *cpudev = DEVICE(s->fpd.apu.cpu[i]); + DeviceState *cpudev = DEVICE(&s->fpd.apu.cpu[i]); int ppibase = XLNX_VERSAL_NR_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS; qemu_irq maint_irq; int ti; diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h index 94b7826fd4..426b66449d 100644 --- a/include/hw/arm/xlnx-versal.h +++ b/include/hw/arm/xlnx-versal.h @@ -36,7 +36,7 @@ typedef struct Versal { struct { struct { MemoryRegion mr; - ARMCPU *cpu[XLNX_VERSAL_NR_ACPUS]; + ARMCPU cpu[XLNX_VERSAL_NR_ACPUS]; GICv3State gic; } apu; } fpd;