]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.asm
ArmPkg: Fixed unsigned type to be architecture independent
[mirror_edk2.git] / ArmPlatformPkg / Library / ArmPlatformStackLib / ArmPlatformStackLib.asm
CommitLineData
17839a45 1//\r
2// Copyright (c) 2012, ARM Limited. All rights reserved.\r
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
24 IMPORT ArmPlatformGetCorePosition\r
25\r
26 IMPORT _gPcd_FixedAtBuild_PcdCoreCount\r
27 IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore\r
28\r
29 PRESERVE8\r
30 AREA ArmPlatformStackLib, CODE, READONLY\r
31\r
32//VOID\r
33//ArmPlatformStackSet (\r
34// IN UINTN StackBase,\r
35// IN UINTN MpId,\r
36// IN UINTN PrimaryStackSize,\r
37// IN UINTN SecondaryStackSize\r
38// );\r
39ArmPlatformStackSet FUNCTION\r
40 // Identify Stack\r
41 // Mask for ClusterId|CoreId\r
42 LoadConstantToReg (0xFFFF, r4)\r
43 and r1, r1, r4\r
44 // Is it the Primary Core ?\r
45 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r4)\r
46 ldr r4, [r4]\r
47 cmp r1, r4\r
48 beq ArmPlatformStackSetPrimary\r
49 bne ArmPlatformStackSetSecondary\r
50 ENDFUNC\r
51\r
52//VOID\r
53//ArmPlatformStackSetPrimary (\r
54// IN UINTN StackBase,\r
55// IN UINTN MpId,\r
56// IN UINTN PrimaryStackSize,\r
57// IN UINTN SecondaryStackSize\r
58// );\r
59ArmPlatformStackSetPrimary FUNCTION\r
60 mov r4, lr\r
61\r
62 // Add stack of primary stack to StackBase\r
63 add r0, r0, r2\r
64\r
65 // Compute SecondaryCoresCount * SecondaryCoreStackSize\r
66 LoadConstantToReg (_gPcd_FixedAtBuild_PcdCoreCount, r1)\r
67 ldr r1, [r1]\r
68 sub r1, #1\r
69 mul r3, r3, r1\r
70\r
71 // Set Primary Stack ((StackBase + PrimaryStackSize) + (SecondaryCoresCount * SecondaryCoreStackSize))\r
72 add sp, r0, r3\r
73\r
74 bx r4\r
75 ENDFUNC\r
76\r
77//VOID\r
78//ArmPlatformStackSetSecondary (\r
79// IN UINTN StackBase,\r
80// IN UINTN MpId,\r
81// IN UINTN PrimaryStackSize,\r
82// IN UINTN SecondaryStackSize\r
83// );\r
84ArmPlatformStackSetSecondary FUNCTION\r
85 mov r4, lr\r
86 mov sp, r0\r
87\r
88 // Get Core Position\r
89 mov r0, r1\r
90 bl ArmPlatformGetCorePosition\r
91 mov r5, r0\r
92\r
93 // Get Primary Core Position\r
94 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)\r
95 ldr r0, [r0]\r
96 bl ArmPlatformGetCorePosition\r
97\r
98 // Get Secondary Core Position. We should get consecutive secondary stack number from 1...(CoreCount-1)\r
99 cmp r5, r0\r
100 subhi r5, r5, #1\r
101 add r5, r5, #1\r
102\r
103 // Compute top of the secondary stack\r
104 mul r3, r3, r5\r
105\r
106 // Set stack\r
107 add sp, sp, r3\r
108\r
109 bx r4\r
110 ENDFUNC\r
111\r
112 END\r