fastrpc.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef __QCOM_FASTRPC_H__
  3. #define __QCOM_FASTRPC_H__
  4. #include <linux/types.h>
  5. #define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_alloc_dma_buf)
  6. #define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, __u32)
  7. #define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_invoke)
  8. #define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4)
  9. #define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create)
  10. #define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap)
  11. #define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap)
  12. #define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8)
  13. #define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static)
  14. #define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map)
  15. #define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap)
  16. #define FASTRPC_IOCTL_GET_DSP_INFO _IOWR('R', 13, struct fastrpc_ioctl_capability)
  17. /**
  18. * enum fastrpc_map_flags - control flags for mapping memory on DSP user process
  19. * @FASTRPC_MAP_STATIC: Map memory pages with RW- permission and CACHE WRITEBACK.
  20. * The driver is responsible for cache maintenance when passed
  21. * the buffer to FastRPC calls. Same virtual address will be
  22. * assigned for subsequent FastRPC calls.
  23. * @FASTRPC_MAP_RESERVED: Reserved
  24. * @FASTRPC_MAP_FD: Map memory pages with RW- permission and CACHE WRITEBACK.
  25. * Mapping tagged with a file descriptor. User is responsible for
  26. * CPU and DSP cache maintenance for the buffer. Get virtual address
  27. * of buffer on DSP using HAP_mmap_get() and HAP_mmap_put() APIs.
  28. * @FASTRPC_MAP_FD_DELAYED: Mapping delayed until user call HAP_mmap() and HAP_munmap()
  29. * functions on DSP. It is useful to map a buffer with cache modes
  30. * other than default modes. User is responsible for CPU and DSP
  31. * cache maintenance for the buffer.
  32. * @FASTRPC_MAP_FD_NOMAP: This flag is used to skip CPU mapping,
  33. * otherwise behaves similar to FASTRPC_MAP_FD_DELAYED flag.
  34. * @FASTRPC_MAP_MAX: max count for flags
  35. *
  36. */
  37. enum fastrpc_map_flags {
  38. FASTRPC_MAP_STATIC = 0,
  39. FASTRPC_MAP_RESERVED,
  40. FASTRPC_MAP_FD = 2,
  41. FASTRPC_MAP_FD_DELAYED,
  42. FASTRPC_MAP_FD_NOMAP = 16,
  43. FASTRPC_MAP_MAX,
  44. };
  45. enum fastrpc_proc_attr {
  46. /* Macro for Debug attr */
  47. FASTRPC_MODE_DEBUG = (1 << 0),
  48. /* Macro for Ptrace */
  49. FASTRPC_MODE_PTRACE = (1 << 1),
  50. /* Macro for CRC Check */
  51. FASTRPC_MODE_CRC = (1 << 2),
  52. /* Macro for Unsigned PD */
  53. FASTRPC_MODE_UNSIGNED_MODULE = (1 << 3),
  54. /* Macro for Adaptive QoS */
  55. FASTRPC_MODE_ADAPTIVE_QOS = (1 << 4),
  56. /* Macro for System Process */
  57. FASTRPC_MODE_SYSTEM_PROCESS = (1 << 5),
  58. /* Macro for Prvileged Process */
  59. FASTRPC_MODE_PRIVILEGED = (1 << 6),
  60. };
  61. /* Fastrpc attribute for memory protection of buffers */
  62. #define FASTRPC_ATTR_SECUREMAP (1)
  63. struct fastrpc_invoke_args {
  64. __u64 ptr;
  65. __u64 length;
  66. __s32 fd;
  67. __u32 attr;
  68. };
  69. struct fastrpc_invoke {
  70. __u32 handle;
  71. __u32 sc;
  72. __u64 args;
  73. };
  74. struct fastrpc_init_create {
  75. __u32 filelen; /* elf file length */
  76. __s32 filefd; /* fd for the file */
  77. __u32 attrs;
  78. __u32 siglen;
  79. __u64 file; /* pointer to elf file */
  80. };
  81. struct fastrpc_init_create_static {
  82. __u32 namelen; /* length of pd process name */
  83. __u32 memlen;
  84. __u64 name; /* pd process name */
  85. };
  86. struct fastrpc_alloc_dma_buf {
  87. __s32 fd; /* fd */
  88. __u32 flags; /* flags to map with */
  89. __u64 size; /* size */
  90. };
  91. struct fastrpc_req_mmap {
  92. __s32 fd;
  93. __u32 flags; /* flags for dsp to map with */
  94. __u64 vaddrin; /* optional virtual address */
  95. __u64 size; /* size */
  96. __u64 vaddrout; /* dsp virtual address */
  97. };
  98. struct fastrpc_mem_map {
  99. __s32 version;
  100. __s32 fd; /* fd */
  101. __s32 offset; /* buffer offset */
  102. __u32 flags; /* flags defined in enum fastrpc_map_flags */
  103. __u64 vaddrin; /* buffer virtual address */
  104. __u64 length; /* buffer length */
  105. __u64 vaddrout; /* [out] remote virtual address */
  106. __s32 attrs; /* buffer attributes used for SMMU mapping */
  107. __s32 reserved[4];
  108. };
  109. struct fastrpc_req_munmap {
  110. __u64 vaddrout; /* address to unmap */
  111. __u64 size; /* size */
  112. };
  113. struct fastrpc_mem_unmap {
  114. __s32 vesion;
  115. __s32 fd; /* fd */
  116. __u64 vaddr; /* remote process (dsp) virtual address */
  117. __u64 length; /* buffer size */
  118. __s32 reserved[5];
  119. };
  120. struct fastrpc_ioctl_capability {
  121. __u32 domain;
  122. __u32 attribute_id;
  123. __u32 capability; /* dsp capability */
  124. __u32 reserved[4];
  125. };
  126. #endif /* __QCOM_FASTRPC_H__ */