1 <!-- Copyright (C) 2002 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of substantively modified versions of this -->
7 <!-- document is prohibited without the explicit permission of the -->
8 <!-- copyright holder. -->
9 <!-- Distribution of the work or derivative of the work in any -->
10 <!-- standard (paper) book form is prohibited unless prior -->
11 <!-- permission is obtained from the copyright holder. -->
15 >Devtab Entries</TITLE
16 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
19 CONTENT="Modular DocBook HTML Stylesheet Version 1.64
22 TITLE="eCos USB Slave Support"
23 HREF="io-usb-slave.html"><LINK
25 TITLE="Starting up a USB Device"
26 HREF="usbs-start.html"><LINK
28 TITLE="Receiving Data from the Host"
29 HREF="usbs-start-rx.html"></HEAD
48 >eCos USB Slave Support</TH
56 HREF="usbs-start.html"
69 HREF="usbs-start-rx.html"
89 >Devtab Entries -- Data endpoint data structure</DIV
91 CLASS="REFSYNOPSISDIV"
120 >USB device drivers provide two ways of transferring data between host
121 and peripheral. The first involves USB-specific functionality such as
123 HREF="usbs-start-rx.html"
126 >usbs_start_rx_buffer</TT
129 This provides non-blocking I/O: a transfer is started, and some time
130 later the device driver will call a supplied completion function. The
131 second uses the conventional I/O model: there are entries in the
132 device table corresponding to the various endpoints. Standard calls
136 > can then be used to get a suitable
137 handle. Actual I/O happens via blocking <TT
144 > calls. In practice the blocking operations
145 are simply implemented using the underlying non-blocking
148 >Each endpoint will have its own devtab entry. The exact names are
149 controlled by the device driver package, but typically the root will
153 >. This is followed by one or more
154 decimal digits giving the endpoint number, followed by
158 > for a control endpoint, <TT
162 a receive endpoint (host to peripheral), and <TT
166 a transmit endpoint (peripheral to host). If the target hardware
167 involves more than one USB device then different roots should be used,
175 >. This may require explicit
176 manipulation of device driver configuration options by the application
179 >At present the devtab entry for a control endpoint does not support
180 any I/O operations. </P
195 > and similar functions in
196 higher-level packages can be used to perform a transfer from
197 peripheral to host. Successive write operations will not be coalesced.
198 For example, when doing a 1000 byte write to an endpoint that uses the
199 bulk transfer protocol this will involve 15 full-size 64-byte packets
200 and a terminating 40-byte packet. USB device drivers are not expected
201 to do any locking, and if higher-level code performs multiple
202 concurrent write operations on a single endpoint then the resulting
203 behaviour is undefined.</P
208 > operation will never transfer less
209 data than specified. It is the responsibility of higher-level code to
210 ensure that the amount of data being transferred is acceptable to the
211 host-side code. Usually this will be defined by a higher-level
212 protocol. If an attempt is made to transfer more data than the host
213 expects then the resulting behaviour is undefined.</P
215 >There are two likely error conditions. <TT
219 indicates that the connection between host and target has been broken.
223 > indicates that the endpoint has been
224 stalled, either at the request of the host or by other activity
225 inside the peripheral.</P
241 > and similar functions in higher-level
242 packages can be used to perform a transfer from host to peripheral.
243 This should be a complete transfer: higher-level protocols should
244 define an upper bound on the amount of data being transferred, and the
248 > operation should involve at least this
249 amount of data. The return value will indicate the actual transfer
250 size, which may be less than requested.</P
252 >Some device drivers may support partial reads, but USB device drivers
253 are not expected to perform any buffering because that involves both
254 memory and code overheads. One technique that may work for bulk
255 transfers is to exploit the fact that such transfers happen in 64-byte
256 packets. It is possible to <TT
260 bytes, corresponding to the first packet in the transfer. These 64
261 bytes can then be examined to determine the total transfer size, and
262 the remaining data can be transferred in another
266 > operation. This technique is not guaranteed
267 to work with all USB hardware. Also, if the delay between accepting
268 the first packet and the remainder of the transfer is excessive then
269 this could cause timeout problems for the host-side software. For
270 these reasons the use of partial reads should be avoided.</P
272 >There are two likely error conditions. <TT
276 indicates that the connection between host and target has been broken.
280 > indicates that the endpoint has been
281 stalled, either at the request of the host or by other activity
282 inside the peripheral.</P
284 >USB device drivers are not expected to do any locking. If higher-level
285 code performs multiple concurrent read operations on a single endpoint
286 then the resulting behaviour is undefined.</P
299 >Typical USB device drivers will not provide any support for
303 >. Consider bulk transfers from the host to
304 the peripheral. At the USB device driver level there is no way of
305 knowing in advance how large a transfer will be, so it is not feasible
306 for the device driver to buffer the entire transfer. It may be
307 possible to buffer part of the transfer, for example the first 64-byte
308 packet, and copy this into application space at the start of a
312 >, but this adds code and memory overheads.
313 Worse, it means that there is an unknown but potentially long delay
314 between a peripheral accepting the first packet of a transfer and the
315 remaining packets, which could confuse or upset the host-side
318 >With some USB hardware it may be possible for the device driver to
319 detect OUT tokens from the host without actually accepting the data,
320 and this would indicate that a <TT
324 succeed. However, it would not be reliable since the host-side I/O
325 operation could time out. A similar mechanism could be used to
329 > for outgoing data, but again
330 this would not be reliable.</P
332 >Some device drivers may provide partial support for
336 > anyway, possibly under the control of a
337 configuration option. The device driver's documentation should be
338 consulted for further information. It is also worth noting that the
339 USB-specific non-blocking API can often be used as an alternative to
371 >) operations defined for USB devices.
372 Some device drivers may provide hardware-specific facilities this way. </P
380 >Currently the USB-specific functions related to <A
381 HREF="usbs-halt.html"
383 > cannot be accessed readily
384 via devtab entries. This functionality should probably be made
392 >. It may also prove useful to provide
396 > operation that maps from the
397 devtab entries to the underlying endpoint data structures.</P
409 >The devtab entries are optional. If the USB device is accessed
410 primarily by class-specific code such as the USB-ethernet package and
411 that package uses the USB-specific API directly, the devtab entries
412 are redundant. Even if application code does need to access the USB
413 device, the non-blocking API may be more convenient than the blocking
414 I/O provided via the devtab entries. In these cases the devtab entries
415 serve no useful purpose, but they still impose a memory overhead. It
416 is possible to suppress the presence of these entries by disabling the
420 >CYGGLO_IO_USB_SLAVE_PROVIDE_DEVTAB_ENTRIES</TT
439 HREF="usbs-start.html"
447 HREF="io-usb-slave.html"
455 HREF="usbs-start-rx.html"
464 >Starting up a USB Device</TD
474 >Receiving Data from the Host</TD