1// 2// Copyright (c) 2012-2013, ARM Limited. All rights reserved. 3// 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 8// 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. 11// 12// 13 14#include <Library/ArmLib.h> 15 16#include <ArmPlatform.h> 17 18 INCLUDE AsmMacroIoLib.inc 19 20 EXPORT ArmPlatformPeiBootAction 21 EXPORT ArmPlatformGetCorePosition 22 EXPORT ArmPlatformIsPrimaryCore 23 EXPORT ArmPlatformGetPrimaryCoreMpId 24 25 PRESERVE8 26 AREA CTA15A7Helper, CODE, READONLY 27 28ArmPlatformPeiBootAction FUNCTION 29 bx lr 30 ENDFUNC 31 32//UINTN 33//ArmPlatformGetCorePosition ( 34// IN UINTN MpId 35// ); 36ArmPlatformGetCorePosition FUNCTION 37 and r1, r0, #ARM_CORE_MASK 38 and r0, r0, #ARM_CLUSTER_MASK 39 add r0, r1, r0, LSR #7 40 bx lr 41 ENDFUNC 42 43//UINTN 44//ArmPlatformIsPrimaryCore ( 45// IN UINTN MpId 46// ); 47ArmPlatformIsPrimaryCore FUNCTION 48 // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48 49 // with cpu_id[0:3] and cluster_id[4:7] 50 mov32 r1, ARM_CTA15A7_SCC_CFGREG48 51 ldr r1, [r1] 52 lsr r1, #24 53 54 // Shift the SCC value to get the cluster ID at the offset #8 55 lsl r2, r1, #4 56 and r2, r2, #0xF00 57 58 // Keep only the cpu ID from the original SCC 59 and r1, r1, #0x0F 60 // Add the Cluster ID to the Cpu ID 61 orr r1, r1, r2 62 63 // Keep the Cluster ID and Core ID from the MPID 64 mov32 r2, ARM_CLUSTER_MASK :OR: ARM_CORE_MASK 65 and r0, r0, r2 66 67 // Compare mpid and boot cpu from ARM_SCC_CFGREG48 68 cmp r0, r1 69 moveq r0, #1 70 movne r0, #0 71 bx lr 72 ENDFUNC 73 74//UINTN 75//ArmPlatformGetPrimaryCoreMpId ( 76// VOID 77// ); 78ArmPlatformGetPrimaryCoreMpId FUNCTION 79 // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48 80 // with cpu_id[0:3] and cluster_id[4:7] 81 mov32 r0, ARM_CTA15A7_SCC_CFGREG48 82 ldr r0, [r0] 83 lsr r0, #24 84 85 // Shift the SCC value to get the cluster ID at the offset #8 86 lsl r1, r0, #4 87 and r1, r1, #0xF00 88 89 // Keep only the cpu ID from the original SCC 90 and r0, r0, #0x0F 91 // Add the Cluster ID to the Cpu ID 92 orr r0, r0, r1 93 bx lr 94 ENDFUNC 95 96 END 97