From patchwork Mon Dec 16 14:12:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 301726 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 900D82C007C for ; Tue, 17 Dec 2013 01:15:38 +1100 (EST) Received: from localhost ([::1]:56330 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsYxK-00087p-JC for incoming@patchwork.ozlabs.org; Mon, 16 Dec 2013 09:15:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsYwf-00082B-0y for qemu-devel@nongnu.org; Mon, 16 Dec 2013 09:14:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VsYwY-0003Ap-GQ for qemu-devel@nongnu.org; Mon, 16 Dec 2013 09:14:52 -0500 Received: from multi.imgtec.com ([194.200.65.239]:37090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsYwY-00039r-Av for qemu-devel@nongnu.org; Mon, 16 Dec 2013 09:14:46 -0500 From: James Hogan To: Date: Mon, 16 Dec 2013 14:12:38 +0000 Message-ID: <1387203165-5553-4-git-send-email-james.hogan@imgtec.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1387203165-5553-1-git-send-email-james.hogan@imgtec.com> References: <1387203165-5553-1-git-send-email-james.hogan@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.154.65] X-SEF-Processed: 7_3_0_01192__2013_12_16_14_14_43 X-detected-operating-system: by eggs.gnu.org: Windows XP X-Received-From: 194.200.65.239 Cc: James Hogan , kvm@vger.kernel.org, Gleb Natapov , Sanjay Lal , Paolo Bonzini , Aurelien Jarno Subject: [Qemu-devel] [PATCH v2 03/10] target-mips: get_physical_address: Add defines for segment bases 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 Add preprocessor definitions for 32bit segment bases for use in get_physical_address(). These will also be taken advantage of in the next patch which adds KVM awareness. Signed-off-by: James Hogan Cc: Aurelien Jarno Reviewed-by: Aurelien Jarno --- target-mips/helper.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/target-mips/helper.c b/target-mips/helper.c index 33e0e88..2e96655 100644 --- a/target-mips/helper.c +++ b/target-mips/helper.c @@ -118,7 +118,13 @@ static int get_physical_address (CPUMIPSState *env, hwaddr *physical, qemu_log("user mode %d h %08x\n", user_mode, env->hflags); #endif - if (address <= (int32_t)0x7FFFFFFFUL) { +#define USEG_LIMIT 0x7FFFFFFFUL +#define KSEG0_BASE 0x80000000UL +#define KSEG1_BASE 0xA0000000UL +#define KSEG2_BASE 0xC0000000UL +#define KSEG3_BASE 0xE0000000UL + + if (address <= USEG_LIMIT) { /* useg */ if (env->CP0_Status & (1 << CP0St_ERL)) { *physical = address & 0xFFFFFFFF; @@ -160,23 +166,23 @@ static int get_physical_address (CPUMIPSState *env, hwaddr *physical, ret = TLBRET_BADADDR; } #endif - } else if (address < (int32_t)0xA0000000UL) { + } else if (address < (int32_t)KSEG1_BASE) { /* kseg0 */ if (kernel_mode) { - *physical = address - (int32_t)0x80000000UL; + *physical = address - (int32_t)KSEG0_BASE; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } - } else if (address < (int32_t)0xC0000000UL) { + } else if (address < (int32_t)KSEG2_BASE) { /* kseg1 */ if (kernel_mode) { - *physical = address - (int32_t)0xA0000000UL; + *physical = address - (int32_t)KSEG1_BASE; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } - } else if (address < (int32_t)0xE0000000UL) { + } else if (address < (int32_t)KSEG3_BASE) { /* sseg (kseg2) */ if (supervisor_mode || kernel_mode) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type);