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