3 Manage Usb Descriptor List
5 Copyright (c) 2007, Intel Corporation
6 All rights reserved. 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_
20 USB_MAX_INTERFACE_SETTING
= 8
21 }USB_INTERFACE_SETTING_MAX
;
24 // The RequestType in EFI_USB_DEVICE_REQUEST is composed of
25 // three fields: One bit direction, 2 bit type, and 5 bit
28 #define USB_REQUEST_TYPE(Dir, Type, Target) \
29 ((UINT8)((((Dir) == EfiUsbDataIn ? 0x01 : 0) << 7) | (Type) | (Target)))
32 // A common header for usb standard descriptor.
33 // Each stand descriptor has a length and type.
44 // Each USB device has a device descriptor. Each device may
45 // have several configures. Each configure contains several
46 // interfaces. Each interface may have several settings. Each
47 // setting has several endpoints.
49 // EFI_USB_..._DESCRIPTOR must be the first member of the
53 EFI_USB_ENDPOINT_DESCRIPTOR Desc
;
58 EFI_USB_INTERFACE_DESCRIPTOR Desc
;
59 USB_ENDPOINT_DESC
**Endpoints
;
60 } USB_INTERFACE_SETTING
;
63 // An interface may have several settings. Use a
64 // fixed max number of settings to simplify code.
65 // It should sufice in most environments.
68 USB_INTERFACE_SETTING
* Settings
[USB_MAX_INTERFACE_SETTING
];
70 UINT8 ActiveIndex
; // Index of active setting
74 EFI_USB_CONFIG_DESCRIPTOR Desc
;
75 USB_INTERFACE_DESC
**Interfaces
;
79 EFI_USB_DEVICE_DESCRIPTOR Desc
;
80 USB_CONFIG_DESC
**Configs
;
84 USB standard control transfer support routine. This
85 function is used by USB device. It is possible that
86 the device's interfaces are still waiting to be
89 @param UsbDev The usb device.
90 @param Direction The direction of data transfer.
91 @param Type Standard / class specific / vendor specific.
92 @param Target The receiving target.
93 @param Request Which request.
94 @param Value The wValue parameter of the request.
95 @param Index The wIndex parameter of the request.
96 @param Buf The buffer to receive data into / transmit from.
97 @param Length The length of the buffer.
99 @retval EFI_SUCCESS The control request is executed.
100 @retval EFI_DEVICE_ERROR Failed to execute the control transfer.
105 IN USB_DEVICE
*UsbDev
,
106 IN EFI_USB_DATA_DIRECTION Direction
,
117 Return the max packet size for endpoint zero. This function
118 is the first function called to get descriptors during bus
121 @param UsbDev The usb device.
123 @retval EFI_SUCCESS The max packet size of endpoint zero is retrieved.
124 @retval EFI_DEVICE_ERROR Failed to retrieve it.
128 UsbGetMaxPacketSize0 (
129 IN USB_DEVICE
*UsbDev
133 Free a device descriptor with its configurations.
135 @param DevDesc The device descriptor.
142 IN USB_DEVICE_DESC
*DevDesc
146 Retrieve the indexed string for the language. It requires two
147 steps to get a string, first to get the string's length. Then
150 @param UsbDev The usb device.
151 @param StringIndex The index of the string to retrieve.
152 @param LangId Language ID.
154 @return The created string descriptor or NULL.
157 EFI_USB_STRING_DESCRIPTOR
*
159 IN USB_DEVICE
*UsbDev
,
160 IN UINT8 StringIndex
,
165 Build the whole array of descriptors. This function must
166 be called after UsbGetMaxPacketSize0 returns the max packet
167 size correctly for endpoint 0.
169 @param UsbDev The Usb device.
171 @retval EFI_SUCCESS The descriptor table is build.
172 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource for the descriptor.
177 IN USB_DEVICE
*UsbDev
181 Set the device's address.
183 @param UsbDev The device to set address to.
184 @param Address The address to set.
186 @retval EFI_SUCCESS The device is set to the address.
187 @retval Others Failed to set the device address.
192 IN USB_DEVICE
*UsbDev
,
197 Set the device's configuration. This function changes
198 the device's internal state. UsbSelectConfig changes
199 the Usb bus's internal state.
201 @param UsbDev The USB device to set configure to.
202 @param ConfigIndex The configure index to set.
204 @retval EFI_SUCCESS The device is configured now.
205 @retval Others Failed to set the device configure.
210 IN USB_DEVICE
*UsbDev
,
215 Usb UsbIo interface to clear the feature. This is should
216 only be used by HUB which is considered a device driver
217 on top of the UsbIo interface.
219 @param UsbIo The UsbIo interface.
220 @param Target The target of the transfer: endpoint/device.
221 @param Feature The feature to clear.
222 @param Index The wIndex parameter.
224 @retval EFI_SUCCESS The device feature is cleared.
225 @retval Others Failed to clear the feature.
230 IN EFI_USB_IO_PROTOCOL
*UsbIo
,