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] [PULL 23/28] etrax-dma: Convert to MemoryRegion
Date: Mon, 12 Sep 2011 13:51:01 +0300	[thread overview]
Message-ID: <1315824666-4214-24-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1315824666-4214-1-git-send-email-avi@redhat.com>

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/etraxfs_dma.c |   43 +++++++++++++++++++++++++++----------------
 1 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/hw/etraxfs_dma.c b/hw/etraxfs_dma.c
index e8ad9e6..03a623b 100644
--- a/hw/etraxfs_dma.c
+++ b/hw/etraxfs_dma.c
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <sys/time.h>
 #include "hw.h"
+#include "exec-memory.h"
 #include "qemu-common.h"
 #include "sysemu.h"
 
@@ -185,7 +186,7 @@ struct fs_dma_channel
 
 struct fs_dma_ctrl
 {
-	int map;
+	MemoryRegion mmio;
 	int nr_channels;
 	struct fs_dma_channel *channels;
 
@@ -562,13 +563,17 @@ static uint32_t dma_rinvalid (void *opaque, target_phys_addr_t addr)
         return 0;
 }
 
-static uint32_t
-dma_readl (void *opaque, target_phys_addr_t addr)
+static uint64_t
+dma_read(void *opaque, target_phys_addr_t addr, unsigned int size)
 {
         struct fs_dma_ctrl *ctrl = opaque;
 	int c;
 	uint32_t r = 0;
 
+	if (size != 4) {
+		dma_rinvalid(opaque, addr);
+	}
+
 	/* Make addr relative to this channel and bounded to nr regs.  */
 	c = fs_channel(addr);
 	addr &= 0xff;
@@ -608,11 +613,17 @@ static uint32_t dma_rinvalid (void *opaque, target_phys_addr_t addr)
 }
 
 static void
-dma_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
+dma_write(void *opaque, target_phys_addr_t addr,
+	  uint64_t val64, unsigned int size)
 {
         struct fs_dma_ctrl *ctrl = opaque;
+	uint32_t value = val64;
 	int c;
 
+	if (size != 4) {
+		dma_winvalid(opaque, addr, value);
+	}
+
         /* Make addr relative to this channel and bounded to nr regs.  */
 	c = fs_channel(addr);
         addr &= 0xff;
@@ -668,16 +679,14 @@ static uint32_t dma_rinvalid (void *opaque, target_phys_addr_t addr)
         }
 }
 
-static CPUReadMemoryFunc * const dma_read[] = {
-	&dma_rinvalid,
-	&dma_rinvalid,
-	&dma_readl,
-};
-
-static CPUWriteMemoryFunc * const dma_write[] = {
-	&dma_winvalid,
-	&dma_winvalid,
-	&dma_writel,
+static const MemoryRegionOps dma_ops = {
+	.read = dma_read,
+	.write = dma_write,
+	.endianness = DEVICE_NATIVE_ENDIAN,
+	.valid = {
+		.min_access_size = 1,
+		.max_access_size = 4
+	}
 };
 
 static int etraxfs_dmac_run(void *opaque)
@@ -750,7 +759,9 @@ static void DMA_run(void *opaque)
 	ctrl->nr_channels = nr_channels;
 	ctrl->channels = g_malloc0(sizeof ctrl->channels[0] * nr_channels);
 
-	ctrl->map = cpu_register_io_memory(dma_read, dma_write, ctrl, DEVICE_NATIVE_ENDIAN);
-	cpu_register_physical_memory(base, nr_channels * 0x2000, ctrl->map);
+	memory_region_init_io(&ctrl->mmio, &dma_ops, ctrl, "etraxfs-dma",
+			      nr_channels * 0x2000);
+	memory_region_add_subregion(get_system_memory(), base, &ctrl->mmio);
+
 	return ctrl;
 }
-- 
1.7.6.1

  parent reply	other threads:[~2011-09-12 10:51 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-12 10:50 [Qemu-devel] [PULL 00/28] Memory API conversion, batch 7 Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 01/28] mips_jazz: convert to memory API Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 02/28] mips_malta: " Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 03/28] mips_mipssim: " Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 04/28] mips_r4k: " Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 05/28] musicpal: " Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 06/28] omap1: convert to memory API (part I) Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 07/28] omap1: convert to memory API (part II) Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 08/28] pci: add pci_address_space_io() Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 09/28] isa: Pass i/o address space to isa_bus_new Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 10/28] isa: add isa_register_ioport() Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 11/28] pc: Re-order pc_init1 to initialize the ISA bus before ISA devices Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 12/28] cs4231a: Convert to MemoryRegion Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 13/28] i8254: " Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 14/28] mips_malta: move i8259 initialization after piix4 initialization Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 15/28] i8259: Convert to MemoryRegion Avi Kivity
2011-09-12 12:54   ` Jan Kiszka
2011-09-12 13:30     ` Jan Kiszka
2011-09-12 10:50 ` [Qemu-devel] [PULL 16/28] pckbd: " Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 17/28] serial: Convert serial_isa_initfn " Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 18/28] fdc: Convert isabus_fdc_init1 " Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 19/28] pci: simplify memory region registration Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 20/28] etrax-pic: Convert to MemoryRegion Avi Kivity
2011-09-12 10:50 ` [Qemu-devel] [PULL 21/28] etrax-ser: " Avi Kivity
2011-09-12 10:51 ` [Qemu-devel] [PULL 22/28] etrax-timer: " Avi Kivity
2011-09-12 10:51 ` Avi Kivity [this message]
2011-09-12 10:51 ` [Qemu-devel] [PULL 24/28] etrax-eth: " Avi Kivity
2011-09-12 10:51 ` [Qemu-devel] [PULL 25/28] serial: Convert serial_mm_init " Avi Kivity
2011-09-12 10:51 ` [Qemu-devel] [PULL 26/28] serial: Use enum device_endian in serial_mm_init parameter Avi Kivity
2011-09-12 10:51 ` [Qemu-devel] [PULL 27/28] serial: Remove ioregister parameter from serial_mm_init Avi Kivity
2011-09-12 10:51 ` [Qemu-devel] [PULL 28/28] serial: Add MemoryRegion parameter to serial_mm_init Avi Kivity
2011-09-12 12:29 ` [Qemu-devel] [PULL 00/28] Memory API conversion, batch 7 Avi Kivity
2011-09-12 12:57   ` Anthony Liguori
2011-09-12 13:04     ` 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=1315824666-4214-24-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).