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
188 Initialize the instance of UsbIo controller
192 UsbIoController - A pointer to controller structure of UsbIo
199 // Copy EFI_USB_IO protocol instance
202 &UsbIoController
->UsbIo
,
204 sizeof (EFI_USB_IO_PROTOCOL
)
214 IN EFI_USB_IO_PROTOCOL
*This
,
215 IN EFI_USB_DEVICE_REQUEST
*Request
,
216 IN EFI_USB_DATA_DIRECTION Direction
,
218 IN OUT VOID
*Data
, OPTIONAL
219 IN UINTN DataLength
, OPTIONAL
225 This function is used to manage a USB device with a control transfer pipe.
228 This - Indicates calling context.
229 Request - A pointer to the USB device request that will be sent to
231 Direction - Indicates the data direction.
232 Data - A pointer to the buffer of data that will be transmitted
233 to USB device or received from USB device.
234 Timeout - Indicates the transfer should be completed within this time
236 DataLength - The size, in bytes, of the data buffer specified by Data.
237 Status - A pointer to the result of the USB transfer.
241 EFI_INVALID_PARAMETER
248 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
250 EFI_STATUS RetStatus
;
251 USB_IO_DEVICE
*UsbIoDev
;
252 UINT8 MaxPacketLength
;
253 UINT32 TransferResult
;
254 BOOLEAN Disconnected
;
256 // Parameters Checking
258 if (Status
== NULL
) {
259 return EFI_INVALID_PARAMETER
;
263 // leave the HostController's ControlTransfer
264 // to perform other parameters checking
266 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
267 UsbIoDev
= UsbIoController
->UsbDevice
;
269 MaxPacketLength
= UsbIoDev
->DeviceDescriptor
.MaxPacketSize0
;
272 if (Request
->Request
== USB_DEV_CLEAR_FEATURE
&&
273 Request
->RequestType
== 0x02 &&
274 Request
->Value
== EfiUsbEndpointHalt
) {
276 //Reduce the remove delay time for system response
278 IsDeviceDisconnected (UsbIoController
, &Disconnected
);
279 if (!EFI_ERROR (Status
) && Disconnected
== TRUE
) {
280 DEBUG ((gUSBErrorLevel
, "Device is disconnected when trying reset\n"));
281 return EFI_DEVICE_ERROR
;
285 // using HostController's ControlTransfer to complete the request
287 RetStatus
= UsbVirtualHcControlTransfer (
288 UsbIoDev
->BusController
,
289 UsbIoDev
->DeviceAddress
,
290 UsbIoDev
->DeviceSpeed
,
297 UsbIoDev
->Translator
,
301 *Status
= TransferResult
;
303 if (Request
->Request
== USB_DEV_CLEAR_FEATURE
&&
304 Request
->RequestType
== 0x02 &&
305 Request
->Value
== EfiUsbEndpointHalt
) {
307 // This is a UsbClearEndpointHalt request
308 // Need to clear data toggle
309 // Request.Index == EndpointAddress
311 if (!EFI_ERROR (RetStatus
) && TransferResult
== EFI_USB_NOERROR
) {
314 (UINT8
) Request
->Index
,
326 IN EFI_USB_IO_PROTOCOL
*This
,
327 IN UINT8 DeviceEndpoint
,
329 IN OUT UINTN
*DataLength
,
336 This function is used to manage a USB device with the bulk transfer pipe.
339 This - Indicates calling context.
340 DeviceEndpoint - The destination USB device endpoint to which the device
341 request is being sent.
342 Data - A pointer to the buffer of data that will be transmitted
343 to USB device or received from USB device.
344 DataLength - On input, the size, in bytes, of the data buffer
345 specified by Data. On output, the number of bytes that
346 were actually transferred.
347 Timeout - Indicates the transfer should be completed within this
349 Status - This parameter indicates the USB transfer status.
353 EFI_INVALID_PARAMETER
360 USB_IO_DEVICE
*UsbIoDev
;
361 UINTN MaxPacketLength
;
364 EFI_STATUS RetStatus
;
365 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
366 ENDPOINT_DESC_LIST_ENTRY
*EndPointListEntry
;
367 UINT8 DataBuffersNumber
;
368 UINT32 TransferResult
;
370 DataBuffersNumber
= 1;
371 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
372 UsbIoDev
= UsbIoController
->UsbDevice
;
375 // Parameters Checking
377 if ((DeviceEndpoint
& 0x7F) == 0) {
378 return EFI_INVALID_PARAMETER
;
381 if ((DeviceEndpoint
& 0x7F) > 15) {
382 return EFI_INVALID_PARAMETER
;
385 if (Status
== NULL
) {
386 return EFI_INVALID_PARAMETER
;
389 EndPointListEntry
= FindEndPointListEntry (
394 if (EndPointListEntry
== NULL
) {
395 return EFI_INVALID_PARAMETER
;
398 if ((EndPointListEntry
->EndpointDescriptor
.Attributes
& 0x03) != 0x02) {
399 return EFI_INVALID_PARAMETER
;
403 // leave the HostController's BulkTransfer
404 // to perform other parameters checking
406 GetDeviceEndPointMaxPacketLength (
418 OldToggle
= DataToggle
;
421 // using HostController's BulkTransfer to complete the request
423 RetStatus
= UsbVirtualHcBulkTransfer (
424 UsbIoDev
->BusController
,
425 UsbIoDev
->DeviceAddress
,
427 UsbIoDev
->DeviceSpeed
,
434 UsbIoDev
->Translator
,
438 if (OldToggle
!= DataToggle
) {
440 // Write the toggle back
449 *Status
= TransferResult
;
457 UsbSyncInterruptTransfer (
458 IN EFI_USB_IO_PROTOCOL
*This
,
459 IN UINT8 DeviceEndpoint
,
461 IN OUT UINTN
*DataLength
,
468 Usb Sync Interrupt Transfer
471 This - Indicates calling context.
472 DeviceEndpoint - The destination USB device endpoint to which the device
473 request is being sent.
474 Data - A pointer to the buffer of data that will be transmitted
475 to USB device or received from USB device.
476 DataLength - On input, the size, in bytes, of the data buffer
477 specified by Data. On output, the number of bytes that
478 were actually transferred.
479 Timeout - Indicates the transfer should be completed within this
481 Status - This parameter indicates the USB transfer status.
485 EFI_INVALID_PARAMETER
492 USB_IO_DEVICE
*UsbIoDev
;
493 UINTN MaxPacketLength
;
496 EFI_STATUS RetStatus
;
497 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
498 ENDPOINT_DESC_LIST_ENTRY
*EndPointListEntry
;
501 // Parameters Checking
503 if ((DeviceEndpoint
& 0x7F) == 0) {
504 return EFI_INVALID_PARAMETER
;
507 if ((DeviceEndpoint
& 0x7F) > 15) {
508 return EFI_INVALID_PARAMETER
;
511 if (Status
== NULL
) {
512 return EFI_INVALID_PARAMETER
;
515 EndPointListEntry
= FindEndPointListEntry (
520 if (EndPointListEntry
== NULL
) {
521 return EFI_INVALID_PARAMETER
;
524 if ((EndPointListEntry
->EndpointDescriptor
.Attributes
& 0x03) != 0x03) {
525 return EFI_INVALID_PARAMETER
;
529 // leave the HostController's SyncInterruptTransfer
530 // to perform other parameters checking
532 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
533 UsbIoDev
= UsbIoController
->UsbDevice
;
534 GetDeviceEndPointMaxPacketLength (
546 OldToggle
= DataToggle
;
548 // using HostController's SyncInterruptTransfer to complete the request
550 RetStatus
= UsbVirtualHcSyncInterruptTransfer (
551 UsbIoDev
->BusController
,
552 UsbIoDev
->DeviceAddress
,
554 UsbIoDev
->DeviceSpeed
,
560 UsbIoDev
->Translator
,
564 if (OldToggle
!= DataToggle
) {
566 // Write the toggle back
581 UsbAsyncInterruptTransfer (
582 IN EFI_USB_IO_PROTOCOL
*This
,
583 IN UINT8 DeviceEndpoint
,
584 IN BOOLEAN IsNewTransfer
,
585 IN UINTN PollingInterval
, OPTIONAL
586 IN UINTN DataLength
, OPTIONAL
587 IN EFI_ASYNC_USB_TRANSFER_CALLBACK InterruptCallBack
, OPTIONAL
588 IN VOID
*Context OPTIONAL
593 Usb Async Interrput Transfer
596 This - Indicates calling context.
597 DeviceEndpoint - The destination USB device endpoint to which the
598 device request is being sent.
599 IsNewTransfer - If TRUE, a new transfer will be submitted to USB
600 controller. If FALSE, the interrupt transfer is
601 deleted from the device's interrupt transfer queue.
602 PollingInterval - Indicates the periodic rate, in milliseconds, that
603 the transfer is to be executed.
604 DataLength - Specifies the length, in bytes, of the data to be
605 received from the USB device.
606 InterruptCallBack - The Callback function. This function is called if
607 the asynchronous interrupt transfer is completed.
608 Context - Passed to InterruptCallback
611 EFI_INVALID_PARAMETER
616 USB_IO_DEVICE
*UsbIoDev
;
617 UINTN MaxPacketLength
;
619 EFI_STATUS RetStatus
;
620 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
621 ENDPOINT_DESC_LIST_ENTRY
*EndpointListEntry
;
626 if ((DeviceEndpoint
& 0x7F) == 0) {
627 return EFI_INVALID_PARAMETER
;
630 if ((DeviceEndpoint
& 0x7F) > 15) {
631 return EFI_INVALID_PARAMETER
;
634 EndpointListEntry
= FindEndPointListEntry (
639 if (EndpointListEntry
== NULL
) {
640 return EFI_INVALID_PARAMETER
;
643 if ((EndpointListEntry
->EndpointDescriptor
.Attributes
& 0x03) != 0x03) {
644 return EFI_INVALID_PARAMETER
;
647 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
648 UsbIoDev
= UsbIoController
->UsbDevice
;
650 if (!IsNewTransfer
) {
652 // Delete this transfer
654 UsbVirtualHcAsyncInterruptTransfer (
655 UsbIoDev
->BusController
,
656 UsbIoDev
->DeviceAddress
,
658 UsbIoDev
->DeviceSpeed
,
664 UsbIoDev
->Translator
,
670 // We need to store the toggle value
681 GetDeviceEndPointMaxPacketLength (
693 RetStatus
= UsbVirtualHcAsyncInterruptTransfer (
694 UsbIoDev
->BusController
,
695 UsbIoDev
->DeviceAddress
,
697 UsbIoDev
->DeviceSpeed
,
703 UsbIoDev
->Translator
,
714 UsbIsochronousTransfer (
715 IN EFI_USB_IO_PROTOCOL
*This
,
716 IN UINT8 DeviceEndpoint
,
724 Usb Isochronous Transfer
727 This - Indicates calling context.
728 DeviceEndpoint - The destination USB device endpoint to which the
729 device request is being sent.
730 Data - A pointer to the buffer of data that will be
731 transmitted to USB device or received from USB device.
732 DataLength - The size, in bytes, of the data buffer specified by
734 Status - This parameter indicates the USB transfer status.
738 EFI_INVALID_PARAMETER
746 // Currently we don't support this transfer
748 return EFI_UNSUPPORTED
;
754 UsbAsyncIsochronousTransfer (
755 IN EFI_USB_IO_PROTOCOL
*This
,
756 IN UINT8 DeviceEndpoint
,
759 IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack
,
760 IN VOID
*Context OPTIONAL
766 Usb Async Isochronous Transfer
770 This - EFI_USB_IO_PROTOCOL
771 DeviceEndpoint - DeviceEndpoint number
772 Data - Data to transfer
773 DataLength - DataLength
774 IsochronousCallBack - Isochronous CallBack function
775 Context - Passed to IsochronousCallBack function
778 EFI_UNSUPPORTED - Unsupported now
783 // Currently we don't support this transfer
785 return EFI_UNSUPPORTED
;
788 // Here is new definitions
793 UsbGetDeviceDescriptor (
794 IN EFI_USB_IO_PROTOCOL
*This
,
795 OUT EFI_USB_DEVICE_DESCRIPTOR
*DeviceDescriptor
800 Retrieves the USB Device Descriptor.
803 This - Indicates the calling context.
804 DeviceDescriptor - A pointer to the caller allocated USB Device
809 EFI_INVALID_PARAMETER
814 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
815 USB_IO_DEVICE
*UsbIoDev
;
818 // This function just wrapps UsbGetDeviceDescriptor.
821 if (DeviceDescriptor
== NULL
) {
822 return EFI_INVALID_PARAMETER
;
825 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
826 UsbIoDev
= UsbIoController
->UsbDevice
;
828 if (!UsbIoDev
->IsConfigured
) {
829 return EFI_NOT_FOUND
;
834 &UsbIoDev
->DeviceDescriptor
,
835 sizeof (EFI_USB_DEVICE_DESCRIPTOR
)
844 UsbGetActiveConfigDescriptor (
845 IN EFI_USB_IO_PROTOCOL
*This
,
846 OUT EFI_USB_CONFIG_DESCRIPTOR
*ConfigurationDescriptor
851 Retrieves the current USB configuration Descriptor.
854 This - Indicates the calling context.
855 ConfigurationDescriptor - A pointer to the caller allocated USB active
856 Configuration Descriptor.
860 EFI_INVALID_PARAMETER
865 USB_IO_DEVICE
*UsbIoDev
;
866 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
869 // This function just wrapps UsbGetActiveConfigDescriptor.
871 if (ConfigurationDescriptor
== NULL
) {
872 return EFI_INVALID_PARAMETER
;
875 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
876 UsbIoDev
= UsbIoController
->UsbDevice
;
878 if (!UsbIoDev
->IsConfigured
) {
879 return EFI_NOT_FOUND
;
883 ConfigurationDescriptor
,
884 &(UsbIoDev
->ActiveConfig
->CongfigDescriptor
),
885 sizeof (EFI_USB_CONFIG_DESCRIPTOR
)
894 UsbGetInterfaceDescriptor (
895 IN EFI_USB_IO_PROTOCOL
*This
,
896 OUT EFI_USB_INTERFACE_DESCRIPTOR
*InterfaceDescriptor
901 Retrieves the interface Descriptor for that controller.
904 This - Indicates the calling context.
905 InterfaceDescriptor - A pointer to the caller allocated USB interface
910 EFI_INVALID_PARAMETER
915 INTERFACE_DESC_LIST_ENTRY
*InterfaceListEntry
;
917 if (InterfaceDescriptor
== NULL
) {
918 return EFI_INVALID_PARAMETER
;
921 InterfaceListEntry
= FindInterfaceListEntry (This
);
923 if (InterfaceListEntry
== NULL
) {
924 return EFI_NOT_FOUND
;
929 &(InterfaceListEntry
->InterfaceDescriptor
),
930 sizeof (EFI_USB_INTERFACE_DESCRIPTOR
)
939 UsbGetEndpointDescriptor (
940 IN EFI_USB_IO_PROTOCOL
*This
,
941 IN UINT8 EndpointIndex
,
942 OUT EFI_USB_ENDPOINT_DESCRIPTOR
*EndpointDescriptor
947 Retrieves the endpoint Descriptor for a given endpoint.
950 This - Indicates the calling context.
951 EndpointIndex - Indicates which endpoint descriptor to retrieve.
952 The valid range is 0..15.
953 EndpointDescriptor - A pointer to the caller allocated USB Endpoint
954 Descriptor of a USB controller.
957 EFI_SUCCESS - The endpoint descriptor was retrieved successfully.
958 EFI_INVALID_PARAMETER - EndpointIndex is not valid.
959 - EndpointDescriptor is NULL.
960 EFI_NOT_FOUND - The endpoint descriptor cannot be found.
961 The device may not be correctly configured.
965 INTERFACE_DESC_LIST_ENTRY
*InterfaceListEntry
;
966 LIST_ENTRY
*EndpointListHead
;
967 ENDPOINT_DESC_LIST_ENTRY
*EndpointListEntry
;
969 if (EndpointDescriptor
== NULL
) {
970 return EFI_INVALID_PARAMETER
;
973 if (EndpointIndex
> 15) {
974 return EFI_INVALID_PARAMETER
;
977 InterfaceListEntry
= FindInterfaceListEntry (This
);
979 if (InterfaceListEntry
== NULL
) {
980 return EFI_NOT_FOUND
;
983 EndpointListHead
= (LIST_ENTRY
*) (&InterfaceListEntry
->EndpointDescListHead
);
984 EndpointListEntry
= (ENDPOINT_DESC_LIST_ENTRY
*) (EndpointListHead
->ForwardLink
);
986 if (EndpointIndex
>= InterfaceListEntry
->InterfaceDescriptor
.NumEndpoints
) {
987 return EFI_NOT_FOUND
;
990 // Loop all endpoint descriptor to get match one.
992 while (EndpointIndex
!= 0) {
993 EndpointListEntry
= (ENDPOINT_DESC_LIST_ENTRY
*) (EndpointListEntry
->Link
.ForwardLink
);
999 &EndpointListEntry
->EndpointDescriptor
,
1000 sizeof (EFI_USB_ENDPOINT_DESCRIPTOR
)
1009 UsbGetSupportedLanguages (
1010 IN EFI_USB_IO_PROTOCOL
*This
,
1011 OUT UINT16
**LangIDTable
,
1012 OUT UINT16
*TableSize
1016 Routine Description:
1017 Get all the languages that the USB device supports
1020 This - Indicates the calling context.
1021 LangIDTable - Language ID for the string the caller wants to get.
1022 TableSize - The size, in bytes, of the table LangIDTable.
1030 USB_IO_DEVICE
*UsbIoDev
;
1031 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
1035 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
1036 UsbIoDev
= UsbIoController
->UsbDevice
;
1041 // Loop language table
1043 while (UsbIoDev
->LangID
[Index
]) {
1049 return EFI_NOT_FOUND
;
1052 *LangIDTable
= UsbIoDev
->LangID
;
1053 *TableSize
= (UINT16
) Index
;
1061 UsbGetStringDescriptor (
1062 IN EFI_USB_IO_PROTOCOL
*This
,
1064 IN UINT8 StringIndex
,
1069 Routine Description:
1070 Get a given string descriptor
1073 This - Indicates the calling context.
1074 LangID - The Language ID for the string being retrieved.
1075 StringIndex - The ID of the string being retrieved.
1076 String - A pointer to a buffer allocated by this function
1077 with AllocatePool() to store the string. If this
1078 function returns EFI_SUCCESS, it stores the string
1079 the caller wants to get. The caller should release
1080 the string buffer with FreePool() after the string
1081 is not used any more.
1085 EFI_OUT_OF_RESOURCES
1092 EFI_USB_STRING_DESCRIPTOR
*StrDescriptor
;
1096 USB_IO_DEVICE
*UsbIoDev
;
1099 USB_IO_CONTROLLER_DEVICE
*UsbIoController
;
1101 if (StringIndex
== 0) {
1102 return EFI_NOT_FOUND
;
1105 // Search LanguageID, check if it is supported by this device
1108 return EFI_NOT_FOUND
;
1111 UsbIoController
= USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This
);
1112 UsbIoDev
= UsbIoController
->UsbDevice
;
1116 while (UsbIoDev
->LangID
[Index
]) {
1117 if (UsbIoDev
->LangID
[Index
] == LangID
) {
1126 return EFI_NOT_FOUND
;
1129 // Get String Length
1131 Result
= UsbGetString (
1139 if (EFI_ERROR (Result
)) {
1140 return EFI_NOT_FOUND
;
1143 StrDescriptor
= (EFI_USB_STRING_DESCRIPTOR
*) &TempBuffer
;
1145 if (StrDescriptor
->Length
== 0) {
1146 return EFI_UNSUPPORTED
;
1149 Buffer
= AllocateZeroPool (StrDescriptor
->Length
);
1150 if (Buffer
== NULL
) {
1151 return EFI_OUT_OF_RESOURCES
;
1154 Result
= UsbGetString (
1159 StrDescriptor
->Length
,
1163 if (EFI_ERROR (Result
)) {
1164 gBS
->FreePool (Buffer
);
1165 return EFI_NOT_FOUND
;
1168 StrDescriptor
= (EFI_USB_STRING_DESCRIPTOR
*) Buffer
;
1171 // UsbString is a UNICODE string
1173 UsbString
= AllocateZeroPool (StrDescriptor
->Length
);
1174 if (UsbString
== NULL
) {
1175 gBS
->FreePool (Buffer
);
1176 return EFI_OUT_OF_RESOURCES
;
1182 StrDescriptor
->Length
- 2
1185 *String
= UsbString
;
1187 gBS
->FreePool (Buffer
);