]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/EhciDxe/EhciUrb.c
Improve coding style in MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / EhciUrb.c
index 4d8e38be2cc557e3517e3a2676256bd4f2f40d0a..593652f3e09fef1f50516e99519848d9eda94dbd 100644 (file)
@@ -3,7 +3,7 @@
     This file contains URB request, each request is warpped in a\r
     URB (Usb Request Block).\r
 \r
-Copyright (c) 2007, Intel Corporation\r
+Copyright (c) 2007 - 2010, 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
@@ -21,7 +21,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   Create a single QTD to hold the data.\r
 \r
   @param  Ehc                   The EHCI device.\r
-  @param  Data                  Current data not associated with a QTD.\r
+  @param  Data                  The cpu memory address of current data not associated with a QTD.\r
+  @param  DataPhy               The pci bus address of current data not associated with a QTD.\r
   @param  DataLen               The length of the data.\r
   @param  PktId                 Packet ID to use in the QTD.\r
   @param  Toggle                Data toggle to use in the QTD.\r
@@ -34,6 +35,7 @@ EHC_QTD *
 EhcCreateQtd (\r
   IN USB2_HC_DEV          *Ehc,\r
   IN UINT8                *Data,\r
+  IN UINT8                *DataPhy,\r
   IN UINTN                DataLen,\r
   IN UINT8                PktId,\r
   IN UINT8                Toggle,\r
@@ -66,7 +68,7 @@ EhcCreateQtd (
   QtdHw->Status     = QTD_STAT_ACTIVE;\r
   QtdHw->Pid        = PktId;\r
   QtdHw->ErrCnt     = QTD_MAX_ERR;\r
-  QtdHw->IOC        = 0;\r
+  QtdHw->Ioc        = 0;\r
   QtdHw->TotalBytes = 0;\r
   QtdHw->DataToggle = Toggle;\r
 \r
@@ -82,10 +84,10 @@ EhcCreateQtd (
       // compute the offset and clear Reserved fields. This is already\r
       // done in the data point.\r
       //\r
-      QtdHw->Page[Index]      = EHC_LOW_32BIT (Data);\r
-      QtdHw->PageHigh[Index]  = EHC_HIGH_32BIT (Data);\r
+      QtdHw->Page[Index]      = EHC_LOW_32BIT (DataPhy);\r
+      QtdHw->PageHigh[Index]  = EHC_HIGH_32BIT (DataPhy);\r
 \r
-      ThisBufLen              = QTD_BUF_LEN - (EHC_LOW_32BIT (Data) & QTD_BUF_MASK);\r
+      ThisBufLen              = QTD_BUF_LEN - (EHC_LOW_32BIT (DataPhy) & QTD_BUF_MASK);\r
 \r
       if (Len + ThisBufLen >= DataLen) {\r
         Len = DataLen;\r
@@ -94,6 +96,7 @@ EhcCreateQtd (
 \r
       Len += ThisBufLen;\r
       Data += ThisBufLen;\r
+      DataPhy += ThisBufLen;\r
     }\r
 \r
     //\r
@@ -125,8 +128,6 @@ EhcCreateQtd (
   @param  Ep                    The queue head's related endpoint.\r
   @param  QhHw                  The queue head to initialize.\r
 \r
-  @return None.\r
-\r
 **/\r
 VOID\r
 EhcInitIntQh (\r
@@ -293,8 +294,6 @@ EhcConvertPollRate (
   @param  Ehc                   The EHCI device.\r
   @param  Qtds                  The list head of the QTD.\r
 \r
-  @return None.\r
-\r
 **/\r
 VOID\r
 EhcFreeQtds (\r
@@ -321,8 +320,6 @@ EhcFreeQtds (
   @param  Ehc                   The EHCI device.\r
   @param  Urb                   The URB to free.\r
 \r
-  @return None.\r
-\r
 **/\r
 VOID\r
 EhcFreeUrb (\r
@@ -381,6 +378,7 @@ EhcCreateQtds (
   UINT8                   Toggle;\r
   UINTN                   Len;\r
   UINT8                   Pid;\r
+  EFI_PHYSICAL_ADDRESS    PhyAddr;\r
 \r
   ASSERT ((Urb != NULL) && (Urb->Qh != NULL));\r
 \r
@@ -396,8 +394,9 @@ EhcCreateQtds (
   StatusQtd = NULL;\r
   AlterNext = QTD_LINK (NULL, TRUE);\r
 \r
+  PhyAddr   = UsbHcGetPciAddressForHostMem (Ehc->MemPool, Ehc->ShortReadStop, sizeof (EHC_QTD));\r
   if (Ep->Direction == EfiUsbDataIn) {\r
-    AlterNext = QTD_LINK (Ehc->ShortReadStop, FALSE);\r
+    AlterNext = QTD_LINK (PhyAddr, FALSE);\r
   }\r
 \r
   //\r
@@ -405,7 +404,7 @@ EhcCreateQtds (
   //\r
   if (Urb->Ep.Type == EHC_CTRL_TRANSFER) {\r
     Len = sizeof (EFI_USB_DEVICE_REQUEST);\r
-    Qtd = EhcCreateQtd (Ehc, Urb->RequestPhy, Len, QTD_PID_SETUP, 0, Ep->MaxPacket);\r
+    Qtd = EhcCreateQtd (Ehc, (UINT8 *)Urb->Request, (UINT8 *)Urb->RequestPhy, Len, QTD_PID_SETUP, 0, Ep->MaxPacket);\r
 \r
     if (Qtd == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
@@ -425,14 +424,15 @@ EhcCreateQtds (
       Pid = QTD_PID_INPUT;\r
     }\r
 \r
-    StatusQtd = EhcCreateQtd (Ehc, NULL, 0, Pid, 1, Ep->MaxPacket);\r
+    StatusQtd = EhcCreateQtd (Ehc, NULL, NULL, 0, Pid, 1, Ep->MaxPacket);\r
 \r
     if (StatusQtd == NULL) {\r
       goto ON_ERROR;\r
     }\r
 \r
     if (Ep->Direction == EfiUsbDataIn) {\r
-      AlterNext = QTD_LINK (StatusQtd, FALSE);\r
+      PhyAddr   = UsbHcGetPciAddressForHostMem (Ehc->MemPool, StatusQtd, sizeof (EHC_QTD));\r
+      AlterNext = QTD_LINK (PhyAddr, FALSE);\r
     }\r
 \r
     Toggle = 1;\r
@@ -453,6 +453,7 @@ EhcCreateQtds (
   while (Len < Urb->DataLen) {\r
     Qtd = EhcCreateQtd (\r
             Ehc,\r
+            (UINT8 *) Urb->Data + Len,\r
             (UINT8 *) Urb->DataPhy + Len,\r
             Urb->DataLen - Len,\r
             Pid,\r
@@ -498,14 +499,16 @@ EhcCreateQtds (
     }\r
 \r
     NextQtd             = EFI_LIST_CONTAINER (Entry->ForwardLink, EHC_QTD, QtdList);\r
-    Qtd->QtdHw.NextQtd  = QTD_LINK (NextQtd, FALSE);\r
+    PhyAddr             = UsbHcGetPciAddressForHostMem (Ehc->MemPool, NextQtd, sizeof (EHC_QTD));\r
+    Qtd->QtdHw.NextQtd  = QTD_LINK (PhyAddr, FALSE);\r
   }\r
 \r
   //\r
   // Link the QTDs to the queue head\r
   //\r
   NextQtd           = EFI_LIST_CONTAINER (Qh->Qtds.ForwardLink, EHC_QTD, QtdList);\r
-  Qh->QhHw.NextQtd  = QTD_LINK (NextQtd, FALSE);\r
+  PhyAddr           = UsbHcGetPciAddressForHostMem (Ehc->MemPool, NextQtd, sizeof (EHC_QTD));\r
+  Qh->QhHw.NextQtd  = QTD_LINK (PhyAddr, FALSE);\r
   return EFI_SUCCESS;\r
 \r
 ON_ERROR:\r