3 * Copyright (c) 2013-2014, ARM Limited. All rights reserved.
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include <AsmMacroIoLibV8.h>
16 #include <Library/ArmLib.h>
21 GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
22 GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
23 GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
24 GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
26 GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
29 PrimaryCoreMpid: .word 0x0
32 // Return the core position from the value of its MpId register
34 // This function returns the core position from the position 0 in the processor.
35 // This function might be called from assembler before any stack is set.
37 // @return Return the core position
40 //ArmPlatformGetCorePosition (
43 // With this function: CorePos = (ClusterId * 2) + CoreId
44 ASM_PFX(ArmPlatformGetCorePosition):
45 and r1, r0, #ARM_CORE_MASK
46 and r0, r0, #ARM_CLUSTER_MASK
47 add r0, r1, r0, LSR #7
51 // Return the MpId of the primary core
53 // This function returns the MpId of the primary core.
54 // This function might be called from assembler before any stack is set.
56 // @return Return the MpId of the primary core
59 //ArmPlatformGetPrimaryCoreMpId (
62 ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
63 ldr r0, =PrimaryCoreMpid
68 // Return a non-zero value if the callee is the primary core
70 // This function returns a non-zero value if the callee is the primary core.
71 // The primary core is the core responsible to initialize the hardware and run UEFI.
72 // This function might be called from assembler before any stack is set.
74 // @return Return a non-zero value if the callee is the primary core.
77 //ArmPlatformIsPrimaryCore (
80 ASM_PFX(ArmPlatformIsPrimaryCore):
81 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
85 ldr r1, =PrimaryCoreMpid
94 // First platform specific function to be called in the PEI phase
96 // This function is actually the first function called by the PrePi
97 // or PrePeiCore modules. It allows to retrieve arguments passed to
98 // the UEFI firmware through the CPU registers.
100 ASM_PFX(ArmPlatformPeiBootAction):
101 // The trusted firmware passes the primary CPU MPID through r0 register.
102 // Save it in a variable.
103 ldr r1, =PrimaryCoreMpid