]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Add NULL QH to set as QH header;
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Jan 2007 04:08:57 +0000 (04:08 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Jan 2007 04:08:57 +0000 (04:08 +0000)
2. Do ping for high speed OUT pipe;
3. Bug fix for QTD size detection;
4. Bug fix for short package detection;
5. Bug fix get next QTD in ExcutionTransfer;
6. BOT module modify to follow spec;
7. Massstorage error hanling enhancement

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2321 6f19259b-4bc3-4df7-8a09-765794883524

16 files changed:
EdkModulePkg/Bus/Pci/Ehci/Dxe/Debug.c
EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.c
EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.h
EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciMem.c
EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciReg.c
EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciSched.c
EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.c
EdkModulePkg/Bus/Usb/UsbBot/Dxe/ComponentName.c
EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.c
EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.h
EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/ComponentName.c
EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.c
EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.h
EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageData.h
EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.c
EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.h

index d9942129ca935a3b116c20f350f13c7ab73162fd..a700d8f2cf89da1172a34d61653aa21b684decea 100644 (file)
@@ -22,7 +22,8 @@ Revision History
 \r
 #include "Ehci.h"\r
 \r
-void \r
+\r
+VOID\r
 DumpEHCIPortsStatus (\r
   IN USB2_HC_DEV    *HcDev\r
   )\r
@@ -47,6 +48,8 @@ DumpEHCIPortsStatus (
       );\r
      DEBUG((gEHCDebugLevel, "Port[%d] = 0x%x\n", Index, Value));\r
   }\r
+\r
+\r
 }\r
 \r
 \r
index baea1f608db09d21c8a86468c682e0c935fb932a..e6a4f6130b15162353b42c81098cbef253df952c 100644 (file)
@@ -1,20 +1,20 @@
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
     Ehci.c\r
-    \r
-Abstract: \r
-    \r
+\r
+Abstract:\r
+\r
 \r
 Revision History\r
 --*/\r
@@ -23,7 +23,7 @@ Revision History
 #include "Ehci.h"\r
 \r
 \r
-GLOBAL_REMOVE_IF_UNREFERENCED UINTN    gEHCDebugLevel  = EFI_D_INFO;\r
+GLOBAL_REMOVE_IF_UNREFERENCED UINTN    gEHCDebugLevel  = EFI_D_ERROR;\r
 GLOBAL_REMOVE_IF_UNREFERENCED UINTN    gEHCErrorLevel  = EFI_D_ERROR;\r
 \r
 \r
