xref: /optee_os/core/arch/arm/kernel/misc_a64.S (revision 78b7c7c7653f8bff42fe44d31a79d7f6bbfd4d47)
1/* SPDX-License-Identifier: BSD-2-Clause */
2/*
3 * Copyright (c) 2015, Linaro Limited
4 * All rights reserved.
5 */
6
7#include <asm.S>
8#include <arm.h>
9#include <platform_config.h>
10
11/* Let platforms override this if needed */
12.weak get_core_pos_mpidr
13
14/* size_t get_core_pos(void); */
15FUNC get_core_pos , :
16	mrs	x0, mpidr_el1
17	b get_core_pos_mpidr
18END_FUNC get_core_pos
19
20/* size_t get_core_pos_mpidr(uint32_t mpidr); */
21FUNC get_core_pos_mpidr , :
22	/* Calculate CorePos = (ClusterId * (cores/cluster)) + CoreId */
23	and	x1, x0, #MPIDR_CPU_MASK
24	and	x0, x0, #MPIDR_CLUSTER_MASK
25	add	x0, x1, x0, LSR #(MPIDR_CLUSTER_SHIFT - CFG_CORE_CLUSTER_SHIFT)
26	ret
27END_FUNC get_core_pos_mpidr
28