From d4c92adef76ef0a52b3590946f4571f8f5c85365 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Thu, 28 Nov 2013 21:38:32 +0000 Subject: [PATCH] ArmPlatformPkg/ArmVExpressLibCTA9x4: Fixed the initial secondary core bringup when remapping DRAM at 0x0 If the DRAM is remapped at 0x0 then we need to wake up the secondary cores from wfe (waiting for the memory to be initialized) as the instruction is still in the remapped flash region at 0x0 to make them jumping into the C-code which lives in the NOR1 at 0x44000000 before the region 0x0 is remapped as DRAM. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14910 6f19259b-4bc3-4df7-8a09-765794883524 --- .../ArmVExpressLibCTA9x4/ArmVExpressLib.inf | 2 -- .../Library/ArmVExpressLibCTA9x4/CTA9x4.c | 20 ++----------- .../ArmVExpressSecLib.inf | 3 +- .../ArmVExpressSecLibCTA9x4/CTA9x4Sec.c | 30 ++++++++++++++++++- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLib.inf index b1beeaafe6..febc6ddf90 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLib.inf +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLib.inf @@ -33,8 +33,6 @@ MemoryAllocationLib PL341DmcLib PL301AxiLib - L2X0CacheLib - SerialPortLib [Sources.common] CTA9x4Helper.asm | RVCT diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c index 55b611190a..60cb09eccc 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2011-2012, ARM Limited. All rights reserved. +* Copyright (c) 2011-2013, ARM Limited. All rights reserved. * * This program and the accompanying materials * are licensed and made available under the terms and conditions of the BSD License @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -26,8 +25,6 @@ #include -#define SerialPrint(txt) SerialPortWrite ((UINT8*)(txt), AsciiStrLen(txt)+1); - ARM_CORE_INFO mVersatileExpressMpCoreInfoCTA9x4[] = { { // Cluster 0, Core 0 @@ -163,19 +160,8 @@ ArmPlatformInitializeSystemMemory ( VOID ) { - UINT32 Value; - - // Memory Map remapping - if (FeaturePcdGet(PcdNorFlashRemapping)) { - SerialPrint ("Secure ROM at 0x0\n\r"); - } else { - Value = MmioRead32(ARM_VE_SYS_CFGRW1_REG); //Scc - CFGRW1 - // Remap the DRAM to 0x0 - MmioWrite32(ARM_VE_SYS_CFGRW1_REG, (Value & 0x0FFFFFFF) | ARM_VE_CFGRW1_REMAP_DRAM); - } - - PL341DmcInit(ARM_VE_DMC_BASE, &DDRTimings); - PL301AxiInit(ARM_VE_FAXI_BASE); + PL341DmcInit (ARM_VE_DMC_BASE, &DDRTimings); + PL301AxiInit (ARM_VE_FAXI_BASE); } EFI_STATUS diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/ArmVExpressSecLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/ArmVExpressSecLib.inf index 5765a2f7a7..969a75644d 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/ArmVExpressSecLib.inf +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/ArmVExpressSecLib.inf @@ -1,5 +1,5 @@ #/* @file -# Copyright (c) 2011-2012, ARM Limited. All rights reserved. +# Copyright (c) 2011-2013, ARM Limited. All rights reserved. # # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -46,6 +46,7 @@ [FeaturePcd] gArmPlatformTokenSpaceGuid.PcdStandalone + gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping gArmPlatformTokenSpaceGuid.PcdSystemMemoryInitializeInSec [FixedPcd] diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Sec.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Sec.c index a671f130f2..eff714cca9 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Sec.c +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Sec.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2011-2012, ARM Limited. All rights reserved. +* Copyright (c) 2011-2013, ARM Limited. All rights reserved. * * This program and the accompanying materials * are licensed and made available under the terms and conditions of the BSD License @@ -17,12 +17,15 @@ #include #include #include +#include #include #include #include +#define SerialPrint(txt) SerialPortWrite ((UINT8*)(txt), AsciiStrLen(txt)+1) + /** Initialize the Secure peripherals and memory regions @@ -119,6 +122,22 @@ ArmPlatformSecInitialize ( IN UINTN MpId ) { + UINT32 Value; + + // If the DRAM is remapped at 0x0 then we need to wake up the secondary cores from wfe + // (waiting for the memory to be initialized) as the instruction is still in the remapped + // flash region at 0x0 to jump in the C-code which lives in the NOR1 at 0x44000000 before + // the region 0x0 is remapped as DRAM. + if (!FeaturePcdGet (PcdNorFlashRemapping)) { + if (!ArmPlatformIsPrimaryCore (MpId)) { + // Replaced ArmCallWFE () in ArmPlatformPkg/Sec/SecEntryPoint.(S|asm) + ArmCallWFE (); + } else { + // Wake up the secondary core from ArmCallWFE () in ArmPlatformPkg/Sec/SecEntryPoint.(S|asm) + ArmCallSEV (); + } + } + // If it is not the primary core then there is nothing to do if (!ArmPlatformIsPrimaryCore (MpId)) { return RETURN_SUCCESS; @@ -144,5 +163,14 @@ ArmPlatformSecInitialize ( ArmPlatformInitializeSystemMemory (); } + // Memory Map remapping + if (FeaturePcdGet (PcdNorFlashRemapping)) { + SerialPrint ("Secure ROM at 0x0\n\r"); + } else { + Value = MmioRead32 (ARM_VE_SYS_CFGRW1_REG); //Scc - CFGRW1 + // Remap the DRAM to 0x0 + MmioWrite32 (ARM_VE_SYS_CFGRW1_REG, (Value & 0x0FFFFFFF) | ARM_VE_CFGRW1_REMAP_DRAM); + } + return RETURN_SUCCESS; } -- 2.39.2