]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
check the usage of %d,%x,%ld,%lx and so on in debug print statement.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / Uhci.c
index 661f125149235934ad1ca2dc7eb8e3c11d89ebcb..deb21dd837337ebe5277220ea895e6b8297f8ead 100644 (file)
@@ -1,5 +1,7 @@
 /** @file\r
 \r
+  The UHCI driver model and HC protocol routines.\r
+\r
 Copyright (c) 2004 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -9,35 +11,33 @@ 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
-  Uhci.c\r
-\r
-Abstract:\r
-\r
-  The UHCI driver model and HC protocol routines.\r
-\r
-Revision History\r
-\r
-\r
 **/\r
 \r
 #include "Uhci.h"\r
 \r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gUhciDriverBinding = {\r
+  UhciDriverBindingSupported,\r
+  UhciDriverBindingStart,\r
+  UhciDriverBindingStop,\r
+  0x20,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
 /**\r
   Provides software reset for the USB host controller according to UEFI 2.0 spec.\r
 \r
-  @param  This                 A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-  @param  Attributes           A bit mask of the reset operation to perform.  See\r
-                               below for a list of the supported bit mask values.\r
+  @param  This                   A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  @param  Attributes             A bit mask of the reset operation to perform.  See\r
+                                 below for a list of the supported bit mask values.\r
 \r
-  @return EFI_SUCCESS           : The reset operation succeeded.\r
-  @return EFI_INVALID_PARAMETER : Attributes is not valid.\r
-  @return EFI_UNSUPPORTED       : This type of reset is not currently supported\r
-  @return EFI_DEVICE_ERROR      : Other errors\r
+  @return EFI_SUCCESS            The reset operation succeeded.\r
+  @return EFI_INVALID_PARAMETER  Attributes is not valid.\r
+  @return EFI_UNSUPPORTED        This type of reset is not currently supported.\r
+  @return EFI_DEVICE_ERROR       Other errors.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2Reset (\r
@@ -112,15 +112,14 @@ ON_INVAILD_PARAMETER:
 /**\r
   Retrieves current state of the USB host controller according to UEFI 2.0 spec.\r
 \r
-  @param  This                 A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-  @param  State                Variable to receive current device state\r
+  @param  This                   A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  @param  State                  Variable to receive current device state.\r
 \r
-  @return EFI_SUCCESS           : The state is returned\r
-  @return EFI_INVALID_PARAMETER : State is not valid.\r
-  @return EFI_DEVICE_ERROR      : Other errors2006\r
+  @return EFI_SUCCESS            The state is returned.\r
+  @return EFI_INVALID_PARAMETER  State is not valid.\r
+  @return EFI_DEVICE_ERROR       Other errors.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2GetState (\r
@@ -141,7 +140,7 @@ Uhci2GetState (
   UsbCmd  = UhciReadReg (Uhc->PciIo, USBCMD_OFFSET);\r
   UsbSts  = UhciReadReg (Uhc->PciIo, USBSTS_OFFSET);\r
 \r
-  if (UsbCmd & USBCMD_EGSM) {\r
+  if ((UsbCmd & USBCMD_EGSM) !=0 ) {\r
     *State = EfiUsbHcStateSuspend;\r
 \r
   } else if ((UsbSts & USBSTS_HCH) != 0) {\r
@@ -158,16 +157,15 @@ Uhci2GetState (
 /**\r
   Sets the USB host controller to a specific state according to UEFI 2.0 spec.\r
 \r
-  @param  This                 A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-  @param  State                Indicates the state of the host controller that will\r
-                               be set.\r
+  @param  This                   A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  @param  State                  Indicates the state of the host controller that will\r
+                                 be set.\r
 \r
-  @return EFI_SUCCESS           : Host controller was successfully placed in the state\r
-  @return EFI_INVALID_PARAMETER : State is invalid.\r
-  @return EFI_DEVICE_ERROR      : Failed to set the state\r
+  @return EFI_SUCCESS            Host controller was successfully placed in the state.\r
+  @return EFI_INVALID_PARAMETER  State is invalid.\r
+  @return EFI_DEVICE_ERROR       Failed to set the state.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2SetState (\r
@@ -265,19 +263,18 @@ ON_EXIT:
 /**\r
   Retrieves capabilities of USB host controller according to UEFI 2.0 spec.\r
 \r
-  @param  This                 A pointer to the EFI_USB2_HC_PROTOCOL instance\r
-  @param  MaxSpeed             A pointer to the max speed USB host controller\r
-                               supports.\r
-  @param  PortNumber           A pointer to the number of root hub ports.\r
-  @param  Is64BitCapable       A pointer to an integer to show whether USB host\r
-                               controller supports 64-bit memory addressing.\r
+  @param  This                   A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  @param  MaxSpeed               A pointer to the max speed USB host controller\r
+                                 supports.\r
+  @param  PortNumber             A pointer to the number of root hub ports.\r
+  @param  Is64BitCapable         A pointer to an integer to show whether USB host\r
+                                 controller supports 64-bit memory addressing.\r
 \r
-  @return EFI_SUCCESS           : capabilities were retrieved successfully.\r
-  @return EFI_INVALID_PARAMETER : MaxSpeed or PortNumber or Is64BitCapable is NULL.\r
-  @return EFI_DEVICE_ERROR      : An error was encountered\r
+  @return EFI_SUCCESS            capabilities were retrieved successfully.\r
+  @return EFI_INVALID_PARAMETER  MaxSpeed or PortNumber or Is64BitCapable is NULL.\r
+  @return EFI_DEVICE_ERROR       An error was encountered.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2GetCapability (\r
@@ -321,7 +318,7 @@ Uhci2GetCapability (
 \r
   Uhc->RootPorts = *PortNumber;\r
 \r
-  DEBUG ((EFI_D_INFO, "Uhci2GetCapability: %d ports\n", Uhc->RootPorts));\r
+  DEBUG ((EFI_D_INFO, "Uhci2GetCapability: %d ports\n", (UINT32)Uhc->RootPorts));\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -329,17 +326,16 @@ Uhci2GetCapability (
 /**\r
   Retrieves the current status of a USB root hub port according to UEFI 2.0 spec.\r
 \r
-  @param  This                 A pointer to the EFI_USB2_HC_PROTOCOL.\r
-  @param  PortNumber           The port to get status\r
-  @param  PortStatus           A pointer to the current port status bits and  port\r
-                               status change bits.\r
+  @param  This                    A pointer to the EFI_USB2_HC_PROTOCOL.\r
+  @param  PortNumber              The port to get status.\r
+  @param  PortStatus              A pointer to the current port status bits and  port\r
+                                  status change bits.\r
 \r
-  @return EFI_SUCCESS           : status of the USB root hub port was returned in PortStatus.\r
-  @return EFI_INVALID_PARAMETER : PortNumber is invalid.\r
-  @return EFI_DEVICE_ERROR      : Can't read register\r
+  @return EFI_SUCCESS             status of the USB root hub port was returned in PortStatus.\r
+  @return EFI_INVALID_PARAMETER   PortNumber is invalid.\r
+  @return EFI_DEVICE_ERROR        Can't read register.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2GetRootHubPortStatus (\r
@@ -368,24 +364,24 @@ Uhci2GetRootHubPortStatus (
 \r
   PortSC                        = UhciReadReg (Uhc->PciIo, Offset);\r
 \r
-  if (PortSC & USBPORTSC_CCS) {\r
+  if ((PortSC & USBPORTSC_CCS) != 0) {\r
     PortStatus->PortStatus |= USB_PORT_STAT_CONNECTION;\r
   }\r
 \r
-  if (PortSC & USBPORTSC_PED) {\r
+  if ((PortSC & USBPORTSC_PED) != 0) {\r
     PortStatus->PortStatus |= USB_PORT_STAT_ENABLE;\r
   }\r
 \r
-  if (PortSC & USBPORTSC_SUSP) {\r
+  if ((PortSC & USBPORTSC_SUSP) != 0) {\r
     DEBUG ((EFI_D_INFO, "Uhci2GetRootHubPortStatus: port %d is suspended\n", PortNumber));\r
     PortStatus->PortStatus |= USB_PORT_STAT_SUSPEND;\r
   }\r
 \r
-  if (PortSC & USBPORTSC_PR) {\r
+  if ((PortSC & USBPORTSC_PR) != 0) {\r
     PortStatus->PortStatus |= USB_PORT_STAT_RESET;\r
   }\r
 \r
-  if (PortSC & USBPORTSC_LSDA) {\r
+  if ((PortSC & USBPORTSC_LSDA) != 0) {\r
     PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED;\r
   }\r
 \r
@@ -394,11 +390,11 @@ Uhci2GetRootHubPortStatus (
   //\r
   PortStatus->PortStatus |= USB_PORT_STAT_OWNER;\r
 \r
-  if (PortSC & USBPORTSC_CSC) {\r
+  if ((PortSC & USBPORTSC_CSC) != 0) {\r
     PortStatus->PortChangeStatus |= USB_PORT_STAT_C_CONNECTION;\r
   }\r
 \r
-  if (PortSC & USBPORTSC_PEDC) {\r
+  if ((PortSC & USBPORTSC_PEDC) != 0) {\r
     PortStatus->PortChangeStatus |= USB_PORT_STAT_C_ENABLE;\r
   }\r
 \r
@@ -409,18 +405,17 @@ Uhci2GetRootHubPortStatus (
 /**\r
   Sets a feature for the specified root hub port according to UEFI 2.0 spec.\r
 \r
-  @param  This                 A pointer to the EFI_USB2_HC_PROTOCOL.\r
-  @param  PortNumber           Specifies the root hub port whose feature  is\r
-                               requested to be set.\r
-  @param  PortFeature          Indicates the feature selector associated  with the\r
-                               feature set request.\r
+  @param  This                   A pointer to the EFI_USB2_HC_PROTOCOL.\r
+  @param  PortNumber             Specifies the root hub port whose feature  is\r
+                                 requested to be set.\r
+  @param  PortFeature            Indicates the feature selector associated  with the\r
+                                 feature set request.\r
 \r
-  @return EFI_SUCCESS           : PortFeature was set for the root port\r
-  @return EFI_INVALID_PARAMETER : PortNumber is invalid or PortFeature is invalid.\r
-  @return EFI_DEVICE_ERROR      : Can't read register\r
+  @return EFI_SUCCESS            PortFeature was set for the root port.\r
+  @return EFI_INVALID_PARAMETER  PortNumber is invalid or PortFeature is invalid.\r
+  @return EFI_DEVICE_ERROR       Can't read register.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2SetRootHubPortFeature (\r
@@ -449,7 +444,7 @@ Uhci2SetRootHubPortFeature (
   switch (PortFeature) {\r
   case EfiUsbPortSuspend:\r
     Command = UhciReadReg (Uhc->PciIo, USBCMD_OFFSET);\r
-    if (!(Command & USBCMD_EGSM)) {\r
+    if ((Command & USBCMD_EGSM) == 0) {\r
       //\r
       // if global suspend is not active, can set port suspend\r
       //\r
@@ -489,18 +484,17 @@ Uhci2SetRootHubPortFeature (
 /**\r
   Clears a feature for the specified root hub port according to Uefi 2.0 spec.\r
 \r
-  @param  This                 A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-  @param  PortNumber           Specifies the root hub port whose feature  is\r
-                               requested to be cleared.\r
-  @param  PortFeature          Indicates the feature selector associated with the\r
-                               feature clear request.\r
+  @param  This                   A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  @param  PortNumber             Specifies the root hub port whose feature  is\r
+                                 requested to be cleared.\r
+  @param  PortFeature            Indicates the feature selector associated with the\r
+                                 feature clear request.\r
 \r
-  @return EFI_SUCCESS           : PortFeature was cleared for the USB root hub port\r
-  @return EFI_INVALID_PARAMETER : PortNumber is invalid or PortFeature is invalid.\r
-  @return EFI_DEVICE_ERROR      : Can't read register\r
+  @return EFI_SUCCESS            PortFeature was cleared for the USB root hub port.\r
+  @return EFI_INVALID_PARAMETER  PortNumber is invalid or PortFeature is invalid.\r
+  @return EFI_DEVICE_ERROR       Can't read register.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2ClearRootHubPortFeature (\r
@@ -591,27 +585,27 @@ Uhci2ClearRootHubPortFeature (
 \r
 \r
 /**\r
-  Submits control transfer to a target USB device accroding to UEFI 2.0 spec..\r
-\r
-  This                : A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-  DeviceAddress       : Target device address\r
-  DeviceSpeed         : Device speed\r
-  MaximumPacketLength : Maximum packet size of the target endpoint\r
-  Request             : USB device request to send\r
-  TransferDirection   : Data direction of the Data stage in control transfer\r
-  Data                : Data to transmit/receive in data stage\r
-  DataLength          : Length of the data\r
-  TimeOut             : Maximum time, in microseconds, for transfer to complete.\r
-  TransferResult      : Variable to receive the transfer result\r
-\r
-  @return EFI_SUCCESS           : The control transfer was completed successfully.\r
-  @return EFI_OUT_OF_RESOURCES  : Failed due to lack of resource.\r
-  @return EFI_INVALID_PARAMETER : Some parameters are invalid.\r
-  @return EFI_TIMEOUT           : Failed due to timeout.\r
-  @return EFI_DEVICE_ERROR      : Failed due to host controller or device error.\r
+  Submits control transfer to a target USB device accroding to UEFI 2.0 spec.\r
+\r
+  @param  This                   A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  @param  DeviceAddress          Target device address.\r
+  @param  DeviceSpeed            Device speed.\r
+  @param  MaximumPacketLength    Maximum packet size of the target endpoint.\r
+  @param  Request                USB device request to send.\r
+  @param  TransferDirection      Data direction of the Data stage in control transfer.\r
+  @param  Data                   Data to transmit/receive in data stage.\r
+  @param  DataLength             Length of the data.\r
+  @param  TimeOut                Maximum time, in microseconds, for transfer to complete.\r
+  @param  Translator             Transaction translator to be used by this device.\r
+  @param  TransferResult         Variable to receive the transfer result.\r
+\r
+  @return EFI_SUCCESS            The control transfer was completed successfully.\r
+  @return EFI_OUT_OF_RESOURCES   Failed due to lack of resource.\r
+  @return EFI_INVALID_PARAMETER  Some parameters are invalid.\r
+  @return EFI_TIMEOUT            Failed due to timeout.\r
+  @return EFI_DEVICE_ERROR       Failed due to host controller or device error.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2ControlTransfer (\r
@@ -747,32 +741,30 @@ ON_EXIT:
 }\r
 \r
 \r
-\r
 /**\r
-  Submits bulk transfer to a bulk endpoint of a USB device\r
-\r
-  This                : A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-  DeviceAddress       : Target device address\r
-  EndPointAddress     : Endpoint number and direction\r
-  DeviceSpeed         : Device speed\r
-  MaximumPacketLength : Maximum packet size of the target endpoint\r
-  DataBuffersNumber   : Number of data buffers prepared for the transfer.\r
-  Data                : Array of pointers to the buffers of data\r
-  DataLength          : On input, size of the data buffer, On output,\r
-  actually transferred data size.\r
-  DataToggle          : On input, data toggle to use; On output, next data toggle\r
-  Translator          : A pointr to the transaction translator data.\r
-  TimeOut             : Maximum time out, in microseconds\r
-  TransferResult      : Variable to receive transfer result\r
-\r
-  @return EFI_SUCCESS           : The bulk transfer was completed successfully.\r
-  @return EFI_OUT_OF_RESOURCES  : Failed due to lack of resource.\r
-  @return EFI_INVALID_PARAMETER : Some parameters are invalid.\r
-  @return EFI_TIMEOUT           : Failed due to timeout.\r
-  @return EFI_DEVICE_ERROR      : Failed due to host controller or device error.\r
+  Submits bulk transfer to a bulk endpoint of a USB device.\r
+\r
+  @param  This                   A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  @param  DeviceAddress          Target device address.\r
+  @param  EndPointAddress        Endpoint number and direction.\r
+  @param  DeviceSpeed            Device speed.\r
+  @param  MaximumPacketLength    Maximum packet size of the target endpoint.\r
+  @param  DataBuffersNumber      Number of data buffers prepared for the transfer.\r
+  @param  Data                   Array of pointers to the buffers of data.\r
+  @param  DataLength             On input, size of the data buffer, On output,\r
+                                 actually transferred data size.\r
+  @param  DataToggle             On input, data toggle to use; On output, next data toggle.\r
+  @param  TimeOut                Maximum time out, in microseconds.\r
+  @param  Translator             A pointr to the transaction translator data.\r
+  @param  TransferResult         Variable to receive transfer result.\r
+\r
+  @return EFI_SUCCESS            The bulk transfer was completed successfully.\r
+  @return EFI_OUT_OF_RESOURCES   Failed due to lack of resource.\r
+  @return EFI_INVALID_PARAMETER  Some parameters are invalid.\r
+  @return EFI_TIMEOUT            Failed due to timeout.\r
+  @return EFI_DEVICE_ERROR       Failed due to host controller or device error.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2BulkTransfer (\r
@@ -809,11 +801,7 @@ Uhci2BulkTransfer (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if ((DataLength == NULL) || (Data == NULL) || (TransferResult == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (*DataLength == 0) {\r
+  if ((DataLength == NULL) || (*DataLength == 0) || (Data == NULL) || (TransferResult == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -845,7 +833,7 @@ Uhci2BulkTransfer (
   // Map the source data buffer for bus master access,\r
   // then create a list of TDs\r
   //\r
-  if (EndPointAddress & 0x80) {\r
+  if ((EndPointAddress & 0x80) != 0) {\r
     Direction = EfiUsbDataIn;\r
   } else {\r
     Direction = EfiUsbDataOut;\r
@@ -906,27 +894,26 @@ ON_EXIT:
   Submits an asynchronous interrupt transfer to an\r
   interrupt endpoint of a USB device according to UEFI 2.0 spec.\r
 \r
-  This                : A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-  DeviceAddress       : Target device address\r
-  EndPointAddress     : Endpoint number and direction\r
-  DeviceSpeed         : Device speed\r
-  MaximumPacketLength : Maximum packet size of the target endpoint\r
-  IsNewTransfer       : If TRUE, submit a new transfer, if FALSE cancel old transfer\r
-  DataToggle          : On input, data toggle to use; On output, next data toggle\r
-  PollingInterval     : Interrupt poll rate in milliseconds\r
-  DataLength          : On input, size of the data buffer, On output,\r
-  actually transferred data size.\r
-  Translator          : A pointr to the transaction translator data.\r
-  CallBackFunction    : Function to call periodically\r
-  Context             : User context\r
-\r
-  @return EFI_SUCCESS           : Transfer was submitted\r
-  @return EFI_INVALID_PARAMETER : Some parameters are invalid.\r
-  @return EFI_OUT_OF_RESOURCES  : Failed due to a lack of resources.\r
-  @return EFI_DEVICE_ERROR      : Can't read register\r
+  @param  This                   A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  @param  DeviceAddress          Target device address.\r
+  @param  EndPointAddress        Endpoint number and direction.\r
+  @param  DeviceSpeed            Device speed.\r
+  @param  MaximumPacketLength    Maximum packet size of the target endpoint.\r
+  @param  IsNewTransfer          If TRUE, submit a new transfer, if FALSE cancel old transfer.\r
+  @param  DataToggle             On input, data toggle to use; On output, next data toggle.\r
+  @param  PollingInterval        Interrupt poll rate in milliseconds.\r
+  @param  DataLength             On input, size of the data buffer, On output,\r
+                                 actually transferred data size.\r
+  @param  Translator             A pointr to the transaction translator data.\r
+  @param  CallBackFunction       Function to call periodically.\r
+  @param  Context                User context.\r
+\r
+  @return EFI_SUCCESS            Transfer was submitted.\r
+  @return EFI_INVALID_PARAMETER  Some parameters are invalid.\r
+  @return EFI_OUT_OF_RESOURCES   Failed due to a lack of resources.\r
+  @return EFI_DEVICE_ERROR       Can't read register.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2AsyncInterruptTransfer (\r
@@ -1102,28 +1089,27 @@ FREE_DATA:
   Submits synchronous interrupt transfer to an interrupt endpoint\r
   of a USB device according to UEFI 2.0 spec.\r
 \r
-  This                : A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-  DeviceAddress       : Target device address\r
-  EndPointAddress     : Endpoint number and direction\r
-  DeviceSpeed         : Device speed\r
-  MaximumPacketLength : Maximum packet size of the target endpoint\r
-  DataBuffersNumber   : Number of data buffers prepared for the transfer.\r
-  Data                : Array of pointers to the buffers of data\r
-  DataLength          : On input, size of the data buffer, On output,\r
-  actually transferred data size.\r
-  DataToggle          : On input, data toggle to use; On output, next data toggle\r
-  TimeOut             : Maximum time out, in microseconds\r
-  Translator          : A pointr to the transaction translator data.\r
-  TransferResult      : Variable to receive transfer result\r
-\r
-  @return EFI_SUCCESS           : The transfer was completed successfully.\r
-  @return EFI_OUT_OF_RESOURCES  : Failed due to lack of resource.\r
-  @return EFI_INVALID_PARAMETER : Some parameters are invalid.\r
-  @return EFI_TIMEOUT           : Failed due to timeout.\r
-  @return EFI_DEVICE_ERROR      : Failed due to host controller or device error.\r
+\r
+  @param  This                   A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  @param  DeviceAddress          Target device address.\r
+  @param  EndPointAddress        Endpoint number and direction.\r
+  @param  DeviceSpeed            Device speed.\r
+  @param  MaximumPacketLength    Maximum packet size of the target endpoint.\r
+  @param  Data                   Array of pointers to the buffers of data.\r
+  @param  DataLength             On input, size of the data buffer, On output,\r
+                                 actually transferred data size.\r
+  @param  DataToggle             On input, data toggle to use; On output, next data toggle.\r
+  @param  TimeOut                Maximum time out, in microseconds.\r
+  @param  Translator             A pointr to the transaction translator data.\r
+  @param  TransferResult         Variable to receive transfer result.\r
+\r
+  @return EFI_SUCCESS            The transfer was completed successfully.\r
+  @return EFI_OUT_OF_RESOURCES   Failed due to lack of resource.\r
+  @return EFI_INVALID_PARAMETER  Some parameters are invalid.\r
+  @return EFI_TIMEOUT            Failed due to timeout.\r
+  @return EFI_DEVICE_ERROR       Failed due to host controller or device error.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2SyncInterruptTransfer (\r
@@ -1254,22 +1240,21 @@ ON_EXIT:
 /**\r
   Submits isochronous transfer to a target USB device according to UEFI 2.0 spec.\r
 \r
-  This                : A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-  DeviceAddress       : Target device address\r
-  EndPointAddress     : Endpoint number and direction\r
-  DeviceSpeed         : Device speed\r
-  MaximumPacketLength : Maximum packet size of the target endpoint\r
-  DataBuffersNumber   : Number of data buffers prepared for the transfer.\r
-  Data                : Array of pointers to the buffers of data\r
-  DataLength          : On input, size of the data buffer, On output,\r
-  actually transferred data size.\r
-  Translator          : A pointr to the transaction translator data.\r
-  TransferResult      : Variable to receive transfer result\r
+  @param  This                  A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  @param  DeviceAddress         Target device address.\r
+  @param  EndPointAddress       Endpoint number and direction.\r
+  @param  DeviceSpeed           Device speed.\r
+  @param  MaximumPacketLength   Maximum packet size of the target endpoint.\r
+  @param  DataBuffersNumber     Number of data buffers prepared for the transfer.\r
+  @param  Data                  Array of pointers to the buffers of data.\r
+  @param  DataLength            On input, size of the data buffer, On output,\r
+                                actually transferred data size.\r
+  @param  Translator            A pointr to the transaction translator data.\r
+  @param  TransferResult        Variable to receive transfer result.\r
 \r
   @return EFI_UNSUPPORTED\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2IsochronousTransfer (\r
@@ -1292,21 +1277,22 @@ Uhci2IsochronousTransfer (
 /**\r
   Submits Async isochronous transfer to a target USB device according to UEFI 2.0 spec.\r
 \r
-  This                : A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-  DeviceAddress       : Target device address\r
-  EndPointAddress     : Endpoint number and direction\r
-  DeviceSpeed         : Device speed\r
-  MaximumPacketLength : Maximum packet size of the target endpoint\r
-  DataBuffersNumber   : Number of data buffers prepared for the transfer.\r
-  Data                : Array of pointers to the buffers of data\r
-  Translator          : A pointr to the transaction translator data.\r
-  IsochronousCallBack : Function to call when the transfer complete\r
-  Context             : Pass to the call back function as parameter\r
+  @param  This                  A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  @param  DeviceAddress         Target device address.\r
+  @param  EndPointAddress       Endpoint number and direction.\r
+  @param  DeviceSpeed           Device speed.\r
+  @param  MaximumPacketLength   Maximum packet size of the target endpoint.\r
+  @param  DataBuffersNumber     Number of data buffers prepared for the transfer.\r
+  @param  Data                  Array of pointers to the buffers of data.\r
+  @param  DataLength            On input, size of the data buffer, On output,\r
+                                actually transferred data size.\r
+  @param  Translator            A pointr to the transaction translator data.\r
+  @param  IsochronousCallBack   Function to call when the transfer complete.\r
+  @param  Context               Pass to the call back function as parameter.\r
 \r
   @return EFI_UNSUPPORTED\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 Uhci2AsyncIsochronousTransfer (\r
@@ -1326,29 +1312,22 @@ Uhci2AsyncIsochronousTransfer (
   return EFI_UNSUPPORTED;\r
 }\r
 \r
+/**\r
+  Entry point for EFI drivers.\r
+\r
+  @param  ImageHandle      EFI_HANDLE.\r
+  @param  SystemTable      EFI_SYSTEM_TABLE.\r
+\r
+  @retval EFI_SUCCESS      Driver is successfully loaded.\r
+  @return Others           Failed.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 UhciDriverEntryPoint (\r
   IN EFI_HANDLE           ImageHandle,\r
   IN EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Entry point for EFI drivers.\r
-\r
-  Arguments:\r
-\r
-    ImageHandle - EFI_HANDLE\r
-    SystemTable - EFI_SYSTEM_TABLE\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS : Driver is successfully loaded\r
-    Others      : Failed\r
-\r
---*/\r
 {\r
   return EfiLibInstallDriverBindingComponentName2 (\r
            ImageHandle,\r
@@ -1366,11 +1345,11 @@ UhciDriverEntryPoint (
   ControllerHandle that has UsbHcProtocol installed will be supported.\r
 \r
   @param  This                 Protocol instance pointer.\r
-  @param  Controller           Handle of device to test\r
-  @param  RemainingDevicePath  Not used\r
+  @param  Controller           Handle of device to test.\r
+  @param  RemainingDevicePath  Not used.\r
 \r
-  @return EFI_SUCCESS         : This driver supports this device.\r
-  @return EFI_UNSUPPORTED     : This driver does not support this device.\r
+  @return EFI_SUCCESS          This driver supports this device.\r
+  @return EFI_UNSUPPORTED      This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1440,14 +1419,14 @@ ON_EXIT:
 \r
 \r
 /**\r
-  Allocate and initialize the empty UHCI device\r
+  Allocate and initialize the empty UHCI device.\r
 \r
-  @param  PciIo                The PCIIO to use\r
+  @param  PciIo                  The PCIIO to use.\r
+  @param  OriginalPciAttributes  The original PCI attributes.\r
 \r
-  @return Allocated UHCI device\r
+  @return Allocated UHCI device. If err, return NULL.\r
 \r
 **/\r
-STATIC\r
 USB_HC_DEV *\r
 UhciAllocateDev (\r
   IN EFI_PCI_IO_PROTOCOL    *PciIo,\r
@@ -1517,14 +1496,13 @@ ON_ERROR:
 \r
 \r
 /**\r
-  Free the UHCI device and release its associated resources\r
+  Free the UHCI device and release its associated resources.\r
 \r
-  @param  Uhc                  The UHCI device to release\r
+  @param  Uhc     The UHCI device to release.\r
 \r
-  @return None\r
+  @return None.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 UhciFreeDev (\r
   IN USB_HC_DEV           *Uhc\r
@@ -1538,7 +1516,7 @@ UhciFreeDev (
     UsbHcFreeMemPool (Uhc->MemPool);\r
   }\r
 \r
-  if (Uhc->CtrlNameTable) {\r
+  if (Uhc->CtrlNameTable != NULL) {\r
     FreeUnicodeStringTable (Uhc->CtrlNameTable);\r
   }\r
 \r
@@ -1547,15 +1525,14 @@ UhciFreeDev (
 \r
 \r
 /**\r
-  Uninstall all Uhci Interface\r
+  Uninstall all Uhci Interface.\r
 \r
-  @param  Controller           Controller handle\r
+  @param  Controller           Controller handle.\r
   @param  This                 Protocol instance pointer.\r
 \r
-  @return VOID\r
+  @return None.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 UhciCleanDevUp (\r
   IN  EFI_HANDLE           Controller,\r
@@ -1594,17 +1571,16 @@ UhciCleanDevUp (
 \r
 \r
 /**\r
-  Starting the Usb UHCI Driver\r
+  Starting the Usb UHCI Driver.\r
 \r
   @param  This                 Protocol instance pointer.\r
-  @param  Controller           Handle of device to test\r
-  @param  RemainingDevicePath  Not used\r
+  @param  Controller           Handle of device to test.\r
+  @param  RemainingDevicePath  Not used.\r
 \r
   @retval EFI_SUCCESS          This driver supports this device.\r
   @retval EFI_UNSUPPORTED      This driver does not support this device.\r
-  @retval EFI_DEVICE_ERROR     This driver cannot be started due to device Error\r
-                               EFI_OUT_OF_RESOURCES- Failed due to resource\r
-                               shortage\r
+  @retval EFI_DEVICE_ERROR     This driver cannot be started due to device Error.\r
+                               EFI_OUT_OF_RESOURCES- Failed due to resource shortage.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1784,8 +1760,8 @@ CLOSE_PCIIO:
   created by this driver.\r
 \r
   @param  This                 Protocol instance pointer.\r
-  @param  Controller           Handle of device to stop driver on\r
-  @param  NumberOfChildren     Number of Children in the ChildHandleBuffer\r
+  @param  Controller           Handle of device to stop driver on.\r
+  @param  NumberOfChildren     Number of Children in the ChildHandleBuffer.\r
   @param  ChildHandleBuffer    List of handles for the children we need to stop.\r
 \r
   @return EFI_SUCCESS\r
@@ -1834,11 +1810,3 @@ UhciDriverBindingStop (
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_DRIVER_BINDING_PROTOCOL gUhciDriverBinding = {\r
-  UhciDriverBindingSupported,\r
-  UhciDriverBindingStart,\r
-  UhciDriverBindingStop,\r
-  0x20,\r
-  NULL,\r
-  NULL\r
-};\r