LibXenon
Bare-metal Xbox 360 homebrew library
Loading...
Searching...
No Matches
usbdevs.c
Go to the documentation of this file.
1/* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * USB Driver List File: usbdevs.c
5 *
6 * This module contains a table of supported USB devices and
7 * the routines to look up appropriate drivers given
8 * USB product, device, and class codes.
9 *
10 * Author: Mitch Lichtenberg
11 *
12 *********************************************************************
13 *
14 * Copyright 2000,2001,2002,2003
15 * Broadcom Corporation. All rights reserved.
16 *
17 * This software is furnished under license and may be used and
18 * copied only in accordance with the following terms and
19 * conditions. Subject to these conditions, you may download,
20 * copy, install, use, modify and distribute modified or unmodified
21 * copies of this software in source and/or binary form. No title
22 * or ownership is transferred hereby.
23 *
24 * 1) Any source code used, modified or distributed must reproduce
25 * and retain this copyright notice and list of conditions
26 * as they appear in the source file.
27 *
28 * 2) No right is granted to use any trade name, trademark, or
29 * logo of Broadcom Corporation. The "Broadcom Corporation"
30 * name may not be used to endorse or promote products derived
31 * from this software without the prior written permission of
32 * Broadcom Corporation.
33 *
34 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
35 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
36 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
38 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
39 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
40 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
42 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
44 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
45 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
46 * THE POSSIBILITY OF SUCH DAMAGE.
47 ********************************************************************* */
48
49#ifndef _CFE_
50#include <stdio.h>
51#include <memory.h>
52#include <stdint.h>
53#include "usbhack.h"
54#include "lib_malloc.h"
55#include "lib_queue.h"
56#else
57#include "cfe.h"
58#endif
59
60#include "usbchap9.h"
61#include "usbd.h"
62
63/* *********************************************************************
64 * The list of drivers we support. If you add more drivers,
65 * list them here.
66 ********************************************************************* */
67
71#ifdef USB11_MASS_STORAGE
72extern usb_driver_t usbmass_driver;
73#endif
81
83
84 /*
85 * Hub driver
86 */
87
89
90 /*
91 * Keyboards and mice
92 */
93
95 {CLASS_ANY, 0x045e,0x291, &usbctrl_driver}, // RF unit
96 {CLASS_ANY, 0x045e,0x28e, &usbctrl_driver}, // wired controller
97 {CLASS_ANY, 0x045e,0x2aa, &usbctrl_driver}, // wireless controller
98 {CLASS_ANY, 0x045e,0x2a9, &usbctrl_driver}, // wireless controller
99 {CLASS_ANY, 0x045e,0x2b0, &dummy_driver}, // Kinect, not handled so we load a dummy drive
100 {CLASS_ANY, 0x1bad,0xf900, &usbctrl_driver}, // PDP Afterglow controller
101 {CLASS_ANY, 0x045e,0x28f, &dummy_driver}, // play and charge kit, not a controller - let's ignore it
102
103 /*
104 * Mass storage devices
105 */
106
107#ifdef USB11_MASS_STORAGE
109#endif
110
111#if 0
112 /*
113 * Serial ports
114 */
115
119
120
121 /*
122 * Ethernet Adapters
123 */
124
125 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x506,0x4601,&usbpeg_driver}, /* 3Com */
126 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x2202,&usbpeg_driver}, /* Linksys */
127 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x2203,&usbpeg_driver}, /* Linksys */
128 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x2204,&usbpeg_driver}, /* Linksys */
129 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x2206,&usbpeg_driver}, /* Linksys */
130 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x400b,&usbpeg_driver}, /* Linksys */
131 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x200c,&usbpeg_driver}, /* Linksys */
132 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x423,0x000a,&usbcatc_driver}, /* CATC */
133 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x423,0x000c,&usbcatc_driver}, /* Belkin */
134 {USB_DEVICE_CLASS_RESERVED,0xbda,0x8150,&usbrtek_driver}, /* Realtek */
135 {USB_DEVICE_CLASS_RESERVED,0x06e1,0x0008,&usbklsi_driver}, /* Kawasaki */
136
137 {CLASS_ANY,0x0846,0x1040,&usbasix_driver}, /* Netgear FA120 */
138 {CLASS_ANY,0x07B8,0x420a,&usbasix_driver}, /* Hawking UF200 */
139#endif
140
141 {0,0,0,NULL}
142};
143
144
145/* *********************************************************************
146 * usb_find_driver(class,vendor,product)
147 *
148 * Find a suitable device driver to handle the specified
149 * class, vendor, or product.
150 *
151 * Input parameters:
152 * devdescr - device descriptor
153 *
154 * Return value:
155 * pointer to device driver or NULL
156 ********************************************************************* */
157
159{
160 usb_device_descr_t *devdescr;
161 usb_interface_descr_t *ifdescr;
162 usb_drvlist_t *list;
163 int dclass,vendor,product;
164
165 devdescr = &(dev->ud_devdescr);
166
167 dclass = devdescr->bDeviceClass;
168 if (dclass == 0) {
170 if (ifdescr) dclass = ifdescr->bInterfaceClass;
171 }
172
173 vendor = (int) GETUSBFIELD(devdescr,idVendor);
174 product = (int) GETUSBFIELD(devdescr,idProduct);
175
176 printf("USB bus %d device %d: vendor %04X product %04X class %02X: ",
177 dev->ud_bus->ub_num, dev->ud_address, vendor, product, dclass);
178
179 list = usb_drivers;
180 while (list->udl_disp) {
181 if (((list->udl_class == dclass) || (list->udl_class == CLASS_ANY)) &&
182 ((list->udl_vendor == vendor) || (list->udl_vendor == VENDOR_ANY)) &&
183 ((list->udl_product == product) || (list->udl_product == PRODUCT_ANY))) {
184 printf("%s\n",list->udl_disp->udrv_name);
185 return list->udl_disp;
186 }
187 list++;
188 }
189
190 // try to detected wired controller
191 int i;
192 for (i = 0; i < devdescr->bNumConfigurations; i++) {
194 if (cfgdescr) {
195 if(cfgdescr && cfgdescr->bInterfaceSubClass == 93){
196 printf("Wired controller ?\n");
197 return &usbctrl_driver;
198 }
199
200 }
201 }
202
203 printf("Not found.\n");
204
205 return NULL;
206}
#define NULL
Definition: def.h:47
uint8_t bDeviceClass
Definition: usbchap9.h:180
uint8_t bNumConfigurations
Definition: usbchap9.h:190
char * udrv_name
Definition: usbd.h:291
int udl_vendor
Definition: usbd.h:298
usb_driver_t * udl_disp
Definition: usbd.h:300
int udl_class
Definition: usbd.h:297
int udl_product
Definition: usbd.h:299
uint8_t bInterfaceSubClass
Definition: usbchap9.h:231
uint8_t bInterfaceClass
Definition: usbchap9.h:230
int ub_num
Definition: usbd.h:99
Definition: usbd.h:141
int ud_address
Definition: usbd.h:144
usbbus_t * ud_bus
Definition: usbd.h:143
usb_device_descr_t ud_devdescr
Definition: usbd.h:149
#define USB_DEVICE_CLASS_STORAGE
Definition: usbchap9.h:151
#define GETUSBFIELD(s, f)
Definition: usbchap9.h:347
#define USB_DEVICE_CLASS_HUMAN_INTERFACE
Definition: usbchap9.h:146
#define USB_DEVICE_CLASS_VENDOR_SPECIFIC
Definition: usbchap9.h:153
#define USB_DEVICE_CLASS_HUB
Definition: usbchap9.h:152
#define USB_DEVICE_CLASS_RESERVED
Definition: usbchap9.h:143
#define USB_INTERFACE_DESCRIPTOR_TYPE
Definition: usbchap9.h:65
void * usb_find_cfg_descr(usbdev_t *dev, int dtype, int idx)
Definition: usbd.c:1237
#define CLASS_ANY
Definition: usbd.h:305
#define PRODUCT_ANY
Definition: usbd.h:307
#define VENDOR_ANY
Definition: usbd.h:306
usb_driver_t usbhid_driver
Definition: usbhid.c:121
usb_driver_t usbklsi_driver
Definition: dev_usb_klsi.c:444
usb_driver_t usbcatc_driver
Definition: dev_usb_catc.c:431
usb_driver_t usbhub_driver
Definition: usbhub.c:114
usb_drvlist_t usb_drivers[]
Definition: usbdevs.c:82
usb_driver_t usbrtek_driver
Definition: dev_usb_rtek.c:428
usb_driver_t usbpeg_driver
usb_driver_t usbserial_driver
Definition: usbserial.c:207
usb_driver_t * usb_find_driver(usbdev_t *dev)
Definition: usbdevs.c:158
usb_driver_t usbctrl_driver
Definition: usbctrl.c:104
usb_driver_t dummy_driver
Definition: dummy.c:53
usb_driver_t usbasix_driver
Definition: dev_usb_asix.c:333