morello_helper.S 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2020, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <asm_macros.S>
  8. #include <cpu_macros.S>
  9. #include <rainier.h>
  10. #include <platform_def.h>
  11. .globl plat_arm_calc_core_pos
  12. .globl plat_reset_handler
  13. /* -----------------------------------------------------
  14. * unsigned int plat_arm_calc_core_pos(u_register_t mpidr)
  15. *
  16. * Helper function to calculate the core position.
  17. * ((ChipId * MORELLO_MAX_CLUSTERS_PER_CHIP + ClusterId) *
  18. * MORELLO_MAX_CPUS_PER_CLUSTER * MORELLO_MAX_PE_PER_CPU) +
  19. * (CPUId * MORELLO_MAX_PE_PER_CPU) + ThreadId
  20. *
  21. * which can be simplified as:
  22. *
  23. * (((ChipId * MORELLO_MAX_CLUSTERS_PER_CHIP + ClusterId) *
  24. * MORELLO_MAX_CPUS_PER_CLUSTER + CPUId) * MORELLO_MAX_PE_PER_CPU) +
  25. * ThreadId
  26. * ------------------------------------------------------
  27. */
  28. func plat_arm_calc_core_pos
  29. mov x4, x0
  30. /*
  31. * The MT bit in MPIDR is always set for morello and the
  32. * affinity level 0 corresponds to thread affinity level.
  33. */
  34. /* Extract individual affinity fields from MPIDR */
  35. ubfx x0, x4, #MPIDR_AFF0_SHIFT, #MPIDR_AFFINITY_BITS
  36. ubfx x1, x4, #MPIDR_AFF1_SHIFT, #MPIDR_AFFINITY_BITS
  37. ubfx x2, x4, #MPIDR_AFF2_SHIFT, #MPIDR_AFFINITY_BITS
  38. ubfx x3, x4, #MPIDR_AFF3_SHIFT, #MPIDR_AFFINITY_BITS
  39. /* Compute linear position */
  40. mov x4, #MORELLO_MAX_CLUSTERS_PER_CHIP
  41. madd x2, x3, x4, x2
  42. mov x4, #MORELLO_MAX_CPUS_PER_CLUSTER
  43. madd x1, x2, x4, x1
  44. mov x4, #MORELLO_MAX_PE_PER_CPU
  45. madd x0, x1, x4, x0
  46. ret
  47. endfunc plat_arm_calc_core_pos