All of lore.kernel.org
 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 v2 05/11] lm32_uart: convert to memory API
Date: Tue, 22 Nov 2011 17:32:01 +0100	[thread overview]
Message-ID: <1321979527-23921-6-git-send-email-benoit.canet@gmail.com> (raw)
In-Reply-To: <1321979527-23921-1-git-send-email-benoit.canet@gmail.com>

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

diff --git a/hw/lm32_uart.c b/hw/lm32_uart.c
index 3678545..46a5ae0 100644
--- a/hw/lm32_uart.c
+++ b/hw/lm32_uart.c
@@ -91,6 +91,7 @@ enum {
 
 struct LM32UartState {
     SysBusDevice busdev;
+    MemoryRegion iomem;
     CharDriverState *chr;
     qemu_irq irq;
 
@@ -124,7 +125,8 @@ static void uart_update_irq(LM32UartState *s)
     qemu_set_irq(s->irq, irq);
 }
 
-static uint32_t uart_read(void *opaque, target_phys_addr_t addr)
+static uint64_t uart_read(void *opaque, target_phys_addr_t addr,
+                          unsigned size)
 {
     LM32UartState *s = opaque;
     uint32_t r = 0;
@@ -158,7 +160,8 @@ static uint32_t uart_read(void *opaque, target_phys_addr_t addr)
     return r;
 }
 
-static void uart_write(void *opaque, target_phys_addr_t addr, uint32_t value)
+static void uart_write(void *opaque, target_phys_addr_t addr,
+                       uint64_t value, unsigned size)
 {
     LM32UartState *s = opaque;
     unsigned char ch = value;
@@ -192,16 +195,14 @@ static void uart_write(void *opaque, target_phys_addr_t addr, uint32_t value)
     uart_update_irq(s);
 }
 
-static CPUReadMemoryFunc * const uart_read_fn[] = {
-    NULL,
-    NULL,
-    &uart_read,
-};
-
-static CPUWriteMemoryFunc * const uart_write_fn[] = {
-    NULL,
-    NULL,
-    &uart_write,
+static const MemoryRegionOps uart_ops = {
+    .read = uart_read,
+    .write = uart_write,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
 };
 
 static void uart_rx(void *opaque, const uint8_t *buf, int size)
@@ -245,13 +246,11 @@ static void uart_reset(DeviceState *d)
 static int lm32_uart_init(SysBusDevice *dev)
 {
     LM32UartState *s = FROM_SYSBUS(typeof(*s), dev);
-    int uart_regs;
 
     sysbus_init_irq(dev, &s->irq);
 
-    uart_regs = cpu_register_io_memory(uart_read_fn, uart_write_fn, s,
-            DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, R_MAX * 4, uart_regs);
+    memory_region_init_io(&s->iomem, &uart_ops, s, "uart", R_MAX * 4);
+    sysbus_init_mmio_region(dev, &s->iomem);
 
     s->chr = qdev_init_chardev(&dev->qdev);
     if (s->chr) {
-- 
1.7.7.3

  parent reply	other threads:[~2011-11-22 16:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22 16:31 [Qemu-devel] [PATCH v2 00/11] more memory API conversion Benoît Canet
2011-11-22 16:31 ` [Qemu-devel] [PATCH v2 01/11] mcf5206: convert to memory API Benoît Canet
2011-11-22 16:31 ` [Qemu-devel] [PATCH v2 02/11] mcf_uart: " Benoît Canet
2011-11-22 16:31 ` [Qemu-devel] [PATCH v2 03/11] mcf_fec: " Benoît Canet
2011-11-22 16:32 ` [Qemu-devel] [PATCH v2 04/11] mcf_intc: " Benoît Canet
2011-11-22 16:32 ` Benoît Canet [this message]
2011-11-22 16:32 ` [Qemu-devel] [PATCH v2 06/11] lm32_sys: " Benoît Canet
2011-11-22 17:36   ` Avi Kivity
2011-11-22 16:32 ` [Qemu-devel] [PATCH v2 07/11] bonito: convert north bridge register mapping " Benoît Canet
2011-11-22 16:32 ` [Qemu-devel] [PATCH v2 08/11] bonito: convert north bridge pci config " Benoît Canet
2011-11-22 16:32 ` [Qemu-devel] [PATCH v2 09/11] bonito: convert south " Benoît Canet
2011-11-22 16:32 ` [Qemu-devel] [PATCH v2 10/11] bonito: convert ldma " Benoît Canet
2011-11-22 16:32 ` [Qemu-devel] [PATCH v2 11/11] bonito: convert cop " Benoît Canet

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=1321979527-23921-6-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.