Patchwork [v2,10/11] bonito: convert ldma to memory API

login
register
mail settings
Submitter Benoit Canet
Date Nov. 22, 2011, 4:32 p.m.
Message ID <1321979527-23921-11-git-send-email-benoit.canet@gmail.com>
Download mbox | patch
Permalink /patch/127139/
State New
Headers show

Comments

Benoit Canet - Nov. 22, 2011, 4:32 p.m.
Signed-off-by: BenoƮt Canet <benoit.canet@gmail.com>
---
 hw/bonito.c |   39 ++++++++++++++++-----------------------
 1 files changed, 16 insertions(+), 23 deletions(-)

Patch

diff --git a/hw/bonito.c b/hw/bonito.c
index b4c3387..8972f55 100644
--- a/hw/bonito.c
+++ b/hw/bonito.c
@@ -204,6 +204,7 @@  typedef struct PCIBonitoState
     MemoryRegion iomem;
     MemoryRegion iomem_pciconf;
     MemoryRegion iomem_spciconf;
+    MemoryRegion iomem_ldma;
 
     target_phys_addr_t bonito_pciio_start;
     target_phys_addr_t bonito_pciio_length;
@@ -213,10 +214,6 @@  typedef struct PCIBonitoState
     target_phys_addr_t bonito_localio_length;
     int bonito_localio_handle;
 
-    target_phys_addr_t bonito_ldma_start;
-    target_phys_addr_t bonito_ldma_length;
-    int bonito_ldma_handle;
-
     target_phys_addr_t bonito_cop_start;
     target_phys_addr_t bonito_cop_length;
     int bonito_cop_handle;
@@ -346,7 +343,8 @@  static const MemoryRegionOps bonito_pciconf_ops = {
     },
 };
 
-static uint32_t bonito_ldma_readl(void *opaque, target_phys_addr_t addr)
+static uint64_t bonito_ldma_readl(void *opaque, target_phys_addr_t addr,
+                                  unsigned size)
 {
     uint32_t val;
     PCIBonitoState *s = opaque;
@@ -357,23 +355,21 @@  static uint32_t bonito_ldma_readl(void *opaque, target_phys_addr_t addr)
 }
 
 static void bonito_ldma_writel(void *opaque, target_phys_addr_t addr,
-                               uint32_t val)
+                               uint64_t val, unsigned size)
 {
     PCIBonitoState *s = opaque;
 
     ((uint32_t *)(&s->bonldma))[addr/sizeof(uint32_t)] = val & 0xffffffff;
 }
 
-static CPUWriteMemoryFunc * const bonito_ldma_write[] = {
-    NULL,
-    NULL,
-    bonito_ldma_writel,
-};
-
-static CPUReadMemoryFunc * const bonito_ldma_read[] = {
-    NULL,
-    NULL,
-    bonito_ldma_readl,
+static const MemoryRegionOps bonito_ldma_ops = {
+    .read = bonito_ldma_readl,
+    .write = bonito_ldma_writel,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
 };
 
 static uint32_t bonito_cop_readl(void *opaque, target_phys_addr_t addr)
@@ -709,13 +705,10 @@  static int bonito_initfn(PCIDevice *dev)
     sysbus_init_mmio_region(sysbus, &s->iomem_spciconf);
     sysbus_mmio_map(sysbus, 2, BONITO_SPCICONFIG_BASE);
 
-    s->bonito_ldma_handle = cpu_register_io_memory(bonito_ldma_read,
-                                                   bonito_ldma_write, s,
-                                                   DEVICE_NATIVE_ENDIAN);
-    s->bonito_ldma_start = 0xbfe00200;
-    s->bonito_ldma_length = 0x100;
-    cpu_register_physical_memory(s->bonito_ldma_start, s->bonito_ldma_length,
-                                 s->bonito_ldma_handle);
+    memory_region_init_io(&s->iomem_ldma, &bonito_ldma_ops, s,
+                          "ldma", 0x100);
+    sysbus_init_mmio_region(sysbus, &s->iomem_ldma);
+    sysbus_mmio_map(sysbus, 3, 0xbfe00200);
 
     s->bonito_cop_handle = cpu_register_io_memory(bonito_cop_read,
                                                   bonito_cop_write, s,