fastrpc_shared.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef FASTRPC_IOCTL_H
  6. #define FASTRPC_IOCTL_H
  7. #include <linux/types.h>
  8. #define remote_arg_t union remote_arg
  9. /* Map and unmap IOCTL methods reserved memory size for future extensions */
  10. #define MAP_RESERVED_NUM (14)
  11. #define UNMAP_RESERVED_NUM (10)
  12. #define FASTRPC_IOCTL_INVOKE _IOWR('R', 1, struct fastrpc_ioctl_invoke)
  13. #define FASTRPC_IOCTL_MMAP _IOWR('R', 2, struct fastrpc_ioctl_mmap)
  14. #define FASTRPC_IOCTL_MUNMAP _IOWR('R', 3, struct fastrpc_ioctl_munmap)
  15. #define FASTRPC_IOCTL_MMAP_64 _IOWR('R', 14, struct fastrpc_ioctl_mmap_64)
  16. #define FASTRPC_IOCTL_MUNMAP_64 _IOWR('R', 15, struct fastrpc_ioctl_munmap_64)
  17. #define FASTRPC_IOCTL_INVOKE_FD _IOWR('R', 4, struct fastrpc_ioctl_invoke_fd)
  18. #define FASTRPC_IOCTL_SETMODE _IOWR('R', 5, uint32_t)
  19. #define FASTRPC_IOCTL_INIT _IOWR('R', 6, struct fastrpc_ioctl_init)
  20. #define FASTRPC_IOCTL_INVOKE_ATTRS \
  21. _IOWR('R', 7, struct fastrpc_ioctl_invoke_attrs)
  22. #define FASTRPC_IOCTL_GETINFO _IOWR('R', 8, uint32_t)
  23. //#define FASTRPC_IOCTL_GETPERF _IOWR('R', 9, struct fastrpc_ioctl_perf)
  24. #define FASTRPC_IOCTL_INIT_ATTRS _IOWR('R', 10, struct fastrpc_ioctl_init_attrs)
  25. #define FASTRPC_IOCTL_INVOKE_CRC _IOWR('R', 11, struct fastrpc_ioctl_invoke_crc)
  26. #define FASTRPC_IOCTL_CONTROL _IOWR('R', 12, struct fastrpc_ioctl_control)
  27. #define FASTRPC_IOCTL_MUNMAP_FD _IOWR('R', 13, struct fastrpc_ioctl_munmap_fd)
  28. #define FASTRPC_IOCTL_GET_DSP_INFO \
  29. _IOWR('R', 17, struct fastrpc_ioctl_capability)
  30. #define FASTRPC_IOCTL_INVOKE2 _IOWR('R', 18, struct fastrpc_ioctl_invoke2)
  31. #define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 19, struct fastrpc_ioctl_mem_map)
  32. #define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 20, struct fastrpc_ioctl_mem_unmap)
  33. #define FASTRPC_IOCTL_INVOKE_PERF \
  34. _IOWR('R', 21, struct fastrpc_ioctl_invoke_perf)
  35. #define FASTRPC_IOCTL_NOTIF_RSP \
  36. _IOWR('R', 22, struct fastrpc_ioctl_notif_rsp)
  37. #define FASTRPC_IOCTL_DSPSIGNAL_CREATE _IOWR('R', 23, struct fastrpc_ioctl_dspsignal_create)
  38. #define FASTRPC_IOCTL_DSPSIGNAL_DESTROY _IOWR('R', 24, struct fastrpc_ioctl_dspsignal_destroy)
  39. #define FASTRPC_IOCTL_DSPSIGNAL_SIGNAL _IOWR('R', 25, struct fastrpc_ioctl_dspsignal_signal)
  40. #define FASTRPC_IOCTL_DSPSIGNAL_WAIT _IOWR('R', 26, struct fastrpc_ioctl_dspsignal_wait)
  41. #define FASTRPC_IOCTL_DSPSIGNAL_CANCEL_WAIT \
  42. _IOWR('R', 27, struct fastrpc_ioctl_dspsignal_cancel_wait)
  43. struct fastrpc_mem_map {
  44. int fd; /* ion fd */
  45. int offset; /* buffer offset */
  46. uint32_t flags; /* flags defined in enum fastrpc_map_flags */
  47. int attrs; /* buffer attributes used for SMMU mapping */
  48. uintptr_t vaddrin; /* buffer virtual address */
  49. size_t length; /* buffer length */
  50. uint64_t vaddrout; /* [out] remote virtual address */
  51. };
  52. struct fastrpc_mem_unmap {
  53. int fd; /* ion fd */
  54. uint64_t vaddr; /* remote process (dsp) virtual address */
  55. size_t length; /* buffer size */
  56. };
  57. struct fastrpc_ctrl_latency {
  58. uint32_t enable; /* latency control enable */
  59. uint32_t latency; /* latency request in us */
  60. };
  61. struct fastrpc_ctrl_kalloc {
  62. uint32_t kalloc_support; /* Remote memory allocation from kernel */
  63. };
  64. struct fastrpc_ctrl_wakelock {
  65. uint32_t enable; /* wakelock control enable */
  66. };
  67. struct fastrpc_ctrl_pm {
  68. uint32_t timeout; /* timeout(in ms) for PM to keep system awake */
  69. };
  70. struct fastrpc_ctrl_smmu {
  71. uint32_t sharedcb; /* Set to SMMU share context bank */
  72. };
  73. struct fastrpc_ioctl_invoke {
  74. uint32_t handle; /* remote handle */
  75. uint32_t sc; /* scalars describing the data */
  76. remote_arg_t *pra; /* remote arguments list */
  77. };
  78. struct fastrpc_ioctl_invoke_fd {
  79. struct fastrpc_ioctl_invoke inv;
  80. int *fds; /* fd list */
  81. };
  82. struct fastrpc_ioctl_invoke_attrs {
  83. struct fastrpc_ioctl_invoke inv;
  84. int *fds; /* fd list */
  85. unsigned int *attrs; /* attribute list */
  86. };
  87. struct fastrpc_ioctl_invoke_crc {
  88. struct fastrpc_ioctl_invoke inv;
  89. int *fds; /* fd list */
  90. unsigned int *attrs; /* attribute list */
  91. unsigned int *crc;
  92. };
  93. struct fastrpc_ioctl_invoke_perf {
  94. struct fastrpc_ioctl_invoke inv;
  95. int *fds;
  96. unsigned int *attrs;
  97. unsigned int *crc;
  98. uint64_t *perf_kernel;
  99. uint64_t *perf_dsp;
  100. };
  101. struct fastrpc_ioctl_invoke_async {
  102. struct fastrpc_ioctl_invoke inv;
  103. int *fds; /* fd list */
  104. unsigned int *attrs; /* attribute list */
  105. unsigned int *crc;
  106. uint64_t *perf_kernel;
  107. uint64_t *perf_dsp;
  108. struct fastrpc_async_job *job; /* async job*/
  109. };
  110. struct fastrpc_ioctl_invoke_async_no_perf {
  111. struct fastrpc_ioctl_invoke inv;
  112. int *fds; /* fd list */
  113. unsigned int *attrs; /* attribute list */
  114. unsigned int *crc;
  115. struct fastrpc_async_job *job; /* async job*/
  116. };
  117. struct fastrpc_ioctl_async_response {
  118. uint64_t jobid;/* job id generated by user */
  119. int result; /* result from DSP */
  120. uint64_t *perf_kernel;
  121. uint64_t *perf_dsp;
  122. uint32_t handle;
  123. uint32_t sc;
  124. };
  125. struct fastrpc_ioctl_notif_rsp {
  126. int domain; /* Domain of User PD */
  127. int session; /* Session ID of User PD */
  128. uint32_t status; /* Status of the process */
  129. };
  130. struct fastrpc_ioctl_invoke2 {
  131. uint32_t req; /* type of invocation request */
  132. uintptr_t invparam; /* invocation request param */
  133. uint32_t size; /* size of invocation param */
  134. int err; /* reserved */
  135. };
  136. struct fastrpc_ioctl_init {
  137. uint32_t flags; /* one of FASTRPC_INIT_* macros */
  138. uintptr_t file; /* pointer to elf file */
  139. uint32_t filelen; /* elf file length */
  140. int32_t filefd; /* ION fd for the file */
  141. uintptr_t mem; /* mem for the PD */
  142. uint32_t memlen; /* mem length */
  143. int32_t memfd; /* ION fd for the mem */
  144. };
  145. struct fastrpc_ioctl_init_attrs {
  146. struct fastrpc_ioctl_init init;
  147. int attrs;
  148. unsigned int siglen;
  149. };
  150. struct fastrpc_ioctl_munmap {
  151. uintptr_t vaddrout; /* address to unmap */
  152. size_t size; /* size */
  153. };
  154. struct fastrpc_ioctl_munmap_64 {
  155. uint64_t vaddrout; /* address to unmap */
  156. size_t size; /* size */
  157. };
  158. struct fastrpc_ioctl_mmap {
  159. int fd; /* ion fd */
  160. uint32_t flags; /* flags for dsp to map with */
  161. uintptr_t vaddrin; /* optional virtual address */
  162. size_t size; /* size */
  163. uintptr_t vaddrout; /* dsps virtual address */
  164. };
  165. struct fastrpc_ioctl_mmap_64 {
  166. int fd; /* ion fd */
  167. uint32_t flags; /* flags for dsp to map with */
  168. uint64_t vaddrin; /* optional virtual address */
  169. size_t size; /* size */
  170. uint64_t vaddrout; /* dsps virtual address */
  171. };
  172. struct fastrpc_ioctl_munmap_fd {
  173. int fd; /* fd */
  174. uint32_t flags; /* control flags */
  175. uintptr_t va; /* va */
  176. ssize_t len; /* length */
  177. };
  178. struct fastrpc_ioctl_dspsignal_create {
  179. uint32_t signal_id; /* Signal ID */
  180. uint32_t flags; /* Flags, currently unused */
  181. };
  182. struct fastrpc_ioctl_dspsignal_destroy {
  183. uint32_t signal_id; /* Signal ID */
  184. };
  185. struct fastrpc_ioctl_dspsignal_signal {
  186. uint32_t signal_id; /* Signal ID */
  187. };
  188. struct fastrpc_ioctl_dspsignal_wait {
  189. uint32_t signal_id; /* Signal ID */
  190. uint32_t timeout_usec; /* Timeout in microseconds. UINT32_MAX for an infinite wait */
  191. };
  192. struct fastrpc_ioctl_dspsignal_cancel_wait {
  193. uint32_t signal_id; /* Signal ID */
  194. };
  195. /* map memory to DSP device */
  196. struct fastrpc_ioctl_mem_map {
  197. int version; /* Initial version 0 */
  198. union {
  199. struct fastrpc_mem_map m;
  200. int reserved[MAP_RESERVED_NUM];
  201. };
  202. };
  203. /* unmap memory to DSP device */
  204. struct fastrpc_ioctl_mem_unmap {
  205. int version; /* Initial version 0 */
  206. union {
  207. struct fastrpc_mem_unmap um;
  208. int reserved[UNMAP_RESERVED_NUM];
  209. };
  210. };
  211. struct fastrpc_ioctl_control {
  212. uint32_t req;
  213. union {
  214. struct fastrpc_ctrl_latency lp;
  215. struct fastrpc_ctrl_kalloc kalloc;
  216. struct fastrpc_ctrl_wakelock wp;
  217. struct fastrpc_ctrl_pm pm;
  218. struct fastrpc_ctrl_smmu smmu;
  219. };
  220. };
  221. struct fastrpc_ioctl_capability {
  222. uint32_t domain;
  223. uint32_t attribute_ID;
  224. uint32_t capability;
  225. };
  226. union fastrpc_ioctl_param {
  227. struct fastrpc_ioctl_invoke_async inv;
  228. struct fastrpc_ioctl_mem_map mem_map;
  229. struct fastrpc_ioctl_mem_unmap mem_unmap;
  230. struct fastrpc_ioctl_mmap mmap;
  231. struct fastrpc_ioctl_mmap_64 mmap64;
  232. struct fastrpc_ioctl_munmap munmap;
  233. struct fastrpc_ioctl_munmap_64 munmap64;
  234. struct fastrpc_ioctl_munmap_fd munmap_fd;
  235. struct fastrpc_ioctl_init_attrs init;
  236. struct fastrpc_ioctl_control cp;
  237. struct fastrpc_ioctl_capability cap;
  238. struct fastrpc_ioctl_invoke2 inv2;
  239. struct fastrpc_ioctl_dspsignal_signal sig;
  240. struct fastrpc_ioctl_dspsignal_wait wait;
  241. struct fastrpc_ioctl_dspsignal_create cre;
  242. struct fastrpc_ioctl_dspsignal_destroy des;
  243. struct fastrpc_ioctl_dspsignal_cancel_wait canc;
  244. };
  245. #endif