]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm
1b5474b5f243db20caf0e1310417cbb0d5345b19
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibCTA15-A7 / CTA15-A7Helper.asm
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 INCLUDE AsmMacroIoLib.inc
20
21 EXPORT ArmPlatformGetCorePosition
22 EXPORT ArmPlatformIsPrimaryCore
23
24 PRESERVE8
25 AREA CTA15A7Helper, CODE, READONLY
26
27 //UINTN
28 //ArmPlatformGetCorePosition (
29 // IN UINTN MpId
30 // );
31 ArmPlatformGetCorePosition FUNCTION
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 ENDFUNC
37
38 //UINTN
39 //ArmPlatformIsPrimaryCore (
40 // IN UINTN MpId
41 // );
42 ArmPlatformIsPrimaryCore FUNCTION
43 // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
44 // with cpu_id[0:3] and cluster_id[4:7]
45 LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1)
46 ldr r1, [r1]
47 lsr r1, #24
48
49 // Shift the SCC value to get the cluster ID at the offset #8
50 lsl r2, r1, #4
51 and r2, r2, #0xF00
52
53 // Keep only the cpu ID from the original SCC
54 and r1, r1, #0x0F
55 // Add the Cluster ID to the Cpu ID
56 orr r1, r1, r2
57
58 // Keep the Cluster ID and Core ID from the MPID
59 LoadConstantToReg (ARM_CLUSTER_MASK | ARM_CORE_MASK, r2)
60 and r0, r0, r2
61
62 // Compare mpid and boot cpu from ARM_SCC_CFGREG48
63 cmp r0, r1
64 moveq r0, #1
65 movne r0, #0
66 bx lr
67 ENDFUNC
68
69 END