3 Usb bus enumeration support.
5 Copyright (c) 2007 - 2008, 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.
20 Return the endpoint descriptor in this interface.
22 @param UsbIf The interface to search in.
23 @param EpAddr The address of the endpoint to return.
25 @return The endpoint descriptor or NULL.
30 IN USB_INTERFACE
*UsbIf
,
34 USB_ENDPOINT_DESC
*EpDesc
;
38 NumEndpoints
= UsbIf
->IfSetting
->Desc
.NumEndpoints
;
40 for (Index
= 0; Index
< NumEndpoints
; Index
++) {
41 EpDesc
= UsbIf
->IfSetting
->Endpoints
[Index
];
43 if (EpDesc
->Desc
.EndpointAddress
== EpAddr
) {
53 Free the resource used by USB interface.
55 @param UsbIf The USB interface to free.
62 IN USB_INTERFACE
*UsbIf
65 UsbCloseHostProtoByChild (UsbIf
->Device
->Bus
, UsbIf
->Handle
);
67 gBS
->UninstallMultipleProtocolInterfaces (
69 &gEfiDevicePathProtocolGuid
,
71 &gEfiUsbIoProtocolGuid
,
76 if (UsbIf
->DevicePath
!= NULL
) {
77 FreePool (UsbIf
->DevicePath
);
85 Create an interface for the descriptor IfDesc. Each
86 device's configuration can have several interfaces.
88 @param Device The device has the interface descriptor.
89 @param IfDesc The interface descriptor.
91 @return The created USB interface for the descriptor, or NULL.
96 IN USB_DEVICE
*Device
,
97 IN USB_INTERFACE_DESC
*IfDesc
100 USB_DEVICE_PATH UsbNode
;
101 USB_INTERFACE
*UsbIf
;
102 USB_INTERFACE
*HubIf
;
105 UsbIf
= AllocateZeroPool (sizeof (USB_INTERFACE
));
111 UsbIf
->Signature
= USB_INTERFACE_SIGNATURE
;
112 UsbIf
->Device
= Device
;
113 UsbIf
->IfDesc
= IfDesc
;
114 UsbIf
->IfSetting
= IfDesc
->Settings
[IfDesc
->ActiveIndex
];
119 sizeof (EFI_USB_IO_PROTOCOL
)
123 // Install protocols for USBIO and device path
125 UsbNode
.Header
.Type
= MESSAGING_DEVICE_PATH
;
126 UsbNode
.Header
.SubType
= MSG_USB_DP
;
127 UsbNode
.ParentPortNumber
= Device
->ParentPort
;
128 UsbNode
.InterfaceNumber
= UsbIf
->IfSetting
->Desc
.InterfaceNumber
;
130 SetDevicePathNodeLength (&UsbNode
.Header
, sizeof (UsbNode
));
132 HubIf
= Device
->ParentIf
;
133 ASSERT (HubIf
!= NULL
);
135 UsbIf
->DevicePath
= AppendDevicePathNode (HubIf
->DevicePath
, &UsbNode
.Header
);
137 if (UsbIf
->DevicePath
== NULL
) {
138 DEBUG ((EFI_D_ERROR
, "UsbCreateInterface: failed to create device path\n"));
140 Status
= EFI_OUT_OF_RESOURCES
;
144 Status
= gBS
->InstallMultipleProtocolInterfaces (
146 &gEfiDevicePathProtocolGuid
,
148 &gEfiUsbIoProtocolGuid
,
153 if (EFI_ERROR (Status
)) {
154 DEBUG ((EFI_D_ERROR
, "UsbCreateInterface: failed to install UsbIo - %r\n", Status
));
159 // Open USB Host Controller Protocol by Child
161 Status
= UsbOpenHostProtoByChild (Device
->Bus
, UsbIf
->Handle
);
163 if (EFI_ERROR (Status
)) {
164 gBS
->UninstallMultipleProtocolInterfaces (
166 &gEfiDevicePathProtocolGuid
,
168 &gEfiUsbIoProtocolGuid
,
173 DEBUG ((EFI_D_ERROR
, "UsbCreateInterface: failed to open host for child - %r\n", Status
));
180 if (UsbIf
->DevicePath
!= NULL
) {
181 FreePool (UsbIf
->DevicePath
);
190 Free the resource used by this USB device.
192 @param Device The USB device to free.
199 IN USB_DEVICE
*Device
202 if (Device
->DevDesc
!= NULL
) {
203 UsbFreeDevDesc (Device
->DevDesc
);
206 gBS
->FreePool (Device
);
211 Create a device which is on the parent's ParentPort port.
213 @param ParentIf The parent HUB interface.
214 @param ParentPort The port on the HUB this device is connected to.
216 @return Created USB device, Or NULL.
221 IN USB_INTERFACE
*ParentIf
,
227 ASSERT (ParentIf
!= NULL
);
229 Device
= AllocateZeroPool (sizeof (USB_DEVICE
));
231 if (Device
== NULL
) {
235 Device
->Bus
= ParentIf
->Device
->Bus
;
236 Device
->MaxPacket0
= 8;
237 Device
->ParentAddr
= ParentIf
->Device
->Address
;
238 Device
->ParentIf
= ParentIf
;
239 Device
->ParentPort
= ParentPort
;
245 Connect the USB interface with its driver. EFI USB bus will
246 create a USB interface for each separate interface descriptor.
248 @param UsbIf The interface to connect driver to.
250 @return EFI_SUCCESS Interface is managed by some driver.
251 @return Others Failed to locate a driver for this interface.
256 IN USB_INTERFACE
*UsbIf
262 Status
= EFI_SUCCESS
;
265 // Hub is maintained by the USB bus driver. Otherwise try to
266 // connect drivers with this interface
268 if (UsbIsHubInterface (UsbIf
)) {
269 DEBUG ((EFI_D_INFO
, "UsbConnectDriver: found a hub device\n"));
270 Status
= mUsbHubApi
.Init (UsbIf
);
274 // This function is called in both UsbIoControlTransfer and
275 // the timer callback in hub enumeration. So, at least it is
276 // called at TPL_CALLBACK. Some driver sitting on USB has
277 // twisted TPL used. It should be no problem for us to connect
278 // or disconnect at CALLBACK.
282 // Only recursively wanted usb child device
284 if (UsbBusIsWantedUsbIO (UsbIf
->Device
->Bus
, UsbIf
)) {
285 OldTpl
= UsbGetCurrentTpl ();
286 DEBUG ((EFI_D_INFO
, "UsbConnectDriver: TPL before connect is %d\n", (UINT32
)OldTpl
));
288 gBS
->RestoreTPL (TPL_CALLBACK
);
290 Status
= gBS
->ConnectController (UsbIf
->Handle
, NULL
, NULL
, TRUE
);
291 UsbIf
->IsManaged
= (BOOLEAN
)!EFI_ERROR (Status
);
293 DEBUG ((EFI_D_INFO
, "UsbConnectDriver: TPL after connect is %d\n", (UINT32
)UsbGetCurrentTpl()));
294 ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK
);
296 gBS
->RaiseTPL (OldTpl
);
305 Select an alternate setting for the interface.
306 Each interface can have several mutually exclusive
307 settings. Only one setting is active. It will
308 also reset its endpoints' toggle to zero.
310 @param IfDesc The interface descriptor to set.
311 @param Alternate The alternate setting number to locate.
313 @retval EFI_NOT_FOUND There is no setting with this alternate index.
314 @retval EFI_SUCCESS The interface is set to Alternate setting.
319 IN USB_INTERFACE_DESC
*IfDesc
,
323 USB_INTERFACE_SETTING
*Setting
;
327 // Locate the active alternate setting
331 for (Index
= 0; Index
< IfDesc
->NumOfSetting
; Index
++) {
332 Setting
= IfDesc
->Settings
[Index
];
334 if (Setting
->Desc
.AlternateSetting
== Alternate
) {
339 if (Index
== IfDesc
->NumOfSetting
) {
340 return EFI_NOT_FOUND
;
343 IfDesc
->ActiveIndex
= Index
;
345 DEBUG ((EFI_D_INFO
, "UsbSelectSetting: setting %d selected for interface %d\n",
346 Alternate
, Setting
->Desc
.InterfaceNumber
));
349 // Reset the endpoint toggle to zero
351 for (Index
= 0; Index
< Setting
->Desc
.NumEndpoints
; Index
++) {
352 Setting
->Endpoints
[Index
]->Toggle
= 0;
360 Select a new configuration for the device. Each
361 device may support several configurations.
363 @param Device The device to select configuration.
364 @param ConfigValue The index of the configuration ( != 0).
366 @retval EFI_NOT_FOUND There is no configuration with the index.
367 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
368 @retval EFI_SUCCESS The configuration is selected.
373 IN USB_DEVICE
*Device
,
377 USB_DEVICE_DESC
*DevDesc
;
378 USB_CONFIG_DESC
*ConfigDesc
;
379 USB_INTERFACE_DESC
*IfDesc
;
380 USB_INTERFACE
*UsbIf
;
385 // Locate the active config, then set the device's pointer
387 DevDesc
= Device
->DevDesc
;
390 for (Index
= 0; Index
< DevDesc
->Desc
.NumConfigurations
; Index
++) {
391 ConfigDesc
= DevDesc
->Configs
[Index
];
393 if (ConfigDesc
->Desc
.ConfigurationValue
== ConfigValue
) {
398 if (Index
== DevDesc
->Desc
.NumConfigurations
) {
399 return EFI_NOT_FOUND
;
402 Device
->ActiveConfig
= ConfigDesc
;
404 DEBUG ((EFI_D_INFO
, "UsbSelectConfig: config %d selected for device %d\n",
405 ConfigValue
, Device
->Address
));
408 // Create interfaces for each USB interface descriptor.
410 for (Index
= 0; Index
< ConfigDesc
->Desc
.NumInterfaces
; Index
++) {
412 // First select the default interface setting, and reset
413 // the endpoint toggles to zero for its endpoints.
415 IfDesc
= ConfigDesc
->Interfaces
[Index
];
416 UsbSelectSetting (IfDesc
, IfDesc
->Settings
[0]->Desc
.AlternateSetting
);
419 // Create a USB_INTERFACE and install USB_IO and other protocols
421 UsbIf
= UsbCreateInterface (Device
, ConfigDesc
->Interfaces
[Index
]);
424 return EFI_OUT_OF_RESOURCES
;
427 Device
->Interfaces
[Index
] = UsbIf
;
430 // Connect the device to drivers, if it failed, ignore
431 // the error. Don't let the unsupported interfaces to block
432 // the supported interfaces.
434 Status
= UsbConnectDriver (UsbIf
);
436 if (EFI_ERROR (Status
)) {
437 DEBUG ((EFI_D_ERROR
, "UsbSelectConfig: failed to connect driver %r, ignored\n", Status
));
441 Device
->NumOfInterface
= Index
;
448 Disconnect the USB interface with its driver.
450 @param UsbIf The interface to disconnect driver from.
456 UsbDisconnectDriver (
457 IN USB_INTERFACE
*UsbIf
463 // Release the hub if it's a hub controller, otherwise
464 // disconnect the driver if it is managed by other drivers.
467 UsbIf
->HubApi
->Release (UsbIf
);
469 } else if (UsbIf
->IsManaged
) {
471 // This function is called in both UsbIoControlTransfer and
472 // the timer callback in hub enumeration. So, at least it is
473 // called at TPL_CALLBACK. Some driver sitting on USB has
474 // twisted TPL used. It should be no problem for us to connect
475 // or disconnect at CALLBACK.
477 OldTpl
= UsbGetCurrentTpl ();
478 DEBUG ((EFI_D_INFO
, "UsbDisconnectDriver: old TPL is %d\n", (UINT32
)OldTpl
));
480 gBS
->RestoreTPL (TPL_CALLBACK
);
482 gBS
->DisconnectController (UsbIf
->Handle
, NULL
, NULL
);
483 UsbIf
->IsManaged
= FALSE
;
485 DEBUG (( EFI_D_INFO
, "UsbDisconnectDriver: TPL after disconnect is %d\n", (UINT32
)UsbGetCurrentTpl()));
486 ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK
);
488 gBS
->RaiseTPL (OldTpl
);
494 Remove the current device configuration.
496 @param Device The USB device to remove configuration from.
503 IN USB_DEVICE
*Device
506 USB_INTERFACE
*UsbIf
;
510 // Remove each interface of the device
512 for (Index
= 0; Index
< Device
->NumOfInterface
; Index
++) {
513 UsbIf
= Device
->Interfaces
[Index
];
519 UsbDisconnectDriver (UsbIf
);
520 UsbFreeInterface (UsbIf
);
521 Device
->Interfaces
[Index
] = NULL
;
524 Device
->ActiveConfig
= NULL
;
525 Device
->NumOfInterface
= 0;
530 Remove the device and all its children from the bus.
532 @param Device The device to remove.
534 @retval EFI_SUCCESS The device is removed.
539 IN USB_DEVICE
*Device
550 // Remove all the devices on its downstream ports. Search from devices[1].
551 // Devices[0] is the root hub.
553 for (Index
= 1; Index
< USB_MAX_DEVICES
; Index
++) {
554 Child
= Bus
->Devices
[Index
];
556 if ((Child
== NULL
) || (Child
->ParentAddr
!= Device
->Address
)) {
560 Status
= UsbRemoveDevice (Child
);
562 if (EFI_ERROR (Status
)) {
563 DEBUG ((EFI_D_ERROR
, "UsbRemoveDevice: failed to remove child, ignore error\n"));
564 Bus
->Devices
[Index
] = NULL
;
568 UsbRemoveConfig (Device
);
570 DEBUG (( EFI_D_INFO
, "UsbRemoveDevice: device %d removed\n", Device
->Address
));
572 Bus
->Devices
[Device
->Address
] = NULL
;
573 UsbFreeDevice (Device
);
580 Find the child device on the hub's port.
582 @param HubIf The hub interface.
583 @param Port The port of the hub this child is connected to.
585 @return The device on the hub's port, or NULL if there is none.
590 IN USB_INTERFACE
*HubIf
,
598 Bus
= HubIf
->Device
->Bus
;
601 // Start checking from device 1, device 0 is the root hub
603 for (Index
= 1; Index
< USB_MAX_DEVICES
; Index
++) {
604 Device
= Bus
->Devices
[Index
];
606 if ((Device
!= NULL
) && (Device
->ParentAddr
== HubIf
->Device
->Address
) &&
607 (Device
->ParentPort
== Port
)) {
618 Enumerate and configure the new device on the port of this HUB interface.
620 @param HubIf The HUB that has the device connected.
621 @param Port The port index of the hub (started with zero).
623 @retval EFI_SUCCESS The device is enumerated (added or removed).
624 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource for the device.
625 @retval Others Failed to enumerate the device.
630 IN USB_INTERFACE
*HubIf
,
638 EFI_USB_PORT_STATUS PortState
;
643 Address
= USB_MAX_DEVICES
;
644 Parent
= HubIf
->Device
;
646 HubApi
= HubIf
->HubApi
;
648 gBS
->Stall (USB_WAIT_PORT_STABLE_STALL
);
651 // Hub resets the device for at least 10 milliseconds.
652 // Host learns device speed. If device is of low/full speed
653 // and the hub is a EHCI root hub, ResetPort will release
654 // the device to its companion UHCI and return an error.
656 Status
= HubApi
->ResetPort (HubIf
, Port
);
658 if (EFI_ERROR (Status
)) {
659 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to reset port %d - %r\n", Port
, Status
));
664 DEBUG (( EFI_D_INFO
, "UsbEnumerateNewDev: hub port %d is reset\n", Port
));
666 Child
= UsbCreateDevice (HubIf
, Port
);
669 return EFI_OUT_OF_RESOURCES
;
673 // OK, now identify the device speed. After reset, hub
674 // fully knows the actual device speed.
676 Status
= HubApi
->GetPortStatus (HubIf
, Port
, &PortState
);
678 if (EFI_ERROR (Status
)) {
679 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to get speed of port %d\n", Port
));
683 if (USB_BIT_IS_SET (PortState
.PortStatus
, USB_PORT_STAT_LOW_SPEED
)) {
684 Child
->Speed
= EFI_USB_SPEED_LOW
;
686 } else if (USB_BIT_IS_SET (PortState
.PortStatus
, USB_PORT_STAT_HIGH_SPEED
)) {
687 Child
->Speed
= EFI_USB_SPEED_HIGH
;
690 Child
->Speed
= EFI_USB_SPEED_FULL
;
693 DEBUG (( EFI_D_INFO
, "UsbEnumerateNewDev: device is of %d speed\n", Child
->Speed
));
695 if (Child
->Speed
!= EFI_USB_SPEED_HIGH
) {
697 // If the child isn't a high speed device, it is necessary to
698 // set the transaction translator. Port TT is 1-based.
699 // This is quite simple:
700 // 1. if parent is of high speed, then parent is our translator
701 // 2. otherwise use parent's translator.
703 if (Parent
->Speed
== EFI_USB_SPEED_HIGH
) {
704 Child
->Translator
.TranslatorHubAddress
= Parent
->Address
;
705 Child
->Translator
.TranslatorPortNumber
= (UINT8
) (Port
+ 1);
708 Child
->Translator
= Parent
->Translator
;
711 DEBUG (( EFI_D_INFO
, "UsbEnumerateNewDev: device uses translator (%d, %d)\n",
712 Child
->Translator
.TranslatorHubAddress
,
713 Child
->Translator
.TranslatorPortNumber
));
717 // After port is reset, hub establishes a signal path between
718 // the device and host (DEFALUT state). Device's registers are
719 // reset, use default address 0 (host enumerates one device at
720 // a time) , and ready to respond to control transfer at EP 0.
724 // Host sends a Get_Descriptor request to learn the max packet
725 // size of default pipe (only part of the device's descriptor).
727 Status
= UsbGetMaxPacketSize0 (Child
);
729 if (EFI_ERROR (Status
)) {
730 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to get max packet for EP 0 - %r\n", Status
));
734 DEBUG (( EFI_D_INFO
, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child
->MaxPacket0
));
737 // Host assigns an address to the device. Device completes the
738 // status stage with default address, then switches to new address.
739 // ADDRESS state. Address zero is reserved for root hub.
741 for (Address
= 1; Address
< USB_MAX_DEVICES
; Address
++) {
742 if (Bus
->Devices
[Address
] == NULL
) {
747 if (Address
== USB_MAX_DEVICES
) {
748 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: address pool is full for port %d\n", Port
));
750 Status
= EFI_ACCESS_DENIED
;
754 Bus
->Devices
[Address
] = Child
;
755 Status
= UsbSetAddress (Child
, Address
);
756 Child
->Address
= Address
;
758 if (EFI_ERROR (Status
)) {
759 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to set device address - %r\n", Status
));
763 gBS
->Stall (USB_SET_DEVICE_ADDRESS_STALL
);
765 DEBUG ((EFI_D_INFO
, "UsbEnumerateNewDev: device is now ADDRESSED at %d\n", Address
));
768 // Host learns about the device's abilities by requesting device's
769 // entire descriptions.
771 Status
= UsbBuildDescTable (Child
);
773 if (EFI_ERROR (Status
)) {
774 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to build descriptor table - %r\n", Status
));
779 // Select a default configuration: UEFI must set the configuration
780 // before the driver can connect to the device.
782 Config
= Child
->DevDesc
->Configs
[0]->Desc
.ConfigurationValue
;
783 Status
= UsbSetConfig (Child
, Config
);
785 if (EFI_ERROR (Status
)) {
786 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to set configure %d - %r\n", Config
, Status
));
790 DEBUG (( EFI_D_INFO
, "UsbEnumerateNewDev: device %d is now in CONFIGED state\n", Address
));
793 // Host assigns and loads a device driver.
795 Status
= UsbSelectConfig (Child
, Config
);
797 if (EFI_ERROR (Status
)) {
798 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to create interfaces - %r\n", Status
));
805 if (Address
!= USB_MAX_DEVICES
) {
806 Bus
->Devices
[Address
] = NULL
;
810 UsbFreeDevice (Child
);
818 Process the events on the port.
820 @param HubIf The HUB that has the device connected.
821 @param Port The port index of the hub (started with zero).
823 @retval EFI_SUCCESS The device is enumerated (added or removed).
824 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource for the device.
825 @retval Others Failed to enumerate the device.
830 IN USB_INTERFACE
*HubIf
,
836 EFI_USB_PORT_STATUS PortState
;
840 HubApi
= HubIf
->HubApi
;
843 // Host learns of the new device by polling the hub for port changes.
845 Status
= HubApi
->GetPortStatus (HubIf
, Port
, &PortState
);
847 if (EFI_ERROR (Status
)) {
848 DEBUG ((EFI_D_ERROR
, "UsbEnumeratePort: failed to get state of port %d\n", Port
));
852 if (PortState
.PortChangeStatus
== 0) {
856 DEBUG (( EFI_D_INFO
, "UsbEnumeratePort: port %d state - %x, change - %x\n",
857 Port
, PortState
.PortStatus
, PortState
.PortChangeStatus
));
860 // This driver only process two kinds of events now: over current and
861 // connect/disconnect. Other three events are: ENABLE, SUSPEND, RESET.
862 // ENABLE/RESET is used to reset port. SUSPEND isn't supported.
865 if (USB_BIT_IS_SET (PortState
.PortChangeStatus
, USB_PORT_STAT_C_OVERCURRENT
)) {
867 if (USB_BIT_IS_SET (PortState
.PortStatus
, USB_PORT_STAT_OVERCURRENT
)) {
870 // Both OverCurrent and OverCurrentChange set, means over current occurs,
871 // which probably is caused by short circuit. It has to wait system hardware
872 // to perform recovery.
874 DEBUG (( EFI_D_ERROR
, "UsbEnumeratePort: Critical Over Current\n", Port
));
875 return EFI_DEVICE_ERROR
;
880 // Only OverCurrentChange set, means system has been recoveried from
881 // over current. As a result, all ports are nearly power-off, so
882 // it's necessary to detach and enumerate all ports again.
884 DEBUG (( EFI_D_ERROR
, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port
));
887 if (USB_BIT_IS_SET (PortState
.PortChangeStatus
, USB_PORT_STAT_C_ENABLE
)) {
890 // 1.1 roothub port reg doesn't reflect over-current state, while its counterpart
891 // on 2.0 roothub does. When over-current has influence on 1.1 device, the port
892 // would be disabled, so it's also necessary to detach and enumerate again.
894 DEBUG (( EFI_D_ERROR
, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port
));
897 if (USB_BIT_IS_SET (PortState
.PortChangeStatus
, USB_PORT_STAT_C_CONNECTION
)) {
900 // Device connected or disconnected normally.
902 DEBUG ((EFI_D_ERROR
, "UsbEnumeratePort: Device Connect/Discount Normally\n", Port
));
906 // Following as the above cases, it's safety to remove and create again.
908 Child
= UsbFindChild (HubIf
, Port
);
911 DEBUG (( EFI_D_INFO
, "UsbEnumeratePort: device at port %d removed from system\n", Port
));
912 UsbRemoveDevice (Child
);
915 if (USB_BIT_IS_SET (PortState
.PortStatus
, USB_PORT_STAT_CONNECTION
)) {
917 // Now, new device connected, enumerate and configure the device
919 DEBUG (( EFI_D_INFO
, "UsbEnumeratePort: new device connected at port %d\n", Port
));
920 Status
= UsbEnumerateNewDev (HubIf
, Port
);
923 DEBUG (( EFI_D_INFO
, "UsbEnumeratePort: device disconnected event on port %d\n", Port
));
926 HubApi
->ClearPortChange (HubIf
, Port
);
932 Enumerate all the changed hub ports.
934 @param Event The event that is triggered.
935 @param Context The context to the event.
947 USB_INTERFACE
*HubIf
;
952 ASSERT (Context
!= NULL
);
954 HubIf
= (USB_INTERFACE
*) Context
;
956 if (HubIf
->ChangeMap
== NULL
) {
961 // HUB starts its port index with 1.
966 for (Index
= 0; Index
< HubIf
->NumOfPort
; Index
++) {
967 if (USB_BIT_IS_SET (HubIf
->ChangeMap
[Byte
], USB_BIT (Bit
))) {
968 UsbEnumeratePort (HubIf
, Index
);
971 USB_NEXT_BIT (Byte
, Bit
);
974 UsbHubAckHubStatus (HubIf
->Device
);
976 gBS
->FreePool (HubIf
->ChangeMap
);
977 HubIf
->ChangeMap
= NULL
;
983 Enumerate all the changed hub ports.
985 @param Event The event that is triggered.
986 @param Context The context to the event.
993 UsbRootHubEnumeration (
998 USB_INTERFACE
*RootHub
;
1001 RootHub
= (USB_INTERFACE
*) Context
;
1003 for (Index
= 0; Index
< RootHub
->NumOfPort
; Index
++) {
1004 UsbEnumeratePort (RootHub
, Index
);