]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm
ArmPlatformPkg/ArmPlatformLib: Added ArmPlatformGetPrimaryCoreMpId()
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibRTSM / Arm / RTSMHelper.asm
CommitLineData
88d4f51d 1//\r
bebda7ce 2// Copyright (c) 2011-2012, 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
16#include <Library/PcdLib.h>\r
17\r
18#include <Chipset/ArmCortexA9.h>\r
19\r
20#include <AutoGen.h>\r
21\r
22 INCLUDE AsmMacroIoLib.inc\r
23\r
24 EXPORT ArmGetCpuCountPerCluster\r
bebda7ce 25 EXPORT ArmPlatformIsPrimaryCore\r
d05ca26c 26 EXPORT ArmPlatformGetPrimaryCoreMpId\r
bebda7ce 27\r
28 IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore\r
29 IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask\r
30\r
88d4f51d 31 AREA RTSMHelper, CODE, READONLY\r
32\r
33// IN None\r
34// OUT r0 = SCU Base Address\r
bebda7ce 35ArmGetScuBaseAddress FUNCTION\r
88d4f51d 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
bebda7ce 41 ENDFUNC\r
88d4f51d 42\r
d05ca26c 43//UINTN\r
44//ArmPlatformGetPrimaryCoreMpId (\r
45// VOID\r
46// );\r
47ArmPlatformGetPrimaryCoreMpId FUNCTION\r
48 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)\r
49 ldr r0, [r0]\r
50 bx lr\r
51 ENDFUNC\r
52\r
88d4f51d 53// IN None\r
54// OUT r0 = number of cores present in the system\r
bebda7ce 55ArmGetCpuCountPerCluster FUNCTION\r
88d4f51d 56 stmfd SP!, {r1-r2}\r
57\r
58 // Read CP15 MIDR\r
59 mrc p15, 0, r1, c0, c0, 0\r
60\r
61 // Check if the CPU is A15\r
62 mov r1, r1, LSR #4\r
63 mov r0, #ARM_CPU_TYPE_MASK\r
64 and r1, r1, r0\r
65\r
66 mov r0, #ARM_CPU_TYPE_A15\r
67 cmp r1, r0\r
68 beq _Read_cp15_reg\r
69\r
70_CPU_is_not_A15\r
71 mov r2, lr ; Save link register\r
72 bl ArmGetScuBaseAddress ; Read SCU Base Address\r
73 mov lr, r2 ; Restore link register val\r
74 ldr r0, [r0, #A9_SCU_CONFIG_OFFSET] ; Read SCU Config reg to get CPU count\r
75 b _Return\r
76\r
77_Read_cp15_reg\r
78 mrc p15, 1, r0, c9, c0, 2 ; Read C9 register of CP15 to get CPU count\r
79 lsr r0, #24\r
80\r
81\r
82_Return\r
83 and r0, r0, #3\r
84 // Add '1' to the number of CPU on the Cluster\r
85 add r0, r0, #1\r
86 ldmfd SP!, {r1-r2}\r
87 bx lr\r
bebda7ce 88 ENDFUNC\r
89\r
90//UINTN\r
91//ArmPlatformIsPrimaryCore (\r
92// IN UINTN MpId\r
93// );\r
94ArmPlatformIsPrimaryCore FUNCTION\r
95 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)\r
96 ldr r1, [r1]\r
97 and r0, r0, r1\r
98 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)\r
99 ldr r1, [r1]\r
100 cmp r0, r1\r
101 moveq r0, #1\r
102 movne r0, #0\r
103 bx lr\r
104 ENDFUNC\r
88d4f51d 105\r
106 END\r