1 |
27 |
unneback |
#ifndef CYGONCE_USBS_ETH_H
|
2 |
|
|
#define CYGONCE_USBS_ETH_H_
|
3 |
|
|
//==========================================================================
|
4 |
|
|
//
|
5 |
|
|
// include/usbs_eth.h
|
6 |
|
|
//
|
7 |
|
|
// Description of the USB slave-side ethernet 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 ethernet support
|
50 |
|
|
//
|
51 |
|
|
//
|
52 |
|
|
//####DESCRIPTIONEND####
|
53 |
|
|
//==========================================================================
|
54 |
|
|
|
55 |
|
|
#ifdef __cplusplus
|
56 |
|
|
extern "C" {
|
57 |
|
|
#endif
|
58 |
|
|
|
59 |
|
|
//
|
60 |
|
|
// The primary purpose of the USB slave-side ethernet code is to
|
61 |
|
|
// provide an ethernet service for the host. Essentially this means
|
62 |
|
|
// the following:
|
63 |
|
|
//
|
64 |
|
|
// 1) the host can transmit an ethernet frame to the USB peripheral.
|
65 |
|
|
// This frame is received by the code in this package and then
|
66 |
|
|
// passed up to higher-level code for processing. Typically the
|
67 |
|
|
// frame will originate from a TCP/IP stack running inside the
|
68 |
|
|
// host, and the higher-level code will forward the frame via a
|
69 |
|
|
// real ethernet chip or some other ethernet-style device.
|
70 |
|
|
//
|
71 |
|
|
// 2) higher-level code will provide ethernet frames to be sent to
|
72 |
|
|
// the host, usually to a TCP/IP stack running on the host. The
|
73 |
|
|
// exact source of the ethernet frame is not known.
|
74 |
|
|
//
|
75 |
|
|
// 3) the host may initiate a number of control operations, for
|
76 |
|
|
// example it may request the MAC address or it may want to
|
77 |
|
|
// control the filtering mode (e.g. enable promiscuous mode).
|
78 |
|
|
//
|
79 |
|
|
// 4) there are USB control-related operations, for example actions
|
80 |
|
|
// to be taken when the peripheral is disconnected from the
|
81 |
|
|
// bus or when the host wants to disable the ethernet interface.
|
82 |
|
|
//
|
83 |
|
|
// It is possible to develop a USB ethernet peripheral that does not
|
84 |
|
|
// involve a TCP/IP stack inside the peripheral, in fact that is the
|
85 |
|
|
// most common implementation. Instead a typical peripheral would
|
86 |
|
|
// involve a USB port, an ethernet port, and a cheap microcontroller
|
87 |
|
|
// just powerful enough to forward packets between the two. The eCos
|
88 |
|
|
// USB code can be used in this way, and the primary external
|
89 |
|
|
// interface provides enough functionality for this to work.
|
90 |
|
|
//
|
91 |
|
|
// +---------------+ ethernet
|
92 |
|
|
// +----+ | | |
|
93 |
|
|
// | | USB | app | |
|
94 |
|
|
// |host|---------| / \ |-----o
|
95 |
|
|
// | | | / \ | |
|
96 |
|
|
// +----+ | USB-eth eth | |
|
97 |
|
|
// +---------------+ |
|
98 |
|
|
// USB peripheral
|
99 |
|
|
//
|
100 |
|
|
// Note that the USB-ethernet code does not know anything about the
|
101 |
|
|
// real ethernet device or what the application gets up to, it just
|
102 |
|
|
// provides an interface to the app. The above represents just one
|
103 |
|
|
// possible use for a USB-ethernet device.
|
104 |
|
|
//
|
105 |
|
|
// Also worth mentioning: when the host TCP/IP stack requests the MAC
|
106 |
|
|
// address USB-eth would normally respond with the MAC address for the
|
107 |
|
|
// real ethernet device. That way things like host-side DHCP should
|
108 |
|
|
// just work.
|
109 |
|
|
//
|
110 |
|
|
// Alternatively for some applications it is desirable to run a TCP/IP
|
111 |
|
|
// stack inside the peripheral as well as on the host. This makes
|
112 |
|
|
// things a fair bit more complicated, something like this.
|
113 |
|
|
//
|
114 |
|
|
// +---------------+
|
115 |
|
|
// | app |
|
116 |
|
|
// | | | ethernet
|
117 |
|
|
// +----+ | | | |
|
118 |
|
|
// | | USB | TCP/IP | |
|
119 |
|
|
// |host|---------| / \ |-----o
|
120 |
|
|
// | | | / \ | |
|
121 |
|
|
// +----+ | USB-eth eth | |
|
122 |
|
|
// +---------------+ |
|
123 |
|
|
// USB peripheral
|
124 |
|
|
//
|
125 |
|
|
//
|
126 |
|
|
// Usually this will involve enabling the bridge code in the TCP/IP
|
127 |
|
|
// stack, or possibly performing some sort of bridging below the
|
128 |
|
|
// TCP/IP stack. One way of getting things to work is to view the
|
129 |
|
|
// USB connection as a small ethernet segment with just two
|
130 |
|
|
// attached machines, the host and the peripheral. The two will
|
131 |
|
|
// need separate MAC addresses, in addition to the MAC address
|
132 |
|
|
// for the real ethernet device. This way the bridge code
|
133 |
|
|
// sees things the way it expects.
|
134 |
|
|
//
|
135 |
|
|
// There will still be some subtle differences between a setup like
|
136 |
|
|
// this and a conventional ethernet bridge, mainly because there
|
137 |
|
|
// is a host-side TCP/IP stack which can perform control operations.
|
138 |
|
|
// For example the host stack may request that USB-eth go into
|
139 |
|
|
// promiscuous mode. A conventional ethernet bridge just deals
|
140 |
|
|
// with ethernet segments and does not need to worry about
|
141 |
|
|
// control requests coming in from one of the segments.
|
142 |
|
|
//
|
143 |
|
|
// It is not absolutely essential that there is another network.
|
144 |
|
|
// However without another network this setup would look to the host
|
145 |
|
|
// like an ethernet segment with just two machines attached to it, the
|
146 |
|
|
// host itself and the USB peripheral, yet it still involves all the
|
147 |
|
|
// complexities of ethernet such as broadcast masks and IP subnets.
|
148 |
|
|
// Anything along these lines is likely to prove somewhat confusing,
|
149 |
|
|
// and the USB peripheral should probably act like some other class
|
150 |
|
|
// of USB device instead.
|
151 |
|
|
//
|
152 |
|
|
// One special setup has the host acting as a bridge to another
|
153 |
|
|
// network, rather than the peripheral. This might make sense for
|
154 |
|
|
// mobile peripherals such as PDA's, as a way of connecting the
|
155 |
|
|
// peripheral to an existing LAN without needing a LAN adapter.
|
156 |
|
|
// Enabling bridging in the host may be a complex operation, limiting
|
157 |
|
|
// the applicability of such a setup.
|
158 |
|
|
//
|
159 |
|
|
// This package will only implement the eCos network driver interface
|
160 |
|
|
// if explicitly enabled. The package-specific interface is always
|
161 |
|
|
// provided, although trying to mix and match the two may lead to
|
162 |
|
|
// terrible confusion: once the network driver is active nothing else
|
163 |
|
|
// should use the lower-level USB ethernet code. However application
|
164 |
|
|
// code is responsible for initializing the package, and specifically
|
165 |
|
|
// for providing details of the USB endpoints that should be used.
|
166 |
|
|
//
|
167 |
|
|
// The package assumes that it needs to provide just one
|
168 |
|
|
// instantiation. Conceivably there may be applications where it makes
|
169 |
|
|
// sense for a USB peripheral to supply two separate ethernet devices
|
170 |
|
|
// to the host, but that would be an unusual setup. Also a peripheral
|
171 |
|
|
// might provide two or more USB slave ports to allow multiple hosts
|
172 |
|
|
// to be connected, with a separate USB-ethernet instantiation for
|
173 |
|
|
// each port, but again that would be an unusual setup. Applications
|
174 |
|
|
// which do require more than one instantiation are responsible
|
175 |
|
|
// for doing this inside the application code.
|
176 |
|
|
|
177 |
|
|
// The public interface depends on configuration options.
|
178 |
|
|
#include <pkgconf/io_usb_slave_eth.h>
|
179 |
|
|
|
180 |
|
|
// Define the interface in terms of eCos data types.
|
181 |
|
|
#include <cyg/infra/cyg_type.h>
|
182 |
|
|
|
183 |
|
|
// The generic USB support
|
184 |
|
|
#include <cyg/io/usb/usbs.h>
|
185 |
|
|
|
186 |
|
|
// Network driver definition, to support cloning of usbs_eth_netdev0
|
187 |
|
|
#ifdef CYGPKG_USBS_ETHDRV
|
188 |
|
|
# include <cyg/io/eth/netdev.h>
|
189 |
|
|
#endif
|
190 |
|
|
|
191 |
|
|
// Cache details, to allow alignment to cache line boundaries etc.
|
192 |
|
|
#include <cyg/hal/hal_cache.h>
|
193 |
|
|
|
194 |
|
|
// ----------------------------------------------------------------------------
|
195 |
|
|
// Maximum transfer size. This is not specified by io/eth. It can be
|
196 |
|
|
// determined from <netinet/if_ether.h> but the TCP/IP stack may not
|
197 |
|
|
// be loaded so that header file cannot be used.
|
198 |
|
|
//
|
199 |
|
|
// Some (most?) USB implementations have implementation problems. For
|
200 |
|
|
// example the SA11x0 family cannot support transfers that are exact
|
201 |
|
|
// multiples of the 64-byte USB bulk packet size, instead it is
|
202 |
|
|
// necessary to add explicit size information. This can be encoded
|
203 |
|
|
// conveniently at the start of the buffer.
|
204 |
|
|
//
|
205 |
|
|
// So the actual MTU consists of:
|
206 |
|
|
// 1) a 1500 byte payload
|
207 |
|
|
// 2) the usual ethernet header with a six-byte source MAC
|
208 |
|
|
// address, a six-byte destination MAC address, and a
|
209 |
|
|
// two-byte protocol or length field, for a total header
|
210 |
|
|
// size of 14 bytes.
|
211 |
|
|
// 3) an extra two bytes of size info.
|
212 |
|
|
//
|
213 |
|
|
// For a total of 1516 bytes.
|
214 |
|
|
#define CYGNUM_USBS_ETH_MAX_FRAME_SIZE 1514
|
215 |
|
|
#define CYGNUM_USBS_ETH_MAXTU (CYGNUM_USBS_ETH_MAX_FRAME_SIZE + 2)
|
216 |
|
|
|
217 |
|
|
// Although the minimum ethernet frame size is 60 bytes, this includes
|
218 |
|
|
// padding which is not needed when transferring over USB. Hence the
|
219 |
|
|
// actual minimum is just the 14 byte ethernet header plus two bytes
|
220 |
|
|
// for the length.
|
221 |
|
|
#define CYGNUM_USBS_ETH_MIN_FRAME_SIZE 14
|
222 |
|
|
#define CYGNUM_USBS_ETH_MINTU (CYGNUM_USBS_ETH_MIN_FRAME_SIZE + 2)
|
223 |
|
|
|
224 |
|
|
// Typical USB devices involve DMA operations and hence confusion
|
225 |
|
|
// between cached and uncached memory. To make life easier for
|
226 |
|
|
// the underlying USB device drivers, this package ensures that
|
227 |
|
|
// receive operations always involve buffers that are aligned to
|
228 |
|
|
// a cache-line boundary and that are a multiple of the cacheline
|
229 |
|
|
// size.
|
230 |
|
|
#ifndef HAL_DCACHE_LINE_SIZE
|
231 |
|
|
# define CYGNUM_USBS_ETH_RXBUFSIZE CYGNUM_USBS_ETH_MAXTU
|
232 |
|
|
# define CYGNUM_USBS_ETH_RXSIZE CYGNUM_USBS_ETH_MAXTU
|
233 |
|
|
#else
|
234 |
|
|
# define CYGNUM_USBS_ETH_RXBUFSIZE ((CYGNUM_USBS_ETH_MAXTU + HAL_DCACHE_LINE_SIZE + HAL_DCACHE_LINE_SIZE - 1) \
|
235 |
|
|
& ~(HAL_DCACHE_LINE_SIZE - 1))
|
236 |
|
|
# define CYGNUM_USBS_ETH_RXSIZE ((CYGNUM_USBS_ETH_MAXTU + HAL_DCACHE_LINE_SIZE - 1) & ~(HAL_DCACHE_LINE_SIZE - 1))
|
237 |
|
|
#endif
|
238 |
|
|
|
239 |
|
|
// ----------------------------------------------------------------------------
|
240 |
|
|
// This data structure serves two purposes. First, it keeps track of
|
241 |
|
|
// the information needed by the low-level USB ethernet code, for
|
242 |
|
|
// example which endpoints should be used for incoming and outgoing
|
243 |
|
|
// packets. Second, if the support for the TCP/IP stack is enabled
|
244 |
|
|
// then there are additional fields to support that (e.g. for keeping
|
245 |
|
|
// track of statistics).
|
246 |
|
|
//
|
247 |
|
|
// Arguably the two uses should be separated into distinct data
|
248 |
|
|
// structures. That would make it possible to instantiate multiple
|
249 |
|
|
// low-level USB-ethernet devices but only have a network driver for
|
250 |
|
|
// one of them. Achieving that flexibility would require some extra
|
251 |
|
|
// indirection, affecting performance and code-size, and it is not
|
252 |
|
|
// clear that that flexibility would ever prove useful. For now having
|
253 |
|
|
// a single data structure seems more appropriate.
|
254 |
|
|
|
255 |
|
|
typedef struct usbs_eth {
|
256 |
|
|
|
257 |
|
|
// What endpoints should be used for communication?
|
258 |
|
|
usbs_control_endpoint* control_endpoint;
|
259 |
|
|
usbs_rx_endpoint* rx_endpoint;
|
260 |
|
|
usbs_tx_endpoint* tx_endpoint;
|
261 |
|
|
|
262 |
|
|
// Is the host ready to receive packets? This state is determined
|
263 |
|
|
// largely by control packets sent from the host. It can change at
|
264 |
|
|
// DSR level.
|
265 |
|
|
volatile cyg_bool host_up;
|
266 |
|
|
|
267 |
|
|
// Has the host-side set promiscuous mode? This is relevant to the
|
268 |
|
|
// network driver which may need to do filtering based on the MAC
|
269 |
|
|
// address and host-side promiscuity.
|
270 |
|
|
volatile cyg_bool host_promiscuous;
|
271 |
|
|
|
272 |
|
|
// The host MAC address. This is the address supplied to the
|
273 |
|
|
// host's TCP/IP stack and filled in by the init function. There
|
274 |
|
|
// is no real hardware to extract the address from.
|
275 |
|
|
unsigned char host_MAC[6];
|
276 |
|
|
|
277 |
|
|
// Needed for callback operations.
|
278 |
|
|
void (*tx_callback_fn)(struct usbs_eth*, void*, int);
|
279 |
|
|
void* tx_callback_arg;
|
280 |
|
|
|
281 |
|
|
void (*rx_callback_fn)(struct usbs_eth*, void*, int);
|
282 |
|
|
void* rx_callback_arg;
|
283 |
|
|
|
284 |
|
|
// RX operations just block if the host is not connected, resuming
|
285 |
|
|
// when a connection is established. This means saving the buffer
|
286 |
|
|
// pointer so that when the host comes back up the rx operation
|
287 |
|
|
// proper can start. This is not quite consistent because if the
|
288 |
|
|
// connection breaks while an RX is in progress there will be a
|
289 |
|
|
// callback with an error code whereas an RX on a broken
|
290 |
|
|
// connection just blocks, but this does fit neatly into an
|
291 |
|
|
// event-driven I/O model.
|
292 |
|
|
unsigned char* rx_pending_buf;
|
293 |
|
|
|
294 |
|
|
#ifdef CYGPKG_USBS_ETHDRV
|
295 |
|
|
// Has the TCP/IP stack brought up this interface yet?
|
296 |
|
|
cyg_bool ecos_up;
|
297 |
|
|
|
298 |
|
|
// Is there an ongoing receive? Cancelling a receive operation
|
299 |
|
|
// during a stop() may be difficult, and a stop() may be followed
|
300 |
|
|
// immediately by a restart.
|
301 |
|
|
cyg_bool rx_active;
|
302 |
|
|
|
303 |
|
|
// The eCos-side MAC. If the host and the eCos stack are to
|
304 |
|
|
// communicate then they must be able to address each other, i.e.
|
305 |
|
|
// they need separate addresses. Again there is no real hardware
|
306 |
|
|
// to extract the address from so it has to be supplied by higher
|
307 |
|
|
// level code via e.g. an ioctl().
|
308 |
|
|
unsigned char ecos_MAC[6];
|
309 |
|
|
|
310 |
|
|
// SNMP statistics
|
311 |
|
|
# ifdef CYGFUN_USBS_ETHDRV_STATISTICS
|
312 |
|
|
unsigned int interrupts;
|
313 |
|
|
unsigned int tx_count;
|
314 |
|
|
unsigned int rx_count;
|
315 |
|
|
unsigned int rx_short_frames;
|
316 |
|
|
unsigned int rx_too_long_frames;
|
317 |
|
|
# endif
|
318 |
|
|
|
319 |
|
|
// The need for a receive buffer is unavoidable for now because
|
320 |
|
|
// the network driver interface does not support pre-allocating an
|
321 |
|
|
// mbuf and then passing it back to the stack later. Ideally the
|
322 |
|
|
// rx operation would read a single USB packet, determine the
|
323 |
|
|
// required mbuf size from the 2-byte header, copy the initial
|
324 |
|
|
// data, and then read more USB packets. Alternatively, a
|
325 |
|
|
// 1516 byte mbuf could be pre-allocated and then the whole
|
326 |
|
|
// transfer could go there, potentially wasting some mbuf space.
|
327 |
|
|
// None of this is possible at present.
|
328 |
|
|
//
|
329 |
|
|
// Also, typically there will be complications because of
|
330 |
|
|
// dependencies on DMA, cached vs. uncached memory, etc.
|
331 |
|
|
unsigned char rx_buffer[CYGNUM_USBS_ETH_RXBUFSIZE];
|
332 |
|
|
unsigned char* rx_bufptr;
|
333 |
|
|
cyg_bool rx_buffer_full;
|
334 |
|
|
|
335 |
|
|
// It should be possible to eliminate the tx buffer. The problem
|
336 |
|
|
// is that the protocol requires 2 bytes to be prepended, and that
|
337 |
|
|
// may not be possible with the buffer supplied by higher-level
|
338 |
|
|
// code. Eliminating this buffer would either require USB
|
339 |
|
|
// device drivers to implement gather functionality on transmits,
|
340 |
|
|
// or it would impose a dependency on higher-level code.
|
341 |
|
|
unsigned char tx_buffer[CYGNUM_USBS_ETH_MAXTU];
|
342 |
|
|
cyg_bool tx_buffer_full;
|
343 |
|
|
cyg_bool tx_done;
|
344 |
|
|
unsigned long tx_key;
|
345 |
|
|
|
346 |
|
|
// Prevent recursion send()->tx_done()->can_send()/send()
|
347 |
|
|
cyg_bool tx_in_send;
|
348 |
|
|
#endif
|
349 |
|
|
|
350 |
|
|
} usbs_eth;
|
351 |
|
|
|
352 |
|
|
// The package automatically instantiates one USB ethernet device.
|
353 |
|
|
extern usbs_eth usbs_eth0;
|
354 |
|
|
|
355 |
|
|
// ----------------------------------------------------------------------------
|
356 |
|
|
// If the network driver option is enabled then the package also
|
357 |
|
|
// provides a single cyg_netdevtab_entry. This is exported so that
|
358 |
|
|
// application code can clone the entry.
|
359 |
|
|
#ifdef CYGPKG_USBS_ETHDRV
|
360 |
|
|
extern cyg_netdevtab_entry_t usbs_eth_netdev0;
|
361 |
|
|
#endif
|
362 |
|
|
|
363 |
|
|
// ----------------------------------------------------------------------------
|
364 |
|
|
// A C interface to the low-level USB code.
|
365 |
|
|
|
366 |
|
|
// Initialize the USBS-eth support for a particular usbs_eth device.
|
367 |
|
|
// This associates a usbs_eth structure with specific endpoints.
|
368 |
|
|
extern void usbs_eth_init(usbs_eth*, usbs_control_endpoint*, usbs_rx_endpoint*, usbs_tx_endpoint*, unsigned char*);
|
369 |
|
|
|
370 |
|
|
// Start an asynchronous transmit of a single buffer of up to
|
371 |
|
|
// CYGNUM_USBS_ETH_MAXTU bytes. This buffer should contain a 2-byte
|
372 |
|
|
// size field, a 14-byte ethernet header, and upto 1500 bytes of
|
373 |
|
|
// payload. When the transmit has completed the callback function (if
|
374 |
|
|
// any) will be invoked with the specified pointer. NOTE: figure out
|
375 |
|
|
// what to do about error reporting
|
376 |
|
|
extern void usbs_eth_start_tx(usbs_eth*, unsigned char*, void (*)(usbs_eth*, void*, int), void*);
|
377 |
|
|
|
378 |
|
|
// Start an asynchronous receive of an ethernet packet. The supplied
|
379 |
|
|
// buffer should be at least CYGNUM_USBS_ETH_MAXTU bytes. When a
|
380 |
|
|
// complete ethernet frame has been received or when some sort of
|
381 |
|
|
// error occurs the callback function will be invoked. The third
|
382 |
|
|
// argument
|
383 |
|
|
extern void usbs_eth_start_rx(usbs_eth*, unsigned char*, void (*)(usbs_eth*, void*, int), void*);
|
384 |
|
|
|
385 |
|
|
// The handler for application class control messages. The init call
|
386 |
|
|
// will install this in the control endpoint by default. However the
|
387 |
|
|
// handler is fairly dumb: it assumes that all application control
|
388 |
|
|
// messages are for the ethernet interface and does not bother to
|
389 |
|
|
// check the control message's destination. This is fine for simple
|
390 |
|
|
// USB ethernet devices, but for any kind of multi-function peripheral
|
391 |
|
|
// higher-level code will have to perform multiplexing and invoke this
|
392 |
|
|
// handler only when appropriate.
|
393 |
|
|
extern usbs_control_return usbs_eth_class_control_handler(usbs_control_endpoint*, void*);
|
394 |
|
|
|
395 |
|
|
// Similarly a handler for state change messages. Installing this
|
396 |
|
|
// means that the ethernet code will have sufficient knowledge about
|
397 |
|
|
// the state of the USB connection for simple ethernet-only
|
398 |
|
|
// peripherals, but not for anything more complicated. In the latter
|
399 |
|
|
// case higher-level code will need to keep track of which
|
400 |
|
|
// configuration, interfaces, etc. are currently active and explicitly
|
401 |
|
|
// enable or disable the ethernet device using the functions below.
|
402 |
|
|
extern void usbs_eth_state_change_handler(usbs_control_endpoint*, void*, usbs_state_change, int);
|
403 |
|
|
extern void usbs_eth_disable(usbs_eth*);
|
404 |
|
|
extern void usbs_eth_enable(usbs_eth*);
|
405 |
|
|
|
406 |
|
|
#ifdef __cplusplus
|
407 |
|
|
} // extern "C"
|
408 |
|
|
#endif
|
409 |
|
|
|
410 |
|
|
#endif // CYGONCE_USBS_ETH_H_
|