]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.asm
ARM Packages: Replace tabs by spaces for indentation
[mirror_edk2.git] / ArmPlatformPkg / Library / ArmPlatformStackLib / Arm / ArmPlatformStackLib.asm
CommitLineData
17839a45 1//\r
8a25bd7c 2// Copyright (c) 2012-2013, ARM Limited. All rights reserved.\r
17839a45 3//\r
4// This program and the accompanying materials\r
5// are licensed and made available under the terms and conditions of the BSD License\r
6// which accompanies this distribution. The full text of the license may be found at\r
7// http://opensource.org/licenses/bsd-license.php\r
8//\r
9// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11//\r
12//\r
13\r
14#include <AsmMacroIoLib.h>\r
15#include <Base.h>\r
16#include <AutoGen.h>\r
17\r
18 INCLUDE AsmMacroIoLib.inc\r
19\r
20 EXPORT ArmPlatformStackSet\r
21 EXPORT ArmPlatformStackSetPrimary\r
22 EXPORT ArmPlatformStackSetSecondary\r
23\r
8a25bd7c 24 IMPORT ArmPlatformIsPrimaryCore\r
17839a45 25 IMPORT ArmPlatformGetCorePosition\r
8a25bd7c 26 IMPORT ArmPlatformGetPrimaryCoreMpId\r
17839a45 27\r
28 IMPORT _gPcd_FixedAtBuild_PcdCoreCount\r
17839a45 29\r
30 PRESERVE8\r
31 AREA ArmPlatformStackLib, CODE, READONLY\r
32\r
33//VOID\r
34//ArmPlatformStackSet (\r
35// IN UINTN StackBase,\r
36// IN UINTN MpId,\r
37// IN UINTN PrimaryStackSize,\r
38// IN UINTN SecondaryStackSize\r
39// );\r
40ArmPlatformStackSet FUNCTION\r
8a25bd7c
OM
41 // Save parameters\r
42 mov r6, r3\r
43 mov r5, r2\r
44 mov r4, r1\r
45 mov r3, r0\r
46\r
47 // Save the Link register\r
48 mov r7, lr\r
49\r
17839a45 50 // Identify Stack\r
8a25bd7c
OM
51 mov r0, r1\r
52 bl ArmPlatformIsPrimaryCore\r
53 cmp r0, #1\r
54\r
55 // Restore parameters\r
56 mov r0, r3\r
57 mov r1, r4\r
58 mov r2, r5\r
59 mov r3, r6\r
60\r
61 // Restore the Link register\r
62 mov lr, r7\r
63\r
91c38d4e 64 beq ArmPlatformStackSetPrimary\r
17839a45 65 bne ArmPlatformStackSetSecondary\r
66 ENDFUNC\r
67\r
68//VOID\r
69//ArmPlatformStackSetPrimary (\r
70// IN UINTN StackBase,\r
71// IN UINTN MpId,\r
72// IN UINTN PrimaryStackSize,\r
73// IN UINTN SecondaryStackSize\r
74// );\r
75ArmPlatformStackSetPrimary FUNCTION\r
91c38d4e 76 mov r4, lr\r
17839a45 77\r
78 // Add stack of primary stack to StackBase\r
91c38d4e 79 add r0, r0, r2\r
17839a45 80\r
81 // Compute SecondaryCoresCount * SecondaryCoreStackSize\r
82 LoadConstantToReg (_gPcd_FixedAtBuild_PcdCoreCount, r1)\r
91c38d4e
RC
83 ldr r1, [r1]\r
84 sub r1, #1\r
85 mul r3, r3, r1\r
17839a45 86\r
87 // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount * SecondaryCoreStackSize))\r
91c38d4e 88 add sp, r0, r3\r
17839a45 89\r
90 bx r4\r
91 ENDFUNC\r
92\r
93//VOID\r
94//ArmPlatformStackSetSecondary (\r
95// IN UINTN StackBase,\r
96// IN UINTN MpId,\r
97// IN UINTN PrimaryStackSize,\r
98// IN UINTN SecondaryStackSize\r
99// );\r
100ArmPlatformStackSetSecondary FUNCTION\r
91c38d4e 101 mov r4, lr\r
17839a45 102 mov sp, r0\r
103\r
104 // Get Core Position\r
91c38d4e 105 mov r0, r1\r
17839a45 106 bl ArmPlatformGetCorePosition\r
91c38d4e 107 mov r5, r0\r
17839a45 108\r
109 // Get Primary Core Position\r
8a25bd7c 110 bl ArmPlatformGetPrimaryCoreMpId\r
17839a45 111 bl ArmPlatformGetCorePosition\r
112\r
113 // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)\r
91c38d4e 114 cmp r5, r0\r
17839a45 115 subhi r5, r5, #1\r
91c38d4e 116 add r5, r5, #1\r
17839a45 117\r
118 // Compute top of the secondary stack\r
91c38d4e 119 mul r3, r3, r5\r
17839a45 120\r
121 // Set stack\r
91c38d4e 122 add sp, sp, r3\r
17839a45 123\r
124 bx r4\r
125 ENDFUNC\r
126\r
127 END\r