]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
MdeModulePkg/UsbBusDxe: Add UsbControlTransfer() error check
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbBus.c
index f2b7f8bd9391d4da3b5b500311028119098beabb..7c58fe8d36a26a67dea4d3f9712f17fd88b27b7b 100644 (file)
@@ -1,7 +1,9 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+    Usb Bus Driver Binding and Bus IO Protocol.\r
+\r
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -9,26 +11,34 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-  Module Name:\r
-\r
-    UsbBus.c\r
-\r
-  Abstract:\r
-\r
-    Usb Bus Driver Binding and Bus IO Protocol\r
-\r
-  Revision History\r
-\r
-\r
 **/\r
 \r
 #include "UsbBus.h"\r
 \r
-//\r
-// USB_BUS_PROTOCOL is only used to locate USB_BUS\r
-//\r
-EFI_GUID  mUsbBusProtocolGuid = EFI_USB_BUS_PROTOCOL_GUID;\r
+EFI_USB_IO_PROTOCOL mUsbIoProtocol = {\r
+  UsbIoControlTransfer,\r
+  UsbIoBulkTransfer,\r
+  UsbIoAsyncInterruptTransfer,\r
+  UsbIoSyncInterruptTransfer,\r
+  UsbIoIsochronousTransfer,\r
+  UsbIoAsyncIsochronousTransfer,\r
+  UsbIoGetDeviceDescriptor,\r
+  UsbIoGetActiveConfigDescriptor,\r
+  UsbIoGetInterfaceDescriptor,\r
+  UsbIoGetEndpointDescriptor,\r
+  UsbIoGetStringDescriptor,\r
+  UsbIoGetSupportedLanguages,\r
+  UsbIoPortReset\r
+};\r
 \r
+EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding = {\r
+  UsbBusControllerDriverSupported,\r
+  UsbBusControllerDriverStart,\r
+  UsbBusControllerDriverStop,\r
+  0xa,\r
+  NULL,\r
+  NULL\r
+};\r
 \r
 /**\r
   USB_IO function to execute a control transfer. This\r
@@ -45,11 +55,10 @@ EFI_GUID  mUsbBusProtocolGuid = EFI_USB_BUS_PROTOCOL_GUID;
   @param  UsbStatus              USB result\r
 \r
   @retval EFI_INVALID_PARAMETER  The parameters are invalid\r
-  @retval EFI_SUCCESS            The control transfer succeded.\r
+  @retval EFI_SUCCESS            The control transfer succeeded.\r
   @retval Others                 Failed to execute the transfer\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoControlTransfer (\r
@@ -67,6 +76,7 @@ UsbIoControlTransfer (
   USB_ENDPOINT_DESC       *EpDesc;\r
   EFI_TPL                 OldTpl;\r
   EFI_STATUS              Status;\r
+  UINTN                   RequestedDataLength;\r
 \r
   if (UsbStatus == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -77,6 +87,7 @@ UsbIoControlTransfer (
   UsbIf  = USB_INTERFACE_FROM_USBIO (This);\r
   Dev    = UsbIf->Device;\r
 \r
+  RequestedDataLength = DataLength;\r
   Status = UsbHcControlTransfer (\r
              Dev->Bus,\r
              Dev->Address,\r
@@ -90,12 +101,25 @@ UsbIoControlTransfer (
              &Dev->Translator,\r
              UsbStatus\r
              );\r
+  //\r
+  // If the request completed sucessfully and the Direction of the request is\r
+  // EfiUsbDataIn or EfiUsbDataOut, then make sure the actual number of bytes\r
+  // transfered is the same as the number of bytes requested.  If a different\r
+  // number of bytes were transfered, then return EFI_DEVICE_ERROR.\r
+  //\r
+  if (!EFI_ERROR (Status)) {\r
+    if (Direction != EfiUsbNoData && DataLength != RequestedDataLength) {\r
+      Status = EFI_DEVICE_ERROR;\r
+      goto ON_EXIT;\r
+    }\r
+  }\r
 \r
   if (EFI_ERROR (Status) || (*UsbStatus != EFI_USB_NOERROR)) {\r
     //\r
     // Clear TT buffer when CTRL/BULK split transaction failes\r
     // Clear the TRANSLATOR TT buffer, not parent's buffer\r
     //\r
+    ASSERT (Dev->Translator.TranslatorHubAddress < Dev->Bus->MaxDevices);\r
     if (Dev->Translator.TranslatorHubAddress != 0) {\r
       UsbHubCtrlClearTTBuffer (\r
         Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress],\r
@@ -137,7 +161,7 @@ UsbIoControlTransfer (
   // should stop use its current UsbIo after calling this driver. The old\r
   // UsbIo will be uninstalled and new UsbIo be installed. We can't use\r
   // ReinstallProtocol since interfaces in different configuration may be\r
-  // completely irrellvant.\r
+  // completely irrelevant.\r
   //\r
   if ((Request->Request == USB_REQ_SET_CONFIG) &&\r
       (Request->RequestType == USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD,\r
@@ -180,6 +204,7 @@ UsbIoControlTransfer (
     Status = UsbSelectSetting (UsbIf->IfDesc, (UINT8) Request->Value);\r
 \r
     if (!EFI_ERROR (Status)) {\r
+      ASSERT (UsbIf->IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);\r
       UsbIf->IfSetting = UsbIf->IfDesc->Settings[UsbIf->IfDesc->ActiveIndex];\r
     }\r
   }\r
@@ -191,22 +216,21 @@ ON_EXIT:
 \r
 \r
 /**\r
-  Execute a bulk transfer to the device endpoint\r
+  Execute a bulk transfer to the device endpoint.\r
 \r
-  @param  This                   The USB IO instance\r
-  @param  Endpoint               The device endpoint\r
-  @param  Data                   The data to transfer\r
-  @param  DataLength             The length of the data to transfer\r
-  @param  Timeout                Time to wait before timeout\r
-  @param  UsbStatus              The result of USB transfer\r
+  @param  This                   The USB IO instance.\r
+  @param  Endpoint               The device endpoint.\r
+  @param  Data                   The data to transfer.\r
+  @param  DataLength             The length of the data to transfer.\r
+  @param  Timeout                Time to wait before timeout.\r
+  @param  UsbStatus              The result of USB transfer.\r
 \r
-  @retval EFI_SUCCESS            The bulk transfer is OK\r
-  @retval EFI_INVALID_PARAMETER  Some parameters are invalid\r
+  @retval EFI_SUCCESS            The bulk transfer is OK.\r
+  @retval EFI_INVALID_PARAMETER  Some parameters are invalid.\r
   @retval Others                 Failed to execute transfer, reason returned in\r
-                                 UsbStatus\r
+                                 UsbStatus.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoBulkTransfer (\r
@@ -268,6 +292,7 @@ UsbIoBulkTransfer (
     // Clear TT buffer when CTRL/BULK split transaction failes.\r
     // Clear the TRANSLATOR TT buffer, not parent's buffer\r
     //\r
+    ASSERT (Dev->Translator.TranslatorHubAddress < Dev->Bus->MaxDevices);\r
     if (Dev->Translator.TranslatorHubAddress != 0) {\r
       UsbHubCtrlClearTTBuffer (\r
         Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress],\r
@@ -286,22 +311,21 @@ ON_EXIT:
 \r
 \r
 /**\r
-  Execute a synchronous interrupt transfer\r
+  Execute a synchronous interrupt transfer.\r
 \r
-  @param  This                   The USB IO instance\r
-  @param  Endpoint               The device endpoint\r
-  @param  Data                   The data to transfer\r
-  @param  DataLength             The length of the data to transfer\r
-  @param  Timeout                Time to wait before timeout\r
-  @param  UsbStatus              The result of USB transfer\r
+  @param  This                   The USB IO instance.\r
+  @param  Endpoint               The device endpoint.\r
+  @param  Data                   The data to transfer.\r
+  @param  DataLength             The length of the data to transfer.\r
+  @param  Timeout                Time to wait before timeout.\r
+  @param  UsbStatus              The result of USB transfer.\r
 \r
-  @retval EFI_SUCCESS            The synchronous interrupt transfer is OK\r
-  @retval EFI_INVALID_PARAMETER  Some parameters are invalid\r
+  @retval EFI_SUCCESS            The synchronous interrupt transfer is OK.\r
+  @retval EFI_INVALID_PARAMETER  Some parameters are invalid.\r
   @retval Others                 Failed to execute transfer, reason returned in\r
-                                 UsbStatus\r
+                                 UsbStatus.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoSyncInterruptTransfer (\r
@@ -363,25 +387,24 @@ ON_EXIT:
 \r
 /**\r
   Queue a new asynchronous interrupt transfer, or remove the old\r
-  request if (IsNewTransfer == FALSE)\r
+  request if (IsNewTransfer == FALSE).\r
 \r
-  @param  This                   The USB_IO instance\r
-  @param  Endpoint               The device endpoint\r
+  @param  This                   The USB_IO instance.\r
+  @param  Endpoint               The device endpoint.\r
   @param  IsNewTransfer          Whether this is a new request, if it's old, remove\r
-                                 the request\r
-  @param  PollInterval           The interval to poll the transfer result, (in ms)\r
-  @param  DataLength             The length of perodic data transfer\r
+                                 the request.\r
+  @param  PollInterval           The interval to poll the transfer result, (in ms).\r
+  @param  DataLength             The length of perodic data transfer.\r
   @param  Callback               The function to call periodicaly when transfer is\r
-                                 ready\r
-  @param  Context                The context to the callback\r
+                                 ready.\r
+  @param  Context                The context to the callback.\r
 \r
-  @retval EFI_SUCCESS            New transfer is queued or old request is removed\r
-  @retval EFI_INVALID_PARAMETER  Some parameters are invalid\r
+  @retval EFI_SUCCESS            New transfer is queued or old request is removed.\r
+  @retval EFI_INVALID_PARAMETER  Some parameters are invalid.\r
   @retval Others                 Failed to queue the new request or remove the old\r
-                                 request\r
+                                 request.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoAsyncInterruptTransfer (\r
@@ -441,18 +464,17 @@ ON_EXIT:
 \r
 \r
 /**\r
-  Execute a synchronous isochronous transfer\r
+  Execute a synchronous isochronous transfer.\r
 \r
-  @param  This                   The USB IO instance\r
-  @param  DeviceEndpoint         The device endpoint\r
-  @param  Data                   The data to transfer\r
-  @param  DataLength             The length of the data to transfer\r
-  @param  UsbStatus              The result of USB transfer\r
+  @param  This                   The USB IO instance.\r
+  @param  DeviceEndpoint         The device endpoint.\r
+  @param  Data                   The data to transfer.\r
+  @param  DataLength             The length of the data to transfer.\r
+  @param  UsbStatus              The result of USB transfer.\r
 \r
-  @retval EFI_UNSUPPORTED        Currently isochronous transfer isn't supported\r
+  @retval EFI_UNSUPPORTED        Currently isochronous transfer isn't supported.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoIsochronousTransfer (\r
@@ -468,19 +490,19 @@ UsbIoIsochronousTransfer (
 \r
 \r
 /**\r
-  Queue an asynchronous isochronous transfer\r
+  Queue an asynchronous isochronous transfer.\r
 \r
-  @param  This                   The USB_IO instance\r
-  @param  DeviceEndpoint         The device endpoint\r
-  @param  DataLength             The length of perodic data transfer\r
+  @param  This                   The USB_IO instance.\r
+  @param  DeviceEndpoint         The device endpoint.\r
+  @param  Data                   The data to transfer.\r
+  @param  DataLength             The length of perodic data transfer.\r
   @param  IsochronousCallBack    The function to call periodicaly when transfer is\r
-                                 ready\r
-  @param  Context                The context to the callback\r
+                                 ready.\r
+  @param  Context                The context to the callback.\r
 \r
-  @retval EFI_UNSUPPORTED        Currently isochronous transfer isn't supported\r
+  @retval EFI_UNSUPPORTED        Currently isochronous transfer isn't supported.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoAsyncIsochronousTransfer (\r
@@ -497,16 +519,15 @@ UsbIoAsyncIsochronousTransfer (
 \r
 \r
 /**\r
-  Retrieve the device descriptor of the device\r
+  Retrieve the device descriptor of the device.\r
 \r
-  @param  This                   The USB IO instance\r
-  @param  Descriptor             The variable to receive the device descriptor\r
+  @param  This                   The USB IO instance.\r
+  @param  Descriptor             The variable to receive the device descriptor.\r
 \r
-  @retval EFI_SUCCESS            The device descriptor is returned\r
-  @retval EFI_INVALID_PARAMETER  The parameter is invalid\r
+  @retval EFI_SUCCESS            The device descriptor is returned.\r
+  @retval EFI_INVALID_PARAMETER  The parameter is invalid.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoGetDeviceDescriptor (\r
@@ -535,17 +556,16 @@ UsbIoGetDeviceDescriptor (
 \r
 \r
 /**\r
-  Return the configuration descriptor of the current active configuration\r
+  Return the configuration descriptor of the current active configuration.\r
 \r
-  @param  This                   The USB IO instance\r
-  @param  Descriptor             The USB configuration descriptor\r
+  @param  This                   The USB IO instance.\r
+  @param  Descriptor             The USB configuration descriptor.\r
 \r
-  @retval EFI_SUCCESS            The active configuration descriptor is returned\r
-  @retval EFI_INVALID_PARAMETER  Some parameter is invalid\r
+  @retval EFI_SUCCESS            The active configuration descriptor is returned.\r
+  @retval EFI_INVALID_PARAMETER  Some parameter is invalid.\r
   @retval EFI_NOT_FOUND          Currently no active configuration is selected.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoGetActiveConfigDescriptor (\r
@@ -582,16 +602,15 @@ ON_EXIT:
 \r
 \r
 /**\r
-  Retrieve the active interface setting descriptor for this USB IO instance\r
+  Retrieve the active interface setting descriptor for this USB IO instance.\r
 \r
-  @param  This                   The USB IO instance\r
-  @param  Descriptor             The variable to receive active interface setting\r
+  @param  This                   The USB IO instance.\r
+  @param  Descriptor             The variable to receive active interface setting.\r
 \r
-  @retval EFI_SUCCESS            The active interface setting is returned\r
-  @retval EFI_INVALID_PARAMETER  Some parameter is invalid\r
+  @retval EFI_SUCCESS            The active interface setting is returned.\r
+  @retval EFI_INVALID_PARAMETER  Some parameter is invalid.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoGetInterfaceDescriptor (\r
@@ -617,18 +636,17 @@ UsbIoGetInterfaceDescriptor (
 \r
 \r
 /**\r
-  Retrieve the endpoint descriptor from this interface setting\r
+  Retrieve the endpoint descriptor from this interface setting.\r
 \r
-  @param  This                   The USB IO instance\r
+  @param  This                   The USB IO instance.\r
   @param  Index                  The index (start from zero) of the endpoint to\r
-                                 retrieve\r
-  @param  Descriptor             The variable to receive the descriptor\r
+                                 retrieve.\r
+  @param  Descriptor             The variable to receive the descriptor.\r
 \r
-  @retval EFI_SUCCESS            The endpoint descriptor is returned\r
-  @retval EFI_INVALID_PARAMETER  Some parameter is invalid\r
+  @retval EFI_SUCCESS            The endpoint descriptor is returned.\r
+  @retval EFI_INVALID_PARAMETER  Some parameter is invalid.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoGetEndpointDescriptor (\r
@@ -666,16 +684,15 @@ UsbIoGetEndpointDescriptor (
 \r
 \r
 /**\r
-  Retrieve the supported language ID table from the device\r
+  Retrieve the supported language ID table from the device.\r
 \r
-  @param  This                   The USB IO instance\r
-  @param  LangIDTable            The table to return the language IDs\r
-  @param  TableSize              The number of supported languanges\r
+  @param  This                   The USB IO instance.\r
+  @param  LangIDTable            The table to return the language IDs.\r
+  @param  TableSize              The size, in bytes, of the table LangIDTable.\r
 \r
-  @retval EFI_SUCCESS            The language ID is return\r
+  @retval EFI_SUCCESS            The language ID is return.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoGetSupportedLanguages (\r
@@ -694,7 +711,7 @@ UsbIoGetSupportedLanguages (
   Dev           = UsbIf->Device;\r
 \r
   *LangIDTable  = Dev->LangId;\r
-  *TableSize    = Dev->TotalLangId;\r
+  *TableSize    = (UINT16) (Dev->TotalLangId * sizeof (UINT16));\r
 \r
   gBS->RestoreTPL (OldTpl);\r
   return EFI_SUCCESS;\r
@@ -702,18 +719,17 @@ UsbIoGetSupportedLanguages (
 \r
 \r
 /**\r
-  Retrieve an indexed string in the language of LangID\r
+  Retrieve an indexed string in the language of LangID.\r
 \r
-  @param  This                   The USB IO instance\r
-  @param  LangID                 The language ID of the string to retrieve\r
-  @param  StringIndex            The index of the string\r
-  @param  String                 The variable to receive the string\r
+  @param  This                   The USB IO instance.\r
+  @param  LangID                 The language ID of the string to retrieve.\r
+  @param  StringIndex            The index of the string.\r
+  @param  String                 The variable to receive the string.\r
 \r
-  @retval EFI_SUCCESS            The string is returned\r
-  @retval EFI_NOT_FOUND          No such string existed\r
+  @retval EFI_SUCCESS            The string is returned.\r
+  @retval EFI_NOT_FOUND          No such string existed.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 UsbIoGetStringDescriptor (\r
@@ -746,6 +762,7 @@ UsbIoGetStringDescriptor (
   Status = EFI_NOT_FOUND;\r
 \r
   for (Index = 0; Index < Dev->TotalLangId; Index++) {\r
+    ASSERT (Index < USB_MAX_LANG_ID);\r
     if (Dev->LangId[Index] == LangID) {\r
       break;\r
     }\r
@@ -793,10 +810,10 @@ ON_EXIT:
   Reset the device, then if that succeeds, reconfigure the\r
   device with its address and current active configuration.\r
 \r
-  @param  This                   The USB IO instance\r
+  @param  This                   The USB IO instance.\r
 \r
-  @retval EFI_SUCCESS            The device is reset and configured\r
-  @retval Others                 Failed to reset the device\r
+  @retval EFI_SUCCESS            The device is reset and configured.\r
+  @retval Others                 Failed to reset the device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -808,9 +825,9 @@ UsbIoPortReset (
   USB_INTERFACE           *UsbIf;\r
   USB_INTERFACE           *HubIf;\r
   USB_DEVICE              *Dev;\r
-  UINT8                   Address;\r
   EFI_TPL                 OldTpl;\r
   EFI_STATUS              Status;\r
+  UINT8                   DevAddress;\r
 \r
   OldTpl = gBS->RaiseTPL (USB_BUS_TPL);\r
 \r
@@ -832,27 +849,32 @@ UsbIoPortReset (
     goto ON_EXIT;\r
   }\r
 \r
+  HubIf->HubApi->ClearPortChange (HubIf, Dev->ParentPort);\r
+\r
   //\r
-  // Reset the device to its current address. The device now has a\r
-  // address of ZERO, so need to set Dev->Address to zero first for\r
-  // host to communicate with the device\r
+  // Reset the device to its current address. The device now has an address\r
+  // of ZERO after port reset, so need to set Dev->Address to the device again for\r
+  // host to communicate with it.\r
   //\r
-  Address       = Dev->Address;\r
-  Dev->Address  = 0;\r
-  Status        = UsbSetAddress (Dev, Address);\r
-  Dev->Address  = Address;\r
+  DevAddress   = Dev->Address;\r
+  Dev->Address = 0;\r
+  Status  = UsbSetAddress (Dev, DevAddress);\r
+  Dev->Address = DevAddress;\r
+\r
+  gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL);\r
   \r
   if (EFI_ERROR (Status)) {\r
+    //\r
+    // It may fail due to device disconnection or other reasons.\r
+    //\r
     DEBUG (( EFI_D_ERROR, "UsbIoPortReset: failed to set address for device %d - %r\n",\r
-                Address, Status));\r
+                Dev->Address, Status));\r
 \r
     goto ON_EXIT;\r
   }\r
 \r
-  gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL);\r
+  DEBUG (( EFI_D_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Dev->Address));\r
 \r
-  DEBUG (( EFI_D_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Address));\r
-  \r
   //\r
   // Reset the current active configure, after this device\r
   // is in CONFIGURED state.\r
@@ -862,7 +884,7 @@ UsbIoPortReset (
 \r
     if (EFI_ERROR (Status)) {\r
       DEBUG (( EFI_D_ERROR, "UsbIoPortReset: failed to set configure for device %d - %r\n",\r
-                  Address, Status));\r
+                  Dev->Address, Status));\r
     }\r
   }\r
 \r
@@ -873,15 +895,15 @@ ON_EXIT:
 \r
 \r
 /**\r
-  Install Usb Bus Protocol on host controller, and start the Usb bus\r
+  Install Usb Bus Protocol on host controller, and start the Usb bus.\r
 \r
-  @param This                    The USB bus driver binding instance\r
-  @param Controller              The controller to check\r
-  @param RemainingDevicePath     The remaining device patch\r
+  @param This                    The USB bus driver binding instance.\r
+  @param Controller              The controller to check.\r
+  @param RemainingDevicePath     The remaining device patch.\r
 \r
-  @retval EFI_SUCCESS            The controller is controlled by the usb bus\r
-  @retval EFI_ALREADY_STARTED    The controller is already controlled by the usb bus\r
-  @retval EFI_OUT_OF_RESOURCES   Failed to allocate resources\r
+  @retval EFI_SUCCESS            The controller is controlled by the usb bus.\r
+  @retval EFI_ALREADY_STARTED    The controller is already controlled by the usb bus.\r
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate resources.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -904,8 +926,9 @@ UsbBusBuildProtocol (
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  UsbBus->Signature   = USB_BUS_SIGNATURE;\r
-  UsbBus->HostHandle  = Controller;\r
+  UsbBus->Signature  = USB_BUS_SIGNATURE;\r
+  UsbBus->HostHandle = Controller;\r
+  UsbBus->MaxDevices = USB_MAX_DEVICES;\r
 \r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
@@ -919,13 +942,13 @@ UsbBusBuildProtocol (
   if (EFI_ERROR (Status)) {\r
     DEBUG ((EFI_D_ERROR, "UsbBusStart: Failed to open device path %r\n", Status));\r
 \r
-    gBS->FreePool (UsbBus);\r
+    FreePool (UsbBus);\r
     return Status;\r
   }\r
 \r
   //\r
   // Get USB_HC2/USB_HC host controller protocol (EHCI/UHCI).\r
-  // This is for backward compatbility with EFI 1.x. In UEFI\r
+  // This is for backward compatibility with EFI 1.x. In UEFI\r
   // 2.x, USB_HC2 replaces USB_HC. We will open both USB_HC2\r
   // and USB_HC because EHCI driver will install both protocols\r
   // (for the same reason). If we don't consume both of them,\r
@@ -956,15 +979,23 @@ UsbBusBuildProtocol (
     goto CLOSE_HC;\r
   }\r
 \r
-  UsbHcReset (UsbBus, EFI_USB_HC_RESET_GLOBAL);\r
-  UsbHcSetState (UsbBus, EfiUsbHcStateOperational);\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // The EFI_USB2_HC_PROTOCOL is produced for XHCI support.\r
+    // Then its max supported devices are 256. Otherwise it's 128.\r
+    //\r
+    ASSERT (UsbBus->Usb2Hc != NULL);\r
+    if (UsbBus->Usb2Hc->MajorRevision == 0x3) {\r
+      UsbBus->MaxDevices = 256;\r
+    }\r
+  }\r
 \r
   //\r
-  // Install an EFI_USB_BUS_PROTOCOL to host controler to identify it.\r
+  // Install an EFI_USB_BUS_PROTOCOL to host controller to identify it.\r
   //\r
   Status = gBS->InstallProtocolInterface (\r
                   &Controller,\r
-                  &mUsbBusProtocolGuid,\r
+                  &gEfiCallerIdGuid,\r
                   EFI_NATIVE_INTERFACE,\r
                   &UsbBus->BusId\r
                   );\r
@@ -993,7 +1024,7 @@ UsbBusBuildProtocol (
   RootIf = AllocateZeroPool (sizeof (USB_INTERFACE));\r
 \r
   if (RootIf == NULL) {\r
-    gBS->FreePool (RootHub);\r
+    FreePool (RootHub);\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto FREE_ROOTHUB;\r
   }\r
@@ -1001,10 +1032,20 @@ UsbBusBuildProtocol (
   RootHub->Bus            = UsbBus;\r
   RootHub->NumOfInterface = 1;\r
   RootHub->Interfaces[0]  = RootIf;\r
+  RootHub->Tier           = 0;\r
   RootIf->Signature       = USB_INTERFACE_SIGNATURE;\r
   RootIf->Device          = RootHub;\r
   RootIf->DevicePath      = UsbBus->DevicePath;\r
-\r
+  \r
+  //\r
+  // Report Status Code here since we will enumerate the USB devices\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    (EFI_IO_BUS_USB | EFI_IOB_PC_DETECT),\r
+    UsbBus->DevicePath\r
+    );\r
+  \r
   Status                  = mUsbRootHubApi.Init (RootIf);\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -1014,19 +1055,19 @@ UsbBusBuildProtocol (
 \r
   UsbBus->Devices[0] = RootHub;\r
 \r
-  DEBUG ((EFI_D_INFO, "UsbBusStart: usb bus started on %x, root hub %x\n", Controller, RootIf));\r
+  DEBUG ((EFI_D_INFO, "UsbBusStart: usb bus started on %p, root hub %p\n", Controller, RootIf));\r
   return EFI_SUCCESS;\r
 \r
 FREE_ROOTHUB:\r
   if (RootIf != NULL) {\r
-    gBS->FreePool (RootIf);\r
+    FreePool (RootIf);\r
   }\r
   if (RootHub != NULL) {\r
-    gBS->FreePool (RootHub);\r
+    FreePool (RootHub);\r
   }\r
 \r
 UNINSTALL_USBBUS:\r
-  gBS->UninstallProtocolInterface (Controller, &mUsbBusProtocolGuid, &UsbBus->BusId);\r
+  gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid, &UsbBus->BusId);\r
 \r
 CLOSE_HC:\r
   if (UsbBus->Usb2Hc != NULL) {\r
@@ -1051,52 +1092,29 @@ CLOSE_HC:
          This->DriverBindingHandle,\r
          Controller\r
          );\r
-  gBS->FreePool (UsbBus);\r
+  FreePool (UsbBus);\r
 \r
   DEBUG ((EFI_D_ERROR, "UsbBusStart: Failed to start bus driver %r\n", Status));\r
   return Status;\r
 }\r
 \r
-EFI_USB_IO_PROTOCOL mUsbIoProtocol = {\r
-  UsbIoControlTransfer,\r
-  UsbIoBulkTransfer,\r
-  UsbIoAsyncInterruptTransfer,\r
-  UsbIoSyncInterruptTransfer,\r
-  UsbIoIsochronousTransfer,\r
-  UsbIoAsyncIsochronousTransfer,\r
-  UsbIoGetDeviceDescriptor,\r
-  UsbIoGetActiveConfigDescriptor,\r
-  UsbIoGetInterfaceDescriptor,\r
-  UsbIoGetEndpointDescriptor,\r
-  UsbIoGetStringDescriptor,\r
-  UsbIoGetSupportedLanguages,\r
-  UsbIoPortReset\r
-};\r
 \r
+/**\r
+  The USB bus driver entry pointer.\r
+\r
+  @param ImageHandle       The driver image handle.\r
+  @param SystemTable       The system table.\r
 \r
+  @return EFI_SUCCESS      The component name protocol is installed.\r
+  @return Others           Failed to init the usb driver.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 UsbBusDriverEntryPoint (\r
   IN EFI_HANDLE           ImageHandle,\r
   IN EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The USB bus driver entry pointer\r
-\r
-Arguments:\r
-\r
-  ImageHandle - The driver image handle\r
-  SystemTable - The system table\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS - The component name protocol is installed\r
-  Others      - Failed to init the usb driver\r
-\r
---*/\r
 {\r
   return EfiLibInstallDriverBindingComponentName2 (\r
            ImageHandle,\r
@@ -1110,14 +1128,14 @@ Returns:
 \r
 \r
 /**\r
-  Check whether USB bus driver support this device\r
+  Check whether USB bus driver support this device.\r
 \r
-  @param  This                   The USB bus driver binding protocol\r
-  @param  Controller             The controller handle to test againist\r
-  @param  RemainingDevicePath    The remaining device path\r
+  @param  This                   The USB bus driver binding protocol.\r
+  @param  Controller             The controller handle to check.\r
+  @param  RemainingDevicePath    The remaining device path.\r
 \r
   @retval EFI_SUCCESS            The bus supports this controller.\r
-  @retval EFI_UNSUPPORTED        This device isn't supported\r
+  @retval EFI_UNSUPPORTED        This device isn't supported.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1138,42 +1156,28 @@ UsbBusControllerDriverSupported (
   // Check whether device path is valid\r
   //\r
   if (RemainingDevicePath != NULL) {\r
-    DevicePathNode.DevPath = RemainingDevicePath;\r
-\r
-    if ((DevicePathNode.DevPath->Type    != MESSAGING_DEVICE_PATH) ||\r
-        (DevicePathNode.DevPath->SubType != MSG_USB_DP &&\r
-         DevicePathNode.DevPath->SubType != MSG_USB_CLASS_DP\r
-         && DevicePathNode.DevPath->SubType != MSG_USB_WWID_DP\r
-         )) {\r
-\r
-      return EFI_UNSUPPORTED;\r
+    //\r
+    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // if yes, go on checking other conditions\r
+    //\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      DevicePathNode.DevPath = RemainingDevicePath;\r
+      \r
+      if ((DevicePathNode.DevPath->Type    != MESSAGING_DEVICE_PATH) ||\r
+          (DevicePathNode.DevPath->SubType != MSG_USB_DP &&\r
+           DevicePathNode.DevPath->SubType != MSG_USB_CLASS_DP\r
+           && DevicePathNode.DevPath->SubType != MSG_USB_WWID_DP\r
+           )) {\r
+      \r
+        return EFI_UNSUPPORTED;\r
+      }\r
     }\r
   }\r
 \r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
   //\r
   // Check whether USB_HC2 protocol is installed\r
   //\r
@@ -1185,45 +1189,80 @@ UsbBusControllerDriverSupported (
                   Controller,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
                   );\r
-\r
   if (Status == EFI_ALREADY_STARTED) {\r
     return EFI_SUCCESS;\r
   }\r
 \r
-  if (!EFI_ERROR (Status)) {\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // If failed to open USB_HC2, fall back to USB_HC\r
+    //\r
+    Status = gBS->OpenProtocol (\r
+                    Controller,\r
+                    &gEfiUsbHcProtocolGuid,\r
+                    (VOID **) &UsbHc,\r
+                    This->DriverBindingHandle,\r
+                    Controller,\r
+                    EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                    );\r
+    if (Status == EFI_ALREADY_STARTED) {\r
+      return EFI_SUCCESS;\r
+    }\r
+  \r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    //\r
+    // Close the USB_HC used to perform the supported test\r
+    //\r
     gBS->CloseProtocol (\r
           Controller,\r
-          &gEfiUsb2HcProtocolGuid,\r
+          &gEfiUsbHcProtocolGuid,\r
           This->DriverBindingHandle,\r
           Controller\r
           );\r
 \r
-    return EFI_SUCCESS;\r
-  }\r
+  } else {\r
 \r
+    //\r
+    // Close the USB_HC2 used to perform the supported test\r
+    //\r
+    gBS->CloseProtocol (\r
+           Controller,\r
+           &gEfiUsb2HcProtocolGuid,\r
+           This->DriverBindingHandle,\r
+           Controller\r
+           );\r
+  }\r
\r
   //\r
-  // If failed to open USB_HC2, fall back to USB_HC\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiUsbHcProtocolGuid,\r
-                  (VOID **) &UsbHc,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
                   );\r
-\r
   if (Status == EFI_ALREADY_STARTED) {\r
     return EFI_SUCCESS;\r
   }\r
 \r
   if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Close protocol, don't use device path protocol in the Support() function\r
+    //\r
     gBS->CloseProtocol (\r
           Controller,\r
-          &gEfiUsbHcProtocolGuid,\r
+          &gEfiDevicePathProtocolGuid,\r
           This->DriverBindingHandle,\r
           Controller\r
           );\r
+\r
+    return EFI_SUCCESS;\r
   }\r
 \r
   return Status;\r
@@ -1231,16 +1270,16 @@ UsbBusControllerDriverSupported (
 \r
 \r
 /**\r
-  Start to process the controller\r
+  Start to process the controller.\r
 \r
-  @param  This                   The USB bus driver binding instance\r
-  @param  Controller             The controller to check\r
-  @param  RemainingDevicePath    The remaining device patch\r
+  @param  This                   The USB bus driver binding instance.\r
+  @param  Controller             The controller to check.\r
+  @param  RemainingDevicePath    The remaining device patch.\r
 \r
-  @retval EFI_SUCCESS            The controller is controlled by the usb bus\r
+  @retval EFI_SUCCESS            The controller is controlled by the usb bus.\r
   @retval EFI_ALREADY_STARTED    The controller is already controlled by the usb\r
-                                 bus\r
-  @retval EFI_OUT_OF_RESOURCES   Failed to allocate resources\r
+                                 bus.\r
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate resources.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1253,6 +1292,26 @@ UsbBusControllerDriverStart (
 {\r
   EFI_USB_BUS_PROTOCOL          *UsbBusId;\r
   EFI_STATUS                    Status;\r
+  EFI_DEVICE_PATH_PROTOCOL      *ParentDevicePath;\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Report Status Code here since we will initialize the host controller\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    (EFI_IO_BUS_USB | EFI_IOB_PC_INIT),\r
+    ParentDevicePath\r
+    );\r
 \r
   //\r
   // Locate the USB bus protocol, if it is found, USB bus\r
@@ -1260,7 +1319,7 @@ UsbBusControllerDriverStart (
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &mUsbBusProtocolGuid,\r
+                  &gEfiCallerIdGuid,\r
                   (VOID **) &UsbBusId,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
@@ -1269,8 +1328,9 @@ UsbBusControllerDriverStart (
 \r
   if (EFI_ERROR (Status)) {\r
     //\r
-    // If first start, build the bus execute enviorment and install bus protocol\r
+    // If first start, build the bus execute environment and install bus protocol\r
     //\r
+    REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_IO_BUS_USB | EFI_P_PC_ENABLE));\r
     Status = UsbBusBuildProtocol (This, Controller, RemainingDevicePath);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
@@ -1280,7 +1340,7 @@ UsbBusControllerDriverStart (
     //\r
     Status = gBS->OpenProtocol (\r
                     Controller,\r
-                    &mUsbBusProtocolGuid,\r
+                    &gEfiCallerIdGuid,\r
                     (VOID **) &UsbBusId,\r
                     This->DriverBindingHandle,\r
                     Controller,\r
@@ -1297,6 +1357,16 @@ UsbBusControllerDriverStart (
     //\r
     // Save the passed in RemainingDevicePath this time\r
     //\r
+    if (RemainingDevicePath != NULL) {\r
+      if (IsDevicePathEnd (RemainingDevicePath)) {\r
+        //\r
+        // If RemainingDevicePath is the End of Device Path Node,\r
+        // skip enumerate any device and return EFI_SUCESSS\r
+        // \r
+        return EFI_SUCCESS;\r
+      }\r
+    }\r
+\r
     Status = UsbBusAddWantedUsbIoDP (UsbBusId, RemainingDevicePath);\r
     ASSERT (!EFI_ERROR (Status));\r
     //\r
@@ -1312,16 +1382,16 @@ UsbBusControllerDriverStart (
 \r
 \r
 /**\r
-  Stop handle the controller by this USB bus driver\r
+  Stop handle the controller by this USB bus driver.\r
 \r
-  @param  This                   The USB bus driver binding protocol\r
-  @param  Controller             The controller to release\r
+  @param  This                   The USB bus driver binding protocol.\r
+  @param  Controller             The controller to release.\r
   @param  NumberOfChildren       The child of USB bus that opened controller\r
-                                 BY_CHILD\r
-  @param  ChildHandleBuffer      The array of child handle\r
+                                 BY_CHILD.\r
+  @param  ChildHandleBuffer      The array of child handle.\r
 \r
-  @retval EFI_SUCCESS            The controller or children are stopped\r
-  @retval EFI_DEVICE_ERROR       Failed to stop the driver\r
+  @retval EFI_SUCCESS            The controller or children are stopped.\r
+  @retval EFI_DEVICE_ERROR       Failed to stop the driver.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1343,6 +1413,7 @@ UsbBusControllerDriverStop (
   EFI_TPL               OldTpl;\r
   UINTN                 Index;\r
   EFI_STATUS            Status;\r
+  EFI_STATUS            ReturnStatus;\r
 \r
   Status  = EFI_SUCCESS;\r
 \r
@@ -1352,6 +1423,7 @@ UsbBusControllerDriverStop (
     //\r
     OldTpl   = gBS->RaiseTPL (TPL_CALLBACK);\r
 \r
+    ReturnStatus = EFI_SUCCESS;\r
     for (Index = 0; Index < NumberOfChildren; Index++) {\r
       Status = gBS->OpenProtocol (\r
                       ChildHandleBuffer[Index],\r
@@ -1375,21 +1447,21 @@ UsbBusControllerDriverStop (
       UsbIf   = USB_INTERFACE_FROM_USBIO (UsbIo);\r
       UsbDev  = UsbIf->Device;\r
 \r
-      UsbRemoveDevice (UsbDev);\r
+      ReturnStatus = UsbRemoveDevice (UsbDev);\r
     }\r
 \r
     gBS->RestoreTPL (OldTpl);\r
-    return EFI_SUCCESS;\r
+    return ReturnStatus;\r
   }\r
 \r
-  DEBUG (( EFI_D_INFO, "UsbBusStop: usb bus stopped on %x\n", Controller));\r
+  DEBUG (( EFI_D_INFO, "UsbBusStop: usb bus stopped on %p\n", Controller));\r
 \r
   //\r
   // Locate USB_BUS for the current host controller\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &mUsbBusProtocolGuid,\r
+                  &gEfiCallerIdGuid,\r
                   (VOID **) &BusId,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
@@ -1408,66 +1480,64 @@ UsbBusControllerDriverStop (
   // BugBug: Raise TPL to callback level instead of USB_BUS_TPL to avoid TPL conflict\r
   //\r
   OldTpl  = gBS->RaiseTPL (TPL_CALLBACK);\r
-  UsbHcSetState (Bus, EfiUsbHcStateHalt);\r
 \r
   RootHub = Bus->Devices[0];\r
   RootIf  = RootHub->Interfaces[0];\r
 \r
-  mUsbRootHubApi.Release (RootIf);\r
-\r
-  for (Index = 1; Index < USB_MAX_DEVICES; Index++) {\r
+  ASSERT (Bus->MaxDevices <= 256);\r
+  ReturnStatus = EFI_SUCCESS;\r
+  for (Index = 1; Index < Bus->MaxDevices; Index++) {\r
     if (Bus->Devices[Index] != NULL) {\r
-      UsbRemoveDevice (Bus->Devices[Index]);\r
+      Status = UsbRemoveDevice (Bus->Devices[Index]);\r
+      if (EFI_ERROR (Status)) {\r
+        ReturnStatus = Status;\r
+      }\r
     }\r
   }\r
 \r
   gBS->RestoreTPL (OldTpl);\r
 \r
-  gBS->FreePool   (RootIf);\r
-  gBS->FreePool   (RootHub);\r
-  Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);\r
-  ASSERT (!EFI_ERROR (Status));\r
+  if (!EFI_ERROR (ReturnStatus)) {\r
+    mUsbRootHubApi.Release (RootIf);\r
+    gBS->FreePool   (RootIf);\r
+    gBS->FreePool   (RootHub);\r
 \r
-  //\r
-  // Uninstall the bus identifier and close USB_HC/USB2_HC protocols\r
-  //\r
-  gBS->UninstallProtocolInterface (Controller, &mUsbBusProtocolGuid, &Bus->BusId);\r
+    Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);\r
+    ASSERT (!EFI_ERROR (Status));\r
 \r
-  if (Bus->Usb2Hc != NULL) {\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiUsb2HcProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-  }\r
+    //\r
+    // Uninstall the bus identifier and close USB_HC/USB2_HC protocols\r
+    //\r
+    gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid, &Bus->BusId);\r
 \r
-  if (Bus->UsbHc != NULL) {\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiUsbHcProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-  }\r
+    if (Bus->Usb2Hc != NULL) {\r
+      Status = gBS->CloseProtocol (\r
+                      Controller,\r
+                      &gEfiUsb2HcProtocolGuid,\r
+                      This->DriverBindingHandle,\r
+                      Controller\r
+                      );\r
+    }\r
 \r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
+    if (Bus->UsbHc != NULL) {\r
+      Status = gBS->CloseProtocol (\r
+                      Controller,\r
+                      &gEfiUsbHcProtocolGuid,\r
+                      This->DriverBindingHandle,\r
+                      Controller\r
+                      );\r
+    }\r
 \r
-  gBS->FreePool (Bus);\r
+    if (!EFI_ERROR (Status)) {\r
+      gBS->CloseProtocol (\r
+             Controller,\r
+             &gEfiDevicePathProtocolGuid,\r
+             This->DriverBindingHandle,\r
+             Controller\r
+             );\r
 \r
+      gBS->FreePool (Bus);\r
+    }\r
+  }\r
   return Status;\r
 }\r
-\r
-EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding = {\r
-  UsbBusControllerDriverSupported,\r
-  UsbBusControllerDriverStart,\r
-  UsbBusControllerDriverStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r