]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/RTSMHelper.S
ArmPlatformPkg: Introduced 'ArmPlatformSecLib'
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressSecLibRTSM / RTSMHelper.S
1 #
2 # Copyright (c) 2011-2012, ARM Limited. All rights reserved.
3 #
4 # This program and the accompanying materials
5 # are licensed and made available under the terms and conditions of the BSD License
6 # which accompanies this distribution. The full text of the license may be found at
7 # http:#opensource.org/licenses/bsd-license.php
8 #
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 #
12 #
13
14 #include <AsmMacroIoLib.h>
15 #include <Base.h>
16 #include <Library/PcdLib.h>
17 #include <AutoGen.h>
18 #.include AsmMacroIoLib.inc
19
20 #include <Chipset/ArmCortexA9.h>
21
22 .text
23 .align 2
24
25 GCC_ASM_EXPORT(ArmGetCpuCountPerCluster)
26
27 # IN None
28 # OUT r0 = SCU Base Address
29 ASM_PFX(ArmGetScuBaseAddress):
30 # Read Configuration Base Address Register. ArmCBar cannot be called to get
31 # the Configuration BAR as a stack is not necessary setup. The SCU is at the
32 # offset 0x0000 from the Private Memory Region.
33 mrc p15, 4, r0, c15, c0, 0
34 bx lr
35
36 # IN None
37 # OUT r0 = number of cores present in the system
38 ASM_PFX(ArmGetCpuCountPerCluster):
39 stmfd SP!, {r1-r2}
40
41 # Read CP15 MIDR
42 mrc p15, 0, r1, c0, c0, 0
43
44 # Check if the CPU is A15
45 mov r1, r1, LSR #4
46 LoadConstantToReg (ARM_CPU_TYPE_MASK, r0)
47 and r1, r1, r0
48
49 LoadConstantToReg (ARM_CPU_TYPE_A15, r0)
50 cmp r1, r0
51 beq _Read_cp15_reg
52
53 _CPU_is_not_A15:
54 mov r2, lr @ Save link register
55 bl ArmGetScuBaseAddress @ Read SCU Base Address
56 mov lr, r2 @ Restore link register val
57 ldr r0, [r0, #A9_SCU_CONFIG_OFFSET] @ Read SCU Config reg to get CPU count
58 b _Return
59
60 _Read_cp15_reg:
61 mrc p15, 1, r0, c9, c0, 2 @ Read C9 register of CP15 to get CPU count
62 lsr r0, #24
63
64 _Return:
65 and r0, r0, #3
66 # Add '1' to the number of CPU on the Cluster
67 add r0, r0, #1
68 ldmfd SP!, {r1-r2}
69 bx lr
70
71 ASM_FUNCTION_REMOVE_IF_UNREFERENCED