55#define USBETH_TRACE( x, y ... ) xprintf( x, ##y )
57#define USBETH_TRACE( x, y ... ) ((void)0)
63#define ALIGN(n,align) (((n)+((align)-1)) & ~((align)-1))
65#define usb_dma_alloc(n) (KMALLOC(ALIGN((n),CACHE_ALIGN),CACHE_ALIGN))
66#define usb_dma_free(p) (KFREE(p))
77static void hexdump(
unsigned char * src,
int srclen,
int rowlen,
int rows )
79 unsigned char *rowptr;
80 unsigned char *srcstp;
81 unsigned char *byteptr;
83 srcstp = src + srclen;
85 for( rowptr = src; rowptr < src + rowlen * rows; rowptr += rowlen ) {
86 for( byteptr = rowptr; byteptr < rowptr + rowlen && byteptr < srcstp; byteptr++ ) {
94#define hexdump(src,srclen,rowlen,rows) ((void)0)
104static const char *VENDOR_NAMES[] = {
105 "?",
"3-COM",
"LinkSys",
"LinkSys-10TX",
"LinkSys-100TX",
"Yikes!"
108static const int ID_TBL[] = {
135static int peg_send_eth_frame(
void *ctx,
hsaddr_t buf,
int len );
136static int peg_get_eth_frame(
void *ctx,
hsaddr_t buf );
137static int peg_data_rx(
void *ctx );
138static int peg_get_dev_addr(
void *ctx,
hsaddr_t mac_addr );
186 xprintf(
"Pegasus Eeprom read failed!\n" );
201 for( i = 0; i < 3; ++i ) {
202 status = peg_get_eep_word( dev, i, &mac_addr[i*2] );
207static void peg_init_phy(
usbdev_t *dev )
210 static uint8_t phy_magic_wr[] = { 0, 4, 0, 0x1b };
211 static uint8_t read_status[] = { 0, 0, 0, 1 };
224 memcpy(
data, phy_magic_wr, 4 );
228 memcpy(
data, read_status, 4 );
239 const int *
ptr=ID_TBL;
247 while( *
ptr != -1 ) {
248 if( (vendor_id ==
ptr[0]) && (product_id ==
ptr[1]) ) {
256 xprintf(
"Unrecognized ADMTEK USB-Ethernet device\n" );
267 peg_get_mac_addr( dev, softc->
mac_addr );
270 xprintf(
"%s USB-Ethernet Adapter (%a)\n",
276static int peg_get_dev_addr(
void *ctx,
hsaddr_t mac_addr )
279 hs_memcpy_to_hs( mac_addr, softc->
mac_addr, 6 );
291static int peg_data_rx(
void *ctx )
298static int peg_get_eth_frame(
void *ctx,
hsaddr_t buf )
305 rxbuf = softc->
rxbuf;
309 xprintf(
"Incoming packet :\n" );
310 hexdump( rxbuf, len, 16, len / 16 + 1 );
312 hs_memcpy_to_hs( buf, rxbuf, len );
315 peg_queue_rx( softc );
318 xprintf(
"Bulk data is not available yet!\n" );
323static int peg_send_eth_frame(
void *ctx,
hsaddr_t buf,
int len )
328 unsigned char *txbuf;
331 txbuf[0] = txlen & 0xff;
332 txbuf[1] = (txlen >> 8) & 0xff;
333 hs_memcpy_from_hs( &txbuf[2], buf, txlen );
336 xprintf(
"Outgoing packet :\n" );
337 hexdump( txbuf, txlen, 16, txlen / 16 + 1 );
361 peg_queue_rx( softc );
407 if( softc ==
NULL ) {
408 xprintf(
"Failed to allocate softc memory.\n" );
416 if (ifdscr ==
NULL) {
417 xprintf(
"USBETH: ERROR...no interace descriptor\n");
421 for (idx = 0; idx < 2; idx++) {
429 if (!indscr || !outdscr) {
434 xprintf(
"USBETH: ERROR...no endpoint descriptors\n");
442 if (peg_init_device(softc) < 0)
453 peg_open_device( softc );
479 peg_close_device ( softc );
const cfe_driver_t usbpegdrv
#define hexdump(src, srclen, rowlen, rows)
usb_driver_t usbpeg_driver
struct peg_softc_s peg_softc_t
#define KMALLOC(size, align)
uint8_t bConfigurationValue
usb_config_descr_t * ud_cfgdescr
#define USBREQ_TYPE_VENDOR
#define USB_ENDPOINT_DESCRIPTOR_TYPE
#define USB_ENDPOINT_DIR_OUT(addr)
#define USB_INTERFACE_DESCRIPTOR_TYPE
void * usb_find_cfg_descr(usbdev_t *dev, int dtype, int idx)
int usb_std_request(usbdev_t *dev, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *buffer, int length)
int usb_sync_request(usbreq_t *ur)
usbreq_t * usb_make_request(usbdev_t *dev, int epaddr, uint8_t *buf, int length, int flags)
void usb_free_request(usbreq_t *ur)
void usb_poll(usbbus_t *bus)
int usb_queue_request(usbreq_t *ur)
int usb_get_device_descriptor(usbdev_t *dev, usb_device_descr_t *dscr, int smallflg)
int usb_set_configuration(usbdev_t *dev, int config)
int usb_open_pipe(usbdev_t *dev, usb_endpoint_descr_t *epdesc)
int usbeth_register(usbeth_disp_t *disp, void *softc)
void usbeth_unregister(void *softc)
#define R_PEG_EEPROM_DATA