]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/ArmPlatformStackLib: Do not directly use PcdArmPrimaryCore
authorOlivier Martin <olivier.martin@arm.com>
Fri, 6 Dec 2013 16:12:24 +0000 (16:12 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Dec 2013 16:12:24 +0000 (16:12 +0000)
To make the code platform independent we should not use PcdArmPrimaryCore
in libraries other than the platform specific libraries.
Some platforms allow to change the primary core with external registers.
These platforms do not use PcdArmPrimaryCore to identify the primary CPU.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14938 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.S
ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.asm
ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf

index 34fab31dd458f084c0c9fada6b21068616ba146f..96e925981fca45387b156a32119374087baff73b 100644 (file)
@@ -22,10 +22,11 @@ GCC_ASM_EXPORT(ArmPlatformStackSet)
 GCC_ASM_EXPORT(ArmPlatformStackSetPrimary)\r
 GCC_ASM_EXPORT(ArmPlatformStackSetSecondary)\r
 \r
+GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)\r
 GCC_ASM_IMPORT(ArmPlatformGetCorePosition)\r
+GCC_ASM_IMPORT(ArmPlatformGetPrimaryCoreMpId)\r
 \r
 GCC_ASM_IMPORT(gPcd_FixedAtBuild_PcdCoreCount)\r
-GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)\r
 \r
 //VOID\r
 //ArmPlatformStackSet (\r
@@ -35,14 +36,29 @@ GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
 //  IN UINTN SecondaryStackSize\r
 //  );\r
 ASM_PFX(ArmPlatformStackSet):\r
+  // Save parameters\r
+  mov   r6, r3\r
+  mov   r5, r2\r
+  mov   r4, r1\r
+  mov   r3, r0\r
+\r
+  // Save the Link register\r
+  mov   r7, lr\r
+\r
   // Identify Stack\r
-  // Mask for ClusterId|CoreId\r
-  LoadConstantToReg (0xFFFF, r4)\r
-  and   r1, r1, r4\r
-  // Is it the Primary Core ?\r
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r4)\r
-  ldr   r4, [r4]\r
-  cmp   r1, r4\r
+  mov   r0, r1\r
+  bl    ASM_PFX(ArmPlatformIsPrimaryCore)\r
+  cmp   r0, #1\r
+\r
+  // Restore parameters\r
+  mov   r0, r3\r
+  mov   r1, r4\r
+  mov   r2, r5\r
+  mov   r3, r6\r
+\r
+  // Restore the Link register\r
+  mov   lr, r7\r
+\r
   beq   ASM_PFX(ArmPlatformStackSetPrimary)\r
   bne   ASM_PFX(ArmPlatformStackSetSecondary)\r
 \r
@@ -87,8 +103,7 @@ ASM_PFX(ArmPlatformStackSetSecondary):
   mov   r5, r0\r
 \r
   // Get Primary Core Position\r
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)\r
-  ldr   r0, [r0]\r
+  bl    ASM_PFX(ArmPlatformGetPrimaryCoreMpId)\r
   bl    ASM_PFX(ArmPlatformGetCorePosition)\r
 \r
   // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)\r
index db92023922839c956ab7355b14b28b8b33d4074f..e7fd4a06a8953f83410ceb532ffcc486c3f0b1d1 100644 (file)
@@ -1,5 +1,5 @@
 //\r
-//  Copyright (c) 2012, ARM Limited. All rights reserved.\r
+//  Copyright (c) 2012-2013, ARM Limited. All rights reserved.\r
 //\r
 //  This program and the accompanying materials\r
 //  are licensed and made available under the terms and conditions of the BSD License\r
   EXPORT  ArmPlatformStackSetPrimary\r
   EXPORT  ArmPlatformStackSetSecondary\r
 \r
+  IMPORT  ArmPlatformIsPrimaryCore\r
   IMPORT  ArmPlatformGetCorePosition\r
+  IMPORT  ArmPlatformGetPrimaryCoreMpId\r
 \r
   IMPORT  _gPcd_FixedAtBuild_PcdCoreCount\r
-  IMPORT  _gPcd_FixedAtBuild_PcdArmPrimaryCore\r
 \r
   PRESERVE8\r
   AREA    ArmPlatformStackLib, CODE, READONLY\r
 //  IN UINTN SecondaryStackSize\r
 //  );\r
 ArmPlatformStackSet FUNCTION\r
+  // Save parameters\r
+  mov   r6, r3\r
+  mov   r5, r2\r
+  mov   r4, r1\r
+  mov   r3, r0\r
+\r
+  // Save the Link register\r
+  mov   r7, lr\r
+\r
   // Identify Stack\r
-  // Mask for ClusterId|CoreId\r
-  LoadConstantToReg (0xFFFF, r4)\r
-  and  r1, r1, r4\r
-  // Is it the Primary Core ?\r
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r4)\r
-  ldr  r4, [r4]\r
-  cmp   r1, r4\r
+  mov   r0, r1\r
+  bl    ArmPlatformIsPrimaryCore\r
+  cmp   r0, #1\r
+\r
+  // Restore parameters\r
+  mov   r0, r3\r
+  mov   r1, r4\r
+  mov   r2, r5\r
+  mov   r3, r6\r
+\r
+  // Restore the Link register\r
+  mov   lr, r7\r
+\r
   beq  ArmPlatformStackSetPrimary\r
   bne   ArmPlatformStackSetSecondary\r
   ENDFUNC\r
@@ -91,8 +107,7 @@ ArmPlatformStackSetSecondary FUNCTION
   mov  r5, r0\r
 \r
   // Get Primary Core Position\r
-  LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)\r
-  ldr  r0, [r0]\r
+  bl ArmPlatformGetPrimaryCoreMpId\r
   bl ArmPlatformGetCorePosition\r
 \r
   // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)\r
index 700bc89eac3184600c93a851a843c9ed72452874..affd3219649c0b8193fa392c57137839fd5a389e 100644 (file)
 [Sources.AARCH64]\r
   AArch64/ArmPlatformStackLib.S     | GCC\r
 \r
-[FixedPcd]\r
-  gArmPlatformTokenSpaceGuid.PcdCoreCount\r
+[LibraryClasses]\r
+  ArmPlatformLib\r
 \r
+[FixedPcd]\r
   gArmPlatformTokenSpaceGuid.PcdCoreCount\r
-\r
-  gArmTokenSpaceGuid.PcdArmPrimaryCoreMask\r
-  gArmTokenSpaceGuid.PcdArmPrimaryCore\r