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 // Should be ASM_PFX(ArmPlatformStackSetPrimary) but generate linker error 'unsupported ELF EM_AARCH64'
63 b.eq ArmPlatformStackSetPrimaryL
64 // Should be ASM_PFX(ArmPlatformStackSetSecondary) but generate linker error 'unsupported ELF EM_AARCH64'
65 b.ne ArmPlatformStackSetSecondaryL
68 //ArmPlatformStackSetPrimary (
69 // IN UINTN StackBase,
71 // IN UINTN PrimaryStackSize,
72 // IN UINTN SecondaryStackSize
74 ArmPlatformStackSetPrimaryL:
75 ASM_PFX(ArmPlatformStackSetPrimary):
76 // Save the Link register
79 // Add stack of primary stack to StackBase
82 // Compute SecondaryCoresCount * SecondaryCoreStackSize
83 LoadConstantToReg (_gPcd_FixedAtBuild_PcdCoreCount, x1)
88 // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount * SecondaryCoreStackSize))
94 //ArmPlatformStackSetSecondary (
95 // IN UINTN StackBase,
97 // IN UINTN PrimaryStackSize,
98 // IN UINTN SecondaryStackSize
100 ArmPlatformStackSetSecondaryL:
101 ASM_PFX(ArmPlatformStackSetSecondary):
102 // Save the Link register
108 bl ASM_PFX(ArmPlatformGetCorePosition)
111 // Get Primary Core Position
112 bl ASM_PFX(ArmPlatformGetPrimaryCoreMpId)
113 bl ASM_PFX(ArmPlatformGetCorePosition)
115 // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)
118 // Decrement the position if after the primary core
123 // Compute top of the secondary stack