#include "qemu-timer.h"
#include "watchdog.h"
#include "hw.h"
-#include "isa.h"
#include "pc.h"
#include "pci.h"
/* Device state. */
struct I6300State {
- PCIDevice dev; /* PCI device state, must be first field. */
+ PCIDevice dev;
int reboot_enabled; /* "Reboot" on timer expiry. The real action
* performed depends on the -watchdog-action
timeout <<= 5;
/* Get the timeout in units of ticks_per_sec. */
- timeout = ticks_per_sec * timeout / 33000000;
+ timeout = get_ticks_per_sec() * timeout / 33000000;
i6300esb_debug("stage %d, timeout %" PRIi64 "\n", d->stage, timeout);
static void i6300esb_config_write(PCIDevice *dev, uint32_t addr,
uint32_t data, int len)
{
- I6300State *d = (I6300State *) dev;
+ I6300State *d = DO_UPCAST(I6300State, dev, dev);
int old;
i6300esb_debug("addr = %x, data = %x, len = %d\n", addr, data, len);
static uint32_t i6300esb_config_read(PCIDevice *dev, uint32_t addr, int len)
{
- I6300State *d = (I6300State *) dev;
+ I6300State *d = DO_UPCAST(I6300State, dev, dev);
uint32_t data;
i6300esb_debug ("addr = %x, len = %d\n", addr, len);
static void i6300esb_map(PCIDevice *dev, int region_num,
uint32_t addr, uint32_t size, int type)
{
- static CPUReadMemoryFunc *mem_read[3] = {
+ static CPUReadMemoryFunc * const mem_read[3] = {
i6300esb_mem_readb,
i6300esb_mem_readw,
i6300esb_mem_readl,
};
- static CPUWriteMemoryFunc *mem_write[3] = {
+ static CPUWriteMemoryFunc * const mem_write[3] = {
i6300esb_mem_writeb,
i6300esb_mem_writew,
i6300esb_mem_writel,
};
- I6300State *d = (I6300State *) dev;
+ I6300State *d = DO_UPCAST(I6300State, dev, dev);
int io_mem;
i6300esb_debug("addr = %x, size = %x, type = %d\n", addr, size, type);
return 0;
}
-/* Create and initialize a virtual Intel 6300ESB during PC creation. */
-static void i6300esb_pc_init(PCIBus *pci_bus)
+static int i6300esb_init(PCIDevice *dev)
{
- I6300State *d;
+ I6300State *d = DO_UPCAST(I6300State, dev, 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;
register_savevm("i6300esb_wdt", -1, sizeof(I6300State),
i6300esb_save, i6300esb_load, d);
+
+ return 0;
}
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);