teesmc_opteed.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright (c) 2014-2023, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. /* Copyright (c) 2014, Linaro Limited. All rights reserved. */
  7. #ifndef TEESMC_OPTEED_H
  8. #define TEESMC_OPTEED_H
  9. #include "teesmc_opteed_macros.h"
  10. /*
  11. * This section specifies SMC function IDs used when returning from TEE to the
  12. * secure monitor.
  13. *
  14. * All SMC Function IDs indicates SMC32 Calling Convention but will carry
  15. * full 64 bit values in the argument registers if invoked from Aarch64
  16. * mode. This violates the SMC Calling Convention, but since this
  17. * convention only coveres API towards Normal World it's something that
  18. * only concerns the OP-TEE Dispatcher in Trusted Firmware-A and OP-TEE
  19. * OS at Secure EL1.
  20. */
  21. /*
  22. * Issued when returning from initial entry.
  23. *
  24. * Register usage:
  25. * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_ENTRY_DONE
  26. * r1/x1 Pointer to entry vector
  27. */
  28. #define TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE 0
  29. #define TEESMC_OPTEED_RETURN_ENTRY_DONE \
  30. TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE)
  31. /*
  32. * Issued when returning from "cpu_on" vector
  33. *
  34. * Register usage:
  35. * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_ON_DONE
  36. * r1/x1 0 on success and anything else to indicate error condition
  37. */
  38. #define TEESMC_OPTEED_FUNCID_RETURN_ON_DONE 1
  39. #define TEESMC_OPTEED_RETURN_ON_DONE \
  40. TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ON_DONE)
  41. /*
  42. * Issued when returning from "cpu_off" vector
  43. *
  44. * Register usage:
  45. * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_OFF_DONE
  46. * r1/x1 0 on success and anything else to indicate error condition
  47. */
  48. #define TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE 2
  49. #define TEESMC_OPTEED_RETURN_OFF_DONE \
  50. TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE)
  51. /*
  52. * Issued when returning from "cpu_suspend" vector
  53. *
  54. * Register usage:
  55. * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SUSPEND_DONE
  56. * r1/x1 0 on success and anything else to indicate error condition
  57. */
  58. #define TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE 3
  59. #define TEESMC_OPTEED_RETURN_SUSPEND_DONE \
  60. TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE)
  61. /*
  62. * Issued when returning from "cpu_resume" vector
  63. *
  64. * Register usage:
  65. * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_RESUME_DONE
  66. * r1/x1 0 on success and anything else to indicate error condition
  67. */
  68. #define TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE 4
  69. #define TEESMC_OPTEED_RETURN_RESUME_DONE \
  70. TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE)
  71. /*
  72. * Issued when returning from "std_smc" or "fast_smc" vector
  73. *
  74. * Register usage:
  75. * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_CALL_DONE
  76. * r1-4/x1-4 Return value 0-3 which will passed to normal world in
  77. * r0-3/x0-3
  78. */
  79. #define TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE 5
  80. #define TEESMC_OPTEED_RETURN_CALL_DONE \
  81. TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE)
  82. /*
  83. * Issued when returning from "fiq" vector
  84. *
  85. * Register usage:
  86. * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_FIQ_DONE
  87. */
  88. #define TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE 6
  89. #define TEESMC_OPTEED_RETURN_FIQ_DONE \
  90. TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE)
  91. /*
  92. * Issued when returning from "system_off" vector
  93. *
  94. * Register usage:
  95. * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE
  96. */
  97. #define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE 7
  98. #define TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE \
  99. TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE)
  100. /*
  101. * Issued when returning from "system_reset" vector
  102. *
  103. * Register usage:
  104. * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE
  105. */
  106. #define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE 8
  107. #define TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE \
  108. TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE)
  109. /*
  110. * This section specifies SMC function IDs used when the secure monitor is
  111. * invoked from the non-secure world.
  112. */
  113. /*
  114. * Load OP-TEE image from the payload specified in the registers.
  115. *
  116. * WARNING: Use this cautiously as it could lead to insecure loading of the
  117. * Trusted OS. Further details are in opteed.mk.
  118. *
  119. * Call register usage:
  120. * x0 SMC Function ID, OPTEE_SMC_CALL_LOAD_IMAGE
  121. * x1 Upper 32bit of a 64bit size for the payload
  122. * x2 Lower 32bit of a 64bit size for the payload
  123. * x3 Upper 32bit of the physical address for the payload
  124. * x4 Lower 32bit of the physical address for the payload
  125. *
  126. * The payload consists of a optee_header struct that contains optee_image
  127. * structs in a flex array, immediately following that in memory is the data
  128. * referenced by the optee_image structs.
  129. * Example:
  130. *
  131. * struct optee_header (with n images specified)
  132. * image 0 data
  133. * image 1 data
  134. * ...
  135. * image n-1 data
  136. *
  137. * Returns 0 on success and an error code otherwise.
  138. */
  139. #define NSSMC_OPTEED_FUNCID_LOAD_IMAGE 2
  140. #define NSSMC_OPTEED_CALL_LOAD_IMAGE \
  141. NSSMC_OPTEED_CALL(NSSMC_OPTEED_FUNCID_LOAD_IMAGE)
  142. /*
  143. * Returns the UID of the OP-TEE image loading service if image loading is
  144. * enabled and the image had not been loaded yet. Otherwise this call will be
  145. * passed through to OP-TEE where it will return the OP-TEE UID.
  146. */
  147. #define NSSMC_OPTEED_FUNCID_CALLS_UID 0xFF01
  148. #define NSSMC_OPTEED_CALL_UID \
  149. NSSMC_OPTEED_CALL(NSSMC_OPTEED_FUNCID_CALLS_UID)
  150. #endif /*TEESMC_OPTEED_H*/