From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:45041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrTk4-00077T-7V for qemu-devel@nongnu.org; Thu, 11 Aug 2011 07:48:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrTjz-0007gI-R1 for qemu-devel@nongnu.org; Thu, 11 Aug 2011 07:48:04 -0400 Received: from mail-fx0-f45.google.com ([209.85.161.45]:51798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrTjz-0007T2-Kb for qemu-devel@nongnu.org; Thu, 11 Aug 2011 07:47:59 -0400 Received: by mail-fx0-f45.google.com with SMTP id b27so1841923fxb.4 for ; Thu, 11 Aug 2011 04:47:59 -0700 (PDT) From: "Edgar E. Iglesias" Date: Thu, 11 Aug 2011 13:47:47 +0200 Message-Id: <1313063268-4208-4-git-send-email-edgar.iglesias@gmail.com> In-Reply-To: <1313063268-4208-1-git-send-email-edgar.iglesias@gmail.com> References: <1313063268-4208-1-git-send-email-edgar.iglesias@gmail.com> Subject: [Qemu-devel] [PATCH 4/5] etrax-dma: Convert to MemoryRegion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Edgar E. Iglesias" , avi@redhat.com, edgar@axis.com From: "Edgar E. Iglesias" Signed-off-by: Edgar E. Iglesias --- 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 c205ec1..8023fa1 100644 --- a/hw/etraxfs_dma.c +++ b/hw/etraxfs_dma.c @@ -24,6 +24,7 @@ #include #include #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 @@ dma_update_state(struct fs_dma_ctrl *ctrl, int c) } 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 @@ dma_writel (void *opaque, target_phys_addr_t addr, uint32_t value) } } -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 @@ void *etraxfs_dmac_init(target_phys_addr_t base, int nr_channels) ctrl->nr_channels = nr_channels; ctrl->channels = qemu_mallocz(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.5.4