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>
18 INCLUDE AsmMacroIoLib.inc
20 EXPORT ArmPlatformStackSet
21 EXPORT ArmPlatformStackSetPrimary
22 EXPORT ArmPlatformStackSetSecondary
24 IMPORT ArmPlatformGetCorePosition
26 IMPORT _gPcd_FixedAtBuild_PcdCoreCount
27 IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore
30 AREA ArmPlatformStackLib, CODE, READONLY
33 //ArmPlatformStackSet (
34 // IN UINTN StackBase,
36 // IN UINTN PrimaryStackSize,
37 // IN UINTN SecondaryStackSize
39 ArmPlatformStackSet FUNCTION
41 // Mask for ClusterId|CoreId
42 LoadConstantToReg (0xFFFF, r4)
44 // Is it the Primary Core ?
45 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r4)
48 beq ArmPlatformStackSetPrimary
49 bne ArmPlatformStackSetSecondary
53 //ArmPlatformStackSetPrimary (
54 // IN UINTN StackBase,
56 // IN UINTN PrimaryStackSize,
57 // IN UINTN SecondaryStackSize
59 ArmPlatformStackSetPrimary FUNCTION
62 // Add stack of primary stack to StackBase
65 // Compute SecondaryCoresCount * SecondaryCoreStackSize
66 LoadConstantToReg (_gPcd_FixedAtBuild_PcdCoreCount, r1)
71 // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount * SecondaryCoreStackSize))
78 //ArmPlatformStackSetSecondary (
79 // IN UINTN StackBase,
81 // IN UINTN PrimaryStackSize,
82 // IN UINTN SecondaryStackSize
84 ArmPlatformStackSetSecondary FUNCTION
90 bl ArmPlatformGetCorePosition
93 // Get Primary Core Position
94 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)
96 bl ArmPlatformGetCorePosition
98 // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)
103 // Compute top of the secondary stack