mirror of https://github.com/xemu-project/xemu.git
hw/arm/bcm2836: Split out common realize() code
The realize() function is clearly composed of two parts, each described by a comment: void realize() { /* common peripherals from bcm2835 */ ... /* bcm2836 interrupt controller (and mailboxes, etc.) */ ... } Split the two part, so we can reuse the common part with other SoCs from this family. Reviewed-by: Luc Michel <luc.michel@greensocs.com> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 20201024170127.3592182-6-f4bug@amsat.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
96c741d7ce
commit
f5600924ad
|
@ -52,7 +52,10 @@ static void bcm2836_init(Object *obj)
|
|||
qdev_prop_set_uint32(DEVICE(obj), "enabled-cpus", bc->core_count);
|
||||
}
|
||||
|
||||
object_initialize_child(obj, "control", &s->control, TYPE_BCM2836_CONTROL);
|
||||
if (bc->ctrl_base) {
|
||||
object_initialize_child(obj, "control", &s->control,
|
||||
TYPE_BCM2836_CONTROL);
|
||||
}
|
||||
|
||||
object_initialize_child(obj, "peripherals", &s->peripherals,
|
||||
TYPE_BCM2835_PERIPHERALS);
|
||||
|
@ -62,12 +65,11 @@ static void bcm2836_init(Object *obj)
|
|||
"vcram-size");
|
||||
}
|
||||
|
||||
static void bcm2836_realize(DeviceState *dev, Error **errp)
|
||||
static bool bcm283x_common_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
BCM283XState *s = BCM283X(dev);
|
||||
BCM283XClass *bc = BCM283X_GET_CLASS(dev);
|
||||
Object *obj;
|
||||
int n;
|
||||
|
||||
/* common peripherals from bcm2835 */
|
||||
|
||||
|
@ -76,7 +78,7 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
|
|||
object_property_add_const_link(OBJECT(&s->peripherals), "ram", obj);
|
||||
|
||||
if (!sysbus_realize(SYS_BUS_DEVICE(&s->peripherals), errp)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->peripherals),
|
||||
|
@ -84,6 +86,18 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
|
|||
|
||||
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0,
|
||||
bc->peri_base, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void bcm2836_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
BCM283XState *s = BCM283X(dev);
|
||||
BCM283XClass *bc = BCM283X_GET_CLASS(dev);
|
||||
int n;
|
||||
|
||||
if (!bcm283x_common_realize(dev, errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* bcm2836 interrupt controller (and mailboxes, etc.) */
|
||||
if (!sysbus_realize(SYS_BUS_DEVICE(&s->control), errp)) {
|
||||
|
|
Loading…
Reference in New Issue