From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>, qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH v2 30/38] uhci: convert to memory API
Date: Wed, 3 Aug 2011 14:56:00 +0300 [thread overview]
Message-ID: <1312372568-5215-31-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1312372568-5215-1-git-send-email-avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
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
next prev parent reply other threads:[~2011-08-03 11:56 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-03 11:55 [Qemu-devel] [PATCH v2 00/38] Memory API, batch 2: PCI devices Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 01/38] pci: add API to get a BAR's mapped address Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 02/38] vmsvga: don't remember pci BAR address in callback any more Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 03/38] vga: convert vga and its derivatives to the memory API Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 04/38] cirrus: simplify mmio BAR access functions Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 05/38] cirrus: simplify bitblt " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 06/38] cirrus: simplify vga window mmio " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 07/38] vga: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 08/38] cirrus: simplify linear framebuffer " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 09/38] Integrate I/O memory regions into qemu Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 10/38] pci: pass I/O address space to new PCI bus Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 11/38] pci: allow I/O BARs to be registered with pci_register_bar_region() Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 12/38] rtl8139: convert to memory API Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 13/38] ac97: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 14/38] e1000: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 15/38] eepro100: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 16/38] es1370: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 17/38] ide: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 18/38] ivshmem: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 19/38] virtio-pci: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 20/38] ahci: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 21/38] intel-hda: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 22/38] lsi53c895a: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 23/38] ppc: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 24/38] ne2000: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 25/38] pcnet: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 26/38] i6300esb: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 27/38] isa-mmio: concert " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 28/38] sun4u: convert " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 29/38] ehci: " Avi Kivity
2011-08-03 11:56 ` Avi Kivity [this message]
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 31/38] xen-platform: " Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 32/38] msix: " Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 33/38] pci: remove pci_register_bar_simple() Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 34/38] pci: convert pci rom to memory API Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 35/38] pci: remove pci_register_bar() Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 36/38] pci: fold BAR mapping function into its caller Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 37/38] pci: rename pci_register_bar_region() to pci_register_bar() Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 38/38] pci: remove support for pre memory API BARs Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1312372568-5215-31-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).