fastrpc_shared.h 8.4 KB

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