projects/linux·blob master · refs

172 lines · 5.3 KiB

1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2
3#ifndef __QCOM_FASTRPC_H__
4#define __QCOM_FASTRPC_H__
5
6#include <linux/types.h>
7
8#define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_alloc_dma_buf)
9#define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, __u32)
10#define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_invoke)
11#define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4)
12#define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create)
13#define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap)
14#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap)
15#define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8)
16#define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static)
17#define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map)
18#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap)
19#define FASTRPC_IOCTL_SET_OPTION _IOWR('R', 12, struct fastrpc_ioctl_set_option)
20#define FASTRPC_IOCTL_GET_DSP_INFO _IOWR('R', 13, struct fastrpc_ioctl_capability)
21
22/**
23 * enum fastrpc_map_flags - control flags for mapping memory on DSP user process
24 * @FASTRPC_MAP_STATIC: Map memory pages with RW- permission and CACHE WRITEBACK.
25 * The driver is responsible for cache maintenance when passed
26 * the buffer to FastRPC calls. Same virtual address will be
27 * assigned for subsequent FastRPC calls.
28 * @FASTRPC_MAP_RESERVED: Reserved
29 * @FASTRPC_MAP_FD: Map memory pages with RW- permission and CACHE WRITEBACK.
30 * Mapping tagged with a file descriptor. User is responsible for
31 * CPU and DSP cache maintenance for the buffer. Get virtual address
32 * of buffer on DSP using HAP_mmap_get() and HAP_mmap_put() APIs.
33 * @FASTRPC_MAP_FD_DELAYED: Mapping delayed until user call HAP_mmap() and HAP_munmap()
34 * functions on DSP. It is useful to map a buffer with cache modes
35 * other than default modes. User is responsible for CPU and DSP
36 * cache maintenance for the buffer.
37 * @FASTRPC_MAP_FD_NOMAP: This flag is used to skip CPU mapping,
38 * otherwise behaves similar to FASTRPC_MAP_FD_DELAYED flag.
39 * @FASTRPC_MAP_MAX: max count for flags
40 *
41 */
42enum fastrpc_map_flags {
43 FASTRPC_MAP_STATIC = 0,
44 FASTRPC_MAP_RESERVED,
45 FASTRPC_MAP_FD = 2,
46 FASTRPC_MAP_FD_DELAYED,
47 FASTRPC_MAP_FD_NOMAP = 16,
48 FASTRPC_MAP_MAX,
49};
50
51enum fastrpc_proc_attr {
52 /* Macro for Debug attr */
53 FASTRPC_MODE_DEBUG = (1 << 0),
54 /* Macro for Ptrace */
55 FASTRPC_MODE_PTRACE = (1 << 1),
56 /* Macro for CRC Check */
57 FASTRPC_MODE_CRC = (1 << 2),
58 /* Macro for Unsigned PD */
59 FASTRPC_MODE_UNSIGNED_MODULE = (1 << 3),
60 /* Macro for Adaptive QoS */
61 FASTRPC_MODE_ADAPTIVE_QOS = (1 << 4),
62 /* Macro for System Process */
63 FASTRPC_MODE_SYSTEM_PROCESS = (1 << 5),
64 /* Macro for Prvileged Process */
65 FASTRPC_MODE_PRIVILEGED = (1 << 6),
66};
67
68/* Fastrpc attribute for memory protection of buffers */
69#define FASTRPC_ATTR_SECUREMAP (1)
70
71/**
72 * FASTRPC_POLL_MODE - Enable/disable poll mode for FastRPC invocations
73 *
74 * Poll mode is an optimization that allows the CPU to poll shared memory
75 * for completion instead of waiting for an interrupt-based response.
76 * This reduces latency for fast-completing operations.
77 *
78 * Restrictions:
79 * - Only supported for USER_PD (User Protection Domain)
80 * - Only applies to dynamic modules (handle > 20)
81 * - Static modules always use interrupt-based completion
82 *
83 * Values:
84 * - 0: Disable poll mode (use interrupt-based completion)
85 * - 1: Enable poll mode (poll shared memory for completion)
86 */
87#define FASTRPC_POLL_MODE (1)
88
89/* Values for FASTRPC_POLL_MODE request */
90#define FASTRPC_POLL_MODE_DISABLE 0
91#define FASTRPC_POLL_MODE_ENABLE 1
92
93struct fastrpc_invoke_args {
94 __u64 ptr;
95 __u64 length;
96 __s32 fd;
97 __u32 attr;
98};
99
100struct fastrpc_invoke {
101 __u32 handle;
102 __u32 sc;
103 __u64 args;
104};
105
106struct fastrpc_init_create {
107 __u32 filelen; /* elf file length */
108 __s32 filefd; /* fd for the file */
109 __u32 attrs;
110 __u32 siglen;
111 __u64 file; /* pointer to elf file */
112};
113
114struct fastrpc_init_create_static {
115 __u32 namelen; /* length of pd process name */
116 __u32 memlen;
117 __u64 name; /* pd process name */
118};
119
120struct fastrpc_alloc_dma_buf {
121 __s32 fd; /* fd */
122 __u32 flags; /* flags to map with */
123 __u64 size; /* size */
124};
125
126struct fastrpc_req_mmap {
127 __s32 fd;
128 __u32 flags; /* flags for dsp to map with */
129 __u64 vaddrin; /* optional virtual address */
130 __u64 size; /* size */
131 __u64 vaddrout; /* dsp virtual address */
132};
133
134struct fastrpc_mem_map {
135 __s32 version;
136 __s32 fd; /* fd */
137 __s32 offset; /* buffer offset */
138 __u32 flags; /* flags defined in enum fastrpc_map_flags */
139 __u64 vaddrin; /* buffer virtual address */
140 __u64 length; /* buffer length */
141 __u64 vaddrout; /* [out] remote virtual address */
142 __s32 attrs; /* buffer attributes used for SMMU mapping */
143 __s32 reserved[4];
144};
145
146struct fastrpc_req_munmap {
147 __u64 vaddrout; /* address to unmap */
148 __u64 size; /* size */
149};
150
151struct fastrpc_mem_unmap {
152 __s32 vesion;
153 __s32 fd; /* fd */
154 __u64 vaddr; /* remote process (dsp) virtual address */
155 __u64 length; /* buffer size */
156 __s32 reserved[5];
157};
158
159struct fastrpc_ioctl_set_option {
160 __u32 request_id; /* Request type (e.g., FASTRPC_POLL_MODE) */
161 __u32 value; /* Request-specific value */
162 __s32 reserved[6];
163};
164
165struct fastrpc_ioctl_capability {
166 __u32 unused; /* deprecated, ignored by the kernel */
167 __u32 attribute_id;
168 __u32 capability; /* dsp capability */
169 __u32 reserved[4];
170};
171
172#endif /* __QCOM_FASTRPC_H__ */