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 <olivier.martin@arm.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Acked-by: Ryan Harkin <ryan.harkin@linaro.org>


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14344 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin
2013-05-10 12:41:27 +00:00
parent bc7b889a03
commit bebda7ceec
59 changed files with 554 additions and 267 deletions

View File

@@ -51,6 +51,3 @@
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize
gArmTokenSpaceGuid.PcdFvBaseAddress
gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
gArmTokenSpaceGuid.PcdArmPrimaryCore

View File

@@ -140,7 +140,7 @@ ArmPlatformInitialize (
IN UINTN MpId
)
{
if (!IS_PRIMARY_CORE(MpId)) {
if (!ArmPlatformIsPrimaryCore (MpId)) {
return RETURN_SUCCESS;
}

View File

@@ -1,5 +1,5 @@
//
// Copyright (c) 2012, ARM Limited. All rights reserved.
// Copyright (c) 2012-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
@@ -11,12 +11,16 @@
//
//
#include <AsmMacroIoLib.h>
#include <Library/ArmLib.h>
#include <ArmPlatform.h>
.text
.align 3
GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
//UINTN
//ArmPlatformGetCorePosition (
@@ -28,3 +32,33 @@ ASM_PFX(ArmPlatformGetCorePosition):
add r0, r1, r0, LSR #7
bx lr
//UINTN
//ArmPlatformIsPrimaryCore (
// IN UINTN MpId
// );
ASM_PFX(ArmPlatformIsPrimaryCore):
// Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
// with cpu_id[0:3] and cluster_id[4:7]
LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1)
ldr r1, [r1]
lsr r1, #24
// Shift the SCC value to get the cluster ID at the offset #8
lsl r2, r1, #4
and r2, r2, #0xF00
// Keep only the cpu ID from the original SCC
and r1, r1, #0x0F
// Add the Cluster ID to the Cpu ID
orr r1, r1, r2
// Keep the Cluster ID and Core ID from the MPID
LoadConstantToReg (ARM_CLUSTER_MASK | ARM_CORE_MASK, r2)
and r0, r0, r2
// Compare mpid and boot cpu from ARM_SCC_CFGREG48
cmp r0, r1
moveq r0, #1
movne r0, #0
bx lr

View File

@@ -1,5 +1,5 @@
//
// Copyright (c) 2012, ARM Limited. All rights reserved.
// Copyright (c) 2012-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
@@ -11,11 +11,15 @@
//
//
#include <AsmMacroIoLib.h>
#include <Library/ArmLib.h>
#include <ArmPlatform.h>
INCLUDE AsmMacroIoLib.inc
EXPORT ArmPlatformGetCorePosition
EXPORT ArmPlatformIsPrimaryCore
PRESERVE8
AREA CTA15A7Helper, CODE, READONLY
@@ -31,4 +35,35 @@ ArmPlatformGetCorePosition FUNCTION
bx lr
ENDFUNC
//UINTN
//ArmPlatformIsPrimaryCore (
// IN UINTN MpId
// );
ArmPlatformIsPrimaryCore FUNCTION
// Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
// with cpu_id[0:3] and cluster_id[4:7]
LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1)
ldr r1, [r1]
lsr r1, #24
// Shift the SCC value to get the cluster ID at the offset #8
lsl r2, r1, #4
and r2, r2, #0xF00
// Keep only the cpu ID from the original SCC
and r1, r1, #0x0F
// Add the Cluster ID to the Cpu ID
orr r1, r1, r2
// Keep the Cluster ID and Core ID from the MPID
LoadConstantToReg (ARM_CLUSTER_MASK | ARM_CORE_MASK, r2)
and r0, r0, r2
// Compare mpid and boot cpu from ARM_SCC_CFGREG48
cmp r0, r1
moveq r0, #1
movne r0, #0
bx lr
ENDFUNC
END