From patchwork Tue Sep 23 17:49:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Eastwood X-Patchwork-Id: 4958721 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 39923BEEA5 for ; Tue, 23 Sep 2014 17:52:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 253B620270 for ; Tue, 23 Sep 2014 17:52:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1ED0C201DD for ; Tue, 23 Sep 2014 17:52:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWUE3-000233-8I; Tue, 23 Sep 2014 17:50:07 +0000 Received: from mail-la0-x22a.google.com ([2a00:1450:4010:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWUDz-0000nu-Bb for linux-arm-kernel@lists.infradead.org; Tue, 23 Sep 2014 17:50:04 +0000 Received: by mail-la0-f42.google.com with SMTP id hz20so9250340lab.15 for ; Tue, 23 Sep 2014 10:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tqFaeCflBg9pm4N3sgH3hGVgiLXqaMNASnu8LfnYaps=; b=HPRlqp+Ci9i5jETnBzAI4/Saxf29oVOOInJAH9qyPQtoMwh9LcXeG62KzgNvjcTZzG Cqg0DJ9f4gLqGtdj4SKRLjf4ajzV7/c4BNvGjHSQAjcq6dwg/FQw9JX91Te83hbB60/g 0bw/wZ2GQZvjQOLgjP02DHZdSzEeAne7sZkwDCOumlnG8ppU+7g4pmOfjnl8pIfhEHDt e1ExT1TP/2rTQg0Rz4vfP6zAXNEbKhQAA5ELVmbTjl9EV2dQAEjhVnZg291ITf7nyQpT yHYwEIVvltMvuSG7KFjVAfoiZLyjNWCku2593pG2HOA3JLGlemkZbkA6rhDTbxQRaGn/ uQCA== X-Received: by 10.112.171.202 with SMTP id aw10mr1167049lbc.52.1411494579754; Tue, 23 Sep 2014 10:49:39 -0700 (PDT) Received: from localhost.localdomain (183.90-149-48.nextgentel.com. [90.149.48.183]) by mx.google.com with ESMTPSA id y5sm4990347laa.20.2014.09.23.10.49.38 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Sep 2014 10:49:39 -0700 (PDT) From: Joachim Eastwood To: arnd@arndb.de, linux@arm.linux.org.uk, catalin.marinas@arm.com, u.kleine-koenig@pengutronix.de Subject: [PATCH v3] ARM: zImage: add support for ARMv7-M Date: Tue, 23 Sep 2014 19:49:25 +0200 Message-Id: <1411494565-29534-1-git-send-email-manabian@gmail.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1411057343-20861-1-git-send-email-manabian@gmail.com> References: <1411057343-20861-1-git-send-email-manabian@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140923_105003_597505_4D00B224 X-CRM114-Status: GOOD ( 12.35 ) X-Spam-Score: -0.8 (/) Cc: Joachim Eastwood , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch makes it possible to enter zImage in Thumb mode for ARMv7M (Cortex-M) CPUs that does not support ARM mode. The kernel entry is also made in Thumb mode. Signed-off-by: Joachim Eastwood --- Hi, Updated patch per comments from Catalin Marinas. Changes v3: Use defines for ARMv7M CPU registers. v2: Introduce AR_CLASS/M_CLASS macros. This reduces the amount of ifdefs needed in compressed/head.S. Successfully tested on NXP LPC4357 (Cortex-M4). regards, Joachim Eastwood arch/arm/boot/compressed/head.S | 19 +++++++++++++++---- arch/arm/include/asm/unified.h | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 413fd94b5301..cd27090625fe 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -10,8 +10,11 @@ */ #include #include +#include + + AR_CLASS( .arch armv7-a ) + M_CLASS( .arch armv7-m ) - .arch armv7-a /* * Debugging stuff * @@ -114,7 +117,7 @@ * sort out different calling conventions */ .align - .arm @ Always enter in ARM state + AR_CLASS( .arm ) @ Always enter in ARM state for A/R classes start: .type start,#function .rept 7 @@ -133,6 +136,7 @@ start: THUMB( .thumb ) 1: ARM_BE8( setend be ) @ go BE8 if compiled for BE8 +#ifndef CONFIG_CPU_V7M mrs r9, cpsr #ifdef CONFIG_ARM_VIRT_EXT bl __hyp_stub_install @ get into SVC mode, reversibly @@ -155,6 +159,7 @@ not_angel: safe_svcmode_maskall r0 msr spsr_cxsf, r9 @ Save the CPU boot mode in @ SPSR +#endif /* * Note that some cache flushing and other stuff may * be needed here - is there an Angel SWI call for this? @@ -790,6 +795,9 @@ __common_mmu_cache_on: call_cache_fn: adr r12, proc_types #ifdef CONFIG_CPU_CP15 mrc p15, 0, r9, c0, c0 @ get processor ID +#elif defined(CONFIG_CPU_V7M) + ldr r9, =BASEADDR_V7M_SCB + ldr r9, [r9, V7M_SCB_CPUID] #else ldr r9, =CONFIG_PROCESSOR_ID #endif @@ -945,11 +953,13 @@ proc_types: W(b) __armv4_mmu_cache_off W(b) __armv6_mmu_cache_flush +#ifndef CONFIG_CPU_V7M .word 0x000f0000 @ new CPU Id .word 0x000f0000 W(b) __armv7_mmu_cache_on W(b) __armv7_mmu_cache_off W(b) __armv7_mmu_cache_flush +#endif .word 0 @ unrecognised type .word 0 @@ -1277,8 +1287,9 @@ __hyp_reentry_vectors: __enter_kernel: mov r0, #0 @ must be 0 - ARM( mov pc, r4 ) @ call kernel - THUMB( bx r4 ) @ entry point is always ARM + ARM( mov pc, r4 ) @ call kernel + M_CLASS( add r4, r4, #1 ) @ enter in Thumb mode for M class + THUMB( bx r4 ) @ entry point is always ARM for AR class reloc_code_end: diff --git a/arch/arm/include/asm/unified.h b/arch/arm/include/asm/unified.h index b88beaba6b4a..200f9a7cd623 100644 --- a/arch/arm/include/asm/unified.h +++ b/arch/arm/include/asm/unified.h @@ -24,6 +24,14 @@ .syntax unified #endif +#ifdef CONFIG_CPU_V7M +#define AR_CLASS(x...) +#define M_CLASS(x...) x +#else +#define AR_CLASS(x...) x +#define M_CLASS(x...) +#endif + #ifdef CONFIG_THUMB2_KERNEL #if __GNUC__ < 4