i6300esb: convert to memory API
Also add missing destructor. Reviewed-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
bd8d6f7cad
commit
d9c6ebd1c1
@ -66,6 +66,7 @@
|
|||||||
/* Device state. */
|
/* Device state. */
|
||||||
struct I6300State {
|
struct I6300State {
|
||||||
PCIDevice dev;
|
PCIDevice dev;
|
||||||
|
MemoryRegion io_mem;
|
||||||
|
|
||||||
int reboot_enabled; /* "Reboot" on timer expiry. The real action
|
int reboot_enabled; /* "Reboot" on timer expiry. The real action
|
||||||
* performed depends on the -watchdog-action
|
* performed depends on the -watchdog-action
|
||||||
@ -355,6 +356,22 @@ static void i6300esb_mem_writel(void *vp, target_phys_addr_t addr, uint32_t val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const MemoryRegionOps i6300esb_ops = {
|
||||||
|
.old_mmio = {
|
||||||
|
.read = {
|
||||||
|
i6300esb_mem_readb,
|
||||||
|
i6300esb_mem_readw,
|
||||||
|
i6300esb_mem_readl,
|
||||||
|
},
|
||||||
|
.write = {
|
||||||
|
i6300esb_mem_writeb,
|
||||||
|
i6300esb_mem_writew,
|
||||||
|
i6300esb_mem_writel,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||||
|
};
|
||||||
|
|
||||||
static const VMStateDescription vmstate_i6300esb = {
|
static const VMStateDescription vmstate_i6300esb = {
|
||||||
.name = "i6300esb_wdt",
|
.name = "i6300esb_wdt",
|
||||||
.version_id = sizeof(I6300State),
|
.version_id = sizeof(I6300State),
|
||||||
@ -381,31 +398,28 @@ static const VMStateDescription vmstate_i6300esb = {
|
|||||||
static int i6300esb_init(PCIDevice *dev)
|
static int i6300esb_init(PCIDevice *dev)
|
||||||
{
|
{
|
||||||
I6300State *d = DO_UPCAST(I6300State, dev, dev);
|
I6300State *d = DO_UPCAST(I6300State, dev, dev);
|
||||||
int io_mem;
|
|
||||||
static CPUReadMemoryFunc * const mem_read[3] = {
|
|
||||||
i6300esb_mem_readb,
|
|
||||||
i6300esb_mem_readw,
|
|
||||||
i6300esb_mem_readl,
|
|
||||||
};
|
|
||||||
static CPUWriteMemoryFunc * const mem_write[3] = {
|
|
||||||
i6300esb_mem_writeb,
|
|
||||||
i6300esb_mem_writew,
|
|
||||||
i6300esb_mem_writel,
|
|
||||||
};
|
|
||||||
|
|
||||||
i6300esb_debug("I6300State = %p\n", d);
|
i6300esb_debug("I6300State = %p\n", d);
|
||||||
|
|
||||||
d->timer = qemu_new_timer_ns(vm_clock, i6300esb_timer_expired, d);
|
d->timer = qemu_new_timer_ns(vm_clock, i6300esb_timer_expired, d);
|
||||||
d->previous_reboot_flag = 0;
|
d->previous_reboot_flag = 0;
|
||||||
|
|
||||||
io_mem = cpu_register_io_memory(mem_read, mem_write, d,
|
memory_region_init_io(&d->io_mem, &i6300esb_ops, d, "i6300esb", 0x10);
|
||||||
DEVICE_NATIVE_ENDIAN);
|
pci_register_bar_region(&d->dev, 0, 0, &d->io_mem);
|
||||||
pci_register_bar_simple(&d->dev, 0, 0x10, 0, io_mem);
|
|
||||||
/* qemu_register_coalesced_mmio (addr, 0x10); ? */
|
/* qemu_register_coalesced_mmio (addr, 0x10); ? */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int i6300esb_exit(PCIDevice *dev)
|
||||||
|
{
|
||||||
|
I6300State *d = DO_UPCAST(I6300State, dev, dev);
|
||||||
|
|
||||||
|
memory_region_destroy(&d->io_mem);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static WatchdogTimerModel model = {
|
static WatchdogTimerModel model = {
|
||||||
.wdt_name = "i6300esb",
|
.wdt_name = "i6300esb",
|
||||||
.wdt_description = "Intel 6300ESB",
|
.wdt_description = "Intel 6300ESB",
|
||||||
@ -419,6 +433,7 @@ static PCIDeviceInfo i6300esb_info = {
|
|||||||
.config_read = i6300esb_config_read,
|
.config_read = i6300esb_config_read,
|
||||||
.config_write = i6300esb_config_write,
|
.config_write = i6300esb_config_write,
|
||||||
.init = i6300esb_init,
|
.init = i6300esb_init,
|
||||||
|
.exit = i6300esb_exit,
|
||||||
.vendor_id = PCI_VENDOR_ID_INTEL,
|
.vendor_id = PCI_VENDOR_ID_INTEL,
|
||||||
.device_id = PCI_DEVICE_ID_INTEL_ESB_9,
|
.device_id = PCI_DEVICE_ID_INTEL_ESB_9,
|
||||||
.class_id = PCI_CLASS_SYSTEM_OTHER,
|
.class_id = PCI_CLASS_SYSTEM_OTHER,
|
||||||
|
Loading…
Reference in New Issue
Block a user