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 "AsmMacroIoLib.inc"
21 #include <Chipset/ArmCortexA9.h>
26 GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
27 GCC_ASM_EXPORT(ArmGetCpuCountPerCluster)
28 GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
29 GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
30 GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
32 GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
33 GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
35 ASM_PFX(ArmPlatformPeiBootAction):
39 # OUT r0 = SCU Base Address
40 ASM_PFX(ArmGetScuBaseAddress):
41 # Read Configuration Base Address Register. ArmCBar cannot be called to get
42 # the Configuration BAR as a stack is not necessary setup. The SCU is at the
43 # offset 0x0000 from the Private Memory Region.
44 mrc p15, 4, r0, c15, c0, 0
48 //ArmPlatformGetPrimaryCoreMpId (
51 ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
52 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)
57 # OUT r0 = number of cores present in the system
58 ASM_PFX(ArmGetCpuCountPerCluster):
62 mrc p15, 0, r1, c0, c0, 0
64 # Check if the CPU is A15
66 LoadConstantToReg (ARM_CPU_TYPE_MASK, r0)
69 LoadConstantToReg (ARM_CPU_TYPE_A15, r0)
74 mov r2, lr @ Save link register
75 bl ArmGetScuBaseAddress @ Read SCU Base Address
76 mov lr, r2 @ Restore link register val
77 ldr r0, [r0, #A9_SCU_CONFIG_OFFSET] @ Read SCU Config reg to get CPU count
81 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
92 //ArmPlatformIsPrimaryCore (
95 ASM_PFX(ArmPlatformIsPrimaryCore):
96 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
99 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
107 //ArmPlatformGetCorePosition (
110 ASM_PFX(ArmPlatformGetCorePosition):
111 and r1, r0, #ARM_CORE_MASK
112 and r0, r0, #ARM_CLUSTER_MASK
113 add r0, r1, r0, LSR #7
116 ASM_FUNCTION_REMOVE_IF_UNREFERENCED