1 /**
2  * Copyright (c) 2010-2012 Broadcom. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions, and the following disclaimer,
9  *    without modification.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. The names of the above-listed copyright holders may not be used
14  *    to endorse or promote products derived from this software without
15  *    specific prior written permission.
16  *
17  * ALTERNATIVELY, this software may be distributed under the terms of the
18  * GNU General Public License ("GPL") version 2, as published by the Free
19  * Software Foundation.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef VCHIQ_IOCTLS_H
35 #define VCHIQ_IOCTLS_H
36 
37 #include "vchiq_if.h"
38 
39 #define VCHIQ_IOC_MAGIC 0xc4
40 #define VCHIQ_INVALID_HANDLE (~0)
41 
42 typedef struct {
43 	VCHIQ_SERVICE_PARAMS_T params;
44 	int is_open;
45 	int is_vchi;
46 	unsigned int handle;       /* OUT */
47 } VCHIQ_CREATE_SERVICE_T;
48 
49 typedef struct {
50 	unsigned int handle;
51 	unsigned int count;
52 	const VCHIQ_ELEMENT_T *elements;
53 } VCHIQ_QUEUE_MESSAGE_T;
54 
55 typedef struct {
56 	unsigned int handle;
57 	void *data;
58 	unsigned int size;
59 	void *userdata;
60 	VCHIQ_BULK_MODE_T mode;
61 } VCHIQ_QUEUE_BULK_TRANSFER_T;
62 
63 typedef struct {
64 	VCHIQ_REASON_T reason;
65 	VCHIQ_HEADER_T *header;
66 	void *service_userdata;
67 	void *bulk_userdata;
68 } VCHIQ_COMPLETION_DATA_T;
69 
70 typedef struct {
71 	unsigned int count;
72 	VCHIQ_COMPLETION_DATA_T *buf;
73 	unsigned int msgbufsize;
74 	unsigned int msgbufcount; /* IN/OUT */
75 	void **msgbufs;
76 } VCHIQ_AWAIT_COMPLETION_T;
77 
78 typedef struct {
79 	unsigned int handle;
80 	int blocking;
81 	unsigned int bufsize;
82 	void *buf;
83 } VCHIQ_DEQUEUE_MESSAGE_T;
84 
85 typedef struct {
86 	unsigned int config_size;
87 	VCHIQ_CONFIG_T *pconfig;
88 } VCHIQ_GET_CONFIG_T;
89 
90 typedef struct {
91 	unsigned int handle;
92 	VCHIQ_SERVICE_OPTION_T option;
93 	int value;
94 } VCHIQ_SET_SERVICE_OPTION_T;
95 
96 typedef struct {
97 	void     *virt_addr;
98 	size_t    num_bytes;
99 } VCHIQ_DUMP_MEM_T;
100 
101 #define VCHIQ_IOC_CONNECT              _IO(VCHIQ_IOC_MAGIC,   0)
102 #define VCHIQ_IOC_SHUTDOWN             _IO(VCHIQ_IOC_MAGIC,   1)
103 #define VCHIQ_IOC_CREATE_SERVICE \
104 	_IOWR(VCHIQ_IOC_MAGIC, 2, VCHIQ_CREATE_SERVICE_T)
105 #define VCHIQ_IOC_REMOVE_SERVICE       _IO(VCHIQ_IOC_MAGIC,   3)
106 #define VCHIQ_IOC_QUEUE_MESSAGE \
107 	_IOW(VCHIQ_IOC_MAGIC,  4, VCHIQ_QUEUE_MESSAGE_T)
108 #define VCHIQ_IOC_QUEUE_BULK_TRANSMIT \
109 	_IOWR(VCHIQ_IOC_MAGIC, 5, VCHIQ_QUEUE_BULK_TRANSFER_T)
110 #define VCHIQ_IOC_QUEUE_BULK_RECEIVE \
111 	_IOWR(VCHIQ_IOC_MAGIC, 6, VCHIQ_QUEUE_BULK_TRANSFER_T)
112 #define VCHIQ_IOC_AWAIT_COMPLETION \
113 	_IOWR(VCHIQ_IOC_MAGIC, 7, VCHIQ_AWAIT_COMPLETION_T)
114 #define VCHIQ_IOC_DEQUEUE_MESSAGE \
115 	_IOWR(VCHIQ_IOC_MAGIC, 8, VCHIQ_DEQUEUE_MESSAGE_T)
116 #define VCHIQ_IOC_GET_CLIENT_ID        _IO(VCHIQ_IOC_MAGIC,   9)
117 #define VCHIQ_IOC_GET_CONFIG \
118 	_IOWR(VCHIQ_IOC_MAGIC, 10, VCHIQ_GET_CONFIG_T)
119 #define VCHIQ_IOC_CLOSE_SERVICE        _IO(VCHIQ_IOC_MAGIC,   11)
120 #define VCHIQ_IOC_USE_SERVICE          _IO(VCHIQ_IOC_MAGIC,   12)
121 #define VCHIQ_IOC_RELEASE_SERVICE      _IO(VCHIQ_IOC_MAGIC,   13)
122 #define VCHIQ_IOC_SET_SERVICE_OPTION \
123 	_IOW(VCHIQ_IOC_MAGIC,  14, VCHIQ_SET_SERVICE_OPTION_T)
124 #define VCHIQ_IOC_DUMP_PHYS_MEM \
125 	_IOW(VCHIQ_IOC_MAGIC,  15, VCHIQ_DUMP_MEM_T)
126 #define VCHIQ_IOC_LIB_VERSION          _IO(VCHIQ_IOC_MAGIC,   16)
127 #define VCHIQ_IOC_CLOSE_DELIVERED      _IO(VCHIQ_IOC_MAGIC,   17)
128 #define VCHIQ_IOC_MAX                  17
129 
130 #endif
131