From bebda7ceec3d3024c76b3c2ed0c9b4e502a13d61 Mon Sep 17 00:00:00 2001 From: oliviermartin Date: Fri, 10 May 2013 12:41:27 +0000 Subject: ArmPlatformPkg/ArmPlatformLib: Added support for ArmPlatformIsPrimaryCore() Checking if a core if the primary/boot core used to be done with the macro IS_PRIMARY_CORE(). Some platforms exposes configuration registers to change the primary core. Replacing the macro IS_PRIMARY_CORE() by ArmPlatformIsPrimaryCore() allows some flexibility in the way to check the primary core. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin Reviewed-by: Leif Lindholm Acked-by: Ryan Harkin git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14344 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S | 24 ++++++++++++++--- .../Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm | 30 +++++++++++++++++++--- 2 files changed, 47 insertions(+), 7 deletions(-) (limited to 'ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm') diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S index 949e7a3014..2977591529 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S @@ -1,10 +1,10 @@ # -# Copyright (c) 2011, 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 # which accompanies this distribution. The full text of the license may be found at -# http:#opensource.org/licenses/bsd-license.php +# http://opensource.org/licenses/bsd-license.php # # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. @@ -15,7 +15,6 @@ #include #include #include -#.include AsmMacroIoLib.inc #include @@ -23,6 +22,10 @@ .align 2 GCC_ASM_EXPORT(ArmGetCpuCountPerCluster) +GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore) + +GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore) +GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask) # IN None # OUT r0 = SCU Base Address @@ -68,4 +71,19 @@ _Return: ldmfd SP!, {r1-r2} bx lr +//UINTN +//ArmPlatformIsPrimaryCore ( +// IN UINTN MpId +// ); +ASM_PFX(ArmPlatformIsPrimaryCore): + LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1) + ldr r1, [r1] + and r0, r0, r1 + LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1) + ldr r1, [r1] + cmp r0, r1 + moveq r0, #1 + movne r0, #0 + bx lr + ASM_FUNCTION_REMOVE_IF_UNREFERENCED diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm index 7326237bc7..7d00d115dc 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm @@ -1,5 +1,5 @@ // -// Copyright (c) 2011, ARM Limited. All rights reserved. +// Copyright (c) 2011-2012, 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 @@ -22,21 +22,26 @@ INCLUDE AsmMacroIoLib.inc EXPORT ArmGetCpuCountPerCluster - + EXPORT ArmPlatformIsPrimaryCore + + IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore + IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask + AREA RTSMHelper, CODE, READONLY // IN None // OUT r0 = SCU Base Address -ArmGetScuBaseAddress +ArmGetScuBaseAddress FUNCTION // Read Configuration Base Address Register. ArmCBar cannot be called to get // the Configuration BAR as a stack is not necessary setup. The SCU is at the // offset 0x0000 from the Private Memory Region. mrc p15, 4, r0, c15, c0, 0 bx lr + ENDFUNC // IN None // OUT r0 = number of cores present in the system -ArmGetCpuCountPerCluster +ArmGetCpuCountPerCluster FUNCTION stmfd SP!, {r1-r2} // Read CP15 MIDR @@ -69,5 +74,22 @@ _Return add r0, r0, #1 ldmfd SP!, {r1-r2} bx lr + ENDFUNC + +//UINTN +//ArmPlatformIsPrimaryCore ( +// IN UINTN MpId +// ); +ArmPlatformIsPrimaryCore FUNCTION + LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1) + ldr r1, [r1] + and r0, r0, r1 + LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1) + ldr r1, [r1] + cmp r0, r1 + moveq r0, #1 + movne r0, #0 + bx lr + ENDFUNC END -- cgit v1.2.3