1 /*
2  * dspapi-ioctl.h
3  *
4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5  *
6  * Contains structures and commands that are used for interaction
7  * between the DDSP API and Bridge driver.
8  *
9  * Copyright (C) 2008 Texas Instruments, Inc.
10  *
11  * This package is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2 as
13  * published by the Free Software Foundation.
14  *
15  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18  */
19 
20 #ifndef DSPAPIIOCTL_
21 #define DSPAPIIOCTL_
22 
23 #include <dspbridge/cmm.h>
24 #include <dspbridge/strmdefs.h>
25 #include <dspbridge/dbdcd.h>
26 
27 union trapped_args {
28 
29 	/* MGR Module */
30 	struct {
31 		u32 node_id;
32 		struct dsp_ndbprops __user *ndb_props;
33 		u32 ndb_props_size;
34 		u32 __user *num_nodes;
35 	} args_mgr_enumnode_info;
36 
37 	struct {
38 		u32 processor_id;
39 		struct dsp_processorinfo __user *processor_info;
40 		u32 processor_info_size;
41 		u32 __user *num_procs;
42 	} args_mgr_enumproc_info;
43 
44 	struct {
45 		struct dsp_uuid *uuid_obj;
46 		enum dsp_dcdobjtype obj_type;
47 		char *sz_path_name;
48 	} args_mgr_registerobject;
49 
50 	struct {
51 		struct dsp_uuid *uuid_obj;
52 		enum dsp_dcdobjtype obj_type;
53 	} args_mgr_unregisterobject;
54 
55 	struct {
56 		struct dsp_notification __user *__user *anotifications;
57 		u32 count;
58 		u32 __user *index;
59 		u32 timeout;
60 	} args_mgr_wait;
61 
62 	/* PROC Module */
63 	struct {
64 		u32 processor_id;
65 		struct dsp_processorattrin __user *attr_in;
66 		void *__user *ph_processor;
67 	} args_proc_attach;
68 
69 	struct {
70 		void *processor;
71 		u32 cmd;
72 		struct dsp_cbdata __user *args;
73 	} args_proc_ctrl;
74 
75 	struct {
76 		void *processor;
77 	} args_proc_detach;
78 
79 	struct {
80 		void *processor;
81 		void *__user *node_tab;
82 		u32 node_tab_size;
83 		u32 __user *num_nodes;
84 		u32 __user *allocated;
85 	} args_proc_enumnode_info;
86 
87 	struct {
88 		void *processor;
89 		u32 resource_type;
90 		struct dsp_resourceinfo *resource_info;
91 		u32 resource_info_size;
92 	} args_proc_enumresources;
93 
94 	struct {
95 		void *processor;
96 		struct dsp_processorstate __user *proc_state_obj;
97 		u32 state_info_size;
98 	} args_proc_getstate;
99 
100 	struct {
101 		void *processor;
102 		u8 __user *buf;
103 		u8 __user *size;
104 		u32 max_size;
105 	} args_proc_gettrace;
106 
107 	struct {
108 		void *processor;
109 		s32 argc_index;
110 		char __user *__user *user_args;
111 		char *__user *user_envp;
112 	} args_proc_load;
113 
114 	struct {
115 		void *processor;
116 		u32 event_mask;
117 		u32 notify_type;
118 		struct dsp_notification __user *notification;
119 	} args_proc_register_notify;
120 
121 	struct {
122 		void *processor;
123 		u32 size;
124 		void *__user *rsv_addr;
125 	} args_proc_rsvmem;
126 
127 	struct {
128 		void *processor;
129 		u32 size;
130 		void *rsv_addr;
131 	} args_proc_unrsvmem;
132 
133 	struct {
134 		void *processor;
135 		void *mpu_addr;
136 		u32 size;
137 		void *req_addr;
138 		void *__user *map_addr;
139 		u32 map_attr;
140 	} args_proc_mapmem;
141 
142 	struct {
143 		void *processor;
144 		u32 size;
145 		void *map_addr;
146 	} args_proc_unmapmem;
147 
148 	struct {
149 		void *processor;
150 		void *mpu_addr;
151 		u32 size;
152 		u32 dir;
153 	} args_proc_dma;
154 
155 	struct {
156 		void *processor;
157 		void *mpu_addr;
158 		u32 size;
159 		u32 flags;
160 	} args_proc_flushmemory;
161 
162 	struct {
163 		void *processor;
164 		void *mpu_addr;
165 		u32 size;
166 	} args_proc_invalidatememory;
167 
168 	/* NODE Module */
169 	struct {
170 		void *processor;
171 		struct dsp_uuid __user *node_id_ptr;
172 		struct dsp_cbdata __user *args;
173 		struct dsp_nodeattrin __user *attr_in;
174 		void *__user *node;
175 	} args_node_allocate;
176 
177 	struct {
178 		void *node;
179 		u32 size;
180 		struct dsp_bufferattr __user *attr;
181 		u8 *__user *buffer;
182 	} args_node_allocmsgbuf;
183 
184 	struct {
185 		void *node;
186 		s32 prio;
187 	} args_node_changepriority;
188 
189 	struct {
190 		void *node;
191 		u32 stream_id;
192 		void *other_node;
193 		u32 other_stream;
194 		struct dsp_strmattr __user *attrs;
195 		struct dsp_cbdata __user *conn_param;
196 	} args_node_connect;
197 
198 	struct {
199 		void *node;
200 	} args_node_create;
201 
202 	struct {
203 		void *node;
204 	} args_node_delete;
205 
206 	struct {
207 		void *node;
208 		struct dsp_bufferattr __user *attr;
209 		u8 *buffer;
210 	} args_node_freemsgbuf;
211 
212 	struct {
213 		void *node;
214 		struct dsp_nodeattr __user *attr;
215 		u32 attr_size;
216 	} args_node_getattr;
217 
218 	struct {
219 		void *node;
220 		struct dsp_msg __user *message;
221 		u32 timeout;
222 	} args_node_getmessage;
223 
224 	struct {
225 		void *node;
226 	} args_node_pause;
227 
228 	struct {
229 		void *node;
230 		struct dsp_msg __user *message;
231 		u32 timeout;
232 	} args_node_putmessage;
233 
234 	struct {
235 		void *node;
236 		u32 event_mask;
237 		u32 notify_type;
238 		struct dsp_notification __user *notification;
239 	} args_node_registernotify;
240 
241 	struct {
242 		void *node;
243 	} args_node_run;
244 
245 	struct {
246 		void *node;
247 		int __user *status;
248 	} args_node_terminate;
249 
250 	struct {
251 		void *processor;
252 		struct dsp_uuid __user *node_id_ptr;
253 		struct dsp_ndbprops __user *node_props;
254 	} args_node_getuuidprops;
255 
256 	/* STRM module */
257 
258 	struct {
259 		void *stream;
260 		u32 size;
261 		u8 *__user *ap_buffer;
262 		u32 num_bufs;
263 	} args_strm_allocatebuffer;
264 
265 	struct {
266 		void *stream;
267 	} args_strm_close;
268 
269 	struct {
270 		void *stream;
271 		u8 *__user *ap_buffer;
272 		u32 num_bufs;
273 	} args_strm_freebuffer;
274 
275 	struct {
276 		void *stream;
277 		void **event;
278 	} args_strm_geteventhandle;
279 
280 	struct {
281 		void *stream;
282 		struct stream_info __user *stream_info;
283 		u32 stream_info_size;
284 	} args_strm_getinfo;
285 
286 	struct {
287 		void *stream;
288 		bool flush_flag;
289 	} args_strm_idle;
290 
291 	struct {
292 		void *stream;
293 		u8 *buffer;
294 		u32 bytes;
295 		u32 buf_size;
296 		u32 arg;
297 	} args_strm_issue;
298 
299 	struct {
300 		void *node;
301 		u32 direction;
302 		u32 index;
303 		struct strm_attr __user *attr_in;
304 		void *__user *stream;
305 	} args_strm_open;
306 
307 	struct {
308 		void *stream;
309 		u8 *__user *buf_ptr;
310 		u32 __user *bytes;
311 		u32 __user *buf_size_ptr;
312 		u32 __user *arg;
313 	} args_strm_reclaim;
314 
315 	struct {
316 		void *stream;
317 		u32 event_mask;
318 		u32 notify_type;
319 		struct dsp_notification __user *notification;
320 	} args_strm_registernotify;
321 
322 	struct {
323 		void *__user *stream_tab;
324 		u32 strm_num;
325 		u32 __user *mask;
326 		u32 timeout;
327 	} args_strm_select;
328 
329 	/* CMM Module */
330 	struct {
331 		struct cmm_object *cmm_mgr;
332 		u32 size;
333 		struct cmm_attrs *attrs;
334 		void **buf_va;
335 	} args_cmm_allocbuf;
336 
337 	struct {
338 		struct cmm_object *cmm_mgr;
339 		void *buf_pa;
340 		u32 seg_id;
341 	} args_cmm_freebuf;
342 
343 	struct {
344 		void *processor;
345 		struct cmm_object *__user *cmm_mgr;
346 	} args_cmm_gethandle;
347 
348 	struct {
349 		struct cmm_object *cmm_mgr;
350 		struct cmm_info __user *cmm_info_obj;
351 	} args_cmm_getinfo;
352 
353 	/* UTIL module */
354 	struct {
355 		s32 util_argc;
356 		char **argv;
357 	} args_util_testdll;
358 };
359 
360 /*
361  * Dspbridge Ioctl numbering scheme
362  *
363  *    7                           0
364  *  ---------------------------------
365  *  |  Module   |   Ioctl Number    |
366  *  ---------------------------------
367  *  | x | x | x | 0 | 0 | 0 | 0 | 0 |
368  *  ---------------------------------
369  */
370 
371 /* Ioctl driver identifier */
372 #define DB		0xDB
373 
374 /*
375  * Following are used to distinguish between module ioctls, this is needed
376  * in case new ioctls are introduced.
377  */
378 #define DB_MODULE_MASK		0xE0
379 #define DB_IOC_MASK		0x1F
380 
381 /* Ioctl module masks */
382 #define DB_MGR		0x0
383 #define DB_PROC		0x20
384 #define DB_NODE		0x40
385 #define DB_STRM		0x60
386 #define DB_CMM		0x80
387 
388 #define DB_MODULE_SHIFT		5
389 
390 /* Used to calculate the ioctl per dspbridge module */
391 #define DB_IOC(module, num) \
392 			(((module) & DB_MODULE_MASK) | ((num) & DB_IOC_MASK))
393 /* Used to get dspbridge ioctl module */
394 #define DB_GET_MODULE(cmd)	((cmd) & DB_MODULE_MASK)
395 /* Used to get dspbridge ioctl number */
396 #define DB_GET_IOC(cmd)		((cmd) & DB_IOC_MASK)
397 
398 /* TODO: Remove deprecated and not implemented */
399 
400 /* MGR Module */
401 #define MGR_ENUMNODE_INFO	_IOWR(DB, DB_IOC(DB_MGR, 0), unsigned long)
402 #define MGR_ENUMPROC_INFO	_IOWR(DB, DB_IOC(DB_MGR, 1), unsigned long)
403 #define MGR_REGISTEROBJECT	_IOWR(DB, DB_IOC(DB_MGR, 2), unsigned long)
404 #define MGR_UNREGISTEROBJECT	_IOWR(DB, DB_IOC(DB_MGR, 3), unsigned long)
405 #define MGR_WAIT		_IOWR(DB, DB_IOC(DB_MGR, 4), unsigned long)
406 /* MGR_GET_PROC_RES Deprecated */
407 #define MGR_GET_PROC_RES	_IOR(DB, DB_IOC(DB_MGR, 5), unsigned long)
408 
409 /* PROC Module */
410 #define PROC_ATTACH		_IOWR(DB, DB_IOC(DB_PROC, 0), unsigned long)
411 #define PROC_CTRL		_IOR(DB, DB_IOC(DB_PROC, 1), unsigned long)
412 /* PROC_DETACH Deprecated */
413 #define PROC_DETACH		_IOR(DB, DB_IOC(DB_PROC, 2), unsigned long)
414 #define PROC_ENUMNODE		_IOWR(DB, DB_IOC(DB_PROC, 3), unsigned long)
415 #define PROC_ENUMRESOURCES	_IOWR(DB, DB_IOC(DB_PROC, 4), unsigned long)
416 #define PROC_GET_STATE		_IOWR(DB, DB_IOC(DB_PROC, 5), unsigned long)
417 #define PROC_GET_TRACE		_IOWR(DB, DB_IOC(DB_PROC, 6), unsigned long)
418 #define PROC_LOAD		_IOW(DB, DB_IOC(DB_PROC, 7), unsigned long)
419 #define PROC_REGISTERNOTIFY	_IOWR(DB, DB_IOC(DB_PROC, 8), unsigned long)
420 #define PROC_START		_IOW(DB, DB_IOC(DB_PROC, 9), unsigned long)
421 #define PROC_RSVMEM		_IOWR(DB, DB_IOC(DB_PROC, 10), unsigned long)
422 #define PROC_UNRSVMEM		_IOW(DB, DB_IOC(DB_PROC, 11), unsigned long)
423 #define PROC_MAPMEM		_IOWR(DB, DB_IOC(DB_PROC, 12), unsigned long)
424 #define PROC_UNMAPMEM		_IOR(DB, DB_IOC(DB_PROC, 13), unsigned long)
425 #define PROC_FLUSHMEMORY	_IOW(DB, DB_IOC(DB_PROC, 14), unsigned long)
426 #define PROC_STOP		_IOWR(DB, DB_IOC(DB_PROC, 15), unsigned long)
427 #define PROC_INVALIDATEMEMORY	_IOW(DB, DB_IOC(DB_PROC, 16), unsigned long)
428 #define PROC_BEGINDMA		_IOW(DB, DB_IOC(DB_PROC, 17), unsigned long)
429 #define PROC_ENDDMA		_IOW(DB, DB_IOC(DB_PROC, 18), unsigned long)
430 
431 /* NODE Module */
432 #define NODE_ALLOCATE		_IOWR(DB, DB_IOC(DB_NODE, 0), unsigned long)
433 #define NODE_ALLOCMSGBUF	_IOWR(DB, DB_IOC(DB_NODE, 1), unsigned long)
434 #define NODE_CHANGEPRIORITY	_IOW(DB, DB_IOC(DB_NODE, 2), unsigned long)
435 #define NODE_CONNECT		_IOW(DB, DB_IOC(DB_NODE, 3), unsigned long)
436 #define NODE_CREATE		_IOW(DB, DB_IOC(DB_NODE, 4), unsigned long)
437 #define NODE_DELETE		_IOW(DB, DB_IOC(DB_NODE, 5), unsigned long)
438 #define NODE_FREEMSGBUF		_IOW(DB, DB_IOC(DB_NODE, 6), unsigned long)
439 #define NODE_GETATTR		_IOWR(DB, DB_IOC(DB_NODE, 7), unsigned long)
440 #define NODE_GETMESSAGE		_IOWR(DB, DB_IOC(DB_NODE, 8), unsigned long)
441 #define NODE_PAUSE		_IOW(DB, DB_IOC(DB_NODE, 9), unsigned long)
442 #define NODE_PUTMESSAGE		_IOW(DB, DB_IOC(DB_NODE, 10), unsigned long)
443 #define NODE_REGISTERNOTIFY	_IOWR(DB, DB_IOC(DB_NODE, 11), unsigned long)
444 #define NODE_RUN		_IOW(DB, DB_IOC(DB_NODE, 12), unsigned long)
445 #define NODE_TERMINATE		_IOWR(DB, DB_IOC(DB_NODE, 13), unsigned long)
446 #define NODE_GETUUIDPROPS	_IOWR(DB, DB_IOC(DB_NODE, 14), unsigned long)
447 
448 /* STRM Module */
449 #define STRM_ALLOCATEBUFFER	_IOWR(DB, DB_IOC(DB_STRM, 0), unsigned long)
450 #define STRM_CLOSE		_IOW(DB, DB_IOC(DB_STRM, 1), unsigned long)
451 #define STRM_FREEBUFFER		_IOWR(DB, DB_IOC(DB_STRM, 2), unsigned long)
452 #define STRM_GETEVENTHANDLE	_IO(DB, DB_IOC(DB_STRM, 3))	/* Not Impl'd */
453 #define STRM_GETINFO		_IOWR(DB, DB_IOC(DB_STRM, 4), unsigned long)
454 #define STRM_IDLE		_IOW(DB, DB_IOC(DB_STRM, 5), unsigned long)
455 #define STRM_ISSUE		_IOW(DB, DB_IOC(DB_STRM, 6), unsigned long)
456 #define STRM_OPEN		_IOWR(DB, DB_IOC(DB_STRM, 7), unsigned long)
457 #define STRM_RECLAIM		_IOWR(DB, DB_IOC(DB_STRM, 8), unsigned long)
458 #define STRM_REGISTERNOTIFY	_IOWR(DB, DB_IOC(DB_STRM, 9), unsigned long)
459 #define STRM_SELECT		_IOWR(DB, DB_IOC(DB_STRM, 10), unsigned long)
460 
461 /* CMM Module */
462 #define CMM_ALLOCBUF		_IO(DB, DB_IOC(DB_CMM, 0))	/* Not Impl'd */
463 #define CMM_FREEBUF		_IO(DB, DB_IOC(DB_CMM, 1))	/* Not Impl'd */
464 #define CMM_GETHANDLE		_IOR(DB, DB_IOC(DB_CMM, 2), unsigned long)
465 #define CMM_GETINFO		_IOR(DB, DB_IOC(DB_CMM, 3), unsigned long)
466 
467 #endif /* DSPAPIIOCTL_ */
468