blob: bdad2c145aa9d4bed7072c3cd033a7ad08d16698 [file] [log] [blame]
Soby Mathew748be1d2016-05-05 14:10:46 +01001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soby Mathew748be1d2016-05-05 14:10:46 +01005 */
6
7#include <asm_macros.S>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <lib/el3_runtime/cpu_data.h>
Soby Mathew748be1d2016-05-05 14:10:46 +01009
10 .globl _cpu_data
11 .globl _cpu_data_by_index
12
13/* -----------------------------------------------------------------
14 * cpu_data_t *_cpu_data(void)
15 *
16 * Return the cpu_data structure for the current CPU.
17 * -----------------------------------------------------------------
18 */
19func _cpu_data
Soby Mathewadb70272016-12-06 12:10:51 +000020 /* r12 is pushed to meet the 8 byte stack alignment requirement */
21 push {r12, lr}
Soby Mathew748be1d2016-05-05 14:10:46 +010022 bl plat_my_core_pos
Soby Mathewadb70272016-12-06 12:10:51 +000023 pop {r12, lr}
Soby Mathew748be1d2016-05-05 14:10:46 +010024 b _cpu_data_by_index
25endfunc _cpu_data
26
27/* -----------------------------------------------------------------
28 * cpu_data_t *_cpu_data_by_index(uint32_t cpu_index)
29 *
30 * Return the cpu_data structure for the CPU with given linear index
31 *
32 * This can be called without a valid stack.
33 * clobbers: r0, r1
34 * -----------------------------------------------------------------
35 */
36func _cpu_data_by_index
Etienne Carriere97ad6ce2017-09-01 10:22:20 +020037 mov_imm r1, CPU_DATA_SIZE
38 mul r0, r0, r1
Soby Mathew748be1d2016-05-05 14:10:46 +010039 ldr r1, =percpu_data
Etienne Carriere97ad6ce2017-09-01 10:22:20 +020040 add r0, r0, r1
Soby Mathew748be1d2016-05-05 14:10:46 +010041 bx lr
42endfunc _cpu_data_by_index