]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S
ARM Packages: Replaced the macro GetCorePositionFromMpId() by the ArmPlatformGetCoreP...
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibRTSM / Arm / RTSMHelper.S
CommitLineData
88d4f51d 1#\r
bebda7ce 2# Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
88d4f51d 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
bebda7ce 7# http://opensource.org/licenses/bsd-license.php\r
88d4f51d 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
2d45f194 16#include <Library/ArmLib.h>\r
88d4f51d 17#include <Library/PcdLib.h>\r
18#include <AutoGen.h>\r
88d4f51d 19\r
20#include <Chipset/ArmCortexA9.h>\r
21\r
22.text\r
23.align 2\r
24\r
25GCC_ASM_EXPORT(ArmGetCpuCountPerCluster)\r
bebda7ce 26GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)\r
d05ca26c 27GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)\r
2d45f194 28GCC_ASM_EXPORT(ArmPlatformGetCorePosition)\r
bebda7ce 29\r
30GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)\r
31GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)\r
88d4f51d 32\r
33# IN None\r
34# OUT r0 = SCU Base Address\r
35ASM_PFX(ArmGetScuBaseAddress):\r
36 # Read Configuration Base Address Register. ArmCBar cannot be called to get\r
37 # the Configuration BAR as a stack is not necessary setup. The SCU is at the\r
38 # offset 0x0000 from the Private Memory Region.\r
39 mrc p15, 4, r0, c15, c0, 0\r
40 bx lr\r
41\r
d05ca26c 42//UINTN\r
43//ArmPlatformGetPrimaryCoreMpId (\r
44// VOID\r
45// );\r
46ASM_PFX(ArmPlatformGetPrimaryCoreMpId):\r
47 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)\r
48 ldr r0, [r0]\r
49 bx lr\r
50\r
88d4f51d 51# IN None\r
52# OUT r0 = number of cores present in the system\r
53ASM_PFX(ArmGetCpuCountPerCluster):\r
54 stmfd SP!, {r1-r2}\r
55\r
56 # Read CP15 MIDR\r
57 mrc p15, 0, r1, c0, c0, 0\r
58\r
59 # Check if the CPU is A15\r
60 mov r1, r1, LSR #4\r
61 LoadConstantToReg (ARM_CPU_TYPE_MASK, r0)\r
62 and r1, r1, r0\r
63\r
64 LoadConstantToReg (ARM_CPU_TYPE_A15, r0)\r
65 cmp r1, r0\r
66 beq _Read_cp15_reg\r
67\r
68_CPU_is_not_A15:\r
69 mov r2, lr @ Save link register\r
70 bl ArmGetScuBaseAddress @ Read SCU Base Address\r
71 mov lr, r2 @ Restore link register val\r
72 ldr r0, [r0, #A9_SCU_CONFIG_OFFSET] @ Read SCU Config reg to get CPU count\r
73 b _Return\r
74\r
75_Read_cp15_reg:\r
76 mrc p15, 1, r0, c9, c0, 2 @ Read C9 register of CP15 to get CPU count\r
77 lsr r0, #24\r
78\r
79_Return:\r
80 and r0, r0, #3\r
81 # Add '1' to the number of CPU on the Cluster\r
82 add r0, r0, #1\r
83 ldmfd SP!, {r1-r2}\r
84 bx lr\r
85\r
bebda7ce 86//UINTN\r
87//ArmPlatformIsPrimaryCore (\r
88// IN UINTN MpId\r
89// );\r
90ASM_PFX(ArmPlatformIsPrimaryCore):\r
91 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)\r
92 ldr r1, [r1]\r
93 and r0, r0, r1\r
94 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)\r
95 ldr r1, [r1]\r
96 cmp r0, r1\r
97 moveq r0, #1\r
98 movne r0, #0\r
99 bx lr\r
100\r
2d45f194 101//UINTN\r
102//ArmPlatformGetCorePosition (\r
103// IN UINTN MpId\r
104// );\r
105ASM_PFX(ArmPlatformGetCorePosition):\r
106 and r1, r0, #ARM_CORE_MASK\r
107 and r0, r0, #ARM_CLUSTER_MASK\r
108 add r0, r1, r0, LSR #7\r
109 bx lr\r
110\r
88d4f51d 111ASM_FUNCTION_REMOVE_IF_UNREFERENCED \r