From patchwork Mon Feb 10 21:58:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: York Sun X-Patchwork-Id: 319068 X-Patchwork-Delegate: albert.aribaud@free.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 979F52C0082 for ; Tue, 11 Feb 2014 08:59:33 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AB14B4B717; Mon, 10 Feb 2014 22:59:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1cUBOYaO5edQ; Mon, 10 Feb 2014 22:59:31 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CC5C64B718; Mon, 10 Feb 2014 22:59:19 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A642D4B70F for ; Mon, 10 Feb 2014 22:59:16 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tK6l0w1NynoB for ; Mon, 10 Feb 2014 22:59:10 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2lp0209.outbound.protection.outlook.com [207.46.163.209]) by theia.denx.de (Postfix) with ESMTPS id B30B14B6ED for ; Mon, 10 Feb 2014 22:58:58 +0100 (CET) Received: from [10.214.83.114] (192.88.168.49) by BLUPR03MB149.namprd03.prod.outlook.com (10.255.212.17) with Microsoft SMTP Server (TLS) id 15.0.873.15; Mon, 10 Feb 2014 21:58:43 +0000 Message-ID: <52F94B8E.2000209@freescale.com> Date: Mon, 10 Feb 2014 13:58:38 -0800 From: York Sun User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "u-boot@lists.denx.de" References: <1392069354-24578-2-git-send-email-yorksun@freescale.com> In-Reply-To: <1392069354-24578-2-git-send-email-yorksun@freescale.com> X-Forwarded-Message-Id: <1392069354-24578-2-git-send-email-yorksun@freescale.com> X-Originating-IP: [192.88.168.49] X-ClientProxiedBy: BLUPR08CA010.namprd08.prod.outlook.com (10.255.219.178) To BLUPR03MB149.namprd03.prod.outlook.com (10.255.212.17) X-Forefront-PRVS: 0118CD8765 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009001)(6009001)(6049001)(13464003)(2473001)(189002)(199002)(81686001)(81816001)(65806001)(56816005)(63696002)(87976001)(47776003)(92566001)(92726001)(77096001)(85852003)(83072002)(36756003)(83506001)(47446002)(80022001)(74662001)(65956001)(66066001)(85306002)(31966008)(23756003)(74502001)(93136001)(90146001)(76786001)(95416001)(94946001)(93516002)(94316002)(81542001)(74706001)(74876001)(42186004)(53806001)(46102001)(54316002)(51856001)(56776001)(54356001)(76482001)(4396001)(64126003)(50986001)(49866001)(47736001)(47976001)(81342001)(33656001)(69226001)(74366001)(76796001)(86362001)(50466002)(80976001)(80316001)(79102001)(19580405001)(95666001)(77982001)(59896001)(59766001)(19580395003)(83322001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB149; H:[10.214.83.114]; CLIP:192.88.168.49; FPR:2E86EF53.A5E29C88.5EFF330C.49DADEB1.202EF; InfoNoRecordsMX:1; A:1; LANG:en; X-OriginatorOrg: freescale.com Subject: [U-Boot] Fwd: [PATCH 2/3] armv8/cache: Flush D-cache, invalidate I-cache for relocation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de -------- Original Message -------- Subject: [PATCH 2/3] armv8/cache: Flush D-cache, invalidate I-cache for relocation Date: Mon, 10 Feb 2014 13:55:53 -0800 From: York Sun To: CC: , York Sun , David Feng If D-cache is enabled, we need to flush it, and invalidate i-cache before jumping to the new location. This should be done right after relocation. Signed-off-by: York Sun CC: David Feng --- arch/arm/cpu/armv8/start.S | 6 ------ arch/arm/lib/relocate_64.S | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S index 90daa4d..e70c51d 100644 --- a/arch/arm/cpu/armv8/start.S +++ b/arch/arm/cpu/armv8/start.S @@ -122,12 +122,6 @@ ENDPROC(lowlevel_init) /*-----------------------------------------------------------------------*/ ENTRY(c_runtime_cpu_setup) - /* If I-cache is enabled invalidate it */ -#ifndef CONFIG_SYS_ICACHE_OFF - ic iallu /* I+BTB cache invalidate */ - isb sy -#endif - /* Relocate vBAR */ adr x0, vectors switch_el x1, 3f, 2f, 1f diff --git a/arch/arm/lib/relocate_64.S b/arch/arm/lib/relocate_64.S index 7fba9e2..3f36e88 100644 --- a/arch/arm/lib/relocate_64.S +++ b/arch/arm/lib/relocate_64.S @@ -19,6 +19,9 @@ * x0 holds the destination address. */ ENTRY(relocate_code) + stp x29, x30, [sp, #-32]! /* create a stack frame */ + mov x29, sp + str x0, [sp, #16] /* * Copy u-boot from flash to RAM */ @@ -32,6 +35,7 @@ copy_loop: stp x10, x11, [x0], #16 /* copy to target address [x0] */ cmp x1, x2 /* until source end address [x2] */ b.lo copy_loop + str x0, [sp, #24] /* * Fix .rela.dyn relocations @@ -54,5 +58,28 @@ fixnext: b.lo fixloop relocate_done: + mrs x0, currentel + lsr w0, w0, #2 + cmp w0, #0x3 + b.ne 1f + mrs x0, sctlr_el3 + b 4f +1: cmp w0, #0x2 + b.ne 2f + mrs x0, sctlr_el2 + b 4f +2: cmp w0, #0x1 + b.ne 3f + mrs x0, sctlr_el1 + b 4f +3: bl hang +4: tbz w0, #2, 4f /* flushing d-cache if enabled */ + ldp x0, x1, [sp, #16] + bl __asm_flush_dcache_range +#ifndef CONFIG_SYS_ICACHE_OFF + ic iallu /* I+BTB cache invalidate */ + isb sy +#endif +4: ldp x29, x30, [sp],#16 ret ENDPROC(relocate_code)