TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbBus.c
Go to the documentation of this file.
1
11#include "UsbBus.h"
12
13EFI_USB_IO_PROTOCOL mUsbIoProtocol = {
27};
28
29EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding = {
33 0xa,
34 NULL,
35 NULL
36};
37
58EFIAPI
62 IN EFI_USB_DATA_DIRECTION Direction,
63 IN UINT32 Timeout,
64 IN OUT VOID *Data OPTIONAL,
65 IN UINTN DataLength OPTIONAL,
66 OUT UINT32 *UsbStatus
67 )
68{
69 USB_DEVICE *Dev;
70 USB_INTERFACE *UsbIf;
71 USB_ENDPOINT_DESC *EpDesc;
72 EFI_TPL OldTpl;
73 EFI_STATUS Status;
74 UINTN RequestedDataLength;
75
76 if (UsbStatus == NULL) {
77 return EFI_INVALID_PARAMETER;
78 }
79
80 OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
81
82 UsbIf = USB_INTERFACE_FROM_USBIO (This);
83 Dev = UsbIf->Device;
84
85 RequestedDataLength = DataLength;
86 Status = UsbHcControlTransfer (
87 Dev->Bus,
88 Dev->Address,
89 Dev->Speed,
90 Dev->MaxPacket0,
91 Request,
92 Direction,
93 Data,
94 &DataLength,
95 (UINTN)Timeout,
96 &Dev->Translator,
97 UsbStatus
98 );
99 //
100 // If the request completed successfully and the Direction of the request is
101 // EfiUsbDataIn or EfiUsbDataOut, then make sure the actual number of bytes
102 // transferred is the same as the number of bytes requested. If a different
103 // number of bytes were transferred, then return EFI_DEVICE_ERROR.
104 //
105 if (!EFI_ERROR (Status)) {
106 if ((Direction != EfiUsbNoData) && (DataLength != RequestedDataLength)) {
107 Status = EFI_DEVICE_ERROR;
108 goto ON_EXIT;
109 }
110 }
111
112 if (EFI_ERROR (Status) || (*UsbStatus != EFI_USB_NOERROR)) {
113 //
114 // Clear TT buffer when CTRL/BULK split transaction failes
115 // Clear the TRANSLATOR TT buffer, not parent's buffer
116 //
117 ASSERT (Dev->Translator.TranslatorHubAddress < Dev->Bus->MaxDevices);
118 if (Dev->Translator.TranslatorHubAddress != 0) {
120 Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress],
121 Dev->Translator.TranslatorPortNumber,
122 Dev->Address,
123 0,
124 USB_ENDPOINT_CONTROL
125 );
126 }
127
128 goto ON_EXIT;
129 }
130
131 //
132 // Some control transfer will change the device's internal
133 // status, such as Set_Configuration and Set_Interface.
134 // We must synchronize the bus driver's status with that in
135 // device. We ignore the Set_Descriptor request because it's
136 // hardly used by any device, especially in pre-boot environment
137 //
138
139 //
140 // Reset the endpoint toggle when endpoint stall is cleared
141 //
142 if ((Request->Request == USB_REQ_CLEAR_FEATURE) &&
143 (Request->RequestType == USB_REQUEST_TYPE (
144 EfiUsbNoData,
145 USB_REQ_TYPE_STANDARD,
146 USB_TARGET_ENDPOINT
147 )) &&
148 (Request->Value == USB_FEATURE_ENDPOINT_HALT))
149 {
150 EpDesc = UsbGetEndpointDesc (UsbIf, (UINT8)Request->Index);
151
152 if (EpDesc != NULL) {
153 EpDesc->Toggle = 0;
154 }
155 }
156
157 //
158 // Select a new configuration. This is a dangerous action. Upper driver
159 // should stop use its current UsbIo after calling this driver. The old
160 // UsbIo will be uninstalled and new UsbIo be installed. We can't use
161 // ReinstallProtocol since interfaces in different configuration may be
162 // completely irrelevant.
163 //
164 if ((Request->Request == USB_REQ_SET_CONFIG) &&
165 (Request->RequestType == USB_REQUEST_TYPE (
166 EfiUsbNoData,
167 USB_REQ_TYPE_STANDARD,
168 USB_TARGET_DEVICE
169 )))
170 {
171 //
172 // Don't re-create the USB interfaces if configuration isn't changed.
173 //
174 if ((Dev->ActiveConfig != NULL) &&
175 (Request->Value == Dev->ActiveConfig->Desc.ConfigurationValue))
176 {
177 goto ON_EXIT;
178 }
179
180 DEBUG ((DEBUG_INFO, "UsbIoControlTransfer: configure changed!!! Do NOT use old UsbIo!!!\n"));
181
182 if (Dev->ActiveConfig != NULL) {
183 UsbRemoveConfig (Dev);
184 }
185
186 if (Request->Value != 0) {
187 Status = UsbSelectConfig (Dev, (UINT8)Request->Value);
188 }
189
190 //
191 // Exit now, Old USB_IO is invalid now
192 //
193 goto ON_EXIT;
194 }
195
196 //
197 // A new alternative setting is selected for the interface.
198 // No need to reinstall UsbIo in this case because only
199 // underlying communication endpoints are changed. Functionality
200 // should remains the same.
201 //
202 if ((Request->Request == USB_REQ_SET_INTERFACE) &&
203 (Request->RequestType == USB_REQUEST_TYPE (
204 EfiUsbNoData,
205 USB_REQ_TYPE_STANDARD,
206 USB_TARGET_INTERFACE
207 )) &&
208 (Request->Index == UsbIf->IfSetting->Desc.InterfaceNumber))
209 {
210 Status = UsbSelectSetting (UsbIf->IfDesc, (UINT8)Request->Value);
211
212 if (!EFI_ERROR (Status)) {
213 ASSERT (UsbIf->IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
214 UsbIf->IfSetting = UsbIf->IfDesc->Settings[UsbIf->IfDesc->ActiveIndex];
215 }
216 }
217
218ON_EXIT:
219 gBS->RestoreTPL (OldTpl);
220 return Status;
221}
222
240EFIAPI
243 IN UINT8 Endpoint,
244 IN OUT VOID *Data,
245 IN OUT UINTN *DataLength,
246 IN UINTN Timeout,
247 OUT UINT32 *UsbStatus
248 )
249{
250 USB_DEVICE *Dev;
251 USB_INTERFACE *UsbIf;
252 USB_ENDPOINT_DESC *EpDesc;
253 UINT8 BufNum;
254 UINT8 Toggle;
255 EFI_TPL OldTpl;
256 EFI_STATUS Status;
257
258 if ((USB_ENDPOINT_ADDR (Endpoint) == 0) || (USB_ENDPOINT_ADDR (Endpoint) > 15) ||
259 (UsbStatus == NULL))
260 {
261 return EFI_INVALID_PARAMETER;
262 }
263
264 OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
265
266 UsbIf = USB_INTERFACE_FROM_USBIO (This);
267 Dev = UsbIf->Device;
268
269 EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint);
270
271 if ((EpDesc == NULL) || (USB_ENDPOINT_TYPE (&EpDesc->Desc) != USB_ENDPOINT_BULK)) {
272 Status = EFI_INVALID_PARAMETER;
273 goto ON_EXIT;
274 }
275
276 BufNum = 1;
277 Toggle = EpDesc->Toggle;
278 Status = UsbHcBulkTransfer (
279 Dev->Bus,
280 Dev->Address,
281 Endpoint,
282 Dev->Speed,
283 EpDesc->Desc.MaxPacketSize,
284 BufNum,
285 &Data,
286 DataLength,
287 &Toggle,
288 Timeout,
289 &Dev->Translator,
290 UsbStatus
291 );
292
293 EpDesc->Toggle = Toggle;
294
295 if (EFI_ERROR (Status) || (*UsbStatus != EFI_USB_NOERROR)) {
296 //
297 // Clear TT buffer when CTRL/BULK split transaction failes.
298 // Clear the TRANSLATOR TT buffer, not parent's buffer
299 //
300 ASSERT (Dev->Translator.TranslatorHubAddress < Dev->Bus->MaxDevices);
301 if (Dev->Translator.TranslatorHubAddress != 0) {
303 Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress],
304 Dev->Translator.TranslatorPortNumber,
305 Dev->Address,
306 0,
307 USB_ENDPOINT_BULK
308 );
309 }
310 }
311
312ON_EXIT:
313 gBS->RestoreTPL (OldTpl);
314 return Status;
315}
316
334EFIAPI
337 IN UINT8 Endpoint,
338 IN OUT VOID *Data,
339 IN OUT UINTN *DataLength,
340 IN UINTN Timeout,
341 OUT UINT32 *UsbStatus
342 )
343{
344 USB_DEVICE *Dev;
345 USB_INTERFACE *UsbIf;
346 USB_ENDPOINT_DESC *EpDesc;
347 EFI_TPL OldTpl;
348 UINT8 Toggle;
349 EFI_STATUS Status;
350
351 if ((USB_ENDPOINT_ADDR (Endpoint) == 0) || (USB_ENDPOINT_ADDR (Endpoint) > 15) ||
352 (UsbStatus == NULL))
353 {
354 return EFI_INVALID_PARAMETER;
355 }
356
357 OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
358
359 UsbIf = USB_INTERFACE_FROM_USBIO (This);
360 Dev = UsbIf->Device;
361
362 EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint);
363
364 if ((EpDesc == NULL) || (USB_ENDPOINT_TYPE (&EpDesc->Desc) != USB_ENDPOINT_INTERRUPT)) {
365 Status = EFI_INVALID_PARAMETER;
366 goto ON_EXIT;
367 }
368
369 Toggle = EpDesc->Toggle;
371 Dev->Bus,
372 Dev->Address,
373 Endpoint,
374 Dev->Speed,
375 EpDesc->Desc.MaxPacketSize,
376 Data,
377 DataLength,
378 &Toggle,
379 Timeout,
380 &Dev->Translator,
381 UsbStatus
382 );
383
384 EpDesc->Toggle = Toggle;
385
386ON_EXIT:
387 gBS->RestoreTPL (OldTpl);
388 return Status;
389}
390
412EFIAPI
415 IN UINT8 Endpoint,
416 IN BOOLEAN IsNewTransfer,
417 IN UINTN PollInterval OPTIONAL,
418 IN UINTN DataLength OPTIONAL,
419 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback OPTIONAL,
420 IN VOID *Context OPTIONAL
421 )
422{
423 USB_DEVICE *Dev;
424 USB_INTERFACE *UsbIf;
425 USB_ENDPOINT_DESC *EpDesc;
426 EFI_TPL OldTpl;
427 UINT8 Toggle;
428 EFI_STATUS Status;
429
430 if ((USB_ENDPOINT_ADDR (Endpoint) == 0) || (USB_ENDPOINT_ADDR (Endpoint) > 15)) {
431 return EFI_INVALID_PARAMETER;
432 }
433
434 OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
435 UsbIf = USB_INTERFACE_FROM_USBIO (This);
436 Dev = UsbIf->Device;
437
438 EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint);
439
440 if ((EpDesc == NULL) || (USB_ENDPOINT_TYPE (&EpDesc->Desc) != USB_ENDPOINT_INTERRUPT)) {
441 Status = EFI_INVALID_PARAMETER;
442 goto ON_EXIT;
443 }
444
445 Toggle = EpDesc->Toggle;
447 Dev->Bus,
448 Dev->Address,
449 Endpoint,
450 Dev->Speed,
451 EpDesc->Desc.MaxPacketSize,
452 IsNewTransfer,
453 &Toggle,
454 PollInterval,
455 DataLength,
456 &Dev->Translator,
457 Callback,
458 Context
459 );
460
461 EpDesc->Toggle = Toggle;
462
463ON_EXIT:
464 gBS->RestoreTPL (OldTpl);
465 return Status;
466}
467
481EFIAPI
484 IN UINT8 DeviceEndpoint,
485 IN OUT VOID *Data,
486 IN UINTN DataLength,
487 OUT UINT32 *Status
488 )
489{
490 return EFI_UNSUPPORTED;
491}
492
508EFIAPI
511 IN UINT8 DeviceEndpoint,
512 IN OUT VOID *Data,
513 IN UINTN DataLength,
514 IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
515 IN VOID *Context OPTIONAL
516 )
517{
518 return EFI_UNSUPPORTED;
519}
520
532EFIAPI
536 )
537{
538 USB_DEVICE *Dev;
539 USB_INTERFACE *UsbIf;
540 EFI_TPL OldTpl;
541
542 if (Descriptor == NULL) {
543 return EFI_INVALID_PARAMETER;
544 }
545
546 OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
547
548 UsbIf = USB_INTERFACE_FROM_USBIO (This);
549 Dev = UsbIf->Device;
550
551 CopyMem (Descriptor, &Dev->DevDesc->Desc, sizeof (EFI_USB_DEVICE_DESCRIPTOR));
552
553 gBS->RestoreTPL (OldTpl);
554 return EFI_SUCCESS;
555}
556
569EFIAPI
573 )
574{
575 USB_DEVICE *Dev;
576 USB_INTERFACE *UsbIf;
577 EFI_STATUS Status;
578 EFI_TPL OldTpl;
579
580 if (Descriptor == NULL) {
581 return EFI_INVALID_PARAMETER;
582 }
583
584 Status = EFI_SUCCESS;
585 OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
586
587 UsbIf = USB_INTERFACE_FROM_USBIO (This);
588 Dev = UsbIf->Device;
589
590 if (Dev->ActiveConfig == NULL) {
591 Status = EFI_NOT_FOUND;
592 goto ON_EXIT;
593 }
594
595 CopyMem (Descriptor, &(Dev->ActiveConfig->Desc), sizeof (EFI_USB_CONFIG_DESCRIPTOR));
596
597ON_EXIT:
598 gBS->RestoreTPL (OldTpl);
599 return Status;
600}
601
613EFIAPI
617 )
618{
619 USB_INTERFACE *UsbIf;
620 EFI_TPL OldTpl;
621
622 if (Descriptor == NULL) {
623 return EFI_INVALID_PARAMETER;
624 }
625
626 OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
627
628 UsbIf = USB_INTERFACE_FROM_USBIO (This);
629 CopyMem (Descriptor, &(UsbIf->IfSetting->Desc), sizeof (EFI_USB_INTERFACE_DESCRIPTOR));
630
631 gBS->RestoreTPL (OldTpl);
632 return EFI_SUCCESS;
633}
634
648EFIAPI
651 IN UINT8 Index,
653 )
654{
655 USB_INTERFACE *UsbIf;
656 EFI_TPL OldTpl;
657
658 OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
659
660 UsbIf = USB_INTERFACE_FROM_USBIO (This);
661
662 if ((Descriptor == NULL) || (Index > 15)) {
663 gBS->RestoreTPL (OldTpl);
664 return EFI_INVALID_PARAMETER;
665 }
666
667 if (Index >= UsbIf->IfSetting->Desc.NumEndpoints) {
668 gBS->RestoreTPL (OldTpl);
669 return EFI_NOT_FOUND;
670 }
671
672 CopyMem (
673 Descriptor,
674 &(UsbIf->IfSetting->Endpoints[Index]->Desc),
676 );
677
678 gBS->RestoreTPL (OldTpl);
679 return EFI_SUCCESS;
680}
681
693EFIAPI
696 OUT UINT16 **LangIDTable,
697 OUT UINT16 *TableSize
698 )
699{
700 USB_DEVICE *Dev;
701 USB_INTERFACE *UsbIf;
702 EFI_TPL OldTpl;
703
704 OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
705
706 UsbIf = USB_INTERFACE_FROM_USBIO (This);
707 Dev = UsbIf->Device;
708
709 *LangIDTable = Dev->LangId;
710 *TableSize = (UINT16)(Dev->TotalLangId * sizeof (UINT16));
711
712 gBS->RestoreTPL (OldTpl);
713 return EFI_SUCCESS;
714}
715
729EFIAPI
732 IN UINT16 LangID,
733 IN UINT8 StringIndex,
734 OUT CHAR16 **String
735 )
736{
737 USB_DEVICE *Dev;
738 USB_INTERFACE *UsbIf;
740 EFI_TPL OldTpl;
741 UINT8 *Buf;
742 UINT8 Index;
743 EFI_STATUS Status;
744
745 if ((StringIndex == 0) || (LangID == 0)) {
746 return EFI_NOT_FOUND;
747 }
748
749 OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
750
751 UsbIf = USB_INTERFACE_FROM_USBIO (This);
752 Dev = UsbIf->Device;
753
754 //
755 // Check whether language ID is supported
756 //
757 Status = EFI_NOT_FOUND;
758
759 for (Index = 0; Index < Dev->TotalLangId; Index++) {
760 ASSERT (Index < USB_MAX_LANG_ID);
761 if (Dev->LangId[Index] == LangID) {
762 break;
763 }
764 }
765
766 if (Index == Dev->TotalLangId) {
767 goto ON_EXIT;
768 }
769
770 //
771 // Retrieve the string descriptor then allocate a buffer
772 // to hold the string itself.
773 //
774 StrDesc = UsbGetOneString (Dev, StringIndex, LangID);
775
776 if (StrDesc == NULL) {
777 goto ON_EXIT;
778 }
779
780 if (StrDesc->Length <= 2) {
781 goto FREE_STR;
782 }
783
784 Buf = AllocateZeroPool (StrDesc->Length);
785
786 if (Buf == NULL) {
787 Status = EFI_OUT_OF_RESOURCES;
788 goto FREE_STR;
789 }
790
791 CopyMem (Buf, StrDesc->String, StrDesc->Length - 2);
792 *String = (CHAR16 *)Buf;
793 Status = EFI_SUCCESS;
794
795FREE_STR:
796 gBS->FreePool (StrDesc);
797
798ON_EXIT:
799 gBS->RestoreTPL (OldTpl);
800 return Status;
801}
802
814EFIAPI
817 )
818{
819 USB_INTERFACE *UsbIf;
820 USB_INTERFACE *HubIf;
821 USB_DEVICE *Dev;
822 EFI_TPL OldTpl;
823 EFI_STATUS Status;
824 UINT8 DevAddress;
825 UINT8 Config;
826
827 OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
828
829 UsbIf = USB_INTERFACE_FROM_USBIO (This);
830 Dev = UsbIf->Device;
831
832 if (UsbIf->IsHub) {
833 Status = EFI_INVALID_PARAMETER;
834 goto ON_EXIT;
835 }
836
837 HubIf = Dev->ParentIf;
838 Status = HubIf->HubApi->ResetPort (HubIf, Dev->ParentPort);
839
840 if (EFI_ERROR (Status)) {
841 DEBUG ((
842 DEBUG_ERROR,
843 "UsbIoPortReset: failed to reset hub port %d@hub %d - %r\n",
844 Dev->ParentPort,
845 Dev->ParentAddr,
846 Status
847 ));
848
849 goto ON_EXIT;
850 }
851
852 HubIf->HubApi->ClearPortChange (HubIf, Dev->ParentPort);
853
854 //
855 // Reset the device to its current address. The device now has an address
856 // of ZERO after port reset, so need to set Dev->Address to the device again for
857 // host to communicate with it.
858 //
859 DevAddress = Dev->Address;
860 Dev->Address = 0;
861 Status = UsbSetAddress (Dev, DevAddress);
862 Dev->Address = DevAddress;
863
864 gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL);
865
866 if (EFI_ERROR (Status)) {
867 //
868 // It may fail due to device disconnection or other reasons.
869 //
870 DEBUG ((
871 DEBUG_ERROR,
872 "UsbIoPortReset: failed to set address for device %d - %r\n",
873 Dev->Address,
874 Status
875 ));
876
877 goto ON_EXIT;
878 }
879
880 DEBUG ((DEBUG_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Dev->Address));
881
882 //
883 // Reset the current active configure, after this device
884 // is in CONFIGURED state.
885 //
886 if (Dev->ActiveConfig != NULL) {
887 UsbFreeDevDesc (Dev->DevDesc);
888
889 Status = UsbRemoveConfig (Dev);
890 if (EFI_ERROR (Status)) {
891 DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to remove configuration - %r\n", Status));
892 }
893
894 Status = UsbGetMaxPacketSize0 (Dev);
895 if (EFI_ERROR (Status)) {
896 DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to get max packet size - %r\n", Status));
897 }
898
899 Status = UsbBuildDescTable (Dev);
900 if (EFI_ERROR (Status)) {
901 DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to build descriptor table - %r\n", Status));
902 }
903
904 Config = Dev->DevDesc->Configs[0]->Desc.ConfigurationValue;
905
906 Status = UsbSetConfig (Dev, Config);
907 if (EFI_ERROR (Status)) {
908 DEBUG ((
909 DEBUG_ERROR,
910 "UsbIoPortReset: failed to set configure for device %d - %r\n",
911 Dev->Address,
912 Status
913 ));
914 }
915
916 Status = UsbSelectConfig (Dev, Config);
917 if (EFI_ERROR (Status)) {
918 DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to set configuration - %r\n", Status));
919 }
920 }
921
922ON_EXIT:
923 gBS->RestoreTPL (OldTpl);
924 return Status;
925}
926
940EFIAPI
943 IN EFI_HANDLE Controller,
944 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
945 )
946{
947 USB_BUS *UsbBus;
948 USB_DEVICE *RootHub;
949 USB_INTERFACE *RootIf;
950 EFI_STATUS Status;
951 EFI_STATUS Status2;
952
953 UsbBus = AllocateZeroPool (sizeof (USB_BUS));
954
955 if (UsbBus == NULL) {
956 return EFI_OUT_OF_RESOURCES;
957 }
958
959 UsbBus->Signature = USB_BUS_SIGNATURE;
960 UsbBus->HostHandle = Controller;
961 UsbBus->MaxDevices = USB_MAX_DEVICES;
962
963 Status = gBS->OpenProtocol (
964 Controller,
965 &gEfiDevicePathProtocolGuid,
966 (VOID **)&UsbBus->DevicePath,
967 This->DriverBindingHandle,
968 Controller,
969 EFI_OPEN_PROTOCOL_BY_DRIVER
970 );
971
972 if (EFI_ERROR (Status)) {
973 DEBUG ((DEBUG_ERROR, "UsbBusStart: Failed to open device path - %r\n", Status));
974
975 FreePool (UsbBus);
976 return Status;
977 }
978
979 //
980 // Get USB_HC2/USB_HC host controller protocol (EHCI/UHCI).
981 // This is for backward compatibility with EFI 1.x. In UEFI
982 // 2.x, USB_HC2 replaces USB_HC. We will open both USB_HC2
983 // and USB_HC because EHCI driver will install both protocols
984 // (for the same reason). If we don't consume both of them,
985 // the unconsumed one may be opened by others.
986 //
987 Status = gBS->OpenProtocol (
988 Controller,
989 &gEfiUsb2HcProtocolGuid,
990 (VOID **)&(UsbBus->Usb2Hc),
991 This->DriverBindingHandle,
992 Controller,
993 EFI_OPEN_PROTOCOL_BY_DRIVER
994 );
995
996 Status2 = gBS->OpenProtocol (
997 Controller,
998 &gEfiUsbHcProtocolGuid,
999 (VOID **)&(UsbBus->UsbHc),
1000 This->DriverBindingHandle,
1001 Controller,
1002 EFI_OPEN_PROTOCOL_BY_DRIVER
1003 );
1004
1005 if (EFI_ERROR (Status) && EFI_ERROR (Status2)) {
1006 DEBUG ((DEBUG_ERROR, "UsbBusStart: Failed to open USB_HC/USB2_HC - %r\n", Status));
1007
1008 Status = EFI_DEVICE_ERROR;
1009 goto CLOSE_HC;
1010 }
1011
1012 if (!EFI_ERROR (Status)) {
1013 //
1014 // The EFI_USB2_HC_PROTOCOL is produced for XHCI support.
1015 // Then its max supported devices are 256. Otherwise it's 128.
1016 //
1017 ASSERT (UsbBus->Usb2Hc != NULL);
1018 if (UsbBus->Usb2Hc->MajorRevision == 0x3) {
1019 UsbBus->MaxDevices = 256;
1020 }
1021 }
1022
1023 //
1024 // Install an EFI_USB_BUS_PROTOCOL to host controller to identify it.
1025 //
1026 Status = gBS->InstallProtocolInterface (
1027 &Controller,
1028 &gEfiCallerIdGuid,
1030 &UsbBus->BusId
1031 );
1032
1033 if (EFI_ERROR (Status)) {
1034 DEBUG ((DEBUG_ERROR, "UsbBusStart: Failed to install bus protocol - %r\n", Status));
1035 goto CLOSE_HC;
1036 }
1037
1038 //
1039 // Initial the wanted child device path list, and add first RemainingDevicePath
1040 //
1041 InitializeListHead (&UsbBus->WantedUsbIoDPList);
1042 Status = UsbBusAddWantedUsbIoDP (&UsbBus->BusId, RemainingDevicePath);
1043 ASSERT (!EFI_ERROR (Status));
1044 //
1045 // Create a fake usb device for root hub
1046 //
1047 RootHub = AllocateZeroPool (sizeof (USB_DEVICE));
1048
1049 if (RootHub == NULL) {
1050 Status = EFI_OUT_OF_RESOURCES;
1051 goto UNINSTALL_USBBUS;
1052 }
1053
1054 RootIf = AllocateZeroPool (sizeof (USB_INTERFACE));
1055
1056 if (RootIf == NULL) {
1057 FreePool (RootHub);
1058 Status = EFI_OUT_OF_RESOURCES;
1059 goto FREE_ROOTHUB;
1060 }
1061
1062 RootHub->Bus = UsbBus;
1063 RootHub->NumOfInterface = 1;
1064 RootHub->Interfaces[0] = RootIf;
1065 RootHub->Tier = 0;
1066 RootIf->Signature = USB_INTERFACE_SIGNATURE;
1067 RootIf->Device = RootHub;
1068 RootIf->DevicePath = UsbBus->DevicePath;
1069
1070 //
1071 // Report Status Code here since we will enumerate the USB devices
1072 //
1075 (EFI_IO_BUS_USB | EFI_IOB_PC_DETECT),
1076 UsbBus->DevicePath
1077 );
1078
1079 Status = mUsbRootHubApi.Init (RootIf);
1080
1081 if (EFI_ERROR (Status)) {
1082 DEBUG ((DEBUG_ERROR, "UsbBusStart: Failed to init root hub - %r\n", Status));
1083 goto FREE_ROOTHUB;
1084 }
1085
1086 UsbBus->Devices[0] = RootHub;
1087
1088 DEBUG ((DEBUG_INFO, "UsbBusStart: usb bus started on %p, root hub %p\n", Controller, RootIf));
1089 return EFI_SUCCESS;
1090
1091FREE_ROOTHUB:
1092 if (RootIf != NULL) {
1093 FreePool (RootIf);
1094 }
1095
1096 if (RootHub != NULL) {
1097 FreePool (RootHub);
1098 }
1099
1100UNINSTALL_USBBUS:
1101 gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid, &UsbBus->BusId);
1102
1103CLOSE_HC:
1104 if (UsbBus->Usb2Hc != NULL) {
1105 gBS->CloseProtocol (
1106 Controller,
1107 &gEfiUsb2HcProtocolGuid,
1108 This->DriverBindingHandle,
1109 Controller
1110 );
1111 }
1112
1113 if (UsbBus->UsbHc != NULL) {
1114 gBS->CloseProtocol (
1115 Controller,
1116 &gEfiUsbHcProtocolGuid,
1117 This->DriverBindingHandle,
1118 Controller
1119 );
1120 }
1121
1122 gBS->CloseProtocol (
1123 Controller,
1124 &gEfiDevicePathProtocolGuid,
1125 This->DriverBindingHandle,
1126 Controller
1127 );
1128 FreePool (UsbBus);
1129
1130 DEBUG ((DEBUG_ERROR, "UsbBusStart: Failed to start bus driver - %r\n", Status));
1131 return Status;
1132}
1133
1145EFIAPI
1147 IN EFI_HANDLE ImageHandle,
1148 IN EFI_SYSTEM_TABLE *SystemTable
1149 )
1150{
1152 ImageHandle,
1153 SystemTable,
1154 &mUsbBusDriverBinding,
1155 ImageHandle,
1156 &mUsbBusComponentName,
1157 &mUsbBusComponentName2
1158 );
1159}
1160
1173EFIAPI
1176 IN EFI_HANDLE Controller,
1177 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
1178 )
1179{
1180 EFI_DEV_PATH_PTR DevicePathNode;
1181 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
1182 EFI_USB2_HC_PROTOCOL *Usb2Hc;
1183 EFI_USB_HC_PROTOCOL *UsbHc;
1184 EFI_STATUS Status;
1185
1186 //
1187 // Check whether device path is valid
1188 //
1189 if (RemainingDevicePath != NULL) {
1190 //
1191 // Check if RemainingDevicePath is the End of Device Path Node,
1192 // if yes, go on checking other conditions
1193 //
1194 if (!IsDevicePathEnd (RemainingDevicePath)) {
1195 //
1196 // If RemainingDevicePath isn't the End of Device Path Node,
1197 // check its validation
1198 //
1199 DevicePathNode.DevPath = RemainingDevicePath;
1200
1201 if ((DevicePathNode.DevPath->Type != MESSAGING_DEVICE_PATH) ||
1202 ( (DevicePathNode.DevPath->SubType != MSG_USB_DP) &&
1203 (DevicePathNode.DevPath->SubType != MSG_USB_CLASS_DP)
1204 && (DevicePathNode.DevPath->SubType != MSG_USB_WWID_DP)
1205 ))
1206 {
1207 return EFI_UNSUPPORTED;
1208 }
1209 }
1210 }
1211
1212 //
1213 // Check whether USB_HC2 protocol is installed
1214 //
1215 Status = gBS->OpenProtocol (
1216 Controller,
1217 &gEfiUsb2HcProtocolGuid,
1218 (VOID **)&Usb2Hc,
1219 This->DriverBindingHandle,
1220 Controller,
1221 EFI_OPEN_PROTOCOL_BY_DRIVER
1222 );
1223 if (Status == EFI_ALREADY_STARTED) {
1224 return EFI_SUCCESS;
1225 }
1226
1227 if (EFI_ERROR (Status)) {
1228 //
1229 // If failed to open USB_HC2, fall back to USB_HC
1230 //
1231 Status = gBS->OpenProtocol (
1232 Controller,
1233 &gEfiUsbHcProtocolGuid,
1234 (VOID **)&UsbHc,
1235 This->DriverBindingHandle,
1236 Controller,
1237 EFI_OPEN_PROTOCOL_BY_DRIVER
1238 );
1239 if (Status == EFI_ALREADY_STARTED) {
1240 return EFI_SUCCESS;
1241 }
1242
1243 if (EFI_ERROR (Status)) {
1244 return Status;
1245 }
1246
1247 //
1248 // Close the USB_HC used to perform the supported test
1249 //
1250 gBS->CloseProtocol (
1251 Controller,
1252 &gEfiUsbHcProtocolGuid,
1253 This->DriverBindingHandle,
1254 Controller
1255 );
1256 } else {
1257 //
1258 // Close the USB_HC2 used to perform the supported test
1259 //
1260 gBS->CloseProtocol (
1261 Controller,
1262 &gEfiUsb2HcProtocolGuid,
1263 This->DriverBindingHandle,
1264 Controller
1265 );
1266 }
1267
1268 //
1269 // Open the EFI Device Path protocol needed to perform the supported test
1270 //
1271 Status = gBS->OpenProtocol (
1272 Controller,
1273 &gEfiDevicePathProtocolGuid,
1274 (VOID **)&ParentDevicePath,
1275 This->DriverBindingHandle,
1276 Controller,
1277 EFI_OPEN_PROTOCOL_BY_DRIVER
1278 );
1279 if (Status == EFI_ALREADY_STARTED) {
1280 return EFI_SUCCESS;
1281 }
1282
1283 if (!EFI_ERROR (Status)) {
1284 //
1285 // Close protocol, don't use device path protocol in the Support() function
1286 //
1287 gBS->CloseProtocol (
1288 Controller,
1289 &gEfiDevicePathProtocolGuid,
1290 This->DriverBindingHandle,
1291 Controller
1292 );
1293
1294 return EFI_SUCCESS;
1295 }
1296
1297 return Status;
1298}
1299
1314EFIAPI
1317 IN EFI_HANDLE Controller,
1318 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
1319 )
1320{
1321 EFI_USB_BUS_PROTOCOL *UsbBusId;
1322 EFI_STATUS Status;
1323 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
1324
1325 Status = gBS->OpenProtocol (
1326 Controller,
1327 &gEfiDevicePathProtocolGuid,
1328 (VOID **)&ParentDevicePath,
1329 This->DriverBindingHandle,
1330 Controller,
1331 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1332 );
1333 ASSERT_EFI_ERROR (Status);
1334
1335 //
1336 // Report Status Code here since we will initialize the host controller
1337 //
1340 (EFI_IO_BUS_USB | EFI_IOB_PC_INIT),
1341 ParentDevicePath
1342 );
1343
1344 //
1345 // Locate the USB bus protocol, if it is found, USB bus
1346 // is already started on this controller.
1347 //
1348 Status = gBS->OpenProtocol (
1349 Controller,
1350 &gEfiCallerIdGuid,
1351 (VOID **)&UsbBusId,
1352 This->DriverBindingHandle,
1353 Controller,
1354 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1355 );
1356
1357 if (EFI_ERROR (Status)) {
1358 //
1359 // If first start, build the bus execute environment and install bus protocol
1360 //
1361 REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_IO_BUS_USB | EFI_P_PC_ENABLE));
1362 Status = UsbBusBuildProtocol (This, Controller, RemainingDevicePath);
1363 if (EFI_ERROR (Status)) {
1364 return Status;
1365 }
1366
1367 //
1368 // Try get the Usb Bus protocol interface again
1369 //
1370 Status = gBS->OpenProtocol (
1371 Controller,
1372 &gEfiCallerIdGuid,
1373 (VOID **)&UsbBusId,
1374 This->DriverBindingHandle,
1375 Controller,
1376 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1377 );
1378 ASSERT (!EFI_ERROR (Status));
1379 } else {
1380 //
1381 // USB Bus driver need to control the recursive connect policy of the bus, only those wanted
1382 // usb child device will be recursively connected.
1383 // The RemainingDevicePath indicate the child usb device which user want to fully recursively connecte this time.
1384 // All wanted usb child devices will be remembered by the usb bus driver itself.
1385 // If RemainingDevicePath == NULL, all the usb child devices in the usb bus are wanted devices.
1386 //
1387 // Save the passed in RemainingDevicePath this time
1388 //
1389 if (RemainingDevicePath != NULL) {
1390 if (IsDevicePathEnd (RemainingDevicePath)) {
1391 //
1392 // If RemainingDevicePath is the End of Device Path Node,
1393 // skip enumerate any device and return EFI_SUCCESS
1394 //
1395 return EFI_SUCCESS;
1396 }
1397 }
1398
1399 Status = UsbBusAddWantedUsbIoDP (UsbBusId, RemainingDevicePath);
1400 ASSERT (!EFI_ERROR (Status));
1401 //
1402 // Ensure all wanted child usb devices are fully recursively connected
1403 //
1404 Status = UsbBusRecursivelyConnectWantedUsbIo (UsbBusId);
1405 ASSERT (!EFI_ERROR (Status));
1406 }
1407
1408 return EFI_SUCCESS;
1409}
1410
1425EFIAPI
1428 IN EFI_HANDLE Controller,
1429 IN UINTN NumberOfChildren,
1430 IN EFI_HANDLE *ChildHandleBuffer
1431 )
1432{
1433 USB_BUS *Bus;
1434 USB_DEVICE *RootHub;
1435 USB_DEVICE *UsbDev;
1436 USB_INTERFACE *RootIf;
1437 USB_INTERFACE *UsbIf;
1438 EFI_USB_BUS_PROTOCOL *BusId;
1439 EFI_USB_IO_PROTOCOL *UsbIo;
1440 EFI_TPL OldTpl;
1441 UINTN Index;
1442 EFI_STATUS Status;
1443 EFI_STATUS ReturnStatus;
1444
1445 Status = EFI_SUCCESS;
1446
1447 if (NumberOfChildren > 0) {
1448 //
1449 // BugBug: Raise TPL to callback level instead of USB_BUS_TPL to avoid TPL conflict
1450 //
1451 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
1452
1453 ReturnStatus = EFI_SUCCESS;
1454 for (Index = 0; Index < NumberOfChildren; Index++) {
1455 Status = gBS->OpenProtocol (
1456 ChildHandleBuffer[Index],
1457 &gEfiUsbIoProtocolGuid,
1458 (VOID **)&UsbIo,
1459 This->DriverBindingHandle,
1460 Controller,
1461 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1462 );
1463
1464 if (EFI_ERROR (Status)) {
1465 //
1466 // It is possible that the child has already been released:
1467 // 1. For combo device, free one device will release others.
1468 // 2. If a hub is released, all devices on its down facing
1469 // ports are released also.
1470 //
1471 continue;
1472 }
1473
1474 UsbIf = USB_INTERFACE_FROM_USBIO (UsbIo);
1475 UsbDev = UsbIf->Device;
1476
1477 ReturnStatus = UsbRemoveDevice (UsbDev);
1478 }
1479
1480 gBS->RestoreTPL (OldTpl);
1481 return ReturnStatus;
1482 }
1483
1484 DEBUG ((DEBUG_INFO, "UsbBusStop: usb bus stopped on %p\n", Controller));
1485
1486 //
1487 // Locate USB_BUS for the current host controller
1488 //
1489 Status = gBS->OpenProtocol (
1490 Controller,
1491 &gEfiCallerIdGuid,
1492 (VOID **)&BusId,
1493 This->DriverBindingHandle,
1494 Controller,
1495 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1496 );
1497
1498 if (EFI_ERROR (Status)) {
1499 return Status;
1500 }
1501
1502 Bus = USB_BUS_FROM_THIS (BusId);
1503
1504 //
1505 // Stop the root hub, then free all the devices
1506 //
1507 // BugBug: Raise TPL to callback level instead of USB_BUS_TPL to avoid TPL conflict
1508 //
1509 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
1510
1511 RootHub = Bus->Devices[0];
1512 RootIf = RootHub->Interfaces[0];
1513
1514 ASSERT (Bus->MaxDevices <= 256);
1515 ReturnStatus = EFI_SUCCESS;
1516 for (Index = 1; Index < Bus->MaxDevices; Index++) {
1517 if (Bus->Devices[Index] != NULL) {
1518 Status = UsbRemoveDevice (Bus->Devices[Index]);
1519 if (EFI_ERROR (Status)) {
1520 ReturnStatus = Status;
1521 }
1522 }
1523 }
1524
1525 gBS->RestoreTPL (OldTpl);
1526
1527 if (!EFI_ERROR (ReturnStatus)) {
1528 mUsbRootHubApi.Release (RootIf);
1529 gBS->FreePool (RootIf);
1530 gBS->FreePool (RootHub);
1531
1532 Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);
1533 ASSERT (!EFI_ERROR (Status));
1534
1535 //
1536 // Uninstall the bus identifier and close USB_HC/USB2_HC protocols
1537 //
1538 gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid, &Bus->BusId);
1539
1540 if (Bus->Usb2Hc != NULL) {
1541 Status = gBS->CloseProtocol (
1542 Controller,
1543 &gEfiUsb2HcProtocolGuid,
1544 This->DriverBindingHandle,
1545 Controller
1546 );
1547 }
1548
1549 if (Bus->UsbHc != NULL) {
1550 Status = gBS->CloseProtocol (
1551 Controller,
1552 &gEfiUsbHcProtocolGuid,
1553 This->DriverBindingHandle,
1554 Controller
1555 );
1556 }
1557
1558 if (!EFI_ERROR (Status)) {
1559 gBS->CloseProtocol (
1560 Controller,
1561 &gEfiDevicePathProtocolGuid,
1562 This->DriverBindingHandle,
1563 Controller
1564 );
1565
1566 gBS->FreePool (Bus);
1567 }
1568 }
1569
1570 return Status;
1571}
UINT64 UINTN
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define MSG_USB_WWID_DP
Definition: DevicePath.h:467
#define MSG_USB_DP
Definition: DevicePath.h:418
#define MSG_USB_CLASS_DP
Definition: DevicePath.h:434
#define MESSAGING_DEVICE_PATH
Definition: DevicePath.h:321
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define REPORT_STATUS_CODE(Type, Value)
#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type, Value, DevicePathParameter)
EFI_USB_DATA_DIRECTION
Definition: UsbIo.h:44
EFI_STATUS(EFIAPI * EFI_ASYNC_USB_TRANSFER_CALLBACK)(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Status)
Definition: UsbIo.h:80
#define EFI_IOB_PC_INIT
Definition: PiStatusCode.h:549
#define EFI_PROGRESS_CODE
Definition: PiStatusCode.h:43
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
UINTN EFI_TPL
Definition: UefiBaseType.h:41
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
@ EFI_NATIVE_INTERFACE
Definition: UefiSpec.h:1193
EFI_STATUS EFIAPI UsbBusBuildProtocol(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbBus.c:941
EFI_STATUS EFIAPI UsbIoAsyncInterruptTransfer(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Endpoint, IN BOOLEAN IsNewTransfer, IN UINTN PollInterval OPTIONAL, IN UINTN DataLength OPTIONAL, IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback OPTIONAL, IN VOID *Context OPTIONAL)
Definition: UsbBus.c:413
EFI_STATUS EFIAPI UsbIoSyncInterruptTransfer(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Endpoint, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN UINTN Timeout, OUT UINT32 *UsbStatus)
Definition: UsbBus.c:335
EFI_STATUS EFIAPI UsbBusControllerDriverSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbBus.c:1174
EFI_STATUS EFIAPI UsbIoGetEndpointDescriptor(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Index, OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor)
Definition: UsbBus.c:649
EFI_STATUS EFIAPI UsbIoIsochronousTransfer(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 DeviceEndpoint, IN OUT VOID *Data, IN UINTN DataLength, OUT UINT32 *Status)
Definition: UsbBus.c:482
EFI_STATUS EFIAPI UsbBusControllerDriverStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: UsbBus.c:1426
EFI_STATUS EFIAPI UsbIoGetActiveConfigDescriptor(IN EFI_USB_IO_PROTOCOL *This, OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor)
Definition: UsbBus.c:570
EFI_STATUS EFIAPI UsbIoGetInterfaceDescriptor(IN EFI_USB_IO_PROTOCOL *This, OUT EFI_USB_INTERFACE_DESCRIPTOR *Descriptor)
Definition: UsbBus.c:614
EFI_STATUS EFIAPI UsbIoGetSupportedLanguages(IN EFI_USB_IO_PROTOCOL *This, OUT UINT16 **LangIDTable, OUT UINT16 *TableSize)
Definition: UsbBus.c:694
EFI_STATUS EFIAPI UsbIoGetStringDescriptor(IN EFI_USB_IO_PROTOCOL *This, IN UINT16 LangID, IN UINT8 StringIndex, OUT CHAR16 **String)
Definition: UsbBus.c:730
EFI_STATUS EFIAPI UsbBusDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: UsbBus.c:1146
EFI_STATUS EFIAPI UsbIoAsyncIsochronousTransfer(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 DeviceEndpoint, IN OUT VOID *Data, IN UINTN DataLength, IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, IN VOID *Context OPTIONAL)
Definition: UsbBus.c:509
EFI_STATUS EFIAPI UsbIoGetDeviceDescriptor(IN EFI_USB_IO_PROTOCOL *This, OUT EFI_USB_DEVICE_DESCRIPTOR *Descriptor)
Definition: UsbBus.c:533
EFI_STATUS EFIAPI UsbBusControllerDriverStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbBus.c:1315
EFI_STATUS EFIAPI UsbIoControlTransfer(IN EFI_USB_IO_PROTOCOL *This, IN EFI_USB_DEVICE_REQUEST *Request, IN EFI_USB_DATA_DIRECTION Direction, IN UINT32 Timeout, IN OUT VOID *Data OPTIONAL, IN UINTN DataLength OPTIONAL, OUT UINT32 *UsbStatus)
Definition: UsbBus.c:59
EFI_STATUS EFIAPI UsbIoBulkTransfer(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Endpoint, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN UINTN Timeout, OUT UINT32 *UsbStatus)
Definition: UsbBus.c:241
EFI_STATUS EFIAPI UsbIoPortReset(IN EFI_USB_IO_PROTOCOL *This)
Definition: UsbBus.c:815
EFI_STATUS EFIAPI UsbBusAddWantedUsbIoDP(IN EFI_USB_BUS_PROTOCOL *UsbBusId, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbUtility.c:951
EFI_STATUS EFIAPI UsbBusFreeUsbDPList(IN LIST_ENTRY *UsbIoDPList)
Definition: UsbUtility.c:902
EFI_STATUS EFIAPI UsbBusRecursivelyConnectWantedUsbIo(IN EFI_USB_BUS_PROTOCOL *UsbBusId)
Definition: UsbUtility.c:1134
EFI_STATUS UsbBuildDescTable(IN USB_DEVICE *UsbDev)
Definition: UsbDesc.c:811
EFI_USB_STRING_DESCRIPTOR * UsbGetOneString(IN USB_DEVICE *UsbDev, IN UINT8 Index, IN UINT16 LangId)
Definition: UsbDesc.c:633
EFI_STATUS UsbSetConfig(IN USB_DEVICE *UsbDev, IN UINT8 ConfigIndex)
Definition: UsbDesc.c:946
EFI_STATUS UsbSetAddress(IN USB_DEVICE *UsbDev, IN UINT8 Address)
Definition: UsbDesc.c:911
EFI_STATUS UsbGetMaxPacketSize0(IN USB_DEVICE *UsbDev)
Definition: UsbDesc.c:548
VOID UsbFreeDevDesc(IN USB_DEVICE_DESC *DevDesc)
Definition: UsbDesc.c:101
EFI_STATUS UsbSelectConfig(IN USB_DEVICE *Device, IN UINT8 ConfigValue)
Definition: UsbEnumer.c:370
EFI_STATUS UsbRemoveDevice(IN USB_DEVICE *Device)
Definition: UsbEnumer.c:558
EFI_STATUS UsbRemoveConfig(IN USB_DEVICE *Device)
Definition: UsbEnumer.c:509
EFI_STATUS UsbSelectSetting(IN USB_INTERFACE_DESC *IfDesc, IN UINT8 Alternate)
Definition: UsbEnumer.c:311
USB_ENDPOINT_DESC * UsbGetEndpointDesc(IN USB_INTERFACE *UsbIf, IN UINT8 EpAddr)
Definition: UsbEnumer.c:22
EFI_STATUS UsbHubCtrlClearTTBuffer(IN USB_DEVICE *HubDev, IN UINT8 Port, IN UINT16 DevAddr, IN UINT16 EpNum, IN UINT16 EpType)
Definition: UsbHub.c:164
EFI_STATUS UsbHcSyncInterruptTransfer(IN USB_BUS *UsbBus, IN UINT8 DevAddr, IN UINT8 EpAddr, IN UINT8 DevSpeed, IN UINTN MaxPacket, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN TimeOut, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, OUT UINT32 *UsbResult)
Definition: UsbUtility.c:411
EFI_STATUS UsbHcAsyncInterruptTransfer(IN USB_BUS *UsbBus, IN UINT8 DevAddr, IN UINT8 EpAddr, IN UINT8 DevSpeed, IN UINTN MaxPacket, IN BOOLEAN IsNewTransfer, IN OUT UINT8 *DataToggle, IN UINTN PollingInterval, IN UINTN DataLength, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback, IN VOID *Context OPTIONAL)
Definition: UsbUtility.c:335
EFI_STATUS UsbHcBulkTransfer(IN USB_BUS *UsbBus, IN UINT8 DevAddr, IN UINT8 EpAddr, IN UINT8 DevSpeed, IN UINTN MaxPacket, IN UINT8 BufferNum, IN OUT VOID *Data[], IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN TimeOut, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, OUT UINT32 *UsbResult)
Definition: UsbUtility.c:263
EFI_STATUS UsbHcControlTransfer(IN USB_BUS *UsbBus, IN UINT8 DevAddr, IN UINT8 DevSpeed, IN UINTN MaxPacket, IN EFI_USB_DEVICE_REQUEST *Request, IN EFI_USB_DATA_DIRECTION Direction, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN UINTN TimeOut, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, OUT UINT32 *UsbResult)
Definition: UsbUtility.c:190
UINT8 TranslatorPortNumber
the port number of the hub that device is connected to.