qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v2 6/8] ppc: simplify access to PReP I/O region


From: Hervé Poussineau
Subject: [Qemu-devel] [PATCH v2 6/8] ppc: simplify access to PReP I/O region
Date: Sun, 9 Jun 2013 01:44:04 +0800

We can now simply use address_space_rw instead of the more convoluted
cpu_in() and cpu_out() functions.

Signed-off-by: Hervé Poussineau <address@hidden>
---
 hw/ppc/prep.c |   65 ++++++++-------------------------------------------------
 1 file changed, 9 insertions(+), 56 deletions(-)

diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index be8a50e..bb77e1f 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -341,75 +341,28 @@ static inline hwaddr prep_IO_address(sysctrl_t *sysctrl,
     return addr;
 }
 
-static void PPC_prep_io_writeb (void *opaque, hwaddr addr,
-                                uint32_t value)
+static uint64_t PPC_prep_io_read(void *opaque, hwaddr addr, unsigned int size)
 {
     sysctrl_t *sysctrl = opaque;
+    uint64_t data = 0;
 
     addr = prep_IO_address(sysctrl, addr);
-    cpu_outb(addr, value);
+    address_space_read(&address_space_io, addr, (uint8_t *)&data, size);
+    return data;
 }
 
-static uint32_t PPC_prep_io_readb (void *opaque, hwaddr addr)
+static void PPC_prep_io_write(void *opaque, hwaddr addr, uint64_t data,
+                              unsigned int size)
 {
     sysctrl_t *sysctrl = opaque;
-    uint32_t ret;
 
     addr = prep_IO_address(sysctrl, addr);
-    ret = cpu_inb(addr);
-
-    return ret;
-}
-
-static void PPC_prep_io_writew (void *opaque, hwaddr addr,
-                                uint32_t value)
-{
-    sysctrl_t *sysctrl = opaque;
-
-    addr = prep_IO_address(sysctrl, addr);
-    PPC_IO_DPRINTF("0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", addr, value);
-    cpu_outw(addr, value);
-}
-
-static uint32_t PPC_prep_io_readw (void *opaque, hwaddr addr)
-{
-    sysctrl_t *sysctrl = opaque;
-    uint32_t ret;
-
-    addr = prep_IO_address(sysctrl, addr);
-    ret = cpu_inw(addr);
-    PPC_IO_DPRINTF("0x" TARGET_FMT_plx " <= 0x%08" PRIx32 "\n", addr, ret);
-
-    return ret;
-}
-
-static void PPC_prep_io_writel (void *opaque, hwaddr addr,
-                                uint32_t value)
-{
-    sysctrl_t *sysctrl = opaque;
-
-    addr = prep_IO_address(sysctrl, addr);
-    PPC_IO_DPRINTF("0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", addr, value);
-    cpu_outl(addr, value);
-}
-
-static uint32_t PPC_prep_io_readl (void *opaque, hwaddr addr)
-{
-    sysctrl_t *sysctrl = opaque;
-    uint32_t ret;
-
-    addr = prep_IO_address(sysctrl, addr);
-    ret = cpu_inl(addr);
-    PPC_IO_DPRINTF("0x" TARGET_FMT_plx " <= 0x%08" PRIx32 "\n", addr, ret);
-
-    return ret;
+    address_space_write(&address_space_io, addr, (uint8_t *)&data, size);
 }
 
 static const MemoryRegionOps PPC_prep_io_ops = {
-    .old_mmio = {
-        .read = { PPC_prep_io_readb, PPC_prep_io_readw, PPC_prep_io_readl },
-        .write = { PPC_prep_io_writeb, PPC_prep_io_writew, PPC_prep_io_writel 
},
-    },
+    .read = PPC_prep_io_read,
+    .write = PPC_prep_io_write,
     .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
-- 
1.7.10.4




reply via email to

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