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 131 /* 132 * COMPAT_FREEBSD32 133 */ 134 135 typedef struct { 136 unsigned int config_size; 137 /*VCHIQ_CONFIG_T * */ uint32_t pconfig; 138 } VCHIQ_GET_CONFIG32_T; 139 140 typedef struct { 141 unsigned int handle; 142 /*void * */ uint32_t data; 143 unsigned int size; 144 /*void * */ uint32_t userdata; 145 VCHIQ_BULK_MODE_T mode; 146 } VCHIQ_QUEUE_BULK_TRANSFER32_T; 147 148 typedef struct { 149 unsigned int handle; 150 unsigned int count; 151 const /*VCHIQ_ELEMENT_T * */ uint32_t elements; 152 } VCHIQ_QUEUE_MESSAGE32_T; 153 154 typedef struct { 155 unsigned int handle; 156 int blocking; 157 unsigned int bufsize; 158 /*void * */ uint32_t buf; 159 } VCHIQ_DEQUEUE_MESSAGE32_T; 160 161 typedef struct { 162 /*void * */ uint32_t virt_addr; 163 /*size_t*/ uint32_t num_bytes; 164 } VCHIQ_DUMP_MEM32_T; 165 166 typedef struct { 167 VCHIQ_REASON_T reason; 168 /* VCHIQ_HEADER_T * */ uint32_t header; 169 /* void * */ uint32_t service_userdata; 170 /* void * */ uint32_t bulk_userdata; 171 } VCHIQ_COMPLETION_DATA32_T; 172 173 typedef struct { 174 unsigned int count; 175 /* VCHIQ_COMPLETION_DATA32_T * */ uint32_t buf; 176 unsigned int msgbufsize; 177 unsigned int msgbufcount; /* IN/OUT */ 178 /* void ** */ uint32_t msgbufs; 179 } VCHIQ_AWAIT_COMPLETION32_T; 180 181 typedef struct vchiq_service_params32_struct { 182 int fourcc; 183 /* VCHIQ_CALLBACK_T */ uint32_t callback; 184 /*void * */ uint32_t userdata; 185 short version; /* Increment for non-trivial changes */ 186 short version_min; /* Update for incompatible changes */ 187 } VCHIQ_SERVICE_PARAMS32_T; 188 189 typedef struct { 190 VCHIQ_SERVICE_PARAMS32_T params; 191 int is_open; 192 int is_vchi; 193 unsigned int handle; /* OUT */ 194 } VCHIQ_CREATE_SERVICE32_T; 195 196 typedef struct { 197 const /*void */ uint32_t data; 198 unsigned int size; 199 } VCHIQ_ELEMENT32_T; 200 201 202 #define VCHIQ_IOC_GET_CONFIG32 \ 203 _IOC_NEWTYPE( \ 204 VCHIQ_IOC_GET_CONFIG, \ 205 VCHIQ_GET_CONFIG32_T \ 206 ) 207 208 #define VCHIQ_IOC_QUEUE_BULK_TRANSMIT32 \ 209 _IOC_NEWTYPE( \ 210 VCHIQ_IOC_QUEUE_BULK_TRANSMIT, \ 211 VCHIQ_QUEUE_BULK_TRANSFER32_T \ 212 ) 213 214 #define VCHIQ_IOC_QUEUE_BULK_RECEIVE32 \ 215 _IOC_NEWTYPE( \ 216 VCHIQ_IOC_QUEUE_BULK_RECEIVE, \ 217 VCHIQ_QUEUE_BULK_TRANSFER32_T \ 218 ) 219 220 #define VCHIQ_IOC_QUEUE_MESSAGE32 \ 221 _IOC_NEWTYPE( \ 222 VCHIQ_IOC_QUEUE_MESSAGE, \ 223 VCHIQ_QUEUE_MESSAGE32_T \ 224 ) 225 226 #define VCHIQ_IOC_DEQUEUE_MESSAGE32 \ 227 _IOC_NEWTYPE( \ 228 VCHIQ_IOC_DEQUEUE_MESSAGE, \ 229 VCHIQ_DEQUEUE_MESSAGE32_T \ 230 ) 231 232 #define VCHIQ_IOC_DUMP_PHYS_MEM32 \ 233 _IOC_NEWTYPE( \ 234 VCHIQ_IOC_DUMP_PHYS_MEM, \ 235 VCHIQ_DUMP_MEM32_T \ 236 ) 237 238 #define VCHIQ_IOC_AWAIT_COMPLETION32 \ 239 _IOC_NEWTYPE( \ 240 VCHIQ_IOC_AWAIT_COMPLETION, \ 241 VCHIQ_AWAIT_COMPLETION32_T \ 242 ) 243 244 #define VCHIQ_IOC_CREATE_SERVICE32 \ 245 _IOC_NEWTYPE( \ 246 VCHIQ_IOC_CREATE_SERVICE, \ 247 VCHIQ_CREATE_SERVICE32_T \ 248 ) 249 250 251 #endif 252