2 // Copyright (c) 2012, 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(ArmPlatformGetCorePosition)
27 GCC_ASM_IMPORT(gPcd_FixedAtBuild_PcdCoreCount)
28 GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
31 //ArmPlatformStackSet (
32 // IN UINTN StackBase,
34 // IN UINTN PrimaryStackSize,
35 // IN UINTN SecondaryStackSize
37 ASM_PFX(ArmPlatformStackSet):
39 // Mask for ClusterId|CoreId
40 LoadConstantToReg (0xFFFF, r4)
42 // Is it the Primary Core ?
43 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r4)
46 beq ASM_PFX(ArmPlatformStackSetPrimary)
47 bne ASM_PFX(ArmPlatformStackSetSecondary)
50 //ArmPlatformStackSetPrimary (
51 // IN UINTN StackBase,
53 // IN UINTN PrimaryStackSize,
54 // IN UINTN SecondaryStackSize
56 ASM_PFX(ArmPlatformStackSetPrimary):
59 // Add stack of primary stack to StackBase
62 // Compute SecondaryCoresCount * SecondaryCoreStackSize
63 LoadConstantToReg (_gPcd_FixedAtBuild_PcdCoreCount, r1)
68 // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount * SecondaryCoreStackSize))
74 //ArmPlatformStackSetSecondary (
75 // IN UINTN StackBase,
77 // IN UINTN PrimaryStackSize,
78 // IN UINTN SecondaryStackSize
80 ASM_PFX(ArmPlatformStackSetSecondary):
86 bl ASM_PFX(ArmPlatformGetCorePosition)
89 // Get Primary Core Position
90 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)
92 bl ASM_PFX(ArmPlatformGetCorePosition)
94 // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)
99 // Compute top of the secondary stack