1/** @file 2* 3* Copyright (c) 2013-2014, ARM Limited. All rights reserved. 4* 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 9* 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. 12* 13**/ 14 15#include <AsmMacroIoLibV8.h> 16#include <Library/ArmLib.h> 17 18.text 19.align 3 20 21GCC_ASM_EXPORT(ArmPlatformPeiBootAction) 22GCC_ASM_EXPORT(ArmPlatformGetCorePosition) 23GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId) 24GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore) 25 26GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask) 27 28 29PrimaryCoreMpid: .word 0x0 30 31//UINTN 32//ArmPlatformGetCorePosition ( 33// IN UINTN MpId 34// ); 35// With this function: CorePos = (ClusterId * 2) + CoreId 36ASM_PFX(ArmPlatformGetCorePosition): 37 and x1, x0, #ARM_CORE_MASK 38 and x0, x0, #ARM_CLUSTER_MASK 39 add x0, x1, x0, LSR #7 40 ret 41 42//UINTN 43//ArmPlatformGetPrimaryCoreMpId ( 44// VOID 45// ); 46ASM_PFX(ArmPlatformGetPrimaryCoreMpId): 47 ldr x0, =PrimaryCoreMpid 48 ldrh w0, [x0] 49 ret 50 51//UINTN 52//ArmPlatformIsPrimaryCore ( 53// IN UINTN MpId 54// ); 55ASM_PFX(ArmPlatformIsPrimaryCore): 56 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, x1) 57 ldrh w1, [x1] 58 and x0, x0, x1 59 60 ldr x1, =PrimaryCoreMpid 61 ldrh w1, [x1] 62 63 cmp w0, w1 64 mov x0, #1 65 mov x1, #0 66 csel x0, x0, x1, eq 67 ret 68 69ASM_PFX(ArmPlatformPeiBootAction): 70 // The trusted firmware passes the primary CPU MPID through x0 register. 71 // Save it in a variable. 72 ldr x1, =PrimaryCoreMpid 73 str w0, [x1] 74 ret 75 76