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> |
| 8 | #include <cpu_data.h> |
| 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 |
| 37 | ldr r1, =percpu_data |
| 38 | add r0, r1, r0, LSL #CPU_DATA_LOG2SIZE |
| 39 | bx lr |
| 40 | endfunc _cpu_data_by_index |