qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 3/8] uhci: do not use old_portio-style callbacks


From: Hervé Poussineau
Subject: [Qemu-devel] [RFC 3/8] uhci: do not use old_portio-style callbacks
Date: Sun, 23 Dec 2012 16:32:43 +0100

Signed-off-by: Hervé Poussineau <address@hidden>
---
 hw/usb/hcd-uhci.c |   43 +++++++++++++++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index d053791..cc47635 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1213,18 +1213,41 @@ static void uhci_frame_timer(void *opaque)
     qemu_mod_timer(s->frame_timer, s->expire_time);
 }
 
-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_OF_LIST()
-};
+static uint64_t uhci_ioport_read(void *opaque, hwaddr addr, unsigned int size)
+{
+    switch (size) {
+    case 1:
+        return uhci_ioport_readb(opaque, (uint32_t)addr);
+    case 2:
+        return uhci_ioport_readw(opaque, (uint32_t)addr);
+    case 4:
+        return uhci_ioport_readl(opaque, (uint32_t)addr);
+    default:
+        return ~0UL;
+    }
+}
+
+static void uhci_ioport_write(void *opaque, hwaddr addr, uint64_t data,
+                              unsigned int size)
+{
+    switch (size) {
+    case 1:
+        uhci_ioport_writeb(opaque, (uint32_t)addr, (uint32_t)data);
+        break;
+    case 2:
+        uhci_ioport_writew(opaque, (uint32_t)addr, (uint32_t)data);
+        break;
+    case 4:
+        uhci_ioport_writel(opaque, (uint32_t)addr, (uint32_t)data);
+        break;
+    default:
+        break;
+    }
+}
 
 static const MemoryRegionOps uhci_ioport_ops = {
-    .old_portio = uhci_portio,
+    .read = uhci_ioport_read,
+    .write = uhci_ioport_write,
 };
 
 static USBPortOps uhci_port_ops = {
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]