2 # Copyright (c) 2011, ARM Limited. All rights reserved.
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
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.
14 #include <AsmMacroIoLib.h>
16 #include <Library/PcdLib.h>
18 #.include AsmMacroIoLib.inc
20 #include <Chipset/ArmCortexA9.h>
25 GCC_ASM_EXPORT(ArmGetCpuCountPerCluster)
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
37 # OUT r0 = number of cores present in the system
38 ASM_PFX(ArmGetCpuCountPerCluster):
42 mrc p15, 0, r1, c0, c0, 0
44 # Check if the CPU is A15
46 LoadConstantToReg (ARM_CPU_TYPE_MASK, r0)
49 LoadConstantToReg (ARM_CPU_TYPE_A15, r0)
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
61 mrc p15, 1, r0, c9, c0, 2 @ Read C9 register of CP15 to get CPU count
66 # Add '1' to the number of CPU on the Cluster
71 ASM_FUNCTION_REMOVE_IF_UNREFERENCED