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 <AsmMacroIoLib.h> 16#include <Library/ArmLib.h> 17 18// 19// Return the core position from the value of its MpId register 20// 21// This function returns the core position from the position 0 in the processor. 22// This function might be called from assembler before any stack is set. 23// 24// @return Return the core position 25// 26//UINTN 27//ArmPlatformGetCorePosition ( 28// IN UINTN MpId 29// ); 30// With this function: CorePos = (ClusterId * 2) + CoreId 31ASM_FUNC(ArmPlatformGetCorePosition) 32 and r1, r0, #ARM_CORE_MASK 33 and r0, r0, #ARM_CLUSTER_MASK 34 add r0, r1, r0, LSR #7 35 bx lr 36 37// 38// Return the MpId of the primary core 39// 40// This function returns the MpId of the primary core. 41// This function might be called from assembler before any stack is set. 42// 43// @return Return the MpId of the primary core 44// 45//UINTN 46//ArmPlatformGetPrimaryCoreMpId ( 47// VOID 48// ); 49ASM_FUNC(ArmPlatformGetPrimaryCoreMpId) 50 LDRL (r0, PrimaryCoreMpid) 51 bx lr 52 53// 54// Return a non-zero value if the callee is the primary core 55// 56// This function returns a non-zero value if the callee is the primary core. 57// The primary core is the core responsible to initialize the hardware and run UEFI. 58// This function might be called from assembler before any stack is set. 59// 60// @return Return a non-zero value if the callee is the primary core. 61// 62//UINTN 63//ArmPlatformIsPrimaryCore ( 64// IN UINTN MpId 65// ); 66ASM_FUNC(ArmPlatformIsPrimaryCore) 67 MOV32 (r1, FixedPcdGet32 (PcdArmPrimaryCoreMask)) 68 and r0, r0, r1 69 70 LDRL (r1, PrimaryCoreMpid) 71 72 cmp r0, r1 73 moveq r0, #1 74 movne r0, #0 75 bx lr 76 77// 78// First platform specific function to be called in the PEI phase 79// 80// This function is actually the first function called by the PrePi 81// or PrePeiCore modules. It allows to retrieve arguments passed to 82// the UEFI firmware through the CPU registers. 83// 84ASM_FUNC(ArmPlatformPeiBootAction) 85 // The trusted firmware passes the primary CPU MPID through r0 register. 86 // Save it in a variable. 87 adr r1, PrimaryCoreMpid 88 str r0, [r1] 89 bx lr 90 91PrimaryCoreMpid: .word 0x0 92