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