qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit.canet@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Benoît Canet" <benoit.canet@gmail.com>, avi@redhat.com
Subject: [Qemu-devel] [PATCH v4 06/11] lm32_sys: convert to memory API
Date: Thu, 24 Nov 2011 14:31:17 +0100	[thread overview]
Message-ID: <1322141482-12173-7-git-send-email-benoit.canet@gmail.com> (raw)
In-Reply-To: <1322141482-12173-1-git-send-email-benoit.canet@gmail.com>

Signed-off-by: Benoît Canet <benoit.canet@gmail.com>
---
 hw/lm32_sys.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/hw/lm32_sys.c b/hw/lm32_sys.c
index e5ff962..0c8e971 100644
--- a/hw/lm32_sys.c
+++ b/hw/lm32_sys.c
@@ -47,6 +47,7 @@ enum {
 
 struct LM32SysState {
     SysBusDevice busdev;
+    MemoryRegion iomem;
     uint32_t base;
     uint32_t regs[R_MAX];
     uint8_t testname[MAX_TESTNAME_LEN];
@@ -60,7 +61,8 @@ static void copy_testname(LM32SysState *s)
     s->testname[MAX_TESTNAME_LEN - 1] = '\0';
 }
 
-static void sys_write(void *opaque, target_phys_addr_t addr, uint32_t value)
+static void sys_write(void *opaque, target_phys_addr_t addr,
+                      uint64_t value, unsigned size)
 {
     LM32SysState *s = opaque;
     char *testname;
@@ -89,16 +91,16 @@ static void sys_write(void *opaque, target_phys_addr_t addr, uint32_t value)
     }
 }
 
-static CPUReadMemoryFunc * const sys_read_fn[] = {
-    NULL,
-    NULL,
-    NULL,
-};
+static bool sys_ops_accepts(void *opaque, target_phys_addr_t addr,
+                            unsigned size, bool is_write)
+{
+    return is_write && size == 4;
+}
 
-static CPUWriteMemoryFunc * const sys_write_fn[] = {
-    NULL,
-    NULL,
-    &sys_write,
+static const MemoryRegionOps sys_ops = {
+    .write = sys_write,
+    .valid.accepts = sys_ops_accepts,
+    .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
 static void sys_reset(DeviceState *d)
@@ -115,11 +117,9 @@ static void sys_reset(DeviceState *d)
 static int lm32_sys_init(SysBusDevice *dev)
 {
     LM32SysState *s = FROM_SYSBUS(typeof(*s), dev);
-    int sys_regs;
 
-    sys_regs = cpu_register_io_memory(sys_read_fn, sys_write_fn, s,
-            DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, R_MAX * 4, sys_regs);
+    memory_region_init_io(&s->iomem, &sys_ops , s, "sys", R_MAX * 4);
+    sysbus_init_mmio_region(dev, &s->iomem);
 
     /* Note: This device is not created in the board initialization,
      * instead it has to be added with the -device parameter. Therefore,
-- 
1.7.7.3

  parent reply	other threads:[~2011-11-24 13:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-24 13:31 [Qemu-devel] [PATCH v4 00/11] more memory API conversions Benoît Canet
2011-11-24 13:31 ` [Qemu-devel] [PATCH v4 01/11] mcf5206: convert to memory API Benoît Canet
2011-11-24 13:31 ` [Qemu-devel] [PATCH v4 02/11] mcf_uart: " Benoît Canet
2011-11-24 13:31 ` [Qemu-devel] [PATCH v4 03/11] mcf_fec: " Benoît Canet
2011-11-24 13:31 ` [Qemu-devel] [PATCH v4 04/11] mcf_intc: " Benoît Canet
2011-11-24 13:31 ` [Qemu-devel] [PATCH v4 05/11] lm32_uart: " Benoît Canet
2011-11-24 13:31 ` Benoît Canet [this message]
2011-11-24 13:31 ` [Qemu-devel] [PATCH v4 07/11] bonito: convert north bridge register mapping " Benoît Canet
2011-11-24 13:43   ` Peter Maydell
2011-11-24 13:48     ` Avi Kivity
2011-11-24 13:31 ` [Qemu-devel] [PATCH v4 08/11] bonito: convert north bridge pci config " Benoît Canet
2011-11-24 13:31 ` [Qemu-devel] [PATCH v4 09/11] bonito: convert south " Benoît Canet
2011-11-24 13:31 ` [Qemu-devel] [PATCH v4 10/11] bonito: convert ldma " Benoît Canet
2011-11-24 13:31 ` [Qemu-devel] [PATCH v4 11/11] bonito: convert cop " Benoît Canet
2011-11-24 13:44 ` [Qemu-devel] [PATCH v4 00/11] more memory API conversions Avi Kivity
2011-11-27  8:38 ` 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=1322141482-12173-7-git-send-email-benoit.canet@gmail.com \
    --to=benoit.canet@gmail.com \
    --cc=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).