1/* SPDX-License-Identifier: BSD-2-Clause */ 2/* 3 * Copyright (c) 2015, Linaro Limited 4 * Copyright (c) 2019, Arm Limited. All rights reserved. 5 * Copyright (c) 2020, Marek Vasut 6 * Copyright (c) 2022, Huawei Technologies Co., Ltd 7 */ 8 9#include <asm.S> 10#include <arm.h> 11#include <arm64_macros.S> 12 13/* 14 * bit8~bit10: core index 15 * bit16~bit18: ccl index 16 * bit20~bit22: sccl index 17 * 96 cores: index = sccl * 24 + ccl * 4 + core 18 * 128 cores: index = sccl * 32 + ccl * 4 + core (now used) 19 */ 20 21FUNC get_core_pos_mpidr , : 22 lsr x1, x0, 8 23 and x2, x1, 0x7 24 25 lsr x1, x0, 16 26 and x3, x1, 0x7 27 28 lsr x1, x0, 20 29 and x4, x1, 0x7 30 31 mov x5, x4 32#if (CFG_TEE_CORE_NB_CORE == 96) 33 lsl x5, x5, 1 34 add x5, x5, x4 35 lsl x5, x5, 1 36#elif (CFG_TEE_CORE_NB_CORE == 128) 37 lsl x5, x5, 3 38#else 39 static_assert(0); 40#endif 41 add x5, x5, x3 42 lsl x5, x5, 2 43 add x5, x5, x2 44 45 mov x0, x5 46 47 ret 48END_FUNC get_core_pos_mpidr 49