tsp.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (c) 2013-2022, 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. /*
  41. * Identify a TSP service from function ID filtering the last 16 bits from the
  42. * SMC function ID
  43. */
  44. #define TSP_BARE_FID(fid) ((fid) & 0xffff)
  45. /*
  46. * Generate function IDs for TSP services to be used in SMC calls, by
  47. * appropriately setting bit 31 to differentiate yielding and fast SMC calls
  48. */
  49. #define TSP_YIELD_FID(fid) ((TSP_BARE_FID(fid) | 0x72000000))
  50. #define TSP_FAST_FID(fid) ((TSP_BARE_FID(fid) | 0x72000000) | (1u << 31))
  51. /* SMC function ID to request a previously preempted yielding smc */
  52. #define TSP_FID_RESUME TSP_YIELD_FID(0x3000)
  53. /*
  54. * SMC function ID to request abortion of a previously preempted yielding SMC. A
  55. * fast SMC is used so that the TSP abort handler does not have to be
  56. * reentrant.
  57. */
  58. #define TSP_FID_ABORT TSP_FAST_FID(0x3001)
  59. /*
  60. * Total number of function IDs implemented for services offered to NS clients.
  61. * The function IDs are defined above
  62. */
  63. #define TSP_NUM_FID 0x5
  64. /* TSP implementation version numbers */
  65. #define TSP_VERSION_MAJOR 0x0 /* Major version */
  66. #define TSP_VERSION_MINOR 0x1 /* Minor version */
  67. /*
  68. * Standard Trusted OS Function IDs that fall under Trusted OS call range
  69. * according to SMC calling convention
  70. */
  71. #define TOS_CALL_COUNT 0xbf00ff00 /* Number of calls implemented */
  72. #define TOS_UID 0xbf00ff01 /* Implementation UID */
  73. /* 0xbf00ff02 is reserved */
  74. #define TOS_CALL_VERSION 0xbf00ff03 /* Trusted OS Call Version */
  75. #ifndef __ASSEMBLER__
  76. #include <stdint.h>
  77. typedef uint32_t tsp_vector_isn_t;
  78. typedef struct tsp_vectors {
  79. tsp_vector_isn_t yield_smc_entry;
  80. tsp_vector_isn_t fast_smc_entry;
  81. tsp_vector_isn_t cpu_on_entry;
  82. tsp_vector_isn_t cpu_off_entry;
  83. tsp_vector_isn_t cpu_resume_entry;
  84. tsp_vector_isn_t cpu_suspend_entry;
  85. tsp_vector_isn_t sel1_intr_entry;
  86. tsp_vector_isn_t system_off_entry;
  87. tsp_vector_isn_t system_reset_entry;
  88. tsp_vector_isn_t abort_yield_smc_entry;
  89. } tsp_vectors_t;
  90. void tsp_setup(void);
  91. #endif /* __ASSEMBLER__ */
  92. #endif /* TSP_H */