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