qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 07/18] r2d: convert to memory API
Date: Mon, 17 Oct 2011 16:02:36 +0200	[thread overview]
Message-ID: <1318860167-14014-8-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1318860167-14014-1-git-send-email-avi@redhat.com>

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/r2d.c |   35 +++++++++++++++--------------------
 1 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/hw/r2d.c b/hw/r2d.c
index 82377a0..b65fd42 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -82,6 +82,7 @@
 
 /* output pin */
     qemu_irq irl;
+    MemoryRegion iomem;
 } r2d_fpga_t;
 
 enum r2d_fpga_irq {
@@ -168,31 +169,25 @@ static uint32_t r2d_fpga_read(void *opaque, target_phys_addr_t addr)
     }
 }
 
-static CPUReadMemoryFunc * const r2d_fpga_readfn[] = {
-    r2d_fpga_read,
-    r2d_fpga_read,
-    NULL,
+static const MemoryRegionOps r2d_fpga_ops = {
+    .old_mmio = {
+        .read = { r2d_fpga_read, r2d_fpga_read, NULL, },
+        .write = { r2d_fpga_write, r2d_fpga_write, NULL, },
+    },
+    .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-static CPUWriteMemoryFunc * const r2d_fpga_writefn[] = {
-    r2d_fpga_write,
-    r2d_fpga_write,
-    NULL,
-};
-
-static qemu_irq *r2d_fpga_init(target_phys_addr_t base, qemu_irq irl)
+static qemu_irq *r2d_fpga_init(MemoryRegion *sysmem,
+                               target_phys_addr_t base, qemu_irq irl)
 {
-    int iomemtype;
     r2d_fpga_t *s;
 
     s = g_malloc0(sizeof(r2d_fpga_t));
 
     s->irl = irl;
 
-    iomemtype = cpu_register_io_memory(r2d_fpga_readfn,
-				       r2d_fpga_writefn, s,
-                                       DEVICE_NATIVE_ENDIAN);
-    cpu_register_physical_memory(base, 0x40, iomemtype);
+    memory_region_init_io(&s->iomem, &r2d_fpga_ops, s, "r2d-fpga", 0x40);
+    memory_region_add_subregion(sysmem, base, &s->iomem);
     return qemu_allocate_irqs(r2d_fpga_irq_set, s, NR_IRQS);
 }
 
@@ -232,7 +227,7 @@ static void r2d_init(ram_addr_t ram_size,
     CPUState *env;
     ResetData *reset_info;
     struct SH7750State *s;
-    ram_addr_t sdram_addr;
+    MemoryRegion *sdram = g_new(MemoryRegion, 1);
     qemu_irq *irq;
     DriveInfo *dinfo;
     int i;
@@ -252,11 +247,11 @@ static void r2d_init(ram_addr_t ram_size,
     qemu_register_reset(main_cpu_reset, reset_info);
 
     /* Allocate memory space */
-    sdram_addr = qemu_ram_alloc(NULL, "r2d.sdram", SDRAM_SIZE);
-    cpu_register_physical_memory(SDRAM_BASE, SDRAM_SIZE, sdram_addr);
+    memory_region_init_ram(sdram, NULL, "r2d.sdram", SDRAM_SIZE);
+    memory_region_add_subregion(address_space_mem, SDRAM_BASE, sdram);
     /* Register peripherals */
     s = sh7750_init(env);
-    irq = r2d_fpga_init(0x04000000, sh7750_irl(s));
+    irq = r2d_fpga_init(address_space_mem, 0x04000000, sh7750_irl(s));
     sysbus_create_varargs("sh_pci", 0x1e200000, irq[PCI_INTA], irq[PCI_INTB],
                           irq[PCI_INTC], irq[PCI_INTD], NULL);
 
-- 
1.7.6.3

  parent reply	other threads:[~2011-10-17 14:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-17 14:02 [Qemu-devel] [PATCH 00/18] Memory API conversions, batch 12 Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 01/18] ppc_oldworld: convert to memory API Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 02/18] ppc_prep: " Avi Kivity
2012-01-05 14:45   ` Andreas Färber
2012-01-05 14:57     ` Avi Kivity
2012-01-05 15:32       ` Andreas Färber
2011-10-17 14:02 ` [Qemu-devel] [PATCH 03/18] pxa2xx: convert to memory API (part I) Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 04/18] pxa2xx: convert to memory API (part II) Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 05/18] pci: simplify memory region registration Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 06/18] ppcr500_mpc8544ds: convert to memory API Avi Kivity
2011-10-17 14:02 ` Avi Kivity [this message]
2011-10-17 14:02 ` [Qemu-devel] [PATCH 08/18] realview: " Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 09/18] s390-virtio: " Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 10/18] sm501: " Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 11/18] spapr: " Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 12/18] spitz: " Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 13/18] strongarm: " Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 14/18] sun4m: " Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 15/18] sun4u: " Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 16/18] syborg: " Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 17/18] tc63963xb: " Avi Kivity
2011-10-17 14:02 ` [Qemu-devel] [PATCH 18/18] tcx: " Avi Kivity
2011-10-17 19:13   ` Blue Swirl
2011-10-17 20:48     ` Avi Kivity
2011-10-18 18:08       ` Blue Swirl
2011-10-18 19:40         ` Avi Kivity
2011-10-18 19:59           ` Blue Swirl
  -- strict thread matches above, loose matches on Subject: below --
2011-10-19 10:59 [Qemu-devel] [PULL 00/18] Memory API conversions, batch 12 Avi Kivity
2011-10-19 10:59 ` [Qemu-devel] [PATCH 07/18] r2d: convert to memory API 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=1318860167-14014-8-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --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).