提交 8f04ee08 编写于 作者: A Anthony Liguori

isa: pic: convert to QEMU Object Model

This converts two devices at once because PIC subclasses ISA and converting
subclasses independently is extremely hard.
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 e855761c
...@@ -220,12 +220,18 @@ static int applesmc_isa_init(ISADevice *dev) ...@@ -220,12 +220,18 @@ static int applesmc_isa_init(ISADevice *dev)
return 0; return 0;
} }
static ISADeviceInfo applesmc_isa_info = { static void qdev_applesmc_class_init(ObjectClass *klass, void *data)
.qdev.name = "isa-applesmc", {
.qdev.size = sizeof(struct AppleSMCStatus), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.reset = qdev_applesmc_isa_reset, ic->init = applesmc_isa_init;
.init = applesmc_isa_init, }
.qdev.props = (Property[]) {
static DeviceInfo applesmc_isa_info = {
.name = "isa-applesmc",
.size = sizeof(struct AppleSMCStatus),
.reset = qdev_applesmc_isa_reset,
.class_init = qdev_applesmc_class_init,
.props = (Property[]) {
DEFINE_PROP_HEX32("iobase", struct AppleSMCStatus, iobase, DEFINE_PROP_HEX32("iobase", struct AppleSMCStatus, iobase,
APPLESMC_DEFAULT_IOBASE), APPLESMC_DEFAULT_IOBASE),
DEFINE_PROP_STRING("osk", struct AppleSMCStatus, osk), DEFINE_PROP_STRING("osk", struct AppleSMCStatus, osk),
......
...@@ -2898,11 +2898,18 @@ static int vga_initfn(ISADevice *dev) ...@@ -2898,11 +2898,18 @@ static int vga_initfn(ISADevice *dev)
return 0; return 0;
} }
static ISADeviceInfo isa_cirrus_vga_info = { static void isa_cirrus_vga_class_init(ObjectClass *klass, void *data)
.qdev.name = "isa-cirrus-vga", {
.qdev.size = sizeof(ISACirrusVGAState), ISADeviceClass *k = ISA_DEVICE_CLASS(klass);
.qdev.vmsd = &vmstate_cirrus_vga,
.init = vga_initfn, k->init = vga_initfn;
}
static DeviceInfo isa_cirrus_vga_info = {
.name = "isa-cirrus-vga",
.size = sizeof(ISACirrusVGAState),
.vmsd = &vmstate_cirrus_vga,
.class_init = isa_cirrus_vga_class_init,
}; };
static void isa_cirrus_vga_register(void) static void isa_cirrus_vga_register(void)
......
...@@ -665,13 +665,19 @@ int cs4231a_init (ISABus *bus) ...@@ -665,13 +665,19 @@ int cs4231a_init (ISABus *bus)
return 0; return 0;
} }
static ISADeviceInfo cs4231a_info = { static void cs4231a_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "cs4231a", {
.qdev.desc = "Crystal Semiconductor CS4231A", ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.size = sizeof (CSState), ic->init = cs4231a_initfn;
.qdev.vmsd = &vmstate_cs4231a, }
.init = cs4231a_initfn,
.qdev.props = (Property[]) { static DeviceInfo cs4231a_info = {
.name = "cs4231a",
.desc = "Crystal Semiconductor CS4231A",
.size = sizeof (CSState),
.vmsd = &vmstate_cs4231a,
.class_init = cs4231a_class_initfn,
.props = (Property[]) {
DEFINE_PROP_HEX32 ("iobase", CSState, port, 0x534), DEFINE_PROP_HEX32 ("iobase", CSState, port, 0x534),
DEFINE_PROP_UINT32 ("irq", CSState, irq, 9), DEFINE_PROP_UINT32 ("irq", CSState, irq, 9),
DEFINE_PROP_UINT32 ("dma", CSState, dma, 3), DEFINE_PROP_UINT32 ("dma", CSState, dma, 3),
......
...@@ -87,11 +87,17 @@ static int debugcon_isa_initfn(ISADevice *dev) ...@@ -87,11 +87,17 @@ static int debugcon_isa_initfn(ISADevice *dev)
return 0; return 0;
} }
static ISADeviceInfo debugcon_isa_info = { static void debugcon_isa_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "isa-debugcon", {
.qdev.size = sizeof(ISADebugconState), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.init = debugcon_isa_initfn, ic->init = debugcon_isa_initfn;
.qdev.props = (Property[]) { }
static DeviceInfo debugcon_isa_info = {
.name = "isa-debugcon",
.size = sizeof(ISADebugconState),
.class_init = debugcon_isa_class_initfn,
.props = (Property[]) {
DEFINE_PROP_HEX32("iobase", ISADebugconState, iobase, 0xe9), DEFINE_PROP_HEX32("iobase", ISADebugconState, iobase, 0xe9),
DEFINE_PROP_CHR("chardev", ISADebugconState, state.chr), DEFINE_PROP_CHR("chardev", ISADebugconState, state.chr),
DEFINE_PROP_HEX32("readback", ISADebugconState, state.readback, 0xe9), DEFINE_PROP_HEX32("readback", ISADebugconState, state.readback, 0xe9),
......
...@@ -1959,15 +1959,21 @@ static const VMStateDescription vmstate_isa_fdc ={ ...@@ -1959,15 +1959,21 @@ static const VMStateDescription vmstate_isa_fdc ={
} }
}; };
static ISADeviceInfo isa_fdc_info = { static void isabus_fdc_class_init1(ObjectClass *klass, void *data)
.init = isabus_fdc_init1, {
.qdev.name = "isa-fdc", ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.fw_name = "fdc", ic->init = isabus_fdc_init1;
.qdev.size = sizeof(FDCtrlISABus), }
.qdev.no_user = 1,
.qdev.vmsd = &vmstate_isa_fdc, static DeviceInfo isa_fdc_info = {
.qdev.reset = fdctrl_external_reset_isa, .class_init = isabus_fdc_class_init1,
.qdev.props = (Property[]) { .name = "isa-fdc",
.fw_name = "fdc",
.size = sizeof(FDCtrlISABus),
.no_user = 1,
.vmsd = &vmstate_isa_fdc,
.reset = fdctrl_external_reset_isa,
.props = (Property[]) {
DEFINE_PROP_DRIVE("driveA", FDCtrlISABus, state.drives[0].bs), DEFINE_PROP_DRIVE("driveA", FDCtrlISABus, state.drives[0].bs),
DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.drives[1].bs), DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.drives[1].bs),
DEFINE_PROP_INT32("bootindexA", FDCtrlISABus, bootindexA, -1), DEFINE_PROP_INT32("bootindexA", FDCtrlISABus, bootindexA, -1),
......
...@@ -299,13 +299,19 @@ int GUS_init (ISABus *bus) ...@@ -299,13 +299,19 @@ int GUS_init (ISABus *bus)
return 0; return 0;
} }
static ISADeviceInfo gus_info = { static void gus_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "gus", {
.qdev.desc = "Gravis Ultrasound GF1", ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.size = sizeof (GUSState), ic->init = gus_initfn;
.qdev.vmsd = &vmstate_gus, }
.init = gus_initfn,
.qdev.props = (Property[]) { static DeviceInfo gus_info = {
.name = "gus",
.desc = "Gravis Ultrasound GF1",
.size = sizeof (GUSState),
.vmsd = &vmstate_gus,
.class_init = gus_class_initfn,
.props = (Property[]) {
DEFINE_PROP_UINT32 ("freq", GUSState, freq, 44100), DEFINE_PROP_UINT32 ("freq", GUSState, freq, 44100),
DEFINE_PROP_HEX32 ("iobase", GUSState, port, 0x240), DEFINE_PROP_HEX32 ("iobase", GUSState, port, 0x240),
DEFINE_PROP_UINT32 ("irq", GUSState, emu.gusirq, 7), DEFINE_PROP_UINT32 ("irq", GUSState, emu.gusirq, 7),
......
...@@ -135,12 +135,19 @@ static int i82374_isa_init(ISADevice *dev) ...@@ -135,12 +135,19 @@ static int i82374_isa_init(ISADevice *dev)
return 0; return 0;
} }
static ISADeviceInfo i82374_isa_info = { static void i82374_class_init(ObjectClass *klass, void *data)
.qdev.name = "i82374", {
.qdev.size = sizeof(ISAi82374State), ISADeviceClass *k = ISA_DEVICE_CLASS(klass);
.qdev.vmsd = &vmstate_isa_i82374,
.init = i82374_isa_init, k->init = i82374_isa_init;
.qdev.props = (Property[]) { }
static DeviceInfo i82374_isa_info = {
.name = "i82374",
.size = sizeof(ISAi82374State),
.vmsd = &vmstate_isa_i82374,
.class_init = i82374_class_init,
.props = (Property[]) {
DEFINE_PROP_HEX32("iobase", ISAi82374State, iobase, 0x400), DEFINE_PROP_HEX32("iobase", ISAi82374State, iobase, 0x400),
DEFINE_PROP_END_OF_LIST() DEFINE_PROP_END_OF_LIST()
}, },
......
...@@ -535,14 +535,20 @@ static int pit_initfn(ISADevice *dev) ...@@ -535,14 +535,20 @@ static int pit_initfn(ISADevice *dev)
return 0; return 0;
} }
static ISADeviceInfo pit_info = { static void pit_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "isa-pit", {
.qdev.size = sizeof(PITState), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.vmsd = &vmstate_pit, ic->init = pit_initfn;
.qdev.reset = pit_reset, }
.qdev.no_user = 1,
.init = pit_initfn, static DeviceInfo pit_info = {
.qdev.props = (Property[]) { .name = "isa-pit",
.size = sizeof(PITState),
.vmsd = &vmstate_pit,
.reset = pit_reset,
.no_user = 1,
.class_init = pit_class_initfn,
.props = (Property[]) {
DEFINE_PROP_UINT32("irq", PITState, irq, -1), DEFINE_PROP_UINT32("irq", PITState, irq, -1),
DEFINE_PROP_HEX32("iobase", PITState, iobase, -1), DEFINE_PROP_HEX32("iobase", PITState, iobase, -1),
DEFINE_PROP_END_OF_LIST(), DEFINE_PROP_END_OF_LIST(),
......
...@@ -472,10 +472,17 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq) ...@@ -472,10 +472,17 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq)
return irq_set; return irq_set;
} }
static PICCommonInfo i8259_info = { static void i8259_class_init(ObjectClass *klass, void *data)
.isadev.qdev.name = "isa-i8259", {
.isadev.qdev.reset = pic_reset, PICCommonClass *k = PIC_COMMON_CLASS(klass);
.init = pic_init,
k->init = pic_init;
}
static DeviceInfo i8259_info = {
.name = "isa-i8259",
.reset = pic_reset,
.class_init = i8259_class_init,
}; };
static void pic_register(void) static void pic_register(void)
......
...@@ -48,8 +48,7 @@ void pic_reset_common(PICCommonState *s) ...@@ -48,8 +48,7 @@ void pic_reset_common(PICCommonState *s)
static void pic_dispatch_pre_save(void *opaque) static void pic_dispatch_pre_save(void *opaque)
{ {
PICCommonState *s = opaque; PICCommonState *s = opaque;
PICCommonInfo *info = PICCommonClass *info = PIC_COMMON_GET_CLASS(s);
DO_UPCAST(PICCommonInfo, isadev.qdev, qdev_get_info(&s->dev.qdev));
if (info->pre_save) { if (info->pre_save) {
info->pre_save(s); info->pre_save(s);
...@@ -59,8 +58,7 @@ static void pic_dispatch_pre_save(void *opaque) ...@@ -59,8 +58,7 @@ static void pic_dispatch_pre_save(void *opaque)
static int pic_dispatch_post_load(void *opaque, int version_id) static int pic_dispatch_post_load(void *opaque, int version_id)
{ {
PICCommonState *s = opaque; PICCommonState *s = opaque;
PICCommonInfo *info = PICCommonClass *info = PIC_COMMON_GET_CLASS(s);
DO_UPCAST(PICCommonInfo, isadev.qdev, qdev_get_info(&s->dev.qdev));
if (info->post_load) { if (info->post_load) {
info->post_load(s); info->post_load(s);
...@@ -71,8 +69,7 @@ static int pic_dispatch_post_load(void *opaque, int version_id) ...@@ -71,8 +69,7 @@ static int pic_dispatch_post_load(void *opaque, int version_id)
static int pic_init_common(ISADevice *dev) static int pic_init_common(ISADevice *dev)
{ {
PICCommonState *s = DO_UPCAST(PICCommonState, dev, dev); PICCommonState *s = DO_UPCAST(PICCommonState, dev, dev);
PICCommonInfo *info = PICCommonClass *info = PIC_COMMON_GET_CLASS(s);
DO_UPCAST(PICCommonInfo, isadev.qdev, qdev_get_info(&dev->qdev));
info->init(s); info->init(s);
...@@ -136,12 +133,34 @@ static Property pic_properties_common[] = { ...@@ -136,12 +133,34 @@ static Property pic_properties_common[] = {
DEFINE_PROP_END_OF_LIST(), DEFINE_PROP_END_OF_LIST(),
}; };
void pic_qdev_register(PICCommonInfo *info) void pic_qdev_register(DeviceInfo *info)
{ {
info->isadev.init = pic_init_common; info->size = sizeof(PICCommonState);
info->isadev.qdev.size = sizeof(PICCommonState); info->vmsd = &vmstate_pic_common;
info->isadev.qdev.vmsd = &vmstate_pic_common; info->no_user = 1;
info->isadev.qdev.no_user = 1; info->props = pic_properties_common;
info->isadev.qdev.props = pic_properties_common; isa_qdev_register_subclass(info, TYPE_PIC_COMMON);
isa_qdev_register(&info->isadev);
} }
static void pic_common_class_init(ObjectClass *klass, void *data)
{
ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
ic->init = pic_init_common;
}
static TypeInfo pic_common_type = {
.name = TYPE_PIC_COMMON,
.parent = TYPE_ISA_DEVICE,
.instance_size = sizeof(PICCommonState),
.class_size = sizeof(PICCommonClass),
.class_init = pic_common_class_init,
.abstract = true,
};
static void register_devices(void)
{
type_register_static(&pic_common_type);
}
device_init(register_devices);
...@@ -31,6 +31,22 @@ ...@@ -31,6 +31,22 @@
typedef struct PICCommonState PICCommonState; typedef struct PICCommonState PICCommonState;
#define TYPE_PIC_COMMON "pic-common"
#define PIC_COMMON(obj) \
OBJECT_CHECK(PICCommon, (obj), TYPE_PIC_COMMON)
#define PIC_COMMON_CLASS(klass) \
OBJECT_CLASS_CHECK(PICCommonClass, (klass), TYPE_PIC_COMMON)
#define PIC_COMMON_GET_CLASS(obj) \
OBJECT_GET_CLASS(PICCommonClass, (obj), TYPE_PIC_COMMON)
typedef struct PICCommonClass
{
ISADeviceClass parent_class;
void (*init)(PICCommonState *s);
void (*pre_save)(PICCommonState *s);
void (*post_load)(PICCommonState *s);
} PICCommonClass;
struct PICCommonState { struct PICCommonState {
ISADevice dev; ISADevice dev;
uint8_t last_irr; /* edge detection */ uint8_t last_irr; /* edge detection */
...@@ -58,19 +74,10 @@ struct PICCommonState { ...@@ -58,19 +74,10 @@ struct PICCommonState {
MemoryRegion elcr_io; MemoryRegion elcr_io;
}; };
typedef struct PICCommonInfo PICCommonInfo;
struct PICCommonInfo {
ISADeviceInfo isadev;
void (*init)(PICCommonState *s);
void (*pre_save)(PICCommonState *s);
void (*post_load)(PICCommonState *s);
};
void pic_reset_common(PICCommonState *s); void pic_reset_common(PICCommonState *s);
ISADevice *i8259_init_chip(const char *name, ISABus *bus, bool master); ISADevice *i8259_init_chip(const char *name, ISABus *bus, bool master);
void pic_qdev_register(PICCommonInfo *info); void pic_qdev_register(DeviceInfo *info);
#endif /* !QEMU_I8259_INTERNAL_H */ #endif /* !QEMU_I8259_INTERNAL_H */
...@@ -94,13 +94,19 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq, ...@@ -94,13 +94,19 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
return dev; return dev;
} }
static ISADeviceInfo isa_ide_info = { static void isa_ide_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "isa-ide", {
.qdev.fw_name = "ide", ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.size = sizeof(ISAIDEState), ic->init = isa_ide_initfn;
.init = isa_ide_initfn, }
.qdev.reset = isa_ide_reset,
.qdev.props = (Property[]) { static DeviceInfo isa_ide_info = {
.name = "isa-ide",
.fw_name = "ide",
.size = sizeof(ISAIDEState),
.class_init = isa_ide_class_initfn,
.reset = isa_ide_reset,
.props = (Property[]) {
DEFINE_PROP_HEX32("iobase", ISAIDEState, iobase, 0x1f0), DEFINE_PROP_HEX32("iobase", ISAIDEState, iobase, 0x1f0),
DEFINE_PROP_HEX32("iobase2", ISAIDEState, iobase2, 0x3f6), DEFINE_PROP_HEX32("iobase2", ISAIDEState, iobase2, 0x3f6),
DEFINE_PROP_UINT32("irq", ISAIDEState, isairq, 14), DEFINE_PROP_UINT32("irq", ISAIDEState, isairq, 14),
......
...@@ -112,20 +112,29 @@ void isa_register_portio_list(ISADevice *dev, uint16_t start, ...@@ -112,20 +112,29 @@ void isa_register_portio_list(ISADevice *dev, uint16_t start,
static int isa_qdev_init(DeviceState *qdev, DeviceInfo *base) static int isa_qdev_init(DeviceState *qdev, DeviceInfo *base)
{ {
ISADevice *dev = DO_UPCAST(ISADevice, qdev, qdev); ISADevice *dev = ISA_DEVICE(qdev);
ISADeviceInfo *info = DO_UPCAST(ISADeviceInfo, qdev, base); ISADeviceClass *klass = ISA_DEVICE_GET_CLASS(dev);
dev->isairq[0] = -1; dev->isairq[0] = -1;
dev->isairq[1] = -1; dev->isairq[1] = -1;
return info->init(dev); if (klass->init) {
return klass->init(dev);
}
return 0;
}
void isa_qdev_register_subclass(DeviceInfo *info, const char *parent)
{
info->init = isa_qdev_init;
info->bus_info = &isa_bus_info;
qdev_register_subclass(info, parent);
} }
void isa_qdev_register(ISADeviceInfo *info) void isa_qdev_register(DeviceInfo *info)
{ {
info->qdev.init = isa_qdev_init; isa_qdev_register_subclass(info, TYPE_ISA_DEVICE);
info->qdev.bus_info = &isa_bus_info;
qdev_register(&info->qdev);
} }
ISADevice *isa_create(ISABus *bus, const char *name) ISADevice *isa_create(ISABus *bus, const char *name)
...@@ -137,7 +146,7 @@ ISADevice *isa_create(ISABus *bus, const char *name) ...@@ -137,7 +146,7 @@ ISADevice *isa_create(ISABus *bus, const char *name)
name); name);
} }
dev = qdev_create(&bus->qbus, name); dev = qdev_create(&bus->qbus, name);
return DO_UPCAST(ISADevice, qdev, dev); return ISA_DEVICE(dev);
} }
ISADevice *isa_try_create(ISABus *bus, const char *name) ISADevice *isa_try_create(ISABus *bus, const char *name)
...@@ -149,7 +158,7 @@ ISADevice *isa_try_create(ISABus *bus, const char *name) ...@@ -149,7 +158,7 @@ ISADevice *isa_try_create(ISABus *bus, const char *name)
name); name);
} }
dev = qdev_try_create(&bus->qbus, name); dev = qdev_try_create(&bus->qbus, name);
return DO_UPCAST(ISADevice, qdev, dev); return ISA_DEVICE(dev);
} }
ISADevice *isa_create_simple(ISABus *bus, const char *name) ISADevice *isa_create_simple(ISABus *bus, const char *name)
...@@ -163,7 +172,7 @@ ISADevice *isa_create_simple(ISABus *bus, const char *name) ...@@ -163,7 +172,7 @@ ISADevice *isa_create_simple(ISABus *bus, const char *name)
static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent) static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
{ {
ISADevice *d = DO_UPCAST(ISADevice, qdev, dev); ISADevice *d = ISA_DEVICE(dev);
if (d->isairq[1] != -1) { if (d->isairq[1] != -1) {
monitor_printf(mon, "%*sisa irqs %d,%d\n", indent, "", monitor_printf(mon, "%*sisa irqs %d,%d\n", indent, "",
...@@ -188,9 +197,18 @@ static SysBusDeviceInfo isabus_bridge_info = { ...@@ -188,9 +197,18 @@ static SysBusDeviceInfo isabus_bridge_info = {
.qdev.no_user = 1, .qdev.no_user = 1,
}; };
static TypeInfo isa_device_type_info = {
.name = TYPE_ISA_DEVICE,
.parent = TYPE_DEVICE,
.instance_size = sizeof(ISADevice),
.abstract = true,
.class_size = sizeof(ISADeviceClass),
};
static void isabus_register_devices(void) static void isabus_register_devices(void)
{ {
sysbus_register_withprop(&isabus_bridge_info); sysbus_register_withprop(&isabus_bridge_info);
type_register_static(&isa_device_type_info);
} }
static char *isabus_get_fw_dev_path(DeviceState *dev) static char *isabus_get_fw_dev_path(DeviceState *dev)
......
...@@ -10,7 +10,19 @@ ...@@ -10,7 +10,19 @@
#define ISA_NUM_IRQS 16 #define ISA_NUM_IRQS 16
typedef struct ISADevice ISADevice; typedef struct ISADevice ISADevice;
typedef struct ISADeviceInfo ISADeviceInfo;
#define TYPE_ISA_DEVICE "isa-device"
#define ISA_DEVICE(obj) \
OBJECT_CHECK(ISADevice, (obj), TYPE_ISA_DEVICE)
#define ISA_DEVICE_CLASS(klass) \
OBJECT_CLASS_CHECK(ISADeviceClass, (klass), TYPE_ISA_DEVICE)
#define ISA_DEVICE_GET_CLASS(obj) \
OBJECT_GET_CLASS(ISADeviceClass, (obj), TYPE_ISA_DEVICE)
typedef struct ISADeviceClass {
DeviceClass parent_class;
int (*init)(ISADevice *dev);
} ISADeviceClass;
struct ISABus { struct ISABus {
BusState qbus; BusState qbus;
...@@ -25,17 +37,12 @@ struct ISADevice { ...@@ -25,17 +37,12 @@ struct ISADevice {
int ioport_id; int ioport_id;
}; };
typedef int (*isa_qdev_initfn)(ISADevice *dev);
struct ISADeviceInfo {
DeviceInfo qdev;
isa_qdev_initfn init;
};
ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io); ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
void isa_bus_irqs(ISABus *bus, qemu_irq *irqs); void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
qemu_irq isa_get_irq(ISADevice *dev, int isairq); qemu_irq isa_get_irq(ISADevice *dev, int isairq);
void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq); void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
void isa_qdev_register(ISADeviceInfo *info); void isa_qdev_register(DeviceInfo *info);
void isa_qdev_register_subclass(DeviceInfo *info, const char *parent);
MemoryRegion *isa_address_space(ISADevice *dev); MemoryRegion *isa_address_space(ISADevice *dev);
ISADevice *isa_create(ISABus *bus, const char *name); ISADevice *isa_create(ISABus *bus, const char *name);
ISADevice *isa_try_create(ISABus *bus, const char *name); ISADevice *isa_try_create(ISABus *bus, const char *name);
......
...@@ -112,12 +112,19 @@ qemu_irq *kvm_i8259_init(ISABus *bus) ...@@ -112,12 +112,19 @@ qemu_irq *kvm_i8259_init(ISABus *bus)
return qemu_allocate_irqs(kvm_pic_set_irq, NULL, ISA_NUM_IRQS); return qemu_allocate_irqs(kvm_pic_set_irq, NULL, ISA_NUM_IRQS);
} }
static PICCommonInfo kvm_i8259_info = { static void kvm_i8259_class_init(ObjectClass *klass, void *data)
.isadev.qdev.name = "kvm-i8259", {
.isadev.qdev.reset = kvm_pic_reset, PICCommonClass *k = PIC_COMMON_CLASS(klass);
.init = kvm_pic_init,
.pre_save = kvm_pic_get, k->init = kvm_pic_init;
.post_load = kvm_pic_put, k->pre_save = kvm_pic_get;
k->post_load = kvm_pic_put;
}
static DeviceInfo kvm_i8259_info = {
.name = "kvm-i8259",
.reset = kvm_pic_reset,
.class_init = kvm_i8259_class_init,
}; };
static void kvm_pic_register(void) static void kvm_pic_register(void)
......
...@@ -720,13 +720,19 @@ static int m48t59_init1(SysBusDevice *dev) ...@@ -720,13 +720,19 @@ static int m48t59_init1(SysBusDevice *dev)
return 0; return 0;
} }
static ISADeviceInfo m48t59_isa_info = { static void m48t59_init_class_isa1(ObjectClass *klass, void *data)
.init = m48t59_init_isa1, {
.qdev.name = "m48t59_isa", ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.size = sizeof(M48t59ISAState), ic->init = m48t59_init_isa1;
.qdev.reset = m48t59_reset_isa, }
.qdev.no_user = 1,
.qdev.props = (Property[]) { static DeviceInfo m48t59_isa_info = {
.class_init = m48t59_init_class_isa1,
.name = "m48t59_isa",
.size = sizeof(M48t59ISAState),
.reset = m48t59_reset_isa,
.no_user = 1,
.props = (Property[]) {
DEFINE_PROP_UINT32("size", M48t59ISAState, state.size, -1), DEFINE_PROP_UINT32("size", M48t59ISAState, state.size, -1),
DEFINE_PROP_UINT32("type", M48t59ISAState, state.type, -1), DEFINE_PROP_UINT32("type", M48t59ISAState, state.type, -1),
DEFINE_PROP_HEX32( "io_base", M48t59ISAState, state.io_base, 0), DEFINE_PROP_HEX32( "io_base", M48t59ISAState, state.io_base, 0),
......
...@@ -629,7 +629,7 @@ static void visit_type_int32(Visitor *v, int *value, const char *name, Error **e ...@@ -629,7 +629,7 @@ static void visit_type_int32(Visitor *v, int *value, const char *name, Error **e
static void rtc_get_date(DeviceState *dev, Visitor *v, void *opaque, static void rtc_get_date(DeviceState *dev, Visitor *v, void *opaque,
const char *name, Error **errp) const char *name, Error **errp)
{ {
ISADevice *isa = DO_UPCAST(ISADevice, qdev, dev); ISADevice *isa = ISA_DEVICE(dev);
RTCState *s = DO_UPCAST(RTCState, dev, isa); RTCState *s = DO_UPCAST(RTCState, dev, isa);
visit_start_struct(v, NULL, "struct tm", name, 0, errp); visit_start_struct(v, NULL, "struct tm", name, 0, errp);
...@@ -699,13 +699,19 @@ ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq) ...@@ -699,13 +699,19 @@ ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
return dev; return dev;
} }
static ISADeviceInfo mc146818rtc_info = { static void rtc_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "mc146818rtc", {
.qdev.size = sizeof(RTCState), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.no_user = 1, ic->init = rtc_initfn;
.qdev.vmsd = &vmstate_rtc, }
.init = rtc_initfn,
.qdev.props = (Property[]) { static DeviceInfo mc146818rtc_info = {
.name = "mc146818rtc",
.size = sizeof(RTCState),
.no_user = 1,
.vmsd = &vmstate_rtc,
.class_init = rtc_class_initfn,
.props = (Property[]) {
DEFINE_PROP_INT32("base_year", RTCState, base_year, 1980), DEFINE_PROP_INT32("base_year", RTCState, base_year, 1980),
DEFINE_PROP_END_OF_LIST(), DEFINE_PROP_END_OF_LIST(),
} }
......
...@@ -82,11 +82,17 @@ static int isa_ne2000_initfn(ISADevice *dev) ...@@ -82,11 +82,17 @@ static int isa_ne2000_initfn(ISADevice *dev)
return 0; return 0;
} }
static ISADeviceInfo ne2000_isa_info = { static void isa_ne2000_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "ne2k_isa", {
.qdev.size = sizeof(ISANE2000State), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.init = isa_ne2000_initfn, ic->init = isa_ne2000_initfn;
.qdev.props = (Property[]) { }
static DeviceInfo ne2000_isa_info = {
.name = "ne2k_isa",
.size = sizeof(ISANE2000State),
.class_init = isa_ne2000_class_initfn,
.props = (Property[]) {
DEFINE_PROP_HEX32("iobase", ISANE2000State, iobase, 0x300), DEFINE_PROP_HEX32("iobase", ISANE2000State, iobase, 0x300),
DEFINE_PROP_UINT32("irq", ISANE2000State, isairq, 9), DEFINE_PROP_UINT32("irq", ISANE2000State, isairq, 9),
DEFINE_NIC_PROPERTIES(ISANE2000State, ne2000.c), DEFINE_NIC_PROPERTIES(ISANE2000State, ne2000.c),
......
...@@ -583,11 +583,17 @@ bool parallel_mm_init(MemoryRegion *address_space, ...@@ -583,11 +583,17 @@ bool parallel_mm_init(MemoryRegion *address_space,
return true; return true;
} }
static ISADeviceInfo parallel_isa_info = { static void parallel_isa_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "isa-parallel", {
.qdev.size = sizeof(ISAParallelState), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.init = parallel_isa_initfn, ic->init = parallel_isa_initfn;
.qdev.props = (Property[]) { }
static DeviceInfo parallel_isa_info = {
.name = "isa-parallel",
.size = sizeof(ISAParallelState),
.class_init = parallel_isa_class_initfn,
.props = (Property[]) {
DEFINE_PROP_UINT32("index", ISAParallelState, index, -1), DEFINE_PROP_UINT32("index", ISAParallelState, index, -1),
DEFINE_PROP_HEX32("iobase", ISAParallelState, iobase, -1), DEFINE_PROP_HEX32("iobase", ISAParallelState, iobase, -1),
DEFINE_PROP_UINT32("irq", ISAParallelState, isairq, 7), DEFINE_PROP_UINT32("irq", ISAParallelState, isairq, 7),
......
...@@ -497,13 +497,19 @@ static int port92_initfn(ISADevice *dev) ...@@ -497,13 +497,19 @@ static int port92_initfn(ISADevice *dev)
return 0; return 0;
} }
static ISADeviceInfo port92_info = { static void port92_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "port92", {
.qdev.size = sizeof(Port92State), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.vmsd = &vmstate_port92_isa, ic->init = port92_initfn;
.qdev.no_user = 1, }
.qdev.reset = port92_reset,
.init = port92_initfn, static DeviceInfo port92_info = {
.name = "port92",
.size = sizeof(Port92State),
.vmsd = &vmstate_port92_isa,
.no_user = 1,
.reset = port92_reset,
.class_init = port92_class_initfn,
}; };
static void port92_register(void) static void port92_register(void)
......
...@@ -497,12 +497,18 @@ static int i8042_initfn(ISADevice *dev) ...@@ -497,12 +497,18 @@ static int i8042_initfn(ISADevice *dev)
return 0; return 0;
} }
static ISADeviceInfo i8042_info = { static void i8042_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "i8042", {
.qdev.size = sizeof(ISAKBDState), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.vmsd = &vmstate_kbd_isa, ic->init = i8042_initfn;
.qdev.no_user = 1, }
.init = i8042_initfn,
static DeviceInfo i8042_info = {
.name = "i8042",
.size = sizeof(ISAKBDState),
.vmsd = &vmstate_kbd_isa,
.no_user = 1,
.class_init = i8042_class_initfn,
}; };
static void i8042_register(void) static void i8042_register(void)
......
...@@ -1391,13 +1391,19 @@ int SB16_init (ISABus *bus) ...@@ -1391,13 +1391,19 @@ int SB16_init (ISABus *bus)
return 0; return 0;
} }
static ISADeviceInfo sb16_info = { static void sb16_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "sb16", {
.qdev.desc = "Creative Sound Blaster 16", ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.size = sizeof (SB16State), ic->init = sb16_initfn;
.qdev.vmsd = &vmstate_sb16, }
.init = sb16_initfn,
.qdev.props = (Property[]) { static DeviceInfo sb16_info = {
.name = "sb16",
.desc = "Creative Sound Blaster 16",
.size = sizeof (SB16State),
.vmsd = &vmstate_sb16,
.class_init = sb16_class_initfn,
.props = (Property[]) {
DEFINE_PROP_HEX32 ("version", SB16State, ver, 0x0405), /* 4.5 */ DEFINE_PROP_HEX32 ("version", SB16State, ver, 0x0405), /* 4.5 */
DEFINE_PROP_HEX32 ("iobase", SB16State, port, 0x220), DEFINE_PROP_HEX32 ("iobase", SB16State, port, 0x220),
DEFINE_PROP_UINT32 ("irq", SB16State, irq, 5), DEFINE_PROP_UINT32 ("irq", SB16State, irq, 5),
......
...@@ -879,12 +879,18 @@ SerialState *serial_mm_init(MemoryRegion *address_space, ...@@ -879,12 +879,18 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
return s; return s;
} }
static ISADeviceInfo serial_isa_info = { static void serial_isa_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "isa-serial", {
.qdev.size = sizeof(ISASerialState), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.vmsd = &vmstate_isa_serial, ic->init = serial_isa_initfn;
.init = serial_isa_initfn, }
.qdev.props = (Property[]) {
static DeviceInfo serial_isa_info = {
.name = "isa-serial",
.size = sizeof(ISASerialState),
.vmsd = &vmstate_isa_serial,
.class_init = serial_isa_class_initfn,
.props = (Property[]) {
DEFINE_PROP_UINT32("index", ISASerialState, index, -1), DEFINE_PROP_UINT32("index", ISASerialState, index, -1),
DEFINE_PROP_HEX32("iobase", ISASerialState, iobase, -1), DEFINE_PROP_HEX32("iobase", ISASerialState, iobase, -1),
DEFINE_PROP_UINT32("irq", ISASerialState, isairq, -1), DEFINE_PROP_UINT32("irq", ISASerialState, isairq, -1),
......
...@@ -40,12 +40,17 @@ static int sga_initfn(ISADevice *dev) ...@@ -40,12 +40,17 @@ static int sga_initfn(ISADevice *dev)
rom_add_vga(SGABIOS_FILENAME); rom_add_vga(SGABIOS_FILENAME);
return 0; return 0;
} }
static void sga_class_initfn(ObjectClass *klass, void *data)
{
ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
ic->init = sga_initfn;
}
static ISADeviceInfo sga_info = { static DeviceInfo sga_info = {
.qdev.name = "sga", .name = "sga",
.qdev.desc = "Serial Graphics Adapter", .desc = "Serial Graphics Adapter",
.qdev.size = sizeof(ISASGAState), .size = sizeof(ISASGAState),
.init = sga_initfn, .class_init = sga_class_initfn,
}; };
static void sga_register(void) static void sga_register(void)
......
...@@ -69,12 +69,18 @@ static int vga_initfn(ISADevice *dev) ...@@ -69,12 +69,18 @@ static int vga_initfn(ISADevice *dev)
return 0; return 0;
} }
static ISADeviceInfo vga_info = { static void vga_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "isa-vga", {
.qdev.size = sizeof(ISAVGAState), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.vmsd = &vmstate_vga_common, ic->init = vga_initfn;
.qdev.reset = vga_reset_isa, }
.init = vga_initfn,
static DeviceInfo vga_info = {
.name = "isa-vga",
.size = sizeof(ISAVGAState),
.vmsd = &vmstate_vga_common,
.reset = vga_reset_isa,
.class_init = vga_class_initfn,
}; };
static void vga_register(void) static void vga_register(void)
......
...@@ -269,14 +269,20 @@ static int vmmouse_initfn(ISADevice *dev) ...@@ -269,14 +269,20 @@ static int vmmouse_initfn(ISADevice *dev)
return 0; return 0;
} }
static ISADeviceInfo vmmouse_info = { static void vmmouse_class_initfn(ObjectClass *klass, void *data)
.init = vmmouse_initfn, {
.qdev.name = "vmmouse", ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.size = sizeof(VMMouseState), ic->init = vmmouse_initfn;
.qdev.vmsd = &vmstate_vmmouse, }
.qdev.no_user = 1,
.qdev.reset = vmmouse_reset, static DeviceInfo vmmouse_info = {
.qdev.props = (Property[]) { .class_init = vmmouse_class_initfn,
.name = "vmmouse",
.size = sizeof(VMMouseState),
.vmsd = &vmstate_vmmouse,
.no_user = 1,
.reset = vmmouse_reset,
.props = (Property[]) {
DEFINE_PROP_PTR("ps2_mouse", VMMouseState, ps2_mouse), DEFINE_PROP_PTR("ps2_mouse", VMMouseState, ps2_mouse),
DEFINE_PROP_END_OF_LIST(), DEFINE_PROP_END_OF_LIST(),
} }
......
...@@ -144,11 +144,17 @@ static int vmport_initfn(ISADevice *dev) ...@@ -144,11 +144,17 @@ static int vmport_initfn(ISADevice *dev)
return 0; return 0;
} }
static ISADeviceInfo vmport_info = { static void vmport_class_initfn(ObjectClass *klass, void *data)
.qdev.name = "vmport", {
.qdev.size = sizeof(VMPortState), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.no_user = 1, ic->init = vmport_initfn;
.init = vmport_initfn, }
static DeviceInfo vmport_info = {
.name = "vmport",
.size = sizeof(VMPortState),
.no_user = 1,
.class_init = vmport_class_initfn,
}; };
static void vmport_dev_register(void) static void vmport_dev_register(void)
......
...@@ -120,12 +120,18 @@ static WatchdogTimerModel model = { ...@@ -120,12 +120,18 @@ static WatchdogTimerModel model = {
.wdt_description = "iBASE 700", .wdt_description = "iBASE 700",
}; };
static ISADeviceInfo wdt_ib700_info = { static void wdt_ib700_class_init(ObjectClass *klass, void *data)
.qdev.name = "ib700", {
.qdev.size = sizeof(IB700State), ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
.qdev.vmsd = &vmstate_ib700, ic->init = wdt_ib700_init;
.qdev.reset = wdt_ib700_reset, }
.init = wdt_ib700_init,
static DeviceInfo wdt_ib700_info = {
.name = "ib700",
.size = sizeof(IB700State),
.vmsd = &vmstate_ib700,
.reset = wdt_ib700_reset,
.class_init = wdt_ib700_class_init,
}; };
static void wdt_ib700_register_devices(void) static void wdt_ib700_register_devices(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册