smcinvoke.h 2.8 KB

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