blob: c435d8b41796fccd9c4d366e7f68f3101ce88592 [file] [log] [blame]
Nariman Poushin0ece80f2018-02-26 06:52:04 +00001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <platform_def.h>
10
11 .globl plat_is_my_cpu_primary
12 .globl plat_arm_calc_core_pos
13
14 /* -----------------------------------------------------
15 * unsigned int plat_is_my_cpu_primary (void);
16 *
17 * Find out whether the current cpu is the primary
18 * cpu (applicable only after a cold boot)
19 * -----------------------------------------------------
20 */
21func plat_is_my_cpu_primary
22 mov x9, x30
23 bl plat_my_core_pos
24 ldr x1, =SGI_BOOT_CFG_ADDR
25 ldr x1, [x1]
26 ubfx x1, x1, #PLAT_CSS_PRIMARY_CPU_SHIFT, \
27 #PLAT_CSS_PRIMARY_CPU_BIT_WIDTH
28 cmp x0, x1
29 cset w0, eq
30 ret x9
31endfunc plat_is_my_cpu_primary
32
33 /* -----------------------------------------------------
34 * unsigned int plat_arm_calc_core_pos(uint64_t mpidr)
35 * Helper function to calculate the core position.
36 * -----------------------------------------------------
37 */
38func plat_arm_calc_core_pos
39 mrs x2, mpidr_el1
40 ands x2, x2, #MPIDR_MT_MASK
41 beq 1f
42 lsr x0, x0, #MPIDR_AFF1_SHIFT
431:
44 and x1, x0, #MPIDR_CPU_MASK
45 and x0, x0, #MPIDR_CLUSTER_MASK
46 add x0, x1, x0, LSR #6
47 and x0, x0, #MPIDR_AFFLVL_MASK
48 ret
49endfunc plat_arm_calc_core_pos