1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ 3 4 #ifndef VCHI_COMMON_H_ 5 #define VCHI_COMMON_H_ 6 7 //flags used when sending messages (must be bitmapped) 8 typedef enum { 9 VCHI_FLAGS_NONE = 0x0, 10 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) 11 VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE = 0x2, // run a callback when message sent 12 VCHI_FLAGS_BLOCK_UNTIL_QUEUED = 0x4, // return once the transfer is in a queue ready to go 13 VCHI_FLAGS_ALLOW_PARTIAL = 0x8, 14 VCHI_FLAGS_BLOCK_UNTIL_DATA_READ = 0x10, 15 VCHI_FLAGS_CALLBACK_WHEN_DATA_READ = 0x20, 16 17 VCHI_FLAGS_ALIGN_SLOT = 0x000080, // internal use only 18 VCHI_FLAGS_BULK_AUX_QUEUED = 0x010000, // internal use only 19 VCHI_FLAGS_BULK_AUX_COMPLETE = 0x020000, // internal use only 20 VCHI_FLAGS_BULK_DATA_QUEUED = 0x040000, // internal use only 21 VCHI_FLAGS_BULK_DATA_COMPLETE = 0x080000, // internal use only 22 VCHI_FLAGS_INTERNAL = 0xFF0000 23 } VCHI_FLAGS_T; 24 25 // constants for vchi_crc_control() 26 typedef enum { 27 VCHI_CRC_NOTHING = -1, 28 VCHI_CRC_PER_SERVICE = 0, 29 VCHI_CRC_EVERYTHING = 1, 30 } VCHI_CRC_CONTROL_T; 31 32 //callback reasons when an event occurs on a service 33 typedef enum { 34 VCHI_CALLBACK_REASON_MIN, 35 36 //This indicates that there is data available 37 //handle is the msg id that was transmitted with the data 38 // When a message is received and there was no FULL message available previously, send callback 39 // Tasks get kicked by the callback, reset their event and try and read from the fifo until it fails 40 VCHI_CALLBACK_MSG_AVAILABLE, 41 VCHI_CALLBACK_MSG_SENT, 42 VCHI_CALLBACK_MSG_SPACE_AVAILABLE, // XXX not yet implemented 43 44 // This indicates that a transfer from the other side has completed 45 VCHI_CALLBACK_BULK_RECEIVED, 46 //This indicates that data queued up to be sent has now gone 47 //handle is the msg id that was used when sending the data 48 VCHI_CALLBACK_BULK_SENT, 49 VCHI_CALLBACK_BULK_RX_SPACE_AVAILABLE, // XXX not yet implemented 50 VCHI_CALLBACK_BULK_TX_SPACE_AVAILABLE, // XXX not yet implemented 51 52 VCHI_CALLBACK_SERVICE_CLOSED, 53 54 // this side has sent XOFF to peer due to lack of data consumption by service 55 // (suggests the service may need to take some recovery action if it has 56 // been deliberately holding off consuming data) 57 VCHI_CALLBACK_SENT_XOFF, 58 VCHI_CALLBACK_SENT_XON, 59 60 // indicates that a bulk transfer has finished reading the source buffer 61 VCHI_CALLBACK_BULK_DATA_READ, 62 63 // power notification events (currently host side only) 64 VCHI_CALLBACK_PEER_OFF, 65 VCHI_CALLBACK_PEER_SUSPENDED, 66 VCHI_CALLBACK_PEER_ON, 67 VCHI_CALLBACK_PEER_RESUMED, 68 VCHI_CALLBACK_FORCED_POWER_OFF, 69 70 // some extra notifications provided by vchiq_arm 71 VCHI_CALLBACK_SERVICE_OPENED, 72 VCHI_CALLBACK_BULK_RECEIVE_ABORTED, 73 VCHI_CALLBACK_BULK_TRANSMIT_ABORTED, 74 75 VCHI_CALLBACK_REASON_MAX 76 } VCHI_CALLBACK_REASON_T; 77 78 // service control options 79 typedef enum { 80 VCHI_SERVICE_OPTION_MIN, 81 82 VCHI_SERVICE_OPTION_TRACE, 83 VCHI_SERVICE_OPTION_SYNCHRONOUS, 84 85 VCHI_SERVICE_OPTION_MAX 86 } VCHI_SERVICE_OPTION_T; 87 88 //Callback used by all services / bulk transfers 89 typedef void (*VCHI_CALLBACK_T)(void *callback_param, //my service local param 90 VCHI_CALLBACK_REASON_T reason, 91 void *handle); //for transmitting msg's only 92 93 /* 94 * Define vector struct for scatter-gather (vector) operations 95 * Vectors can be nested - if a vector element has negative length, then 96 * the data pointer is treated as pointing to another vector array, with 97 * '-vec_len' elements. Thus to append a header onto an existing vector, 98 * you can do this: 99 * 100 * void foo(const struct vchi_msg_vector *v, int n) 101 * { 102 * struct vchi_msg_vector nv[2]; 103 * nv[0].vec_base = my_header; 104 * nv[0].vec_len = sizeof my_header; 105 * nv[1].vec_base = v; 106 * nv[1].vec_len = -n; 107 * ... 108 * 109 */ 110 struct vchi_msg_vector { 111 const void *vec_base; 112 int32_t vec_len; 113 }; 114 115 // Opaque type for a connection API 116 typedef struct opaque_vchi_connection_api_t VCHI_CONNECTION_API_T; 117 118 // Opaque type for a message driver 119 typedef struct opaque_vchi_message_driver_t VCHI_MESSAGE_DRIVER_T; 120 121 // Iterator structure for reading ahead through received message queue. Allocated by client, 122 // initialised by vchi_msg_look_ahead. Fields are for internal VCHI use only. 123 // Iterates over messages in queue at the instant of the call to vchi_msg_lookahead - 124 // will not proceed to messages received since. Behaviour is undefined if an iterator 125 // is used again after messages for that service are removed/dequeued by any 126 // means other than vchi_msg_iter_... calls on the iterator itself. 127 struct vchi_msg_iter { 128 struct opaque_vchi_service_t *service; 129 void *last; 130 void *next; 131 void *remove; 132 }; 133 134 #endif // VCHI_COMMON_H_