aboutsummaryrefslogtreecommitdiff
path: root/el3_payload/plat/juno/platform.S
blob: 6c8773b6617b14ca53c42b0ea9a1ce75aa39ab52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * Copyright (c) 2018, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "arch.h"
#include "asm_macros.S"

	.text
	.global platform_get_core_pos

	/* --------------------------------------------------------------------
	 * unsigned int get_core_pos(uint64_t mpidr);
	 *
	 * Helper function to calculate the core position from its MPID.
	 * Core positions must be consecutive, there must be no holes.
	 *
	 * MPID  -> core position:
	 * 0x100 -> 0
	 * 0x101 -> 1
	 * 0x102 -> 2
	 * 0x103 -> 3
	 *   0x0 -> 4
	 *   0x1 -> 5
	 * --------------------------------------------------------------------
	 */
func platform_get_core_pos
	and	x1, x0, #MPIDR_CPU_MASK
	and	x0, x0, #MPIDR_CLUSTER_MASK
	eor	x0, x0, #(1 << MPIDR_AFFINITY_BITS)  /* swap cluster order */
	add	x0, x1, x0, LSR #6
	ret
endfunc platform_get_core_pos