Skip to content

Commit

Permalink
vt82c686: QOMify
Browse files Browse the repository at this point in the history
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
gongleiarei authored and Michael Tokarev committed Jun 23, 2015
1 parent f9b9d29 commit 417349e
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions hw/isa/vt82c686.c
Expand Up @@ -47,6 +47,10 @@ typedef struct VT82C686BState {
SuperIOConfig superio_conf;
} VT82C686BState;

#define TYPE_VT82C686B_DEVICE "VT82C686B"
#define VT82C686B_DEVICE(obj) \
OBJECT_CHECK(VT82C686BState, (obj), TYPE_VT82C686B_DEVICE)

static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data,
unsigned size)
{
Expand Down Expand Up @@ -114,7 +118,7 @@ static void vt82c686b_reset(void * opaque)
{
PCIDevice *d = opaque;
uint8_t *pci_conf = d->config;
VT82C686BState *vt82c = DO_UPCAST(VT82C686BState, dev, d);
VT82C686BState *vt82c = VT82C686B_DEVICE(d);

pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0);
pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
Expand Down Expand Up @@ -142,7 +146,7 @@ static void vt82c686b_reset(void * opaque)
static void vt82c686b_write_config(PCIDevice * d, uint32_t address,
uint32_t val, int len)
{
VT82C686BState *vt686 = DO_UPCAST(VT82C686BState, dev, d);
VT82C686BState *vt686 = VT82C686B_DEVICE(d);

DPRINTF("vt82c686b_write_config address 0x%x val 0x%x len 0x%x\n",
address, val, len);
Expand Down Expand Up @@ -172,6 +176,18 @@ typedef struct VT686MC97State {
PCIDevice dev;
} VT686MC97State;

#define TYPE_VT82C686B_PM_DEVICE "VT82C686B_PM"
#define VT82C686B_PM_DEVICE(obj) \
OBJECT_CHECK(VT686PMState, (obj), TYPE_VT82C686B_PM_DEVICE)

#define TYPE_VT82C686B_MC97_DEVICE "VT82C686B_MC97"
#define VT82C686B_MC97_DEVICE(obj) \
OBJECT_CHECK(VT686MC97State, (obj), TYPE_VT82C686B_MC97_DEVICE)

#define TYPE_VT82C686B_AC97_DEVICE "VT82C686B_AC97"
#define VT82C686B_AC97_DEVICE(obj) \
OBJECT_CHECK(VT686AC97State, (obj), TYPE_VT82C686B_AC97_DEVICE)

static void pm_update_sci(VT686PMState *s)
{
int sci_level, pmsts;
Expand Down Expand Up @@ -247,7 +263,7 @@ static const VMStateDescription vmstate_acpi = {

static void vt82c686b_ac97_realize(PCIDevice *dev, Error **errp)
{
VT686AC97State *s = DO_UPCAST(VT686AC97State, dev, dev);
VT686AC97State *s = VT82C686B_AC97_DEVICE(dev);
uint8_t *pci_conf = s->dev.config;

pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
Expand All @@ -261,7 +277,7 @@ void vt82c686b_ac97_init(PCIBus *bus, int devfn)
{
PCIDevice *dev;

dev = pci_create(bus, devfn, "VT82C686B_AC97");
dev = pci_create(bus, devfn, TYPE_VT82C686B_AC97_DEVICE);
qdev_init_nofail(&dev->qdev);
}

Expand All @@ -280,15 +296,15 @@ static void via_ac97_class_init(ObjectClass *klass, void *data)
}

static const TypeInfo via_ac97_info = {
.name = "VT82C686B_AC97",
.name = TYPE_VT82C686B_AC97_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT686AC97State),
.class_init = via_ac97_class_init,
};

static void vt82c686b_mc97_realize(PCIDevice *dev, Error **errp)
{
VT686MC97State *s = DO_UPCAST(VT686MC97State, dev, dev);
VT686MC97State *s = VT82C686B_MC97_DEVICE(dev);
uint8_t *pci_conf = s->dev.config;

pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
Expand All @@ -301,7 +317,7 @@ void vt82c686b_mc97_init(PCIBus *bus, int devfn)
{
PCIDevice *dev;

dev = pci_create(bus, devfn, "VT82C686B_MC97");
dev = pci_create(bus, devfn, TYPE_VT82C686B_MC97_DEVICE);
qdev_init_nofail(&dev->qdev);
}

Expand All @@ -320,7 +336,7 @@ static void via_mc97_class_init(ObjectClass *klass, void *data)
}

static const TypeInfo via_mc97_info = {
.name = "VT82C686B_MC97",
.name = TYPE_VT82C686B_MC97_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT686MC97State),
.class_init = via_mc97_class_init,
Expand All @@ -329,7 +345,7 @@ static const TypeInfo via_mc97_info = {
/* vt82c686 pm init */
static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)
{
VT686PMState *s = DO_UPCAST(VT686PMState, dev, dev);
VT686PMState *s = VT82C686B_PM_DEVICE(dev);
uint8_t *pci_conf;

pci_conf = s->dev.config;
Expand Down Expand Up @@ -365,10 +381,10 @@ I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
PCIDevice *dev;
VT686PMState *s;

dev = pci_create(bus, devfn, "VT82C686B_PM");
dev = pci_create(bus, devfn, TYPE_VT82C686B_PM_DEVICE);
qdev_prop_set_uint32(&dev->qdev, "smb_io_base", smb_io_base);

s = DO_UPCAST(VT686PMState, dev, dev);
s = VT82C686B_PM_DEVICE(dev);

qdev_init_nofail(&dev->qdev);

Expand Down Expand Up @@ -398,7 +414,7 @@ static void via_pm_class_init(ObjectClass *klass, void *data)
}

static const TypeInfo via_pm_info = {
.name = "VT82C686B_PM",
.name = TYPE_VT82C686B_PM_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT686PMState),
.class_init = via_pm_class_init,
Expand All @@ -417,7 +433,7 @@ static const VMStateDescription vmstate_via = {
/* init the PCI-to-ISA bridge */
static void vt82c686b_realize(PCIDevice *d, Error **errp)
{
VT82C686BState *vt82c = DO_UPCAST(VT82C686BState, dev, d);
VT82C686BState *vt82c = VT82C686B_DEVICE(d);
uint8_t *pci_conf;
ISABus *isa_bus;
uint8_t *wmask;
Expand Down Expand Up @@ -451,7 +467,8 @@ ISABus *vt82c686b_init(PCIBus *bus, int devfn)
{
PCIDevice *d;

d = pci_create_simple_multifunction(bus, devfn, true, "VT82C686B");
d = pci_create_simple_multifunction(bus, devfn, true,
TYPE_VT82C686B_DEVICE);

return ISA_BUS(qdev_get_child_bus(DEVICE(d), "isa.0"));
}
Expand All @@ -477,7 +494,7 @@ static void via_class_init(ObjectClass *klass, void *data)
}

static const TypeInfo via_info = {
.name = "VT82C686B",
.name = TYPE_VT82C686B_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT82C686BState),
.class_init = via_class_init,
Expand Down

0 comments on commit 417349e

Please sign in to comment.