@@ -234,18 +234,18 @@ EhciDriverBindingSupported (
 /*++\r
 \r
   Routine Description:\r
-  \r
+\r
     Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
     that has Usb2HcProtocol installed will be supported.\r
 \r
   Arguments:\r
-  \r
+\r
     This                - Protocol instance pointer.\r
     Controlle           - Handle of device to test\r
     RemainingDevicePath - Not used\r
 \r
   Returns:\r
-  \r
+\r
     EFI_SUCCESS       This driver supports this device.\r
     EFI_UNSUPPORTED   This driver does not support this device.\r
 \r
@@ -255,7 +255,7 @@ EhciDriverBindingSupported (
   EFI_PCI_IO_PROTOCOL *PciIo;\r
   USB_CLASSC          UsbClassCReg;\r
 \r
-  \r
+\r
   //\r
   // Test whether there is PCI IO Protocol attached on the controller handle.\r
   //\r
@@ -288,7 +288,7 @@ EhciDriverBindingSupported (
     Status = EFI_UNSUPPORTED;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Test whether the controller belongs to Ehci type\r
   //\r
@@ -329,17 +329,17 @@ EhciDriverBindingStart (
 /*++\r
 \r
   Routine Description:\r
-  \r
+\r
     Starting the Usb EHCI Driver\r
 \r
   Arguments:\r
-  \r
+\r
     This                - Protocol instance pointer.\r
     Controller          - Handle of device to test\r
     RemainingDevicePath - Not used\r
 \r
   Returns:\r
-  \r
+\r
     EFI_SUCCESS           supports this device.\r
     EFI_UNSUPPORTED       do not support this device.\r
     EFI_DEVICE_ERROR      cannot be started due to device Error\r
@@ -353,7 +353,8 @@ EhciDriverBindingStart (
   UINT8                 MaxSpeed;\r
   UINT8                 PortNumber;\r
   UINT8                 Is64BitCapable;\r
-  \r
+  UINT64                Supports;\r
+\r
   //\r
   // Open the PciIo Protocol\r
   //\r
@@ -369,21 +370,30 @@ EhciDriverBindingStart (
     Status = EFI_OUT_OF_RESOURCES;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Enable the USB Host Controller\r
   //\r
   Status = PciIo->Attributes (\r
                     PciIo,\r
-                    EfiPciIoAttributeOperationEnable,\r
-                    EFI_PCI_DEVICE_ENABLE,\r
-                    NULL\r
+                    EfiPciIoAttributeOperationSupported,\r
+                    0,\r
+                    &Supports\r
                     );\r
+  if (!EFI_ERROR (Status)) {\r
+    Supports &= EFI_PCI_DEVICE_ENABLE;\r
+    Status = PciIo->Attributes (\r
+                      PciIo,\r
+                      EfiPciIoAttributeOperationEnable,\r
+                      Supports,\r
+                      NULL\r
+                      );\r
+  }\r
   if (EFI_ERROR (Status)) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto close_pciio_protocol;\r
   }\r
-  \r
+\r
   //\r
   // Allocate memory for EHC private data structure\r
   //\r
@@ -392,7 +402,7 @@ EhciDriverBindingStart (
     Status = EFI_OUT_OF_RESOURCES;\r
     goto close_pciio_protocol;\r
   }\r
-  \r
+\r
   //\r
   // Init EFI_USB2_HC_PROTOCOL interface and private data structure\r
   //\r
@@ -430,7 +440,7 @@ EhciDriverBindingStart (
     Status = EFI_OUT_OF_RESOURCES;\r
     goto free_pool;\r
   }\r
-  \r
+\r
   //\r
   // Get Capability Register Length\r
   //\r
@@ -446,14 +456,14 @@ EhciDriverBindingStart (
   DEBUG_CODE (\r
    DumpEHCIPortsStatus (HcDev);\r
   );\r
-  \r
+\r
   //\r
   // Create and Init Perodic Frame List\r
   //\r
   Status = EhciGetCapability (\r
-             &HcDev->Usb2Hc, \r
-             &MaxSpeed, \r
-             &PortNumber, \r
+             &HcDev->Usb2Hc,\r
+             &MaxSpeed,\r
+             &PortNumber,\r
              &Is64BitCapable\r
              );\r
   if (EFI_ERROR (Status)) {\r
@@ -461,19 +471,19 @@ EhciDriverBindingStart (
     goto uninstall_usb2hc_protocol;\r
   }\r
   HcDev->Is64BitCapable = Is64BitCapable;\r
-  \r
+\r
   //\r
   // Create and Init Perodic Frame List\r
   //\r
   Status = InitialPeriodicFrameList (\r
-             HcDev, \r
+             HcDev,\r
              EHCI_MAX_FRAME_LIST_LENGTH\r
              );\r
   if (EFI_ERROR (Status)) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto uninstall_usb2hc_protocol;\r
   }\r
-  \r
+\r
   //\r
   // Init memory pool management\r
   //\r
@@ -482,21 +492,26 @@ EhciDriverBindingStart (
     Status = EFI_OUT_OF_RESOURCES;\r
     goto deinit_perodic_frame_list;\r
   }\r
-  \r
+\r
+  Status = CreateNULLQH (HcDev);\r
+  if (EFI_ERROR (Status)) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto deinit_perodic_frame_list;\r
+  }\r
   //\r
   // Create AsyncRequest Polling Timer\r
   //\r
   Status = CreatePollingTimer (HcDev, (EFI_EVENT_NOTIFY) AsyncRequestMoniter);\r
   if (EFI_ERROR (Status)) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
-    goto deinit_memory_management;\r
+    goto deinit_null_qh;\r
   }\r
-  \r
+\r
   //\r
-  // Default Maxximum Interrupt Interval is 8, \r
+  // Default Maxximum Interrupt Interval is 8,\r
   // it means that 8 micro frame = 1ms\r
   //\r
-  \r
+\r
   //\r
   // Start the Host Controller\r
   //\r
@@ -507,7 +522,7 @@ EhciDriverBindingStart (
       goto deinit_timer;\r
     }\r
   }\r
-  \r
+\r
   //\r
   // Set all ports routing to EHC\r
   //\r
@@ -516,7 +531,7 @@ EhciDriverBindingStart (
     Status = EFI_DEVICE_ERROR;\r
     goto deinit_timer;\r
   }\r
-  \r
+\r
   //\r
   // Component name protocol\r
   //\r
@@ -538,7 +553,8 @@ EhciDriverBindingStart (
   //\r
 deinit_timer:\r
   DestoryPollingTimer (HcDev);\r
-deinit_memory_management:\r
+deinit_null_qh:\r
+  DestroyNULLQH(HcDev);\r
   DeinitialMemoryManagement (HcDev);\r
 deinit_perodic_frame_list:\r
   DeinitialPeriodicFrameList (HcDev);\r
@@ -573,19 +589,19 @@ EhciDriverBindingStop (
 /*++\r
 \r
   Routine Description:\r
-  \r
+\r
     Stop this driver on ControllerHandle. Support stoping any child handles\r
     created by this driver.\r
 \r
   Arguments:\r
-  \r
+\r
     This              - Protocol instance pointer.\r
     Controller        - Handle of device to stop driver on\r
     NumberOfChildren  - Number of Children in the ChildHandleBuffer\r
     ChildHandleBuffer - List of handles for the children we need to stop.\r
 \r
   Returns:\r
-  \r
+\r
     EFI_SUCCESS         Success\r
     EFI_DEVICE_ERROR    Fail\r
 --*/\r
@@ -593,6 +609,7 @@ EhciDriverBindingStop (
   EFI_STATUS            Status;\r
   EFI_USB2_HC_PROTOCOL  *Usb2Hc;\r
   USB2_HC_DEV           *HcDev;\r
+  UINT64                Supports;\r
 \r
   //\r
   // Test whether the Controller handler passed in is a valid\r
@@ -626,19 +643,19 @@ EhciDriverBindingStop (
     Status = EFI_DEVICE_ERROR;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Set Host Controller state as halt\r
   //\r
   Status = Usb2Hc->SetState (\r
-                     Usb2Hc, \r
+                     Usb2Hc,\r
                      EfiUsbHcStateHalt\r
                      );\r
   if (EFI_ERROR (Status)) {\r
     Status = EFI_DEVICE_ERROR;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Stop AsyncRequest Polling Timer\r
   //\r
@@ -647,7 +664,7 @@ EhciDriverBindingStop (
     Status = EFI_DEVICE_ERROR;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Destroy Asynchronous Request Event\r
   //\r
@@ -658,6 +675,11 @@ EhciDriverBindingStop (
   //\r
   DeinitialPeriodicFrameList (HcDev);\r
 \r
+  //\r
+  // Destroy NULLQH\r
+  //\r
+  DestroyNULLQH (HcDev);\r
+\r
   //\r
   // Deinit Ehci pool memory management\r
   //\r
@@ -673,10 +695,19 @@ EhciDriverBindingStop (
   //\r
   Status = HcDev->PciIo->Attributes (\r
                            HcDev->PciIo,\r
-                           EfiPciIoAttributeOperationDisable,\r
-                           EFI_PCI_DEVICE_ENABLE,\r
-                           NULL\r
+                           EfiPciIoAttributeOperationSupported,\r
+                           0,\r
+                           &Supports\r
                            );\r
+  if (!EFI_ERROR (Status)) {\r
+    Supports &= EFI_PCI_DEVICE_ENABLE;\r
+    Status = HcDev->PciIo->Attributes (\r
+                             HcDev->PciIo,\r
+                             EfiPciIoAttributeOperationDisable,\r
+                             Supports,\r
+                             NULL\r
+                             );\r
+  }\r
   if (EFI_ERROR (Status)) {\r
     Status = EFI_DEVICE_ERROR;\r
     goto exit;\r
@@ -704,25 +735,25 @@ EhciGetCapability (
   OUT UINT8                *Is64BitCapable\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
+\r
     Retrieves the capablility of root hub ports.\r
-    \r
+\r
   Arguments:\r
-  \r
+\r
     This            - A pointer to the EFI_USB_HC_PROTOCOL instance.\r
     MaxSpeed        - A pointer to the number of the host controller.\r
     PortNumber      - A pointer to the number of the root hub ports.\r
-    Is64BitCapable  - A pointer to the flag for whether controller supports \r
+    Is64BitCapable  - A pointer to the flag for whether controller supports\r
                       64-bit memory addressing.\r
-    \r
+\r
   Returns:\r
-  \r
+\r
     EFI_SUCCESS            host controller capability were retrieved successfully.\r
     EFI_INVALID_PARAMETER  MaxSpeed or PortNumber or Is64BitCapable is NULL.\r
-    EFI_DEVICE_ERROR       An error was encountered while attempting to retrieve the capabilities.  \r
-          \r
+    EFI_DEVICE_ERROR       An error was encountered while attempting to retrieve the capabilities.\r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -776,58 +807,58 @@ EhciReset (
   IN UINT16               Attributes\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
+\r
     Provides software reset for the USB host controller.\r
-  \r
+\r
   Arguments:\r
-  \r
-  This        - A pointer to the EFI_USB2_HC_PROTOCOL instance.  \r
-  Attributes  - A bit mask of the reset operation to perform. \r
+\r
+  This        - A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+  Attributes  - A bit mask of the reset operation to perform.\r
                 See below for a list of the supported bit mask values.\r
-  \r
+\r
   #define EFI_USB_HC_RESET_GLOBAL  0x0001\r
   #define EFI_USB_HC_RESET_HOST_CONTROLLER  0x0002\r
   #define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG  0x0004\r
   #define EFI_USB_HC_RESET_HOST_WITH_DEBUG  0x0008\r
 \r
-  EFI_USB_HC_RESET_GLOBAL \r
+  EFI_USB_HC_RESET_GLOBAL\r
         If this bit is set, a global reset signal will be sent to the USB bus.\r
-        This resets all of the USB bus logic, including the USB host \r
+        This resets all of the USB bus logic, including the USB host\r
         controller hardware and all the devices attached on the USB bus.\r
-  EFI_USB_HC_RESET_HOST_CONTROLLER  \r
-        If this bit is set, the USB host controller hardware will be reset. \r
+  EFI_USB_HC_RESET_HOST_CONTROLLER\r
+        If this bit is set, the USB host controller hardware will be reset.\r
         No reset signal will be sent to the USB bus.\r
   EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG\r
         If this bit is set, a global reset signal will be sent to the USB bus.\r
-        This resets all of the USB bus logic, including the USB host \r
-        controller hardware and all the devices attached on the USB bus. \r
-        If this is an EHCI controller and the debug port has configured, then \r
+        This resets all of the USB bus logic, including the USB host\r
+        controller hardware and all the devices attached on the USB bus.\r
+        If this is an EHCI controller and the debug port has configured, then\r
         this is will still reset the host controller.\r
   EFI_USB_HC_RESET_HOST_WITH_DEBUG\r
-        If this bit is set, the USB host controller hardware will be reset. \r
+        If this bit is set, the USB host controller hardware will be reset.\r
         If this is an EHCI controller and the debug port has been configured,\r
         then this will still reset the host controller.\r
-        \r
+\r
   Returns:\r
-  \r
-    EFI_SUCCESS \r
+\r
+    EFI_SUCCESS\r
         The reset operation succeeded.\r
-    EFI_INVALID_PARAMETER \r
+    EFI_INVALID_PARAMETER\r
         Attributes is not valid.\r
     EFI_UNSUPPOURTED\r
         The type of reset specified by Attributes is not currently supported by\r
         the host controller hardware.\r
     EFI_ACCESS_DENIED\r
-        Reset operation is rejected due to the debug port being configured and \r
-        active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or \r
+        Reset operation is rejected due to the debug port being configured and\r
+        active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or\r
         EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Atrributes can be used to\r
         perform reset operation for this host controller.\r
-    EFI_DEVICE_ERROR  \r
-        An error was encountered while attempting to perform \r
+    EFI_DEVICE_ERROR\r
+        An error was encountered while attempting to perform\r
         the reset operation.\r
-        \r
+\r
 --*/\r
 {\r
   EFI_STATUS        Status;\r
@@ -840,7 +871,7 @@ EhciReset (
   switch (Attributes) {\r
 \r
   case EFI_USB_HC_RESET_GLOBAL:\r
-    \r
+\r
     //\r
     // Same behavior as Host Controller Reset\r
     //\r
@@ -892,7 +923,7 @@ EhciReset (
     // Init Perodic List Base Addr and Frame List\r
     //\r
     Status = SetFrameListBaseAddr (\r
-               HcDev, \r
+               HcDev,\r
                (UINT32)GET_0B_TO_31B (HcDev->PeriodicFrameListBuffer)\r
                );\r
     if (EFI_ERROR (Status)) {\r
@@ -951,34 +982,34 @@ EhciGetState (
   OUT EFI_USB_HC_STATE     *State\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
+\r
     Retrieves current state of the USB host controller.\r
-  \r
+\r
   Arguments:\r
-    \r
+\r
     This      A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-    State     A pointer to the EFI_USB_HC_STATE data structure that \r
-              indicates current state of the USB host controller.  \r
+    State     A pointer to the EFI_USB_HC_STATE data structure that\r
+              indicates current state of the USB host controller.\r
               Type EFI_USB_HC_STATE is defined below.\r
-              \r
+\r
     typedef enum {\r
       EfiUsbHcStateHalt,\r
       EfiUsbHcStateOperational,\r
       EfiUsbHcStateSuspend,\r
       EfiUsbHcStateMaximum\r
     } EFI_USB_HC_STATE;\r
-  \r
+\r
   Returns:\r
-  \r
-    EFI_SUCCESS \r
+\r
+    EFI_SUCCESS\r
             The state information of the host controller was returned in State.\r
-    EFI_INVALID_PARAMETER \r
+    EFI_INVALID_PARAMETER\r
             State is NULL.\r
-    EFI_DEVICE_ERROR  \r
-            An error was encountered while attempting to retrieve the \r
-            host controller's current state.  \r
+    EFI_DEVICE_ERROR\r
+            An error was encountered while attempting to retrieve the\r
+            host controller's current state.\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1021,26 +1052,26 @@ EhciSetState (
   IN EFI_USB_HC_STATE     State\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
+\r
     Sets the USB host controller to a specific state.\r
-  \r
+\r
   Arguments:\r
-    \r
+\r
     This     - A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
     State    - Indicates the state of the host controller that will be set.\r
-  \r
+\r
   Returns:\r
-  \r
-    EFI_SUCCESS \r
-          The USB host controller was successfully placed in the state \r
+\r
+    EFI_SUCCESS\r
+          The USB host controller was successfully placed in the state\r
           specified by State.\r
-    EFI_INVALID_PARAMETER \r
+    EFI_INVALID_PARAMETER\r
           State is invalid.\r
-    EFI_DEVICE_ERROR  \r
-          Failed to set the state specified by State due to device error.  \r
-          \r
+    EFI_DEVICE_ERROR\r
+          Failed to set the state specified by State due to device error.\r
+\r
 --*/\r
 {\r
   EFI_STATUS        Status;\r
@@ -1154,28 +1185,28 @@ EhciGetRootHubPortStatus (
   OUT EFI_USB_PORT_STATUS  *PortStatus\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
+\r
     Retrieves the current status of a USB root hub port.\r
-  \r
+\r
   Arguments:\r
-  \r
+\r
     This        - A pointer to the EFI_USB2_HC_PROTOCOL.\r
-    PortNumber  - Specifies the root hub port from which the status \r
-                  is to be retrieved.  This value is zero-based. For example, \r
+    PortNumber  - Specifies the root hub port from which the status\r
+                  is to be retrieved.  This value is zero-based. For example,\r
                   if a root hub has two ports, then the first port is numbered 0,\r
                   and the second port is numbered 1.\r
-    PortStatus  - A pointer to the current port status bits and \r
-                  port status change bits.  \r
-  \r
+    PortStatus  - A pointer to the current port status bits and\r
+                  port status change bits.\r
+\r
   Returns:\r
-  \r
-    EFI_SUCCESS           The status of the USB root hub port specified \r
+\r
+    EFI_SUCCESS           The status of the USB root hub port specified\r
                           by PortNumber was returned in PortStatus.\r
-    EFI_INVALID_PARAMETER PortNumber is invalid. \r
-    EFI_DEVICE_ERROR      Can't read register     \r
-    \r
+    EFI_INVALID_PARAMETER PortNumber is invalid.\r
+    EFI_DEVICE_ERROR      Can't read register\r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1192,12 +1223,12 @@ EhciGetRootHubPortStatus (
   }\r
 \r
   EhciGetCapability (\r
-    This, \r
-    &MaxSpeed, \r
-    &TotalPortNumber, \r
+    This,\r
+    &MaxSpeed,\r
+    &TotalPortNumber,\r
     &Is64BitCapable\r
     );\r
-  \r
+\r
   if (PortNumber >= TotalPortNumber) {\r
     Status = EFI_INVALID_PARAMETER;\r
     goto exit;\r
@@ -1221,11 +1252,11 @@ EhciGetRootHubPortStatus (
     Status = EFI_DEVICE_ERROR;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   //    Fill Port Status bits\r
   //\r
-  \r
+\r
   //\r
   // Current Connect Status\r
   //\r
@@ -1319,29 +1350,29 @@ EhciSetRootHubPortFeature (
   IN  EFI_USB_PORT_FEATURE     PortFeature\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
+\r
     Sets a feature for the specified root hub port.\r
-  \r
+\r
   Arguments:\r
-  \r
+\r
     This        - A pointer to the EFI_USB2_HC_PROTOCOL.\r
-    PortNumber  - Specifies the root hub port whose feature \r
+    PortNumber  - Specifies the root hub port whose feature\r
                   is requested to be set.\r
-    PortFeature - Indicates the feature selector associated \r
-                  with the feature set request. \r
-  \r
+    PortFeature - Indicates the feature selector associated\r
+                  with the feature set request.\r
+\r
   Returns:\r
-  \r
-    EFI_SUCCESS \r
-        The feature specified by PortFeature was set for the \r
+\r
+    EFI_SUCCESS\r
+        The feature specified by PortFeature was set for the\r
         USB root hub port specified by PortNumber.\r
-    EFI_INVALID_PARAMETER \r
+    EFI_INVALID_PARAMETER\r
         PortNumber is invalid or PortFeature is invalid.\r
     EFI_DEVICE_ERROR\r
         Can't read register\r
-        \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1353,9 +1384,9 @@ EhciSetRootHubPortFeature (
   UINT8       Is64BitCapable;\r
 \r
   EhciGetCapability (\r
-    This, \r
-    &MaxSpeed, \r
-    &TotalPortNumber, \r
+    This,\r
+    &MaxSpeed,\r
+    &TotalPortNumber,\r
     &Is64BitCapable\r
     );\r
 \r
@@ -1380,7 +1411,7 @@ EhciSetRootHubPortFeature (
   switch (PortFeature) {\r
 \r
   case EfiUsbPortEnable:\r
-  \r
+\r
     //\r
     // Sofeware can't set this bit, Port can only be enable by the Host Controller\r
     // as a part of the reset and enable\r
@@ -1390,13 +1421,13 @@ EhciSetRootHubPortFeature (
     break;\r
 \r
   case EfiUsbPortSuspend:\r
-  \r
+\r
     PortStatusControlReg &= 0xffffffd5;\r
     PortStatusControlReg |= PORTSC_SUSP;\r
     break;\r
 \r
   case EfiUsbPortReset:\r
-  \r
+\r
     //\r
     // Make sure Host Controller not halt before reset it\r
     //\r
@@ -1422,14 +1453,14 @@ EhciSetRootHubPortFeature (
     break;\r
 \r
   case EfiUsbPortPower:\r
-    \r
+\r
     //\r
     // No support, no operation\r
     //\r
     goto exit;\r
 \r
   case EfiUsbPortOwner:\r
-  \r
+\r
     PortStatusControlReg &= 0xffffffd5;\r
     PortStatusControlReg |= PORTSC_PO;\r
     break;\r
@@ -1461,29 +1492,29 @@ EhciClearRootHubPortFeature (
   IN  EFI_USB_PORT_FEATURE     PortFeature\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
+\r
     Clears a feature for the specified root hub port.\r
-  \r
+\r
   Arguments:\r
-  \r
-    This        - A pointer to the EFI_USB2_HC_PROTOCOL instance. \r
-    PortNumber  - Specifies the root hub port whose feature \r
+\r
+    This        - A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+    PortNumber  - Specifies the root hub port whose feature\r
                   is requested to be cleared.\r
-    PortFeature - Indicates the feature selector associated with the \r
+    PortFeature - Indicates the feature selector associated with the\r
                   feature clear request.\r
-                  \r
+\r
   Returns:\r
-  \r
-    EFI_SUCCESS \r
-        The feature specified by PortFeature was cleared for the \r
+\r
+    EFI_SUCCESS\r
+        The feature specified by PortFeature was cleared for the\r
         USB root hub port specified by PortNumber.\r
-    EFI_INVALID_PARAMETER \r
+    EFI_INVALID_PARAMETER\r
         PortNumber is invalid or PortFeature is invalid.\r
     EFI_DEVICE_ERROR\r
         Can't read register\r
-        \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1495,9 +1526,9 @@ EhciClearRootHubPortFeature (
   UINT8       Is64BitCapable;\r
 \r
   EhciGetCapability (\r
-    This, \r
-    &MaxSpeed, \r
-    &TotalPortNumber, \r
+    This,\r
+    &MaxSpeed,\r
+    &TotalPortNumber,\r
     &Is64BitCapable\r
     );\r
 \r
@@ -1522,7 +1553,7 @@ EhciClearRootHubPortFeature (
   switch (PortFeature) {\r
 \r
   case EfiUsbPortEnable:\r
-  \r
+\r
     //\r
     // Clear PORT_ENABLE feature means disable port.\r
     //\r
@@ -1531,7 +1562,7 @@ EhciClearRootHubPortFeature (
     break;\r
 \r
   case EfiUsbPortSuspend:\r
-  \r
+\r
     //\r
     // A write of zero to this bit is ignored by the host controller.\r
     // The host controller will unconditionally set this bit to a zero when:\r
@@ -1543,7 +1574,7 @@ EhciClearRootHubPortFeature (
     break;\r
 \r
   case EfiUsbPortReset:\r
-  \r
+\r
     //\r
     // Clear PORT_RESET means clear the reset signal.\r
     //\r
@@ -1552,14 +1583,14 @@ EhciClearRootHubPortFeature (
     break;\r
 \r
   case EfiUsbPortPower:\r
-  \r
+\r
     //\r
     // No support, no operation\r
     //\r
     goto exit;\r
 \r
   case EfiUsbPortOwner:\r
-  \r
+\r
     //\r
     // Clear port owner means this port owned by EHC\r
     //\r
@@ -1568,7 +1599,7 @@ EhciClearRootHubPortFeature (
     break;\r
 \r
   case EfiUsbPortConnectChange:\r
-  \r
+\r
     //\r
     // Clear connect status change\r
     //\r
@@ -1577,7 +1608,7 @@ EhciClearRootHubPortFeature (
     break;\r
 \r
   case EfiUsbPortEnableChange:\r
-  \r
+\r
     //\r
     // Clear enable status change\r
     //\r
@@ -1586,14 +1617,14 @@ EhciClearRootHubPortFeature (
     break;\r
 \r
   case EfiUsbPortSuspendChange:\r
-  \r
+\r
     //\r
     // No related bit, no operation\r
     //\r
     goto exit;\r
 \r
   case EfiUsbPortOverCurrentChange:\r
-  \r
+\r
     //\r
     // Clear PortOverCurrent change\r
     //\r
@@ -1602,7 +1633,7 @@ EhciClearRootHubPortFeature (
     break;\r
 \r
   case EfiUsbPortResetChange:\r
-  \r
+\r
     //\r
     // No related bit, no operation\r
     //\r
@@ -1644,47 +1675,47 @@ EhciControlTransfer (
   OUT UINT32                               *TransferResult\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
+\r
     Submits control transfer to a target USB device.\r
-  \r
+\r
   Arguments:\r
-    \r
+\r
     This            - A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
     DeviceAddress   - Represents the address of the target device on the USB,\r
                       which is assigned during USB enumeration.\r
     DeviceSpeed     - Indicates target device speed.\r
-    MaximumPacketLength - Indicates the maximum packet size that the \r
-                         default control transfer endpoint is capable of \r
+    MaximumPacketLength - Indicates the maximum packet size that the\r
+                         default control transfer endpoint is capable of\r
                          sending or receiving.\r
-    Request         - A pointer to the USB device request that will be sent \r
-                      to the USB device. \r
+    Request         - A pointer to the USB device request that will be sent\r
+                      to the USB device.\r
     TransferDirection - Specifies the data direction for the transfer.\r
-                        There are three values available, DataIn, DataOut \r
+                        There are three values available, DataIn, DataOut\r
                         and NoData.\r
-    Data            - A pointer to the buffer of data that will be transmitted \r
+    Data            - A pointer to the buffer of data that will be transmitted\r
                       to USB device or received from USB device.\r
-    DataLength      - Indicates the size, in bytes, of the data buffer \r
+    DataLength      - Indicates the size, in bytes, of the data buffer\r
                       specified by Data.\r
-    TimeOut         - Indicates the maximum time, in microseconds, \r
+    TimeOut         - Indicates the maximum time, in microseconds,\r
                       which the transfer is allowed to complete.\r
     Translator      - A pointr to the transaction translator data.\r
-    TransferResult  - A pointer to the detailed result information generated \r
+    TransferResult  - A pointer to the detailed result information generated\r
                       by this control transfer.\r
-                     \r
+\r
   Returns:\r
-  \r
-    EFI_SUCCESS \r
+\r
+    EFI_SUCCESS\r
         The control transfer was completed successfully.\r
-    EFI_OUT_OF_RESOURCES  \r
+    EFI_OUT_OF_RESOURCES\r
         The control transfer could not be completed due to a lack of resources.\r
-    EFI_INVALID_PARAMETER \r
+    EFI_INVALID_PARAMETER\r
         Some parameters are invalid.\r
-    EFI_TIMEOUT \r
+    EFI_TIMEOUT\r
         The control transfer failed due to timeout.\r
-    EFI_DEVICE_ERROR  \r
-        The control transfer failed due to host controller or device error. \r
+    EFI_DEVICE_ERROR\r
+        The control transfer failed due to host controller or device error.\r
         Caller should check TranferResult for detailed error information.\r
 \r
 --*/\r
@@ -1748,7 +1779,7 @@ EhciControlTransfer (
     Status = EFI_INVALID_PARAMETER;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // If errors exist that cause host controller halt,\r
   // then return EFI_DEVICE_ERROR.\r
@@ -1759,7 +1790,7 @@ EhciControlTransfer (
     Status          = EFI_DEVICE_ERROR;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Map the Request for bus master access.\r
   // BusMasterRead means cpu write\r
@@ -1775,7 +1806,7 @@ EhciControlTransfer (
     Status          = EFI_DEVICE_ERROR;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Map the source data buffer for bus master access.\r
   //\r
@@ -1793,7 +1824,7 @@ EhciControlTransfer (
     Status          = EFI_DEVICE_ERROR;\r
     goto unmap_request;\r
   }\r
-  \r
+\r
   //\r
   // Create and init control Qh\r
   //\r
@@ -1810,7 +1841,7 @@ EhciControlTransfer (
     Status          = EFI_OUT_OF_RESOURCES;\r
     goto unmap_data;\r
   }\r
-  \r
+\r
   //\r
   // Create and init control Qtds\r
   //\r
@@ -1828,7 +1859,7 @@ EhciControlTransfer (
     Status          = EFI_OUT_OF_RESOURCES;\r
     goto destory_qh;\r
   }\r
-  \r
+\r
   //\r
   // Link Qtds to Qh\r
   //\r
@@ -1845,7 +1876,7 @@ EhciControlTransfer (
     Status          = EFI_DEVICE_ERROR;\r
     goto destory_qtds;\r
   }\r
-  \r
+\r
   //\r
   // Poll Qh-Qtds execution and get result.\r
   // detail status is returned\r
@@ -1862,7 +1893,7 @@ EhciControlTransfer (
   if (EFI_ERROR (Status)) {\r
     goto destory_qtds;\r
   }\r
-  \r
+\r
   //\r
   // If has errors that cause host controller halt,\r
   // then return EFI_DEVICE_ERROR directly.\r
@@ -1904,54 +1935,54 @@ EhciBulkTransfer (
   OUT UINT32                              *TransferResult\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
+\r
     Submits bulk transfer to a bulk endpoint of a USB device.\r
-    \r
+\r
   Arguments:\r
-    \r
+\r
     This              - A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
     DeviceAddress     - Represents the address of the target device on the USB,\r
-                        which is assigned during USB enumeration.               \r
-    EndPointAddress   - The combination of an endpoint number and an \r
-                        endpoint direction of the target USB device. \r
-                        Each endpoint address supports data transfer in \r
-                        one direction except the control endpoint \r
-                        (whose default endpoint address is 0). \r
-                        It is the caller's responsibility to make sure that \r
-                        the EndPointAddress represents a bulk endpoint.                  \r
+                        which is assigned during USB enumeration.\r
+    EndPointAddress   - The combination of an endpoint number and an\r
+                        endpoint direction of the target USB device.\r
+                        Each endpoint address supports data transfer in\r
+                        one direction except the control endpoint\r
+                        (whose default endpoint address is 0).\r
+                        It is the caller's responsibility to make sure that\r
+                        the EndPointAddress represents a bulk endpoint.\r
     DeviceSpeed       - Indicates device speed. The supported values are EFI_USB_SPEED_FULL\r
                         and EFI_USB_SPEED_HIGH.\r
     MaximumPacketLength - Indicates the maximum packet size the target endpoint\r
-                          is capable of sending or receiving.                 \r
+                          is capable of sending or receiving.\r
     DataBuffersNumber - Number of data buffers prepared for the transfer.\r
-    Data              - Array of pointers to the buffers of data that will be transmitted \r
-                        to USB device or received from USB device.              \r
+    Data              - Array of pointers to the buffers of data that will be transmitted\r
+                        to USB device or received from USB device.\r
     DataLength        - When input, indicates the size, in bytes, of the data buffer\r
-                        specified by Data. When output, indicates the actually \r
-                        transferred data size.              \r
-    DataToggle        - A pointer to the data toggle value. On input, it indicates \r
+                        specified by Data. When output, indicates the actually\r
+                        transferred data size.\r
+    DataToggle        - A pointer to the data toggle value. On input, it indicates\r
                         the initial data toggle value the bulk transfer should adopt;\r
-                        on output, it is updated to indicate the data toggle value \r
-                        of the subsequent bulk transfer. \r
-    Translator        - A pointr to the transaction translator data. \r
-    TimeOut           - Indicates the maximum time, in microseconds, which the \r
-                        transfer is allowed to complete.              \r
-    TransferResult    - A pointer to the detailed result information of the \r
+                        on output, it is updated to indicate the data toggle value\r
+                        of the subsequent bulk transfer.\r
+    Translator        - A pointr to the transaction translator data.\r
+    TimeOut           - Indicates the maximum time, in microseconds, which the\r
+                        transfer is allowed to complete.\r
+    TransferResult    - A pointer to the detailed result information of the\r
                         bulk transfer.\r
 \r
   Returns:\r
-  \r
-    EFI_SUCCESS \r
+\r
+    EFI_SUCCESS\r
         The bulk transfer was completed successfully.\r
-    EFI_OUT_OF_RESOURCES  \r
+    EFI_OUT_OF_RESOURCES\r
         The bulk transfer could not be submitted due to lack of resource.\r
-    EFI_INVALID_PARAMETER \r
+    EFI_INVALID_PARAMETER\r
         Some parameters are invalid.\r
-    EFI_TIMEOUT \r
+    EFI_TIMEOUT\r
         The bulk transfer failed due to timeout.\r
-    EFI_DEVICE_ERROR  \r
+    EFI_DEVICE_ERROR\r
         The bulk transfer failed due to host controller or device error.\r
         Caller should check TranferResult for detailed error information.\r
 \r
@@ -1976,8 +2007,8 @@ EhciBulkTransfer (
   // Parameters Checking\r
   //\r
   if (NULL == DataLength ||\r
-       NULL == Data || \r
-       NULL == Data[0] || \r
+       NULL == Data ||\r
+       NULL == Data[0] ||\r
        NULL == TransferResult\r
        ) {\r
     Status = EFI_INVALID_PARAMETER;\r
@@ -2012,7 +2043,7 @@ EhciBulkTransfer (
       goto exit;\r
     }\r
   }\r
-  \r
+\r
   //\r
   // if has errors that cause host controller halt,\r
   // then return EFI_DEVICE_ERROR directly.\r
@@ -2029,7 +2060,7 @@ EhciBulkTransfer (
     Status = EFI_DEVICE_ERROR;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // construct QH and TD data structures,\r
   // and link them together\r
@@ -2054,7 +2085,7 @@ EhciBulkTransfer (
     Status          = EFI_DEVICE_ERROR;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Create and init Bulk Qh\r
   //\r
@@ -2073,7 +2104,7 @@ EhciBulkTransfer (
     Status          = EFI_OUT_OF_RESOURCES;\r
     goto unmap_data;\r
   }\r
-  \r
+\r
   //\r
   // Create and init Bulk Qtds\r
   //\r
@@ -2090,7 +2121,7 @@ EhciBulkTransfer (
     Status          = EFI_OUT_OF_RESOURCES;\r
     goto destory_qh;\r
   }\r
-  \r
+\r
   //\r
   // Link Qtds to Qh\r
   //\r
@@ -2107,7 +2138,7 @@ EhciBulkTransfer (
     Status          = EFI_DEVICE_ERROR;\r
     goto destory_qtds;\r
   }\r
-  \r
+\r
   //\r
   // Poll QH-TDs execution and get result.\r
   // detail status is returned\r
@@ -2124,7 +2155,7 @@ EhciBulkTransfer (
   if (EFI_ERROR (Status)) {\r
     goto destory_qtds;\r
   }\r
-  \r
+\r
   //\r
   // if has errors that cause host controller halt,\r
   // then return EFI_DEVICE_ERROR directly.\r
@@ -2164,65 +2195,65 @@ EhciAsyncInterruptTransfer (
   IN  VOID                                  *Context OPTIONAL\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
-    Submits an asynchronous interrupt transfer to an \r
+\r
+    Submits an asynchronous interrupt transfer to an\r
     interrupt endpoint of a USB device.\r
-    Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated \r
+    Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated\r
     in the following specification version.\r
-    \r
+\r
   Arguments:\r
-    \r
+\r
     This            - A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
     DeviceAddress   - Represents the address of the target device on the USB,\r
-                      which is assigned during USB enumeration.                \r
-    EndPointAddress - The combination of an endpoint number and an endpoint \r
-                      direction of the target USB device. Each endpoint address \r
-                      supports data transfer in one direction except the \r
-                      control endpoint (whose default endpoint address is 0). \r
-                      It is the caller's responsibility to make sure that \r
-                      the EndPointAddress represents an interrupt endpoint.              \r
+                      which is assigned during USB enumeration.\r
+    EndPointAddress - The combination of an endpoint number and an endpoint\r
+                      direction of the target USB device. Each endpoint address\r
+                      supports data transfer in one direction except the\r
+                      control endpoint (whose default endpoint address is 0).\r
+                      It is the caller's responsibility to make sure that\r
+                      the EndPointAddress represents an interrupt endpoint.\r
     DeviceSpeed     - Indicates device speed.\r
     MaximumPacketLength  - Indicates the maximum packet size the target endpoint\r
-                           is capable of sending or receiving.                   \r
+                           is capable of sending or receiving.\r
     IsNewTransfer   - If TRUE, an asynchronous interrupt pipe is built between\r
-                      the host and the target interrupt endpoint. \r
-                      If FALSE, the specified asynchronous interrupt pipe \r
-                      is canceled.               \r
-    DataToggle      - A pointer to the data toggle value.  On input, it is valid \r
-                      when IsNewTransfer is TRUE, and it indicates the initial \r
-                      data toggle value the asynchronous interrupt transfer \r
-                      should adopt.  \r
-                      On output, it is valid when IsNewTransfer is FALSE, \r
-                      and it is updated to indicate the data toggle value of \r
-                      the subsequent asynchronous interrupt transfer.              \r
-    PollingInterval - Indicates the interval, in milliseconds, that the \r
-                      asynchronous interrupt transfer is polled.  \r
-                      This parameter is required when IsNewTransfer is TRUE.               \r
-    DataLength      - Indicates the length of data to be received at the \r
-                      rate specified by PollingInterval from the target \r
-                      asynchronous interrupt endpoint.  This parameter \r
-                      is only required when IsNewTransfer is TRUE.             \r
+                      the host and the target interrupt endpoint.\r
+                      If FALSE, the specified asynchronous interrupt pipe\r
+                      is canceled.\r
+    DataToggle      - A pointer to the data toggle value.  On input, it is valid\r
+                      when IsNewTransfer is TRUE, and it indicates the initial\r
+                      data toggle value the asynchronous interrupt transfer\r
+                      should adopt.\r
+                      On output, it is valid when IsNewTransfer is FALSE,\r
+                      and it is updated to indicate the data toggle value of\r
+                      the subsequent asynchronous interrupt transfer.\r
+    PollingInterval - Indicates the interval, in milliseconds, that the\r
+                      asynchronous interrupt transfer is polled.\r
+                      This parameter is required when IsNewTransfer is TRUE.\r
+    DataLength      - Indicates the length of data to be received at the\r
+                      rate specified by PollingInterval from the target\r
+                      asynchronous interrupt endpoint.  This parameter\r
+                      is only required when IsNewTransfer is TRUE.\r
     Translator      - A pointr to the transaction translator data.\r
-    CallBackFunction  - The Callback function.This function is called at the \r
-                        rate specified by PollingInterval.This parameter is \r
-                        only required when IsNewTransfer is TRUE.               \r
+    CallBackFunction  - The Callback function.This function is called at the\r
+                        rate specified by PollingInterval.This parameter is\r
+                        only required when IsNewTransfer is TRUE.\r
     Context         - The context that is passed to the CallBackFunction.\r
                     - This is an optional parameter and may be NULL.\r
-  \r
+\r
   Returns:\r
-  \r
-    EFI_SUCCESS \r
-        The asynchronous interrupt transfer request has been successfully \r
+\r
+    EFI_SUCCESS\r
+        The asynchronous interrupt transfer request has been successfully\r
         submitted or canceled.\r
-    EFI_INVALID_PARAMETER \r
+    EFI_INVALID_PARAMETER\r
         Some parameters are invalid.\r
-    EFI_OUT_OF_RESOURCES  \r
-        The request could not be completed due to a lack of resources.  \r
+    EFI_OUT_OF_RESOURCES\r
+        The request could not be completed due to a lack of resources.\r
     EFI_DEVICE_ERROR\r
         Can't read register\r
-        \r
+\r
 --*/\r
 {\r
   EFI_STATUS          Status;\r
@@ -2269,7 +2300,7 @@ EhciAsyncInterruptTransfer (
       goto exit;\r
     }\r
   }\r
-  \r
+\r
   //\r
   // if has errors that cause host controller halt,\r
   // then return EFI_DEVICE_ERROR directly.\r
@@ -2285,7 +2316,7 @@ EhciAsyncInterruptTransfer (
     Status = EFI_DEVICE_ERROR;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Delete Async interrupt transfer request\r
   //\r
@@ -2306,8 +2337,8 @@ EhciAsyncInterruptTransfer (
   }\r
 \r
   Status = EhciAllocatePool (\r
-                HcDev, \r
-                (UINT8 **) &AsyncRequestPtr, \r
+                HcDev,\r
+                (UINT8 **) &AsyncRequestPtr,\r
                 sizeof (EHCI_ASYNC_REQUEST)\r
                 );\r
   if (EFI_ERROR (Status)) {\r
@@ -2335,7 +2366,7 @@ EhciAsyncInterruptTransfer (
     Status = EFI_DEVICE_ERROR;\r
     goto free_data;\r
   }\r
-  \r
+\r
   //\r
   // Create and init Interrupt Qh\r
   //\r
@@ -2354,7 +2385,7 @@ EhciAsyncInterruptTransfer (
     Status = EFI_OUT_OF_RESOURCES;\r
     goto unmap_data;\r
   }\r
-  \r
+\r
   //\r
   // Create and init Interrupt Qtds\r
   //\r
@@ -2370,7 +2401,7 @@ EhciAsyncInterruptTransfer (
     Status = EFI_OUT_OF_RESOURCES;\r
     goto destory_qh;\r
   }\r
-  \r
+\r
   //\r
   // Link Qtds to Qh\r
   //\r
@@ -2394,7 +2425,7 @@ EhciAsyncInterruptTransfer (
       goto exit;\r
     }\r
   }\r
-  \r
+\r
   //\r
   // Link Entry to AsyncRequest List\r
   //\r
@@ -2413,7 +2444,7 @@ EhciAsyncInterruptTransfer (
     Status = EFI_TIMEOUT;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Link Qh and Qtds to Periodic Schedule List\r
   //\r
@@ -2448,8 +2479,8 @@ free_data:
   EhciFreePool (HcDev, DataPtr, DataLength);\r
 free_request:\r
   EhciFreePool (\r
-       HcDev, \r
-       (UINT8 *) AsyncRequestPtr, \r
+       HcDev,\r
+       (UINT8 *) AsyncRequestPtr,\r
        sizeof (EHCI_ASYNC_REQUEST)\r
        );\r
 unmap_data:\r
@@ -2474,60 +2505,60 @@ EhciSyncInterruptTransfer (
   OUT UINT32                                *TransferResult\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
-    Submits synchronous interrupt transfer to an interrupt endpoint \r
-    of a USB device. \r
-    Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated \r
+\r
+    Submits synchronous interrupt transfer to an interrupt endpoint\r
+    of a USB device.\r
+    Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated\r
     in the following specification version.\r
-  \r
+\r
   Arguments:\r
-    \r
+\r
     This            - A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
-    DeviceAddress   - Represents the address of the target device on the USB, \r
+    DeviceAddress   - Represents the address of the target device on the USB,\r
                       which is assigned during USB enumeration.\r
-    EndPointAddress - The combination of an endpoint number and an endpoint \r
-                      direction of the target USB device. Each endpoint \r
-                      address supports data transfer in one direction \r
-                      except the control endpoint (whose default \r
+    EndPointAddress - The combination of an endpoint number and an endpoint\r
+                      direction of the target USB device. Each endpoint\r
+                      address supports data transfer in one direction\r
+                      except the control endpoint (whose default\r
                       endpoint address is 0). It is the caller's responsibility\r
-                      to make sure that the EndPointAddress represents \r
-                      an interrupt endpoint. \r
+                      to make sure that the EndPointAddress represents\r
+                      an interrupt endpoint.\r
     DeviceSpeed     - Indicates device speed.\r
-    MaximumPacketLength - Indicates the maximum packet size the target endpoint \r
+    MaximumPacketLength - Indicates the maximum packet size the target endpoint\r
                           is capable of sending or receiving.\r
-    Data            - A pointer to the buffer of data that will be transmitted \r
+    Data            - A pointer to the buffer of data that will be transmitted\r
                       to USB device or received from USB device.\r
-    DataLength      - On input, the size, in bytes, of the data buffer specified \r
+    DataLength      - On input, the size, in bytes, of the data buffer specified\r
                       by Data. On output, the number of bytes transferred.\r
     DataToggle      - A pointer to the data toggle value. On input, it indicates\r
-                      the initial data toggle value the synchronous interrupt \r
-                      transfer should adopt; \r
-                      on output, it is updated to indicate the data toggle value \r
-                      of the subsequent synchronous interrupt transfer. \r
-    TimeOut         - Indicates the maximum time, in microseconds, which the \r
+                      the initial data toggle value the synchronous interrupt\r
+                      transfer should adopt;\r
+                      on output, it is updated to indicate the data toggle value\r
+                      of the subsequent synchronous interrupt transfer.\r
+    TimeOut         - Indicates the maximum time, in microseconds, which the\r
                       transfer is allowed to complete.\r
     Translator      - A pointr to the transaction translator data.\r
-    TransferResult  - A pointer to the detailed result information from \r
-                      the synchronous interrupt transfer.  \r
+    TransferResult  - A pointer to the detailed result information from\r
+                      the synchronous interrupt transfer.\r
 \r
   Returns:\r
-  \r
-    EFI_SUCCESS \r
+\r
+    EFI_SUCCESS\r
         The synchronous interrupt transfer was completed successfully.\r
-    EFI_OUT_OF_RESOURCES  \r
-        The synchronous interrupt transfer could not be submitted due \r
+    EFI_OUT_OF_RESOURCES\r
+        The synchronous interrupt transfer could not be submitted due\r
         to lack of resource.\r
-    EFI_INVALID_PARAMETER \r
+    EFI_INVALID_PARAMETER\r
         Some parameters are invalid.\r
-    EFI_TIMEOUT \r
+    EFI_TIMEOUT\r
         The synchronous interrupt transfer failed due to timeout.\r
-    EFI_DEVICE_ERROR  \r
-        The synchronous interrupt transfer failed due to host controller \r
-        or device error. Caller should check TranferResult for detailed \r
-        error information.  \r
-        \r
+    EFI_DEVICE_ERROR\r
+        The synchronous interrupt transfer failed due to host controller\r
+        or device error. Caller should check TranferResult for detailed\r
+        error information.\r
+\r
 --*/\r
 {\r
   EFI_STATUS      Status;\r
@@ -2548,7 +2579,7 @@ EhciSyncInterruptTransfer (
   // Parameters Checking\r
   //\r
   if (DataLength == NULL ||\r
-       Data == NULL || \r
+       Data == NULL ||\r
        TransferResult == NULL\r
        ) {\r
     Status = EFI_INVALID_PARAMETER;\r
@@ -2584,7 +2615,7 @@ EhciSyncInterruptTransfer (
     Status = EFI_INVALID_PARAMETER;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // if has errors that cause host controller halt,\r
   // then return EFI_DEVICE_ERROR directly.\r
@@ -2616,7 +2647,7 @@ EhciSyncInterruptTransfer (
     Status          = EFI_DEVICE_ERROR;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Create and init Interrupt Qh\r
   //\r
@@ -2635,7 +2666,7 @@ EhciSyncInterruptTransfer (
     Status = EFI_OUT_OF_RESOURCES;\r
     goto unmap_data;\r
   }\r
-  \r
+\r
   //\r
   // Create and init Interrupt Qtds\r
   //\r
@@ -2652,7 +2683,7 @@ EhciSyncInterruptTransfer (
     Status          = EFI_OUT_OF_RESOURCES;\r
     goto destory_qh;\r
   }\r
-  \r
+\r
   //\r
   // Link Qtds to Qh\r
   //\r
@@ -2671,7 +2702,7 @@ EhciSyncInterruptTransfer (
     Status = EFI_TIMEOUT;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Link Qh and Qtds to Periodic Schedule List\r
   //\r
@@ -2696,7 +2727,7 @@ EhciSyncInterruptTransfer (
       goto exit;\r
     }\r
   }\r
-  \r
+\r
   //\r
   // Poll QH-TDs execution and get result.\r
   // detail status is returned\r
@@ -2713,7 +2744,7 @@ EhciSyncInterruptTransfer (
   if (EFI_ERROR (Status)) {\r
     goto destory_qtds;\r
   }\r
-  \r
+\r
   //\r
   // if has errors that cause host controller halt,\r
   // then return EFI_DEVICE_ERROR directly.\r
@@ -2751,33 +2782,33 @@ EhciIsochronousTransfer (
   OUT UINT32                                *TransferResult\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
+\r
     Submits isochronous transfer to a target USB device.\r
-  \r
+\r
   Arguments:\r
-    \r
+\r
     This             - A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
     DeviceAddress    - Represents the address of the target device on the USB,\r
                        which is assigned during USB enumeration.\r
     EndPointAddress  - End point address\r
     DeviceSpeed      - Indicates device speed.\r
-    MaximumPacketLength    - Indicates the maximum packet size that the \r
-                             default control transfer endpoint is capable of \r
+    MaximumPacketLength    - Indicates the maximum packet size that the\r
+                             default control transfer endpoint is capable of\r
                              sending or receiving.\r
     DataBuffersNumber - Number of data buffers prepared for the transfer.\r
-    Data              - Array of pointers to the buffers of data that will be \r
+    Data              - Array of pointers to the buffers of data that will be\r
                         transmitted to USB device or received from USB device.\r
-    DataLength        - Indicates the size, in bytes, of the data buffer \r
+    DataLength        - Indicates the size, in bytes, of the data buffer\r
                         specified by Data.\r
     Translator        - A pointr to the transaction translator data.\r
-    TransferResult    - A pointer to the detailed result information generated \r
-                        by this control transfer.               \r
-                      \r
+    TransferResult    - A pointer to the detailed result information generated\r
+                        by this control transfer.\r
+\r
   Returns:\r
-  \r
-    EFI_UNSUPPORTED \r
+\r
+    EFI_UNSUPPORTED\r
 \r
 --*/\r
 {\r
@@ -2800,31 +2831,31 @@ EhciAsyncIsochronousTransfer (
   IN  VOID                                *Context\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
-  \r
+\r
     Submits Async isochronous transfer to a target USB device.\r
-  \r
+\r
   Arguments:\r
-    \r
+\r
     This                - A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
     DeviceAddress       - Represents the address of the target device on the USB,\r
                           which is assigned during USB enumeration.\r
     EndPointAddress     - End point address\r
     DeviceSpeed         - Indicates device speed.\r
-    MaximumPacketLength - Indicates the maximum packet size that the \r
-                          default control transfer endpoint is capable of \r
+    MaximumPacketLength - Indicates the maximum packet size that the\r
+                          default control transfer endpoint is capable of\r
                           sending or receiving.\r
     DataBuffersNumber   - Number of data buffers prepared for the transfer.\r
-    Data                - Array of pointers to the buffers of data that will be transmitted \r
+    Data                - Array of pointers to the buffers of data that will be transmitted\r
                           to USB device or received from USB device.\r
     Translator          - A pointr to the transaction translator data.\r
     IsochronousCallBack - When the transfer complete, the call back function will be called\r
     Context             - Pass to the call back function as parameter\r
-                    \r
+\r
   Returns:\r
-  \r
-    EFI_UNSUPPORTED \r
+\r
+    EFI_UNSUPPORTED\r
 \r
 --*/\r
 {\r
index 747e1ee1240417e2c2442a14cb36a112173a6665..603bb2665a8b2c6717a1e9105181dfc0366af979 100644 (file)
@@ -1,20 +1,20 @@
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
     Ehci.h\r
-    \r
-Abstract: \r
-    \r
+\r
+Abstract:\r
+\r
 \r
 Revision History\r
 --*/\r
@@ -36,6 +36,9 @@ extern UINTN  gEHCErrorLevel;
 #define STALL_1_MILLI_SECOND              1000 * STALL_1_MACRO_SECOND\r
 #define STALL_1_SECOND                    1000 * STALL_1_MILLI_SECOND\r
 \r
+#define MEM_UNIT_SIZE                     128\r
+\r
+\r
 #define SETUP_PACKET_PID_CODE             0x02\r
 #define INPUT_PACKET_PID_CODE             0x01\r
 #define OUTPUT_PACKET_PID_CODE            0x0\r
@@ -54,7 +57,7 @@ extern UINTN  gEHCErrorLevel;
 \r
 #define USB_BAR_INDEX                     0 /* how many bytes away from USB_BASE to 0x10 */\r
 \r
-#define NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES 1\r
+#define NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES 16\r
 \r
 #define EHCI_MIN_PACKET_SIZE              8\r
 #define EHCI_MAX_PACKET_SIZE              1024\r
@@ -64,7 +67,7 @@ extern UINTN  gEHCErrorLevel;
 #define EHCI_MAX_QTD_CAPACITY             (EFI_PAGE_SIZE * 5)\r
 \r
 #define NAK_COUNT_RELOAD                  3\r
-#define QTD_ERROR_COUNTER                 1\r
+#define QTD_ERROR_COUNTER                 3\r
 #define HIGH_BANDWIDTH_PIPE_MULTIPLIER    1\r
 \r
 #define QTD_STATUS_ACTIVE                 0x80\r
@@ -210,6 +213,9 @@ typedef struct {
   UINT8 BaseCode;\r
 } USB_CLASSC;\r
 \r
+//\r
+//32 Bytes Aligned\r
+//\r
 typedef struct {\r
   UINT32  NextQtdTerminate : 1;\r
   UINT32  Rsvd1 : 4;\r
@@ -242,13 +248,12 @@ typedef struct {
   UINT32  Rsvd6 : 12;\r
   UINT32  BufferPointer4 : 20;\r
 \r
-  UINT32  ExtBufferPointer0;\r
-  UINT32  ExtBufferPointer1;\r
-  UINT32  ExtBufferPointer2;\r
-  UINT32  ExtBufferPointer3;\r
-  UINT32  ExtBufferPointer4;\r
+  UINT32  PAD[5];\r
 } EHCI_QTD_HW;\r
 \r
+//\r
+//32 Bytes Aligned\r
+//\r
 typedef struct {\r
   UINT32  QhTerminate : 1;\r
   UINT32  SelectType : 2;\r
@@ -307,11 +312,7 @@ typedef struct {
   UINT32  Rsvd6 : 12;\r
   UINT32  BufferPointer4 : 20;\r
 \r
-  UINT32  ExtBufferPointer0;\r
-  UINT32  ExtBufferPointer1;\r
-  UINT32  ExtBufferPointer2;\r
-  UINT32  ExtBufferPointer3;\r
-  UINT32  ExtBufferPointer4;\r
+  UINT32  Pad[5];\r
 } EHCI_QH_HW;\r
 \r
 typedef struct {\r
@@ -326,7 +327,9 @@ typedef struct {
 typedef struct _EHCI_QTD_ENTITY     EHCI_QTD_ENTITY;\r
 typedef struct _EHCI_QH_ENTITY      EHCI_QH_ENTITY;\r
 typedef struct _EHCI_ASYNC_REQUEST  EHCI_ASYNC_REQUEST;\r
-\r
+//\r
+//Aligan On 32 Bytes\r
+//\r
 struct _EHCI_QTD_ENTITY {\r
   EHCI_QTD_HW     Qtd;\r
   UINT32          TotalBytes;\r
@@ -337,7 +340,9 @@ struct _EHCI_QTD_ENTITY {
   EHCI_QTD_ENTITY *AltNext;\r
   EHCI_QH_ENTITY  *SelfQh;\r
 };\r
-\r
+//\r
+//Aligan On 32 Bytes\r
+//\r
 struct _EHCI_QH_ENTITY {\r
   EHCI_QH_HW      Qh;\r
   EHCI_QH_ENTITY  *Next;\r
@@ -390,8 +395,9 @@ typedef struct _USB2_HC_DEV {
   EFI_EVENT                 AsyncRequestEvent;\r
   EFI_UNICODE_STRING_TABLE  *ControllerNameTable;\r
   MEMORY_MANAGE_HEADER      *MemoryHeader;\r
-  UINT8                                                Is64BitCapable;\r
+  UINT8                     Is64BitCapable;\r
   UINT32                    High32BitAddr;\r
+  EHCI_QH_ENTITY            *NULLQH;\r
   UINT32                    UsbCapabilityLen;\r
   UINT16                    DeviceSpeed[16];\r
 } USB2_HC_DEV;\r
@@ -422,13 +428,13 @@ Arguments:
   HcDev                  - USB2_HC_DEV\r
   MemoryHeader           - MEMORY_MANAGE_HEADER to output\r
   MemoryBlockSizeInPages - MemoryBlockSizeInPages\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS           Success\r
   EFI_OUT_OF_RESOURCES  Fail for no resources\r
   EFI_UNSUPPORTED       Unsupported currently\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -500,7 +506,7 @@ Arguments:
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
-  EFI_NOT_FOUND  Can't find the free memory \r
+  EFI_NOT_FOUND  Can't find the free memory\r
 \r
 --*/\r
 ;\r
@@ -522,7 +528,7 @@ Arguments:
 Returns:\r
 \r
   TRUE    Empty\r
-  FALSE   Not Empty \r
+  FALSE   Not Empty\r
 \r
 --*/\r
 ;\r
@@ -590,7 +596,7 @@ Returns:
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -616,7 +622,7 @@ Returns:
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -659,18 +665,18 @@ ReadEhcCapabiltiyReg (
 Routine Description:\r
 \r
   Read  Ehc Capabitlity register\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev             - USB2_HC_DEV \r
+  HcDev             - USB2_HC_DEV\r
   CapabiltiyRegAddr - Ehc Capability register address\r
   Data              - A pointer to data read from register\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -685,18 +691,18 @@ ReadEhcOperationalReg (
 Routine Description:\r
 \r
   Read  Ehc Operation register\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev                - USB2_HC_DEV \r
+  HcDev                - USB2_HC_DEV\r
   OperationalRegAddr   - Ehc Operation register address\r
   Data                 - A pointer to data read from register\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -711,18 +717,18 @@ WriteEhcOperationalReg (
 Routine Description:\r
 \r
   Write  Ehc Operation register\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev                - USB2_HC_DEV \r
+  HcDev                - USB2_HC_DEV\r
   OperationalRegAddr   - Ehc Operation register address\r
   Data                 - 32bit write to register\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -735,16 +741,16 @@ SetEhcDoorbell (
 Routine Description:\r
 \r
   Set Ehc door bell bit\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-     \r
+\r
 --*/\r
 ;\r
 \r
@@ -758,18 +764,18 @@ SetFrameListLen (
 Routine Description:\r
 \r
   Set the length of Frame List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev    - USB2_HC_DEV \r
+  HcDev    - USB2_HC_DEV\r
   Length   - the required length of frame list\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_INVALID_PARAMETER  Invalid parameter\r
   EFI_DEVICE_ERROR       Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -782,16 +788,16 @@ IsFrameListProgrammable (
 Routine Description:\r
 \r
   Whether frame list is programmable\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   Programmable\r
   FALSE  Unprogrammable\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -804,16 +810,16 @@ IsPeriodicScheduleEnabled (
 Routine Description:\r
 \r
   Whether periodic schedule is enabled\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   Enabled\r
   FALSE  Disabled\r
-   \r
+\r
 --*/\r
 ;\r
 \r
@@ -826,16 +832,16 @@ IsAsyncScheduleEnabled (
 Routine Description:\r
 \r
   Whether asynchronous schedule is enabled\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   Enabled\r
   FALSE  Disabled\r
-    \r
+\r
 --*/\r
 ;\r
 \r
@@ -849,16 +855,16 @@ IsEhcPortEnabled (
 Routine Description:\r
 \r
   Whether port is enabled\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   Enabled\r
   FALSE  Disabled\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -871,16 +877,16 @@ IsEhcReseted (
 Routine Description:\r
 \r
   Whether Ehc is halted\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   Reseted\r
   FALSE  Unreseted\r
-    \r
+\r
 --*/\r
 ;\r
 \r
@@ -893,16 +899,16 @@ IsEhcHalted (
 Routine Description:\r
 \r
   Whether Ehc is halted\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev  - USB2_HC_DEV \r
-  \r
+  HcDev  - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   Halted\r
   FALSE  Not halted\r
-    \r
+\r
 --*/\r
 ;\r
 \r
@@ -915,39 +921,39 @@ IsEhcSysError (
 Routine Description:\r
 \r
   Whether Ehc is system error\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev  - USB2_HC_DEV \r
-  \r
+  HcDev  - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   System error\r
   FALSE  No system error\r
-    \r
+\r
 --*/\r
 ;\r
 \r
 BOOLEAN\r
 IsHighSpeedDevice (\r
   IN EFI_USB2_HC_PROTOCOL *This,\r
-  IN UINT8                PortNum \r
+  IN UINT8                PortNum\r
   )\r
 /*++\r
 \r
 Routine Description:\r
 \r
   Whether high speed device attached\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   High speed\r
   FALSE  Full speed\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -961,17 +967,17 @@ WaitForEhcReset (
 Routine Description:\r
 \r
   wait for Ehc reset or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -985,17 +991,17 @@ WaitForEhcHalt (
 Routine Description:\r
 \r
   wait for Ehc halt or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1009,17 +1015,17 @@ WaitForEhcNotHalt (
 Routine Description:\r
 \r
   wait for Ehc not halt or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1036,14 +1042,14 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
 \r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1057,17 +1063,17 @@ WaitForAsyncScheduleEnable (
 Routine Description:\r
 \r
   Wait for Ehc asynchronous schedule enable or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1081,17 +1087,17 @@ WaitForAsyncScheduleDisable (
 Routine Description:\r
 \r
   Wait for Ehc asynchronous schedule disable or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1105,17 +1111,17 @@ WaitForPeriodicScheduleEnable (
 Routine Description:\r
 \r
   Wait for Ehc periodic schedule enable or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1129,17 +1135,17 @@ WaitForPeriodicScheduleDisable (
 Routine Description:\r
 \r
   Wait for periodic schedule disable or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1152,16 +1158,16 @@ GetCapabilityLen (
 Routine Description:\r
 \r
   Get the length of capability register\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1175,17 +1181,17 @@ SetFrameListBaseAddr (
 Routine Description:\r
 \r
   Set base address of frame list first entry\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev       - USB2_HC_DEV \r
+  HcDev       - USB2_HC_DEV\r
   FrameBuffer - base address of first entry of frame list\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1199,17 +1205,17 @@ SetAsyncListAddr (
 Routine Description:\r
 \r
   Set address of first Async schedule Qh\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev    - USB2_HC_DEV \r
+  HcDev    - USB2_HC_DEV\r
   QhPtr    - A pointer to first Qh in the Async schedule\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1222,17 +1228,17 @@ SetCtrlDataStructSeg (
 Routine Description:\r
 \r
   Set address of first Async schedule Qh\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev    - USB2_HC_DEV \r
+  HcDev    - USB2_HC_DEV\r
   QhPtr    - A pointer to first Qh in the Async schedule\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1245,16 +1251,16 @@ SetPortRoutingEhc (
 Routine Description:\r
 \r
   Set Ehc port routing bit\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1267,16 +1273,16 @@ EnablePeriodicSchedule (
 Routine Description:\r
 \r
   Enable periodic schedule\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1289,16 +1295,16 @@ DisablePeriodicSchedule (
 Routine Description:\r
 \r
   Disable periodic schedule\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1311,16 +1317,16 @@ EnableAsynchronousSchedule (
 Routine Description:\r
 \r
   Enable asynchrounous schedule\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1333,16 +1339,16 @@ DisableAsynchronousSchedule (
 Routine Description:\r
 \r
   Disable asynchrounous schedule\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1355,16 +1361,16 @@ StartScheduleExecution (
 Routine Description:\r
 \r
   Start Ehc schedule execution\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1377,16 +1383,16 @@ ResetEhc (
 Routine Description:\r
 \r
   Reset Ehc\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1399,16 +1405,16 @@ ClearEhcAllStatus (
 Routine Description:\r
 \r
   Clear Ehc all status bits\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1430,12 +1436,12 @@ Arguments:
 \r
   HcDev   - USB2_HC_DEV\r
   Length  - Frame List Length\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1456,7 +1462,7 @@ Arguments:
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1475,12 +1481,12 @@ Arguments:
 \r
   HcDev          - USB2_HC_DEV\r
   NotifyFunction - Timer Notify Function\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1497,12 +1503,12 @@ Routine Description:
 Arguments:\r
 \r
   HcDev - USB2_HC_DEV\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1519,12 +1525,12 @@ Routine Description:
 Arguments:\r
 \r
   HcDev - USB2_HC_DEV\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1541,12 +1547,12 @@ Routine Description:
 Arguments:\r
 \r
   HcDev - USB2_HC_DEV\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1567,18 +1573,18 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev          - USB2_HC_DEV \r
+  HcDev          - USB2_HC_DEV\r
   DeviceAddr     - Address of Device\r
   Endpoint       - Endpoint Number\r
   DeviceSpeed    - Device Speed\r
   MaxPacketLen   - Max Length of one Packet\r
   QhPtrPtr       - A pointer of pointer to Qh for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1599,18 +1605,18 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev         - USB2_HC_DEV \r
+  HcDev         - USB2_HC_DEV\r
   DeviceAddr    - Address of Device\r
   DeviceSpeed   - Device Speed\r
   MaxPacketLen  - Max Length of one Packet\r
   Translator    - Translator Transaction for SplitX\r
   QhPtrPtr      - A pointer of pointer to Qh for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1633,19 +1639,19 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev         - USB2_HC_DEV \r
+  HcDev         - USB2_HC_DEV\r
   DeviceAddr    - Address of Device\r
   EndPointAddr  - Address of Endpoint\r
   DeviceSpeed   - Device Speed\r
   MaxPacketLen  - Max Length of one Packet\r
   Translator    - Translator Transaction for SplitX\r
   QhPtrPtr      - A pointer of pointer to Qh for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1669,7 +1675,7 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev        - USB2_HC_DEV \r
+  HcDev        - USB2_HC_DEV\r
   DeviceAddr   - Address of Device\r
   EndPointAddr - Address of Endpoint\r
   DeviceSpeed  - Device Speed\r
@@ -1677,12 +1683,12 @@ Arguments:
   Interval     - value of interval\r
   Translator   - Translator Transaction for SplitX\r
   QhPtrPtr     - A pointer of pointer to Qh for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1695,17 +1701,17 @@ DestoryQh (
 \r
 Routine Description:\r
 \r
-  Destory Qh Structure \r
-  \r
+  Destory Qh Structure\r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
+  HcDev - USB2_HC_DEV\r
   QhPtr - A pointer to Qh\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1727,19 +1733,19 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev       - USB2_HC_DEV \r
+  HcDev       - USB2_HC_DEV\r
   DataPtr     - A pointer to user data buffer to transfer\r
   DataLen     - Length of user data to transfer\r
   PktId       - Packet Identification of this Qtd\r
   Toggle      - Data Toggle of this Qtd\r
   QtdStatus   - Default value of status of this Qtd\r
   QtdPtrPtr   - A pointer of pointer to Qtd for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1753,19 +1759,19 @@ CreateSetupQtd (
 \r
 Routine Description:\r
 \r
-  Create Qtd Structure for Setup \r
+  Create Qtd Structure for Setup\r
 \r
 Arguments:\r
 \r
-  HcDev      - USB2_HC_DEV \r
+  HcDev      - USB2_HC_DEV\r
   DevReqPtr  - A pointer to Device Request Data\r
   QtdPtrPtr  - A pointer of pointer to Qtd for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1782,22 +1788,22 @@ CreateDataQtd (
 \r
 Routine Description:\r
 \r
-  Create Qtd Structure for data \r
+  Create Qtd Structure for data\r
 \r
 Arguments:\r
 \r
-  HcDev       - USB2_HC_DEV \r
+  HcDev       - USB2_HC_DEV\r
   DataPtr     - A pointer to user data buffer to transfer\r
   DataLen     - Length of user data to transfer\r
   PktId       - Packet Identification of this Qtd\r
   Toggle      - Data Toggle of this Qtd\r
   QtdPtrPtr   - A pointer of pointer to Qtd for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1811,19 +1817,19 @@ CreateStatusQtd (
 \r
 Routine Description:\r
 \r
-  Create Qtd Structure for status \r
+  Create Qtd Structure for status\r
 \r
 Arguments:\r
 \r
-  HcDev       - USB2_HC_DEV \r
+  HcDev       - USB2_HC_DEV\r
   PktId       - Packet Identification of this Qtd\r
   QtdPtrPtr   - A pointer of pointer to Qtd for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1837,19 +1843,19 @@ CreateAltQtd (
 \r
 Routine Description:\r
 \r
-  Create Qtd Structure for Alternative \r
+  Create Qtd Structure for Alternative\r
 \r
 Arguments:\r
 \r
-  HcDev      - USB2_HC_DEV \r
+  HcDev      - USB2_HC_DEV\r
   PktId      - Packet Identification of this Qtd\r
   QtdPtrPtr  - A pointer of pointer to Qtd for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1867,22 +1873,22 @@ CreateControlQtds (
 \r
 Routine Description:\r
 \r
-  Create Qtds list for Control Transfer \r
+  Create Qtds list for Control Transfer\r
 \r
 Arguments:\r
 \r
-  HcDev           - USB2_HC_DEV \r
+  HcDev           - USB2_HC_DEV\r
   DataPktId       - Packet Identification of Data Qtds\r
   RequestCursor   - A pointer to request structure buffer to transfer\r
   DataCursor      - A pointer to user data buffer to transfer\r
   DataLen         - Length of user data to transfer\r
   ControlQtdsHead - A pointer of pointer to first Qtd for control tranfer for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1899,23 +1905,23 @@ CreateBulkOrInterruptQtds (
 \r
 Routine Description:\r
 \r
-  Create Qtds list for Bulk or Interrupt Transfer \r
+  Create Qtds list for Bulk or Interrupt Transfer\r
 \r
 Arguments:\r
 \r
-  HcDev        - USB2_HC_DEV \r
+  HcDev        - USB2_HC_DEV\r
   PktId        - Packet Identification of Qtds\r
   DataCursor   - A pointer to user data buffer to transfer\r
   DataLen      - Length of user data to transfer\r
   DataToggle   - Data Toggle to start\r
   Translator   - Translator Transaction for SplitX\r
   QtdsHead     - A pointer of pointer to first Qtd for control tranfer for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -1932,9 +1938,9 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev        - USB2_HC_DEV \r
-  FirstQtdPtr  - A pointer to first Qtd in the list \r
-    \r
+  HcDev        - USB2_HC_DEV\r
+  FirstQtdPtr  - A pointer to first Qtd in the list\r
+\r
 Returns:\r
 \r
   VOID\r
@@ -1952,12 +1958,12 @@ LinkQtdToQtd (
 Routine Description:\r
 \r
   Link Qtds together\r
-  \r
+\r
 Arguments:\r
 \r
   PreQtdPtr  - A pointer to pre Qtd\r
   QtdPtr     - A pointer to next Qtd\r
-    \r
+\r
 Returns:\r
 \r
   VOID\r
@@ -1975,12 +1981,12 @@ LinkQtdsToAltQtd (
 Routine Description:\r
 \r
   Link AlterQtds together\r
-  \r
+\r
 Arguments:\r
 \r
   FirstQtdPtr - A pointer to first Qtd in the list\r
   AltQtdPtr - A pointer to alternative Qtd\r
-    \r
+\r
 Returns:\r
   VOID\r
 \r
@@ -1997,12 +2003,12 @@ LinkQtdToQh (
 Routine Description:\r
 \r
   Link Qtds list to Qh\r
-  \r
+\r
 Arguments:\r
 \r
   QhPtr   - A pointer to Qh\r
   QtdPtr  - A pointer to first Qtd in the list\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
@@ -2020,17 +2026,17 @@ LinkQhToAsyncList (
 Routine Description:\r
 \r
   Link Qh to Async Schedule List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
+  HcDev - USB2_HC_DEV\r
   QhPtr - A pointer to Qh\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2044,17 +2050,17 @@ UnlinkQhFromAsyncList (
 Routine Description:\r
 \r
   Unlink Qh from Async Schedule List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   QhPtr   - A pointer to Qh\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2068,12 +2074,12 @@ LinkQhToPeriodicList (
 Routine Description:\r
 \r
   Link Qh to Periodic Schedule List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   QhPtr   - A pointer to Qh\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
@@ -2092,17 +2098,17 @@ UnlinkQhFromPeriodicList (
 Routine Description:\r
 \r
   Unlink Qh from Periodic Schedule List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev     - USB2_HC_DEV \r
+  HcDev     - USB2_HC_DEV\r
   QhPtr     - A pointer to Qh\r
   Interval  - Interval of this periodic transfer\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2116,16 +2122,16 @@ LinkToAsyncReqeust (
 Routine Description:\r
 \r
   Llink AsyncRequest Entry to Async Request List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev           - USB2_HC_DEV \r
+  HcDev           - USB2_HC_DEV\r
   AsyncRequestPtr - A pointer to Async Request Entry\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2139,16 +2145,16 @@ UnlinkFromAsyncReqeust (
 Routine Description:\r
 \r
   Unlink AsyncRequest Entry from Async Request List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev           - USB2_HC_DEV \r
+  HcDev           - USB2_HC_DEV\r
   AsyncRequestPtr - A pointer to Async Request Entry\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2161,11 +2167,11 @@ GetNumberOfQtd (
 Routine Description:\r
 \r
   Number of Qtds in the list\r
-  \r
+\r
 Arguments:\r
 \r
   FirstQtdPtr - A pointer to first Qtd in the list\r
-    \r
+\r
 Returns:\r
 \r
   Number of Qtds in the list\r
@@ -2173,28 +2179,7 @@ Returns:
 --*/\r
 ;\r
 \r
-UINTN\r
-GetNumberOfTransaction (\r
-  IN UINTN    SizeOfData,\r
-  IN UINTN    SizeOfTransaction\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
 \r
-  Number of Transactions in one Qtd\r
-  \r
-Arguments:\r
-\r
-  SizeOfData           - Size of one Qtd\r
-  SizeOfTransaction    - Size of one Transaction\r
-   \r
-Returns:\r
-\r
-  Number of Transactions in this Qtd\r
-\r
---*/\r
-;\r
 \r
 UINTN\r
 GetCapacityOfQtd (\r
@@ -2205,11 +2190,11 @@ GetCapacityOfQtd (
 Routine Description:\r
 \r
   Get Capacity of Qtd\r
-  \r
+\r
 Arguments:\r
 \r
   BufferCursor  - BufferCursor of the Qtd\r
-   \r
+\r
 Returns:\r
 \r
   Capacity of Qtd\r
@@ -2226,15 +2211,15 @@ GetApproxiOfInterval (
 Routine Description:\r
 \r
   Get the approximate value in the 2 index sequence\r
-  \r
+\r
 Arguments:\r
 \r
   Interval - the value of interval\r
-  \r
+\r
 Returns:\r
 \r
   approximate value of interval in the 2 index sequence\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2247,15 +2232,15 @@ GetQtdNextPointer (
 Routine Description:\r
 \r
   Get Qtd next pointer field\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   A pointer to next hardware Qtd structure\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2268,16 +2253,16 @@ IsQtdStatusActive (
 Routine Description:\r
 \r
   Whether Qtd status is active or not\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   TRUE    Active\r
   FALSE   Inactive\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2290,16 +2275,16 @@ IsQtdStatusHalted (
 Routine Description:\r
 \r
   Whether Qtd status is halted or not\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r\r
 \r
   TRUE    Halted\r
   FALSE   Not halted\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2312,16 +2297,16 @@ IsQtdStatusBufferError (
 Routine Description:\r
 \r
   Whether Qtd status is buffer error or not\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   TRUE    Buffer error\r
   FALSE   No buffer error\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2334,16 +2319,16 @@ IsQtdStatusBabbleError (
 Routine Description:\r
 \r
   Whether Qtd status is babble error or not\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   TRUE    Babble error\r
   FALSE   No babble error\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2356,16 +2341,16 @@ IsQtdStatusTransactionError (
 Routine Description:\r
 \r
   Whether Qtd status is transaction error or not\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   TRUE    Transaction error\r
   FALSE   No transaction error\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2378,16 +2363,16 @@ IsDataInTransfer (
 Routine Description:\r
 \r
   Whether is a DataIn direction transfer\r
-  \r
+\r
 Arguments:\r
 \r
-  EndPointAddress - address of the endpoint \r
-  \r
+  EndPointAddress - address of the endpoint\r
+\r
 Returns:\r
 \r
   TRUE    DataIn\r
   FALSE   DataOut\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2406,22 +2391,22 @@ MapDataBuffer (
 Routine Description:\r
 \r
   Map address of user data buffer\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev             - USB2_HC_DEV \r
+  HcDev             - USB2_HC_DEV\r
   TransferDirection - direction of transfer\r
-  Data              - A pointer to user data buffer \r
+  Data              - A pointer to user data buffer\r
   DataLength        - length of user data\r
   PktId             - Packte Identificaion\r
   DataCursor        - mapped address to return\r
   DataMap           - identificaion of this mapping to return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2437,19 +2422,19 @@ MapRequestBuffer (
 Routine Description:\r
 \r
   Map address of request structure buffer\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev           - USB2_HC_DEV \r
+  HcDev           - USB2_HC_DEV\r
   Request         - A pointer to request structure\r
   RequestCursor   - Mapped address of request structure to return\r
   RequestMap      - Identificaion of this mapping to return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2467,10 +2452,10 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  QtdHwPtr  - A pointer to Qtd hardware structure \r
+  QtdHwPtr  - A pointer to Qtd hardware structure\r
   DataPtr   - A pointer to user data buffer\r
   DataLen   - Length of the user data buffer\r
-    \r
+\r
 Returns:\r
 \r
   VOID\r
@@ -2487,15 +2472,15 @@ GetQtdAlternateNextPointer (
 Routine Description:\r
 \r
   Get Qtd alternate next pointer field\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   A pointer to hardware alternate Qtd\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2508,15 +2493,15 @@ ZeroOutQhOverlay (
 Routine Description:\r
 \r
   Zero out the fields in Qh structure\r
-  \r
+\r
 Arguments:\r
 \r
   QhPtr - A pointer to Qh structure\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2531,17 +2516,17 @@ UpdateAsyncRequestTransfer (
 Routine Description:\r
 \r
   Update asynchronous request transfer\r
-  \r
+\r
 Arguments:\r
 \r
-  AsyncRequestPtr  - A pointer to async request  \r
-  TransferResult   - transfer result \r
+  AsyncRequestPtr  - A pointer to async request\r
+  TransferResult   - transfer result\r
   ErrQtdPos        - postion of error Qtd\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2558,14 +2543,14 @@ DeleteAsyncRequestTransfer (
 Routine Description:\r
 \r
   Delete all asynchronous request transfer\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev           - USB2_HC_DEV \r
+  HcDev           - USB2_HC_DEV\r
   DeviceAddress   - address of usb device\r
   EndPointAddress - address of endpoint\r
   DataToggle      - stored data toggle\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
@@ -2583,14 +2568,14 @@ CleanUpAllAsyncRequestTransfer (
 Routine Description:\r
 \r
   Clean up all asynchronous request transfer\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
   VOID\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2615,16 +2600,16 @@ Arguments:
   HcDev            - USB2_HC_DEV\r
   IsControl        - Is control transfer or not\r
   QhPtr            - A pointer to Qh\r
-  ActualLen        - Actual transfered Len \r
+  ActualLen        - Actual transfered Len\r
   DataToggle       - Data Toggle\r
   TimeOut          - TimeOut threshold\r
   TransferResult   - Transfer result\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Sucess\r
   EFI_DEVICE_ERROR   Error\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2654,7 +2639,7 @@ Returns:
 \r
   TRUE    Qtds finished\r
   FALSE   Not finish\r
-  \r
+\r
 --*/\r
 ;\r
 \r
@@ -2666,22 +2651,48 @@ AsyncRequestMoniter (
 /*++\r
 \r
 Routine Description:\r
-  \r
+\r
   Interrupt transfer periodic check handler\r
-    \r
+\r
 Arguments:\r
 \r
   Event     - Interrupt event\r
   Context   - Pointer to USB2_HC_DEV\r
-    \r
+\r
 Returns:\r
-  \r
+\r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-    \r
+\r
+--*/\r
+;\r
+\r
+\r
+EFI_STATUS\r
+CreateNULLQH (\r
+  IN  USB2_HC_DEV     *HcDev\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create the NULL QH to make it as the Async QH header\r
+\r
+Arguments:\r
+\r
+  HcDev   - USB2_HC_DEV\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS        Success\r
 --*/\r
 ;\r
 \r
+VOID\r
+DestroyNULLQH (\r
+  IN  USB2_HC_DEV     *HcDev\r
+  );\r
+\r
 VOID\r
 ClearLegacySupport (\r
   IN USB2_HC_DEV     *HcDev\r
@@ -2692,8 +2703,11 @@ HostReset (
   IN USB2_HC_DEV    *HcDev\r
   );\r
 \r
-VOID \r
+\r
+VOID\r
 DumpEHCIPortsStatus (\r
   IN USB2_HC_DEV    *HcDev\r
   );\r
+\r
+\r
 #endif\r
index aba27cb82c1f8624bda734a64fb262cd794b3557..9eef0537d0e36fb5fd17df7e9e6056fd198a50b0 100644 (file)
@@ -1,20 +1,20 @@
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
     EhciMem.c\r
-    \r
-Abstract: \r
-    \r
+\r
+Abstract:\r
+\r
 \r
 Revision History\r
 --*/\r
@@ -40,13 +40,13 @@ Arguments:
   HcDev                  - USB2_HC_DEV\r
   MemoryHeader           - MEMORY_MANAGE_HEADER to output\r
   MemoryBlockSizeInPages - MemoryBlockSizeInPages\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS           Success\r
   EFI_OUT_OF_RESOURCES  Fail for no resources\r
   EFI_UNSUPPORTED       Unsupported currently\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS            Status;\r
@@ -73,7 +73,7 @@ Returns:
   //\r
   // each bit in Bit Array will manage 32 bytes memory in memory block\r
   //\r
-  (*MemoryHeader)->BitArraySizeInBytes = ((*MemoryHeader)->MemoryBlockSizeInBytes / 32) / 8;\r
+  (*MemoryHeader)->BitArraySizeInBytes = ((*MemoryHeader)->MemoryBlockSizeInBytes / MEM_UNIT_SIZE) / 8;\r
 \r
   //\r
   // Allocate memory for BitArray\r
@@ -83,7 +83,7 @@ Returns:
     gBS->FreePool (*MemoryHeader);\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
-  \r
+\r
   //\r
   // Memory Block uses MemoryBlockSizeInPages pages,\r
   // and it is allocated as common buffer use.\r
@@ -112,7 +112,7 @@ Returns:
                            &Mapping\r
                            );\r
   //\r
-  // If returned Mapped size is less than the size \r
+  // If returned Mapped size is less than the size\r
   // we request,do not support.\r
   //\r
   if (EFI_ERROR (Status) || (MemoryBlockSizeInBytes != EFI_PAGES_TO_SIZE (MemoryBlockSizeInPages))) {\r
@@ -121,9 +121,9 @@ Returns:
     gBS->FreePool (*MemoryHeader);\r
     return EFI_UNSUPPORTED;\r
   }\r
-  \r
+\r
   //\r
-  // Data structure involved by host controller \r
+  // Data structure involved by host controller\r
   // should be restricted into the same 4G\r
   //\r
   if (HcDev->Is64BitCapable != 0) {\r
@@ -135,7 +135,7 @@ Returns:
       return EFI_UNSUPPORTED;\r
        }\r
   }\r
-  \r
+\r
   //\r
   // Set Memory block initial address\r
   //\r
@@ -240,16 +240,16 @@ Returns:
   ASSERT (MemoryHeader != NULL);\r
 \r
   OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY + 1);\r
-  \r
+\r
   //\r
   // allocate unit is 32 bytes (align on 32 byte)\r
   //\r
-  if (AllocSize & 0x1F) {\r
-    RealAllocSize = (AllocSize / 32 + 1) * 32;\r
+  if (AllocSize & (MEM_UNIT_SIZE - 1)) {\r
+    RealAllocSize = (AllocSize / MEM_UNIT_SIZE + 1) * MEM_UNIT_SIZE;\r
   } else {\r
     RealAllocSize = AllocSize;\r
   }\r
-  \r
+\r
   //\r
   // There may be linked MemoryHeaders.\r
   // To allocate a free pool in Memory blocks,\r
@@ -262,22 +262,26 @@ Returns:
     Status = AllocMemInMemoryBlock (\r
               TempHeaderPtr,\r
               (VOID **) Pool,\r
-              RealAllocSize / 32\r
+              RealAllocSize / MEM_UNIT_SIZE\r
               );\r
     if (!EFI_ERROR (Status)) {\r
-      ZeroMem (*Pool, AllocSize);\r
-      gBS->RestoreTPL (OldTpl);\r
-      return EFI_SUCCESS;\r
+       break;\r
     }\r
   }\r
 \r
   gBS->RestoreTPL (OldTpl);\r
-  \r
+\r
+  if (!EFI_ERROR (Status)) {\r
+     ZeroMem (*Pool, AllocSize);\r
+     return EFI_SUCCESS;\r
+  }\r
+\r
+\r
   //\r
   // There is no enough memory,\r
   // Create a new Memory Block\r
   //\r
-  \r
+\r
   //\r
   // if pool size is larger than NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES,\r
   // just allocate a large enough memory block.\r
@@ -303,13 +307,15 @@ Returns:
   Status = AllocMemInMemoryBlock (\r
              NewMemoryHeader,\r
              (VOID **) Pool,\r
-             RealAllocSize / 32\r
+             RealAllocSize / MEM_UNIT_SIZE\r
              );\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+\r
   if (!EFI_ERROR (Status)) {\r
     ZeroMem (*Pool, AllocSize);\r
   }\r
 \r
-  gBS->RestoreTPL (OldTpl);\r
   return Status;\r
 }\r
 \r
@@ -354,12 +360,12 @@ Returns:
   //\r
   // allocate unit is 32 byte (align on 32 byte)\r
   //\r
-  if (AllocSize & 0x1F) {\r
-    RealAllocSize = (AllocSize / 32 + 1) * 32;\r
+  if (AllocSize & (MEM_UNIT_SIZE - 1)) {\r
+    RealAllocSize = (AllocSize / MEM_UNIT_SIZE + 1) * MEM_UNIT_SIZE;\r
   } else {\r
     RealAllocSize = AllocSize;\r
   }\r
-  \r
+\r
   //\r
   // scan the memory header linked list for\r
   // the asigned memory to free.\r
@@ -373,14 +379,16 @@ Returns:
       // Pool is in the Memory Block area,\r
       // find the start byte and bit in the bit array\r
       //\r
-      StartBytePos  = ((Pool - TempHeaderPtr->MemoryBlockPtr) / 32) / 8;\r
-      StartBitPos   = (UINT8) (((Pool - TempHeaderPtr->MemoryBlockPtr) / 32) & 0x7);\r
+      StartBytePos  = ((Pool - TempHeaderPtr->MemoryBlockPtr) / MEM_UNIT_SIZE) / 8;\r
+      StartBitPos   = (UINT8) (((Pool - TempHeaderPtr->MemoryBlockPtr) / MEM_UNIT_SIZE) & 0x7);\r
 \r
       //\r
       // reset associated bits in bit arry\r
       //\r
-      for (Index = StartBytePos, Index2 = StartBitPos, Count = 0; Count < (RealAllocSize / 32); Count++) {\r
-        TempHeaderPtr->BitArrayPtr[Index] = (UINT8) (TempHeaderPtr->BitArrayPtr[Index] ^ (bit (Index2)));\r
+      for (Index = StartBytePos, Index2 = StartBitPos, Count = 0; Count < (RealAllocSize / MEM_UNIT_SIZE); Count++) {\r
+        ASSERT ((TempHeaderPtr->BitArrayPtr[Index] & bit (Index2) )== bit (Index2));\r
+\r
+        TempHeaderPtr->BitArrayPtr[Index] ^= (UINT8) (bit (Index2));\r
         Index2++;\r
         if (Index2 == 8) {\r
           Index += 1;\r
@@ -393,7 +401,7 @@ Returns:
       break;\r
     }\r
   }\r
-  \r
+\r
   //\r
   // Release emptied memory blocks (only if the memory block is not\r
   // the first one in the memory header list\r
@@ -479,7 +487,7 @@ Arguments:
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
-  EFI_NOT_FOUND  Can't find the free memory \r
+  EFI_NOT_FOUND  Can't find the free memory\r
 \r
 --*/\r
 {\r
@@ -508,7 +516,7 @@ Returns:
     //\r
     // right shift the byte\r
     //\r
-    ByteValue /= 2;\r
+    ByteValue = ByteValue >> 1;\r
 \r
     if (BitValue == 0) {\r
       //\r
@@ -564,11 +572,11 @@ Returns:
   if (NumberOfZeros < NumberOfMemoryUnit) {\r
     return EFI_NOT_FOUND;\r
   }\r
-  \r
+\r
   //\r
   // Found enough free space.\r
   //\r
-  \r
+\r
   //\r
   // The values recorded in (FoundBytePos,FoundBitPos) have two conditions:\r
   //  1)(FoundBytePos,FoundBitPos) record the position\r
@@ -581,7 +589,7 @@ Returns:
   if ((MemoryHeader->BitArrayPtr[FoundBytePos] & bit (FoundBitPos)) != 0) {\r
     FoundBitPos += 1;\r
   }\r
-  \r
+\r
   //\r
   // Have the (FoundBytePos,FoundBitPos) make sense.\r
   //\r
@@ -589,13 +597,14 @@ Returns:
     FoundBytePos += 1;\r
     FoundBitPos -= 8;\r
   }\r
-  \r
+\r
   //\r
   // Set the memory as allocated\r
   //\r
   for (TempBytePos = FoundBytePos, Index = FoundBitPos, Count = 0; Count < NumberOfMemoryUnit; Count++) {\r
 \r
-    MemoryHeader->BitArrayPtr[TempBytePos] = (UINT8) (MemoryHeader->BitArrayPtr[TempBytePos] | (bit (Index)));\r
+    ASSERT ((MemoryHeader->BitArrayPtr[TempBytePos] & bit (Index) )== 0);\r
+    MemoryHeader->BitArrayPtr[TempBytePos] |= bit (Index);\r
     Index++;\r
     if (Index == 8) {\r
       TempBytePos += 1;\r
@@ -603,7 +612,7 @@ Returns:
     }\r
   }\r
 \r
-  *Pool = MemoryHeader->MemoryBlockPtr + (FoundBytePos * 8 + FoundBitPos) * 32;\r
+  *Pool = MemoryHeader->MemoryBlockPtr + (FoundBytePos * 8 + FoundBitPos) * MEM_UNIT_SIZE;\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -625,7 +634,7 @@ Arguments:
 Returns:\r
 \r
   TRUE    Empty\r
-  FALSE   Not Empty \r
+  FALSE   Not Empty\r
 \r
 --*/\r
 {\r
@@ -675,6 +684,7 @@ Returns:
       // Link the before and after\r
       //\r
       TempHeaderPtr->Next = NeedFreeMemoryHeader->Next;\r
+      NeedFreeMemoryHeader->Next = NULL;\r
       break;\r
     }\r
   }\r
@@ -698,7 +708,7 @@ Returns:
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS            Status;\r
@@ -736,7 +746,7 @@ Returns:
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 {\r
   MEMORY_MANAGE_HEADER  *TempHeaderPtr;\r
index d5271c25b27b748930379d2b9d437e270a298437..78bca3b767d238c163ca26770e7f73b9821cd260 100644 (file)
@@ -1,20 +1,20 @@
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
     Ehchlp.c\r
-    \r
-Abstract: \r
-    \r
+\r
+Abstract:\r
+\r
 \r
 Revision History\r
 --*/\r
@@ -29,7 +29,7 @@ HostReset (
 {\r
   UINT32  Value;\r
   UINT32  TimeOut;\r
\r
+\r
   ReadEhcOperationalReg (\r
     HcDev,\r
     USBCMD,\r
@@ -102,18 +102,18 @@ ReadEhcCapabiltiyReg (
 Routine Description:\r
 \r
   Read  Ehc Capabitlity register\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev              - USB2_HC_DEV \r
+  HcDev              - USB2_HC_DEV\r
   CapabiltiyRegAddr  - Ehc Capability register address\r
   Data               - A pointer to data read from register\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-    \r
+\r
 --*/\r
 {\r
   return HcDev->PciIo->Mem.Read (\r
@@ -137,18 +137,18 @@ ReadEhcOperationalReg (
 Routine Description:\r
 \r
   Read  Ehc Operation register\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev                - USB2_HC_DEV \r
+  HcDev                - USB2_HC_DEV\r
   OperationalRegAddr   - Ehc Operation register address\r
   Data                 - A pointer to data read from register\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-    \r
+\r
 --*/\r
 {\r
   ASSERT (HcDev->UsbCapabilityLen);\r
@@ -173,18 +173,18 @@ WriteEhcOperationalReg (
 Routine Description:\r
 \r
   Write  Ehc Operation register\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev                - USB2_HC_DEV \r
+  HcDev                - USB2_HC_DEV\r
   OperationalRegAddr   - Ehc Operation register address\r
   Data                 - 32bit write to register\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 {\r
   ASSERT (HcDev->UsbCapabilityLen);\r
@@ -198,6 +198,8 @@ Returns:
                              );\r
 }\r
 \r
+\r
+\r
 VOID\r
 ClearLegacySupport (\r
   IN USB2_HC_DEV     *HcDev\r
@@ -239,7 +241,7 @@ Returns:
                      EfiPciIoWidthUint32,\r
                      EECP,\r
                      1,\r
-                     &Value \r
+                     &Value\r
                      );\r
 \r
   DEBUG((gEHCDebugLevel, "EECP[0] = 0x%x\n", Value));\r
@@ -249,7 +251,7 @@ Returns:
                      EfiPciIoWidthUint32,\r
                      EECP + 0x4,\r
                      1,\r
-                     &Value \r
+                     &Value\r
                      );\r
 \r
   DEBUG((gEHCDebugLevel, "EECP[4] = 0x%x\n", Value));\r
@@ -259,7 +261,7 @@ Returns:
                      EfiPciIoWidthUint32,\r
                      EECP,\r
                      1,\r
-                     &Value \r
+                     &Value\r
                      );\r
 \r
   Value = Value | (0x1 << 24);\r
@@ -270,7 +272,7 @@ Returns:
                      EfiPciIoWidthUint32,\r
                      EECP,\r
                      1,\r
-                     &Value \r
+                     &Value\r
                      );\r
 \r
  TimeOut = 40;\r
@@ -282,7 +284,7 @@ Returns:
                       EfiPciIoWidthUint32,\r
                       EECP,\r
                       1,\r
-                      &Value \r
+                      &Value\r
                       );\r
   if ((Value & 0x01010000) == 0x01000000) {\r
     break;\r
@@ -291,8 +293,8 @@ Returns:
 \r
   if (TimeOut == 0) {\r
     DEBUG((gEHCErrorLevel, "Timeout for getting HC OS Owned Semaphore\n" ));\r
-  } \r
-  \r
+  }\r
+\r
   DEBUG((gEHCErrorLevel, "After Release Value\n" ));\r
 \r
   HcDev->PciIo->Pci.Read (\r
@@ -300,7 +302,7 @@ Returns:
                      EfiPciIoWidthUint32,\r
                      EECP,\r
                      1,\r
-                     &Value \r
+                     &Value\r
                      );\r
 \r
   DEBUG((gEHCDebugLevel, "EECP[0] = 0x%x\n", Value));\r
@@ -310,7 +312,7 @@ Returns:
                      EfiPciIoWidthUint32,\r
                      EECP + 0x4,\r
                      1,\r
-                     &Value \r
+                     &Value\r
                      );\r
 \r
   DEBUG((gEHCDebugLevel, "EECP[4] = 0x%x\n", Value));\r
@@ -327,16 +329,16 @@ GetCapabilityLen (
 Routine Description:\r
 \r
   Get the length of capability register\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-    \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -364,18 +366,18 @@ SetFrameListLen (
 Routine Description:\r
 \r
   Set the length of Frame List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev    - USB2_HC_DEV \r
+  HcDev    - USB2_HC_DEV\r
   Length   - the required length of frame list\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_INVALID_PARAMETER  Invalid parameter\r
   EFI_DEVICE_ERROR       Fail\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -428,14 +430,14 @@ SetFrameListBaseAddr (
 Routine Description:\r
 \r
   Set base address of frame list first entry\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev        - USB2_HC_DEV \r
+  HcDev        - USB2_HC_DEV\r
   FrameBuffer  - base address of first entry of frame list\r
-  \r
+\r
 Returns:\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -474,17 +476,17 @@ SetAsyncListAddr (
 Routine Description:\r
 \r
   Set address of first Async schedule Qh\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   QhPtr   - A pointer to first Qh in the Async schedule\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-    \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -512,16 +514,16 @@ SetCtrlDataStructSeg (
 Routine Description:\r
 \r
   Set register of control and data structure segment\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev  - USB2_HC_DEV \r
-  \r
+  HcDev  - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 \r
 --*/\r
 {\r
@@ -550,16 +552,16 @@ SetPortRoutingEhc (
 Routine Description:\r
 \r
   Set Ehc port routing bit\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-    \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -601,16 +603,16 @@ SetEhcDoorbell (
 Routine Description:\r
 \r
   Set Ehc door bell bit\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-     \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -652,16 +654,16 @@ ClearEhcAllStatus (
 Routine Description:\r
 \r
   Clear Ehc all status bits\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-     \r
+\r
 --*/\r
 {\r
   UINT32  UsbStatusAddr;\r
@@ -684,16 +686,16 @@ EnablePeriodicSchedule (
 Routine Description:\r
 \r
   Enable periodic schedule\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-   \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -735,16 +737,16 @@ DisablePeriodicSchedule (
 Routine Description:\r
 \r
   Disable periodic schedule\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-   \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -784,16 +786,16 @@ EnableAsynchronousSchedule (
 Routine Description:\r
 \r
   Enable asynchrounous schedule\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-    \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -835,16 +837,16 @@ DisableAsynchronousSchedule (
 Routine Description:\r
 \r
   Disable asynchrounous schedule\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-   \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -884,16 +886,16 @@ ResetEhc (
 Routine Description:\r
 \r
   Reset Ehc\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-   \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -935,16 +937,16 @@ StartScheduleExecution (
 Routine Description:\r
 \r
   Start Ehc schedule execution\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-   \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -986,16 +988,16 @@ IsFrameListProgrammable (
 Routine Description:\r
 \r
   Whether frame list is programmable\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   Programmable\r
   FALSE  Unprogrammable\r
-  \r
+\r
 --*/\r
 {\r
   BOOLEAN Value;\r
@@ -1028,16 +1030,16 @@ IsPeriodicScheduleEnabled (
 Routine Description:\r
 \r
   Whether periodic schedule is enabled\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE    Enabled\r
   FALSE   Disabled\r
-  \r
+\r
 --*/\r
 {\r
   BOOLEAN Value;\r
@@ -1070,16 +1072,16 @@ IsAsyncScheduleEnabled (
 Routine Description:\r
 \r
   Whether asynchronous schedule is enabled\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   Enabled\r
   FALSE  Disabled\r
-  \r
+\r
 --*/\r
 {\r
   BOOLEAN Value;\r
@@ -1113,16 +1115,16 @@ IsEhcPortEnabled (
 Routine Description:\r
 \r
   Whether port is enabled\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   Enabled\r
   FALSE  Disabled\r
-  \r
+\r
 --*/\r
 {\r
   UINT32  PortStatusControlAddr;\r
@@ -1148,16 +1150,16 @@ IsEhcReseted (
 Routine Description:\r
 \r
   Whether Ehc is reseted\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   Reseted\r
   FALSE  Unreseted\r
-  \r
+\r
 --*/\r
 {\r
   BOOLEAN Value;\r
@@ -1190,16 +1192,16 @@ IsEhcHalted (
 Routine Description:\r
 \r
   Whether Ehc is halted\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   Halted\r
   FALSE  Not halted\r
-  \r
+\r
 --*/\r
 {\r
   BOOLEAN Value;\r
@@ -1232,16 +1234,16 @@ IsEhcSysError (
 Routine Description:\r
 \r
   Whether Ehc is system error\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   System error\r
   FALSE  No system error\r
-  \r
+\r
 --*/\r
 {\r
   BOOLEAN Value;\r
@@ -1268,29 +1270,29 @@ Returns:
 BOOLEAN\r
 IsHighSpeedDevice (\r
   IN EFI_USB2_HC_PROTOCOL *This,\r
-  IN UINT8                PortNum \r
+  IN UINT8                PortNum\r
   )\r
 /*++\r
 \r
 Routine Description:\r
 \r
   Whether high speed device attached\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   TRUE   High speed\r
   FALSE  Full speed\r
-  \r
+\r
 --*/\r
 {\r
   USB2_HC_DEV          *HcDev;\r
   UINT32               PortStatusControlAddr;\r
   UINT32               PortStatusControlReg;\r
-  \r
+\r
   HcDev = USB2_HC_DEV_FROM_THIS (This);\r
   PortStatusControlAddr = (UINT32) (PORTSC + (4 * PortNum));\r
 \r
@@ -1360,17 +1362,17 @@ WaitForEhcReset (
 Routine Description:\r
 \r
   wait for Ehc reset or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1406,17 +1408,17 @@ WaitForEhcHalt (
 Routine Description:\r
 \r
   wait for Ehc halt or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1452,17 +1454,17 @@ WaitForEhcNotHalt (
 Routine Description:\r
 \r
   wait for Ehc not halt or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1498,17 +1500,17 @@ WaitForAsyncScheduleEnable (
 Routine Description:\r
 \r
   Wait for Ehc asynchronous schedule enable or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1544,17 +1546,17 @@ WaitForAsyncScheduleDisable (
 Routine Description:\r
 \r
   Wait for Ehc asynchronous schedule disable or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1590,17 +1592,17 @@ WaitForPeriodicScheduleEnable (
 Routine Description:\r
 \r
   Wait for Ehc periodic schedule enable or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1636,17 +1638,17 @@ WaitForPeriodicScheduleDisable (
 Routine Description:\r
 \r
   Wait for periodic schedule disable or timeout\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1685,14 +1687,14 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev   - USB2_HC_DEV \r
+  HcDev   - USB2_HC_DEV\r
   Timeout - timeout threshold\r
 \r
 Returns:\r
 \r
   EFI_SUCCESS    Success\r
   EFI_TIMEOUT    Timeout\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1702,7 +1704,7 @@ Returns:
 \r
   UsbCommandAddr  = USBCMD;\r
   Delay           = (Timeout / 50) + 1;\r
-  \r
+\r
   do {\r
     Status = ReadEhcOperationalReg (\r
                HcDev,\r
index 48432c0b98c63cad6a880ce583f7960cd1c3e9cb..34e31a896fed5fc57f92c52fee20d20a21374201 100644 (file)
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
     EhciSched.c\r
-    \r
-Abstract: \r
-    \r
+\r
+Abstract:\r
+\r
 \r
 Revision History\r
 --*/\r
 \r
 #include "Ehci.h"\r
 \r
+\r
+EFI_STATUS\r
+SetAndWaitDoorBell (\r
+  IN  USB2_HC_DEV     *HcDev,\r
+  IN  UINTN           Timeout\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set DoorBell and wait it to complete\r
+\r
+Arguments:\r
+\r
+  HcDev - USB2_HC_DEV\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS       Success\r
+  EFI_DEVICE_ERROR  Fail\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      Data;\r
+  UINTN       Delay;\r
+\r
+  Status = ReadEhcOperationalReg (\r
+             HcDev,\r
+             USBCMD,\r
+             &Data\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    Status = EFI_DEVICE_ERROR;\r
+    goto exit;\r
+  }\r
+\r
+  Data |= USBCMD_IAAD;\r
+  Status = WriteEhcOperationalReg (\r
+             HcDev,\r
+             USBCMD,\r
+             Data\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    Status = EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  //\r
+  // Timeout is in US unit\r
+  //\r
+  Delay = (Timeout / 50) + 1;\r
+  do {\r
+    Status = ReadEhcOperationalReg (\r
+               HcDev,\r
+               USBSTS,\r
+               &Data\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      Status = EFI_DEVICE_ERROR;\r
+      goto exit;\r
+    }\r
+\r
+    if ((Data & USBSTS_IAA) == USBSTS_IAA) {\r
+      break;\r
+    }\r
+\r
+    gBS->Stall (EHCI_GENERIC_RECOVERY_TIME);\r
+\r
+  } while (Delay--);\r
+\r
+  Data = Data & 0xFFFFFFC0;\r
+  Data |= USBSTS_IAA;\r
+  Status = WriteEhcOperationalReg (\r
+             HcDev,\r
+             USBSTS,\r
+             Data\r
+             );\r
+\r
+exit:\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+\r
+\r
+EFI_STATUS\r
+CreateNULLQH (\r
+  IN  USB2_HC_DEV     *HcDev\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create the NULL QH to make it as the Async QH header\r
+\r
+Arguments:\r
+\r
+  HcDev   - USB2_HC_DEV\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS        Success\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EHCI_QH_ENTITY        *NULLQhPtr;\r
+  //\r
+  // Allocate  memory for Qh structure\r
+  //\r
+  Status = EhciAllocatePool (\r
+             HcDev,\r
+             (UINT8 **) &NULLQhPtr,\r
+             sizeof (EHCI_QH_ENTITY)\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+     return Status;\r
+  }\r
+\r
+  NULLQhPtr->Qh.Status = QTD_STATUS_HALTED;\r
+  NULLQhPtr->Qh.HeadReclamationFlag = 1;\r
+  NULLQhPtr->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&(NULLQhPtr->Qh) >> 5));\r
+  NULLQhPtr->Qh.SelectType = QH_SELECT_TYPE;\r
+  NULLQhPtr->Qh.NextQtdTerminate = 1;\r
+\r
+  NULLQhPtr->Next = NULLQhPtr;\r
+  NULLQhPtr->Prev = NULLQhPtr;\r
+\r
+  HcDev->NULLQH = NULLQhPtr;\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+VOID\r
+DestroyNULLQH (\r
+  IN  USB2_HC_DEV     *HcDev\r
+  )\r
+{\r
+\r
+  if (HcDev->NULLQH != NULL) {\r
+    EhciFreePool (HcDev, (UINT8 *)HcDev->NULLQH, sizeof (EHCI_QH_ENTITY));\r
+    HcDev->NULLQH = NULL;\r
+  }\r
+}\r
+\r
+\r
+\r
 EFI_STATUS\r
 InitialPeriodicFrameList (\r
   IN  USB2_HC_DEV     *HcDev,\r
@@ -36,7 +185,7 @@ Arguments:
 \r
   HcDev   - USB2_HC_DEV\r
   Length  - Frame List Length\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
@@ -52,7 +201,7 @@ Returns:
   UINTN                 BufferSizeInBytes;\r
   UINTN                 FrameIndex;\r
   FRAME_LIST_ENTRY      *FrameEntryPtr;\r
-  \r
+\r
   //\r
   // The Frame List is a common buffer that will be\r
   // accessed by both the cpu and the usb bus master\r
@@ -99,7 +248,7 @@ Returns:
   }\r
 \r
   //\r
-  // Put high 32bit into CtrlDataStructSeg reg \r
+  // Put high 32bit into CtrlDataStructSeg reg\r
   // when 64bit addressing range capability\r
   //\r
   if (HcDev->Is64BitCapable != 0) {\r
@@ -112,7 +261,7 @@ Returns:
       goto unmap_buffer;\r
     }\r
   }\r
-  \r
+\r
   //\r
   // Tell the Host Controller where the Frame List lies,\r
   // by set the Frame List Base Address Register.\r
@@ -166,7 +315,7 @@ Arguments:
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 {\r
   HcDev->PciIo->Unmap (HcDev->PciIo, HcDev->PeriodicFrameListMap);\r
@@ -189,12 +338,12 @@ Arguments:
 \r
   HcDev          - USB2_HC_DEV\r
   NotifyFunction - Timer Notify Function\r
-  \r
+\r
 Returns:\r
-  \r
+\r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 {\r
   return gBS->CreateEvent (\r
@@ -219,12 +368,12 @@ Routine Description:
 Arguments:\r
 \r
   HcDev - USB2_HC_DEV\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 {\r
   return gBS->CloseEvent (HcDev->AsyncRequestEvent);\r
@@ -243,12 +392,12 @@ Routine Description:
 Arguments:\r
 \r
   HcDev - USB2_HC_DEV\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 {\r
   return gBS->SetTimer (\r
@@ -271,12 +420,12 @@ Routine Description:
 Arguments:\r
 \r
   HcDev - USB2_HC_DEV\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 {\r
   return gBS->SetTimer (\r
@@ -303,18 +452,18 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev        - USB2_HC_DEV \r
+  HcDev        - USB2_HC_DEV\r
   DeviceAddr   - Address of Device\r
   Endpoint     - Endpoint Number\r
   DeviceSpeed  - Device Speed\r
   MaxPacketLen - Max Length of one Packet\r
   QhPtrPtr     - A pointer of pointer to Qh for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -337,10 +486,6 @@ Returns:
     Status = EFI_OUT_OF_RESOURCES;\r
     goto exit;\r
   }\r
-  //\r
-  // Init fields in Qh\r
-  //\r
-  ZeroMem (*QhPtrPtr, sizeof (EHCI_QH_ENTITY));\r
 \r
   //\r
   // Software field\r
@@ -359,8 +504,8 @@ Returns:
   QhHwPtr->SelectType           = 0;\r
   QhHwPtr->MaxPacketLen         = (UINT32) MaxPacketLen;\r
   QhHwPtr->EndpointSpeed        = (DeviceSpeed & 0x3);\r
-  QhHwPtr->EndpointNum          = (Endpoint & 0x0f);\r
-  QhHwPtr->DeviceAddr           = (DeviceAddr & 0x7f);\r
+  QhHwPtr->EndpointNum          = (Endpoint & 0x0F);\r
+  QhHwPtr->DeviceAddr           = (DeviceAddr & 0x7F);\r
   QhHwPtr->Multiplier           = HIGH_BANDWIDTH_PIPE_MULTIPLIER;\r
   QhHwPtr->Rsvd1                = 0;\r
   QhHwPtr->Rsvd2                = 0;\r
@@ -382,18 +527,18 @@ DestoryQh (
 \r
 Routine Description:\r
 \r
-  Destory Qh Structure \r
-  \r
+  Destory Qh Structure\r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
+  HcDev - USB2_HC_DEV\r
   QhPtr - A pointer to Qh\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 {\r
   ASSERT (HcDev);\r
@@ -420,18 +565,18 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev        - USB2_HC_DEV \r
+  HcDev        - USB2_HC_DEV\r
   DeviceAddr   - Address of Device\r
   DeviceSpeed  - Device Speed\r
   MaxPacketLen - Max Length of one Packet\r
   Translator   - Translator Transaction for SplitX\r
   QhPtrPtr     - A pointer of pointer to Qh for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -467,7 +612,9 @@ Returns:
   (*QhPtrPtr)->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&((*QhPtrPtr)->Qh)) >> 5);\r
   (*QhPtrPtr)->Qh.SelectType          = QH_SELECT_TYPE;\r
   (*QhPtrPtr)->Qh.QhTerminate         = FALSE;\r
-  (*QhPtrPtr)->Qh.ControlEndpointFlag = TRUE;\r
+  if (EFI_USB_SPEED_HIGH != DeviceSpeed)  {\r
+    (*QhPtrPtr)->Qh.ControlEndpointFlag = TRUE;\r
+  }\r
   (*QhPtrPtr)->Qh.NakCountReload      = NAK_COUNT_RELOAD;\r
   if (NULL != Translator) {\r
     (*QhPtrPtr)->Qh.PortNum = Translator->TranslatorPortNumber;\r
@@ -498,19 +645,19 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev        - USB2_HC_DEV \r
+  HcDev        - USB2_HC_DEV\r
   DeviceAddr   - Address of Device\r
   EndPointAddr - Address of Endpoint\r
   DeviceSpeed  - Device Speed\r
   MaxPacketLen - Max Length of one Packet\r
   Translator   - Translator Transaction for SplitX\r
   QhPtrPtr     - A pointer of pointer to Qh for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -530,7 +677,7 @@ Returns:
     Status = EFI_OUT_OF_RESOURCES;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Software fields\r
   //\r
@@ -543,7 +690,7 @@ Returns:
   //\r
   // BulkTransfer don't use DataToggleControl\r
   //\r
-  (*QhPtrPtr)->Qh.DataToggleControl   = FALSE;  \r
+  (*QhPtrPtr)->Qh.DataToggleControl   = FALSE;\r
   (*QhPtrPtr)->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&((*QhPtrPtr)->Qh)) >> 5);\r
   (*QhPtrPtr)->Qh.SelectType          = QH_SELECT_TYPE;\r
   (*QhPtrPtr)->Qh.QhTerminate         = FALSE;\r
@@ -579,7 +726,7 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev        - USB2_HC_DEV \r
+  HcDev        - USB2_HC_DEV\r
   DeviceAddr   - Address of Device\r
   EndPointAddr - Address of Endpoint\r
   DeviceSpeed  - Device Speed\r
@@ -587,12 +734,12 @@ Arguments:
   Interval     - value of interval\r
   Translator   - Translator Transaction for SplitX\r
   QhPtrPtr     - A pointer of pointer to Qh for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -612,7 +759,7 @@ Returns:
     Status = EFI_OUT_OF_RESOURCES;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Software fields\r
   //\r
@@ -663,19 +810,19 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev       - USB2_HC_DEV \r
+  HcDev       - USB2_HC_DEV\r
   DataPtr     - A pointer to user data buffer to transfer\r
   DataLen     - Length of user data to transfer\r
   PktId       - Packet Identification of this Qtd\r
   Toggle      - Data Toggle of this Qtd\r
   QtdStatus   - Default value of status of this Qtd\r
   QtdPtrPtr   - A pointer of pointer to Qtd for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -696,11 +843,6 @@ Returns:
     Status = EFI_OUT_OF_RESOURCES;\r
     goto exit;\r
   }\r
-  //\r
-  // Init fields in Qtd\r
-  //\r
-\r
-  ZeroMem (*QtdPtrPtr, sizeof (EHCI_QTD_ENTITY));\r
 \r
   //\r
   // Software field\r
@@ -750,7 +892,7 @@ Returns:
     Status = EFI_INVALID_PARAMETER;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   // Set Data Buffer Pointers\r
   //\r
@@ -777,19 +919,19 @@ CreateSetupQtd (
 \r
 Routine Description:\r
 \r
-  Create Qtd Structure for Setup \r
+  Create Qtd Structure for Setup\r
 \r
 Arguments:\r
 \r
-  HcDev      - USB2_HC_DEV \r
+  HcDev      - USB2_HC_DEV\r
   DevReqPtr  - A pointer to Device Request Data\r
   QtdPtrPtr  - A pointer of pointer to Qtd for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 {\r
   return CreateQtd (\r
@@ -816,22 +958,22 @@ CreateDataQtd (
 \r
 Routine Description:\r
 \r
-  Create Qtd Structure for data \r
+  Create Qtd Structure for data\r
 \r
 Arguments:\r
 \r
-  HcDev       - USB2_HC_DEV \r
+  HcDev       - USB2_HC_DEV\r
   DataPtr     - A pointer to user data buffer to transfer\r
   DataLen     - Length of user data to transfer\r
   PktId       - Packet Identification of this Qtd\r
   Toggle      - Data Toggle of this Qtd\r
   QtdPtrPtr   - A pointer of pointer to Qtd for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 {\r
   return CreateQtd (\r
@@ -855,19 +997,19 @@ CreateAltQtd (
 \r
 Routine Description:\r
 \r
-  Create Qtd Structure for Alternative \r
+  Create Qtd Structure for Alternative\r
 \r
 Arguments:\r
 \r
-  HcDev      - USB2_HC_DEV \r
+  HcDev      - USB2_HC_DEV\r
   PktId      - Packet Identification of this Qtd\r
   QtdPtrPtr  - A pointer of pointer to Qtd for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 {\r
   return CreateQtd (\r
@@ -891,19 +1033,19 @@ CreateStatusQtd (
 \r
 Routine Description:\r
 \r
-  Create Qtd Structure for status \r
+  Create Qtd Structure for status\r
 \r
 Arguments:\r
 \r
-  HcDev       - USB2_HC_DEV \r
+  HcDev       - USB2_HC_DEV\r
   PktId       - Packet Identification of this Qtd\r
   QtdPtrPtr   - A pointer of pointer to Qtd for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 {\r
   return CreateQtd (\r
@@ -931,22 +1073,22 @@ CreateControlQtds (
 \r
 Routine Description:\r
 \r
-  Create Qtds list for Control Transfer \r
+  Create Qtds list for Control Transfer\r
 \r
 Arguments:\r
 \r
-  HcDev           - USB2_HC_DEV \r
+  HcDev           - USB2_HC_DEV\r
   DataPktId       - Packet Identification of Data Qtds\r
   RequestCursor   - A pointer to request structure buffer to transfer\r
   DataCursor      - A pointer to user data buffer to transfer\r
   DataLen         - Length of user data to transfer\r
   ControlQtdsHead - A pointer of pointer to first Qtd for control tranfer for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS      Status;\r
@@ -961,8 +1103,7 @@ Returns:
   UINTN           CapacityOfQtd;\r
   UINTN           SizePerQtd;\r
   UINTN           DataCount;\r
-  UINTN           Xnum;\r
-  \r
+\r
   QtdPtr          = NULL;\r
   PreQtdPtr       = NULL;\r
   SetupQtdPtr     = NULL;\r
@@ -983,7 +1124,7 @@ Returns:
     Status = EFI_OUT_OF_RESOURCES;\r
     goto exit;\r
   }\r
-  \r
+\r
   //\r
   //  Data Stage of Control Transfer\r
   //\r
@@ -1026,14 +1167,8 @@ Returns:
       LinkQtdToQtd (PreQtdPtr, QtdPtr);\r
     }\r
 \r
-    //\r
-    // Reverse Data Toggle or not determined by parity of transactions of one qtd\r
-    //\r
-    Xnum = Translator ? GetNumberOfTransaction (SizePerQtd, EHCI_BLOCK_SIZE_WITH_TT) : GetNumberOfTransaction (SizePerQtd, EHCI_BLOCK_SIZE);\r
-    if (Xnum % 2 != 0) {\r
-      DataToggle ^= 1;\r
-    }\r
-    \r
+    DataToggle ^= 1;\r
+\r
     PreQtdPtr = QtdPtr;\r
     DataCursor += SizePerQtd;\r
     DataCount -= SizePerQtd;\r
@@ -1059,7 +1194,7 @@ Returns:
     Status = EFI_OUT_OF_RESOURCES;\r
     goto destory_qtds;\r
   }\r
-  \r
+\r
   //\r
   // Link setup Qtd -> data Qtds -> status Qtd\r
   //\r
@@ -1095,23 +1230,23 @@ CreateBulkOrInterruptQtds (
 \r
 Routine Description:\r
 \r
-  Create Qtds list for Bulk or Interrupt Transfer \r
+  Create Qtds list for Bulk or Interrupt Transfer\r
 \r
 Arguments:\r
 \r
-  HcDev        - USB2_HC_DEV \r
+  HcDev        - USB2_HC_DEV\r
   PktId        - Packet Identification of Qtds\r
   DataCursor   - A pointer to user data buffer to transfer\r
   DataLen      - Length of user data to transfer\r
   DataToggle   - Data Toggle to start\r
   Translator   - Translator Transaction for SplitX\r
   QtdsHead     - A pointer of pointer to first Qtd for control tranfer for return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS            Success\r
   EFI_OUT_OF_RESOURCES   Cannot allocate resources\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS      Status;\r
@@ -1166,11 +1301,11 @@ Returns:
     DataCursor += SizePerQtd;\r
     DataCount -= SizePerQtd;\r
   }\r
-  \r
+\r
   //\r
   // Set Alternate Qtd\r
   //\r
-  if (INPUT_PACKET_ID == PktId && 1 < GetNumberOfQtd (FirstQtdPtr)) {\r
+  if (INPUT_PACKET_ID == PktId && 0 < GetNumberOfQtd (FirstQtdPtr)) {\r
     Status = CreateAltQtd (\r
               HcDev,\r
               PktId,\r
@@ -1206,9 +1341,9 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  HcDev         - USB2_HC_DEV \r
-  FirstQtdPtr   - A pointer to first Qtd in the list \r
-    \r
+  HcDev         - USB2_HC_DEV\r
+  FirstQtdPtr   - A pointer to first Qtd in the list\r
+\r
 Returns:\r
 \r
   VOID\r
@@ -1246,11 +1381,11 @@ GetNumberOfQtd (
 Routine Description:\r
 \r
   Number of Qtds in the list\r
-  \r
+\r
 Arguments:\r
 \r
   FirstQtdPtr - A pointer to first Qtd in the list\r
-    \r
+\r
 Returns:\r
 \r
   Number of Qtds in the list\r
@@ -1262,8 +1397,6 @@ Returns:
   Count   = 0;\r
   QtdPtr  = FirstQtdPtr;\r
 \r
-  ;\r
-\r
   while (NULL != QtdPtr) {\r
     Count++;\r
     QtdPtr = QtdPtr->Next;\r
@@ -1272,33 +1405,6 @@ Returns:
   return Count;\r
 }\r
 \r
-UINTN\r
-GetNumberOfTransaction (\r
-  IN UINTN    SizeOfData,\r
-  IN UINTN    SizeOfTransaction\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Number of Transactions in one Qtd\r
-  \r
-Arguments:\r
-\r
-  SizeOfData           - Size of one Qtd\r
-  SizeOfTransaction    - Size of one Transaction\r
-   \r
-Returns:\r
-\r
-  Number of Transactions in this Qtd\r
-\r
---*/\r
-{\r
-\r
-  return ((SizeOfData & (SizeOfTransaction - 1)) ? SizeOfData / SizeOfTransaction + 1 : SizeOfData / SizeOfTransaction);\r
-\r
-}\r
-\r
 UINTN\r
 GetCapacityOfQtd (\r
   IN UINT8    *BufferCursor\r
@@ -1308,11 +1414,11 @@ GetCapacityOfQtd (
 Routine Description:\r
 \r
   Get Size of First Qtd\r
-  \r
+\r
 Arguments:\r
 \r
   BufferCursor       - BufferCursor of the Qtd\r
-   \r
+\r
 Returns:\r
 \r
   Size of First Qtd\r
@@ -1320,7 +1426,11 @@ Returns:
 --*/\r
 {\r
 \r
-  return (EHCI_MAX_QTD_CAPACITY - (EHCI_BLOCK_SIZE * GetNumberOfTransaction (EFI_PAGE_MASK & GET_0B_TO_31B (BufferCursor), EHCI_BLOCK_SIZE)));\r
+ if (EFI_PAGE_MASK & GET_0B_TO_31B (BufferCursor)) {\r
+   return EFI_PAGE_SIZE * 4;\r
+ } else {\r
+   return EFI_PAGE_SIZE * 5;\r
+ }\r
 \r
 }\r
 \r
@@ -1333,15 +1443,15 @@ GetApproxiOfInterval (
 Routine Description:\r
 \r
   Get the approximate value in the 2 index sequence\r
-  \r
+\r
 Arguments:\r
 \r
   Interval  - the value of interval\r
-  \r
+\r
 Returns:\r
 \r
   approximate value of interval in the 2 index sequence\r
-  \r
+\r
 --*/\r
 {\r
   UINTN Orignate;\r
@@ -1371,15 +1481,15 @@ GetQtdAlternateNextPointer (
 Routine Description:\r
 \r
   Get Qtd alternate next pointer field\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   A pointer to hardware alternate Qtd\r
-  \r
+\r
 --*/\r
 {\r
   EHCI_QTD_HW *Value;\r
@@ -1402,15 +1512,15 @@ GetQtdNextPointer (
 Routine Description:\r
 \r
   Get Qtd next pointer field\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   A pointer to next hardware Qtd structure\r
-  \r
+\r
 --*/\r
 {\r
   EHCI_QTD_HW *Value;\r
@@ -1424,8 +1534,9 @@ Returns:
   return Value;\r
 }\r
 \r
-VOID LinkQtdToQtd (\r
-  IN EHCI_QTD_ENTITY * PreQtdPtr, \r
+VOID\r
+LinkQtdToQtd (\r
+  IN EHCI_QTD_ENTITY * PreQtdPtr,\r
   IN EHCI_QTD_ENTITY * QtdPtr\r
   )\r
 /*++\r
@@ -1433,12 +1544,12 @@ VOID LinkQtdToQtd (
 Routine Description:\r
 \r
   Link Qtds together\r
-  \r
+\r
 Arguments:\r
 \r
   PreQtdPtr   - A pointer to pre Qtd\r
   QtdPtr      - A pointer to next Qtd\r
-    \r
+\r
 Returns:\r
 \r
   VOID\r
@@ -1467,8 +1578,9 @@ Returns:
 }\r
 \r\r
 \r
-VOID LinkQtdsToAltQtd (\r
-  IN EHCI_QTD_ENTITY  * FirstQtdPtr, \r
+VOID\r
+LinkQtdsToAltQtd (\r
+  IN EHCI_QTD_ENTITY  * FirstQtdPtr,\r
   IN EHCI_QTD_ENTITY  * AltQtdPtr\r
   )\r
 /*++\r
@@ -1476,12 +1588,12 @@ VOID LinkQtdsToAltQtd (
 Routine Description:\r
 \r
   Link AlterQtds together\r
-  \r
+\r
 Arguments:\r
 \r
   FirstQtdPtr  - A pointer to first Qtd in the list\r
   AltQtdPtr    - A pointer to alternative Qtd\r
-    \r
+\r
 Returns:\r
 \r
   VOID\r
@@ -1496,7 +1608,7 @@ Returns:
 \r
   AltQtdHwPtr = &(AltQtdPtr->Qtd);\r
   QtdPtr      = FirstQtdPtr;\r
-  \r
+\r
   while (NULL != QtdPtr) {\r
     //\r
     // Software link\r
@@ -1523,12 +1635,12 @@ LinkQtdToQh (
 Routine Description:\r
 \r
   Link Qtds list to Qh\r
-  \r
+\r
 Arguments:\r
 \r
   QhPtr    - A pointer to Qh\r
   QtdPtr   - A pointer to first Qtd in the list\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
@@ -1560,6 +1672,18 @@ Returns:
   QhPtr->Qh.NextQtdPointer    = (UINT32) (GET_0B_TO_31B (QtdHwPtr) >> 5);\r
   QhPtr->Qh.NextQtdTerminate  = FALSE;\r
 \r
+  QhPtr->Qh.AltNextQtdPointer    = 0;\r
+  QhPtr->Qh.AltNextQtdTerminate  = TRUE;\r
+\r
+\r
+  if ((QtdPtr->Qtd.PidCode == OUTPUT_PACKET_PID_CODE) &&\r
+      (QhPtr->TransferType == BULK_TRANSFER)) {\r
+      //\r
+      //Start PING first\r
+      //\r
+      QhPtr->Qh.Status |= QTD_STATUS_DO_PING;\r
+    }\r
+\r
   return ;\r
 }\r
 \r
@@ -1573,17 +1697,17 @@ LinkQhToAsyncList (
 Routine Description:\r
 \r
   Link Qh to Async Schedule List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev  - USB2_HC_DEV \r
+  HcDev  - USB2_HC_DEV\r
   QhPtr  - A pointer to Qh\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1591,9 +1715,23 @@ Returns:
   ASSERT (HcDev);\r
   ASSERT (QhPtr);\r
 \r
-  QhPtr->Qh.HeadReclamationFlag = TRUE;\r
 \r
-  Status                        = SetAsyncListAddr (HcDev, QhPtr);\r
+  //\r
+  // NULL QH created before\r
+  //\r
+\r
+  HcDev->NULLQH->Next = QhPtr;\r
+  HcDev->NULLQH->Prev = QhPtr;\r
+\r
+  QhPtr->Next = HcDev->NULLQH;\r
+  QhPtr->Prev = HcDev->NULLQH;\r
+\r
+\r
+  HcDev->NULLQH->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&(QhPtr->Qh) >> 5));\r
+  QhPtr->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&(HcDev->NULLQH->Qh) >> 5));\r
+\r
+\r
+  Status = SetAsyncListAddr (HcDev, HcDev->NULLQH);\r
   if (EFI_ERROR (Status)) {\r
     Status = EFI_DEVICE_ERROR;\r
     goto exit;\r
@@ -1609,7 +1747,7 @@ Returns:
 \r
     Status = WaitForAsyncScheduleEnable (HcDev, EHCI_GENERIC_TIMEOUT);\r
     if (EFI_ERROR (Status)) {\r
-      DEBUG ((gEHCDebugLevel, "WaitForAsyncScheduleEnable TimeOut"));\r
+      DEBUG ((gEHCDebugLevel, "EHCI: WaitForAsyncScheduleEnable TimeOut"));\r
       Status = EFI_TIMEOUT;\r
       goto exit;\r
     }\r
@@ -1637,17 +1775,17 @@ UnlinkQhFromAsyncList (
 Routine Description:\r
 \r
   Unlink Qh from Async Schedule List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev  - USB2_HC_DEV \r
+  HcDev  - USB2_HC_DEV\r
   QhPtr  - A pointer to Qh\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS       Success\r
   EFI_DEVICE_ERROR  Fail\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -1657,23 +1795,37 @@ Returns:
   ASSERT (HcDev);\r
   ASSERT (QhPtr);\r
 \r
-  if (QhPtr == QhPtr->Next) {\r
 \r
-    Status = DisableAsynchronousSchedule (HcDev);\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto exit;\r
-    }\r
+  HcDev->NULLQH->Next = HcDev->NULLQH;\r
+  HcDev->NULLQH->Prev = HcDev->NULLQH;\r
 \r
-    Status = WaitForAsyncScheduleDisable (HcDev, EHCI_GENERIC_TIMEOUT);\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((gEHCErrorLevel, "WaitForAsyncScheduleDisable TimeOut\n"));\r
-      Status = EFI_TIMEOUT;\r
-      goto exit;\r
-    }\r
 \r
+  QhPtr->Next = QhPtr;\r
+  QhPtr->Prev = QhPtr;\r
+\r
+  HcDev->NULLQH->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&(HcDev->NULLQH->Qh) >> 5));\r
+\r
+\r
+  SetAndWaitDoorBell (HcDev, 2 * EHCI_GENERIC_TIMEOUT);\r
+\r
+  QhPtr->Qh.QhTerminate         = 1;\r
+  QhPtr->Qh.QhHorizontalPointer = 0;\r
+\r
+\r
+  Status = DisableAsynchronousSchedule (HcDev);\r
+  if (EFI_ERROR (Status)) {\r
+    Status = EFI_DEVICE_ERROR;\r
+    goto exit;\r
   }\r
 \r
+  Status = WaitForAsyncScheduleDisable (HcDev, EHCI_GENERIC_TIMEOUT);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((gEHCErrorLevel, "EHCI: WaitForAsyncScheduleDisable TimeOut\n"));\r
+    Status = EFI_TIMEOUT;\r
+    goto exit;\r
+  }\r
+\r
+\r
 exit:\r
   return Status;\r
 }\r
@@ -1688,16 +1840,16 @@ LinkQhToPeriodicList (
 Routine Description:\r
 \r
   Link Qh to Periodic Schedule List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev  - USB2_HC_DEV \r
+  HcDev  - USB2_HC_DEV\r
   QhPtr  - A pointer to Qh\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 {\r
   FRAME_LIST_ENTRY  *FrameEntryPtr;\r
@@ -1720,7 +1872,7 @@ Returns:
     //\r
     // AsyncInterruptTransfer Qh\r
     //\r
-    \r
+\r
     //\r
     // Link to Frame[0] List\r
     //\r
@@ -1835,11 +1987,11 @@ Returns:
       }\r
     }\r
   } else {\r
-  \r
+\r
     //\r
     // SyncInterruptTransfer Qh\r
     //\r
-    \r
+\r
     if (!FrameEntryPtr->LinkTerminate) {\r
       //\r
       // Not Null FrameList\r
@@ -1883,17 +2035,17 @@ UnlinkQhFromPeriodicList (
 Routine Description:\r
 \r
   Unlink Qh from Periodic Schedule List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev     - USB2_HC_DEV \r
+  HcDev     - USB2_HC_DEV\r
   QhPtr     - A pointer to Qh\r
   Interval  - Interval of this periodic transfer\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 {\r
   FRAME_LIST_ENTRY  *FrameEntryPtr;\r
@@ -1908,11 +2060,11 @@ Returns:
   FrameEntryPtr = (FRAME_LIST_ENTRY *) HcDev->PeriodicFrameListBuffer;\r
 \r
   if (QhPtr->TransferType == ASYNC_INTERRUPT_TRANSFER) {\r
-  \r
+\r
     //\r
     // AsyncInterruptTransfer Qh\r
     //\r
-    \r
+\r
     if (NULL == QhPtr->Prev) {\r
       //\r
       // Qh is the First one on  Frame[0] List\r
@@ -1938,7 +2090,7 @@ Returns:
         }\r
       }\r
     } else {\r
-    \r
+\r
       //\r
       // Not First one on  Frame[0] List\r
       //\r
@@ -2018,16 +2170,16 @@ LinkToAsyncReqeust (
 Routine Description:\r
 \r
   Llink AsyncRequest Entry to Async Request List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev             - USB2_HC_DEV \r
+  HcDev             - USB2_HC_DEV\r
   AsyncRequestPtr   - A pointer to Async Request Entry\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 {\r
   EHCI_ASYNC_REQUEST  *CurrentPtr;\r
@@ -2054,16 +2206,16 @@ UnlinkFromAsyncReqeust (
 Routine Description:\r
 \r
   Unlink AsyncRequest Entry from Async Request List\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev            - USB2_HC_DEV \r
+  HcDev            - USB2_HC_DEV\r
   AsyncRequestPtr  - A pointer to Async Request Entry\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 {\r
   if (NULL == AsyncRequestPtr->Prev) {\r
@@ -2095,10 +2247,10 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  QtdHwPtr  - A pointer to Qtd hardware structure \r
+  QtdHwPtr  - A pointer to Qtd hardware structure\r
   DataPtr   - A pointer to user data buffer\r
   DataLen   - Length of the user data buffer\r
-    \r
+\r
 Returns:\r
 \r
   VOID\r
@@ -2107,21 +2259,20 @@ Returns:
 {\r
   UINTN RemainLen;\r
 \r
-  RemainLen = DataLen;\r
   ASSERT (QtdHwPtr);\r
+  ASSERT (DataLen <= 5 * EFI_PAGE_SIZE);\r
 \r
+  RemainLen = DataLen;\r
   //\r
   // Allow buffer address range across 4G.\r
   // But EFI_USB_MAX_BULK_BUFFER_NUM = 1, so don't allow\r
   // seperate buffer array.\r
   //\r
-\r
   //\r
   // Set BufferPointer0, ExtBufferPointer0 and Offset\r
   //\r
-  QtdHwPtr->BufferPointer0    = (UINT32) (GET_0B_TO_31B (DataPtr) >> 12);\r
+  QtdHwPtr->BufferPointer0    = (UINT32) (GET_0B_TO_31B (DataPtr) >> EFI_PAGE_SHIFT);\r
   QtdHwPtr->CurrentOffset     = (UINT32) (GET_0B_TO_31B (DataPtr) & EFI_PAGE_MASK);\r
-  QtdHwPtr->ExtBufferPointer0 = (UINT32) GET_32B_TO_63B (DataPtr);\r
 \r
   //\r
   // Set BufferPointer1 and ExtBufferPointer1\r
@@ -2132,7 +2283,6 @@ Returns:
   }\r
 \r
   QtdHwPtr->BufferPointer1    = QtdHwPtr->BufferPointer0 + 1;\r
-  QtdHwPtr->ExtBufferPointer1 = (QtdHwPtr->BufferPointer1 == 0) ? (QtdHwPtr->ExtBufferPointer0 + 1) : QtdHwPtr->ExtBufferPointer0;\r
 \r
   //\r
   // Set BufferPointer2 and ExtBufferPointer2\r
@@ -2143,7 +2293,6 @@ Returns:
   }\r
 \r
   QtdHwPtr->BufferPointer2    = QtdHwPtr->BufferPointer1 + 1;\r
-  QtdHwPtr->ExtBufferPointer2 = (QtdHwPtr->BufferPointer2 == 0) ? (QtdHwPtr->ExtBufferPointer1 + 1) : QtdHwPtr->ExtBufferPointer1;\r
 \r
   //\r
   // Set BufferPointer3 and ExtBufferPointer3\r
@@ -2154,7 +2303,6 @@ Returns:
   }\r
 \r
   QtdHwPtr->BufferPointer3    = QtdHwPtr->BufferPointer2 + 1;\r
-  QtdHwPtr->ExtBufferPointer3 = (QtdHwPtr->BufferPointer2 == 0) ? (QtdHwPtr->ExtBufferPointer2 + 1) : QtdHwPtr->ExtBufferPointer2;\r
 \r
   //\r
   // Set BufferPointer4 and ExtBufferPointer4\r
@@ -2165,7 +2313,6 @@ Returns:
   }\r
 \r
   QtdHwPtr->BufferPointer4    = QtdHwPtr->BufferPointer3 + 1;\r
-  QtdHwPtr->ExtBufferPointer4 = (QtdHwPtr->BufferPointer3 == 0) ? (QtdHwPtr->ExtBufferPointer3 + 1) : QtdHwPtr->ExtBufferPointer3;\r
 \r
 exit:\r
   return ;\r
@@ -2180,16 +2327,16 @@ IsQtdStatusActive (
 Routine Description:\r
 \r
   Whether Qtd status is active or not\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   TRUE    Active\r
   FALSE   Inactive\r
-  \r
+\r
 --*/\r
 {\r
   UINT8   QtdStatus;\r
@@ -2197,6 +2344,7 @@ Returns:
 \r
   QtdStatus = (UINT8) (HwQtdPtr->Status);\r
   Value     = (BOOLEAN) (QtdStatus & QTD_STATUS_ACTIVE);\r
+  //DEBUG ((gEHCErrorLevel, "EHCI: IsQtdStatusActive 0x%X, Address = %x\r\n",HwQtdPtr->Status, HwQtdPtr));\r
 \r
   return Value;\r
 }\r
@@ -2210,16 +2358,16 @@ IsQtdStatusHalted (
 Routine Description:\r
 \r
   Whether Qtd status is halted or not\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   TRUE    Halted\r
   FALSE   Not halted\r
-  \r
+\r
 --*/\r
 {\r
   UINT8   QtdStatus;\r
@@ -2240,16 +2388,16 @@ IsQtdStatusBufferError (
 Routine Description:\r
 \r
   Whether Qtd status is buffer error or not\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   TRUE    Buffer error\r
   FALSE   No buffer error\r
-  \r
+\r
 --*/\r
 {\r
   UINT8   QtdStatus;\r
@@ -2270,16 +2418,16 @@ IsQtdStatusBabbleError (
 Routine Description:\r
 \r
   Whether Qtd status is babble error or not\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   TRUE    Babble error\r
   FALSE   No babble error\r
-  \r
+\r
 --*/\r
 {\r
   UINT8   QtdStatus;\r
@@ -2300,16 +2448,16 @@ IsQtdStatusTransactionError (
 Routine Description:\r
 \r
   Whether Qtd status is transaction error or not\r
-  \r
+\r
 Arguments:\r
 \r
   HwQtdPtr - A pointer to hardware Qtd structure\r
-  \r
+\r
 Returns:\r
 \r
   TRUE    Transaction error\r
   FALSE   No transaction error\r
-  \r
+\r
 --*/\r
 {\r
   UINT8   QtdStatus;\r
@@ -2330,16 +2478,16 @@ IsDataInTransfer (
 Routine Description:\r
 \r
   Whether is a DataIn direction transfer\r
-  \r
+\r
 Arguments:\r
 \r
-  EndPointAddress - address of the endpoint \r
-  \r
+  EndPointAddress - address of the endpoint\r
+\r
 Returns:\r
 \r
   TRUE    DataIn\r
   FALSE   DataOut\r
-  \r
+\r
 --*/\r
 {\r
   BOOLEAN Value;\r
@@ -2368,22 +2516,22 @@ MapDataBuffer (
 Routine Description:\r
 \r
   Map address of user data buffer\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev              - USB2_HC_DEV \r
+  HcDev              - USB2_HC_DEV\r
   TransferDirection  - direction of transfer\r
-  Data               - A pointer to user data buffer \r
+  Data               - A pointer to user data buffer\r
   DataLength         - length of user data\r
   PktId              - Packte Identificaion\r
   DataCursor         - mapped address to return\r
   DataMap            - identificaion of this mapping to return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-    \r
+\r
 --*/\r
 {\r
   EFI_STATUS            Status;\r
@@ -2408,7 +2556,7 @@ Returns:
                             DataMap\r
                             );\r
     if (EFI_ERROR (Status)) {\r
-      DEBUG ((gEHCDebugLevel, "MapDataBuffer Failed\n"));\r
+      DEBUG ((gEHCDebugLevel, "EHCI: MapDataBuffer Failed\n"));\r
       Status = EFI_DEVICE_ERROR;\r
       goto exit;\r
     }\r
@@ -2468,19 +2616,19 @@ MapRequestBuffer (
 Routine Description:\r
 \r
   Map address of request structure buffer\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev           - USB2_HC_DEV \r
+  HcDev           - USB2_HC_DEV\r
   Request         - A pointer to request structure\r
   RequestCursor   - Mapped address of request structure to return\r
   RequestMap      - Identificaion of this mapping to return\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-    \r
+\r
 --*/\r
 {\r
   EFI_STATUS            Status;\r
@@ -2519,19 +2667,19 @@ DeleteAsyncRequestTransfer (
 Routine Description:\r
 \r
   Delete all asynchronous request transfer\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev           - USB2_HC_DEV \r
+  HcDev           - USB2_HC_DEV\r
   DeviceAddress   - address of usb device\r
   EndPointAddress - address of endpoint\r
   DataToggle      - stored data toggle\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-    \r
+\r
 --*/\r
 {\r
   EFI_STATUS          Status;\r
@@ -2578,7 +2726,7 @@ Returns:
 \r
   Status = WaitForPeriodicScheduleDisable (HcDev, EHCI_GENERIC_TIMEOUT);\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((gEHCErrorLevel, "WaitForPeriodicScheduleDisable TimeOut\n"));\r
+    DEBUG ((gEHCErrorLevel, "EHCI: WaitForPeriodicScheduleDisable TimeOut\n"));\r
     Status = EFI_TIMEOUT;\r
     goto exit;\r
   }\r
@@ -2605,7 +2753,7 @@ Returns:
 \r
     Status = WaitForPeriodicScheduleEnable (HcDev, EHCI_GENERIC_TIMEOUT);\r
     if (EFI_ERROR (Status)) {\r
-      DEBUG ((gEHCErrorLevel, "WaitForPeriodicScheduleEnable TimeOut\n"));\r
+      DEBUG ((gEHCErrorLevel, "EHCI: WaitForPeriodicScheduleEnable TimeOut\n"));\r
       Status = EFI_TIMEOUT;\r
       goto exit;\r
     }\r
@@ -2637,15 +2785,15 @@ CleanUpAllAsyncRequestTransfer (
 Routine Description:\r
 \r
   Clean up all asynchronous request transfer\r
-  \r
+\r
 Arguments:\r
 \r
-  HcDev - USB2_HC_DEV \r
-  \r
+  HcDev - USB2_HC_DEV\r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 {\r
   EHCI_ASYNC_REQUEST  *AsyncRequestPtr;\r
@@ -2681,15 +2829,15 @@ ZeroOutQhOverlay (
 Routine Description:\r
 \r
   Zero out the fields in Qh structure\r
-  \r
+\r
 Arguments:\r
 \r
   QhPtr - A pointer to Qh structure\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 {\r
   QhPtr->Qh.CurrentQtdPointer   = 0;\r
@@ -2711,11 +2859,6 @@ Returns:
   QhPtr->Qh.FrameTag            = 0;\r
   QhPtr->Qh.BufferPointer3      = 0;\r
   QhPtr->Qh.BufferPointer4      = 0;\r
-  QhPtr->Qh.ExtBufferPointer0   = 0;\r
-  QhPtr->Qh.ExtBufferPointer1   = 0;\r
-  QhPtr->Qh.ExtBufferPointer2   = 0;\r
-  QhPtr->Qh.ExtBufferPointer3   = 0;\r
-  QhPtr->Qh.ExtBufferPointer4   = 0;\r
 }\r
 \r
 VOID\r
@@ -2729,17 +2872,17 @@ UpdateAsyncRequestTransfer (
 Routine Description:\r
 \r
   Update asynchronous request transfer\r
-  \r
+\r
 Arguments:\r
 \r
-  AsyncRequestPtr  - A pointer to async request  \r
-  TransferResult   - transfer result \r
+  AsyncRequestPtr  - A pointer to async request\r
+  TransferResult   - transfer result\r
   ErrQtdPos        - postion of error Qtd\r
-  \r
+\r
 Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 {\r
   EHCI_QTD_ENTITY *QtdPtr;\r
@@ -2747,7 +2890,7 @@ Returns:
   QtdPtr      = NULL;\r
 \r
   if (EFI_USB_NOERROR == TransferResult) {\r
-  \r
+\r
     //\r
     // Update Qh for next trigger\r
     //\r
@@ -2811,7 +2954,7 @@ Returns:
 \r
   TRUE    Qtds finished\r
   FALSE   Not finish\r
-  \r
+\r
 --*/\r
 {\r
   UINTN           ActualLenPerQtd;\r
@@ -2829,25 +2972,37 @@ Returns:
   QtdHwPtr  = &(QtdPtr->Qtd);\r
 \r
   while (NULL != QtdHwPtr) {\r
-\r
     if (IsQtdStatusActive (QtdHwPtr)) {\r
       *Result |= EFI_USB_ERR_NOTEXECUTE;\r
     }\r
 \r
     if (IsQtdStatusHalted (QtdHwPtr)) {\r
+\r
+      DEBUG ((gEHCErrorLevel, "EHCI: QTD_STATUS_HALTED 0x%X\n", QtdHwPtr->Status));\r
       *Result |= EFI_USB_ERR_STALL;\r
     }\r
 \r
     if (IsQtdStatusBufferError (QtdHwPtr)) {\r
+      DEBUG ((gEHCErrorLevel, "EHCI: QTD_STATUS_BUFFER_ERR 0x%X\n", QtdHwPtr->Status));\r
       *Result |= EFI_USB_ERR_BUFFER;\r
     }\r
 \r
     if (IsQtdStatusBabbleError (QtdHwPtr)) {\r
+      DEBUG ((gEHCErrorLevel, "EHCI: StatusBufferError 0x%X\n", QtdHwPtr->Status));\r
       *Result |= EFI_USB_ERR_BABBLE;\r
     }\r
 \r
     if (IsQtdStatusTransactionError (QtdHwPtr)) {\r
-      *Result |= EFI_USB_ERR_TIMEOUT;\r
+\r
+      //\r
+      //Exclude Special Case\r
+      //\r
+      if (((QtdHwPtr->Status & QTD_STATUS_HALTED) == QTD_STATUS_HALTED) ||\r
+          ((QtdHwPtr->Status & QTD_STATUS_ACTIVE) == QTD_STATUS_ACTIVE) ||\r
+          ((QtdHwPtr->ErrorCount != QTD_ERROR_COUNTER))) {\r
+        *Result |= EFI_USB_ERR_TIMEOUT;\r
+        DEBUG ((gEHCErrorLevel, "EHCI: QTD_STATUS_TRANSACTION_ERR: 0x%X\n", QtdHwPtr->Status));\r
+      }\r
     }\r
 \r
     ActualLenPerQtd     = QtdPtr->TotalBytes - QtdHwPtr->TotalBytes;\r
@@ -2864,16 +3019,21 @@ Returns:
       break;\r
     }\r
 \r
-    if ((!IsControl) && (QtdPtr->TotalBytes > 0)) {\r
+    if ((INPUT_PACKET_PID_CODE == QtdHwPtr->PidCode)&& (QtdPtr->TotalBytes > 0)) {\r
       //\r
-      // Did something, but isn't full workload\r
+      // Short Packet: IN, Short\r
       //\r
+      DEBUG ((gEHCDebugLevel, "EHCI: Short Packet Status: 0x%x\n", QtdHwPtr->Status));\r
       break;\r
     }\r
 \r
-    (*ErrQtdPos)++;\r
-    QtdPtr   = QtdPtr->Next;\r
-    QtdHwPtr = &(QtdPtr->Qtd);\r
+    if (QtdPtr->Next != NULL) {\r
+      (*ErrQtdPos)++;\r
+      QtdPtr   = QtdPtr->Next;\r
+      QtdHwPtr = &(QtdPtr->Qtd);\r
+    } else {\r
+      QtdHwPtr = NULL;\r
+    }\r
 \r
   }\r
 \r
@@ -2901,16 +3061,16 @@ Arguments:
   HcDev            - USB2_HC_DEV\r
   IsControl        - Is control transfer or not\r
   QhPtr            - A pointer to Qh\r
-  ActualLen        - Actual transfered Len \r
+  ActualLen        - Actual transfered Len\r
   DataToggle       - Data Toggle\r
   TimeOut          - TimeOut threshold\r
   TransferResult   - Transfer result\r
-  \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS      Sucess\r
   EFI_DEVICE_ERROR Fail\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS  Status;\r
@@ -2924,7 +3084,7 @@ Returns:
   *ActualLen      = 0;\r
   Finished        = FALSE;\r
 \r
-  Delay           = (TimeOut * STALL_1_MILLI_SECOND / 50) + 1;\r
+  Delay           = (TimeOut * STALL_1_MILLI_SECOND / 50);\r
 \r
   do {\r
     *TransferResult = 0;\r
@@ -2951,6 +3111,7 @@ Returns:
 \r
   if (EFI_USB_NOERROR != *TransferResult) {\r
     if (0 == Delay) {\r
+      DEBUG((gEHCErrorLevel, "EHCI: QTDS TimeOut\n"));\r
       Status = EFI_TIMEOUT;\r
     } else {\r
       Status = EFI_DEVICE_ERROR;\r
@@ -2961,7 +3122,7 @@ Returns:
   // Special for Bulk and Interrupt Transfer\r
   //\r
   *DataToggle = (UINT8) QhPtr->Qh.DataToggle;\r
-  \r
+\r
   return Status;\r
 }\r
 \r
@@ -2972,30 +3133,30 @@ AsyncRequestMoniter (
   )\r
 /*++\r
 Routine Description:\r
-  \r
+\r
   Interrupt transfer periodic check handler\r
-    \r
+\r
 Arguments:\r
   Event    - Interrupt event\r
   Context  - Pointer to USB2_HC_DEV\r
-    \r
+\r
 Returns:\r
 \r
   EFI_SUCCESS        Success\r
   EFI_DEVICE_ERROR   Fail\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS          Status;\r
   USB2_HC_DEV         *HcDev;\r
   EHCI_ASYNC_REQUEST  *AsyncRequestPtr;\r
+  EHCI_ASYNC_REQUEST  *NextPtr;\r
   EHCI_QTD_HW         *QtdHwPtr;\r
   UINTN               ErrQtdPos;\r
   UINTN               ActualLen;\r
   UINT32              TransferResult;\r
   UINT8               *ReceiveBuffer;\r
   UINT8               *ProcessBuffer;\r
-  EHCI_ASYNC_REQUEST  *NextPtr;\r
 \r
   Status          = EFI_SUCCESS;\r
   QtdHwPtr        = NULL;\r
@@ -3011,10 +3172,10 @@ Returns:
     ActualLen       = 0;\r
 \r
     CheckQtdsTransferResult (\r
-      FALSE, \r
-      AsyncRequestPtr->QhPtr, \r
-      &TransferResult, \r
-      &ErrQtdPos, \r
+      FALSE,\r
+      AsyncRequestPtr->QhPtr,\r
+      &TransferResult,\r
+      &ErrQtdPos,\r
       &ActualLen\r
       );\r
 \r
@@ -3032,7 +3193,7 @@ Returns:
     }\r
 \r
     QtdHwPtr = &(AsyncRequestPtr->QhPtr->FirstQtdPtr->Qtd);\r
-    ReceiveBuffer = (UINT8 *) GET_0B_TO_31B ((QtdHwPtr->BufferPointer0 << 12) | AsyncRequestPtr->QhPtr->FirstQtdPtr->StaticCurrentOffset);\r
+    ReceiveBuffer = (UINT8 *) GET_0B_TO_31B ((QtdHwPtr->BufferPointer0 << EFI_PAGE_SHIFT) | AsyncRequestPtr->QhPtr->FirstQtdPtr->StaticCurrentOffset);\r
     CopyMem (\r
       ProcessBuffer,\r
       ReceiveBuffer,\r
@@ -3052,7 +3213,7 @@ Returns:
     } else {\r
 \r
       //\r
-      // leave error recovery to its related device driver. A common case of \r
+      // leave error recovery to its related device driver. A common case of\r
       // the error recovery is to re-submit the interrupt transfer.\r
       // When an interrupt transfer is re-submitted, its position in the linked\r
       // list is changed. It is inserted to the head of the linked list, while\r
index 3d81d2c5c375eeb0504f7dd5237f0cc08ba6743b..7e033df2dffd5e91702b898e65f3d5f8210d3d9e 100644 (file)
@@ -485,6 +485,7 @@ UHCIDriverBindingStart (
   UINTN                   FlBaseAddrReg; \r
   EFI_PCI_IO_PROTOCOL     *PciIo; \r
   USB_HC_DEV              *HcDev;\r
+  UINT64                  Supports;\r
   \r
   HcDev = NULL;\r
 \r
@@ -510,10 +511,19 @@ UHCIDriverBindingStart (
   //\r
   Status = PciIo->Attributes (\r
                     PciIo,\r
-                    EfiPciIoAttributeOperationEnable,\r
-                    EFI_PCI_DEVICE_ENABLE,\r
-                    NULL\r
+                    EfiPciIoAttributeOperationSupported,\r
+                    0,\r
+                    &Supports\r
                     );\r
+  if (!EFI_ERROR (Status)) {\r
+    Supports &= EFI_PCI_DEVICE_ENABLE;\r
+    Status = PciIo->Attributes (\r
+                      PciIo,\r
+                      EfiPciIoAttributeOperationEnable,\r
+                      Supports,\r
+                      NULL\r
+                      );\r
+  }\r
   if (EFI_ERROR (Status)) {\r
     gBS->CloseProtocol (\r
            Controller,\r
@@ -777,6 +787,8 @@ UnInstallUHCInterface (
 --*/\r
 {\r
   USB_HC_DEV  *HcDev;\r
+  EFI_STATUS  Status;\r
+  UINT64      Supports;\r
 \r
   HcDev = USB_HC_DEV_FROM_THIS (This);\r
 \r
@@ -823,12 +835,21 @@ UnInstallUHCInterface (
   //\r
   // Disable the USB Host Controller\r
   //\r
-  HcDev->PciIo->Attributes (\r
-                  HcDev->PciIo,\r
-                  EfiPciIoAttributeOperationDisable,\r
-                  EFI_PCI_DEVICE_ENABLE,\r
-                  NULL\r
-                  );\r
+  Status = HcDev->PciIo->Attributes (\r
+                           HcDev->PciIo,\r
+                           EfiPciIoAttributeOperationSupported,\r
+                           0,\r
+                           &Supports\r
+                           );\r
+  if (!EFI_ERROR (Status)) {\r
+    Supports &= EFI_PCI_DEVICE_ENABLE;\r
+    Status = HcDev->PciIo->Attributes (\r
+                             HcDev->PciIo,\r
+                             EfiPciIoAttributeOperationDisable,\r
+                             Supports,\r
+                             NULL\r
+                             );\r
+  }\r
 \r
   gBS->FreePool (HcDev);\r
 \r
index 34ab75864f0c5ecee3d0bb8a4e8245db30ef3dd3..ca4228583adfdae7e8b17ed2a1be3e3eda4f6c3e 100644 (file)
@@ -1,13 +1,13 @@
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
@@ -70,21 +70,21 @@ UsbBotComponentNameGetDriverName (
   Arguments:\r
     This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
     Language   - A pointer to a three character ISO 639-2 language identifier.\r
-                 This is the language of the driver name that that the caller \r
+                 This is the language of the driver name that that the caller\r
                  is requesting, and it must match one of the languages specified\r
-                 in SupportedLanguages.  The number of languages supported by a \r
+                 in SupportedLanguages.  The number of languages supported by a\r
                  driver is up to the driver writer.\r
     DriverName - A pointer to the Unicode string to return.  This Unicode string\r
-                 is the name of the driver specified by This in the language \r
+                 is the name of the driver specified by This in the language\r
                  specified by Language.\r
 \r
   Returns:\r
     EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
-                            and the language specified by Language was returned \r
+                            and the language specified by Language was returned\r
                             in DriverName.\r
     EFI_INVALID_PARAMETER - Language is NULL.\r
     EFI_INVALID_PARAMETER - DriverName is NULL.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the\r
                             language specified by Language.\r
 \r
 --*/\r
@@ -114,39 +114,39 @@ UsbBotComponentNameGetControllerName (
 \r
   Arguments:\r
     This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
-    ControllerHandle - The handle of a controller that the driver specified by \r
-                       This is managing.  This handle specifies the controller \r
+    ControllerHandle - The handle of a controller that the driver specified by\r
+                       This is managing.  This handle specifies the controller\r
                        whose name is to be returned.\r
-    ChildHandle      - The handle of the child controller to retrieve the name \r
-                       of.  This is an optional parameter that may be NULL.  It \r
-                       will be NULL for device drivers.  It will also be NULL \r
-                       for a bus drivers that wish to retrieve the name of the \r
-                       bus controller.  It will not be NULL for a bus driver \r
+    ChildHandle      - The handle of the child controller to retrieve the name\r
+                       of.  This is an optional parameter that may be NULL.  It\r
+                       will be NULL for device drivers.  It will also be NULL\r
+                       for a bus drivers that wish to retrieve the name of the\r
+                       bus controller.  It will not be NULL for a bus driver\r
                        that wishes to retrieve the name of a child controller.\r
-    Language         - A pointer to a three character ISO 639-2 language \r
-                       identifier.  This is the language of the controller name \r
+    Language         - A pointer to a three character ISO 639-2 language\r
+                       identifier.  This is the language of the controller name\r
                        that that the caller is requesting, and it must match one\r
-                       of the languages specified in SupportedLanguages.  The \r
-                       number of languages supported by a driver is up to the \r
+                       of the languages specified in SupportedLanguages.  The\r
+                       number of languages supported by a driver is up to the\r
                        driver writer.\r
     ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
-                       string is the name of the controller specified by \r
+                       string is the name of the controller specified by\r
                        ControllerHandle and ChildHandle in the language specified\r
                        by Language from the point of view of the driver specified\r
-                       by This. \r
+                       by This.\r
 \r
   Returns:\r
-    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
-                            language specified by Language for the driver \r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the\r
+                            language specified by Language for the driver\r
                             specified by This was returned in DriverName.\r
     EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
     EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
     EFI_INVALID_PARAMETER - Language is NULL.\r
     EFI_INVALID_PARAMETER - ControllerName is NULL.\r
-    EFI_UNSUPPORTED       - The driver specified by This is not currently managing \r
-                            the controller specified by ControllerHandle and \r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently managing\r
+                            the controller specified by ControllerHandle and\r
                             ChildHandle.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the\r
                             language specified by Language.\r
 \r
 --*/\r
index acba154842dc24047047665867ca3d49a65fa73f..37b316f875d74556a5bb00f325f21af54b3817d3 100644 (file)
@@ -1,13 +1,13 @@
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
@@ -19,6 +19,8 @@ Abstract:
 \r
 #include "bot.h"\r
 \r
+GLOBAL_REMOVE_IF_UNREFERENCED UINT32     gBOTDebugLevel  = EFI_D_INFO;\r
+GLOBAL_REMOVE_IF_UNREFERENCED UINT32     gBOTErrorLevel  = EFI_D_INFO;\r
 //\r
 // Function prototypes\r
 //\r
@@ -85,7 +87,7 @@ STATIC
 EFI_STATUS\r
 BotDataPhase (\r
   IN     USB_BOT_DEVICE            *UsbBotDev,\r
-  IN     UINT32                    *DataSize,\r
+  IN     UINT                    *DataSize,\r
   IN OUT VOID                      *DataBuffer,\r
   IN     EFI_USB_DATA_DIRECTION    Direction,\r
   IN     UINT16                    Timeout\r
@@ -94,11 +96,10 @@ BotDataPhase (
 STATIC\r
 EFI_STATUS\r
 BotStatusPhase (\r
-  IN  USB_BOT_DEVICE      *UsbBotDev,\r
-  OUT UINT8               *TransferStatus,\r
-  IN  UINT16              Timeout\r
+  IN  USB_BOT_DEVICE          *UsbBotDev,\r
+  OUT UINT32                  *DataResidue, \r
+  IN  UINT16                  Timeout\r
   );\r
-\r
 //\r
 // USB Atapi protocol prototype\r
 //\r
@@ -193,7 +194,7 @@ BotDriverBindingSupported (
   //\r
   // Check if it is a BOT type Mass Storage Device\r
   //\r
-  if ((InterfaceDescriptor.InterfaceClass    != 0x08) ||\r
+  if ((InterfaceDescriptor.InterfaceClass    != MASS_STORAGE_CLASS) ||\r
       (InterfaceDescriptor.InterfaceProtocol != BOT)) {\r
     Status = EFI_UNSUPPORTED;\r
     goto Exit;\r
@@ -431,7 +432,7 @@ BotDriverBindingStop (
 \r
   Returns:\r
     EFI_SUCCESS       - This driver is removed DeviceHandle\r
-    EFI_UNSUPPORTED   - Can't open the gEfiUsbAtapiProtocolGuid protocl  \r
+    EFI_UNSUPPORTED   - Can't open the gEfiUsbAtapiProtocolGuid protocl\r
     other             - This driver was not removed from this device\r
 \r
 --*/\r
@@ -513,6 +514,38 @@ BotDriverBindingStop (
   return Status;\r
 }\r
 \r
+\r
+\r
+STATIC\r
+EFI_STATUS\r
+ClearBulkInPipe (\r
+  IN  USB_BOT_DEVICE          *UsbBotDev\r
+  )\r
+{\r
+ UINT32   Result;\r
+\r
+ return UsbClearEndpointHalt (\r
+          UsbBotDev->UsbIo,\r
+          UsbBotDev->BulkInEndpointDescriptor->EndpointAddress,\r
+          &Result\r
+          );\r
+}\r
+\r
+\r
+STATIC\r
+EFI_STATUS\r
+ClearBulkOutPipe  (\r
+  IN  USB_BOT_DEVICE          *UsbBotDev\r
+  )\r
+{\r
+ UINT32   Result;\r
+ return UsbClearEndpointHalt (\r
+          UsbBotDev->UsbIo,\r
+          UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress,\r
+          &Result\r
+          );\r
+}\r
+\r
 STATIC\r
 EFI_STATUS\r
 BotRecoveryReset (\r
@@ -530,17 +563,12 @@ Arguments:
 \r
 Returns:\r
   EFI_SUCCESS - Success the operation\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS              Status;\r
-  UINT32                  Result;\r
   EFI_USB_DEVICE_REQUEST  Request;\r
-  EFI_USB_IO_PROTOCOL     *UsbIo;\r
-  UINT8                   EndpointAddr;\r
-\r
-  UsbIo = UsbBotDev->UsbIo;\r
-\r
+  UINT32                  Result;\r
   BotReportStatusCode (\r
     UsbBotDev->DevicePath,\r
     EFI_PROGRESS_CODE,\r
@@ -555,43 +583,24 @@ Returns:
   Request.RequestType = 0x21;\r
   Request.Request     = 0xFF;\r
 \r
-  Status = UsbIo->UsbControlTransfer (\r
-                    UsbIo,\r
-                    &Request,\r
-                    EfiUsbNoData,\r
-                    TIMEOUT_VALUE,\r
-                    NULL,\r
-                    0,\r
-                    &Result\r
-                    );\r
+  Status = UsbBotDev->UsbIo->UsbControlTransfer (\r
+                               UsbBotDev->UsbIo,\r
+                               &Request,\r
+                               EfiUsbNoData,\r
+                               TIMEOUT_VALUE,\r
+                               NULL,\r
+                               0,\r
+                               &Result\r
+                               );\r
 \r
   gBS->Stall (100 * 1000);\r
 \r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // clear bulk in endpoint stall feature\r
-    //\r
-    EndpointAddr = UsbBotDev->BulkInEndpointDescriptor->EndpointAddress;\r
-\r
-    Status = UsbClearEndpointHalt (\r
-               UsbIo,\r
-               EndpointAddr,\r
-               &Result\r
-               );\r
-\r
-    //\r
-    // clear bulk out endpoint stall feature\r
-    //\r
-    EndpointAddr = UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress;\r
-    Status = UsbClearEndpointHalt (\r
-               UsbIo,\r
-               EndpointAddr,\r
-               &Result\r
-               );\r
-  }\r
+  ClearBulkInPipe (UsbBotDev);\r
+  ClearBulkOutPipe (UsbBotDev);\r
 \r
   return Status;\r
 }\r
+\r
 //\r
 // Bot Protocol Implementation\r
 //\r
@@ -639,7 +648,17 @@ BotCommandPhase (
   cbw.dCBWSignature           = CBWSIG;\r
   cbw.dCBWTag                 = 0x01;\r
   cbw.dCBWDataTransferLength  = DataTransferLength;\r
-  cbw.bmCBWFlags              = (UINT8) (Direction << 7);\r
+  switch (Direction) {\r
+  case EfiUsbDataOut:\r
+  case EfiUsbNoData:\r
+    cbw.bmCBWFlags            = 0;\r
+    break;\r
+  case EfiUsbDataIn:\r
+    cbw.bmCBWFlags            = 0x80;\r
+    break;\r
+  default:\r
+    break;\r
+  }\r
   cbw.bCBWCBLength            = CommandSize;\r
 \r
   CopyMem (cbw.CBWCB, Command, CommandSize);\r
@@ -648,28 +667,20 @@ BotCommandPhase (
 \r
   Status = UsbIo->UsbBulkTransfer (\r
                     UsbIo,\r
-                    (UsbBotDev->BulkOutEndpointDescriptor)->EndpointAddress,\r
+                    UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress,\r
                     &cbw,\r
                     &DataSize,\r
                     Timeout,\r
                     &Result\r
                     );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Command phase fail, we need to recovery reset this device\r
-    //\r
-    BotRecoveryReset (UsbBotDev);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r
 \r
 STATIC\r
 EFI_STATUS\r
 BotDataPhase (\r
   IN      USB_BOT_DEVICE            *UsbBotDev,\r
-  IN      UINT32                    *DataSize,\r
+  IN      UINT                    *DataSize,\r
   IN  OUT VOID                      *DataBuffer,\r
   IN      EFI_USB_DATA_DIRECTION    Direction,\r
   IN      UINT16                    Timeout\r
@@ -695,125 +706,52 @@ BotDataPhase (
   UINT32              Result;\r
   EFI_USB_IO_PROTOCOL *UsbIo;\r
   UINT8               EndpointAddr;\r
-  UINTN               Remain;\r
-  UINTN               Increment;\r
-  UINT32              MaxPacketLen;\r
   UINT8               *BufferPtr;\r
-  UINTN               TransferredSize;\r
-  UINTN               RetryTimes;\r
-  UINTN               MaxRetry;\r
-  UINTN               BlockSize;\r
-  UINTN               PackageNum;\r
 \r
   UsbIo           = UsbBotDev->UsbIo;\r
-  Remain          = *DataSize;\r
   BufferPtr       = (UINT8 *) DataBuffer;\r
-  TransferredSize = 0;\r
-  MaxRetry        = 10;\r
-  PackageNum      = 128;\r
 \r
   //\r
   // retrieve the the max packet length of the given endpoint\r
   //\r
   if (Direction == EfiUsbDataIn) {\r
-    MaxPacketLen  = (UsbBotDev->BulkInEndpointDescriptor)->MaxPacketSize;\r
-    EndpointAddr  = (UsbBotDev->BulkInEndpointDescriptor)->EndpointAddress;\r
+    EndpointAddr  = UsbBotDev->BulkInEndpointDescriptor->EndpointAddress;\r
   } else {\r
-    MaxPacketLen  = (UsbBotDev->BulkOutEndpointDescriptor)->MaxPacketSize;\r
-    EndpointAddr  = (UsbBotDev->BulkOutEndpointDescriptor)->EndpointAddress;\r
+    EndpointAddr  = UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress;\r
   }\r
 \r
-  RetryTimes  = MaxRetry;\r
-  BlockSize   = PackageNum * MaxPacketLen;\r
-  while (Remain > 0) {\r
-    //\r
-    // Using 15 packets to aVOID Bitstuff error\r
-    //\r
-    if (Remain > PackageNum * MaxPacketLen) {\r
-      Increment = BlockSize;\r
-    } else {\r
-      Increment = Remain;\r
-    }\r
-\r
     Status = UsbIo->UsbBulkTransfer (\r
                       UsbIo,\r
                       EndpointAddr,\r
                       BufferPtr,\r
-                      &Increment,\r
-                      Timeout,\r
+                      DataSize,\r
+                      (UINT16)(Timeout),\r
                       &Result\r
                       );\r
 \r
-    TransferredSize += Increment;\r
-\r
     if (EFI_ERROR (Status)) {\r
-      RetryTimes--;\r
-      if ((RetryTimes == 0) || ((Result & EFI_USB_ERR_TIMEOUT) == 0)) {\r
-        goto ErrorExit;\r
+      if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {\r
+        if (Direction == EfiUsbDataIn) {\r
+          DEBUG((gBOTErrorLevel, "BOT: Data IN Stall, ClearBulkInPipe\n"));\r
+          ClearBulkInPipe (UsbBotDev);\r
+        } else {\r
+          DEBUG((gBOTErrorLevel, "BOT: Data OUT Stall, ClearBulkInPipe\n"));\r
+          ClearBulkOutPipe (UsbBotDev);\r
+        }\r
       }\r
+     // BotRecoveryReset (UsbBotDev);\r
+   }\r
 \r
-      TransferredSize -= Increment;\r
-      continue;\r
-    } else {\r
-      //\r
-      // we try MaxTetry times for every bulk transfer\r
-      //\r
-      RetryTimes = MaxRetry;\r
-    }\r
-\r
-    BufferPtr += Increment;\r
-    Remain -= Increment;\r
-    if (Increment < BlockSize && TransferredSize <= *DataSize) {\r
-      //\r
-      // we get to the end of transter and transter size is\r
-      // less than requriedsize\r
-      //\r
-      break;\r
-    }\r
-  }\r
-\r
-  *DataSize = (UINT32) TransferredSize;\r
-\r
-  return EFI_SUCCESS;\r
-\r
-ErrorExit:\r
-  if (Direction == EfiUsbDataIn) {\r
-    BotReportStatusCode (\r
-      UsbBotDev->DevicePath,\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      (EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_INPUT_ERROR)\r
-      );\r
-  } else {\r
-    BotReportStatusCode (\r
-      UsbBotDev->DevicePath,\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      (EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_OUTPUT_ERROR)\r
-      );\r
-  }\r
-\r
-  if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {\r
-    //\r
-    // just endpoint stall happens\r
-    //\r
-    UsbClearEndpointHalt (\r
-      UsbIo,\r
-      EndpointAddr,\r
-      &Result\r
-      );\r
-  }\r
-\r
-  *DataSize = (UINT32) TransferredSize;\r
 \r
   return Status;\r
-\r
 }\r
 \r
 STATIC\r
 EFI_STATUS\r
 BotStatusPhase (\r
-  IN  USB_BOT_DEVICE        *UsbBotDev,\r
-  OUT UINT8                 *TransferStatus,\r
-  IN  UINT16                Timeout\r
+  IN  USB_BOT_DEVICE          *UsbBotDev,\r
+  OUT UINT32                  *DataResidue,\r
+  IN  UINT16                  Timeout\r
   )\r
 /*++\r
 \r
@@ -822,7 +760,6 @@ BotStatusPhase (
 \r
   Parameters:\r
     UsbBotDev       -  USB_BOT_DEVICE pointer\r
-    TransferStatus  -  TransferStatus\r
     Timeout         -  Time out value in milliseconds\r
   Return Value:\r
     EFI_SUCCESS\r
@@ -832,47 +769,21 @@ BotStatusPhase (
 {\r
   CSW                 csw;\r
   EFI_STATUS          Status;\r
-  UINT32              Result;\r
   EFI_USB_IO_PROTOCOL *UsbIo;\r
   UINT8               EndpointAddr;\r
   UINTN               DataSize;\r
+  UINT32              Result;\r
+  UINT8               Index;\r
 \r
   UsbIo = UsbBotDev->UsbIo;\r
+  EndpointAddr  = UsbBotDev->BulkInEndpointDescriptor->EndpointAddress;\r
 \r
-  ZeroMem (&csw, sizeof (CSW));\r
-\r
-  EndpointAddr  = (UsbBotDev->BulkInEndpointDescriptor)->EndpointAddress;\r
-\r
-  DataSize      = sizeof (CSW);\r
-\r
-  //\r
-  // Get the status field from bulk transfer\r
-  //\r
-  Status = UsbIo->UsbBulkTransfer (\r
-                    UsbIo,\r
-                    EndpointAddr,\r
-                    &csw,\r
-                    &DataSize,\r
-                    Timeout,\r
-                    &Result\r
-                    );\r
-  if (EFI_ERROR (Status)) {\r
-    if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {\r
-      //\r
-      // just endpoint stall happens\r
-      //\r
-      UsbClearEndpointHalt (\r
-        UsbIo,\r
-        EndpointAddr,\r
-        &Result\r
-        );\r
-    }\r
 \r
+  for (Index = 0; Index < 3; Index ++) {\r
     ZeroMem (&csw, sizeof (CSW));\r
+    DataSize    = sizeof (CSW);\r
+    Result      = 0;\r
 \r
-    EndpointAddr  = (UsbBotDev->BulkInEndpointDescriptor)->EndpointAddress;\r
-\r
-    DataSize      = sizeof (CSW);\r
     Status = UsbIo->UsbBulkTransfer (\r
                       UsbIo,\r
                       EndpointAddr,\r
@@ -883,25 +794,36 @@ BotStatusPhase (
                       );\r
     if (EFI_ERROR (Status)) {\r
       if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {\r
-        UsbClearEndpointHalt (\r
-          UsbIo,\r
-          EndpointAddr,\r
-          &Result\r
-          );\r
+        DEBUG((gBOTDebugLevel, "BOT: CSW Stall, ClearBulkInPipe\n"));\r
+        ClearBulkInPipe (UsbBotDev);\r
+        continue;\r
+      }\r
+    }\r
+\r
+    if (csw.dCSWSignature == CSWSIG) {\r
+      if (csw.bCSWStatus == 0 || csw.bCSWStatus  == 0x01) {\r
+        if (DataResidue != NULL) {\r
+          *DataResidue = csw.dCSWDataResidue;\r
+        }\r
+        if (csw.bCSWStatus  == 0x01) {\r
+          return EFI_DEVICE_ERROR;\r
+        }\r
+        break;\r
+      } else if (csw.bCSWStatus == 0x02) {\r
+        DEBUG((gBOTErrorLevel, "BOT: Bot Phase error\n"));\r
+        BotRecoveryReset (UsbBotDev);\r
       }\r
 \r
-      return Status;\r
     }\r
   }\r
 \r
-  if (csw.dCSWSignature == CSWSIG) {\r
-    *TransferStatus = csw.bCSWStatus;\r
-  } else {\r
+  if (Index == 3) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
   return EFI_SUCCESS;\r
 }\r
+\r
 //\r
 // Usb Atapi Protocol implementation\r
 //\r
@@ -938,81 +860,82 @@ BotAtapiCommand (
 {\r
   EFI_STATUS      Status;\r
   EFI_STATUS      BotDataStatus;\r
-  UINT8           TransferStatus;\r
   USB_BOT_DEVICE  *UsbBotDev;\r
-  UINT32          BufferSize;\r
-\r
-  BotDataStatus = EFI_SUCCESS;\r
-  TransferStatus = 0;\r
+  UINTN           BufferSize;\r
+  UINT8           Index;\r
+  UINT32          DataResidue;\r
 \r
   //\r
   // Get the context\r
   //\r
-  UsbBotDev = USB_BOT_DEVICE_FROM_THIS (This);\r
+  UsbBotDev     = USB_BOT_DEVICE_FROM_THIS (This);\r
+  BotDataStatus = EFI_SUCCESS;\r
+  BufferSize    = 0;\r
 \r
-  //\r
-  // First send ATAPI command through Bot\r
-  //\r
-  Status = BotCommandPhase (\r
-            UsbBotDev,\r
-            Command,\r
-            CommandSize,\r
-            BufferLength,\r
-            Direction,\r
-            TimeOutInMilliSeconds\r
-            );\r
+  for (Index = 0; Index < 3; Index ++) {\r
+    //\r
+    // First send ATAPI command through Bot\r
+    //\r
+    Status = BotCommandPhase (\r
+              UsbBotDev,\r
+              Command,\r
+              CommandSize,\r
+              BufferLength,\r
+              Direction,\r
+              10 * 1000\r
+              );\r
 \r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Send/Get Data if there is a Data Stage\r
-  //\r
-  switch (Direction) {\r
+    if (EFI_ERROR (Status)) {\r
+       DEBUG((gBOTErrorLevel, "BotCommandPhase Fail\n"));\r
+       return Status;\r
+    }\r
+    //\r
+    // Send/Get Data if there is a Data Stage\r
+    //\r
+    switch (Direction) {\r
 \r
-  case EfiUsbDataIn:\r
-  case EfiUsbDataOut:\r
-    BufferSize = BufferLength;\r
-\r
-    BotDataStatus = BotDataPhase (\r
-                      UsbBotDev,\r
-                      &BufferSize,\r
-                      DataBuffer,\r
-                      Direction,\r
-                      (UINT16) (TimeOutInMilliSeconds)\r
-                      );\r
+    case EfiUsbDataIn:\r
+    case EfiUsbDataOut:\r
+      BufferSize = BufferLength;\r
 \r
-    break;\r
+      BotDataStatus = BotDataPhase (\r
+                        UsbBotDev,\r
+                        &BufferSize,\r
+                        DataBuffer,\r
+                        Direction,\r
+                        (UINT16) (TimeOutInMilliSeconds)\r
+                        );\r
 \r
-  case EfiUsbNoData:\r
-    break;\r
-  }\r
-  \r
-  //\r
-  // Status Phase\r
-  //\r
-  Status = BotStatusPhase (\r
-            UsbBotDev,\r
-            &TransferStatus,\r
-            TimeOutInMilliSeconds\r
-            );\r
 \r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
+      if (EFI_ERROR (BotDataStatus)) {\r
+        DEBUG((gBOTErrorLevel, "BotDataPhase Fail\n"));\r
+      }\r
+      break;\r
 \r
-  if (TransferStatus == 0x02) {\r
+    case EfiUsbNoData:\r
+      break;\r
+   }\r
+\r
+    DataResidue = 0;\r
     //\r
-    // Phase error\r
+    // Status Phase\r
     //\r
-    BotRecoveryReset (UsbBotDev);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
+    Status = BotStatusPhase (\r
+              UsbBotDev,\r
+              &DataResidue,\r
+              10 * 1000\r
+              );\r
 \r
-  if (TransferStatus == 0x01) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG((gBOTErrorLevel, "BotStatusPhase Fail\n"));\r
+      return Status;\r
+    }\r
 \r
+    if (!EFI_ERROR (BotDataStatus)) {\r
+      break;\r
+    }\r
+\r
+  }\r
   return BotDataStatus;\r
 }\r
 \r
index 5f9006b5bd3ca67471ed79fef6292d8faa3d7b05..383cfde48e3723efaeabc67e8e84eddc177a46ae 100644 (file)
@@ -1,13 +1,13 @@
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
@@ -22,6 +22,9 @@ Abstract:
 \r
 \r
 #include <IndustryStandard/Usb.h>\r
+extern UINT32     gBOTDebugLevel;\r
+extern UINT32     gBOTErrorLevel;\r
+#define MASS_STORAGE_CLASS   0x08\r
 \r
 #pragma pack(1)\r
 //\r
index a021d95389612e2645f65db0b7488654c7089064..f033361fffc660f84e89c66fc3f7b0c92a80ffa8 100644 (file)
@@ -1,13 +1,13 @@
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
@@ -69,21 +69,21 @@ UsbMassStorageComponentNameGetDriverName (
   Arguments:\r
     This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
     Language   - A pointer to a three character ISO 639-2 language identifier.\r
-                 This is the language of the driver name that that the caller \r
+                 This is the language of the driver name that that the caller\r
                  is requesting, and it must match one of the languages specified\r
-                 in SupportedLanguages.  The number of languages supported by a \r
+                 in SupportedLanguages.  The number of languages supported by a\r
                  driver is up to the driver writer.\r
     DriverName - A pointer to the Unicode string to return.  This Unicode string\r
-                 is the name of the driver specified by This in the language \r
+                 is the name of the driver specified by This in the language\r
                  specified by Language.\r
 \r
   Returns:\r
     EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
-                            and the language specified by Language was returned \r
+                            and the language specified by Language was returned\r
                             in DriverName.\r
     EFI_INVALID_PARAMETER - Language is NULL.\r
     EFI_INVALID_PARAMETER - DriverName is NULL.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the\r
                             language specified by Language.\r
 \r
 --*/\r
@@ -113,39 +113,39 @@ UsbMassStorageComponentNameGetControllerName (
 \r
   Arguments:\r
     This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
-    ControllerHandle - The handle of a controller that the driver specified by \r
-                       This is managing.  This handle specifies the controller \r
+    ControllerHandle - The handle of a controller that the driver specified by\r
+                       This is managing.  This handle specifies the controller\r
                        whose name is to be returned.\r
-    ChildHandle      - The handle of the child controller to retrieve the name \r
-                       of.  This is an optional parameter that may be NULL.  It \r
-                       will be NULL for device drivers.  It will also be NULL \r
-                       for a bus drivers that wish to retrieve the name of the \r
-                       bus controller.  It will not be NULL for a bus driver \r
+    ChildHandle      - The handle of the child controller to retrieve the name\r
+                       of.  This is an optional parameter that may be NULL.  It\r
+                       will be NULL for device drivers.  It will also be NULL\r
+                       for a bus drivers that wish to retrieve the name of the\r
+                       bus controller.  It will not be NULL for a bus driver\r
                        that wishes to retrieve the name of a child controller.\r
-    Language         - A pointer to a three character ISO 639-2 language \r
-                       identifier.  This is the language of the controller name \r
+    Language         - A pointer to a three character ISO 639-2 language\r
+                       identifier.  This is the language of the controller name\r
                        that that the caller is requesting, and it must match one\r
-                       of the languages specified in SupportedLanguages.  The \r
-                       number of languages supported by a driver is up to the \r
+                       of the languages specified in SupportedLanguages.  The\r
+                       number of languages supported by a driver is up to the\r
                        driver writer.\r
     ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
-                       string is the name of the controller specified by \r
+                       string is the name of the controller specified by\r
                        ControllerHandle and ChildHandle in the language specified\r
                        by Language from the point of view of the driver specified\r
-                       by This. \r
+                       by This.\r
 \r
   Returns:\r
-    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
-                            language specified by Language for the driver \r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the\r
+                            language specified by Language for the driver\r
                             specified by This was returned in DriverName.\r
     EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
     EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
     EFI_INVALID_PARAMETER - Language is NULL.\r
     EFI_INVALID_PARAMETER - ControllerName is NULL.\r
-    EFI_UNSUPPORTED       - The driver specified by This is not currently managing \r
-                            the controller specified by ControllerHandle and \r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently managing\r
+                            the controller specified by ControllerHandle and\r
                             ChildHandle.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the\r
                             language specified by Language.\r
 \r
 --*/\r
index b86c06a514d06469a2e0d73e07b73d7639ceb7a4..7f6cd4daf26796f7320d227acdde074f10b9e6ef 100644 (file)
@@ -1,18 +1,18 @@
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
   UsbMassStorage.c\r
-    \r
+\r
 Abstract:\r
 \r
   USB Mass Storage Driver\r
@@ -192,11 +192,11 @@ USBFloppyDriverBindingStart (
     EFI_OUT_OF_RESOURCES- Can't allocate memory resources\r
     EFI_ALREADY_STARTED - Thios driver has been started\r
 --*/\r
-{ \r
-  EFI_STATUS                Status; \r
+{\r
+  EFI_STATUS                Status;\r
   EFI_USB_ATAPI_PROTOCOL    *AtapiProtocol;\r
   USB_FLOPPY_DEV            *UsbFloppyDevice;\r
-  \r
+\r
   UsbFloppyDevice = NULL;\r
   //\r
   // Check whether Usb Atapi Protocol attached on the controller handle.\r
@@ -311,7 +311,7 @@ USBFloppyDriverBindingStop (
     EFI_DEVICE_ERROR\r
     others\r
 \r
---*/  \r
+--*/\r
 {\r
   EFI_STATUS            Status;\r
   USB_FLOPPY_DEV        *UsbFloppyDevice;\r
@@ -373,17 +373,17 @@ USBFloppyReset (
 \r
   Routine Description:\r
     Implements EFI_BLOCK_IO_PROTOCOL.Reset() function.\r
-  \r
+\r
   Arguments:\r
     This     The EFI_BLOCK_IO_PROTOCOL instance.\r
     ExtendedVerification\r
               Indicates that the driver may perform a more exhaustive\r
               verification operation of the device during reset.\r
               (This parameter is ingored in this driver.)\r
-    \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_SUCCESS - Success\r
---*/      \r
+--*/\r
 {\r
   USB_FLOPPY_DEV          *UsbFloppyDevice;\r
   EFI_USB_ATAPI_PROTOCOL  *UsbAtapiInterface;\r
@@ -396,7 +396,7 @@ USBFloppyReset (
   //\r
   // directly calling EFI_USB_ATAPI_PROTOCOL.Reset() to implement reset.\r
   //\r
-  Status = UsbAtapiInterface->UsbAtapiReset (UsbAtapiInterface, TRUE);\r
+  Status = UsbAtapiInterface->UsbAtapiReset (UsbAtapiInterface, ExtendedVerification);\r
 \r
   return Status;\r
 }\r
@@ -415,26 +415,26 @@ USBFloppyReadBlocks (
 \r
   Routine Description:\r
     Implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks() function.\r
-  \r
+\r
   Arguments:\r
     This     The EFI_BLOCK_IO_PROTOCOL instance.\r
     MediaId  The media id that the read request is for.\r
     LBA      The starting logical block address to read from on the device.\r
     BufferSize\r
-              The size of the Buffer in bytes. This must be a multiple of \r
+              The size of the Buffer in bytes. This must be a multiple of\r
               the intrinsic block size of the device.\r
-    Buffer    A pointer to the destination buffer for the data. The caller \r
+    Buffer    A pointer to the destination buffer for the data. The caller\r
               is responsible for either having implicit or explicit ownership\r
-              of the buffer.                               \r
-  \r
-  Returns:  \r
+              of the buffer.\r
+\r
+  Returns:\r
     EFI_INVALID_PARAMETER - Parameter is error\r
-    EFI_SUCCESS           - Success  \r
+    EFI_SUCCESS           - Success\r
     EFI_DEVICE_ERROR      - Hardware Error\r
     EFI_NO_MEDIA          - No media\r
     EFI_MEDIA_CHANGED     - Media Change\r
     EFI_BAD_BUFFER_SIZE   - Buffer size is bad\r
- --*/      \r
+ --*/\r
 {\r
   USB_FLOPPY_DEV      *UsbFloppyDevice;\r
   EFI_STATUS          Status;\r
@@ -442,12 +442,9 @@ USBFloppyReadBlocks (
   UINTN               BlockSize;\r
   UINTN               NumberOfBlocks;\r
   BOOLEAN             MediaChange;\r
-  EFI_TPL             OldTpl;\r
 \r
-  OldTpl          = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
   Status          = EFI_SUCCESS;\r
   MediaChange     = FALSE;\r
-\r
   UsbFloppyDevice = USB_FLOPPY_DEV_FROM_THIS (This);\r
 \r
   //\r
@@ -473,14 +470,12 @@ USBFloppyReadBlocks (
   }\r
 \r
   if (MediaChange) {\r
-    gBS->RestoreTPL (OldTpl);\r
     gBS->ReinstallProtocolInterface (\r
           UsbFloppyDevice->Handle,\r
           &gEfiBlockIoProtocolGuid,\r
           &UsbFloppyDevice->BlkIo,\r
           &UsbFloppyDevice->BlkIo\r
           );\r
-    gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
   }\r
 \r
   Media           = UsbFloppyDevice->BlkIo.Media;\r
@@ -517,33 +512,31 @@ USBFloppyReadBlocks (
     goto Done;\r
   }\r
 \r
-  if (!EFI_ERROR (Status)) {\r
-\r
-    Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, 1);\r
-    if (EFI_ERROR (Status)) {\r
-      This->Reset (This, TRUE);\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Done;\r
-    }\r
-\r
-    LBA += 1;\r
-    NumberOfBlocks -= 1;\r
-    Buffer = (UINT8 *) Buffer + This->Media->BlockSize;\r
+  while (NumberOfBlocks > 0) {\r
 \r
-    if (NumberOfBlocks == 0) {\r
-      Status = EFI_SUCCESS;\r
-      goto Done;\r
+    if (NumberOfBlocks > BLOCK_UNIT) {\r
+      Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, BLOCK_UNIT);\r
+    } else {\r
+      Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);\r
     }\r
 \r
-    Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);\r
     if (EFI_ERROR (Status)) {\r
       This->Reset (This, TRUE);\r
       Status = EFI_DEVICE_ERROR;\r
     }\r
-  }\r
 \r
-Done:\r
-  gBS->RestoreTPL (OldTpl);\r
+    if (NumberOfBlocks > BLOCK_UNIT) {\r
+       NumberOfBlocks -= BLOCK_UNIT;\r
+       LBA += BLOCK_UNIT;\r
+       Buffer = (UINT8 *) Buffer + This->Media->BlockSize * BLOCK_UNIT;\r
+    } else {\r
+       NumberOfBlocks -= NumberOfBlocks;\r
+       LBA += NumberOfBlocks;\r
+       Buffer = (UINT8 *) Buffer + This->Media->BlockSize * NumberOfBlocks;\r
+    }\r
+ }\r
+\r
+ Done:\r
   return Status;\r
 }\r
 \r
@@ -561,29 +554,29 @@ USBFloppyWriteBlocks (
 \r
   Routine Description:\r
     Implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks() function.\r
-  \r
+\r
   Arguments:\r
     This     The EFI_BLOCK_IO_PROTOCOL instance.\r
     MediaId  The media id that the write request is for.\r
     LBA      The starting logical block address to be written.\r
-             The caller is responsible for writing to only \r
+             The caller is responsible for writing to only\r
              legitimate locations.\r
     BufferSize\r
-              The size of the Buffer in bytes. This must be a multiple of \r
+              The size of the Buffer in bytes. This must be a multiple of\r
               the intrinsic block size of the device.\r
-    Buffer    A pointer to the source buffer for the data. The caller \r
+    Buffer    A pointer to the source buffer for the data. The caller\r
               is responsible for either having implicit or explicit ownership\r
-              of the buffer.                               \r
-  \r
-  Returns:  \r
+              of the buffer.\r
+\r
+  Returns:\r
     EFI_INVALID_PARAMETER - Parameter is error\r
-    EFI_SUCCESS           - Success  \r
+    EFI_SUCCESS           - Success\r
     EFI_DEVICE_ERROR      - Hardware Error\r
     EFI_NO_MEDIA          - No media\r
     EFI_MEDIA_CHANGED     - Media Change\r
     EFI_BAD_BUFFER_SIZE   - Buffer size is bad\r
 \r
---*/        \r
+--*/\r
 {\r
   USB_FLOPPY_DEV      *UsbFloppyDevice;\r
   EFI_STATUS          Status;\r
@@ -591,9 +584,7 @@ USBFloppyWriteBlocks (
   UINTN               BlockSize;\r
   UINTN               NumberOfBlocks;\r
   BOOLEAN             MediaChange;\r
-  EFI_TPL             OldTpl;\r
 \r
-  OldTpl          = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
   Status          = EFI_SUCCESS;\r
   MediaChange     = FALSE;\r
 \r
@@ -622,14 +613,12 @@ USBFloppyWriteBlocks (
   }\r
 \r
   if (MediaChange) {\r
-    gBS->RestoreTPL (OldTpl);\r
     gBS->ReinstallProtocolInterface (\r
           UsbFloppyDevice->Handle,\r
           &gEfiBlockIoProtocolGuid,\r
           &UsbFloppyDevice->BlkIo,\r
           &UsbFloppyDevice->BlkIo\r
           );\r
-    gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
   }\r
 \r
   Media           = UsbFloppyDevice->BlkIo.Media;\r
@@ -671,32 +660,32 @@ USBFloppyWriteBlocks (
     goto Done;\r
   }\r
 \r
-  if (!EFI_ERROR (Status)) {\r
-    Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, 1);\r
-    if (EFI_ERROR (Status)) {\r
-      This->Reset (This, TRUE);\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Done;\r
-    }\r
-\r
-    LBA += 1;\r
-    NumberOfBlocks -= 1;\r
-    Buffer = (UINT8 *) Buffer + This->Media->BlockSize;\r
+  while (NumberOfBlocks > 0) {\r
 \r
-    if (NumberOfBlocks == 0) {\r
-      Status = EFI_SUCCESS;\r
-      goto Done;\r
+    if (NumberOfBlocks > BLOCK_UNIT) {\r
+      Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, BLOCK_UNIT);\r
+    } else {\r
+      Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);\r
     }\r
 \r
-    Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);\r
     if (EFI_ERROR (Status)) {\r
       This->Reset (This, TRUE);\r
       Status = EFI_DEVICE_ERROR;\r
     }\r
-  }\r
+\r
+    if (NumberOfBlocks > BLOCK_UNIT) {\r
+       NumberOfBlocks -= BLOCK_UNIT;\r
+       LBA += BLOCK_UNIT;\r
+       Buffer = (UINT8 *) Buffer + This->Media->BlockSize * BLOCK_UNIT;\r
+    } else {\r
+       NumberOfBlocks -= NumberOfBlocks;\r
+       LBA += NumberOfBlocks;\r
+       Buffer = (UINT8 *) Buffer + This->Media->BlockSize * NumberOfBlocks;\r
+    }\r
+ }\r
 \r
 Done:\r
-  gBS->RestoreTPL (OldTpl);\r
+\r
   return Status;\r
 }\r
 \r
@@ -711,13 +700,13 @@ USBFloppyFlushBlocks (
   Routine Description:\r
     Implements EFI_BLOCK_IO_PROTOCOL.FlushBlocks() function.\r
     (In this driver, this function just returns EFI_SUCCESS.)\r
-  \r
+\r
   Arguments:\r
     This     The EFI_BLOCK_IO_PROTOCOL instance.\r
-  \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_SUCCESS - Success\r
---*/    \r
+--*/\r
 {\r
   return EFI_SUCCESS;\r
 }\r
index fc19930cbdc433a7029411d4bbdcf4941aca69c8..832befccccfafa38a0737f2b5c3edddf8d4567e7 100644 (file)
@@ -1,12 +1,12 @@
 /*++\r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
@@ -37,6 +37,8 @@ Revision History
 #define USBFLOPPY2                2 // for those that use ReadFormatCapacity(0x23) command to retrieve media capacity\r
 #define USBCDROM                  3\r
 \r
+#define BLOCK_UNIT                128\r
+\r
 #define USB_FLOPPY_DEV_SIGNATURE  EFI_SIGNATURE_32 ('u', 'f', 'l', 'p')\r
 \r
 typedef struct {\r
@@ -50,7 +52,6 @@ typedef struct {
   REQUEST_SENSE_DATA      *SenseData;\r
   UINT8                   SenseDataNumber;\r
   UINT8                   DeviceType;\r
-\r
 } USB_FLOPPY_DEV;\r
 \r
 #define USB_FLOPPY_DEV_FROM_THIS(a) \\r
index 45433edfc2ca7d322cd6998cbeb3d20a48c3a6f7..cef33bd4f51c060db2dc9787b8acc52da76be85d 100644 (file)
@@ -1,12 +1,12 @@
 /*++\r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
@@ -30,7 +30,7 @@ Revision History
 //\r
 // timeout unit is in millisecond.\r
 //\r
-#define USBFLPTIMEOUT         2000\r
+#define USBFLPTIMEOUT         1000\r
 #define STALL_1_MILLI_SECOND  1000\r
 \r
 //\r
index de61eeb6d0a3840c8f98af03563aef5d0dc1e477..c81fbf299ea34542522825cce5293d28224149f1 100644 (file)
@@ -1,18 +1,18 @@
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
   UsbMassStorageHelper.c\r
-    \r
+\r
 Abstract:\r
 \r
   Helper functions for USB Mass Storage Driver\r
@@ -80,19 +80,19 @@ USBFloppyPacketCommand (
 \r
   Routine Description:\r
     Sends Packet Command to USB Floppy Drive.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  -  The USB_FLOPPY_DEV instance.\r
     Command          -  A pointer to the command packet.\r
     CommandSize      -  Indicates the size of the command packet.\r
     DataBuffer       -  A pointer to the buffer for the data transfer\r
-                        after the command packet.              \r
+                        after the command packet.\r
     BufferLength     -  Indicates the size of the Data Buffer.\r
     Direction        -  Transfer Direction\r
     TimeOutInMilliSeconds - Timeout Value\r
-  Returns:  \r
+  Returns:\r
     EFI_SUCCESS  - Success\r
---*/    \r
+--*/\r
 {\r
   EFI_USB_ATAPI_PROTOCOL  *UsbAtapiInterface;\r
   EFI_STATUS              Status;\r
@@ -123,14 +123,14 @@ USBFloppyIdentify (
 \r
   Routine Description:\r
     Retrieves device information to tell the device type.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice    The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/    \r
+--*/\r
 {\r
 \r
   EFI_STATUS        Status;\r
@@ -144,7 +144,7 @@ USBFloppyIdentify (
   if (EFI_ERROR (Status)) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
-   \r
+\r
   //\r
   // Get media removable info from INQUIRY data.\r
   //\r
@@ -201,7 +201,7 @@ USBFloppyIdentify (
     gBS->FreePool (Idata);\r
     return EFI_DEVICE_ERROR;\r
   }\r
-  \r
+\r
   //\r
   // Get media information.\r
   //\r
@@ -221,16 +221,16 @@ USBFloppyInquiry (
 \r
   Routine Description:\r
     Send Inquiry Packet Command to device and retrieve Inquiry Data.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice    The USB_FLOPPY_DEV instance.\r
-    Idata              A pointer pointing to the address of \r
+    Idata              A pointer pointing to the address of\r
                        Inquiry Data.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/      \r
+--*/\r
 {\r
   ATAPI_PACKET_COMMAND    Packet;\r
   EFI_STATUS              Status;\r
@@ -272,31 +272,31 @@ USBFloppyInquiry (
 \r
 EFI_STATUS\r
 USBFloppyRead10 (\r
-  IN    USB_FLOPPY_DEV    *UsbFloppyDevice,\r
-  IN    VOID              *Buffer,\r
-  IN    EFI_LBA           Lba,\r
-  IN    UINTN             NumberOfBlocks\r
+  IN  USB_FLOPPY_DEV    *UsbFloppyDevice,\r
+  IN  VOID              *Buffer,\r
+  IN  EFI_LBA           Lba,\r
+  IN  UINTN             NumberOfBlocks\r
   )\r
 /*++\r
 \r
   Routine Description:\r
     Sends Read10 Packet Command to device to perform data transfer\r
     from device to host.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice -   The USB_FLOPPY_DEV instance.\r
-    Buffer          -   A pointer to the destination buffer for the data. \r
+    Buffer          -   A pointer to the destination buffer for the data.\r
                         The caller is responsible for either having implicit\r
                         or explicit ownership of the buffer.\r
-    Lba             -   The starting logical block address to read from \r
+    Lba             -   The starting logical block address to read from\r
                         on the device.\r
-    NumberOfBlocks  -   Indicates the number of blocks that the read \r
+    NumberOfBlocks  -   Indicates the number of blocks that the read\r
                         operation requests.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/      \r
+--*/\r
 {\r
   ATAPI_PACKET_COMMAND    Packet;\r
   READ10_CMD              *Read10Packet;\r
@@ -310,7 +310,7 @@ USBFloppyRead10 (
   EFI_STATUS              Status;\r
   UINT16                  TimeOut;\r
   EFI_USB_ATAPI_PROTOCOL  *UsbAtapiInterface;\r
-  UINTN                   SenseCounts;\r
+  UINT8                   Index;\r
 \r
   UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
@@ -333,78 +333,52 @@ USBFloppyRead10 (
     } else {\r
       SectorCount = MaxBlock;\r
     }\r
-    //\r
-    // fill the Packet data structure\r
-    //\r
-    Read10Packet->opcode = READ_10;\r
 \r
-    //\r
-    // Lba0 ~ Lba3 specify the start logical block address of the data transfer.\r
-    // Lba0 is MSB, Lba3 is LSB\r
-    //\r
-    Read10Packet->Lba3  = (UINT8) (Lba32 & 0xff);\r
-    Read10Packet->Lba2  = (UINT8) (Lba32 >> 8);\r
-    Read10Packet->Lba1  = (UINT8) (Lba32 >> 16);\r
-    Read10Packet->Lba0  = (UINT8) (Lba32 >> 24);\r
+    for (Index = 0; Index < 3; Index ++) {\r
 \r
-    //\r
-    // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
-    // TranLen0 is MSB, TranLen is LSB\r
-    //\r
-    Read10Packet->TranLen1  = (UINT8) (SectorCount & 0xff);\r
-    Read10Packet->TranLen0  = (UINT8) (SectorCount >> 8);\r
+      //\r
+      // fill the Packet data structure\r
+      //\r
+      Read10Packet->opcode = READ_10;\r
+      //\r
+      // Lba0 ~ Lba3 specify the start logical block address of the data transfer.\r
+      // Lba0 is MSB, Lba3 is LSB\r
+      //\r
+      Read10Packet->Lba3  = (UINT8) (Lba32 & 0xff);\r
+      Read10Packet->Lba2  = (UINT8) (Lba32 >> 8);\r
+      Read10Packet->Lba1  = (UINT8) (Lba32 >> 16);\r
+      Read10Packet->Lba0  = (UINT8) (Lba32 >> 24);\r
 \r
-    ByteCount               = SectorCount * BlockSize;\r
+      //\r
+      // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
+      // TranLen0 is MSB, TranLen is LSB\r
+      //\r
+      Read10Packet->TranLen1  = (UINT8) (SectorCount & 0xff);\r
+      Read10Packet->TranLen0  = (UINT8) (SectorCount >> 8);\r
 \r
-    TimeOut                 = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
+      ByteCount               = SectorCount * BlockSize;\r
 \r
-    Status = USBFloppyPacketCommand (\r
-              UsbFloppyDevice,\r
-              &Packet,\r
-              sizeof (ATAPI_PACKET_COMMAND),\r
-              (VOID *) ptrBuffer,\r
-              ByteCount,\r
-              EfiUsbDataIn,\r
-              TimeOut\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
+      TimeOut                 = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
 \r
-      Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts);\r
-      if (!EFI_ERROR (Status)) {\r
-        if (IsLogicalUnitCommunicationOverRun (\r
-              UsbFloppyDevice->SenseData,\r
-              SenseCounts\r
-              )) {\r
-          Lba32           = (UINT32) Lba;\r
-          ptrBuffer       = Buffer;\r
-          BlocksRemaining = (UINT16) NumberOfBlocks;\r
-          MaxBlock        = (UINT16) (MaxBlock / 4);\r
-          if (MaxBlock < 1) {\r
-            MaxBlock = 1;\r
-          }\r
 \r
-          continue;\r
-        }\r
-      } else {\r
-        return EFI_DEVICE_ERROR;\r
-      }\r
-      //\r
-      // retry read10 command\r
-      //\r
       Status = USBFloppyPacketCommand (\r
-                UsbFloppyDevice,\r
-                &Packet,\r
-                sizeof (ATAPI_PACKET_COMMAND),\r
-                (VOID *) ptrBuffer,\r
-                ByteCount,\r
-                EfiUsbDataIn,\r
-                TimeOut\r
-                );\r
-      if (EFI_ERROR (Status)) {\r
-        return EFI_DEVICE_ERROR;\r
+                 UsbFloppyDevice,\r
+                 &Packet,\r
+                 sizeof (ATAPI_PACKET_COMMAND),\r
+                 (VOID *) ptrBuffer,\r
+                 ByteCount,\r
+                 EfiUsbDataIn,\r
+                 TimeOut\r
+                 );\r
+      if (!EFI_ERROR (Status)) {\r
+         break;\r
       }\r
     }\r
 \r
+    if (Index == 3) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
     Lba32 += SectorCount;\r
     ptrBuffer       = (UINT8 *) ptrBuffer + SectorCount * BlockSize;\r
     BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);\r
@@ -420,17 +394,17 @@ USBFloppyReadCapacity (
 /*++\r
 \r
   Routine Description:\r
-    Retrieves media capacity information via \r
+    Retrieves media capacity information via\r
     sending Read Capacity Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice -   The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/        \r
-{ \r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
@@ -483,17 +457,17 @@ USBFloppyReadFormatCapacity (
 /*++\r
 \r
   Routine Description:\r
-    Retrieves media capacity information via sending Read Format \r
+    Retrieves media capacity information via sending Read Format\r
     Capacity Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/         \r
-{ \r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
@@ -537,7 +511,7 @@ USBFloppyReadFormatCapacity (
   } else {\r
 \r
     UsbFloppyDevice->BlkIo.Media->LastBlock = (FormatData.LastLba3 << 24) |\r
-                                              (FormatData.LastLba2 << 16) | \r
+                                              (FormatData.LastLba2 << 16) |\r
                                               (FormatData.LastLba1 << 8)  |\r
                                                FormatData.LastLba0;\r
 \r
@@ -565,17 +539,17 @@ UsbFloppyRequestSense (
 /*++\r
 \r
   Routine Description:\r
-    Retrieves Sense Data from device via \r
+    Retrieves Sense Data from device via\r
     sending Request Sense Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
     SenseCounts     - A pointer to the number of Sense Data returned.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/         \r
+--*/\r
 {\r
   EFI_STATUS              Status;\r
   REQUEST_SENSE_DATA      *Sense;\r
@@ -598,7 +572,7 @@ UsbFloppyRequestSense (
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
   Packet.RequestSense.opcode            = REQUEST_SENSE;\r
   Packet.RequestSense.allocation_length = sizeof (REQUEST_SENSE_DATA);\r
-  \r
+\r
   //\r
   // initialize pointer\r
   //\r
@@ -666,7 +640,7 @@ UsbFloppyRequestSense (
       //\r
       SenseReq = FALSE;\r
     }\r
-  \r
+\r
     //\r
     // If the sense key numbers exceed Sense Data Buffer size,\r
     // just skip the loop and do not fetch the sense key in this function.\r
@@ -687,25 +661,25 @@ UsbFloppyTestUnitReady (
 \r
   Routine Description:\r
     Sends Test Unit ReadyPacket Command to the device.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice -  The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/  \r
-{ \r
-  ATAPI_PACKET_COMMAND      Packet; \r
+--*/\r
+{\r
+  ATAPI_PACKET_COMMAND      Packet;\r
   EFI_STATUS                Status;\r
   EFI_USB_ATAPI_PROTOCOL    *UsbAtapiInterface;\r
   UINT32                    RetryIndex;\r
   UINT32                    MaximumRetryTimes;\r
-  \r
+\r
   UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
   MaximumRetryTimes = 2;\r
   //\r
-  // fill command packet  \r
+  // fill command packet\r
   //\r
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
   Packet.TestUnitReady.opcode = TEST_UNIT_READY;\r
@@ -737,31 +711,31 @@ UsbFloppyTestUnitReady (
 \r
 EFI_STATUS\r
 USBFloppyWrite10 (\r
-  IN    USB_FLOPPY_DEV    *UsbFloppyDevice,\r
-  IN    VOID              *Buffer,\r
-  IN    EFI_LBA           Lba,\r
-  IN    UINTN             NumberOfBlocks\r
+  IN  USB_FLOPPY_DEV    *UsbFloppyDevice,\r
+  IN  VOID              *Buffer,\r
+  IN  EFI_LBA           Lba,\r
+  IN  UINTN             NumberOfBlocks\r
   )\r
 /*++\r
 \r
   Routine Description:\r
     Sends Write10 Packet Command to device to perform data transfer\r
     from host to device.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice -   The USB_FLOPPY_DEV instance.\r
-    Buffer          -   A pointer to the source buffer for the data. \r
+    Buffer          -   A pointer to the source buffer for the data.\r
                         The caller is responsible for either having implicit\r
                         or explicit ownership of the buffer.\r
-    Lba             -   The starting logical block address to written to \r
+    Lba             -   The starting logical block address to written to\r
                         the device.\r
-    NumberOfBlocks  -   Indicates the number of blocks that the write \r
+    NumberOfBlocks  -   Indicates the number of blocks that the write\r
                         operation requests.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/      \r
+--*/\r
 {\r
   ATAPI_PACKET_COMMAND    Packet;\r
   READ10_CMD              *Write10Packet;\r
@@ -775,7 +749,7 @@ USBFloppyWrite10 (
   EFI_STATUS              Status;\r
   UINT16                  TimeOut;\r
   EFI_USB_ATAPI_PROTOCOL  *UsbAtapiInterface;\r
-  UINTN                   SenseCounts;\r
+  UINT8                   Index;\r
 \r
   UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
@@ -795,82 +769,56 @@ USBFloppyWrite10 (
   while (BlocksRemaining > 0) {\r
 \r
     if (BlocksRemaining <= MaxBlock) {\r
-\r
       SectorCount = BlocksRemaining;\r
     } else {\r
-\r
       SectorCount = MaxBlock;\r
     }\r
-    //\r
-    // fill the Packet data structure\r
-    //\r
-    Write10Packet->opcode = WRITE_10;\r
 \r
-    //\r
-    // Lba0 ~ Lba3 specify the start logical block address\r
-    // of the data transfer.\r
-    // Lba0 is MSB, Lba3 is LSB\r
-    //\r
-    Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff);\r
-    Write10Packet->Lba2 = (UINT8) (Lba32 >> 8);\r
-    Write10Packet->Lba1 = (UINT8) (Lba32 >> 16);\r
-    Write10Packet->Lba0 = (UINT8) (Lba32 >> 24);\r
+    for (Index = 0; Index < 3; Index ++) {\r
+      //\r
+      // fill the Packet data structure\r
+      //\r
+      Write10Packet->opcode = WRITE_10;\r
 \r
-    //\r
-    // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
-    // TranLen0 is MSB, TranLen is LSB\r
-    //\r
-    Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);\r
-    Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8);\r
+      //\r
+      // Lba0 ~ Lba3 specify the start logical block address\r
+      // of the data transfer.\r
+      // Lba0 is MSB, Lba3 is LSB\r
+      //\r
+      Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff);\r
+      Write10Packet->Lba2 = (UINT8) (Lba32 >> 8);\r
+      Write10Packet->Lba1 = (UINT8) (Lba32 >> 16);\r
+      Write10Packet->Lba0 = (UINT8) (Lba32 >> 24);\r
 \r
-    ByteCount               = SectorCount * BlockSize;\r
+      //\r
+      // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
+      // TranLen0 is MSB, TranLen is LSB\r
+      //\r
+      Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);\r
+      Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8);\r
 \r
-    TimeOut                 = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
+      ByteCount               = SectorCount * BlockSize;\r
 \r
-    Status = USBFloppyPacketCommand (\r
-              UsbFloppyDevice,\r
-              &Packet,\r
-              sizeof (ATAPI_PACKET_COMMAND),\r
-              (VOID *) ptrBuffer,\r
-              ByteCount,\r
-              EfiUsbDataOut,\r
-              TimeOut\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts);\r
-      if (!EFI_ERROR (Status)) {\r
-        if (IsLogicalUnitCommunicationOverRun (\r
-              UsbFloppyDevice->SenseData,\r
-              SenseCounts\r
-              )) {\r
-          Lba32           = (UINT32) Lba;\r
-          ptrBuffer       = Buffer;\r
-          BlocksRemaining = (UINT16) NumberOfBlocks;\r
-          MaxBlock        = (UINT16) (MaxBlock / 4);\r
-          if (MaxBlock < 1) {\r
-            MaxBlock = 1;\r
-          }\r
+      TimeOut                 = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
 \r
-          continue;\r
-        }\r
-      }\r
-      //\r
-      // retry write10 command\r
-      //\r
       Status = USBFloppyPacketCommand (\r
-                UsbFloppyDevice,\r
-                &Packet,\r
-                sizeof (ATAPI_PACKET_COMMAND),\r
-                (VOID *) ptrBuffer,\r
-                ByteCount,\r
-                EfiUsbDataOut,\r
-                TimeOut\r
-                );\r
-      if (EFI_ERROR (Status)) {\r
-        return EFI_DEVICE_ERROR;\r
+                 UsbFloppyDevice,\r
+                 &Packet,\r
+                 sizeof (ATAPI_PACKET_COMMAND),\r
+                 (VOID *) ptrBuffer,\r
+                 ByteCount,\r
+                 EfiUsbDataOut,\r
+                 TimeOut\r
+                 );\r
+      if (!EFI_ERROR (Status)) {\r
+         break;\r
       }\r
     }\r
 \r
+    if (Index == 3) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
     Lba32 += SectorCount;\r
     ptrBuffer       = (UINT8 *) ptrBuffer + SectorCount * BlockSize;\r
     BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);\r
@@ -888,16 +836,16 @@ UsbFloppyDetectMedia (
 \r
   Routine Description:\r
     Retrieves media information.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  -  The USB_FLOPPY_DEV instance.\r
     MediaChange      -  Indicates whether media was changed.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_INVALID_PARAMETER - Parameter is error\r
---*/        \r
+--*/\r
 {\r
   EFI_STATUS          Status;\r
   EFI_STATUS          FloppyStatus;\r
@@ -910,11 +858,10 @@ UsbFloppyDetectMedia (
   UINTN               RetryTimes;\r
   UINTN               MaximumRetryTimes;\r
   BOOLEAN             NeedRetry;\r
-\r
+  BOOLEAN             NeedReadCapacity;\r
   //\r
   // a flag used to determine whether need to perform Read Capacity command.\r
   //\r
-  BOOLEAN             NeedReadCapacity;\r
 \r
   REQUEST_SENSE_DATA  *SensePtr;\r
 \r
@@ -955,14 +902,14 @@ UsbFloppyDetectMedia (
       if (IsMediaChange (UsbFloppyDevice->SenseData, SenseCounts)) {\r
         UsbFloppyDevice->BlkIo.Media->MediaId++;\r
       }\r
-        \r
+\r
       //\r
       // Media Write-protected\r
       //\r
       if (IsMediaWriteProtected (UsbFloppyDevice->SenseData, SenseCounts)) {\r
         UsbFloppyDevice->BlkIo.Media->ReadOnly = TRUE;\r
       }\r
-        \r
+\r
       //\r
       // Media Error\r
       //\r
@@ -1078,7 +1025,7 @@ UsbFloppyDetectMedia (
       }\r
 \r
       if (!IsDriveReady (UsbFloppyDevice->SenseData, SenseCounts, &NeedRetry)) {\r
-          \r
+\r
         //\r
         // Drive not ready: if NeedRetry, then retry once more;\r
         // else return error\r
@@ -1160,18 +1107,18 @@ UsbFloppyModeSense5APage5 (
 /*++\r
 \r
   Routine Description:\r
-    Retrieves media capacity information via sending Read Format \r
+    Retrieves media capacity information via sending Read Format\r
     Capacity Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
-    \r
---*/         \r
-{ \r
+\r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
@@ -1246,18 +1193,18 @@ UsbFloppyModeSense5APage1C (
 /*++\r
 \r
   Routine Description:\r
-    Retrieves media capacity information via sending Read Format \r
+    Retrieves media capacity information via sending Read Format\r
     Capacity Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
-    \r
---*/         \r
-{ \r
+\r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
@@ -1323,16 +1270,16 @@ UsbFloppyModeSense5APage3F (
   Routine Description:\r
     Retrieves mode sense information via sending Mode Sense\r
     Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
 \r
---*/         \r
-{ \r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
@@ -1381,16 +1328,16 @@ UsbSCSIModeSense1APage3F (
   Routine Description:\r
     Retrieves mode sense information via sending Mode Sense\r
     Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
-    \r
---*/  \r
-{ \r
+\r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
@@ -1450,7 +1397,7 @@ IsNoMedia (
 \r
   for (Index = 0; Index < SenseCounts; Index++) {\r
 \r
-    if ((SensePtr->sense_key == SK_NOT_READY) && \r
+    if ((SensePtr->sense_key == SK_NOT_READY) &&\r
         (SensePtr->addnl_sense_code == ASC_NO_MEDIA)) {\r
 \r
       NoMedia = TRUE;\r
@@ -1479,7 +1426,7 @@ IsMediaError (
   for (Index = 0; Index < SenseCounts; Index++) {\r
 \r
     switch (SensePtr->sense_key) {\r
-      \r
+\r
     //\r
     // Medium error case\r
     //\r
index f41241adc43886e8a2dd704e5f594e82ca2fad1a..dc810bc3dc03cc773bd2950b1b1952a12783e2cc 100644 (file)
@@ -1,12 +1,12 @@
 /*++\r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
+Copyright (c) 2006, 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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