[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v4 51/58] uhci: convert to memory API
From: |
Avi Kivity |
Subject: |
[Qemu-devel] [RFC v4 51/58] uhci: convert to memory API |
Date: |
Sun, 17 Jul 2011 14:14:18 +0300 |
Signed-off-by: Avi Kivity <address@hidden>
---
hw/usb-uhci.c | 43 +++++++++++++++++++++++++++++--------------
1 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 405fa7b..5202e37 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;
uint16_t cmd; /* cmd register */
uint16_t status;
@@ -1083,18 +1084,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 MemoryRegionOps uhci_ioport_ops = {
+ .old_portio = uhci_portio,
+};
static void uhci_device_destroy(USBBus *bus, USBDevice *dev)
{
@@ -1137,10 +1139,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;
}
@@ -1160,12 +1163,22 @@ 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 PCIDeviceInfo uhci_info[] = {
{
.qdev.name = "piix3-usb-uhci",
.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,
@@ -1175,6 +1188,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,
@@ -1184,6 +1198,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] [RFC v4 16/58] pc: move global memory map out of pc_init1() and into its callers, (continued)
- [Qemu-devel] [RFC v4 16/58] pc: move global memory map out of pc_init1() and into its callers, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 09/58] memory: add backward compatibility for old portio registration, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 48/58] isa-mmio: concert to memory API, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 52/58] xen-platform: convert to memory API, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 24/58] cirrus: simplify mmio BAR access functions, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 46/58] pcnet: convert to memory API, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 57/58] pci: fold BAR mapping function into its caller, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 21/58] pci: add API to get a BAR's mapped address, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 41/58] ahci: convert to memory API, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 32/58] pci: allow I/O BARs to be registered with pci_register_bar_region(), Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 51/58] uhci: convert to memory API,
Avi Kivity <=
- [Qemu-devel] [RFC v4 49/58] sun4u: convert to memory API, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 17/58] pci: pass address space to pci bus when created, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 38/58] ide: convert to memory API, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 45/58] ne2000: convert to memory API, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 39/58] ivshmem: convert to memory API, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 58/58] pci: rename pci_register_bar_region() to pci_register_bar(), Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 56/58] pci: remove pci_register_bar(), Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 44/58] ppc: convert to memory API, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 31/58] pci: pass I/O address space to new PCI bus, Avi Kivity, 2011/07/17
- [Qemu-devel] [RFC v4 23/58] vga: convert vga and its derivatives to the memory API, Avi Kivity, 2011/07/17