3 Manage Usb Descriptor List
5 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef _USB_DESCRIPTOR_H_
11 #define _USB_DESCRIPTOR_H_
13 #define USB_MAX_INTERFACE_SETTING 256
16 // The RequestType in EFI_USB_DEVICE_REQUEST is composed of
17 // three fields: One bit direction, 2 bit type, and 5 bit
20 #define USB_REQUEST_TYPE(Dir, Type, Target) \
21 ((UINT8)((((Dir) == EfiUsbDataIn ? 0x01 : 0) << 7) | (Type) | (Target)))
24 // A common header for usb standard descriptor.
25 // Each stand descriptor has a length and type.
35 // Each USB device has a device descriptor. Each device may
36 // have several configures. Each configure contains several
37 // interfaces. Each interface may have several settings. Each
38 // setting has several endpoints.
40 // EFI_USB_..._DESCRIPTOR must be the first member of the
44 EFI_USB_ENDPOINT_DESCRIPTOR Desc
;
49 EFI_USB_INTERFACE_DESCRIPTOR Desc
;
50 USB_ENDPOINT_DESC
**Endpoints
;
51 } USB_INTERFACE_SETTING
;
54 // An interface may have several settings. Use a
55 // fixed max number of settings to simplify code.
56 // It should sufice in most environments.
59 USB_INTERFACE_SETTING
*Settings
[USB_MAX_INTERFACE_SETTING
];
61 UINTN ActiveIndex
; // Index of active setting
65 EFI_USB_CONFIG_DESCRIPTOR Desc
;
66 USB_INTERFACE_DESC
**Interfaces
;
70 EFI_USB_DEVICE_DESCRIPTOR Desc
;
71 USB_CONFIG_DESC
**Configs
;
75 USB standard control transfer support routine. This
76 function is used by USB device. It is possible that
77 the device's interfaces are still waiting to be
80 @param UsbDev The usb device.
81 @param Direction The direction of data transfer.
82 @param Type Standard / class specific / vendor specific.
83 @param Target The receiving target.
84 @param Request Which request.
85 @param Value The wValue parameter of the request.
86 @param Index The wIndex parameter of the request.
87 @param Buf The buffer to receive data into / transmit from.
88 @param Length The length of the buffer.
90 @retval EFI_SUCCESS The control request is executed.
91 @retval EFI_DEVICE_ERROR Failed to execute the control transfer.
96 IN USB_DEVICE
*UsbDev
,
97 IN EFI_USB_DATA_DIRECTION Direction
,
108 Return the max packet size for endpoint zero. This function
109 is the first function called to get descriptors during bus
112 @param UsbDev The usb device.
114 @retval EFI_SUCCESS The max packet size of endpoint zero is retrieved.
115 @retval EFI_DEVICE_ERROR Failed to retrieve it.
119 UsbGetMaxPacketSize0 (
120 IN USB_DEVICE
*UsbDev
124 Free a device descriptor with its configurations.
126 @param DevDesc The device descriptor.
133 IN USB_DEVICE_DESC
*DevDesc
137 Retrieve the indexed string for the language. It requires two
138 steps to get a string, first to get the string's length. Then
141 @param UsbDev The usb device.
142 @param StringIndex The index of the string to retrieve.
143 @param LangId Language ID.
145 @return The created string descriptor or NULL.
148 EFI_USB_STRING_DESCRIPTOR
*
150 IN USB_DEVICE
*UsbDev
,
151 IN UINT8 StringIndex
,
156 Build the whole array of descriptors. This function must
157 be called after UsbGetMaxPacketSize0 returns the max packet
158 size correctly for endpoint 0.
160 @param UsbDev The Usb device.
162 @retval EFI_SUCCESS The descriptor table is build.
163 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource for the descriptor.
168 IN USB_DEVICE
*UsbDev
172 Set the device's address.
174 @param UsbDev The device to set address to.
175 @param Address The address to set.
177 @retval EFI_SUCCESS The device is set to the address.
178 @retval Others Failed to set the device address.
183 IN USB_DEVICE
*UsbDev
,
188 Set the device's configuration. This function changes
189 the device's internal state. UsbSelectConfig changes
190 the Usb bus's internal state.
192 @param UsbDev The USB device to set configure to.
193 @param ConfigIndex The configure index to set.
195 @retval EFI_SUCCESS The device is configured now.
196 @retval Others Failed to set the device configure.
201 IN USB_DEVICE
*UsbDev
,
206 Usb UsbIo interface to clear the feature. This is should
207 only be used by HUB which is considered a device driver
208 on top of the UsbIo interface.
210 @param UsbIo The UsbIo interface.
211 @param Target The target of the transfer: endpoint/device.
212 @param Feature The feature to clear.
213 @param Index The wIndex parameter.
215 @retval EFI_SUCCESS The device feature is cleared.
216 @retval Others Failed to clear the feature.
221 IN EFI_USB_IO_PROTOCOL
*UsbIo
,