/** Connect the USB interface with its driver. EFI USB bus will create a USB interface for each separate interface descriptor. @param UsbIf The interface to connect driver to. @return EFI_SUCCESS Interface is managed by some driver. @return Others Failed to locate a driver for this interface. **/ EFI_STATUS UsbConnectDriver ( IN USB_INTERFACE *UsbIf ) { EFI_STATUS Status; EFI_TPL OldTpl; Status = EFI_SUCCESS; // // Hub is maintained by the USB bus driver. Otherwise try to // connect drivers with this interface // if (UsbIsHubInterface (UsbIf)) { // DEBUG ((EFI_D_INFO, "UsbConnectDriver: found a hub device\n")); DBG("UsbConnectDriver: found a hub device\n"); Status = mUsbHubApi.Init (UsbIf); } else { // // This function is called in both UsbIoControlTransfer and // the timer callback in hub enumeration. So, at least it is // called at TPL_CALLBACK. Some driver sitting on USB has // twisted TPL used. It should be no problem for us to connect // or disconnect at CALLBACK. // // // Only recursively wanted usb child device // if (UsbBusIsWantedUsbIO (UsbIf->Device->Bus, UsbIf)) { OldTpl = UsbGetCurrentTpl (); // DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL before connect is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle)); DBG("UsbConnectDriver: TPL before connect is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle); gBS->RestoreTPL (TPL_CALLBACK); Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE); UsbIf->IsManaged = (BOOLEAN)!EFI_ERROR (Status); // DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl())); // ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK); DBG("UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl()); gBS->RaiseTPL (OldTpl); } } return Status; }
STATIC EFI_STATUS UsbConnectDriver ( IN USB_INTERFACE *UsbIf ) /*++ Routine Description: Connect the USB interface with its driver. EFI USB bus will create a USB interface for each seperate interface descriptor. Arguments: UsbIf - The interface to connect driver to Returns: EFI_SUCCESS : Interface is managed by some driver Others : Failed to locate a driver for this interface --*/ { EFI_STATUS Status; EFI_TPL OldTpl; Status = EFI_SUCCESS; // // Hub is maintained by the USB bus driver. Otherwise try to // connect drivers with this interface // if (UsbIsHubInterface (UsbIf)) { USB_DEBUG (("UsbConnectDriver: found a hub device\n")); Status = mUsbHubApi.Init (UsbIf); } else { // // This function is called in both UsbIoControlTransfer and // the timer callback in hub enumeration. So, at least it is // called at EFI_TPL_CALLBACK. Some driver sitting on USB has // twisted TPL used. It should be no problem for us to connect // or disconnect at CALLBACK. // // // Only recursively wanted usb child device // if (UsbBusIsWantedUsbIO (UsbIf->Device->Bus, UsbIf)) { OldTpl = UsbGetCurrentTpl (); USB_DEBUG (("UsbConnectDriver: TPL before connect is %d\n", OldTpl)); gBS->RestoreTPL (EFI_TPL_CALLBACK); Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE); UsbIf->IsManaged = (BOOLEAN)!EFI_ERROR (Status); USB_DEBUG (("UsbConnectDriver: TPL after connect is %d\n", UsbGetCurrentTpl())); ASSERT (UsbGetCurrentTpl () == EFI_TPL_CALLBACK); gBS->RaiseTPL (OldTpl); } } return Status; }