Path: blob/main/sys/contrib/vchiq/interface/vchi/vchi_common.h
48383 views
/**1* Copyright (c) 2010-2012 Broadcom. All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions, and the following disclaimer,8* without modification.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. The names of the above-listed copyright holders may not be used13* to endorse or promote products derived from this software without14* specific prior written permission.15*16* ALTERNATIVELY, this software may be distributed under the terms of the17* GNU General Public License ("GPL") version 2, as published by the Free18* Software Foundation.19*20* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS21* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,22* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR23* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR24* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,25* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,26* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR27* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF28* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING29* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS30* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.31*/3233#ifndef VCHI_COMMON_H_34#define VCHI_COMMON_H_353637//flags used when sending messages (must be bitmapped)38typedef enum39{40VCHI_FLAGS_NONE = 0x0,41VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE = 0x1, // waits for message to be received, or sent (NB. not the same as being seen on other side)42VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE = 0x2, // run a callback when message sent43VCHI_FLAGS_BLOCK_UNTIL_QUEUED = 0x4, // return once the transfer is in a queue ready to go44VCHI_FLAGS_ALLOW_PARTIAL = 0x8,45VCHI_FLAGS_BLOCK_UNTIL_DATA_READ = 0x10,46VCHI_FLAGS_CALLBACK_WHEN_DATA_READ = 0x20,4748VCHI_FLAGS_ALIGN_SLOT = 0x000080, // internal use only49VCHI_FLAGS_BULK_AUX_QUEUED = 0x010000, // internal use only50VCHI_FLAGS_BULK_AUX_COMPLETE = 0x020000, // internal use only51VCHI_FLAGS_BULK_DATA_QUEUED = 0x040000, // internal use only52VCHI_FLAGS_BULK_DATA_COMPLETE = 0x080000, // internal use only53VCHI_FLAGS_INTERNAL = 0xFF000054} VCHI_FLAGS_T;5556// constants for vchi_crc_control()57typedef enum {58VCHI_CRC_NOTHING = -1,59VCHI_CRC_PER_SERVICE = 0,60VCHI_CRC_EVERYTHING = 1,61} VCHI_CRC_CONTROL_T;6263//callback reasons when an event occurs on a service64typedef enum65{66VCHI_CALLBACK_REASON_MIN,6768//This indicates that there is data available69//handle is the msg id that was transmitted with the data70// When a message is received and there was no FULL message available previously, send callback71// Tasks get kicked by the callback, reset their event and try and read from the fifo until it fails72VCHI_CALLBACK_MSG_AVAILABLE,73VCHI_CALLBACK_MSG_SENT,74VCHI_CALLBACK_MSG_SPACE_AVAILABLE, // XXX not yet implemented7576// This indicates that a transfer from the other side has completed77VCHI_CALLBACK_BULK_RECEIVED,78//This indicates that data queued up to be sent has now gone79//handle is the msg id that was used when sending the data80VCHI_CALLBACK_BULK_SENT,81VCHI_CALLBACK_BULK_RX_SPACE_AVAILABLE, // XXX not yet implemented82VCHI_CALLBACK_BULK_TX_SPACE_AVAILABLE, // XXX not yet implemented8384VCHI_CALLBACK_SERVICE_CLOSED,8586// this side has sent XOFF to peer due to lack of data consumption by service87// (suggests the service may need to take some recovery action if it has88// been deliberately holding off consuming data)89VCHI_CALLBACK_SENT_XOFF,90VCHI_CALLBACK_SENT_XON,9192// indicates that a bulk transfer has finished reading the source buffer93VCHI_CALLBACK_BULK_DATA_READ,9495// power notification events (currently host side only)96VCHI_CALLBACK_PEER_OFF,97VCHI_CALLBACK_PEER_SUSPENDED,98VCHI_CALLBACK_PEER_ON,99VCHI_CALLBACK_PEER_RESUMED,100VCHI_CALLBACK_FORCED_POWER_OFF,101102#ifdef USE_VCHIQ_ARM103// some extra notifications provided by vchiq_arm104VCHI_CALLBACK_SERVICE_OPENED,105VCHI_CALLBACK_BULK_RECEIVE_ABORTED,106VCHI_CALLBACK_BULK_TRANSMIT_ABORTED,107#endif108109VCHI_CALLBACK_REASON_MAX110} VCHI_CALLBACK_REASON_T;111112// service control options113typedef enum114{115VCHI_SERVICE_OPTION_MIN,116117VCHI_SERVICE_OPTION_TRACE,118VCHI_SERVICE_OPTION_SYNCHRONOUS,119120VCHI_SERVICE_OPTION_MAX121} VCHI_SERVICE_OPTION_T;122123124//Callback used by all services / bulk transfers125typedef void (*VCHI_CALLBACK_T)( void *callback_param, //my service local param126VCHI_CALLBACK_REASON_T reason,127void *handle ); //for transmitting msg's only128129130131/*132* Define vector struct for scatter-gather (vector) operations133* Vectors can be nested - if a vector element has negative length, then134* the data pointer is treated as pointing to another vector array, with135* '-vec_len' elements. Thus to append a header onto an existing vector,136* you can do this:137*138* void foo(const VCHI_MSG_VECTOR_T *v, int n)139* {140* VCHI_MSG_VECTOR_T nv[2];141* nv[0].vec_base = my_header;142* nv[0].vec_len = sizeof my_header;143* nv[1].vec_base = v;144* nv[1].vec_len = -n;145* ...146*147*/148typedef struct vchi_msg_vector {149const void *vec_base;150int32_t vec_len;151} VCHI_MSG_VECTOR_T;152153// Opaque type for a connection API154typedef struct opaque_vchi_connection_api_t VCHI_CONNECTION_API_T;155156// Opaque type for a message driver157typedef struct opaque_vchi_message_driver_t VCHI_MESSAGE_DRIVER_T;158159160// Iterator structure for reading ahead through received message queue. Allocated by client,161// initialised by vchi_msg_look_ahead. Fields are for internal VCHI use only.162// Iterates over messages in queue at the instant of the call to vchi_msg_lookahead -163// will not proceed to messages received since. Behaviour is undefined if an iterator164// is used again after messages for that service are removed/dequeued by any165// means other than vchi_msg_iter_... calls on the iterator itself.166typedef struct {167struct opaque_vchi_service_t *service;168void *last;169void *next;170void *remove;171} VCHI_MSG_ITER_T;172173174#endif // VCHI_COMMON_H_175176177