Skip to content

Commit 54afb78

Browse files
committed
Update to match latest vc side vchiq. Allows vchiq calls from kernel.
1 parent ecab818 commit 54afb78

File tree

15 files changed

+2370
-118
lines changed

15 files changed

+2370
-118
lines changed

drivers/misc/vc04_services/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ obj-$(CONFIG_BCM2708_VCHIQ) += vchiq.o
22

33
vchiq-objs := \
44
interface/vchiq_arm/vchiq_core.o \
5+
interface/vchiq_arm/vchiq_shim.o \
6+
interface/vchiq_arm/vchiq_util.o \
57
interface/vchiq_arm/vchiq_arm.o \
68
interface/vchiq_arm/vchiq_kern_lib.o \
79
interface/vchiq_arm/vchiq_2835_arm.o \
@@ -13,7 +15,7 @@ vchiq-objs := \
1315
interface/vcos/generic/vcos_mem_from_malloc.o \
1416
interface/vcos/generic/vcos_cmd.o
1517

16-
EXTRA_CFLAGS += -DVCOS_VERIFY_BKPTS=1 -Idrivers/misc/vc04_services -Idrivers/misc/vc04_services/interface/vcos/linuxkernel
18+
EXTRA_CFLAGS += -DVCOS_VERIFY_BKPTS=1 -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -Idrivers/misc/vc04_services -Idrivers/misc/vc04_services/interface/vcos/linuxkernel
1719

1820

1921

