2 // Copyright (c) 2011-2013, 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.
15 #include <Library/ArmLib.h>
16 #include <Library/PcdLib.h>
18 #include <Chipset/ArmCortexA9.h>
22 INCLUDE AsmMacroIoLib.inc
24 EXPORT ArmPlatformPeiBootAction
25 EXPORT ArmGetCpuCountPerCluster
26 EXPORT ArmPlatformIsPrimaryCore
27 EXPORT ArmPlatformGetPrimaryCoreMpId
28 EXPORT ArmPlatformGetCorePosition
30 AREA RTSMHelper, CODE, READONLY
32 ArmPlatformPeiBootAction FUNCTION
37 // OUT r0 = SCU Base Address
38 ArmGetScuBaseAddress FUNCTION
39 // Read Configuration Base Address Register. ArmCBar cannot be called to get
40 // the Configuration BAR as a stack is not necessary setup. The SCU is at the
41 // offset 0x0000 from the Private Memory Region.
42 mrc p15, 4, r0, c15, c0, 0
47 //ArmPlatformGetPrimaryCoreMpId (
50 ArmPlatformGetPrimaryCoreMpId FUNCTION
51 mov32 r0, FixedPcdGet32(PcdArmPrimaryCore)
56 // OUT r0 = number of cores present in the system
57 ArmGetCpuCountPerCluster FUNCTION
61 mrc p15, 0, r1, c0, c0, 0
63 // Check if the CPU is A15
65 mov r0, #ARM_CPU_TYPE_MASK
68 mov r0, #ARM_CPU_TYPE_A15
73 mov r2, lr ; Save link register
74 bl ArmGetScuBaseAddress ; Read SCU Base Address
75 mov lr, r2 ; Restore link register val
76 ldr r0, [r0, #A9_SCU_CONFIG_OFFSET] ; Read SCU Config reg to get CPU count
80 mrc p15, 1, r0, c9, c0, 2 ; Read C9 register of CP15 to get CPU count
86 // Add '1' to the number of CPU on the Cluster
93 //ArmPlatformIsPrimaryCore (
96 ArmPlatformIsPrimaryCore FUNCTION
97 mov32 r1, FixedPcdGet32(PcdArmPrimaryCoreMask)
99 mov32 r1, FixedPcdGet32(PcdArmPrimaryCore)
108 //ArmPlatformGetCorePosition (
111 ArmPlatformGetCorePosition FUNCTION
112 and r1, r0, #ARM_CORE_MASK
113 and r0, r0, #ARM_CLUSTER_MASK
114 add r0, r1, r0, LSR #7