blob: 2edf2255963ba6e98a876e82c5d52217176312cb [file] [log] [blame]
Andrew Thoelke8c28fe02014-06-02 11:40:35 +01001/*
Soby Mathew0d786072016-03-24 16:56:29 +00002 * Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
Andrew Thoelke8c28fe02014-06-02 11:40:35 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Andrew Thoelke8c28fe02014-06-02 11:40:35 +01005 */
6
7#include <asm_macros.S>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <lib/el3_runtime/cpu_data.h>
Andrew Thoelke8c28fe02014-06-02 11:40:35 +01009
10.globl init_cpu_data_ptr
Andrew Thoelke8c28fe02014-06-02 11:40:35 +010011.globl _cpu_data_by_index
12
13/* -----------------------------------------------------------------
14 * void init_cpu_data_ptr(void)
15 *
16 * Initialise the TPIDR_EL3 register to refer to the cpu_data_t
17 * for the calling CPU. This must be called before cm_get_cpu_data()
18 *
Soby Mathew3700a922015-07-13 11:21:11 +010019 * This can be called without a valid stack. It assumes that
20 * plat_my_core_pos() does not clobber register x10.
21 * clobbers: x0, x1, x10
Andrew Thoelke8c28fe02014-06-02 11:40:35 +010022 * -----------------------------------------------------------------
23 */
24func init_cpu_data_ptr
25 mov x10, x30
Soby Mathew3700a922015-07-13 11:21:11 +010026 bl plat_my_core_pos
27 bl _cpu_data_by_index
Andrew Thoelke8c28fe02014-06-02 11:40:35 +010028 msr tpidr_el3, x0
29 ret x10
Kévin Petita877c252015-03-24 14:03:57 +000030endfunc init_cpu_data_ptr
Andrew Thoelke8c28fe02014-06-02 11:40:35 +010031
Andrew Thoelke8c28fe02014-06-02 11:40:35 +010032/* -----------------------------------------------------------------
33 * cpu_data_t *_cpu_data_by_index(uint32_t cpu_index)
34 *
35 * Return the cpu_data structure for the CPU with given linear index
36 *
37 * This can be called without a valid stack.
38 * clobbers: x0, x1
39 * -----------------------------------------------------------------
40 */
41func _cpu_data_by_index
Etienne Carriere97ad6ce2017-09-01 10:22:20 +020042 mov_imm x1, CPU_DATA_SIZE
43 mul x0, x0, x1
Andrew Thoelke8c28fe02014-06-02 11:40:35 +010044 adr x1, percpu_data
Etienne Carriere97ad6ce2017-09-01 10:22:20 +020045 add x0, x0, x1
Andrew Thoelke8c28fe02014-06-02 11:40:35 +010046 ret
Kévin Petita877c252015-03-24 14:03:57 +000047endfunc _cpu_data_by_index