]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.asm
ARM Packages: Replace tabs by spaces for indentation
[mirror_edk2.git] / ArmPlatformPkg / Library / ArmPlatformStackLib / Arm / ArmPlatformStackLib.asm
1 //
2 // Copyright (c) 2012-2013, ARM Limited. All rights reserved.
3 //
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
8 //
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.
11 //
12 //
13
14 #include <AsmMacroIoLib.h>
15 #include <Base.h>
16 #include <AutoGen.h>
17
18 INCLUDE AsmMacroIoLib.inc
19
20 EXPORT ArmPlatformStackSet
21 EXPORT ArmPlatformStackSetPrimary
22 EXPORT ArmPlatformStackSetSecondary
23
24 IMPORT ArmPlatformIsPrimaryCore
25 IMPORT ArmPlatformGetCorePosition
26 IMPORT ArmPlatformGetPrimaryCoreMpId
27
28 IMPORT _gPcd_FixedAtBuild_PcdCoreCount
29
30 PRESERVE8
31 AREA ArmPlatformStackLib, CODE, READONLY
32
33 //VOID
34 //ArmPlatformStackSet (
35 // IN UINTN StackBase,
36 // IN UINTN MpId,
37 // IN UINTN PrimaryStackSize,
38 // IN UINTN SecondaryStackSize
39 // );
40 ArmPlatformStackSet FUNCTION
41 // Save parameters
42 mov r6, r3
43 mov r5, r2
44 mov r4, r1
45 mov r3, r0
46
47 // Save the Link register
48 mov r7, lr
49
50 // Identify Stack
51 mov r0, r1
52 bl ArmPlatformIsPrimaryCore
53 cmp r0, #1
54
55 // Restore parameters
56 mov r0, r3
57 mov r1, r4
58 mov r2, r5
59 mov r3, r6
60
61 // Restore the Link register
62 mov lr, r7
63
64 beq ArmPlatformStackSetPrimary
65 bne ArmPlatformStackSetSecondary
66 ENDFUNC
67
68 //VOID
69 //ArmPlatformStackSetPrimary (
70 // IN UINTN StackBase,
71 // IN UINTN MpId,
72 // IN UINTN PrimaryStackSize,
73 // IN UINTN SecondaryStackSize
74 // );
75 ArmPlatformStackSetPrimary FUNCTION
76 mov r4, lr
77
78 // Add stack of primary stack to StackBase
79 add r0, r0, r2
80
81 // Compute SecondaryCoresCount * SecondaryCoreStackSize
82 LoadConstantToReg (_gPcd_FixedAtBuild_PcdCoreCount, r1)
83 ldr r1, [r1]
84 sub r1, #1
85 mul r3, r3, r1
86
87 // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount * SecondaryCoreStackSize))
88 add sp, r0, r3
89
90 bx r4
91 ENDFUNC
92
93 //VOID
94 //ArmPlatformStackSetSecondary (
95 // IN UINTN StackBase,
96 // IN UINTN MpId,
97 // IN UINTN PrimaryStackSize,
98 // IN UINTN SecondaryStackSize
99 // );
100 ArmPlatformStackSetSecondary FUNCTION
101 mov r4, lr
102 mov sp, r0
103
104 // Get Core Position
105 mov r0, r1
106 bl ArmPlatformGetCorePosition
107 mov r5, r0
108
109 // Get Primary Core Position
110 bl ArmPlatformGetPrimaryCoreMpId
111 bl ArmPlatformGetCorePosition
112
113 // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)
114 cmp r5, r0
115 subhi r5, r5, #1
116 add r5, r5, #1
117
118 // Compute top of the secondary stack
119 mul r3, r3, r5
120
121 // Set stack
122 add sp, sp, r3
123
124 bx r4
125 ENDFUNC
126
127 END