2 // Copyright (c) 2012-2013, ARM Limited. All rights reserved.
4 // This program and the accompanying materials
5 // are licensed and made available under the terms and conditions of the BSD License
6 // which accompanies this distribution. The full text of the license may be found at
7 // http://opensource.org/licenses/bsd-license.php
9 // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #include <AsmMacroIoLib.h>
21 GCC_ASM_EXPORT(ArmPlatformStackSet)
22 GCC_ASM_EXPORT(ArmPlatformStackSetPrimary)
23 GCC_ASM_EXPORT(ArmPlatformStackSetSecondary)
25 GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
26 GCC_ASM_IMPORT(ArmPlatformGetCorePosition)
27 GCC_ASM_IMPORT(ArmPlatformGetPrimaryCoreMpId)
29 GCC_ASM_IMPORT(gPcd_FixedAtBuild_PcdCoreCount)
32 //ArmPlatformStackSet (
33 // IN UINTN StackBase,
35 // IN UINTN PrimaryStackSize,
36 // IN UINTN SecondaryStackSize
38 ASM_PFX(ArmPlatformStackSet):
45 // Save the Link register
50 bl ASM_PFX(ArmPlatformIsPrimaryCore)
59 // Restore the Link register
62 beq ASM_PFX(ArmPlatformStackSetPrimary)
63 bne ASM_PFX(ArmPlatformStackSetSecondary)
66 //ArmPlatformStackSetPrimary (
67 // IN UINTN StackBase,
69 // IN UINTN PrimaryStackSize,
70 // IN UINTN SecondaryStackSize
72 ASM_PFX(ArmPlatformStackSetPrimary):
75 // Add stack of primary stack to StackBase
78 // Compute SecondaryCoresCount * SecondaryCoreStackSize
79 LoadConstantToReg (_gPcd_FixedAtBuild_PcdCoreCount, r1)
84 // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount * SecondaryCoreStackSize))
90 //ArmPlatformStackSetSecondary (
91 // IN UINTN StackBase,
93 // IN UINTN PrimaryStackSize,
94 // IN UINTN SecondaryStackSize
96 ASM_PFX(ArmPlatformStackSetSecondary):
102 bl ASM_PFX(ArmPlatformGetCorePosition)
105 // Get Primary Core Position
106 bl ASM_PFX(ArmPlatformGetPrimaryCoreMpId)
107 bl ASM_PFX(ArmPlatformGetCorePosition)
109 // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)
114 // Compute top of the secondary stack