Andrew Thoelke | 8c28fe0 | 2014-06-02 11:40:35 +0100 | [diff] [blame] | 1 | /* |
Soby Mathew | 0d78607 | 2016-03-24 16:56:29 +0000 | [diff] [blame] | 2 | * Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved. |
Andrew Thoelke | 8c28fe0 | 2014-06-02 11:40:35 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Andrew Thoelke | 8c28fe0 | 2014-06-02 11:40:35 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <asm_macros.S> |
| 8 | #include <cpu_data.h> |
| 9 | |
| 10 | .globl init_cpu_data_ptr |
Andrew Thoelke | 8c28fe0 | 2014-06-02 11:40:35 +0100 | [diff] [blame] | 11 | .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 Mathew | 3700a92 | 2015-07-13 11:21:11 +0100 | [diff] [blame] | 19 | * 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 Thoelke | 8c28fe0 | 2014-06-02 11:40:35 +0100 | [diff] [blame] | 22 | * ----------------------------------------------------------------- |
| 23 | */ |
| 24 | func init_cpu_data_ptr |
| 25 | mov x10, x30 |
Soby Mathew | 3700a92 | 2015-07-13 11:21:11 +0100 | [diff] [blame] | 26 | bl plat_my_core_pos |
| 27 | bl _cpu_data_by_index |
Andrew Thoelke | 8c28fe0 | 2014-06-02 11:40:35 +0100 | [diff] [blame] | 28 | msr tpidr_el3, x0 |
| 29 | ret x10 |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 30 | endfunc init_cpu_data_ptr |
Andrew Thoelke | 8c28fe0 | 2014-06-02 11:40:35 +0100 | [diff] [blame] | 31 | |
Andrew Thoelke | 8c28fe0 | 2014-06-02 11:40:35 +0100 | [diff] [blame] | 32 | /* ----------------------------------------------------------------- |
| 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 | */ |
| 41 | func _cpu_data_by_index |
| 42 | adr x1, percpu_data |
| 43 | add x0, x1, x0, LSL #CPU_DATA_LOG2SIZE |
| 44 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 45 | endfunc _cpu_data_by_index |