1 1.1 jmcneill /** 2 1.1 jmcneill * Copyright (c) 2010-2012 Broadcom. All rights reserved. 3 1.1 jmcneill * 4 1.1 jmcneill * Redistribution and use in source and binary forms, with or without 5 1.1 jmcneill * modification, are permitted provided that the following conditions 6 1.1 jmcneill * are met: 7 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright 8 1.1 jmcneill * notice, this list of conditions, and the following disclaimer, 9 1.1 jmcneill * without modification. 10 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright 11 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the 12 1.1 jmcneill * documentation and/or other materials provided with the distribution. 13 1.1 jmcneill * 3. The names of the above-listed copyright holders may not be used 14 1.1 jmcneill * to endorse or promote products derived from this software without 15 1.1 jmcneill * specific prior written permission. 16 1.1 jmcneill * 17 1.1 jmcneill * ALTERNATIVELY, this software may be distributed under the terms of the 18 1.1 jmcneill * GNU General Public License ("GPL") version 2, as published by the Free 19 1.1 jmcneill * Software Foundation. 20 1.1 jmcneill * 21 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 1.1 jmcneill * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 1.1 jmcneill * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 1.1 jmcneill * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 25 1.1 jmcneill * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 1.1 jmcneill * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 1.1 jmcneill * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 1.1 jmcneill * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 1.1 jmcneill * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 1.1 jmcneill * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 1.1 jmcneill * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 1.1 jmcneill */ 33 1.1 jmcneill 34 1.1 jmcneill #ifndef VCHI_COMMON_H_ 35 1.1 jmcneill #define VCHI_COMMON_H_ 36 1.1 jmcneill 37 1.1 jmcneill 38 1.1 jmcneill //flags used when sending messages (must be bitmapped) 39 1.1 jmcneill typedef enum 40 1.1 jmcneill { 41 1.1 jmcneill VCHI_FLAGS_NONE = 0x0, 42 1.1 jmcneill VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE = 0x1, // waits for message to be received, or sent (NB. not the same as being seen on other side) 43 1.1 jmcneill VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE = 0x2, // run a callback when message sent 44 1.1 jmcneill VCHI_FLAGS_BLOCK_UNTIL_QUEUED = 0x4, // return once the transfer is in a queue ready to go 45 1.1 jmcneill VCHI_FLAGS_ALLOW_PARTIAL = 0x8, 46 1.1 jmcneill VCHI_FLAGS_BLOCK_UNTIL_DATA_READ = 0x10, 47 1.1 jmcneill VCHI_FLAGS_CALLBACK_WHEN_DATA_READ = 0x20, 48 1.1 jmcneill 49 1.1 jmcneill VCHI_FLAGS_ALIGN_SLOT = 0x000080, // internal use only 50 1.1 jmcneill VCHI_FLAGS_BULK_AUX_QUEUED = 0x010000, // internal use only 51 1.1 jmcneill VCHI_FLAGS_BULK_AUX_COMPLETE = 0x020000, // internal use only 52 1.1 jmcneill VCHI_FLAGS_BULK_DATA_QUEUED = 0x040000, // internal use only 53 1.1 jmcneill VCHI_FLAGS_BULK_DATA_COMPLETE = 0x080000, // internal use only 54 1.1 jmcneill VCHI_FLAGS_INTERNAL = 0xFF0000 55 1.1 jmcneill } VCHI_FLAGS_T; 56 1.1 jmcneill 57 1.1 jmcneill // constants for vchi_crc_control() 58 1.1 jmcneill typedef enum { 59 1.1 jmcneill VCHI_CRC_NOTHING = -1, 60 1.1 jmcneill VCHI_CRC_PER_SERVICE = 0, 61 1.1 jmcneill VCHI_CRC_EVERYTHING = 1, 62 1.1 jmcneill } VCHI_CRC_CONTROL_T; 63 1.1 jmcneill 64 1.1 jmcneill //callback reasons when an event occurs on a service 65 1.1 jmcneill typedef enum 66 1.1 jmcneill { 67 1.1 jmcneill VCHI_CALLBACK_REASON_MIN, 68 1.1 jmcneill 69 1.1 jmcneill //This indicates that there is data available 70 1.1 jmcneill //handle is the msg id that was transmitted with the data 71 1.1 jmcneill // When a message is received and there was no FULL message available previously, send callback 72 1.1 jmcneill // Tasks get kicked by the callback, reset their event and try and read from the fifo until it fails 73 1.1 jmcneill VCHI_CALLBACK_MSG_AVAILABLE, 74 1.1 jmcneill VCHI_CALLBACK_MSG_SENT, 75 1.1 jmcneill VCHI_CALLBACK_MSG_SPACE_AVAILABLE, // XXX not yet implemented 76 1.1 jmcneill 77 1.1 jmcneill // This indicates that a transfer from the other side has completed 78 1.1 jmcneill VCHI_CALLBACK_BULK_RECEIVED, 79 1.1 jmcneill //This indicates that data queued up to be sent has now gone 80 1.1 jmcneill //handle is the msg id that was used when sending the data 81 1.1 jmcneill VCHI_CALLBACK_BULK_SENT, 82 1.1 jmcneill VCHI_CALLBACK_BULK_RX_SPACE_AVAILABLE, // XXX not yet implemented 83 1.1 jmcneill VCHI_CALLBACK_BULK_TX_SPACE_AVAILABLE, // XXX not yet implemented 84 1.1 jmcneill 85 1.1 jmcneill VCHI_CALLBACK_SERVICE_CLOSED, 86 1.1 jmcneill 87 1.1 jmcneill // this side has sent XOFF to peer due to lack of data consumption by service 88 1.1 jmcneill // (suggests the service may need to take some recovery action if it has 89 1.1 jmcneill // been deliberately holding off consuming data) 90 1.1 jmcneill VCHI_CALLBACK_SENT_XOFF, 91 1.1 jmcneill VCHI_CALLBACK_SENT_XON, 92 1.1 jmcneill 93 1.1 jmcneill // indicates that a bulk transfer has finished reading the source buffer 94 1.1 jmcneill VCHI_CALLBACK_BULK_DATA_READ, 95 1.1 jmcneill 96 1.1 jmcneill // power notification events (currently host side only) 97 1.1 jmcneill VCHI_CALLBACK_PEER_OFF, 98 1.1 jmcneill VCHI_CALLBACK_PEER_SUSPENDED, 99 1.1 jmcneill VCHI_CALLBACK_PEER_ON, 100 1.1 jmcneill VCHI_CALLBACK_PEER_RESUMED, 101 1.1 jmcneill VCHI_CALLBACK_FORCED_POWER_OFF, 102 1.1 jmcneill 103 1.1 jmcneill #ifdef USE_VCHIQ_ARM 104 1.1 jmcneill // some extra notifications provided by vchiq_arm 105 1.1 jmcneill VCHI_CALLBACK_SERVICE_OPENED, 106 1.1 jmcneill VCHI_CALLBACK_BULK_RECEIVE_ABORTED, 107 1.1 jmcneill VCHI_CALLBACK_BULK_TRANSMIT_ABORTED, 108 1.1 jmcneill #endif 109 1.1 jmcneill 110 1.1 jmcneill VCHI_CALLBACK_REASON_MAX 111 1.1 jmcneill } VCHI_CALLBACK_REASON_T; 112 1.1 jmcneill 113 1.2 skrll // service control options 114 1.2 skrll typedef enum 115 1.2 skrll { 116 1.2 skrll VCHI_SERVICE_OPTION_MIN, 117 1.2 skrll 118 1.2 skrll VCHI_SERVICE_OPTION_TRACE, 119 1.2 skrll VCHI_SERVICE_OPTION_SYNCHRONOUS, 120 1.2 skrll 121 1.2 skrll VCHI_SERVICE_OPTION_MAX 122 1.2 skrll } VCHI_SERVICE_OPTION_T; 123 1.2 skrll 124 1.2 skrll 125 1.2 skrll //Callback used by all services / bulk transfers 126 1.1 jmcneill typedef void (*VCHI_CALLBACK_T)( void *callback_param, //my service local param 127 1.1 jmcneill VCHI_CALLBACK_REASON_T reason, 128 1.1 jmcneill void *handle ); //for transmitting msg's only 129 1.1 jmcneill 130 1.1 jmcneill 131 1.1 jmcneill 132 1.1 jmcneill /* 133 1.1 jmcneill * Define vector struct for scatter-gather (vector) operations 134 1.1 jmcneill * Vectors can be nested - if a vector element has negative length, then 135 1.1 jmcneill * the data pointer is treated as pointing to another vector array, with 136 1.1 jmcneill * '-vec_len' elements. Thus to append a header onto an existing vector, 137 1.1 jmcneill * you can do this: 138 1.1 jmcneill * 139 1.1 jmcneill * void foo(const VCHI_MSG_VECTOR_T *v, int n) 140 1.1 jmcneill * { 141 1.1 jmcneill * VCHI_MSG_VECTOR_T nv[2]; 142 1.1 jmcneill * nv[0].vec_base = my_header; 143 1.1 jmcneill * nv[0].vec_len = sizeof my_header; 144 1.1 jmcneill * nv[1].vec_base = v; 145 1.1 jmcneill * nv[1].vec_len = -n; 146 1.1 jmcneill * ... 147 1.1 jmcneill * 148 1.1 jmcneill */ 149 1.1 jmcneill typedef struct vchi_msg_vector { 150 1.1 jmcneill const void *vec_base; 151 1.1 jmcneill int32_t vec_len; 152 1.1 jmcneill } VCHI_MSG_VECTOR_T; 153 1.1 jmcneill 154 1.1 jmcneill // Opaque type for a connection API 155 1.1 jmcneill typedef struct opaque_vchi_connection_api_t VCHI_CONNECTION_API_T; 156 1.1 jmcneill 157 1.1 jmcneill // Opaque type for a message driver 158 1.1 jmcneill typedef struct opaque_vchi_message_driver_t VCHI_MESSAGE_DRIVER_T; 159 1.1 jmcneill 160 1.1 jmcneill 161 1.1 jmcneill // Iterator structure for reading ahead through received message queue. Allocated by client, 162 1.1 jmcneill // initialised by vchi_msg_look_ahead. Fields are for internal VCHI use only. 163 1.1 jmcneill // Iterates over messages in queue at the instant of the call to vchi_msg_lookahead - 164 1.1 jmcneill // will not proceed to messages received since. Behaviour is undefined if an iterator 165 1.1 jmcneill // is used again after messages for that service are removed/dequeued by any 166 1.1 jmcneill // means other than vchi_msg_iter_... calls on the iterator itself. 167 1.1 jmcneill typedef struct { 168 1.1 jmcneill struct opaque_vchi_service_t *service; 169 1.1 jmcneill void *last; 170 1.1 jmcneill void *next; 171 1.1 jmcneill void *remove; 172 1.1 jmcneill } VCHI_MSG_ITER_T; 173 1.1 jmcneill 174 1.1 jmcneill 175 1.1 jmcneill #endif // VCHI_COMMON_H_ 176