Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 21 | func 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 |
| 31 | endfunc 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 | */ |
| 38 | func 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 |
| 43 | 1: |
| 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 |
| 49 | endfunc plat_arm_calc_core_pos |