tsp.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef TSP_H
  7. #define TSP_H
  8. /*
  9. * SMC function IDs that TSP uses to signal various forms of completions
  10. * to the secure payload dispatcher.
  11. */
  12. #define TSP_ENTRY_DONE 0xf2000000
  13. #define TSP_ON_DONE 0xf2000001
  14. #define TSP_OFF_DONE 0xf2000002
  15. #define TSP_SUSPEND_DONE 0xf2000003
  16. #define TSP_RESUME_DONE 0xf2000004
  17. #define TSP_PREEMPTED 0xf2000005
  18. #define TSP_ABORT_DONE 0xf2000007
  19. #define TSP_SYSTEM_OFF_DONE 0xf2000008
  20. #define TSP_SYSTEM_RESET_DONE 0xf2000009
  21. /*
  22. * Function identifiers to handle S-EL1 interrupt through the synchronous
  23. * handling model. If the TSP was previously interrupted then control has to
  24. * be returned to the TSPD after handling the interrupt else execution can
  25. * remain in the TSP.
  26. */
  27. #define TSP_HANDLED_S_EL1_INTR 0xf2000006
  28. /* SMC function ID that TSP uses to request service from secure monitor */
  29. #define TSP_GET_ARGS 0xf2001000
  30. /*
  31. * Identifiers for various TSP services. Corresponding function IDs (whether
  32. * fast or yielding) are generated by macros defined below
  33. */
  34. #define TSP_ADD 0x2000
  35. #define TSP_SUB 0x2001
  36. #define TSP_MUL 0x2002
  37. #define TSP_DIV 0x2003
  38. #define TSP_HANDLE_SEL1_INTR_AND_RETURN 0x2004
  39. #define TSP_CHECK_DIT 0x2005
  40. #define TSP_MODIFY_EL1_CTX 0x2006
  41. /*
  42. * Identify a TSP service from function ID filtering the last 16 bits from the
  43. * SMC function ID
  44. */
  45. #define TSP_BARE_FID(fid) ((fid) & 0xffff)
  46. /*
  47. * Generate function IDs for TSP services to be used in SMC calls, by
  48. * appropriately setting bit 31 to differentiate yielding and fast SMC calls
  49. */
  50. #define TSP_YIELD_FID(fid) ((TSP_BARE_FID(fid) | 0x72000000))
  51. #define TSP_FAST_FID(fid) ((TSP_BARE_FID(fid) | 0x72000000) | (1u << 31))
  52. /* SMC function ID to request a previously preempted yielding smc */
  53. #define TSP_FID_RESUME TSP_YIELD_FID(0x3000)
  54. /*
  55. * SMC function ID to request abortion of a previously preempted yielding SMC. A
  56. * fast SMC is used so that the TSP abort handler does not have to be
  57. * reentrant.
  58. */
  59. #define TSP_FID_ABORT TSP_FAST_FID(0x3001)
  60. /*
  61. * Total number of function IDs implemented for services offered to NS clients.
  62. * The function IDs are defined above
  63. */
  64. #define TSP_NUM_FID 0x5
  65. /* TSP implementation version numbers */
  66. #define TSP_VERSION_MAJOR 0x0 /* Major version */
  67. #define TSP_VERSION_MINOR 0x1 /* Minor version */
  68. /*
  69. * Standard Trusted OS Function IDs that fall under Trusted OS call range
  70. * according to SMC calling convention
  71. */
  72. #define TOS_CALL_COUNT 0xbf00ff00 /* Number of calls implemented */
  73. #define TOS_UID 0xbf00ff01 /* Implementation UID */
  74. /* 0xbf00ff02 is reserved */
  75. #define TOS_CALL_VERSION 0xbf00ff03 /* Trusted OS Call Version */
  76. #ifndef __ASSEMBLER__
  77. #include <stdint.h>
  78. typedef uint32_t tsp_vector_isn_t;
  79. typedef struct tsp_vectors {
  80. tsp_vector_isn_t yield_smc_entry;
  81. tsp_vector_isn_t fast_smc_entry;
  82. tsp_vector_isn_t cpu_on_entry;
  83. tsp_vector_isn_t cpu_off_entry;
  84. tsp_vector_isn_t cpu_resume_entry;
  85. tsp_vector_isn_t cpu_suspend_entry;
  86. tsp_vector_isn_t sel1_intr_entry;
  87. tsp_vector_isn_t system_off_entry;
  88. tsp_vector_isn_t system_reset_entry;
  89. tsp_vector_isn_t abort_yield_smc_entry;
  90. } tsp_vectors_t;
  91. void tsp_setup(void);
  92. #endif /* __ASSEMBLER__ */
  93. #endif /* TSP_H */