[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 31/39] uhci: convert to memory API
From: |
Avi Kivity |
Subject: |
[Qemu-devel] [PATCH 31/39] uhci: convert to memory API |
Date: |
Sun, 31 Jul 2011 20:57:54 +0300 |
Signed-off-by: Avi Kivity <address@hidden>
---
hw/usb-uhci.c | 42 ++++++++++++++++++++++++++++--------------
1 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index da74c57..96a17bd 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -132,6 +132,7 @@ typedef struct UHCIPort {
struct UHCIState {
PCIDevice dev;
+ MemoryRegion io_bar;
USBBus bus; /* Note unused when we're a companion controller */
uint16_t cmd; /* cmd register */
uint16_t status;
@@ -1101,18 +1102,19 @@ static void uhci_frame_timer(void *opaque)
qemu_mod_timer(s->frame_timer, s->expire_time);
}
-static void uhci_map(PCIDevice *pci_dev, int region_num,
- pcibus_t addr, pcibus_t size, int type)
-{
- UHCIState *s = (UHCIState *)pci_dev;
-
- register_ioport_write(addr, 32, 2, uhci_ioport_writew, s);
- register_ioport_read(addr, 32, 2, uhci_ioport_readw, s);
- register_ioport_write(addr, 32, 4, uhci_ioport_writel, s);
- register_ioport_read(addr, 32, 4, uhci_ioport_readl, s);
- register_ioport_write(addr, 32, 1, uhci_ioport_writeb, s);
- register_ioport_read(addr, 32, 1, uhci_ioport_readb, s);
-}
+static const MemoryRegionPortio uhci_portio[] = {
+ { 0, 32, 2, .write = uhci_ioport_writew, },
+ { 0, 32, 2, .read = uhci_ioport_readw, },
+ { 0, 32, 4, .write = uhci_ioport_writel, },
+ { 0, 32, 4, .read = uhci_ioport_readl, },
+ { 0, 32, 1, .write = uhci_ioport_writeb, },
+ { 0, 32, 1, .read = uhci_ioport_readb, },
+ PORTIO_END
+};
+
+static const MemoryRegionOps uhci_ioport_ops = {
+ .old_portio = uhci_portio,
+};
static USBPortOps uhci_port_ops = {
.attach = uhci_attach,
@@ -1159,10 +1161,11 @@ static int usb_uhci_common_initfn(PCIDevice *dev)
qemu_register_reset(uhci_reset, s);
+ memory_region_init_io(&s->io_bar, &uhci_ioport_ops, s, "uhci", 0x20);
/* Use region 4 for consistency with real hardware. BSD guests seem
to rely on this. */
- pci_register_bar(&s->dev, 4, 0x20,
- PCI_BASE_ADDRESS_SPACE_IO, uhci_map);
+ pci_register_bar_region(&s->dev, 4,
+ PCI_BASE_ADDRESS_SPACE_IO, &s->io_bar);
return 0;
}
@@ -1182,6 +1185,14 @@ static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)
return usb_uhci_common_initfn(dev);
}
+static int usb_uhci_exit(PCIDevice *dev)
+{
+ UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
+
+ memory_region_destroy(&s->io_bar);
+ return 0;
+}
+
static Property uhci_properties[] = {
DEFINE_PROP_STRING("masterbus", UHCIState, masterbus),
DEFINE_PROP_UINT32("firstport", UHCIState, firstport, 0),
@@ -1194,6 +1205,7 @@ static PCIDeviceInfo uhci_info[] = {
.qdev.size = sizeof(UHCIState),
.qdev.vmsd = &vmstate_uhci,
.init = usb_uhci_common_initfn,
+ .exit = usb_uhci_exit,
.vendor_id = PCI_VENDOR_ID_INTEL,
.device_id = PCI_DEVICE_ID_INTEL_82371SB_2,
.revision = 0x01,
@@ -1204,6 +1216,7 @@ static PCIDeviceInfo uhci_info[] = {
.qdev.size = sizeof(UHCIState),
.qdev.vmsd = &vmstate_uhci,
.init = usb_uhci_common_initfn,
+ .exit = usb_uhci_exit,
.vendor_id = PCI_VENDOR_ID_INTEL,
.device_id = PCI_DEVICE_ID_INTEL_82371AB_2,
.revision = 0x01,
@@ -1214,6 +1227,7 @@ static PCIDeviceInfo uhci_info[] = {
.qdev.size = sizeof(UHCIState),
.qdev.vmsd = &vmstate_uhci,
.init = usb_uhci_vt82c686b_initfn,
+ .exit = usb_uhci_exit,
.vendor_id = PCI_VENDOR_ID_VIA,
.device_id = PCI_DEVICE_ID_VIA_UHCI,
.revision = 0x01,
--
1.7.5.3
- [Qemu-devel] [PATCH 15/39] e1000: convert to memory API, (continued)
- [Qemu-devel] [PATCH 15/39] e1000: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 10/39] exec.c: fix initialization of system I/O memory region, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 27/39] i6300esb: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 39/39] pci: remove support for pre memory API BARs, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 13/39] rtl8139: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 21/39] ahci: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 12/39] pci: allow I/O BARs to be registered with pci_register_bar_region(), Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 05/39] cirrus: simplify bitblt BAR access functions, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 04/39] cirrus: simplify mmio BAR access functions, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 25/39] ne2000: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 31/39] uhci: convert to memory API,
Avi Kivity <=
- [Qemu-devel] [PATCH 09/39] Integrate I/O memory regions into qemu, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 22/39] intel-hda: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 30/39] ehci: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 08/39] cirrus: simplify linear framebuffer access functions, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 06/39] cirrus: simplify vga window mmio access functions, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 16/39] eepro100: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 20/39] virtio-pci: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 19/39] ivshmem: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 37/39] pci: fold BAR mapping function into its caller, Avi Kivity, 2011/07/31