aboutsummaryrefslogtreecommitdiff
path: root/hw/wdt_i6300esb.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2009-08-21 10:31:34 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-08-27 20:35:24 -0500
commit09aaa1602f9381c0e0fb539390b1793e51bdfc7b (patch)
treeabb82ec81e3f501e46d1104ab8e1af8fdfecd58e /hw/wdt_i6300esb.c
parent9d472d51ea26af6f3006e50a9b5088efcb95e7ce (diff)
qdev: convert watchdogs
-watchdog NAME is now equivalent to -device NAME, except it treats option argument '?' specially, and supports only one watchdog. A side effect is that a device created with -watchdog may now receive a different PCI address. i6300esb is now available on any machine with a PCI bus, not just PCs. ib700 is still PC only, but that could be changed easily. The only remaining use of struct WatchdogTimerModel and watchdog_add_model() is supporting '-watchdog ?'. Should be replaced by searching device_info_list for watchdog devices when we can identify them there. Also fixes ib700 not to use vm_clock before it is initialized: in wdt_ib700_init(), called from register_watchdogs(), which runs before init_timers(). The bug made ib700_write_enable_reg() crash in qemu_del_timer(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/wdt_i6300esb.c')
-rw-r--r--hw/wdt_i6300esb.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/hw/wdt_i6300esb.c b/hw/wdt_i6300esb.c
index 282644e7a0..815dacc539 100644
--- a/hw/wdt_i6300esb.c
+++ b/hw/wdt_i6300esb.c
@@ -413,22 +413,11 @@ static int i6300esb_load(QEMUFile *f, void *vp, int version)
return 0;
}
-/* Create and initialize a virtual Intel 6300ESB during PC creation. */
-static void i6300esb_pc_init(PCIBus *pci_bus)
+static void i6300esb_init(PCIDevice *dev)
{
- I6300State *d;
+ I6300State *d = container_of(dev, I6300State, dev);
uint8_t *pci_conf;
- if (!pci_bus) {
- fprintf(stderr, "wdt_i6300esb: no PCI bus in this machine\n");
- return;
- }
-
- d = (I6300State *)
- pci_register_device (pci_bus, "i6300esb_wdt", sizeof (I6300State),
- -1,
- i6300esb_config_read, i6300esb_config_write);
-
d->reboot_enabled = 1;
d->clock_scale = CLOCK_SCALE_1KHZ;
d->int_type = INT_TYPE_IRQ;
@@ -458,10 +447,20 @@ static void i6300esb_pc_init(PCIBus *pci_bus)
static WatchdogTimerModel model = {
.wdt_name = "i6300esb",
.wdt_description = "Intel 6300ESB",
- .wdt_pc_init = i6300esb_pc_init,
};
-void wdt_i6300esb_init(void)
+static PCIDeviceInfo i6300esb_info = {
+ .qdev.name = "i6300esb",
+ .qdev.size = sizeof(I6300State),
+ .config_read = i6300esb_config_read,
+ .config_write = i6300esb_config_write,
+ .init = i6300esb_init,
+};
+
+static void i6300esb_register_devices(void)
{
watchdog_add_model(&model);
+ pci_qdev_register(&i6300esb_info);
}
+
+device_init(i6300esb_register_devices);