smcinvoke.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _UAPI_SMCINVOKE_H_
  7. #define _UAPI_SMCINVOKE_H_
  8. #include <linux/types.h>
  9. #include <linux/ioctl.h>
  10. #define SMCINVOKE_USERSPACE_OBJ_NULL -1
  11. #define DEFAULT_CB_OBJ_THREAD_CNT 4
  12. #define SMCINVOKE_TZ_MIN_BUF_SIZE 4096
  13. struct smcinvoke_buf {
  14. __u64 addr;
  15. __u64 size;
  16. };
  17. struct smcinvoke_obj {
  18. __s64 fd;
  19. __s64 cb_server_fd;
  20. __s64 reserved;
  21. };
  22. union smcinvoke_arg {
  23. struct smcinvoke_buf b;
  24. struct smcinvoke_obj o;
  25. };
  26. /*
  27. * struct smcinvoke_cmd_req: This structure is transparently sent to TEE
  28. * @op - Operation to be performed
  29. * @counts - number of aruments passed
  30. * @result - result of invoke operation
  31. * @argsize - size of each of arguments
  32. * @args - args is pointer to buffer having all arguments
  33. * @reserved: IN/OUT: Usage is not defined but should be set to 0
  34. */
  35. struct smcinvoke_cmd_req {
  36. __u32 op;
  37. __u32 counts;
  38. __s32 result;
  39. __u32 argsize;
  40. __u64 args;
  41. __s64 reserved;
  42. };
  43. /*
  44. * struct smcinvoke_accept: structure to process CB req from TEE
  45. * @has_resp: IN: Whether IOCTL is carrying response data
  46. * @result: IN: Outcome of operation op
  47. * @op: OUT: Operation to be performed on target object
  48. * @counts: OUT: Number of arguments, embedded in buffer pointed by
  49. * buf_addr, to complete operation
  50. * @reserved: IN/OUT: Usage is not defined but should be set to 0.
  51. * @argsize: IN: Size of any argument, all of equal size, embedded
  52. * in buffer pointed by buf_addr
  53. * @txn_id: OUT: An id that should be passed as it is for response
  54. * @cbobj_id: OUT: Callback object which is target of operation op
  55. * @buf_len: IN: Len of buffer pointed by buf_addr
  56. * @buf_addr: IN: Buffer containing all arguments which are needed
  57. * to complete operation op
  58. */
  59. struct smcinvoke_accept {
  60. __u32 has_resp;
  61. __s32 result;
  62. __u32 op;
  63. __u32 counts;
  64. __s32 reserved;
  65. __u32 argsize;
  66. __u64 txn_id;
  67. __s64 cbobj_id;
  68. __u64 buf_len;
  69. __u64 buf_addr;
  70. };
  71. /*
  72. * @cb_buf_size: IN: Max buffer size for any callback obj implemented by client
  73. * @reserved: IN/OUT: Usage is not defined but should be set to 0
  74. */
  75. struct smcinvoke_server {
  76. __u64 cb_buf_size;
  77. __s64 reserved;
  78. };
  79. #define SMCINVOKE_IOC_MAGIC 0x98
  80. #define SMCINVOKE_IOCTL_INVOKE_REQ \
  81. _IOWR(SMCINVOKE_IOC_MAGIC, 1, struct smcinvoke_cmd_req)
  82. #define SMCINVOKE_IOCTL_ACCEPT_REQ \
  83. _IOWR(SMCINVOKE_IOC_MAGIC, 2, struct smcinvoke_accept)
  84. #define SMCINVOKE_IOCTL_SERVER_REQ \
  85. _IOWR(SMCINVOKE_IOC_MAGIC, 3, struct smcinvoke_server)
  86. #define SMCINVOKE_IOCTL_ACK_LOCAL_OBJ \
  87. _IOWR(SMCINVOKE_IOC_MAGIC, 4, __s64)
  88. /*
  89. * smcinvoke logging buffer is for communicating with the smcinvoke driver additional
  90. * info for debugging to be included in driver's log (if any)
  91. */
  92. #define SMCINVOKE_LOG_BUF_SIZE 100
  93. #define SMCINVOKE_IOCTL_LOG \
  94. _IOC(_IOC_READ|_IOC_WRITE, SMCINVOKE_IOC_MAGIC, 255, SMCINVOKE_LOG_BUF_SIZE)
  95. #endif /* _UAPI_SMCINVOKE_H_ */