]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Library/ArmPlatformStackLib/AArch64/ArmPlatformStackLib.S
ArmPlatformPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / ArmPlatformPkg / Library / ArmPlatformStackLib / AArch64 / ArmPlatformStackLib.S
CommitLineData
1bc83266 1//\r
51ad04cb 2// Copyright (c) 2012-2014, ARM Limited. All rights reserved.\r
1bc83266 3//\r
f4dfad05 4// SPDX-License-Identifier: BSD-2-Clause-Patent\r
1bc83266
HL
5//\r
6//\r
7\r
51ad04cb 8#include <AsmMacroIoLibV8.h>\r
1bc83266
HL
9\r
10//VOID\r
11//ArmPlatformStackSet (\r
12// IN UINTN StackBase,\r
13// IN UINTN MpId,\r
14// IN UINTN PrimaryStackSize,\r
15// IN UINTN SecondaryStackSize\r
16// );\r
92605930 17ASM_FUNC(ArmPlatformStackSet)\r
1bc83266 18 // Save parameters\r
91231b55
AB
19 mov x26, x3\r
20 mov x25, x2\r
21 mov x24, x1\r
22 mov x23, x0\r
1bc83266
HL
23\r
24 // Save the Link register\r
91231b55 25 mov x27, x30\r
1bc83266
HL
26\r
27 // Identify Stack\r
28 mov x0, x1\r
29 bl ASM_PFX(ArmPlatformIsPrimaryCore)\r
30 cmp x0, #1\r
31\r
32 // Restore parameters\r
91231b55
AB
33 mov x0, x23\r
34 mov x1, x24\r
35 mov x2, x25\r
36 mov x3, x26\r
1bc83266
HL
37\r
38 // Restore the Link register\r
91231b55 39 mov x30, x27\r
1bc83266 40\r
92605930
AB
41 b.ne 0f\r
42\r
43 b ASM_PFX(ArmPlatformStackSetPrimary)\r
440:b ASM_PFX(ArmPlatformStackSetSecondary)\r
1bc83266
HL
45\r
46//VOID\r
47//ArmPlatformStackSetPrimary (\r
48// IN UINTN StackBase,\r
49// IN UINTN MpId,\r
50// IN UINTN PrimaryStackSize,\r
51// IN UINTN SecondaryStackSize\r
52// );\r
92605930 53ASM_FUNC(ArmPlatformStackSetPrimary)\r
91231b55 54 // Add size of primary stack to StackBase\r
1bc83266
HL
55 add x0, x0, x2\r
56\r
57 // Compute SecondaryCoresCount * SecondaryCoreStackSize\r
92605930 58 MOV32 (w1, FixedPcdGet32(PcdCoreCount) - 1)\r
1bc83266
HL
59 mul x3, x3, x1\r
60\r
61 // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount * SecondaryCoreStackSize))\r
62 add sp, x0, x3\r
63\r
91231b55 64 ret\r
1bc83266
HL
65\r
66//VOID\r
67//ArmPlatformStackSetSecondary (\r
68// IN UINTN StackBase,\r
69// IN UINTN MpId,\r
70// IN UINTN PrimaryStackSize,\r
71// IN UINTN SecondaryStackSize\r
72// );\r
92605930 73ASM_FUNC(ArmPlatformStackSetSecondary)\r
1bc83266 74 // Save the Link register\r
91231b55 75 mov x24, x30\r
1bc83266
HL
76 mov sp, x0\r
77\r
78 // Get Core Position\r
79 mov x0, x1\r
80 bl ASM_PFX(ArmPlatformGetCorePosition)\r
91231b55 81 mov x25, x0\r
1bc83266
HL
82\r
83 // Get Primary Core Position\r
84 bl ASM_PFX(ArmPlatformGetPrimaryCoreMpId)\r
85 bl ASM_PFX(ArmPlatformGetCorePosition)\r
86\r
87 // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)\r
91231b55
AB
88 cmp x25, x0\r
89\r
1bc83266 90 // Decrement the position if after the primary core\r
91231b55 91 cinc x25, x25, ls\r
1bc83266
HL
92\r
93 // Compute top of the secondary stack\r
91231b55 94 mul x3, x3, x25\r
1bc83266
HL
95\r
96 // Set stack\r
97 add sp, sp, x3\r
98\r
91231b55 99 ret x24\r