Patchwork [v2,6/8] ppc: simplify access to PReP I/O region

login
register
mail settings
Submitter Hervé Poussineau
Date June 8, 2013, 5:44 p.m.
Message ID <1370713446-9460-7-git-send-email-hpoussin@reactos.org>
Download mbox | patch
Permalink /patch/249972/
State New
Headers show

Comments

Hervé Poussineau - June 8, 2013, 5:44 p.m.
We can now simply use address_space_rw instead of the more convoluted
cpu_in() and cpu_out() functions.

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

Patch

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,
 };