3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 USB I/O Abstraction Driver
27 // USB I/O Support Function Prototypes
33 IN EFI_USB_IO_PROTOCOL
*This
,
34 IN EFI_USB_DEVICE_REQUEST
*Request
,
35 IN EFI_USB_DATA_DIRECTION Direction
,
37 IN OUT VOID
*Data
, OPTIONAL
38 IN UINTN DataLength
, OPTIONAL
46 IN EFI_USB_IO_PROTOCOL
*This
,
47 IN UINT8 DeviceEndpoint
,
49 IN OUT UINTN
*DataLength
,
57 UsbAsyncInterruptTransfer (
58 IN EFI_USB_IO_PROTOCOL
* This
,
59 IN UINT8 DeviceEndpoint
,
60 IN BOOLEAN IsNewTransfer
,
61 IN UINTN PollingInterval
, OPTIONAL
62 IN UINTN DataLength
, OPTIONAL
63 IN EFI_ASYNC_USB_TRANSFER_CALLBACK InterruptCallBack
, OPTIONAL
64 IN VOID
*Context OPTIONAL
70 UsbSyncInterruptTransfer (
71 IN EFI_USB_IO_PROTOCOL
*This
,
72 IN UINT8 DeviceEndpoint
,
74 IN OUT UINTN
*DataLength
,
82 UsbIsochronousTransfer (
83 IN EFI_USB_IO_PROTOCOL
*This
,
84 IN UINT8 DeviceEndpoint
,
93 UsbAsyncIsochronousTransfer (
94 IN EFI_USB_IO_PROTOCOL
* This
,
95 IN UINT8 DeviceEndpoint
,
98 IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack
,
99 IN VOID
*Context OPTIONAL
106 IN EFI_USB_IO_PROTOCOL
*This
112 UsbGetDeviceDescriptor (
113 IN EFI_USB_IO_PROTOCOL
*This
,
114 OUT EFI_USB_DEVICE_DESCRIPTOR
*DeviceDescriptor
120 UsbGetActiveConfigDescriptor (
121 IN EFI_USB_IO_PROTOCOL
*This
,
122 OUT EFI_USB_CONFIG_DESCRIPTOR
*ConfigurationDescriptor
128 UsbGetInterfaceDescriptor (
129 IN EFI_USB_IO_PROTOCOL
*This
,
130 OUT EFI_USB_INTERFACE_DESCRIPTOR
*InterfaceDescriptor
136 UsbGetEndpointDescriptor (
137 IN EFI_USB_IO_PROTOCOL
*This
,
138 IN UINT8 EndpointIndex
,
139 OUT EFI_USB_ENDPOINT_DESCRIPTOR
*EndpointDescriptor
145 UsbGetStringDescriptor (
146 IN EFI_USB_IO_PROTOCOL
*This
,
148 IN UINT8 StringIndex
,
155 UsbGetSupportedLanguages (
156 IN EFI_USB_IO_PROTOCOL
*This
,
157 OUT UINT16
**LangIDTable
,
158 OUT UINT16
*TableSize
162 // USB I/O Interface structure
164 STATIC EFI_USB_IO_PROTOCOL UsbIoInterface
= {
167 UsbAsyncInterruptTransfer
,
168 UsbSyncInterruptTransfer
,
169 UsbIsochronousTransfer
,
170 UsbAsyncIsochronousTransfer
,
171 UsbGetDeviceDescriptor
,
172 UsbGetActiveConfigDescriptor
,
173 UsbGetInterfaceDescriptor
,
174 UsbGetEndpointDescriptor
,
175 UsbGetStringDescriptor
,
176 UsbGetSupportedLanguages
,
181 InitializeUsbIoInstance (
182 IN USB_IO_CONTROLLER_DEVICE
*UsbIoController
186 // Copy EFI_USB_IO protocol instance
189 &UsbIoController
->UsbIo
,
191 sizeof (EFI_USB_IO_PROTOCOL
)
201 IN EFI_USB_IO_PROTOCOL
*This
,
202 IN EFI_USB_DEVICE_REQUEST
*Request
,
203 IN EFI_USB_DATA_DIRECTION Direction
,
205 IN OUT VOID
*Data
, OPTIONAL
206 IN UINTN DataLength
, OPTIONAL
212 This function is used to manage a USB device with a control transfer pipe.
215 This - Indicates calling context.
216 Request - A pointer to the USB device request that will be sent to
218 Direction - Indicates the data direction.
219 Data - A pointer to the buffer of data that will be transmitted
220 to USB device or received from USB device.
221 Timeout - Indicates the transfer should be completed within this time
223 DataLength - The size, in bytes, of the data buffer specified by Data.
224 Status - A pointer to the result of the USB transfer.
228 EFI_INVALID_PARAMETER
235 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
236 EFI_USB_HC_PROTOCOL
*UsbHCInterface
;
237 EFI_STATUS RetStatus
;
238 USB_IO_DEVICE
*UsbIoDevice
;
239 UINT8 MaxPacketLength
;
240 UINT32 TransferResult
;
241 BOOLEAN Disconnected
;
243 // Parameters Checking
245 if (Status
== NULL
) {
246 return EFI_INVALID_PARAMETER
;
250 // leave the HostController's ControlTransfer
251 // to perform other parameters checking
253 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
254 UsbIoDevice
= UsbIoController
->UsbDevice
;
255 UsbHCInterface
= UsbIoDevice
->BusController
->UsbHCInterface
;
256 MaxPacketLength
= UsbIoDevice
->DeviceDescriptor
.MaxPacketSize0
;
259 if (Request
->Request
== USB_DEV_CLEAR_FEATURE
&&
260 Request
->RequestType
== 0x02 &&
261 Request
->Value
== EfiUsbEndpointHalt
) {
263 //Reduce the remove delay time for system response
265 IsDeviceDisconnected (UsbIoController
, &Disconnected
);
266 if (!EFI_ERROR (Status
) && Disconnected
== TRUE
) {
267 DEBUG ((gUSBErrorLevel
, "Device is disconnected when trying reset\n"));
268 return EFI_DEVICE_ERROR
;
275 // using HostController's ControlTransfer to complete the request
277 RetStatus
= UsbHCInterface
->ControlTransfer (
279 UsbIoDevice
->DeviceAddress
,
280 UsbIoDevice
->IsSlowDevice
,
289 *Status
= TransferResult
;
291 if (Request
->Request
== USB_DEV_CLEAR_FEATURE
&&
292 Request
->RequestType
== 0x02 &&
293 Request
->Value
== EfiUsbEndpointHalt
) {
295 // This is a UsbClearEndpointHalt request
296 // Need to clear data toggle
297 // Request.Index == EndpointAddress
299 if (!EFI_ERROR (RetStatus
) && TransferResult
== EFI_USB_NOERROR
) {
302 (UINT8
) Request
->Index
,
314 IN EFI_USB_IO_PROTOCOL
*This
,
315 IN UINT8 DeviceEndpoint
,
317 IN OUT UINTN
*DataLength
,
324 This function is used to manage a USB device with the bulk transfer pipe.
327 This - Indicates calling context.
328 DeviceEndpoint - The destination USB device endpoint to which the device
329 request is being sent.
330 Data - A pointer to the buffer of data that will be transmitted
331 to USB device or received from USB device.
332 DataLength - On input, the size, in bytes, of the data buffer
333 specified by Data. On output, the number of bytes that
334 were actually transferred.
335 Timeout - Indicates the transfer should be completed within this
337 Status - This parameter indicates the USB transfer status.
341 EFI_INVALID_PARAMETER
348 USB_IO_DEVICE
*UsbIoDev
;
349 UINT8 MaxPacketLength
;
352 EFI_STATUS RetStatus
;
353 EFI_USB_HC_PROTOCOL
*UsbHCInterface
;
354 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
355 ENDPOINT_DESC_LIST_ENTRY
*EndPointListEntry
;
356 UINT32 TransferResult
;
358 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
359 UsbIoDev
= UsbIoController
->UsbDevice
;
360 UsbHCInterface
= UsbIoDev
->BusController
->UsbHCInterface
;
363 // Parameters Checking
365 if ((DeviceEndpoint
& 0x7F) == 0) {
366 return EFI_INVALID_PARAMETER
;
369 if ((DeviceEndpoint
& 0x7F) > 15) {
370 return EFI_INVALID_PARAMETER
;
373 if (Status
== NULL
) {
374 return EFI_INVALID_PARAMETER
;
377 EndPointListEntry
= FindEndPointListEntry (
382 if (EndPointListEntry
== NULL
) {
383 return EFI_INVALID_PARAMETER
;
386 if ((EndPointListEntry
->EndpointDescriptor
.Attributes
& 0x03) != 0x02) {
387 return EFI_INVALID_PARAMETER
;
391 // leave the HostController's BulkTransfer
392 // to perform other parameters checking
394 GetDeviceEndPointMaxPacketLength (
406 OldToggle
= DataToggle
;
409 // using HostController's BulkTransfer to complete the request
411 RetStatus
= UsbHCInterface
->BulkTransfer (
413 UsbIoDev
->DeviceAddress
,
423 if (OldToggle
!= DataToggle
) {
425 // Write the toggle back
434 *Status
= TransferResult
;
442 UsbSyncInterruptTransfer (
443 IN EFI_USB_IO_PROTOCOL
*This
,
444 IN UINT8 DeviceEndpoint
,
446 IN OUT UINTN
*DataLength
,
453 Usb Sync Interrupt Transfer
456 This - Indicates calling context.
457 DeviceEndpoint - The destination USB device endpoint to which the device
458 request is being sent.
459 Data - A pointer to the buffer of data that will be transmitted
460 to USB device or received from USB device.
461 DataLength - On input, the size, in bytes, of the data buffer
462 specified by Data. On output, the number of bytes that
463 were actually transferred.
464 Timeout - Indicates the transfer should be completed within this
466 Status - This parameter indicates the USB transfer status.
470 EFI_INVALID_PARAMETER
477 USB_IO_DEVICE
*UsbIoDev
;
478 UINT8 MaxPacketLength
;
481 EFI_STATUS RetStatus
;
482 EFI_USB_HC_PROTOCOL
*UsbHCInterface
;
483 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
484 ENDPOINT_DESC_LIST_ENTRY
*EndPointListEntry
;
487 // Parameters Checking
489 if ((DeviceEndpoint
& 0x7F) == 0) {
490 return EFI_INVALID_PARAMETER
;
493 if ((DeviceEndpoint
& 0x7F) > 15) {
494 return EFI_INVALID_PARAMETER
;
497 if (Status
== NULL
) {
498 return EFI_INVALID_PARAMETER
;
501 EndPointListEntry
= FindEndPointListEntry (
506 if (EndPointListEntry
== NULL
) {
507 return EFI_INVALID_PARAMETER
;
510 if ((EndPointListEntry
->EndpointDescriptor
.Attributes
& 0x03) != 0x03) {
511 return EFI_INVALID_PARAMETER
;
515 // leave the HostController's SyncInterruptTransfer
516 // to perform other parameters checking
518 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
519 UsbIoDev
= UsbIoController
->UsbDevice
;
520 UsbHCInterface
= UsbIoDev
->BusController
->UsbHCInterface
;
522 GetDeviceEndPointMaxPacketLength (
534 OldToggle
= DataToggle
;
536 // using HostController's SyncInterruptTransfer to complete the request
538 RetStatus
= UsbHCInterface
->SyncInterruptTransfer (
540 UsbIoDev
->DeviceAddress
,
542 UsbIoDev
->IsSlowDevice
,
551 if (OldToggle
!= DataToggle
) {
553 // Write the toggle back
568 UsbAsyncInterruptTransfer (
569 IN EFI_USB_IO_PROTOCOL
*This
,
570 IN UINT8 DeviceEndpoint
,
571 IN BOOLEAN IsNewTransfer
,
572 IN UINTN PollingInterval
, OPTIONAL
573 IN UINTN DataLength
, OPTIONAL
574 IN EFI_ASYNC_USB_TRANSFER_CALLBACK InterruptCallBack
, OPTIONAL
575 IN VOID
*Context OPTIONAL
580 Usb Async Interrput Transfer
583 This - Indicates calling context.
584 DeviceEndpoint - The destination USB device endpoint to which the
585 device request is being sent.
586 IsNewTransfer - If TRUE, a new transfer will be submitted to USB
587 controller. If FALSE, the interrupt transfer is
588 deleted from the device's interrupt transfer queue.
589 PollingInterval - Indicates the periodic rate, in milliseconds, that
590 the transfer is to be executed.
591 DataLength - Specifies the length, in bytes, of the data to be
592 received from the USB device.
593 InterruptCallback - The Callback function. This function is called if
594 the asynchronous interrupt transfer is completed.
595 Context - Passed to InterruptCallback
598 EFI_INVALID_PARAMETER
603 USB_IO_DEVICE
*UsbIoDev
;
604 UINT8 MaxPacketLength
;
606 EFI_USB_HC_PROTOCOL
*UsbHCInterface
;
607 EFI_STATUS RetStatus
;
608 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
609 ENDPOINT_DESC_LIST_ENTRY
*EndpointListEntry
;
614 if ((DeviceEndpoint
& 0x7F) == 0) {
615 return EFI_INVALID_PARAMETER
;
618 if ((DeviceEndpoint
& 0x7F) > 15) {
619 return EFI_INVALID_PARAMETER
;
622 EndpointListEntry
= FindEndPointListEntry (
627 if (EndpointListEntry
== NULL
) {
628 return EFI_INVALID_PARAMETER
;
631 if ((EndpointListEntry
->EndpointDescriptor
.Attributes
& 0x03) != 0x03) {
632 return EFI_INVALID_PARAMETER
;
635 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
636 UsbIoDev
= UsbIoController
->UsbDevice
;
637 UsbHCInterface
= UsbIoDev
->BusController
->UsbHCInterface
;
639 if (!IsNewTransfer
) {
641 // Delete this transfer
643 UsbHCInterface
->AsyncInterruptTransfer (
645 UsbIoDev
->DeviceAddress
,
647 UsbIoDev
->IsSlowDevice
,
658 // We need to store the toggle value
669 GetDeviceEndPointMaxPacketLength (
681 RetStatus
= UsbHCInterface
->AsyncInterruptTransfer (
683 UsbIoDev
->DeviceAddress
,
685 UsbIoDev
->IsSlowDevice
,
701 UsbIsochronousTransfer (
702 IN EFI_USB_IO_PROTOCOL
*This
,
703 IN UINT8 DeviceEndpoint
,
711 Usb Isochronous Transfer
714 This - Indicates calling context.
715 DeviceEndpoint - The destination USB device endpoint to which the
716 device request is being sent.
717 Data - A pointer to the buffer of data that will be
718 transmitted to USB device or received from USB device.
719 DataLength - The size, in bytes, of the data buffer specified by
721 Status - This parameter indicates the USB transfer status.
725 EFI_INVALID_PARAMETER
733 // Currently we don't support this transfer
735 return EFI_UNSUPPORTED
;
741 UsbAsyncIsochronousTransfer (
742 IN EFI_USB_IO_PROTOCOL
*This
,
743 IN UINT8 DeviceEndpoint
,
746 IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack
,
747 IN VOID
*Context OPTIONAL
753 Usb Async Isochronous Transfer
757 This - EFI_USB_IO_PROTOCOL
758 DeviceEndpoint - DeviceEndpoint number
759 Data - Data to transfer
760 DataLength - DataLength
761 IsochronousCallBack - Isochronous CallBack function
762 Context - Passed to IsochronousCallBack function
765 EFI_UNSUPPORTED - Unsupported now
770 // Currently we don't support this transfer
772 return EFI_UNSUPPORTED
;
775 // Here is new definitions
780 UsbGetDeviceDescriptor (
781 IN EFI_USB_IO_PROTOCOL
*This
,
782 OUT EFI_USB_DEVICE_DESCRIPTOR
*DeviceDescriptor
787 Retrieves the USB Device Descriptor.
790 This - Indicates the calling context.
791 DeviceDescriptor - A pointer to the caller allocated USB Device
796 EFI_INVALID_PARAMETER
801 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
802 USB_IO_DEVICE
*UsbIoDev
;
805 // This function just wrapps UsbGetDeviceDescriptor.
808 if (DeviceDescriptor
== NULL
) {
809 return EFI_INVALID_PARAMETER
;
812 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
813 UsbIoDev
= UsbIoController
->UsbDevice
;
815 if (!UsbIoDev
->IsConfigured
) {
816 return EFI_NOT_FOUND
;
821 &UsbIoDev
->DeviceDescriptor
,
822 sizeof (EFI_USB_DEVICE_DESCRIPTOR
)
831 UsbGetActiveConfigDescriptor (
832 IN EFI_USB_IO_PROTOCOL
*This
,
833 OUT EFI_USB_CONFIG_DESCRIPTOR
*ConfigurationDescriptor
838 Retrieves the current USB configuration Descriptor.
841 This - Indicates the calling context.
842 ConfigurationDescriptor - A pointer to the caller allocated USB active
843 Configuration Descriptor.
847 EFI_INVALID_PARAMETER
852 USB_IO_DEVICE
*UsbIoDev
;
853 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
856 // This function just wrapps UsbGetActiveConfigDescriptor.
858 if (ConfigurationDescriptor
== NULL
) {
859 return EFI_INVALID_PARAMETER
;
862 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
863 UsbIoDev
= UsbIoController
->UsbDevice
;
865 if (!UsbIoDev
->IsConfigured
) {
866 return EFI_NOT_FOUND
;
870 ConfigurationDescriptor
,
871 &(UsbIoDev
->ActiveConfig
->CongfigDescriptor
),
872 sizeof (EFI_USB_CONFIG_DESCRIPTOR
)
881 UsbGetInterfaceDescriptor (
882 IN EFI_USB_IO_PROTOCOL
*This
,
883 OUT EFI_USB_INTERFACE_DESCRIPTOR
*InterfaceDescriptor
888 Retrieves the interface Descriptor for that controller.
891 This - Indicates the calling context.
892 InterfaceDescriptor - A pointer to the caller allocated USB interface
897 EFI_INVALID_PARAMETER
902 INTERFACE_DESC_LIST_ENTRY
*InterfaceListEntry
;
904 if (InterfaceDescriptor
== NULL
) {
905 return EFI_INVALID_PARAMETER
;
908 InterfaceListEntry
= FindInterfaceListEntry (This
);
910 if (InterfaceListEntry
== NULL
) {
911 return EFI_NOT_FOUND
;
916 &(InterfaceListEntry
->InterfaceDescriptor
),
917 sizeof (EFI_USB_INTERFACE_DESCRIPTOR
)
926 UsbGetEndpointDescriptor (
927 IN EFI_USB_IO_PROTOCOL
*This
,
928 IN UINT8 EndpointIndex
,
929 OUT EFI_USB_ENDPOINT_DESCRIPTOR
*EndpointDescriptor
934 Retrieves the endpoint Descriptor for a given endpoint.
937 This - Indicates the calling context.
938 EndpointIndex - Indicates which endpoint descriptor to retrieve.
939 The valid range is 0..15.
940 EndpointDescriptor - A pointer to the caller allocated USB Endpoint
941 Descriptor of a USB controller.
944 EFI_SUCCESS - The endpoint descriptor was retrieved successfully.
945 EFI_INVALID_PARAMETER - EndpointIndex is not valid.
946 - EndpointDescriptor is NULL.
947 EFI_NOT_FOUND - The endpoint descriptor cannot be found.
948 The device may not be correctly configured.
952 INTERFACE_DESC_LIST_ENTRY
*InterfaceListEntry
;
953 LIST_ENTRY
*EndpointListHead
;
954 ENDPOINT_DESC_LIST_ENTRY
*EndpointListEntry
;
956 if (EndpointDescriptor
== NULL
) {
957 return EFI_INVALID_PARAMETER
;
960 if (EndpointIndex
> 15) {
961 return EFI_INVALID_PARAMETER
;
964 InterfaceListEntry
= FindInterfaceListEntry (This
);
966 if (InterfaceListEntry
== NULL
) {
967 return EFI_NOT_FOUND
;
970 EndpointListHead
= (LIST_ENTRY
*) (&InterfaceListEntry
->EndpointDescListHead
);
971 EndpointListEntry
= (ENDPOINT_DESC_LIST_ENTRY
*) (EndpointListHead
->ForwardLink
);
973 if (EndpointIndex
>= InterfaceListEntry
->InterfaceDescriptor
.NumEndpoints
) {
974 return EFI_NOT_FOUND
;
977 // Loop all endpoint descriptor to get match one.
979 while (EndpointIndex
!= 0) {
980 EndpointListEntry
= (ENDPOINT_DESC_LIST_ENTRY
*) (EndpointListEntry
->Link
.ForwardLink
);
986 &EndpointListEntry
->EndpointDescriptor
,
987 sizeof (EFI_USB_ENDPOINT_DESCRIPTOR
)
996 UsbGetSupportedLanguages (
997 IN EFI_USB_IO_PROTOCOL
*This
,
998 OUT UINT16
**LangIDTable
,
999 OUT UINT16
*TableSize
1003 Routine Description:
1004 Get all the languages that the USB device supports
1007 This - Indicates the calling context.
1008 LangIDTable - Language ID for the string the caller wants to get.
1009 TableSize - The size, in bytes, of the table LangIDTable.
1017 USB_IO_DEVICE
*UsbIoDev
;
1018 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
1022 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
1023 UsbIoDev
= UsbIoController
->UsbDevice
;
1028 // Loop language table
1030 while (UsbIoDev
->LangID
[Index
]) {
1036 return EFI_NOT_FOUND
;
1039 *LangIDTable
= UsbIoDev
->LangID
;
1040 *TableSize
= (UINT16
) Index
;
1048 UsbGetStringDescriptor (
1049 IN EFI_USB_IO_PROTOCOL
*This
,
1051 IN UINT8 StringIndex
,
1056 Routine Description:
1057 Get a given string descriptor
1060 This - Indicates the calling context.
1061 LangID - The Language ID for the string being retrieved.
1062 StringIndex - The ID of the string being retrieved.
1063 String - A pointer to a buffer allocated by this function
1064 with AllocatePool() to store the string. If this
1065 function returns EFI_SUCCESS, it stores the string
1066 the caller wants to get. The caller should release
1067 the string buffer with FreePool() after the string
1068 is not used any more.
1072 EFI_OUT_OF_RESOURCES
1078 EFI_USB_STRING_DESCRIPTOR
*StrDescriptor
;
1082 USB_IO_DEVICE
*UsbIoDev
;
1085 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
1087 if (StringIndex
== 0) {
1088 return EFI_NOT_FOUND
;
1091 // Search LanguageID, check if it is supported by this device
1094 return EFI_NOT_FOUND
;
1097 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
1098 UsbIoDev
= UsbIoController
->UsbDevice
;
1102 while (UsbIoDev
->LangID
[Index
]) {
1103 if (UsbIoDev
->LangID
[Index
] == LangID
) {
1112 return EFI_NOT_FOUND
;
1115 // Get String Length
1117 Result
= UsbGetString (
1125 if (EFI_ERROR (Result
)) {
1126 return EFI_NOT_FOUND
;
1129 StrDescriptor
= (EFI_USB_STRING_DESCRIPTOR
*) &TempBuffer
;
1131 if (StrDescriptor
->Length
== 0) {
1132 return EFI_UNSUPPORTED
;
1135 Buffer
= AllocateZeroPool (StrDescriptor
->Length
);
1136 if (Buffer
== NULL
) {
1137 return EFI_OUT_OF_RESOURCES
;
1140 Result
= UsbGetString (
1145 StrDescriptor
->Length
,
1149 if (EFI_ERROR (Result
)) {
1150 gBS
->FreePool (Buffer
);
1151 return EFI_NOT_FOUND
;
1154 StrDescriptor
= (EFI_USB_STRING_DESCRIPTOR
*) Buffer
;
1157 // UsbString is a UNICODE string
1159 UsbString
= AllocateZeroPool (StrDescriptor
->Length
);
1160 if (UsbString
== NULL
) {
1161 gBS
->FreePool (Buffer
);
1162 return EFI_OUT_OF_RESOURCES
;
1168 StrDescriptor
->Length
- 2
1171 *String
= UsbString
;
1173 gBS
->FreePool (Buffer
);