1 |
27 |
unneback |
#ifndef CYGONCE_USBS_H
|
2 |
|
|
# define CYGONCE_USBS_H
|
3 |
|
|
//==========================================================================
|
4 |
|
|
//
|
5 |
|
|
// include/usbs.h
|
6 |
|
|
//
|
7 |
|
|
// The generic USB slave-side support
|
8 |
|
|
//
|
9 |
|
|
//==========================================================================
|
10 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
18 |
|
|
//
|
19 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
20 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
21 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
22 |
|
|
// for more details.
|
23 |
|
|
//
|
24 |
|
|
// You should have received a copy of the GNU General Public License along
|
25 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
26 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
27 |
|
|
//
|
28 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
29 |
|
|
// or inline functions from this file, or you compile this file and link it
|
30 |
|
|
// with other works to produce a work based on this file, this file does not
|
31 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
32 |
|
|
// License. However the source code for this file must still be made available
|
33 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
36 |
|
|
// this file might be covered by the GNU General Public License.
|
37 |
|
|
//
|
38 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
39 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//==========================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s): bartv
|
46 |
|
|
// Contributors: bartv
|
47 |
|
|
// Date: 2000-10-04
|
48 |
|
|
// Purpose:
|
49 |
|
|
// Description: USB slave-side support
|
50 |
|
|
//
|
51 |
|
|
//
|
52 |
|
|
//####DESCRIPTIONEND####
|
53 |
|
|
//==========================================================================
|
54 |
|
|
|
55 |
|
|
# include <pkgconf/system.h>
|
56 |
|
|
# include <cyg/infra/cyg_type.h>
|
57 |
|
|
# include <cyg/io/usb/usb.h>
|
58 |
|
|
|
59 |
|
|
#ifdef __cplusplus
|
60 |
|
|
extern "C" {
|
61 |
|
|
#endif
|
62 |
|
|
|
63 |
|
|
// The USB slave-side eCos support involves a number of different
|
64 |
|
|
// components:
|
65 |
|
|
//
|
66 |
|
|
// 1) a hardware-specific package to drive a specific chip implementation.
|
67 |
|
|
// This provides access to the endpoints. All the hardware-specific
|
68 |
|
|
// packages implement a common interface.
|
69 |
|
|
//
|
70 |
|
|
// 2) a common package (this one). This defines the interface implemented
|
71 |
|
|
// by the hardware-specific packages. It also provides support for
|
72 |
|
|
// the various generic control messages, using information provided
|
73 |
|
|
// by higher-level code and invoking callbacks as appropriate.
|
74 |
|
|
//
|
75 |
|
|
// 3) some number of support packages for particular types of
|
76 |
|
|
// application, for example ethernet or mass-storage.
|
77 |
|
|
//
|
78 |
|
|
// Typically there will only be one USB slave device, although the design
|
79 |
|
|
// does allow for multiple devices. Each device should provide a
|
80 |
|
|
// usbs_control_endpoint structure and zero or more usbs_data_endpoint
|
81 |
|
|
// structures. Each usbs_data_endpoint structure supports uni-directional
|
82 |
|
|
// transfers on a single endpoint. If an endpoint can support multiple
|
83 |
|
|
// types of transfer then there will be some control operation to switch
|
84 |
|
|
// between bulk, interrupt and isochronous.
|
85 |
|
|
//
|
86 |
|
|
// Access to the USB endpoints can go either via usbs_ calls which
|
87 |
|
|
// take a usbs_endpoint structure, or via open/read/write calls. The
|
88 |
|
|
// latter is more likely to be used in application code since it
|
89 |
|
|
// involves a familiar interface. The former is more appropriate for
|
90 |
|
|
// eCos packages layered on top of the USB code. The difference is
|
91 |
|
|
// synchronous vs. asynchronous: the open/read/write model involves
|
92 |
|
|
// blocking operations, implying a need for extra threads; the usbs_
|
93 |
|
|
// calls involve start operations and a completion callback. In
|
94 |
|
|
// practice the read and write calls are implemented using the
|
95 |
|
|
// lower-level code.
|
96 |
|
|
|
97 |
|
|
// Enumeration data. This requires information about the hardware,
|
98 |
|
|
// specifically what endpoints are available and what they get used
|
99 |
|
|
// for. It also requires information about the application class
|
100 |
|
|
// packages that are in the configuration, and quite possibly about
|
101 |
|
|
// things in application space. Some of the enumeration info such as
|
102 |
|
|
// the vendor id is inherently application-specific. Hence there is no
|
103 |
|
|
// way of generating part or all of the the enumeration information
|
104 |
|
|
// automatically, instead it is up to application code to supply this.
|
105 |
|
|
//
|
106 |
|
|
// The intention is that application provides all the data via const
|
107 |
|
|
// static objects, allowing the data to live in ROM. Alternatively the
|
108 |
|
|
// data structures can go into the .data section as normal, allowing
|
109 |
|
|
// them to be edited at run-time.
|
110 |
|
|
//
|
111 |
|
|
// There can be only one device descriptor, so that is part of the
|
112 |
|
|
// main enumeration data structure. There can be an unknown number of
|
113 |
|
|
// configurations so application code has to initialize an array of
|
114 |
|
|
// these. Ditto for interfaces and endpoints. The first x interfaces
|
115 |
|
|
// in the array correspond to the first configuration, the next y
|
116 |
|
|
// interfaces to the second configuration, etc. The endpoints array
|
117 |
|
|
// works in the same way.
|
118 |
|
|
//
|
119 |
|
|
// In the initial implementation multiple languages are not supported
|
120 |
|
|
// so a simple array of strings suffices. The first entry of these
|
121 |
|
|
// is still special in that it should define a single supported
|
122 |
|
|
// LANGID. All strings should be encoded as per the USB standard:
|
123 |
|
|
// a length field, a type code of USB_STRING_DESCRIPTOR_TYPE,
|
124 |
|
|
// and data in unicode format. In future multiple language support
|
125 |
|
|
// may be supported via configury with the default case remaining
|
126 |
|
|
// a single language, thus avoiding incompatibility problems.
|
127 |
|
|
|
128 |
|
|
typedef struct usbs_enumeration_data {
|
129 |
|
|
usb_device_descriptor device;
|
130 |
|
|
int total_number_interfaces;
|
131 |
|
|
int total_number_endpoints;
|
132 |
|
|
int total_number_strings;
|
133 |
|
|
const usb_configuration_descriptor* configurations;
|
134 |
|
|
const usb_interface_descriptor* interfaces;
|
135 |
|
|
const usb_endpoint_descriptor* endpoints;
|
136 |
|
|
const unsigned char** strings;
|
137 |
|
|
} usbs_enumeration_data;
|
138 |
|
|
|
139 |
|
|
// The current state of a USB device. This involves a bit to mark
|
140 |
|
|
// whether or not the device has been suspended, plus a state machine.
|
141 |
|
|
// On some hardware it may not be possible to distinguish between the
|
142 |
|
|
// detached, attached and powered states. If so then the initial state
|
143 |
|
|
// will be POWERED.
|
144 |
|
|
|
145 |
|
|
#define USBS_STATE_DETACHED 0x01
|
146 |
|
|
#define USBS_STATE_ATTACHED 0x02
|
147 |
|
|
#define USBS_STATE_POWERED 0x03
|
148 |
|
|
#define USBS_STATE_DEFAULT 0x04
|
149 |
|
|
#define USBS_STATE_ADDRESSED 0x05
|
150 |
|
|
#define USBS_STATE_CONFIGURED 0x06
|
151 |
|
|
#define USBS_STATE_MASK 0x7F
|
152 |
|
|
#define USBS_STATE_SUSPENDED (1 << 7)
|
153 |
|
|
|
154 |
|
|
// State changes. Application code or higher-level packages should
|
155 |
|
|
// install an appropriate state change function which will get
|
156 |
|
|
// invoked with details of the state change.
|
157 |
|
|
typedef enum {
|
158 |
|
|
USBS_STATE_CHANGE_DETACHED = 1,
|
159 |
|
|
USBS_STATE_CHANGE_ATTACHED = 2,
|
160 |
|
|
USBS_STATE_CHANGE_POWERED = 3,
|
161 |
|
|
USBS_STATE_CHANGE_RESET = 4,
|
162 |
|
|
USBS_STATE_CHANGE_ADDRESSED = 5,
|
163 |
|
|
USBS_STATE_CHANGE_CONFIGURED = 6,
|
164 |
|
|
USBS_STATE_CHANGE_DECONFIGURED = 7,
|
165 |
|
|
USBS_STATE_CHANGE_SUSPENDED = 8,
|
166 |
|
|
USBS_STATE_CHANGE_RESUMED = 9
|
167 |
|
|
} usbs_state_change;
|
168 |
|
|
|
169 |
|
|
typedef enum {
|
170 |
|
|
USBS_CONTROL_RETURN_HANDLED = 0,
|
171 |
|
|
USBS_CONTROL_RETURN_UNKNOWN = 1,
|
172 |
|
|
USBS_CONTROL_RETURN_STALL = 2
|
173 |
|
|
} usbs_control_return;
|
174 |
|
|
|
175 |
|
|
typedef struct usbs_control_endpoint {
|
176 |
|
|
// The state is maintained by the USB code and should not be
|
177 |
|
|
// modified by anything higher up.
|
178 |
|
|
int state;
|
179 |
|
|
|
180 |
|
|
// The enumeration data should be supplied by higher level code,
|
181 |
|
|
// usually the application. Often this data will be constant.
|
182 |
|
|
const usbs_enumeration_data* enumeration_data;
|
183 |
|
|
|
184 |
|
|
// This function pointer is supplied by the USB device driver.
|
185 |
|
|
// Application code should invoke it directly or via the
|
186 |
|
|
// usbs_start() function when the system is ready. Typically it
|
187 |
|
|
// will cause the USB lines to switch from tristate to active,
|
188 |
|
|
// and the USB host/hub should detect this.
|
189 |
|
|
void (*start_fn)(struct usbs_control_endpoint*);
|
190 |
|
|
|
191 |
|
|
// This function is used for polled operation when interrupts
|
192 |
|
|
// are disabled. This can happen in some debugging contexts.
|
193 |
|
|
// Higher-level code may also need to know about the interrupt
|
194 |
|
|
// number(s) used.
|
195 |
|
|
void (*poll_fn)(struct usbs_control_endpoint*);
|
196 |
|
|
int interrupt_vector;
|
197 |
|
|
|
198 |
|
|
// When a new control message arrives it will be in this buffer
|
199 |
|
|
// where the appropriate callback functions can examine it. The
|
200 |
|
|
// USB code will not modify the buffer unless a new control
|
201 |
|
|
// message arrives. The control_buffer can also be re-used
|
202 |
|
|
// by handlers to maintain some state information, e.g.
|
203 |
|
|
// for coping with complicated IN requests, but this is only
|
204 |
|
|
// allowed if they actually handle the request.
|
205 |
|
|
unsigned char control_buffer[8];
|
206 |
|
|
|
207 |
|
|
// This callback will be invoked by the USB code following a
|
208 |
|
|
// change in USB state, e.g. to SUSPENDED mode. Higher-level code
|
209 |
|
|
// should install a suitable function. There is some callback data
|
210 |
|
|
// as well. This gets passed explicitly to the callback function,
|
211 |
|
|
// in addition to the control endpoint structure. The reason is
|
212 |
|
|
// that the actual state change callback may be some sort of
|
213 |
|
|
// multiplexer inside a multifunction peripheral, and this
|
214 |
|
|
// multiplexer wants to invoke device-specific state change
|
215 |
|
|
// functions. However in simple devices those device-specific
|
216 |
|
|
// state change functions could be invoked directly.
|
217 |
|
|
void (*state_change_fn)(struct usbs_control_endpoint*, void*, usbs_state_change, int /* old state */);
|
218 |
|
|
void* state_change_data;
|
219 |
|
|
// When a standard control message arrives, the device driver will
|
220 |
|
|
// detect some requests such as SET_ADDRESS and handle it
|
221 |
|
|
// internally. Otherwise if higher-level code has installed a
|
222 |
|
|
// callback then that will be invoked. If the callback returns
|
223 |
|
|
// UNKNOWN then the default handler usbs_handle_standard_control()
|
224 |
|
|
// is used to process the request.
|
225 |
|
|
usbs_control_return (*standard_control_fn)(struct usbs_control_endpoint*, void*);
|
226 |
|
|
void* standard_control_data;
|
227 |
|
|
|
228 |
|
|
// These three callbacks are used for other types of control
|
229 |
|
|
// messages. The generic USB code has no way of knowing what
|
230 |
|
|
// such control messages are about.
|
231 |
|
|
usbs_control_return (*class_control_fn)(struct usbs_control_endpoint*, void*);
|
232 |
|
|
void* class_control_data;
|
233 |
|
|
usbs_control_return (*vendor_control_fn)(struct usbs_control_endpoint*, void*);
|
234 |
|
|
void* vendor_control_data;
|
235 |
|
|
usbs_control_return (*reserved_control_fn)(struct usbs_control_endpoint*, void*);
|
236 |
|
|
void* reserved_control_data;
|
237 |
|
|
|
238 |
|
|
// If a control operation involves transferring more data than
|
239 |
|
|
// just the initial eight-byte packet, the following fields are
|
240 |
|
|
// used to keep track of the current operation. The original
|
241 |
|
|
// control request indicates the direction of the transfer (IN or
|
242 |
|
|
// OUT) and a length field. For OUT this length is exact, for IN
|
243 |
|
|
// it is an upper bound. The transfer operates mostly as per the
|
244 |
|
|
// bulk protocol, but if the length requested is an exact multiple
|
245 |
|
|
// of the control fifo size (typically eight bytes) then there
|
246 |
|
|
// is no need for an empty packet at the end.
|
247 |
|
|
//
|
248 |
|
|
// For an OUT operation the control message handler should supply
|
249 |
|
|
// a suitable buffer via the "buffer" field below. The only other
|
250 |
|
|
// field of interest is the complete_fn which must be provided and
|
251 |
|
|
// will be invoked once all the data has arrived. Alternatively
|
252 |
|
|
// the OUT operation may get aborted if a new control message
|
253 |
|
|
// arrives. The second argument is an error code -EPIPE or -EIO,
|
254 |
|
|
// or zero to indicate success. The return code is used by the
|
255 |
|
|
// device driver during the status phase.
|
256 |
|
|
//
|
257 |
|
|
// IN is more complicated and the defined interface makes it
|
258 |
|
|
// possible to gather data from multiple locations, eliminating
|
259 |
|
|
// the need for copying into large buffers in some circumstances.
|
260 |
|
|
// Basically when an IN request arrives the device driver will
|
261 |
|
|
// look at the buffer and buffer_size fields, extracting data from
|
262 |
|
|
// there if possible. If the current buffer has been exhausted
|
263 |
|
|
// then the the refill function will be invoked, and this can
|
264 |
|
|
// reset the buffer and size fields to point somewhere else.
|
265 |
|
|
// This continues until such time that there is no longer
|
266 |
|
|
// a refill function and the current buffer is empty. The
|
267 |
|
|
// refill function can use the refill_data and refill_index
|
268 |
|
|
// to keep track of the current state. The control_buffer
|
269 |
|
|
// fields are available as well. At the end of the transfer,
|
270 |
|
|
// if a completion function has been supplied then it will
|
271 |
|
|
// be invoked. The return code will be ignored.
|
272 |
|
|
unsigned char* buffer;
|
273 |
|
|
int buffer_size;
|
274 |
|
|
void (*fill_buffer_fn)(struct usbs_control_endpoint*);
|
275 |
|
|
void* fill_data;
|
276 |
|
|
int fill_index;
|
277 |
|
|
usbs_control_return (*complete_fn)(struct usbs_control_endpoint*, int);
|
278 |
|
|
} usbs_control_endpoint;
|
279 |
|
|
|
280 |
|
|
// Data endpoints are a little bit simpler, but not much. From the
|
281 |
|
|
// perspective of a device driver things a single buffer is most
|
282 |
|
|
// convenient, but that is quite likely to require a max-size buffer
|
283 |
|
|
// at a higher level and an additional copy operation. Supplying
|
284 |
|
|
// a vector of buffers is a bit more general, but in a layered
|
285 |
|
|
// system it may be desirable to prepend to this vector...
|
286 |
|
|
// A combination of a current buffer and a refill/empty function
|
287 |
|
|
// offers flexibility, at the cost of additional function calls
|
288 |
|
|
// from inside the device driver.
|
289 |
|
|
//
|
290 |
|
|
// FIXME: implement support for fill/empty functions.
|
291 |
|
|
//
|
292 |
|
|
// Some USB devices may prefer buffers of particular alignment,
|
293 |
|
|
// e.g. for DMA purposes. This is hard to reconcile with the
|
294 |
|
|
// current interface. However pushing such alignment restrictions
|
295 |
|
|
// etc. up into the higher levels is difficult, e.g. it does
|
296 |
|
|
// not map at all onto a conventional read/write interface.
|
297 |
|
|
// The device driver will just have to do the best it can.
|
298 |
|
|
//
|
299 |
|
|
// The completion function will be invoked at the end of the transfer.
|
300 |
|
|
// The second argument indicates per-transfer completion data. The
|
301 |
|
|
// third argument indicates the total amount received, or an error
|
302 |
|
|
// code: typically -EPIPE to indicate a broken conenction; -EAGAIN to
|
303 |
|
|
// indicate a stall condition; -EMSGSIZE if the host is sending more
|
304 |
|
|
// data than the target is expecting; or -EIO to indicate some other
|
305 |
|
|
// error. Individual device drivers should avoid generating other
|
306 |
|
|
// errors.
|
307 |
|
|
typedef struct usbs_rx_endpoint {
|
308 |
|
|
void (*start_rx_fn)(struct usbs_rx_endpoint*);
|
309 |
|
|
void (*set_halted_fn)(struct usbs_rx_endpoint*, cyg_bool);
|
310 |
|
|
void (*complete_fn)(void*, int);
|
311 |
|
|
void* complete_data;
|
312 |
|
|
unsigned char* buffer;
|
313 |
|
|
int buffer_size;
|
314 |
|
|
cyg_bool halted;
|
315 |
|
|
} usbs_rx_endpoint;
|
316 |
|
|
|
317 |
|
|
typedef struct usbs_tx_endpoint {
|
318 |
|
|
void (*start_tx_fn)(struct usbs_tx_endpoint*);
|
319 |
|
|
void (*set_halted_fn)(struct usbs_tx_endpoint*, cyg_bool);
|
320 |
|
|
void (*complete_fn)(void*, int);
|
321 |
|
|
void* complete_data;
|
322 |
|
|
const unsigned char*buffer;
|
323 |
|
|
int buffer_size;
|
324 |
|
|
cyg_bool halted;
|
325 |
|
|
} usbs_tx_endpoint;
|
326 |
|
|
|
327 |
|
|
// Functions called by device drivers.
|
328 |
|
|
extern usbs_control_return usbs_handle_standard_control(struct usbs_control_endpoint*);
|
329 |
|
|
|
330 |
|
|
// Utility functions. These just invoke the corresponding function
|
331 |
|
|
// pointers in the endpoint structures. It is assumed that the
|
332 |
|
|
// necessary fields in the endpoint structures will have been
|
333 |
|
|
// filled in already.
|
334 |
|
|
extern void usbs_start(usbs_control_endpoint*);
|
335 |
|
|
extern void usbs_start_rx(usbs_rx_endpoint*);
|
336 |
|
|
extern void usbs_start_tx(usbs_tx_endpoint*);
|
337 |
|
|
extern void usbs_start_rx_buffer(usbs_rx_endpoint*, unsigned char*, int, void (*)(void*, int), void*);
|
338 |
|
|
extern void usbs_start_tx_buffer(usbs_tx_endpoint*, const unsigned char*, int, void (*)(void*, int), void*);
|
339 |
|
|
extern cyg_bool usbs_rx_endpoint_halted(usbs_rx_endpoint*);
|
340 |
|
|
extern cyg_bool usbs_tx_endpoint_halted(usbs_tx_endpoint*);
|
341 |
|
|
extern void usbs_set_rx_endpoint_halted(usbs_rx_endpoint*, cyg_bool);
|
342 |
|
|
extern void usbs_set_tx_endpoint_halted(usbs_tx_endpoint*, cyg_bool);
|
343 |
|
|
extern void usbs_start_rx_endpoint_wait(usbs_rx_endpoint*, void (*)(void*, int), void*);
|
344 |
|
|
extern void usbs_start_tx_endpoint_wait(usbs_tx_endpoint*, void (*)(void*, int), void*);
|
345 |
|
|
|
346 |
|
|
// Functions that can go into devtab entries. These should not be
|
347 |
|
|
// called directly, they are intended only for use by USB device
|
348 |
|
|
// drivers.
|
349 |
|
|
#if defined(CYGPKG_IO) && defined(CYGPKG_ERROR)
|
350 |
|
|
#include <cyg/io/io.h>
|
351 |
|
|
extern Cyg_ErrNo usbs_devtab_cwrite(cyg_io_handle_t, const void*, cyg_uint32*);
|
352 |
|
|
extern Cyg_ErrNo usbs_devtab_cread(cyg_io_handle_t, void*, cyg_uint32*);
|
353 |
|
|
extern Cyg_ErrNo usbs_devtab_get_config(cyg_io_handle_t, cyg_uint32, void*, cyg_uint32*);
|
354 |
|
|
extern Cyg_ErrNo usbs_devtab_set_config(cyg_io_handle_t, cyg_uint32, const void*, cyg_uint32*);
|
355 |
|
|
#endif
|
356 |
|
|
|
357 |
|
|
// Additional support for testing.
|
358 |
|
|
// Test cases need to have some way of finding out about what support is
|
359 |
|
|
// actually provided by the USB device driver, for example what endpoints
|
360 |
|
|
// are available. There is no perfect way of achieving this. One approach
|
361 |
|
|
// would be to scan through the devtab table looking for devices of the
|
362 |
|
|
// form /dev/usbs1r. That is not reliable: the devtab entries may have been
|
363 |
|
|
// configured out if higher-level code uses the usb-specific API; or the
|
364 |
|
|
// devtab entries may have been renamed. Also having a devtab entry does not
|
365 |
|
|
// really give the kind of information a general-purpose testcase needs,
|
366 |
|
|
// for example upper bounds on transfer size.
|
367 |
|
|
//
|
368 |
|
|
// An alternative approach is to have a data structure that somehow
|
369 |
|
|
// defines the USB hardware, and the USB device driver then creates an
|
370 |
|
|
// instance of this. This is the approach actually taken. The problem
|
371 |
|
|
// now is how the test code can access this instance. Accessing by
|
372 |
|
|
// unique name is simple, as long as there is only one USB device in
|
373 |
|
|
// the system (which of course will usually be the case on the USB
|
374 |
|
|
// slave side). Alternative approaches such as creating a table at
|
375 |
|
|
// link time or a list during static construction time are vulnerable
|
376 |
|
|
// either to selective linking or to having these structures present
|
377 |
|
|
// in applications other than the test cases. In future it might be
|
378 |
|
|
// possible to address the latter issue by extending the build system
|
379 |
|
|
// support, e.g. a new library libtesting.a and a new object file
|
380 |
|
|
// testing.o.
|
381 |
|
|
//
|
382 |
|
|
// Note that a given endpoint could be used for bulk transfers some
|
383 |
|
|
// of the time, then for isochronous transfers, etc. It is the
|
384 |
|
|
// responsibility of the host to only perform one type of IN operation
|
385 |
|
|
// for a given endpoint number, and ditto for OUT.
|
386 |
|
|
|
387 |
|
|
typedef struct usbs_testing_endpoint {
|
388 |
|
|
int endpoint_type; // One of ATTR_CONTROL, ATTR_BULK, ...
|
389 |
|
|
int endpoint_number; // Between 0 and 15
|
390 |
|
|
int endpoint_direction; // ENDPOINT_IN or ENDPOINT_OUT
|
391 |
|
|
void* endpoint; // pointer to the usbs_control_endpoint, usbs_rx_endpoint, ...
|
392 |
|
|
const char* devtab_entry; // e.g. "/dev/usbs1r", or 0 if inaccessible via devtab
|
393 |
|
|
int min_size; // Minimum transfer size
|
394 |
|
|
int max_size; // -1 indicates no specific upper bound
|
395 |
|
|
int max_in_padding; // extra bytes that the target may send, usually 0.
|
396 |
|
|
// Primarily for SA11x0 hardware. It is assumed
|
397 |
|
|
// for now that no other hardware will exhibit
|
398 |
|
|
// comparable problems.
|
399 |
|
|
int alignment; // Buffer should be aligned to a suitable boundary
|
400 |
|
|
} usbs_testing_endpoint;
|
401 |
|
|
|
402 |
|
|
// A specific instance provided by the device driver. The end of
|
403 |
|
|
// the table is indicated by a NULL endpoint field.
|
404 |
|
|
extern usbs_testing_endpoint usbs_testing_endpoints[];
|
405 |
|
|
|
406 |
|
|
#define USBS_TESTING_ENDPOINTS_TERMINATOR \
|
407 |
|
|
{ \
|
408 |
|
|
endpoint_type : USB_ENDPOINT_DESCRIPTOR_ATTR_CONTROL, \
|
409 |
|
|
endpoint_number : 0, \
|
410 |
|
|
endpoint_direction : USB_ENDPOINT_DESCRIPTOR_ENDPOINT_IN, \
|
411 |
|
|
endpoint : (void*) 0, \
|
412 |
|
|
devtab_entry : (const char*) 0, \
|
413 |
|
|
min_size : 0, \
|
414 |
|
|
max_size : 0, \
|
415 |
|
|
max_in_padding : 0, \
|
416 |
|
|
alignment : 0 \
|
417 |
|
|
}
|
418 |
|
|
|
419 |
|
|
#define USBS_TESTING_ENDPOINTS_IS_TERMINATOR(_endpoint_) ((void*)0 == (_endpoint_).endpoint)
|
420 |
|
|
|
421 |
|
|
#ifdef __cplusplus
|
422 |
|
|
} // extern "C" {
|
423 |
|
|
#endif
|
424 |
|
|
|
425 |
|
|
#endif // CYGONCE_USBS_H
|
426 |
|
|
|