From patchwork Fri Jan 25 12:48:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 215804 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 645FF2C008C for ; Sat, 26 Jan 2013 03:31:36 +1100 (EST) Received: from localhost ([::1]:49444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyijT-0004bZ-Em for incoming@patchwork.ozlabs.org; Fri, 25 Jan 2013 07:50:11 -0500 Received: from eggs.gnu.org ([208.118.235.92]:43252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyiiX-0002kq-Nj for qemu-devel@nongnu.org; Fri, 25 Jan 2013 07:49:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TyiiS-0003ge-F8 for qemu-devel@nongnu.org; Fri, 25 Jan 2013 07:49:13 -0500 Received: from cantor2.suse.de ([195.135.220.15]:59097 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyiiS-0003gX-5m for qemu-devel@nongnu.org; Fri, 25 Jan 2013 07:49:08 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 94E54A3A78; Fri, 25 Jan 2013 13:49:07 +0100 (CET) From: Alexander Graf To: qemu-devel Date: Fri, 25 Jan 2013 13:48:46 +0100 Message-Id: <1359118138-9367-4-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1359118138-9367-1-git-send-email-agraf@suse.de> References: <1359118138-9367-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Blue Swirl , Cornelia Huck , =?utf-8?q?Aur=C3=A9lien=20Jarno?= Subject: [Qemu-devel] [PATCH 03/15] s390: Add mapping helper functions. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cornelia Huck Add s390_cpu_physical_memory_{map,unmap} with special handling for the lowcore. Signed-off-by: Cornelia Huck Signed-off-by: Alexander Graf --- target-s390x/cpu.h | 4 ++++ target-s390x/helper.c | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 0 deletions(-) diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index 1f2d942..7951aab 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -302,6 +302,10 @@ int cpu_s390x_handle_mmu_fault (CPUS390XState *env, target_ulong address, int rw #ifndef CONFIG_USER_ONLY +void *s390_cpu_physical_memory_map(CPUS390XState *env, hwaddr addr, hwaddr *len, + int is_write); +void s390_cpu_physical_memory_unmap(CPUS390XState *env, void *addr, hwaddr len, + int is_write); void s390x_tod_timer(void *opaque); void s390x_cpu_timer(void *opaque); diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 023c074..3109c77 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -490,6 +490,31 @@ static void cpu_unmap_lowcore(LowCore *lowcore) cpu_physical_memory_unmap(lowcore, sizeof(LowCore), 1, sizeof(LowCore)); } +void *s390_cpu_physical_memory_map(CPUS390XState *env, hwaddr addr, hwaddr *len, + int is_write) +{ + hwaddr start = addr; + + /* Mind the prefix area. */ + if (addr < 8192) { + /* Map the lowcore. */ + start += env->psa; + *len = MIN(*len, 8192 - addr); + } else if ((addr >= env->psa) && (addr < env->psa + 8192)) { + /* Map the 0 page. */ + start -= env->psa; + *len = MIN(*len, 8192 - start); + } + + return cpu_physical_memory_map(start, len, is_write); +} + +void s390_cpu_physical_memory_unmap(CPUS390XState *env, void *addr, hwaddr len, + int is_write) +{ + cpu_physical_memory_unmap(addr, len, is_write, len); +} + static void do_svc_interrupt(CPUS390XState *env) { uint64_t mask, addr;