3 Manage Usb Descriptor List
5 Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef _USB_DESCRIPTOR_H_
17 #define _USB_DESCRIPTOR_H_
19 #define USB_MAX_INTERFACE_SETTING 8
22 // The RequestType in EFI_USB_DEVICE_REQUEST is composed of
23 // three fields: One bit direction, 2 bit type, and 5 bit
26 #define USB_REQUEST_TYPE(Dir, Type, Target) \
27 ((UINT8)((((Dir) == EfiUsbDataIn ? 0x01 : 0) << 7) | (Type) | (Target)))
30 // A common header for usb standard descriptor.
31 // Each stand descriptor has a length and type.
42 // Each USB device has a device descriptor. Each device may
43 // have several configures. Each configure contains several
44 // interfaces. Each interface may have several settings. Each
45 // setting has several endpoints.
47 // EFI_USB_..._DESCRIPTOR must be the first member of the
51 EFI_USB_ENDPOINT_DESCRIPTOR Desc
;
56 EFI_USB_INTERFACE_DESCRIPTOR Desc
;
57 USB_ENDPOINT_DESC
**Endpoints
;
58 } USB_INTERFACE_SETTING
;
61 // An interface may have several settings. Use a
62 // fixed max number of settings to simplify code.
63 // It should sufice in most environments.
66 USB_INTERFACE_SETTING
* Settings
[USB_MAX_INTERFACE_SETTING
];
68 UINT8 ActiveIndex
; // Index of active setting
72 EFI_USB_CONFIG_DESCRIPTOR Desc
;
73 USB_INTERFACE_DESC
**Interfaces
;
77 EFI_USB_DEVICE_DESCRIPTOR Desc
;
78 USB_CONFIG_DESC
**Configs
;
82 USB standard control transfer support routine. This
83 function is used by USB device. It is possible that
84 the device's interfaces are still waiting to be
87 @param UsbDev The usb device.
88 @param Direction The direction of data transfer.
89 @param Type Standard / class specific / vendor specific.
90 @param Target The receiving target.
91 @param Request Which request.
92 @param Value The wValue parameter of the request.
93 @param Index The wIndex parameter of the request.
94 @param Buf The buffer to receive data into / transmit from.
95 @param Length The length of the buffer.
97 @retval EFI_SUCCESS The control request is executed.
98 @retval EFI_DEVICE_ERROR Failed to execute the control transfer.
103 IN USB_DEVICE
*UsbDev
,
104 IN EFI_USB_DATA_DIRECTION Direction
,
115 Return the max packet size for endpoint zero. This function
116 is the first function called to get descriptors during bus
119 @param UsbDev The usb device.
121 @retval EFI_SUCCESS The max packet size of endpoint zero is retrieved.
122 @retval EFI_DEVICE_ERROR Failed to retrieve it.
126 UsbGetMaxPacketSize0 (
127 IN USB_DEVICE
*UsbDev
131 Free a device descriptor with its configurations.
133 @param DevDesc The device descriptor.
140 IN USB_DEVICE_DESC
*DevDesc
144 Retrieve the indexed string for the language. It requires two
145 steps to get a string, first to get the string's length. Then
148 @param UsbDev The usb device.
149 @param StringIndex The index of the string to retrieve.
150 @param LangId Language ID.
152 @return The created string descriptor or NULL.
155 EFI_USB_STRING_DESCRIPTOR
*
157 IN USB_DEVICE
*UsbDev
,
158 IN UINT8 StringIndex
,
163 Build the whole array of descriptors. This function must
164 be called after UsbGetMaxPacketSize0 returns the max packet
165 size correctly for endpoint 0.
167 @param UsbDev The Usb device.
169 @retval EFI_SUCCESS The descriptor table is build.
170 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource for the descriptor.
175 IN USB_DEVICE
*UsbDev
179 Set the device's address.
181 @param UsbDev The device to set address to.
182 @param Address The address to set.
184 @retval EFI_SUCCESS The device is set to the address.
185 @retval Others Failed to set the device address.
190 IN USB_DEVICE
*UsbDev
,
195 Set the device's configuration. This function changes
196 the device's internal state. UsbSelectConfig changes
197 the Usb bus's internal state.
199 @param UsbDev The USB device to set configure to.
200 @param ConfigIndex The configure index to set.
202 @retval EFI_SUCCESS The device is configured now.
203 @retval Others Failed to set the device configure.
208 IN USB_DEVICE
*UsbDev
,
213 Usb UsbIo interface to clear the feature. This is should
214 only be used by HUB which is considered a device driver
215 on top of the UsbIo interface.
217 @param UsbIo The UsbIo interface.
218 @param Target The target of the transfer: endpoint/device.
219 @param Feature The feature to clear.
220 @param Index The wIndex parameter.
222 @retval EFI_SUCCESS The device feature is cleared.
223 @retval Others Failed to clear the feature.
228 IN EFI_USB_IO_PROTOCOL
*UsbIo
,