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.
60 IN USB_INTERFACE
*UsbIf
63 UsbCloseHostProtoByChild (UsbIf
->Device
->Bus
, UsbIf
->Handle
);
65 gBS
->UninstallMultipleProtocolInterfaces (
67 &gEfiDevicePathProtocolGuid
,
69 &gEfiUsbIoProtocolGuid
,
74 if (UsbIf
->DevicePath
!= NULL
) {
75 FreePool (UsbIf
->DevicePath
);
83 Create an interface for the descriptor IfDesc. Each
84 device's configuration can have several interfaces.
86 @param Device The device has the interface descriptor.
87 @param IfDesc The interface descriptor.
89 @return The created USB interface for the descriptor, or NULL.
94 IN USB_DEVICE
*Device
,
95 IN USB_INTERFACE_DESC
*IfDesc
98 USB_DEVICE_PATH UsbNode
;
100 USB_INTERFACE
*HubIf
;
103 UsbIf
= AllocateZeroPool (sizeof (USB_INTERFACE
));
109 UsbIf
->Signature
= USB_INTERFACE_SIGNATURE
;
110 UsbIf
->Device
= Device
;
111 UsbIf
->IfDesc
= IfDesc
;
112 UsbIf
->IfSetting
= IfDesc
->Settings
[IfDesc
->ActiveIndex
];
117 sizeof (EFI_USB_IO_PROTOCOL
)
121 // Install protocols for USBIO and device path
123 UsbNode
.Header
.Type
= MESSAGING_DEVICE_PATH
;
124 UsbNode
.Header
.SubType
= MSG_USB_DP
;
125 UsbNode
.ParentPortNumber
= Device
->ParentPort
;
126 UsbNode
.InterfaceNumber
= UsbIf
->IfSetting
->Desc
.InterfaceNumber
;
128 SetDevicePathNodeLength (&UsbNode
.Header
, sizeof (UsbNode
));
130 HubIf
= Device
->ParentIf
;
131 ASSERT (HubIf
!= NULL
);
133 UsbIf
->DevicePath
= AppendDevicePathNode (HubIf
->DevicePath
, &UsbNode
.Header
);
135 if (UsbIf
->DevicePath
== NULL
) {
136 DEBUG ((EFI_D_ERROR
, "UsbCreateInterface: failed to create device path\n"));
138 Status
= EFI_OUT_OF_RESOURCES
;
142 Status
= gBS
->InstallMultipleProtocolInterfaces (
144 &gEfiDevicePathProtocolGuid
,
146 &gEfiUsbIoProtocolGuid
,
151 if (EFI_ERROR (Status
)) {
152 DEBUG ((EFI_D_ERROR
, "UsbCreateInterface: failed to install UsbIo - %r\n", Status
));
157 // Open USB Host Controller Protocol by Child
159 Status
= UsbOpenHostProtoByChild (Device
->Bus
, UsbIf
->Handle
);
161 if (EFI_ERROR (Status
)) {
162 gBS
->UninstallMultipleProtocolInterfaces (
164 &gEfiDevicePathProtocolGuid
,
166 &gEfiUsbIoProtocolGuid
,
171 DEBUG ((EFI_D_ERROR
, "UsbCreateInterface: failed to open host for child - %r\n", Status
));
178 if (UsbIf
->DevicePath
!= NULL
) {
179 FreePool (UsbIf
->DevicePath
);
188 Free the resource used by this USB device.
190 @param Device The USB device to free.
195 IN USB_DEVICE
*Device
198 if (Device
->DevDesc
!= NULL
) {
199 UsbFreeDevDesc (Device
->DevDesc
);
202 gBS
->FreePool (Device
);
207 Create a device which is on the parent's ParentPort port.
209 @param ParentIf The parent HUB interface.
210 @param ParentPort The port on the HUB this device is connected to.
212 @return Created USB device, Or NULL.
217 IN USB_INTERFACE
*ParentIf
,
223 ASSERT (ParentIf
!= NULL
);
225 Device
= AllocateZeroPool (sizeof (USB_DEVICE
));
227 if (Device
== NULL
) {
231 Device
->Bus
= ParentIf
->Device
->Bus
;
232 Device
->MaxPacket0
= 8;
233 Device
->ParentAddr
= ParentIf
->Device
->Address
;
234 Device
->ParentIf
= ParentIf
;
235 Device
->ParentPort
= ParentPort
;
241 Connect the USB interface with its driver. EFI USB bus will
242 create a USB interface for each separate interface descriptor.
244 @param UsbIf The interface to connect driver to.
246 @return EFI_SUCCESS Interface is managed by some driver.
247 @return Others Failed to locate a driver for this interface.
252 IN USB_INTERFACE
*UsbIf
258 Status
= EFI_SUCCESS
;
261 // Hub is maintained by the USB bus driver. Otherwise try to
262 // connect drivers with this interface
264 if (UsbIsHubInterface (UsbIf
)) {
265 DEBUG ((EFI_D_INFO
, "UsbConnectDriver: found a hub device\n"));
266 Status
= mUsbHubApi
.Init (UsbIf
);
270 // This function is called in both UsbIoControlTransfer and
271 // the timer callback in hub enumeration. So, at least it is
272 // called at TPL_CALLBACK. Some driver sitting on USB has
273 // twisted TPL used. It should be no problem for us to connect
274 // or disconnect at CALLBACK.
278 // Only recursively wanted usb child device
280 if (UsbBusIsWantedUsbIO (UsbIf
->Device
->Bus
, UsbIf
)) {
281 OldTpl
= UsbGetCurrentTpl ();
282 DEBUG ((EFI_D_INFO
, "UsbConnectDriver: TPL before connect is %d\n", (UINT32
)OldTpl
));
284 gBS
->RestoreTPL (TPL_CALLBACK
);
286 Status
= gBS
->ConnectController (UsbIf
->Handle
, NULL
, NULL
, TRUE
);
287 UsbIf
->IsManaged
= (BOOLEAN
)!EFI_ERROR (Status
);
289 DEBUG ((EFI_D_INFO
, "UsbConnectDriver: TPL after connect is %d\n", (UINT32
)UsbGetCurrentTpl()));
290 ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK
);
292 gBS
->RaiseTPL (OldTpl
);
301 Select an alternate setting for the interface.
302 Each interface can have several mutually exclusive
303 settings. Only one setting is active. It will
304 also reset its endpoints' toggle to zero.
306 @param IfDesc The interface descriptor to set.
307 @param Alternate The alternate setting number to locate.
309 @retval EFI_NOT_FOUND There is no setting with this alternate index.
310 @retval EFI_SUCCESS The interface is set to Alternate setting.
315 IN USB_INTERFACE_DESC
*IfDesc
,
319 USB_INTERFACE_SETTING
*Setting
;
323 // Locate the active alternate setting
327 for (Index
= 0; Index
< IfDesc
->NumOfSetting
; Index
++) {
328 Setting
= IfDesc
->Settings
[Index
];
330 if (Setting
->Desc
.AlternateSetting
== Alternate
) {
335 if (Index
== IfDesc
->NumOfSetting
) {
336 return EFI_NOT_FOUND
;
339 IfDesc
->ActiveIndex
= Index
;
341 DEBUG ((EFI_D_INFO
, "UsbSelectSetting: setting %d selected for interface %d\n",
342 Alternate
, Setting
->Desc
.InterfaceNumber
));
345 // Reset the endpoint toggle to zero
347 for (Index
= 0; Index
< Setting
->Desc
.NumEndpoints
; Index
++) {
348 Setting
->Endpoints
[Index
]->Toggle
= 0;
356 Select a new configuration for the device. Each
357 device may support several configurations.
359 @param Device The device to select configuration.
360 @param ConfigValue The index of the configuration ( != 0).
362 @retval EFI_NOT_FOUND There is no configuration with the index.
363 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
364 @retval EFI_SUCCESS The configuration is selected.
369 IN USB_DEVICE
*Device
,
373 USB_DEVICE_DESC
*DevDesc
;
374 USB_CONFIG_DESC
*ConfigDesc
;
375 USB_INTERFACE_DESC
*IfDesc
;
376 USB_INTERFACE
*UsbIf
;
381 // Locate the active config, then set the device's pointer
383 DevDesc
= Device
->DevDesc
;
386 for (Index
= 0; Index
< DevDesc
->Desc
.NumConfigurations
; Index
++) {
387 ConfigDesc
= DevDesc
->Configs
[Index
];
389 if (ConfigDesc
->Desc
.ConfigurationValue
== ConfigValue
) {
394 if (Index
== DevDesc
->Desc
.NumConfigurations
) {
395 return EFI_NOT_FOUND
;
398 Device
->ActiveConfig
= ConfigDesc
;
400 DEBUG ((EFI_D_INFO
, "UsbSelectConfig: config %d selected for device %d\n",
401 ConfigValue
, Device
->Address
));
404 // Create interfaces for each USB interface descriptor.
406 for (Index
= 0; Index
< ConfigDesc
->Desc
.NumInterfaces
; Index
++) {
408 // First select the default interface setting, and reset
409 // the endpoint toggles to zero for its endpoints.
411 IfDesc
= ConfigDesc
->Interfaces
[Index
];
412 UsbSelectSetting (IfDesc
, IfDesc
->Settings
[0]->Desc
.AlternateSetting
);
415 // Create a USB_INTERFACE and install USB_IO and other protocols
417 UsbIf
= UsbCreateInterface (Device
, ConfigDesc
->Interfaces
[Index
]);
420 return EFI_OUT_OF_RESOURCES
;
423 Device
->Interfaces
[Index
] = UsbIf
;
426 // Connect the device to drivers, if it failed, ignore
427 // the error. Don't let the unsupported interfaces to block
428 // the supported interfaces.
430 Status
= UsbConnectDriver (UsbIf
);
432 if (EFI_ERROR (Status
)) {
433 DEBUG ((EFI_D_ERROR
, "UsbSelectConfig: failed to connect driver %r, ignored\n", Status
));
437 Device
->NumOfInterface
= Index
;
444 Disconnect the USB interface with its driver.
446 @param UsbIf The interface to disconnect driver from.
450 UsbDisconnectDriver (
451 IN USB_INTERFACE
*UsbIf
457 // Release the hub if it's a hub controller, otherwise
458 // disconnect the driver if it is managed by other drivers.
461 UsbIf
->HubApi
->Release (UsbIf
);
463 } else if (UsbIf
->IsManaged
) {
465 // This function is called in both UsbIoControlTransfer and
466 // the timer callback in hub enumeration. So, at least it is
467 // called at TPL_CALLBACK. Some driver sitting on USB has
468 // twisted TPL used. It should be no problem for us to connect
469 // or disconnect at CALLBACK.
471 OldTpl
= UsbGetCurrentTpl ();
472 DEBUG ((EFI_D_INFO
, "UsbDisconnectDriver: old TPL is %d\n", (UINT32
)OldTpl
));
474 gBS
->RestoreTPL (TPL_CALLBACK
);
476 gBS
->DisconnectController (UsbIf
->Handle
, NULL
, NULL
);
477 UsbIf
->IsManaged
= FALSE
;
479 DEBUG (( EFI_D_INFO
, "UsbDisconnectDriver: TPL after disconnect is %d\n", (UINT32
)UsbGetCurrentTpl()));
480 ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK
);
482 gBS
->RaiseTPL (OldTpl
);
488 Remove the current device configuration.
490 @param Device The USB device to remove configuration from.
495 IN USB_DEVICE
*Device
498 USB_INTERFACE
*UsbIf
;
502 // Remove each interface of the device
504 for (Index
= 0; Index
< Device
->NumOfInterface
; Index
++) {
505 UsbIf
= Device
->Interfaces
[Index
];
511 UsbDisconnectDriver (UsbIf
);
512 UsbFreeInterface (UsbIf
);
513 Device
->Interfaces
[Index
] = NULL
;
516 Device
->ActiveConfig
= NULL
;
517 Device
->NumOfInterface
= 0;
522 Remove the device and all its children from the bus.
524 @param Device The device to remove.
526 @retval EFI_SUCCESS The device is removed.
531 IN USB_DEVICE
*Device
542 // Remove all the devices on its downstream ports. Search from devices[1].
543 // Devices[0] is the root hub.
545 for (Index
= 1; Index
< USB_MAX_DEVICES
; Index
++) {
546 Child
= Bus
->Devices
[Index
];
548 if ((Child
== NULL
) || (Child
->ParentAddr
!= Device
->Address
)) {
552 Status
= UsbRemoveDevice (Child
);
554 if (EFI_ERROR (Status
)) {
555 DEBUG ((EFI_D_ERROR
, "UsbRemoveDevice: failed to remove child, ignore error\n"));
556 Bus
->Devices
[Index
] = NULL
;
560 UsbRemoveConfig (Device
);
562 DEBUG (( EFI_D_INFO
, "UsbRemoveDevice: device %d removed\n", Device
->Address
));
564 Bus
->Devices
[Device
->Address
] = NULL
;
565 UsbFreeDevice (Device
);
572 Find the child device on the hub's port.
574 @param HubIf The hub interface.
575 @param Port The port of the hub this child is connected to.
577 @return The device on the hub's port, or NULL if there is none.
582 IN USB_INTERFACE
*HubIf
,
590 Bus
= HubIf
->Device
->Bus
;
593 // Start checking from device 1, device 0 is the root hub
595 for (Index
= 1; Index
< USB_MAX_DEVICES
; Index
++) {
596 Device
= Bus
->Devices
[Index
];
598 if ((Device
!= NULL
) && (Device
->ParentAddr
== HubIf
->Device
->Address
) &&
599 (Device
->ParentPort
== Port
)) {
610 Enumerate and configure the new device on the port of this HUB interface.
612 @param HubIf The HUB that has the device connected.
613 @param Port The port index of the hub (started with zero).
615 @retval EFI_SUCCESS The device is enumerated (added or removed).
616 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource for the device.
617 @retval Others Failed to enumerate the device.
622 IN USB_INTERFACE
*HubIf
,
630 EFI_USB_PORT_STATUS PortState
;
635 Address
= USB_MAX_DEVICES
;
636 Parent
= HubIf
->Device
;
638 HubApi
= HubIf
->HubApi
;
640 gBS
->Stall (USB_WAIT_PORT_STABLE_STALL
);
643 // Hub resets the device for at least 10 milliseconds.
644 // Host learns device speed. If device is of low/full speed
645 // and the hub is a EHCI root hub, ResetPort will release
646 // the device to its companion UHCI and return an error.
648 Status
= HubApi
->ResetPort (HubIf
, Port
);
650 if (EFI_ERROR (Status
)) {
651 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to reset port %d - %r\n", Port
, Status
));
656 DEBUG (( EFI_D_INFO
, "UsbEnumerateNewDev: hub port %d is reset\n", Port
));
658 Child
= UsbCreateDevice (HubIf
, Port
);
661 return EFI_OUT_OF_RESOURCES
;
665 // OK, now identify the device speed. After reset, hub
666 // fully knows the actual device speed.
668 Status
= HubApi
->GetPortStatus (HubIf
, Port
, &PortState
);
670 if (EFI_ERROR (Status
)) {
671 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to get speed of port %d\n", Port
));
675 if (USB_BIT_IS_SET (PortState
.PortStatus
, USB_PORT_STAT_LOW_SPEED
)) {
676 Child
->Speed
= EFI_USB_SPEED_LOW
;
678 } else if (USB_BIT_IS_SET (PortState
.PortStatus
, USB_PORT_STAT_HIGH_SPEED
)) {
679 Child
->Speed
= EFI_USB_SPEED_HIGH
;
682 Child
->Speed
= EFI_USB_SPEED_FULL
;
685 DEBUG (( EFI_D_INFO
, "UsbEnumerateNewDev: device is of %d speed\n", Child
->Speed
));
687 if (Child
->Speed
!= EFI_USB_SPEED_HIGH
) {
689 // If the child isn't a high speed device, it is necessary to
690 // set the transaction translator. Port TT is 1-based.
691 // This is quite simple:
692 // 1. if parent is of high speed, then parent is our translator
693 // 2. otherwise use parent's translator.
695 if (Parent
->Speed
== EFI_USB_SPEED_HIGH
) {
696 Child
->Translator
.TranslatorHubAddress
= Parent
->Address
;
697 Child
->Translator
.TranslatorPortNumber
= (UINT8
) (Port
+ 1);
700 Child
->Translator
= Parent
->Translator
;
703 DEBUG (( EFI_D_INFO
, "UsbEnumerateNewDev: device uses translator (%d, %d)\n",
704 Child
->Translator
.TranslatorHubAddress
,
705 Child
->Translator
.TranslatorPortNumber
));
709 // After port is reset, hub establishes a signal path between
710 // the device and host (DEFALUT state). Device's registers are
711 // reset, use default address 0 (host enumerates one device at
712 // a time) , and ready to respond to control transfer at EP 0.
716 // Host sends a Get_Descriptor request to learn the max packet
717 // size of default pipe (only part of the device's descriptor).
719 Status
= UsbGetMaxPacketSize0 (Child
);
721 if (EFI_ERROR (Status
)) {
722 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to get max packet for EP 0 - %r\n", Status
));
726 DEBUG (( EFI_D_INFO
, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child
->MaxPacket0
));
729 // Host assigns an address to the device. Device completes the
730 // status stage with default address, then switches to new address.
731 // ADDRESS state. Address zero is reserved for root hub.
733 for (Address
= 1; Address
< USB_MAX_DEVICES
; Address
++) {
734 if (Bus
->Devices
[Address
] == NULL
) {
739 if (Address
== USB_MAX_DEVICES
) {
740 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: address pool is full for port %d\n", Port
));
742 Status
= EFI_ACCESS_DENIED
;
746 Bus
->Devices
[Address
] = Child
;
747 Status
= UsbSetAddress (Child
, Address
);
748 Child
->Address
= Address
;
750 if (EFI_ERROR (Status
)) {
751 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to set device address - %r\n", Status
));
755 gBS
->Stall (USB_SET_DEVICE_ADDRESS_STALL
);
757 DEBUG ((EFI_D_INFO
, "UsbEnumerateNewDev: device is now ADDRESSED at %d\n", Address
));
760 // Host learns about the device's abilities by requesting device's
761 // entire descriptions.
763 Status
= UsbBuildDescTable (Child
);
765 if (EFI_ERROR (Status
)) {
766 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to build descriptor table - %r\n", Status
));
771 // Select a default configuration: UEFI must set the configuration
772 // before the driver can connect to the device.
774 Config
= Child
->DevDesc
->Configs
[0]->Desc
.ConfigurationValue
;
775 Status
= UsbSetConfig (Child
, Config
);
777 if (EFI_ERROR (Status
)) {
778 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to set configure %d - %r\n", Config
, Status
));
782 DEBUG (( EFI_D_INFO
, "UsbEnumerateNewDev: device %d is now in CONFIGED state\n", Address
));
785 // Host assigns and loads a device driver.
787 Status
= UsbSelectConfig (Child
, Config
);
789 if (EFI_ERROR (Status
)) {
790 DEBUG ((EFI_D_ERROR
, "UsbEnumerateNewDev: failed to create interfaces - %r\n", Status
));
797 if (Address
!= USB_MAX_DEVICES
) {
798 Bus
->Devices
[Address
] = NULL
;
802 UsbFreeDevice (Child
);
810 Process the events on the port.
812 @param HubIf The HUB that has the device connected.
813 @param Port The port index of the hub (started with zero).
815 @retval EFI_SUCCESS The device is enumerated (added or removed).
816 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource for the device.
817 @retval Others Failed to enumerate the device.
822 IN USB_INTERFACE
*HubIf
,
828 EFI_USB_PORT_STATUS PortState
;
832 HubApi
= HubIf
->HubApi
;
835 // Host learns of the new device by polling the hub for port changes.
837 Status
= HubApi
->GetPortStatus (HubIf
, Port
, &PortState
);
839 if (EFI_ERROR (Status
)) {
840 DEBUG ((EFI_D_ERROR
, "UsbEnumeratePort: failed to get state of port %d\n", Port
));
844 if (PortState
.PortChangeStatus
== 0) {
848 DEBUG (( EFI_D_INFO
, "UsbEnumeratePort: port %d state - %x, change - %x\n",
849 Port
, PortState
.PortStatus
, PortState
.PortChangeStatus
));
852 // This driver only process two kinds of events now: over current and
853 // connect/disconnect. Other three events are: ENABLE, SUSPEND, RESET.
854 // ENABLE/RESET is used to reset port. SUSPEND isn't supported.
857 if (USB_BIT_IS_SET (PortState
.PortChangeStatus
, USB_PORT_STAT_C_OVERCURRENT
)) {
859 if (USB_BIT_IS_SET (PortState
.PortStatus
, USB_PORT_STAT_OVERCURRENT
)) {
862 // Both OverCurrent and OverCurrentChange set, means over current occurs,
863 // which probably is caused by short circuit. It has to wait system hardware
864 // to perform recovery.
866 DEBUG (( EFI_D_ERROR
, "UsbEnumeratePort: Critical Over Current\n", Port
));
867 return EFI_DEVICE_ERROR
;
872 // Only OverCurrentChange set, means system has been recoveried from
873 // over current. As a result, all ports are nearly power-off, so
874 // it's necessary to detach and enumerate all ports again.
876 DEBUG (( EFI_D_ERROR
, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port
));
879 if (USB_BIT_IS_SET (PortState
.PortChangeStatus
, USB_PORT_STAT_C_ENABLE
)) {
882 // 1.1 roothub port reg doesn't reflect over-current state, while its counterpart
883 // on 2.0 roothub does. When over-current has influence on 1.1 device, the port
884 // would be disabled, so it's also necessary to detach and enumerate again.
886 DEBUG (( EFI_D_ERROR
, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port
));
889 if (USB_BIT_IS_SET (PortState
.PortChangeStatus
, USB_PORT_STAT_C_CONNECTION
)) {
892 // Device connected or disconnected normally.
894 DEBUG ((EFI_D_ERROR
, "UsbEnumeratePort: Device Connect/Discount Normally\n", Port
));
898 // Following as the above cases, it's safety to remove and create again.
900 Child
= UsbFindChild (HubIf
, Port
);
903 DEBUG (( EFI_D_INFO
, "UsbEnumeratePort: device at port %d removed from system\n", Port
));
904 UsbRemoveDevice (Child
);
907 if (USB_BIT_IS_SET (PortState
.PortStatus
, USB_PORT_STAT_CONNECTION
)) {
909 // Now, new device connected, enumerate and configure the device
911 DEBUG (( EFI_D_INFO
, "UsbEnumeratePort: new device connected at port %d\n", Port
));
912 Status
= UsbEnumerateNewDev (HubIf
, Port
);
915 DEBUG (( EFI_D_INFO
, "UsbEnumeratePort: device disconnected event on port %d\n", Port
));
918 HubApi
->ClearPortChange (HubIf
, Port
);
924 Enumerate all the changed hub ports.
926 @param Event The event that is triggered.
927 @param Context The context to the event.
937 USB_INTERFACE
*HubIf
;
942 ASSERT (Context
!= NULL
);
944 HubIf
= (USB_INTERFACE
*) Context
;
946 if (HubIf
->ChangeMap
== NULL
) {
951 // HUB starts its port index with 1.
956 for (Index
= 0; Index
< HubIf
->NumOfPort
; Index
++) {
957 if (USB_BIT_IS_SET (HubIf
->ChangeMap
[Byte
], USB_BIT (Bit
))) {
958 UsbEnumeratePort (HubIf
, Index
);
961 USB_NEXT_BIT (Byte
, Bit
);
964 UsbHubAckHubStatus (HubIf
->Device
);
966 gBS
->FreePool (HubIf
->ChangeMap
);
967 HubIf
->ChangeMap
= NULL
;
973 Enumerate all the changed hub ports.
975 @param Event The event that is triggered.
976 @param Context The context to the event.
981 UsbRootHubEnumeration (
986 USB_INTERFACE
*RootHub
;
989 RootHub
= (USB_INTERFACE
*) Context
;
991 for (Index
= 0; Index
< RootHub
->NumOfPort
; Index
++) {
992 UsbEnumeratePort (RootHub
, Index
);