cpu_data.S 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2014-2020, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <asm_macros.S>
  7. #include <lib/el3_runtime/cpu_data.h>
  8. .globl init_cpu_data_ptr
  9. .globl _cpu_data_by_index
  10. /* -----------------------------------------------------------------
  11. * void init_cpu_data_ptr(void)
  12. *
  13. * Initialise the TPIDR_EL3 register to refer to the cpu_data_t
  14. * for the calling CPU. This must be called before cm_get_cpu_data()
  15. *
  16. * This can be called without a valid stack. It assumes that
  17. * plat_my_core_pos() does not clobber register x10.
  18. * clobbers: x0, x1, x10
  19. * -----------------------------------------------------------------
  20. */
  21. func init_cpu_data_ptr
  22. mov x10, x30
  23. bl plat_my_core_pos
  24. bl _cpu_data_by_index
  25. msr tpidr_el3, x0
  26. ret x10
  27. endfunc init_cpu_data_ptr
  28. /* -----------------------------------------------------------------
  29. * cpu_data_t *_cpu_data_by_index(uint32_t cpu_index)
  30. *
  31. * Return the cpu_data structure for the CPU with given linear index
  32. *
  33. * This can be called without a valid stack.
  34. * clobbers: x0, x1
  35. * -----------------------------------------------------------------
  36. */
  37. func _cpu_data_by_index
  38. mov_imm x1, CPU_DATA_SIZE
  39. mul x0, x0, x1
  40. adrp x1, percpu_data
  41. add x1, x1, :lo12:percpu_data
  42. add x0, x0, x1
  43. ret
  44. endfunc _cpu_data_by_index