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>
18 INCLUDE AsmMacroIoLib.inc
20 EXPORT ArmPlatformStackSet
21 EXPORT ArmPlatformStackSetPrimary
22 EXPORT ArmPlatformStackSetSecondary
24 IMPORT ArmPlatformIsPrimaryCore
25 IMPORT ArmPlatformGetCorePosition
26 IMPORT ArmPlatformGetPrimaryCoreMpId
28 IMPORT _gPcd_FixedAtBuild_PcdCoreCount
31 AREA ArmPlatformStackLib, CODE, READONLY
34 //ArmPlatformStackSet (
35 // IN UINTN StackBase,
37 // IN UINTN PrimaryStackSize,
38 // IN UINTN SecondaryStackSize
40 ArmPlatformStackSet FUNCTION
47 // Save the Link register
52 bl ArmPlatformIsPrimaryCore
61 // Restore the Link register
64 beq ArmPlatformStackSetPrimary
65 bne ArmPlatformStackSetSecondary
69 //ArmPlatformStackSetPrimary (
70 // IN UINTN StackBase,
72 // IN UINTN PrimaryStackSize,
73 // IN UINTN SecondaryStackSize
75 ArmPlatformStackSetPrimary FUNCTION
78 // Add stack of primary stack to StackBase
81 // Compute SecondaryCoresCount * SecondaryCoreStackSize
82 LoadConstantToReg (_gPcd_FixedAtBuild_PcdCoreCount, r1)
87 // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount * SecondaryCoreStackSize))
94 //ArmPlatformStackSetSecondary (
95 // IN UINTN StackBase,
97 // IN UINTN PrimaryStackSize,
98 // IN UINTN SecondaryStackSize
100 ArmPlatformStackSetSecondary FUNCTION
106 bl ArmPlatformGetCorePosition
109 // Get Primary Core Position
110 bl ArmPlatformGetPrimaryCoreMpId
111 bl ArmPlatformGetCorePosition
113 // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)
118 // Compute top of the secondary stack