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