Soby Mathew | 748be1d | 2016-05-05 14:10:46 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Soby Mathew | 748be1d | 2016-05-05 14:10:46 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <asm_macros.S> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | #include <lib/el3_runtime/cpu_data.h> |
Soby Mathew | 748be1d | 2016-05-05 14:10:46 +0100 | [diff] [blame] | 9 | |
| 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 | */ |
| 19 | func _cpu_data |
Soby Mathew | adb7027 | 2016-12-06 12:10:51 +0000 | [diff] [blame] | 20 | /* r12 is pushed to meet the 8 byte stack alignment requirement */ |
| 21 | push {r12, lr} |
Soby Mathew | 748be1d | 2016-05-05 14:10:46 +0100 | [diff] [blame] | 22 | bl plat_my_core_pos |
Soby Mathew | adb7027 | 2016-12-06 12:10:51 +0000 | [diff] [blame] | 23 | pop {r12, lr} |
Soby Mathew | 748be1d | 2016-05-05 14:10:46 +0100 | [diff] [blame] | 24 | b _cpu_data_by_index |
| 25 | endfunc _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 | */ |
| 36 | func _cpu_data_by_index |
Etienne Carriere | 97ad6ce | 2017-09-01 10:22:20 +0200 | [diff] [blame] | 37 | mov_imm r1, CPU_DATA_SIZE |
| 38 | mul r0, r0, r1 |
Soby Mathew | 748be1d | 2016-05-05 14:10:46 +0100 | [diff] [blame] | 39 | ldr r1, =percpu_data |
Etienne Carriere | 97ad6ce | 2017-09-01 10:22:20 +0200 | [diff] [blame] | 40 | add r0, r0, r1 |
Soby Mathew | 748be1d | 2016-05-05 14:10:46 +0100 | [diff] [blame] | 41 | bx lr |
| 42 | endfunc _cpu_data_by_index |