ArmPlatformPkg/ArmPlatformLib: Added ArmPlatformGetPrimaryCoreMpId()

ArmPlatformGetPrimaryCoreMpId returns the MPID of the primary core.
The primary core might not be known at build time (eg: the platform allows
the boot CPU to be changed through board config).

This function is used during the secondary core stack initialization to know
the position of the secondary core in the SoC.
A secondary core that is at the position N, with N greater than the primary
core position, will be at the position N-1 in the list of secondary stacks
(the primary core has its own separate bigger stack).

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
Acked-by: Ryan Harkin <ryan.harkin@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14345 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2013-05-10 12:44:30 +00:00
parent bebda7ceec
commit d05ca26cb8
7 changed files with 76 additions and 0 deletions

View File

@ -17,10 +17,20 @@
.align 2 .align 2
GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore) GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore) GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask) GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
//UINTN
//ArmPlatformGetPrimaryCoreMpId (
// VOID
// );
ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
ldr r0, [r0]
bx lr
//UINTN //UINTN
//ArmPlatformIsPrimaryCore ( //ArmPlatformIsPrimaryCore (
// IN UINTN MpId // IN UINTN MpId

View File

@ -18,12 +18,23 @@
INCLUDE AsmMacroIoLib.inc INCLUDE AsmMacroIoLib.inc
EXPORT ArmPlatformIsPrimaryCore EXPORT ArmPlatformIsPrimaryCore
EXPORT ArmPlatformGetPrimaryCoreMpId
IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore
IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask
AREA CTA9x4Helper, CODE, READONLY AREA CTA9x4Helper, CODE, READONLY
//UINTN
//ArmPlatformGetPrimaryCoreMpId (
// VOID
// );
ArmPlatformGetPrimaryCoreMpId FUNCTION
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
ldr r0, [r0]
bx lr
ENDFUNC
//UINTN //UINTN
//ArmPlatformIsPrimaryCore ( //ArmPlatformIsPrimaryCore (
// IN UINTN MpId // IN UINTN MpId

View File

@ -23,6 +23,7 @@
GCC_ASM_EXPORT(ArmGetCpuCountPerCluster) GCC_ASM_EXPORT(ArmGetCpuCountPerCluster)
GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore) GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore) GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask) GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
@ -36,6 +37,15 @@ ASM_PFX(ArmGetScuBaseAddress):
mrc p15, 4, r0, c15, c0, 0 mrc p15, 4, r0, c15, c0, 0
bx lr bx lr
//UINTN
//ArmPlatformGetPrimaryCoreMpId (
// VOID
// );
ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
ldr r0, [r0]
bx lr
# IN None # IN None
# OUT r0 = number of cores present in the system # OUT r0 = number of cores present in the system
ASM_PFX(ArmGetCpuCountPerCluster): ASM_PFX(ArmGetCpuCountPerCluster):

View File

@ -23,6 +23,7 @@
EXPORT ArmGetCpuCountPerCluster EXPORT ArmGetCpuCountPerCluster
EXPORT ArmPlatformIsPrimaryCore EXPORT ArmPlatformIsPrimaryCore
EXPORT ArmPlatformGetPrimaryCoreMpId
IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore
IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask
@ -39,6 +40,16 @@ ArmGetScuBaseAddress FUNCTION
bx lr bx lr
ENDFUNC ENDFUNC
//UINTN
//ArmPlatformGetPrimaryCoreMpId (
// VOID
// );
ArmPlatformGetPrimaryCoreMpId FUNCTION
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
ldr r0, [r0]
bx lr
ENDFUNC
// IN None // IN None
// OUT r0 = number of cores present in the system // OUT r0 = number of cores present in the system
ArmGetCpuCountPerCluster FUNCTION ArmGetCpuCountPerCluster FUNCTION

View File

@ -69,6 +69,20 @@ ArmPlatformIsPrimaryCore (
IN UINTN MpId IN UINTN MpId
); );
/**
Return the MpId of the primary core
This function returns the MpId of the primary core.
This function might be called from assembler before any stack is set.
@return Return the MpId of the primary core
**/
UINTN
ArmPlatformGetPrimaryCoreMpId (
VOID
);
/** /**
Return the current Boot Mode Return the current Boot Mode

View File

@ -18,6 +18,7 @@
.align 3 .align 3
GCC_ASM_EXPORT(ArmPlatformGetCorePosition) GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore) GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore) GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
@ -33,6 +34,14 @@ ASM_PFX(ArmPlatformGetCorePosition):
add r0, r1, r0, LSR #7 add r0, r1, r0, LSR #7
bx lr bx lr
//UINTN
//ArmPlatformGetPrimaryCoreMpId (
// VOID
// );
ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
ldr r0, [r0]
bx lr
//UINTN //UINTN
//ArmPlatformIsPrimaryCore ( //ArmPlatformIsPrimaryCore (

View File

@ -17,6 +17,7 @@
INCLUDE AsmMacroIoLib.inc INCLUDE AsmMacroIoLib.inc
EXPORT ArmPlatformGetCorePosition EXPORT ArmPlatformGetCorePosition
EXPORT ArmPlatformGetPrimaryCoreMpId
EXPORT ArmPlatformIsPrimaryCore EXPORT ArmPlatformIsPrimaryCore
IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore
@ -36,6 +37,16 @@ ArmPlatformGetCorePosition FUNCTION
bx lr bx lr
ENDFUNC ENDFUNC
//UINTN
//ArmPlatformGetPrimaryCoreMpId (
// VOID
// );
ArmPlatformGetPrimaryCoreMpId FUNCTION
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
ldr r0, [r0]
bx lr
ENDFUNC
//UINTN //UINTN
//ArmPlatformIsPrimaryCore ( //ArmPlatformIsPrimaryCore (
// IN UINTN MpId // IN UINTN MpId