1 <!-- Copyright (C) 2003 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 the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >Devtab Entries</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
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
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="usbs-start.html"
71 HREF="usbs-start-rx.html"
82 NAME="USBS-DEVTAB">Devtab Entries</H1
90 >Devtab Entries -- Data endpoint data structure</DIV
92 CLASS="REFSYNOPSISDIV"
119 >USB device drivers provide two ways of transferring data between host
120 and peripheral. The first involves USB-specific functionality such as
122 HREF="usbs-start-rx.html"
125 >usbs_start_rx_buffer</TT
128 This provides non-blocking I/O: a transfer is started, and some time
129 later the device driver will call a supplied completion function. The
130 second uses the conventional I/O model: there are entries in the
131 device table corresponding to the various endpoints. Standard calls
135 > can then be used to get a suitable
136 handle. Actual I/O happens via blocking <TT
143 > calls. In practice the blocking operations
144 are simply implemented using the underlying non-blocking
147 >Each endpoint will have its own devtab entry. The exact names are
148 controlled by the device driver package, but typically the root will
152 >. This is followed by one or more
153 decimal digits giving the endpoint number, followed by
157 > for a control endpoint, <TT
161 a receive endpoint (host to peripheral), and <TT
165 a transmit endpoint (peripheral to host). If the target hardware
166 involves more than one USB device then different roots should be used,
174 >. This may require explicit
175 manipulation of device driver configuration options by the application
178 >At present the devtab entry for a control endpoint does not support
179 any I/O operations. </P
194 > and similar functions in
195 higher-level packages can be used to perform a transfer from
196 peripheral to host. Successive write operations will not be coalesced.
197 For example, when doing a 1000 byte write to an endpoint that uses the
198 bulk transfer protocol this will involve 15 full-size 64-byte packets
199 and a terminating 40-byte packet. USB device drivers are not expected
200 to do any locking, and if higher-level code performs multiple
201 concurrent write operations on a single endpoint then the resulting
202 behaviour is undefined.</P
207 > operation will never transfer less
208 data than specified. It is the responsibility of higher-level code to
209 ensure that the amount of data being transferred is acceptable to the
210 host-side code. Usually this will be defined by a higher-level
211 protocol. If an attempt is made to transfer more data than the host
212 expects then the resulting behaviour is undefined.</P
214 >There are two likely error conditions. <TT
218 indicates that the connection between host and target has been broken.
222 > indicates that the endpoint has been
223 stalled, either at the request of the host or by other activity
224 inside the peripheral.</P
240 > and similar functions in higher-level
241 packages can be used to perform a transfer from host to peripheral.
242 This should be a complete transfer: higher-level protocols should
243 define an upper bound on the amount of data being transferred, and the
247 > operation should involve at least this
248 amount of data. The return value will indicate the actual transfer
249 size, which may be less than requested.</P
251 >Some device drivers may support partial reads, but USB device drivers
252 are not expected to perform any buffering because that involves both
253 memory and code overheads. One technique that may work for bulk
254 transfers is to exploit the fact that such transfers happen in 64-byte
255 packets. It is possible to <TT
259 bytes, corresponding to the first packet in the transfer. These 64
260 bytes can then be examined to determine the total transfer size, and
261 the remaining data can be transferred in another
265 > operation. This technique is not guaranteed
266 to work with all USB hardware. Also, if the delay between accepting
267 the first packet and the remainder of the transfer is excessive then
268 this could cause timeout problems for the host-side software. For
269 these reasons the use of partial reads should be avoided.</P
271 >There are two likely error conditions. <TT
275 indicates that the connection between host and target has been broken.
279 > indicates that the endpoint has been
280 stalled, either at the request of the host or by other activity
281 inside the peripheral.</P
283 >USB device drivers are not expected to do any locking. If higher-level
284 code performs multiple concurrent read operations on a single endpoint
285 then the resulting behaviour is undefined.</P
298 >Typical USB device drivers will not provide any support for
302 >. Consider bulk transfers from the host to
303 the peripheral. At the USB device driver level there is no way of
304 knowing in advance how large a transfer will be, so it is not feasible
305 for the device driver to buffer the entire transfer. It may be
306 possible to buffer part of the transfer, for example the first 64-byte
307 packet, and copy this into application space at the start of a
311 >, but this adds code and memory overheads.
312 Worse, it means that there is an unknown but potentially long delay
313 between a peripheral accepting the first packet of a transfer and the
314 remaining packets, which could confuse or upset the host-side
317 >With some USB hardware it may be possible for the device driver to
318 detect OUT tokens from the host without actually accepting the data,
319 and this would indicate that a <TT
323 succeed. However, it would not be reliable since the host-side I/O
324 operation could time out. A similar mechanism could be used to
328 > for outgoing data, but again
329 this would not be reliable.</P
331 >Some device drivers may provide partial support for
335 > anyway, possibly under the control of a
336 configuration option. The device driver's documentation should be
337 consulted for further information. It is also worth noting that the
338 USB-specific non-blocking API can often be used as an alternative to
370 >) operations defined for USB devices.
371 Some device drivers may provide hardware-specific facilities this way. </P
379 >Currently the USB-specific functions related to <A
380 HREF="usbs-halt.html"
382 > cannot be accessed readily
383 via devtab entries. This functionality should probably be made
391 >. It may also prove useful to provide
395 > operation that maps from the
396 devtab entries to the underlying endpoint data structures.</P
408 >The devtab entries are optional. If the USB device is accessed
409 primarily by class-specific code such as the USB-ethernet package and
410 that package uses the USB-specific API directly, the devtab entries
411 are redundant. Even if application code does need to access the USB
412 device, the non-blocking API may be more convenient than the blocking
413 I/O provided via the devtab entries. In these cases the devtab entries
414 serve no useful purpose, but they still impose a memory overhead. It
415 is possible to suppress the presence of these entries by disabling the
419 >CYGGLO_IO_USB_SLAVE_PROVIDE_DEVTAB_ENTRIES</TT
428 SUMMARY="Footer navigation table"
439 HREF="usbs-start.html"
457 HREF="usbs-start-rx.html"
467 >Starting up a USB Device</TD
473 HREF="io-usb-slave.html"
481 >Receiving Data from the Host</TD