qdev: Convert busses to QEMU Object Model

This is far less interesting than it sounds.  We simply add an Object to each
BusState and then register the types appropriately.  Most of the interesting
refactoring will follow in the next patches.

Since we're changing fundamental type names (BusInfo -> BusClass), it all needs
to convert at once.  Fortunately, not a lot of code is affected.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[AF: Made all new bus TypeInfos static const.]
[AF: Made qbus_free() call object_delete(), required {qom,glib}_allocated]
Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Anthony Liguori 2012-05-02 09:00:20 +02:00 committed by Andreas Färber
parent 8185d21639
commit 0d936928ef
27 changed files with 299 additions and 142 deletions

View file

@ -16,9 +16,13 @@ struct SSIBus {
BusState qbus;
};
static struct BusInfo ssi_bus_info = {
.name = "SSI",
.size = sizeof(SSIBus),
#define TYPE_SSI_BUS "SSI"
#define SSI_BUS(obj) OBJECT_CHECK(SSIBus, (obj), TYPE_SSI_BUS)
static const TypeInfo ssi_bus_info = {
.name = TYPE_SSI_BUS,
.parent = TYPE_BUS,
.instance_size = sizeof(SSIBus),
};
static int ssi_slave_init(DeviceState *dev)
@ -40,7 +44,7 @@ static void ssi_slave_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->init = ssi_slave_init;
dc->bus_info = &ssi_bus_info;
dc->bus_type = TYPE_SSI_BUS;
}
static TypeInfo ssi_slave_info = {
@ -62,7 +66,7 @@ DeviceState *ssi_create_slave(SSIBus *bus, const char *name)
SSIBus *ssi_create_bus(DeviceState *parent, const char *name)
{
BusState *bus;
bus = qbus_create(&ssi_bus_info, parent, name);
bus = qbus_create(TYPE_SSI_BUS, parent, name);
return FROM_QBUS(SSIBus, bus);
}
@ -82,6 +86,7 @@ uint32_t ssi_transfer(SSIBus *bus, uint32_t val)
static void ssi_slave_register_types(void)
{
type_register_static(&ssi_bus_info);
type_register_static(&ssi_slave_info);
}