tsp_private.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Copyright (c) 2014-2022, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef TSP_PRIVATE_H
  7. #define TSP_PRIVATE_H
  8. /*******************************************************************************
  9. * The TSP memory footprint starts at address BL32_BASE and ends with the
  10. * linker symbol __BL32_END__. Use these addresses to compute the TSP image
  11. * size.
  12. ******************************************************************************/
  13. #define BL32_TOTAL_LIMIT BL32_END
  14. #define BL32_TOTAL_SIZE (BL32_TOTAL_LIMIT - (unsigned long) BL32_BASE)
  15. #ifndef __ASSEMBLER__
  16. #include <stdint.h>
  17. #include <bl32/tsp/tsp.h>
  18. #include <lib/cassert.h>
  19. #include <lib/spinlock.h>
  20. #include <smccc_helpers.h>
  21. typedef struct work_statistics {
  22. /* Number of s-el1 interrupts on this cpu */
  23. uint32_t sel1_intr_count;
  24. /* Number of non s-el1 interrupts on this cpu which preempted TSP */
  25. uint32_t preempt_intr_count;
  26. /* Number of sync s-el1 interrupts on this cpu */
  27. uint32_t sync_sel1_intr_count;
  28. /* Number of s-el1 interrupts returns on this cpu */
  29. uint32_t sync_sel1_intr_ret_count;
  30. uint32_t smc_count; /* Number of returns on this cpu */
  31. uint32_t eret_count; /* Number of entries on this cpu */
  32. uint32_t cpu_on_count; /* Number of cpu on requests */
  33. uint32_t cpu_off_count; /* Number of cpu off requests */
  34. uint32_t cpu_suspend_count; /* Number of cpu suspend requests */
  35. uint32_t cpu_resume_count; /* Number of cpu resume requests */
  36. } __aligned(CACHE_WRITEBACK_GRANULE) work_statistics_t;
  37. /* Macros to access members of the above structure using their offsets */
  38. #define read_sp_arg(args, offset) ((args)->_regs[offset >> 3])
  39. #define write_sp_arg(args, offset, val) (((args)->_regs[offset >> 3]) \
  40. = val)
  41. uint128_t tsp_get_magic(void);
  42. smc_args_t *set_smc_args(uint64_t arg0,
  43. uint64_t arg1,
  44. uint64_t arg2,
  45. uint64_t arg3,
  46. uint64_t arg4,
  47. uint64_t arg5,
  48. uint64_t arg6,
  49. uint64_t arg7);
  50. smc_args_t *tsp_cpu_resume_main(uint64_t max_off_pwrlvl,
  51. uint64_t arg1,
  52. uint64_t arg2,
  53. uint64_t arg3,
  54. uint64_t arg4,
  55. uint64_t arg5,
  56. uint64_t arg6,
  57. uint64_t arg7);
  58. smc_args_t *tsp_cpu_suspend_main(uint64_t arg0,
  59. uint64_t arg1,
  60. uint64_t arg2,
  61. uint64_t arg3,
  62. uint64_t arg4,
  63. uint64_t arg5,
  64. uint64_t arg6,
  65. uint64_t arg7);
  66. smc_args_t *tsp_cpu_on_main(void);
  67. smc_args_t *tsp_cpu_off_main(uint64_t arg0,
  68. uint64_t arg1,
  69. uint64_t arg2,
  70. uint64_t arg3,
  71. uint64_t arg4,
  72. uint64_t arg5,
  73. uint64_t arg6,
  74. uint64_t arg7);
  75. /* Generic Timer functions */
  76. void tsp_generic_timer_start(void);
  77. void tsp_generic_timer_handler(void);
  78. void tsp_generic_timer_stop(void);
  79. void tsp_generic_timer_save(void);
  80. void tsp_generic_timer_restore(void);
  81. /* S-EL1 interrupt management functions */
  82. void tsp_update_sync_sel1_intr_stats(uint32_t type, uint64_t elr_el3);
  83. /* Data structure to keep track of TSP statistics */
  84. extern work_statistics_t tsp_stats[PLATFORM_CORE_COUNT];
  85. /* Vector table of jumps */
  86. extern tsp_vectors_t tsp_vector_table;
  87. /* functions */
  88. int32_t tsp_common_int_handler(void);
  89. int32_t tsp_handle_preemption(void);
  90. smc_args_t *tsp_abort_smc_handler(uint64_t func,
  91. uint64_t arg1,
  92. uint64_t arg2,
  93. uint64_t arg3,
  94. uint64_t arg4,
  95. uint64_t arg5,
  96. uint64_t arg6,
  97. uint64_t arg7);
  98. smc_args_t *tsp_smc_handler(uint64_t func,
  99. uint64_t arg1,
  100. uint64_t arg2,
  101. uint64_t arg3,
  102. uint64_t arg4,
  103. uint64_t arg5,
  104. uint64_t arg6,
  105. uint64_t arg7);
  106. smc_args_t *tsp_system_reset_main(uint64_t arg0,
  107. uint64_t arg1,
  108. uint64_t arg2,
  109. uint64_t arg3,
  110. uint64_t arg4,
  111. uint64_t arg5,
  112. uint64_t arg6,
  113. uint64_t arg7);
  114. smc_args_t *tsp_system_off_main(uint64_t arg0,
  115. uint64_t arg1,
  116. uint64_t arg2,
  117. uint64_t arg3,
  118. uint64_t arg4,
  119. uint64_t arg5,
  120. uint64_t arg6,
  121. uint64_t arg7);
  122. uint64_t tsp_main(void);
  123. #endif /* __ASSEMBLER__ */
  124. #endif /* TSP_PRIVATE_H */