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.
14 #include <AsmMacroIoLib.h>
16 #include <Library/ArmLib.h>
17 #include <Library/PcdLib.h>
19 #include <Chipset/ArmCortexA9.h>
23 INCLUDE AsmMacroIoLib.inc
25 EXPORT ArmPlatformPeiBootAction
26 EXPORT ArmGetCpuCountPerCluster
27 EXPORT ArmPlatformIsPrimaryCore
28 EXPORT ArmPlatformGetPrimaryCoreMpId
29 EXPORT ArmPlatformGetCorePosition
31 IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore
32 IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask
34 AREA RTSMHelper, CODE, READONLY
36 ArmPlatformPeiBootAction FUNCTION
41 // OUT r0 = SCU Base Address
42 ArmGetScuBaseAddress FUNCTION
43 // Read Configuration Base Address Register. ArmCBar cannot be called to get
44 // the Configuration BAR as a stack is not necessary setup. The SCU is at the
45 // offset 0x0000 from the Private Memory Region.
46 mrc p15, 4, r0, c15, c0, 0
51 //ArmPlatformGetPrimaryCoreMpId (
54 ArmPlatformGetPrimaryCoreMpId FUNCTION
55 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)
61 // OUT r0 = number of cores present in the system
62 ArmGetCpuCountPerCluster FUNCTION
66 mrc p15, 0, r1, c0, c0, 0
68 // Check if the CPU is A15
70 mov r0, #ARM_CPU_TYPE_MASK
73 mov r0, #ARM_CPU_TYPE_A15
78 mov r2, lr ; Save link register
79 bl ArmGetScuBaseAddress ; Read SCU Base Address
80 mov lr, r2 ; Restore link register val
81 ldr r0, [r0, #A9_SCU_CONFIG_OFFSET] ; Read SCU Config reg to get CPU count
85 mrc p15, 1, r0, c9, c0, 2 ; Read C9 register of CP15 to get CPU count
91 // Add '1' to the number of CPU on the Cluster
98 //ArmPlatformIsPrimaryCore (
101 ArmPlatformIsPrimaryCore FUNCTION
102 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
105 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
114 //ArmPlatformGetCorePosition (
117 ArmPlatformGetCorePosition FUNCTION
118 and r1, r0, #ARM_CORE_MASK
119 and r0, r0, #ARM_CLUSTER_MASK
120 add r0, r1, r0, LSR #7