optee_rpc_cmd.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* SPDX-License-Identifier: BSD-2-Clause */
  2. /*
  3. * Copyright (c) 2016-2021, Linaro Limited
  4. */
  5. #ifndef __OPTEE_RPC_CMD_H
  6. #define __OPTEE_RPC_CMD_H
  7. /*
  8. * All RPC is done with a struct optee_msg_arg as bearer of information,
  9. * struct optee_msg_arg::arg holds values defined by OPTEE_RPC_CMD_* below.
  10. * Only the commands handled by the kernel driver are defined here.
  11. *
  12. * RPC communication with tee-supplicant is reversed compared to normal
  13. * client communication described above. The supplicant receives requests
  14. * and sends responses.
  15. */
  16. /*
  17. * Get time
  18. *
  19. * Returns number of seconds and nano seconds since the Epoch,
  20. * 1970-01-01 00:00:00 +0000 (UTC).
  21. *
  22. * [out] value[0].a Number of seconds
  23. * [out] value[0].b Number of nano seconds.
  24. */
  25. #define OPTEE_RPC_CMD_GET_TIME 3
  26. /*
  27. * Notification from/to secure world.
  28. *
  29. * If secure world needs to wait for something, for instance a mutex, it
  30. * does a notification wait request instead of spinning in secure world.
  31. * Conversely can a synchronous notification can be sent when a secure
  32. * world mutex with a thread waiting thread is unlocked.
  33. *
  34. * This interface can also be used to wait for a asynchronous notification
  35. * which instead is sent via a non-secure interrupt.
  36. *
  37. * Waiting on notification
  38. * [in] value[0].a OPTEE_RPC_NOTIFICATION_WAIT
  39. * [in] value[0].b notification value
  40. * [in] value[0].c timeout in milliseconds or 0 if no timeout
  41. *
  42. * Sending a synchronous notification
  43. * [in] value[0].a OPTEE_RPC_NOTIFICATION_SEND
  44. * [in] value[0].b notification value
  45. */
  46. #define OPTEE_RPC_CMD_NOTIFICATION 4
  47. #define OPTEE_RPC_NOTIFICATION_WAIT 0
  48. #define OPTEE_RPC_NOTIFICATION_SEND 1
  49. /*
  50. * Suspend execution
  51. *
  52. * [in] value[0].a Number of milliseconds to suspend
  53. */
  54. #define OPTEE_RPC_CMD_SUSPEND 5
  55. /*
  56. * Allocate a piece of shared memory
  57. *
  58. * [in] value[0].a Type of memory one of
  59. * OPTEE_RPC_SHM_TYPE_* below
  60. * [in] value[0].b Requested size
  61. * [in] value[0].c Required alignment
  62. * [out] memref[0] Buffer
  63. */
  64. #define OPTEE_RPC_CMD_SHM_ALLOC 6
  65. /* Memory that can be shared with a non-secure user space application */
  66. #define OPTEE_RPC_SHM_TYPE_APPL 0
  67. /* Memory only shared with non-secure kernel */
  68. #define OPTEE_RPC_SHM_TYPE_KERNEL 1
  69. /*
  70. * Free shared memory previously allocated with OPTEE_RPC_CMD_SHM_ALLOC
  71. *
  72. * [in] value[0].a Type of memory one of
  73. * OPTEE_RPC_SHM_TYPE_* above
  74. * [in] value[0].b Value of shared memory reference or cookie
  75. */
  76. #define OPTEE_RPC_CMD_SHM_FREE 7
  77. /*
  78. * Issue master requests (read and write operations) to an I2C chip.
  79. *
  80. * [in] value[0].a Transfer mode (OPTEE_RPC_I2C_TRANSFER_*)
  81. * [in] value[0].b The I2C bus (a.k.a adapter).
  82. * 16 bit field.
  83. * [in] value[0].c The I2C chip (a.k.a address).
  84. * 16 bit field (either 7 or 10 bit effective).
  85. * [in] value[1].a The I2C master control flags (ie, 10 bit address).
  86. * 16 bit field.
  87. * [in/out] memref[2] Buffer used for data transfers.
  88. * [out] value[3].a Number of bytes transferred by the REE.
  89. */
  90. #define OPTEE_RPC_CMD_I2C_TRANSFER 21
  91. /* I2C master transfer modes */
  92. #define OPTEE_RPC_I2C_TRANSFER_RD 0
  93. #define OPTEE_RPC_I2C_TRANSFER_WR 1
  94. /* I2C master control flags */
  95. #define OPTEE_RPC_I2C_FLAGS_TEN_BIT BIT(0)
  96. /*
  97. * Reset RPMB probing
  98. *
  99. * Releases an eventually already used RPMB devices and starts over searching
  100. * for RPMB devices. Returns the kind of shared memory to use in subsequent
  101. * OPTEE_RPC_CMD_RPMB_PROBE_NEXT and OPTEE_RPC_CMD_RPMB calls.
  102. *
  103. * [out] value[0].a OPTEE_RPC_SHM_TYPE_*, the parameter for
  104. * OPTEE_RPC_CMD_SHM_ALLOC
  105. */
  106. #define OPTEE_RPC_CMD_RPMB_PROBE_RESET 22
  107. /*
  108. * Probe next RPMB device
  109. *
  110. * [out] value[0].a Type of RPMB device, OPTEE_RPC_RPMB_*
  111. * [out] value[0].b EXT CSD-slice 168 "RPMB Size"
  112. * [out] value[0].c EXT CSD-slice 222 "Reliable Write Sector Count"
  113. * [out] memref[1] Buffer with the raw CID
  114. */
  115. #define OPTEE_RPC_CMD_RPMB_PROBE_NEXT 23
  116. /* Type of RPMB device */
  117. #define OPTEE_RPC_RPMB_EMMC 0
  118. #define OPTEE_RPC_RPMB_UFS 1
  119. #define OPTEE_RPC_RPMB_NVME 2
  120. /*
  121. * Replay Protected Memory Block access
  122. *
  123. * [in] memref[0] Frames to device
  124. * [out] memref[1] Frames from device
  125. */
  126. #define OPTEE_RPC_CMD_RPMB_FRAMES 24
  127. #endif /*__OPTEE_RPC_CMD_H*/