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