]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm
ArmPlatformPkg/ArmPlatformLib: Added support for ArmPlatformIsPrimaryCore()
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibCTA15-A7 / CTA15-A7Helper.asm
CommitLineData
295c2eb8 1//\r
bebda7ce 2// Copyright (c) 2012-2013, ARM Limited. All rights reserved.\r
295c2eb8 3//\r
4// This program and the accompanying materials\r
5// are licensed and made available under the terms and conditions of the BSD License\r
6// which accompanies this distribution. The full text of the license may be found at\r
7// http://opensource.org/licenses/bsd-license.php\r
8//\r
9// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11//\r
12//\r
13\r
bebda7ce 14#include <AsmMacroIoLib.h>\r
295c2eb8 15#include <Library/ArmLib.h>\r
16\r
bebda7ce 17#include <ArmPlatform.h>\r
18\r
295c2eb8 19 INCLUDE AsmMacroIoLib.inc\r
20\r
21 EXPORT ArmPlatformGetCorePosition\r
bebda7ce 22 EXPORT ArmPlatformIsPrimaryCore\r
295c2eb8 23\r
24 PRESERVE8\r
25 AREA CTA15A7Helper, CODE, READONLY\r
26\r
27//UINTN\r
28//ArmPlatformGetCorePosition (\r
29// IN UINTN MpId\r
30// );\r
31ArmPlatformGetCorePosition FUNCTION\r
32 and r1, r0, #ARM_CORE_MASK\r
33 and r0, r0, #ARM_CLUSTER_MASK\r
34 add r0, r1, r0, LSR #7\r
35 bx lr\r
36 ENDFUNC\r
37\r
bebda7ce 38//UINTN\r
39//ArmPlatformIsPrimaryCore (\r
40// IN UINTN MpId\r
41// );\r
42ArmPlatformIsPrimaryCore FUNCTION\r
43 // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48\r
44 // with cpu_id[0:3] and cluster_id[4:7]\r
45 LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1)\r
46 ldr r1, [r1]\r
47 lsr r1, #24\r
48\r
49 // Shift the SCC value to get the cluster ID at the offset #8\r
50 lsl r2, r1, #4\r
51 and r2, r2, #0xF00\r
52\r
53 // Keep only the cpu ID from the original SCC\r
54 and r1, r1, #0x0F\r
55 // Add the Cluster ID to the Cpu ID\r
56 orr r1, r1, r2\r
57\r
58 // Keep the Cluster ID and Core ID from the MPID\r
59 LoadConstantToReg (ARM_CLUSTER_MASK | ARM_CORE_MASK, r2)\r
60 and r0, r0, r2\r
61\r
62 // Compare mpid and boot cpu from ARM_SCC_CFGREG48\r
63 cmp r0, r1\r
64 moveq r0, #1\r
65 movne r0, #0\r
66 bx lr\r
67 ENDFUNC\r
68\r
295c2eb8 69 END\r