Lines changed: 309 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
1+
/*
2+
* Copyright (c) 2010-2011 Broadcom Corporation. All rights reserved.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17+
*/
18+
19+
#ifndef CONNECTION_H_
20+
#define CONNECTION_H_
21+
22+
#include "interface/vchi/vchi_cfg_internal.h"
23+
#include "interface/vchi/vchi_common.h"
24+
#include "interface/vchi/message_drivers/message.h"
25+
26+
/******************************************************************************
27+
Global defs
28+
*****************************************************************************/
29+
30+
// Opaque handle for a connection / service pair
31+
typedef struct opaque_vchi_connection_connected_service_handle_t *VCHI_CONNECTION_SERVICE_HANDLE_T;
32+
33+
// opaque handle to the connection state information
34+
typedef struct opaque_vchi_connection_info_t VCHI_CONNECTION_STATE_T;
35+
36+
typedef struct vchi_connection_t VCHI_CONNECTION_T;
37+
38+
39+
/******************************************************************************
40+
API
41+
*****************************************************************************/
42+
43+
// Routine to init a connection with a particular low level driver
44+
typedef VCHI_CONNECTION_STATE_T * (*VCHI_CONNECTION_INIT_T)( struct vchi_connection_t * connection,
45+
const VCHI_MESSAGE_DRIVER_T * driver );
46+
47+
// Routine to control CRC enabling at a connection level
48+
typedef int32_t (*VCHI_CONNECTION_CRC_CONTROL_T)( VCHI_CONNECTION_STATE_T *state_handle,
49+
VCHI_CRC_CONTROL_T control );
50+
51+
// Routine to create a service
52+
typedef int32_t (*VCHI_CONNECTION_SERVICE_CONNECT_T)( VCHI_CONNECTION_STATE_T *state_handle,
53+
vcos_fourcc_t service_id,
54+
uint32_t rx_fifo_size,
55+
uint32_t tx_fifo_size,
56+
int server,
57+
VCHI_CALLBACK_T callback,
58+
void *callback_param,
59+
vcos_bool_t want_crc,
60+
vcos_bool_t want_unaligned_bulk_rx,
61+
vcos_bool_t want_unaligned_bulk_tx,
62+
VCHI_CONNECTION_SERVICE_HANDLE_T *service_handle );
63+
64+
// Routine to close a service
65+
typedef int32_t (*VCHI_CONNECTION_SERVICE_DISCONNECT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle );
66+
67+
// Routine to queue a message
68+
typedef int32_t (*VCHI_CONNECTION_SERVICE_QUEUE_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
69+
const void *data,
70+
uint32_t data_size,
71+
VCHI_FLAGS_T flags,
72+
void *msg_handle );
73+
74+
// scatter-gather (vector) message queueing
75+
typedef int32_t (*VCHI_CONNECTION_SERVICE_QUEUE_MESSAGEV_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
76+
VCHI_MSG_VECTOR_T *vector,
77+
uint32_t count,
78+
VCHI_FLAGS_T flags,
79+
void *msg_handle );
80+
81+
// Routine to dequeue a message
82+
typedef int32_t (*VCHI_CONNECTION_SERVICE_DEQUEUE_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
83+
void *data,
84+
uint32_t max_data_size_to_read,
85+
uint32_t *actual_msg_size,
86+
VCHI_FLAGS_T flags );
87+
88+
// Routine to peek at a message
89+
typedef int32_t (*VCHI_CONNECTION_SERVICE_PEEK_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
90+
void **data,
91+
uint32_t *msg_size,
92+
VCHI_FLAGS_T flags );
93+
94+
// Routine to hold a message
95+
typedef int32_t (*VCHI_CONNECTION_SERVICE_HOLD_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
96+
void **data,
97+
uint32_t *msg_size,
98+
VCHI_FLAGS_T flags,
99+
void **message_handle );
100+
101+
// Routine to initialise a received message iterator
102+
typedef int32_t (*VCHI_CONNECTION_SERVICE_LOOKAHEAD_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
103+
VCHI_MSG_ITER_T *iter,
104+
VCHI_FLAGS_T flags );
105+
106+
// Routine to release a held message
107+
typedef int32_t (*VCHI_CONNECTION_HELD_MSG_RELEASE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
108+
void *message_handle );
109+
110+
// Routine to get info on a held message
111+
typedef int32_t (*VCHI_CONNECTION_HELD_MSG_INFO_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
112+
void *message_handle,
113+
void **data,
114+
int32_t *msg_size,
115+
uint32_t *tx_timestamp,
116+
uint32_t *rx_timestamp );
117+
118+
// Routine to check whether the iterator has a next message
119+
typedef vcos_bool_t (*VCHI_CONNECTION_MSG_ITER_HAS_NEXT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,
120+
const VCHI_MSG_ITER_T *iter );
121+
122+
// Routine to advance the iterator
123+
typedef int32_t (*VCHI_CONNECTION_MSG_ITER_NEXT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,
124+
VCHI_MSG_ITER_T *iter,
125+
void **data,
126+
uint32_t *msg_size );
127+
128+
// Routine to remove the last message returned by the iterator
129+
typedef int32_t (*VCHI_CONNECTION_MSG_ITER_REMOVE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,
130+
VCHI_MSG_ITER_T *iter );
131+
132+
// Routine to hold the last message returned by the iterator
133+
typedef int32_t (*VCHI_CONNECTION_MSG_ITER_HOLD_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,
134+
VCHI_MSG_ITER_T *iter,
135+
void **msg_handle );
136+
137+
// Routine to transmit bulk data
138+
typedef int32_t (*VCHI_CONNECTION_BULK_QUEUE_TRANSMIT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
139+
const void *data_src,
140+
uint32_t data_size,
141+
VCHI_FLAGS_T flags,
142+
void *bulk_handle );
143+
144+
// Routine to receive data
145+
typedef int32_t (*VCHI_CONNECTION_BULK_QUEUE_RECEIVE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
146+
void *data_dst,
147+
uint32_t data_size,
148+
VCHI_FLAGS_T flags,
149+
void *bulk_handle );
150+
151+
// Routine to report if a server is available
152+
typedef int32_t (*VCHI_CONNECTION_SERVER_PRESENT)( VCHI_CONNECTION_STATE_T *state, vcos_fourcc_t service_id, int32_t peer_flags );
153+
154+
// Routine to report the number of RX slots available
155+
typedef int (*VCHI_CONNECTION_RX_SLOTS_AVAILABLE)( const VCHI_CONNECTION_STATE_T *state );
156+
157+
// Routine to report the RX slot size
158+
typedef uint32_t (*VCHI_CONNECTION_RX_SLOT_SIZE)( const VCHI_CONNECTION_STATE_T *state );
159+
160+
// Callback to indicate that the other side has added a buffer to the rx bulk DMA FIFO
161+
typedef void (*VCHI_CONNECTION_RX_BULK_BUFFER_ADDED)(VCHI_CONNECTION_STATE_T *state,
162+
vcos_fourcc_t service,
163+
uint32_t length,
164+
MESSAGE_TX_CHANNEL_T channel,
165+
uint32_t channel_params,
166+
uint32_t data_length,
167+
uint32_t data_offset);
168+
169+
// Callback to inform a service that a Xon or Xoff message has been received
170+
typedef void (*VCHI_CONNECTION_FLOW_CONTROL)(VCHI_CONNECTION_STATE_T *state, vcos_fourcc_t service_id, int32_t xoff);
171+
172+
// Callback to inform a service that a server available reply message has been received
173+
typedef void (*VCHI_CONNECTION_SERVER_AVAILABLE_REPLY)(VCHI_CONNECTION_STATE_T *state, vcos_fourcc_t service_id, uint32_t flags);
174+
175+
// Callback to indicate that bulk auxiliary messages have arrived
176+
typedef void (*VCHI_CONNECTION_BULK_AUX_RECEIVED)(VCHI_CONNECTION_STATE_T *state);
177+
178+
// Callback to indicate that bulk auxiliary messages have arrived
179+
typedef void (*VCHI_CONNECTION_BULK_AUX_TRANSMITTED)(VCHI_CONNECTION_STATE_T *state, void *handle);
180+
181+
// Callback with all the connection info you require
182+
typedef void (*VCHI_CONNECTION_INFO)(VCHI_CONNECTION_STATE_T *state, uint32_t protocol_version, uint32_t slot_size, uint32_t num_slots, uint32_t min_bulk_size);
183+
184+
// Callback to inform of a disconnect
185+
typedef void (*VCHI_CONNECTION_DISCONNECT)(VCHI_CONNECTION_STATE_T *state, uint32_t flags);
186+
187+
// Callback to inform of a power control request
188+
typedef void (*VCHI_CONNECTION_POWER_CONTROL)(VCHI_CONNECTION_STATE_T *state, MESSAGE_TX_CHANNEL_T channel, vcos_bool_t enable);
189+
190+
// allocate memory suitably aligned for this connection
191+
typedef void * (*VCHI_BUFFER_ALLOCATE)(VCHI_CONNECTION_SERVICE_HANDLE_T service_handle, uint32_t * length);
192+
193+
// free memory allocated by buffer_allocate
194+
typedef void (*VCHI_BUFFER_FREE)(VCHI_CONNECTION_SERVICE_HANDLE_T service_handle, void * address);
195+
196+
197+
/******************************************************************************
198+
System driver struct
199+
*****************************************************************************/
200+
201+
struct opaque_vchi_connection_api_t
202+
{
203+
// Routine to init the connection
204+
VCHI_CONNECTION_INIT_T init;
205+
206+
// Connection-level CRC control
207+
VCHI_CONNECTION_CRC_CONTROL_T crc_control;
208+
209+
// Routine to connect to or create service
210+
VCHI_CONNECTION_SERVICE_CONNECT_T service_connect;
211+
212+
// Routine to disconnect from a service
213+
VCHI_CONNECTION_SERVICE_DISCONNECT_T service_disconnect;
214+
215+
// Routine to queue a message
216+
VCHI_CONNECTION_SERVICE_QUEUE_MESSAGE_T service_queue_msg;
217+
218+
// scatter-gather (vector) message queue
219+
VCHI_CONNECTION_SERVICE_QUEUE_MESSAGEV_T service_queue_msgv;
220+
221+
// Routine to dequeue a message
222+
VCHI_CONNECTION_SERVICE_DEQUEUE_MESSAGE_T service_dequeue_msg;
223+
224+
// Routine to peek at a message
225+
VCHI_CONNECTION_SERVICE_PEEK_MESSAGE_T service_peek_msg;
226+
227+
// Routine to hold a message
228+
VCHI_CONNECTION_SERVICE_HOLD_MESSAGE_T service_hold_msg;
229+
230+
// Routine to initialise a received message iterator
231+
VCHI_CONNECTION_SERVICE_LOOKAHEAD_MESSAGE_T service_look_ahead_msg;
232+
233+
// Routine to release a message
234+
VCHI_CONNECTION_HELD_MSG_RELEASE_T held_msg_release;
235+
236+
// Routine to get information on a held message
237+
VCHI_CONNECTION_HELD_MSG_INFO_T held_msg_info;
238+
239+
// Routine to check for next message on iterator
240+
VCHI_CONNECTION_MSG_ITER_HAS_NEXT_T msg_iter_has_next;
241+
242+
// Routine to get next message on iterator
243+
VCHI_CONNECTION_MSG_ITER_NEXT_T msg_iter_next;
244+
245+
// Routine to remove the last message returned by iterator
246+
VCHI_CONNECTION_MSG_ITER_REMOVE_T msg_iter_remove;
247+
248+
// Routine to hold the last message returned by iterator
249+
VCHI_CONNECTION_MSG_ITER_HOLD_T msg_iter_hold;
250+
251+
// Routine to transmit bulk data
252+
VCHI_CONNECTION_BULK_QUEUE_TRANSMIT_T bulk_queue_transmit;
253+
254+
// Routine to receive data
255+
VCHI_CONNECTION_BULK_QUEUE_RECEIVE_T bulk_queue_receive;
256+
257+
// Routine to report the available servers
258+
VCHI_CONNECTION_SERVER_PRESENT server_present;
259+
260+
// Routine to report the number of RX slots available
261+
VCHI_CONNECTION_RX_SLOTS_AVAILABLE connection_rx_slots_available;
262+
263+
// Routine to report the RX slot size
264+
VCHI_CONNECTION_RX_SLOT_SIZE connection_rx_slot_size;
265+
266+
// Callback to indicate that the other side has added a buffer to the rx bulk DMA FIFO
267+
VCHI_CONNECTION_RX_BULK_BUFFER_ADDED rx_bulk_buffer_added;
268+
269+
// Callback to inform a service that a Xon or Xoff message has been received
270+
VCHI_CONNECTION_FLOW_CONTROL flow_control;
271+
272+
// Callback to inform a service that a server available reply message has been received
273+
VCHI_CONNECTION_SERVER_AVAILABLE_REPLY server_available_reply;
274+
275+
// Callback to indicate that bulk auxiliary messages have arrived
276+
VCHI_CONNECTION_BULK_AUX_RECEIVED bulk_aux_received;
277+
278+
// Callback to indicate that a bulk auxiliary message has been transmitted
279+
VCHI_CONNECTION_BULK_AUX_TRANSMITTED bulk_aux_transmitted;
280+
281+
// Callback to provide information about the connection
282+
VCHI_CONNECTION_INFO connection_info;
283+
284+
// Callback to notify that peer has requested disconnect
285+
VCHI_CONNECTION_DISCONNECT disconnect;
286+
287+
// Callback to notify that peer has requested power change
288+
VCHI_CONNECTION_POWER_CONTROL power_control;
289+
290+
// allocate memory suitably aligned for this connection
291+
VCHI_BUFFER_ALLOCATE buffer_allocate;
292+
293+
// free memory allocated by buffer_allocate
294+
VCHI_BUFFER_FREE buffer_free;
295+
296+
};
297+
298+
struct vchi_connection_t {
299+
const VCHI_CONNECTION_API_T *api;
300+
VCHI_CONNECTION_STATE_T *state;
301+
#ifdef VCHI_COARSE_LOCKING
302+
VCOS_SEMAPHORE_T sem;
303+
#endif
304+
};
305+
306+
307+
#endif /* CONNECTION_H_ */
308+
309+
/****************************** End of file **********************************/

0 commit comments

Comments
 (0)