]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/UndiRuntimeDxe/E100b.c
1. Fixed one bug in Undi driver.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UndiRuntimeDxe / E100b.c
index 4ca431c520ad25af2e3c4a5e61ba689595bd4ded..2bd7813b18c8305a045cdd19f7f769c6f92f4009 100644 (file)
@@ -1,17 +1,17 @@
 /*++\r
 \r
 /*++\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
 Module Name:\r
-  \r
-  \r
+\r
+\r
  E100B.C\r
 \r
 Abstract:\r
  E100B.C\r
 \r
 Abstract:\r
@@ -33,7 +33,7 @@ static UINT8 basic_config_cmd[22] = {
                     0x60,           0,\r
                     (UINT8)0xf2,        0x48,\r
                     0,        0x40,\r
                     0x60,           0,\r
                     (UINT8)0xf2,        0x48,\r
                     0,        0x40,\r
-                    (UINT8)0xf2, (UINT8)0x80, // 0x40=Force full-duplex \r
+                    (UINT8)0xf2, (UINT8)0x80, // 0x40=Force full-duplex\r
                     0x3f,       0x05,\r
 };\r
 \r
                     0x3f,       0x05,\r
 };\r
 \r
@@ -61,9 +61,9 @@ Routine Description:
   This function calls the MemIo callback to read a byte from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
   This function calls the MemIo callback to read a byte from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
-  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have \r
+  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have\r
   to make undi3.0 a special case\r
   to make undi3.0 a special case\r
-  \r
+\r
 Arguments:\r
   Port              - Which port to read from.\r
 \r
 Arguments:\r
   Port              - Which port to read from.\r
 \r
@@ -76,9 +76,9 @@ Returns:
   UINT8 Results;\r
 \r
   (*AdapterInfo->Mem_Io) (\r
   UINT8 Results;\r
 \r
   (*AdapterInfo->Mem_Io) (\r
-    AdapterInfo->Unique_ID, \r
-    PXE_MEM_READ, \r
-    1, \r
+    AdapterInfo->Unique_ID,\r
+    PXE_MEM_READ,\r
+    1,\r
     (UINT64)Port,\r
     (UINT64) (UINTN) &Results\r
     );\r
     (UINT64)Port,\r
     (UINT64) (UINTN) &Results\r
     );\r
@@ -96,7 +96,7 @@ Routine Description:
   This function calls the MemIo callback to read a word from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
   This function calls the MemIo callback to read a word from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
-  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have \r
+  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have\r
   to make undi3.0 a special case\r
 \r
 Arguments:\r
   to make undi3.0 a special case\r
 \r
 Arguments:\r
@@ -131,7 +131,7 @@ Routine Description:
   This function calls the MemIo callback to read a dword from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
   This function calls the MemIo callback to read a dword from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
-  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have \r
+  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have\r
   to make undi3.0 a special case\r
 \r
 Arguments:\r
   to make undi3.0 a special case\r
 \r
 Arguments:\r
@@ -167,7 +167,7 @@ Routine Description:
   This function calls the MemIo callback to write a byte from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
   This function calls the MemIo callback to write a byte from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
-  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have \r
+  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have\r
   to make undi3.0 a special case\r
 \r
 Arguments:\r
   to make undi3.0 a special case\r
 \r
 Arguments:\r
@@ -205,7 +205,7 @@ Routine Description:
   This function calls the MemIo callback to write a word from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
   This function calls the MemIo callback to write a word from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
-  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have \r
+  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have\r
   to make undi3.0 a special case\r
 \r
 Arguments:\r
   to make undi3.0 a special case\r
 \r
 Arguments:\r
@@ -243,7 +243,7 @@ Routine Description:
   This function calls the MemIo callback to write a dword from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
   This function calls the MemIo callback to write a dword from the device's\r
   address space\r
   Since UNDI3.0 uses the TmpMemIo function (instead of the callback routine)\r
-  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have \r
+  which also takes the UniqueId parameter (as in UNDI3.1 spec) we don't have\r
   to make undi3.0 a special case\r
 \r
 Arguments:\r
   to make undi3.0 a special case\r
 \r
 Arguments:\r
@@ -854,7 +854,7 @@ Returns:
   AdapterInfo->rx_phy_addr    = AdapterInfo->Mapped_MemoryPtr;\r
   AdapterInfo->tx_phy_addr    = AdapterInfo->Mapped_MemoryPtr + rx_size;\r
   AdapterInfo->stat_phy_addr  = AdapterInfo->tx_phy_addr + tx_size;\r
   AdapterInfo->rx_phy_addr    = AdapterInfo->Mapped_MemoryPtr;\r
   AdapterInfo->tx_phy_addr    = AdapterInfo->Mapped_MemoryPtr + rx_size;\r
   AdapterInfo->stat_phy_addr  = AdapterInfo->tx_phy_addr + tx_size;\r
-  \r
+\r
   //\r
   // auto detect.\r
   //\r
   //\r
   // auto detect.\r
   //\r
@@ -1559,7 +1559,7 @@ Returns:
     cur_ptr[Index].PhysTCBAddress     =\r
     (UINT32) AdapterInfo->tx_phy_addr + (Index * sizeof (TxCB));\r
 \r
     cur_ptr[Index].PhysTCBAddress     =\r
     (UINT32) AdapterInfo->tx_phy_addr + (Index * sizeof (TxCB));\r
 \r
-    cur_ptr[Index].PhysArrayAddr      = (UINT32)(cur_ptr[Index].PhysTCBAddress + array_off);  \r
+    cur_ptr[Index].PhysArrayAddr      = (UINT32)(cur_ptr[Index].PhysTCBAddress + array_off);\r
     cur_ptr[Index].PhysTBDArrayAddres = (UINT32)(cur_ptr[Index].PhysTCBAddress + array_off);\r
 \r
     cur_ptr->free_data_ptr = (UINT64) 0;\r
     cur_ptr[Index].PhysTBDArrayAddres = (UINT32)(cur_ptr[Index].PhysTCBAddress + array_off);\r
 \r
     cur_ptr->free_data_ptr = (UINT64) 0;\r
@@ -2032,7 +2032,7 @@ Returns:
   UINTN wait;\r
   UINT8 tmp;\r
 \r
   UINTN wait;\r
   UINT8 tmp;\r
 \r
-  if ((AdapterInfo->DeviceID == D102_DEVICE_ID) || \r
+  if ((AdapterInfo->DeviceID == D102_DEVICE_ID) ||\r
       (AdapterInfo->RevID >= D102_REVID)) {\r
 \r
     wait = 500;\r
       (AdapterInfo->RevID >= D102_REVID)) {\r
 \r
     wait = 500;\r
@@ -2074,12 +2074,12 @@ Arguments:
 \r
 Returns:\r
  None\r
 \r
 Returns:\r
  None\r
\r
+\r
 --*/\r
 {\r
   UINT8 tmp;\r
 \r
 --*/\r
 {\r
   UINT8 tmp;\r
 \r
-  if ((AdapterInfo->DeviceID == D102_DEVICE_ID) || \r
+  if ((AdapterInfo->DeviceID == D102_DEVICE_ID) ||\r
       (AdapterInfo->RevID >= D102_REVID)) {\r
 \r
     tmp = InByte (AdapterInfo, AdapterInfo->ioaddr + SCBGenCtrl2);\r
       (AdapterInfo->RevID >= D102_REVID)) {\r
 \r
     tmp = InByte (AdapterInfo, AdapterInfo->ioaddr + SCBGenCtrl2);\r
@@ -2396,7 +2396,7 @@ Returns:
   db.Data[0x08] = AdapterInfo->statistics->rx_crc_errs +\r
                   AdapterInfo->statistics->rx_align_errs;\r
 \r
   db.Data[0x08] = AdapterInfo->statistics->rx_crc_errs +\r
                   AdapterInfo->statistics->rx_align_errs;\r
 \r
-  db.Data[0x04] = db.Data[0x02] + \r
+  db.Data[0x04] = db.Data[0x02] +\r
                   db.Data[0x08] +\r
                   AdapterInfo->statistics->rx_resource_errs +\r
                   AdapterInfo->statistics->rx_overrun_errs;\r
                   db.Data[0x08] +\r
                   AdapterInfo->statistics->rx_resource_errs +\r
                   AdapterInfo->statistics->rx_overrun_errs;\r
@@ -2557,9 +2557,9 @@ MdiWrite (
 \r
 Routine Description:\r
  This routine will write a value to the specified MII register\r
 \r
 Routine Description:\r
  This routine will write a value to the specified MII register\r
- of an external MDI compliant device (e.g. PHY 100).  The command will \r
+ of an external MDI compliant device (e.g. PHY 100).  The command will\r
  execute in polled mode.\r
  execute in polled mode.\r
\r
+\r
 Arguments:\r
   AdapterInfo - pointer to the structure that contains the NIC's context.\r
   RegAddress - The MII register that we are writing to\r
 Arguments:\r
   AdapterInfo - pointer to the structure that contains the NIC's context.\r
   RegAddress - The MII register that we are writing to\r
@@ -2567,13 +2567,13 @@ Arguments:
   DataValue - The value that we are writing to the MII register.\r
 \r
 Returns:\r
   DataValue - The value that we are writing to the MII register.\r
 \r
 Returns:\r
- nothing  \r
+ nothing\r
 --*/\r
 {\r
   UINT32  WriteCommand;\r
 \r
   WriteCommand = ((UINT32) DataValue) |\r
 --*/\r
 {\r
   UINT32  WriteCommand;\r
 \r
   WriteCommand = ((UINT32) DataValue) |\r
-                 ((UINT32)(RegAddress << 16)) | \r
+                 ((UINT32)(RegAddress << 16)) |\r
                  ((UINT32)(PhyAddress << 21)) |\r
                  ((UINT32)(MDI_WRITE << 26));\r
 \r
                  ((UINT32)(PhyAddress << 21)) |\r
                  ((UINT32)(MDI_WRITE << 26));\r
 \r
@@ -2589,7 +2589,7 @@ Returns:
 \r
   //\r
   // poll for the mdi write to complete\r
 \r
   //\r
   // poll for the mdi write to complete\r
-  while ((InLong (AdapterInfo, AdapterInfo->ioaddr + SCBCtrlMDI) & \r
+  while ((InLong (AdapterInfo, AdapterInfo->ioaddr + SCBCtrlMDI) &\r
                     MDI_PHY_READY) == 0){\r
     DelayIt (AdapterInfo, 20);\r
   }\r
                     MDI_PHY_READY) == 0){\r
     DelayIt (AdapterInfo, 20);\r
   }\r
@@ -2608,7 +2608,7 @@ Routine Description:
  This routine will read a value from the specified MII register\r
  of an external MDI compliant device (e.g. PHY 100), and return\r
  it to the calling routine.  The command will execute in polled mode.\r
  This routine will read a value from the specified MII register\r
  of an external MDI compliant device (e.g. PHY 100), and return\r
  it to the calling routine.  The command will execute in polled mode.\r
\r
+\r
 Arguments:\r
  AdapterInfo - pointer to the structure that contains the NIC's context.\r
  RegAddress - The MII register that we are reading from\r
 Arguments:\r
  AdapterInfo - pointer to the structure that contains the NIC's context.\r
  RegAddress - The MII register that we are reading from\r
@@ -2616,7 +2616,7 @@ Arguments:
  DataValue - pointer to the value that we read from the MII register.\r
 \r
 Returns:\r
  DataValue - pointer to the value that we read from the MII register.\r
 \r
 Returns:\r
-  \r
+\r
 --*/\r
 {\r
   UINT32  ReadCommand;\r
 --*/\r
 {\r
   UINT32  ReadCommand;\r
@@ -2655,19 +2655,19 @@ PhyReset (
 \r
 Routine Description:\r
  This routine will reset the PHY that the adapter is currently\r
 \r
 Routine Description:\r
  This routine will reset the PHY that the adapter is currently\r
- configured to use. \r
\r
+ configured to use.\r
+\r
 Arguments:\r
   AdapterInfo - pointer to the structure that contains the NIC's context.\r
 \r
 Returns:\r
 Arguments:\r
   AdapterInfo - pointer to the structure that contains the NIC's context.\r
 \r
 Returns:\r
-  \r
+\r
 --*/\r
 {\r
   UINT16  MdiControlReg;\r
 \r
 --*/\r
 {\r
   UINT16  MdiControlReg;\r
 \r
-  MdiControlReg = (MDI_CR_AUTO_SELECT | \r
-                  MDI_CR_RESTART_AUTO_NEG | \r
+  MdiControlReg = (MDI_CR_AUTO_SELECT |\r
+                  MDI_CR_RESTART_AUTO_NEG |\r
                   MDI_CR_RESET);\r
 \r
   //\r
                   MDI_CR_RESET);\r
 \r
   //\r
@@ -2721,14 +2721,14 @@ Routine Description:
               this range.\r
           6.  Driver ignores FORCEFDX and SPEED overrides if a 503 interface\r
               is detected.\r
               this range.\r
           6.  Driver ignores FORCEFDX and SPEED overrides if a 503 interface\r
               is detected.\r
\r
+\r
 Arguments:\r
   AdapterInfo - pointer to the structure that contains the NIC's context.\r
 \r
 Returns:\r
   TRUE - If a Phy was detected, and configured correctly.\r
 Arguments:\r
   AdapterInfo - pointer to the structure that contains the NIC's context.\r
 \r
 Returns:\r
   TRUE - If a Phy was detected, and configured correctly.\r
-  FALSE - If a valid phy could not be detected and configured. \r
-  \r
+  FALSE - If a valid phy could not be detected and configured.\r
+\r
 --*/\r
 {\r
   UINT16  *eedata;\r
 --*/\r
 {\r
   UINT16  *eedata;\r
@@ -2788,7 +2788,7 @@ Returns:
       &MdiStatusReg\r
       );\r
 \r
       &MdiStatusReg\r
       );\r
 \r
-    if (!((MdiControlReg == 0xffff) || \r
+    if (!((MdiControlReg == 0xffff) ||\r
           ((MdiStatusReg == 0) && (MdiControlReg == 0)))) {\r
 \r
       //\r
           ((MdiStatusReg == 0) && (MdiControlReg == 0)))) {\r
 \r
       //\r
@@ -3030,9 +3030,9 @@ Arguments:
 \r
 Returns:\r
  TRUE - If the phy could be configured correctly\r
 \r
 Returns:\r
  TRUE - If the phy could be configured correctly\r
- FALSE - If the phy couldn't be configured correctly, because an \r
+ FALSE - If the phy couldn't be configured correctly, because an\r
          unsupported over-ride option was used\r
          unsupported over-ride option was used\r
-  \r
+\r
 --*/\r
 {\r
   UINT16  MdiControlReg;\r
 --*/\r
 {\r
   UINT16  MdiControlReg;\r
@@ -3258,7 +3258,7 @@ Returns:
   // value accordingly\r
   //\r
   AdapterInfo->LinkSpeed  = AdapterInfo->LinkSpeedReq;\r
   // value accordingly\r
   //\r
   AdapterInfo->LinkSpeed  = AdapterInfo->LinkSpeedReq;\r
-  AdapterInfo->Duplex = (UINT8) ((AdapterInfo->DuplexReq & PXE_FORCE_FULL_DUPLEX) ? \r
+  AdapterInfo->Duplex = (UINT8) ((AdapterInfo->DuplexReq & PXE_FORCE_FULL_DUPLEX) ?\r
                         FULL_DUPLEX : HALF_DUPLEX);\r
 \r
   //\r
                         FULL_DUPLEX : HALF_DUPLEX);\r
 \r
   //\r
@@ -3363,7 +3363,7 @@ Returns:
   // advertised ablilities, and then assuming that the highest common\r
   // denominator was chosed by NWAY.\r
   //\r
   // advertised ablilities, and then assuming that the highest common\r
   // denominator was chosed by NWAY.\r
   //\r
-  if ((MdiLinkPartnerAdReg & NWAY_LP_ABILITY) && \r
+  if ((MdiLinkPartnerAdReg & NWAY_LP_ABILITY) &&\r
       (MdiStatusReg & MDI_SR_AUTO_NEG_COMPLETE)) {\r
 \r
     //\r
       (MdiStatusReg & MDI_SR_AUTO_NEG_COMPLETE)) {\r
 \r
     //\r