1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */
7 //flags used when sending messages (must be bitmapped)
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,
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
25 // constants for vchi_crc_control()
26 enum vchi_crc_control {
27 VCHI_CRC_NOTHING = -1,
28 VCHI_CRC_PER_SERVICE = 0,
29 VCHI_CRC_EVERYTHING = 1,
32 //callback reasons when an event occurs on a service
33 enum vchi_callback_reason {
34 VCHI_CALLBACK_REASON_MIN,
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
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
52 VCHI_CALLBACK_SERVICE_CLOSED,
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,
60 // indicates that a bulk transfer has finished reading the source buffer
61 VCHI_CALLBACK_BULK_DATA_READ,
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,
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,
75 VCHI_CALLBACK_REASON_MAX
78 // service control options
79 enum vchi_service_option {
80 VCHI_SERVICE_OPTION_MIN,
82 VCHI_SERVICE_OPTION_TRACE,
83 VCHI_SERVICE_OPTION_SYNCHRONOUS,
85 VCHI_SERVICE_OPTION_MAX
88 //Callback used by all services / bulk transfers
89 typedef void (*vchi_callback)(void *callback_param, //my service local param
90 enum vchi_callback_reason reason,
91 void *handle); //for transmitting msg's only
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,
100 * void foo(const struct vchi_msg_vector *v, int n)
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;
110 struct vchi_msg_vector {
111 const void *vec_base;
115 // Iterator structure for reading ahead through received message queue. Allocated by client,
116 // initialised by vchi_msg_look_ahead. Fields are for internal VCHI use only.
117 // Iterates over messages in queue at the instant of the call to vchi_msg_lookahead -
118 // will not proceed to messages received since. Behaviour is undefined if an iterator
119 // is used again after messages for that service are removed/dequeued by any
120 // means other than vchi_msg_iter_... calls on the iterator itself.
121 struct vchi_msg_iter {
122 struct opaque_vchi_service_t *service;
128 #endif // VCHI_COMMON_H_