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 <linux/ioctl.h>
38 #include "vchiq_if.h"
39 
40 #define VCHIQ_IOC_MAGIC 0xc4
41 #define VCHIQ_INVALID_HANDLE (~0)
42 
43 typedef struct {
44 	VCHIQ_SERVICE_PARAMS_T params;
45 	int is_open;
46 	int is_vchi;
47 	unsigned int handle;       /* OUT */
48 } VCHIQ_CREATE_SERVICE_T;
49 
50 typedef struct {
51 	unsigned int handle;
52 	unsigned int count;
53 	const struct vchiq_element __user *elements;
54 } VCHIQ_QUEUE_MESSAGE_T;
55 
56 typedef struct {
57 	unsigned int handle;
58 	void *data;
59 	unsigned int size;
60 	void *userdata;
61 	VCHIQ_BULK_MODE_T mode;
62 } VCHIQ_QUEUE_BULK_TRANSFER_T;
63 
64 struct vchiq_completion_data {
65 	VCHIQ_REASON_T reason;
66 	VCHIQ_HEADER_T *header;
67 	void *service_userdata;
68 	void *bulk_userdata;
69 };
70 
71 struct vchiq_await_completion {
72 	unsigned int count;
73 	struct vchiq_completion_data *buf;
74 	unsigned int msgbufsize;
75 	unsigned int msgbufcount; /* IN/OUT */
76 	void **msgbufs;
77 };
78 
79 typedef struct {
80 	unsigned int handle;
81 	int blocking;
82 	unsigned int bufsize;
83 	void *buf;
84 } VCHIQ_DEQUEUE_MESSAGE_T;
85 
86 typedef struct {
87 	unsigned int config_size;
88 	struct vchiq_config __user *pconfig;
89 } VCHIQ_GET_CONFIG_T;
90 
91 typedef struct {
92 	unsigned int handle;
93 	VCHIQ_SERVICE_OPTION_T option;
94 	int value;
95 } VCHIQ_SET_SERVICE_OPTION_T;
96 
97 typedef struct {
98 	void     *virt_addr;
99 	size_t    num_bytes;
100 } VCHIQ_DUMP_MEM_T;
101 
102 #define VCHIQ_IOC_CONNECT              _IO(VCHIQ_IOC_MAGIC,   0)
103 #define VCHIQ_IOC_SHUTDOWN             _IO(VCHIQ_IOC_MAGIC,   1)
104 #define VCHIQ_IOC_CREATE_SERVICE \
105 	_IOWR(VCHIQ_IOC_MAGIC, 2, VCHIQ_CREATE_SERVICE_T)
106 #define VCHIQ_IOC_REMOVE_SERVICE       _IO(VCHIQ_IOC_MAGIC,   3)
107 #define VCHIQ_IOC_QUEUE_MESSAGE \
108 	_IOW(VCHIQ_IOC_MAGIC,  4, VCHIQ_QUEUE_MESSAGE_T)
109 #define VCHIQ_IOC_QUEUE_BULK_TRANSMIT \
110 	_IOWR(VCHIQ_IOC_MAGIC, 5, VCHIQ_QUEUE_BULK_TRANSFER_T)
111 #define VCHIQ_IOC_QUEUE_BULK_RECEIVE \
112 	_IOWR(VCHIQ_IOC_MAGIC, 6, VCHIQ_QUEUE_BULK_TRANSFER_T)
113 #define VCHIQ_IOC_AWAIT_COMPLETION \
114 	_IOWR(VCHIQ_IOC_MAGIC, 7, struct vchiq_await_completion)
115 #define VCHIQ_IOC_DEQUEUE_MESSAGE \
116 	_IOWR(VCHIQ_IOC_MAGIC, 8, VCHIQ_DEQUEUE_MESSAGE_T)
117 #define VCHIQ_IOC_GET_CLIENT_ID        _IO(VCHIQ_IOC_MAGIC,   9)
118 #define VCHIQ_IOC_GET_CONFIG \
119 	_IOWR(VCHIQ_IOC_MAGIC, 10, VCHIQ_GET_CONFIG_T)
120 #define VCHIQ_IOC_CLOSE_SERVICE        _IO(VCHIQ_IOC_MAGIC,   11)
121 #define VCHIQ_IOC_USE_SERVICE          _IO(VCHIQ_IOC_MAGIC,   12)
122 #define VCHIQ_IOC_RELEASE_SERVICE      _IO(VCHIQ_IOC_MAGIC,   13)
123 #define VCHIQ_IOC_SET_SERVICE_OPTION \
124 	_IOW(VCHIQ_IOC_MAGIC,  14, VCHIQ_SET_SERVICE_OPTION_T)
125 #define VCHIQ_IOC_DUMP_PHYS_MEM \
126 	_IOW(VCHIQ_IOC_MAGIC,  15, VCHIQ_DUMP_MEM_T)
127 #define VCHIQ_IOC_LIB_VERSION          _IO(VCHIQ_IOC_MAGIC,   16)
128 #define VCHIQ_IOC_CLOSE_DELIVERED      _IO(VCHIQ_IOC_MAGIC,   17)
129 #define VCHIQ_IOC_MAX                  17
130 
131 #endif
132