LibXenon
Bare-metal Xbox 360 homebrew library
Loading...
Searching...
No Matches
usbchap9.h
Go to the documentation of this file.
1/* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * Chapter 9 definitions File: usbchap9.h
5 *
6 * This module contains definitions from the USB specification,
7 * chapter 9.
8 *
9 * Author: Mitch Lichtenberg
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This software is furnished under license and may be used and
17 * copied only in accordance with the following terms and
18 * conditions. Subject to these conditions, you may download,
19 * copy, install, use, modify and distribute modified or unmodified
20 * copies of this software in source and/or binary form. No title
21 * or ownership is transferred hereby.
22 *
23 * 1) Any source code used, modified or distributed must reproduce
24 * and retain this copyright notice and list of conditions
25 * as they appear in the source file.
26 *
27 * 2) No right is granted to use any trade name, trademark, or
28 * logo of Broadcom Corporation. The "Broadcom Corporation"
29 * name may not be used to endorse or promote products derived
30 * from this software without the prior written permission of
31 * Broadcom Corporation.
32 *
33 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
34 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
35 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
37 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
38 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
39 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
41 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
42 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
43 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
44 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
45 * THE POSSIBILITY OF SUCH DAMAGE.
46 ********************************************************************* */
47
48
49
50#ifndef _USBCHAP9_H_
51#define _USBCHAP9_H_
52
53#define MAXIMUM_USB_STRING_LENGTH 255
54
55/*
56 * values for the bits returned by the USB GET_STATUS command
57 */
58#define USB_GETSTATUS_SELF_POWERED 0x01
59#define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02
60
61
62#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
63#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
64#define USB_STRING_DESCRIPTOR_TYPE 0x03
65#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
66#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
67#define USB_POWER_DESCRIPTOR_TYPE 0x06
68#define USB_HID_DESCRIPTOR_TYPE 0x21
69#define USB_HUB_DESCRIPTOR_TYPE 0x29
70
71#define USB_DESCRIPTOR_TYPEINDEX(d, i) ((uint16_t)((uint16_t)(d)<<8 | (i)))
72
73/*
74 * Values for bmAttributes field of an
75 * endpoint descriptor
76 */
77
78#define USB_ENDPOINT_TYPE_MASK 0x03
79
80#define USB_ENDPOINT_TYPE_CONTROL 0x00
81#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
82#define USB_ENDPOINT_TYPE_BULK 0x02
83#define USB_ENDPOINT_TYPE_INTERRUPT 0x03
84
85
86/*
87 * definitions for bits in the bmAttributes field of a
88 * configuration descriptor.
89 */
90#define USB_CONFIG_POWERED_MASK 0xc0
91
92#define USB_CONFIG_BUS_POWERED 0x80
93#define USB_CONFIG_SELF_POWERED 0x40
94#define USB_CONFIG_REMOTE_WAKEUP 0x20
95
96/*
97 * Endpoint direction bit, stored in address
98 */
99
100#define USB_ENDPOINT_DIRECTION_MASK 0x80
101#define USB_ENDPOINT_DIRECTION_IN 0x80 /* bit set means IN */
102
103/*
104 * test direction bit in the bEndpointAddress field of
105 * an endpoint descriptor.
106 */
107#define USB_ENDPOINT_DIR_OUT(addr) (!((addr) & USB_ENDPOINT_DIRECTION_MASK))
108#define USB_ENDPOINT_DIR_IN(addr) ((addr) & USB_ENDPOINT_DIRECTION_MASK)
109
110#define USB_ENDPOINT_ADDRESS(addr) ((addr) & 0x0F)
111
112/*
113 * USB defined request codes
114 * see chapter 9 of the USB 1.0 specifcation for
115 * more information.
116 */
117
118/*
119 * These are the correct values based on the USB 1.0
120 * specification
121 */
122
123#define USB_REQUEST_GET_STATUS 0x00
124#define USB_REQUEST_CLEAR_FEATURE 0x01
125
126#define USB_REQUEST_SET_FEATURE 0x03
127
128#define USB_REQUEST_SET_ADDRESS 0x05
129#define USB_REQUEST_GET_DESCRIPTOR 0x06
130#define USB_REQUEST_SET_DESCRIPTOR 0x07
131#define USB_REQUEST_GET_CONFIGURATION 0x08
132#define USB_REQUEST_SET_CONFIGURATION 0x09
133#define USB_REQUEST_GET_INTERFACE 0x0A
134#define USB_REQUEST_SET_INTERFACE 0x0B
135#define USB_REQUEST_SYNC_FRAME 0x0C
136
137
138/*
139 * defined USB device classes
140 */
141
142
143#define USB_DEVICE_CLASS_RESERVED 0x00
144#define USB_DEVICE_CLASS_AUDIO 0x01
145#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
146#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
147#define USB_DEVICE_CLASS_MONITOR 0x04
148#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
149#define USB_DEVICE_CLASS_POWER 0x06
150#define USB_DEVICE_CLASS_PRINTER 0x07
151#define USB_DEVICE_CLASS_STORAGE 0x08
152#define USB_DEVICE_CLASS_HUB 0x09
153#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
154
155/*
156 * USB defined Feature selectors
157 */
158
159#define USB_FEATURE_ENDPOINT_STALL 0x0000
160#define USB_FEATURE_REMOTE_WAKEUP 0x0001
161#define USB_FEATURE_POWER_D0 0x0002
162#define USB_FEATURE_POWER_D1 0x0003
163#define USB_FEATURE_POWER_D2 0x0004
164#define USB_FEATURE_POWER_D3 0x0005
165
166/*
167 * USB Device descriptor.
168 * To reduce problems with compilers trying to optimize
169 * this structure, all the fields are bytes.
170 */
171
172#define USBWORD(x) ((x) & 0xFF),(((x) >> 8) & 0xFF)
173
174#define USB_CONTROL_ENDPOINT_MIN_SIZE 8
175
176typedef struct usb_device_descr_s {
192
193typedef struct usb_endpoint_descr_s {
201
202/*
203 * values for bmAttributes Field in
204 * USB_CONFIGURATION_DESCRIPTOR
205 */
206
207#define CONFIG_BUS_POWERED 0x80
208#define CONFIG_SELF_POWERED 0x40
209#define CONFIG_REMOTE_WAKEUP 0x20
210
211typedef struct usb_config_descr_s {
221
222#define USB_INTERFACE_CLASS_HUB 0x09
223
224typedef struct usb_interface_descr_s {
235
236typedef struct usb_string_descr_s {
241
242/*
243 * USB power descriptor added to core specification
244 * XXX Note uint16_t fields. Not currently used by CFE.
245 */
246
247#define USB_SUPPORT_D0_COMMAND 0x01
248#define USB_SUPPORT_D1_COMMAND 0x02
249#define USB_SUPPORT_D2_COMMAND 0x04
250#define USB_SUPPORT_D3_COMMAND 0x08
251
252#define USB_SUPPORT_D1_WAKEUP 0x10
253#define USB_SUPPORT_D2_WAKEUP 0x20
254
255
256typedef struct usb_power_descr_s {
269
270
271typedef struct usb_common_descr_s {
275
276typedef struct usb_device_status_s {
279
280
281/*
282 * Standard USB HUB definitions
283 *
284 * See Chapter 11
285 */
286
287#define USB_HUB_DESCR_SIZE 8
288typedef struct usb_hub_descr_s {
289 uint8_t bDescriptorLength; /* Length of this descriptor */
290 uint8_t bDescriptorType; /* Hub configuration type */
291 uint8_t bNumberOfPorts; /* number of ports on this hub */
292 uint8_t wHubCharacteristicsLow; /* Hub Charateristics */
294 uint8_t bPowerOnToPowerGood; /* port power on till power good in 2ms */
295 uint8_t bHubControlCurrent; /* max current in mA */
296 /* room for 255 ports power control and removable bitmask */
299
300#define USB_HUBCHAR_PWR_GANGED 0
301#define USB_HUBCHAR_PWR_IND 1
302#define USB_HUBCHAR_PWR_NONE 2
303
304typedef struct usb_hub_status_s {
308
309#define USB_PORT_STATUS_CONNECT 0x0001
310#define USB_PORT_STATUS_ENABLED 0x0002
311#define USB_PORT_STATUS_SUSPEND 0x0004
312#define USB_PORT_STATUS_OVERCUR 0x0008
313#define USB_PORT_STATUS_RESET 0x0010
314#define USB_PORT_STATUS_POWER 0x0100
315#define USB_PORT_STATUS_LOWSPD 0x0200
316
317typedef struct usb_port_status_s {
321
322
323#define USB_HUBREQ_GET_STATUS 0
324#define USB_HUBREQ_CLEAR_FEATURE 1
325#define USB_HUBREQ_GET_STATE 2
326#define USB_HUBREQ_SET_FEATURE 3
327#define USB_HUBREQ_GET_DESCRIPTOR 6
328#define USB_HUBREQ_SET_DESCRIPTOR 7
329
330#define USB_HUB_FEATURE_C_LOCAL_POWER 0
331#define USB_HUB_FEATURE_C_OVER_CURRENT 1
332
333#define USB_PORT_FEATURE_CONNECTION 0
334#define USB_PORT_FEATURE_ENABLE 1
335#define USB_PORT_FEATURE_SUSPEND 2
336#define USB_PORT_FEATURE_OVER_CURRENT 3
337#define USB_PORT_FEATURE_RESET 4
338#define USB_PORT_FEATURE_POWER 8
339#define USB_PORT_FEATURE_LOW_SPEED 9
340#define USB_PORT_FEATURE_C_PORT_CONNECTION 16
341#define USB_PORT_FEATURE_C_PORT_ENABLE 17
342#define USB_PORT_FEATURE_C_PORT_SUSPEND 18
343#define USB_PORT_FEATURE_C_PORT_OVER_CURRENT 19
344#define USB_PORT_FEATURE_C_PORT_RESET 20
345
346
347#define GETUSBFIELD(s,f) (((s)->f##Low) | ((s)->f##High << 8))
348#define PUTUSBFIELD(s,f,v) (s)->f##Low = (v & 0xFF); \
349 (s)->f##High = ((v)>>8 & 0xFF)
350
351typedef struct usb_device_request_s {
358
359/*
360 * Values for the bmAttributes field of a request
361 */
362#define USBREQ_DIR_IN 0x80
363#define USBREQ_DIR_OUT 0x00
364#define USBREQ_TYPE_STD 0x00
365#define USBREQ_TYPE_CLASS 0x20
366#define USBREQ_TYPE_VENDOR 0x40
367#define USBREQ_TYPE_RSVD 0x60
368#define USBREQ_REC_DEVICE 0x00
369#define USBREQ_REC_INTERFACE 0x01
370#define USBREQ_REC_ENDPOINT 0x02
371#define USBREQ_REC_OTHER 0x03
372
373#define REQCODE(req,dir,type,rec) (((req) << 8) | (dir) | (type) | (rec))
374#define REQSW(req,attr) (((req) << 8) | (attr))
375
376/* *********************************************************************
377 * HID stuff
378 ********************************************************************* */
379
380typedef struct usb_hid_descr_s {
389
390#endif /* _USBCHAP9_H_ */
u16 uint16_t
Definition: libfdt_env.h:10
u8 uint8_t
Definition: libfdt_env.h:9
uint8_t bDescriptorType
Definition: usbchap9.h:273
uint8_t bmAttributes
Definition: usbchap9.h:218
uint8_t MaxPower
Definition: usbchap9.h:219
uint8_t bConfigurationValue
Definition: usbchap9.h:216
uint8_t wTotalLengthLow
Definition: usbchap9.h:214
uint8_t bNumInterfaces
Definition: usbchap9.h:215
uint8_t bDescriptorType
Definition: usbchap9.h:213
uint8_t wTotalLengthHigh
Definition: usbchap9.h:214
uint8_t iConfiguration
Definition: usbchap9.h:217
uint8_t idVendorLow
Definition: usbchap9.h:184
uint8_t bDeviceSubClass
Definition: usbchap9.h:181
uint8_t bcdUSBHigh
Definition: usbchap9.h:179
uint8_t bcdUSBLow
Definition: usbchap9.h:179
uint8_t bDeviceClass
Definition: usbchap9.h:180
uint8_t bNumConfigurations
Definition: usbchap9.h:190
uint8_t iSerialNumber
Definition: usbchap9.h:189
uint8_t iManufacturer
Definition: usbchap9.h:187
uint8_t bcdDeviceLow
Definition: usbchap9.h:186
uint8_t idProductLow
Definition: usbchap9.h:185
uint8_t idProductHigh
Definition: usbchap9.h:185
uint8_t bMaxPacketSize0
Definition: usbchap9.h:183
uint8_t bcdDeviceHigh
Definition: usbchap9.h:186
uint8_t bDescriptorType
Definition: usbchap9.h:178
uint8_t idVendorHigh
Definition: usbchap9.h:184
uint8_t bDeviceProtocol
Definition: usbchap9.h:182
uint8_t iProduct
Definition: usbchap9.h:188
uint8_t bmRequestType
Definition: usbchap9.h:352
uint8_t wDeviceStatusHigh
Definition: usbchap9.h:277
uint8_t wDeviceStatusLow
Definition: usbchap9.h:277
uint8_t bmAttributes
Definition: usbchap9.h:197
uint8_t bDescriptorType
Definition: usbchap9.h:195
uint8_t bEndpointAddress
Definition: usbchap9.h:196
uint8_t wMaxPacketSizeHigh
Definition: usbchap9.h:198
uint8_t wMaxPacketSizeLow
Definition: usbchap9.h:198
uint8_t bcdHIDLow
Definition: usbchap9.h:383
uint8_t wClassDescrLengthHigh
Definition: usbchap9.h:387
uint8_t bDescriptorType
Definition: usbchap9.h:382
uint8_t bNumDescriptors
Definition: usbchap9.h:385
uint8_t wClassDescrLengthLow
Definition: usbchap9.h:387
uint8_t bcdHIDHigh
Definition: usbchap9.h:383
uint8_t bClassDescrType
Definition: usbchap9.h:386
uint8_t bLength
Definition: usbchap9.h:381
uint8_t bCountryCode
Definition: usbchap9.h:384
uint8_t bDescriptorType
Definition: usbchap9.h:290
uint8_t bHubControlCurrent
Definition: usbchap9.h:295
uint8_t bNumberOfPorts
Definition: usbchap9.h:291
uint8_t bDescriptorLength
Definition: usbchap9.h:289
uint8_t wHubCharacteristicsLow
Definition: usbchap9.h:292
uint8_t bRemoveAndPowerMask[64]
Definition: usbchap9.h:297
uint8_t wHubCharacteristicsHigh
Definition: usbchap9.h:293
uint8_t bPowerOnToPowerGood
Definition: usbchap9.h:294
uint8_t wHubChangeLow
Definition: usbchap9.h:306
uint8_t wHubStatusHigh
Definition: usbchap9.h:305
uint8_t wHubStatusLow
Definition: usbchap9.h:305
uint8_t wHubChangeHigh
Definition: usbchap9.h:306
uint8_t bAlternateSetting
Definition: usbchap9.h:228
uint8_t bInterfaceNumber
Definition: usbchap9.h:227
uint8_t bDescriptorType
Definition: usbchap9.h:226
uint8_t bInterfaceSubClass
Definition: usbchap9.h:231
uint8_t bInterfaceProtocol
Definition: usbchap9.h:232
uint8_t bInterfaceClass
Definition: usbchap9.h:230
uint8_t wPortChangeLow
Definition: usbchap9.h:319
uint8_t wPortStatusLow
Definition: usbchap9.h:318
uint8_t wPortStatusHigh
Definition: usbchap9.h:318
uint8_t wPortChangeHigh
Definition: usbchap9.h:319
uint16_t EventNotification
Definition: usbchap9.h:260
uint8_t bDescriptorType
Definition: usbchap9.h:258
uint16_t D1PowerConsumption
Definition: usbchap9.h:266
uint16_t D1LatencyTime
Definition: usbchap9.h:261
uint16_t D0PowerConsumption
Definition: usbchap9.h:265
uint16_t D2PowerConsumption
Definition: usbchap9.h:267
uint8_t bCapabilitiesFlags
Definition: usbchap9.h:259
uint8_t bLength
Definition: usbchap9.h:257
uint8_t PowerUnit
Definition: usbchap9.h:264
uint16_t D2LatencyTime
Definition: usbchap9.h:262
uint16_t D3LatencyTime
Definition: usbchap9.h:263
uint8_t bString[1]
Definition: usbchap9.h:239
uint8_t bDescriptorType
Definition: usbchap9.h:238
struct usb_config_descr_s usb_config_descr_t
struct usb_device_status_s usb_device_status_t
struct usb_string_descr_s usb_string_descr_t
struct usb_device_descr_s usb_device_descr_t
struct usb_device_request_s usb_device_request_t
struct usb_endpoint_descr_s usb_endpoint_descr_t
struct usb_hid_descr_s usb_hid_descr_t
struct usb_interface_descr_s usb_interface_descr_t
struct usb_port_status_s usb_port_status_t
struct usb_power_descr_s usb_power_descr_t
struct usb_hub_descr_s usb_hub_descr_t
struct usb_common_descr_s usb_common_descr_t
struct usb_hub_status_s usb_hub_status_t