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