optee_rpc_cmd.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. *
  41. * Sending a synchronous notification
  42. * [in] value[0].a OPTEE_RPC_NOTIFICATION_SEND
  43. * [in] value[0].b notification value
  44. */
  45. #define OPTEE_RPC_CMD_NOTIFICATION 4
  46. #define OPTEE_RPC_NOTIFICATION_WAIT 0
  47. #define OPTEE_RPC_NOTIFICATION_SEND 1
  48. /*
  49. * Suspend execution
  50. *
  51. * [in] value[0].a Number of milliseconds to suspend
  52. */
  53. #define OPTEE_RPC_CMD_SUSPEND 5
  54. /*
  55. * Allocate a piece of shared memory
  56. *
  57. * [in] value[0].a Type of memory one of
  58. * OPTEE_RPC_SHM_TYPE_* below
  59. * [in] value[0].b Requested size
  60. * [in] value[0].c Required alignment
  61. * [out] memref[0] Buffer
  62. */
  63. #define OPTEE_RPC_CMD_SHM_ALLOC 6
  64. /* Memory that can be shared with a non-secure user space application */
  65. #define OPTEE_RPC_SHM_TYPE_APPL 0
  66. /* Memory only shared with non-secure kernel */
  67. #define OPTEE_RPC_SHM_TYPE_KERNEL 1
  68. /*
  69. * Free shared memory previously allocated with OPTEE_RPC_CMD_SHM_ALLOC
  70. *
  71. * [in] value[0].a Type of memory one of
  72. * OPTEE_RPC_SHM_TYPE_* above
  73. * [in] value[0].b Value of shared memory reference or cookie
  74. */
  75. #define OPTEE_RPC_CMD_SHM_FREE 7
  76. /*
  77. * Issue master requests (read and write operations) to an I2C chip.
  78. *
  79. * [in] value[0].a Transfer mode (OPTEE_RPC_I2C_TRANSFER_*)
  80. * [in] value[0].b The I2C bus (a.k.a adapter).
  81. * 16 bit field.
  82. * [in] value[0].c The I2C chip (a.k.a address).
  83. * 16 bit field (either 7 or 10 bit effective).
  84. * [in] value[1].a The I2C master control flags (ie, 10 bit address).
  85. * 16 bit field.
  86. * [in/out] memref[2] Buffer used for data transfers.
  87. * [out] value[3].a Number of bytes transferred by the REE.
  88. */
  89. #define OPTEE_RPC_CMD_I2C_TRANSFER 21
  90. /* I2C master transfer modes */
  91. #define OPTEE_RPC_I2C_TRANSFER_RD 0
  92. #define OPTEE_RPC_I2C_TRANSFER_WR 1
  93. /* I2C master control flags */
  94. #define OPTEE_RPC_I2C_FLAGS_TEN_BIT BIT(0)
  95. #endif /*__OPTEE_RPC_CMD_H*/