sysbus: New sysbus_realize(), sysbus_realize_and_unref()
Sysbus devices almost always plug into the main system bus. qdev_create() even has a convenience feature to make that easy: a null bus argument gets replaced by the main system bus. qdev_realize() and qdev_realize_and_unref() do the same. We can do better. Provide convenience wrappers around qdev_realize() and qdev_realize_and_unref() that don't take a @bus argument. They always pass the main system bus. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200610053247.1583243-45-armbru@redhat.com>
This commit is contained in:
parent
b45ad78889
commit
496a852562
|
@ -217,7 +217,7 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size)
|
||||||
* from being set to NULL to break the normal init/realize
|
* from being set to NULL to break the normal init/realize
|
||||||
* of some devices.
|
* of some devices.
|
||||||
*/
|
*/
|
||||||
static void sysbus_realize(DeviceState *dev, Error **errp)
|
static void sysbus_device_realize(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +250,16 @@ DeviceState *sysbus_create_varargs(const char *name,
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool sysbus_realize(SysBusDevice *dev, Error **errp)
|
||||||
|
{
|
||||||
|
return qdev_realize(DEVICE(dev), sysbus_get_default(), errp);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp)
|
||||||
|
{
|
||||||
|
return qdev_realize_and_unref(DEVICE(dev), sysbus_get_default(), errp);
|
||||||
|
}
|
||||||
|
|
||||||
static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
|
static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
|
||||||
{
|
{
|
||||||
SysBusDevice *s = SYS_BUS_DEVICE(dev);
|
SysBusDevice *s = SYS_BUS_DEVICE(dev);
|
||||||
|
@ -301,7 +311,7 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
|
||||||
static void sysbus_device_class_init(ObjectClass *klass, void *data)
|
static void sysbus_device_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *k = DEVICE_CLASS(klass);
|
DeviceClass *k = DEVICE_CLASS(klass);
|
||||||
k->realize = sysbus_realize;
|
k->realize = sysbus_device_realize;
|
||||||
k->bus_type = TYPE_SYSTEM_BUS;
|
k->bus_type = TYPE_SYSTEM_BUS;
|
||||||
/*
|
/*
|
||||||
* device_add plugs devices into a suitable bus. For "real" buses,
|
* device_add plugs devices into a suitable bus. For "real" buses,
|
||||||
|
|
|
@ -90,6 +90,9 @@ void sysbus_add_io(SysBusDevice *dev, hwaddr addr,
|
||||||
MemoryRegion *mem);
|
MemoryRegion *mem);
|
||||||
MemoryRegion *sysbus_address_space(SysBusDevice *dev);
|
MemoryRegion *sysbus_address_space(SysBusDevice *dev);
|
||||||
|
|
||||||
|
bool sysbus_realize(SysBusDevice *dev, Error **errp);
|
||||||
|
bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sysbus_init_child_obj:
|
* sysbus_init_child_obj:
|
||||||
* @parent: The parent object
|
* @parent: The parent object
|
||||||
|
@ -121,5 +124,4 @@ static inline DeviceState *sysbus_create_simple(const char *name,
|
||||||
return sysbus_create_varargs(name, addr, irq, NULL);
|
return sysbus_create_varargs(name, addr, irq, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* HW_SYSBUS_H */
|
#endif /* HW_SYSBUS_H */
|
||||||
|
|
Loading…
Reference in a new issue