From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:36100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFpH9-0000O7-9n for qemu-devel@nongnu.org; Mon, 17 Oct 2011 11:38:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RFpH3-0000bk-52 for qemu-devel@nongnu.org; Mon, 17 Oct 2011 11:38:51 -0400 Received: from mail-ey0-f173.google.com ([209.85.215.173]:47352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFpH2-0000bR-UF for qemu-devel@nongnu.org; Mon, 17 Oct 2011 11:38:45 -0400 Received: by eyh6 with SMTP id 6so3498248eyh.4 for ; Mon, 17 Oct 2011 08:38:43 -0700 (PDT) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Mon, 17 Oct 2011 17:28:28 +0200 Message-Id: <1318865312-27483-4-git-send-email-benoit.canet@gmail.com> In-Reply-To: <1318865312-27483-1-git-send-email-benoit.canet@gmail.com> References: <1318865312-27483-1-git-send-email-benoit.canet@gmail.com> Subject: [Qemu-devel] [PATCH 3/7] integratorcp: convert control to memory API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Beno=C3=AEt=20Canet?= , avi@redhat.com Signed-off-by: Benoit Canet --- hw/integratorcp.c | 31 ++++++++++++++----------------- 1 files changed, 14 insertions(+), 17 deletions(-) diff --git a/hw/integratorcp.c b/hw/integratorcp.c index c7d6596..7f79560 100644 --- a/hw/integratorcp.c +++ b/hw/integratorcp.c @@ -392,7 +392,9 @@ static int icp_pic_init(SysBusDevice *dev) } /* CP control registers. */ -static uint32_t icp_control_read(void *opaque, target_phys_addr_t offset) + +static uint64_t icp_control_read(void *opaque, target_phys_addr_t offset, + unsigned size) { switch (offset >> 2) { case 0: /* CP_IDFIELD */ @@ -410,7 +412,7 @@ static uint32_t icp_control_read(void *opaque, target_phys_addr_t offset) } static void icp_control_write(void *opaque, target_phys_addr_t offset, - uint32_t value) + uint64_t value, unsigned size) { switch (offset >> 2) { case 1: /* CP_FLASHPROG */ @@ -422,26 +424,21 @@ static void icp_control_write(void *opaque, target_phys_addr_t offset, hw_error("icp_control_write: Bad offset %x\n", (int)offset); } } -static CPUReadMemoryFunc * const icp_control_readfn[] = { - icp_control_read, - icp_control_read, - icp_control_read -}; -static CPUWriteMemoryFunc * const icp_control_writefn[] = { - icp_control_write, - icp_control_write, - icp_control_write +static const MemoryRegionOps icp_control_ops = { + .read = icp_control_read, + .write = icp_control_write, + .endianness = DEVICE_NATIVE_ENDIAN, }; -static void icp_control_init(uint32_t base) +static void icp_control_init(target_phys_addr_t base) { - int iomemtype; + MemoryRegion *io; - iomemtype = cpu_register_io_memory(icp_control_readfn, - icp_control_writefn, NULL, - DEVICE_NATIVE_ENDIAN); - cpu_register_physical_memory(base, 0x00800000, iomemtype); + io = (MemoryRegion *)g_malloc0(sizeof(MemoryRegion)); + memory_region_init_io(io, &icp_control_ops, NULL, + "control", 0x00800000); + memory_region_add_subregion(get_system_memory(), base, io); /* ??? Save/restore. */ } -- 1.7.5.4