]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S
ArmPlatformPkg/ArmPlatformLib: Added support for ArmPlatformIsPrimaryCore()
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibCTA15-A7 / CTA15-A7Helper.S
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 <AsmMacroIoLib.h>
15 #include <Library/ArmLib.h>
16
17 #include <ArmPlatform.h>
18
19 .text
20 .align 3
21
22 GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
23 GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
24
25 //UINTN
26 //ArmPlatformGetCorePosition (
27 // IN UINTN MpId
28 // );
29 ASM_PFX(ArmPlatformGetCorePosition):
30 and r1, r0, #ARM_CORE_MASK
31 and r0, r0, #ARM_CLUSTER_MASK
32 add r0, r1, r0, LSR #7
33 bx lr
34
35 //UINTN
36 //ArmPlatformIsPrimaryCore (
37 // IN UINTN MpId
38 // );
39 ASM_PFX(ArmPlatformIsPrimaryCore):
40 // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
41 // with cpu_id[0:3] and cluster_id[4:7]
42 LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1)
43 ldr r1, [r1]
44 lsr r1, #24
45
46 // Shift the SCC value to get the cluster ID at the offset #8
47 lsl r2, r1, #4
48 and r2, r2, #0xF00
49
50 // Keep only the cpu ID from the original SCC
51 and r1, r1, #0x0F
52 // Add the Cluster ID to the Cpu ID
53 orr r1, r1, r2
54
55 // Keep the Cluster ID and Core ID from the MPID
56 LoadConstantToReg (ARM_CLUSTER_MASK | ARM_CORE_MASK, r2)
57 and r0, r0, r2
58
59 // Compare mpid and boot cpu from ARM_SCC_CFGREG48
60 cmp r0, r1
61 moveq r0, #1
62 movne r0, #0
63 bx lr
64