]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Fixed one bug in Undi driver.
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 30 Aug 2007 06:58:37 +0000 (06:58 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 30 Aug 2007 06:58:37 +0000 (06:58 +0000)
2. Add default branch to meet CYGWINGCC build in Tcp4Dispatcher.c.
3. Sync the latest network stack library.
4. Fixed one bug in Mtftp4Support.c, for AsciiStrCpy() return the pointer to head of string, not the tail of string.

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

MdeModulePkg/Bus/Pci/UndiRuntimeDxe/E100b.c
MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c
MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c
MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c

index 4ca431c520ad25af2e3c4a5e61ba689595bd4ded..2bd7813b18c8305a045cdd19f7f769c6f92f4009 100644 (file)
@@ -1,17 +1,17 @@
 /*++\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
-  \r
+\r
+\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
-                    (UINT8)0xf2, (UINT8)0x80, // 0x40=Force full-duplex \r
+                    (UINT8)0xf2, (UINT8)0x80, // 0x40=Force full-duplex\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
-  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
+\r
 Arguments:\r
   Port              - Which port to read from.\r
 \r
@@ -76,9 +76,9 @@ Returns:
   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
@@ -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
-  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
@@ -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
-  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
@@ -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
-  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
@@ -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
-  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
@@ -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
-  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
@@ -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
-  \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].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
@@ -2032,7 +2032,7 @@ Returns:
   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
@@ -2074,12 +2074,12 @@ Arguments:
 \r
 Returns:\r
  None\r
\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
@@ -2396,7 +2396,7 @@ Returns:
   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
@@ -2557,9 +2557,9 @@ MdiWrite (
 \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
\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
@@ -2567,13 +2567,13 @@ Arguments:
   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
-                 ((UINT32)(RegAddress << 16)) | \r
+                 ((UINT32)(RegAddress << 16)) |\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
-  while ((InLong (AdapterInfo, AdapterInfo->ioaddr + SCBCtrlMDI) & \r
+  while ((InLong (AdapterInfo, AdapterInfo->ioaddr + SCBCtrlMDI) &\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
\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
@@ -2616,7 +2616,7 @@ Arguments:
  DataValue - pointer to the value that we read from the MII register.\r
 \r
 Returns:\r
-  \r
+\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
- 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
-  \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
@@ -2721,14 +2721,14 @@ Routine Description:
               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
-  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
@@ -2788,7 +2788,7 @@ Returns:
       &MdiStatusReg\r
       );\r
 \r
-    if (!((MdiControlReg == 0xffff) || \r
+    if (!((MdiControlReg == 0xffff) ||\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
- 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
-  \r
+\r
 --*/\r
 {\r
   UINT16  MdiControlReg;\r
@@ -3258,7 +3258,7 @@ Returns:
   // 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
@@ -3363,7 +3363,7 @@ Returns:
   // 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
index 98df75df11ce78d380ec5c30564676a7666f9bd2..cc869717dd047af7552b8c29579d2180a35838ea 100644 (file)
@@ -29,6 +29,7 @@ Abstract:
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
 \r
 \r
 #define NET_PROTO_HDR(Buf, Type)  ((Type *) ((Buf)->BlockOp[0].Head))\r
@@ -416,13 +417,13 @@ IpIoCreateSndEntry (
     //\r
     // Set the fields of OverrideData\r
     //\r
-    *OverrideData = * (EFI_IP4_OVERRIDE_DATA *) Override;\r
+    NetCopyMem (OverrideData, Override, sizeof (*OverrideData));\r
   }\r
 \r
   //\r
   // Set the fields of TxData\r
   //\r
-  EFI_IP4 (TxData->DestinationAddress)  = Dest;\r
+  NetCopyMem (&TxData->DestinationAddress, &Dest, sizeof (EFI_IPv4_ADDRESS));\r
   TxData->OverrideData                  = OverrideData;\r
   TxData->OptionsLength                 = 0;\r
   TxData->OptionsBuffer                 = NULL;\r
@@ -761,7 +762,6 @@ IpIoOpen (
 {\r
   EFI_STATUS        Status;\r
   EFI_IP4_PROTOCOL  *Ip;\r
-  EFI_IPv4_ADDRESS  ZeroIp;\r
 \r
   if (IpIo->IsConfigured) {\r
     return EFI_ACCESS_DENIED;\r
@@ -782,8 +782,7 @@ IpIoOpen (
   // (0.0.0.0, 0.0.0.0, 0.0.0.0). Delete this statement if Ip modified\r
   // its code\r
   //\r
-  EFI_IP4 (ZeroIp) = 0;\r
-  Status = Ip->Routes (Ip, TRUE, &ZeroIp, &ZeroIp, &ZeroIp);\r
+  Status = Ip->Routes (Ip, TRUE, &mZeroIp4Addr, &mZeroIp4Addr, &mZeroIp4Addr);\r
 \r
   if (EFI_ERROR (Status) && (EFI_NOT_FOUND != Status)) {\r
     return Status;\r
@@ -1147,8 +1146,8 @@ IpIoConfigIp (
       Ip4ConfigData->SubnetMask     = Ip4ModeData.ConfigData.SubnetMask;\r
     }\r
 \r
-    IpInfo->Addr       = EFI_IP4 (Ip4ConfigData->StationAddress);\r
-    IpInfo->SubnetMask = EFI_IP4 (Ip4ConfigData->SubnetMask);\r
+    NetCopyMem (&IpInfo->Addr, &Ip4ConfigData->StationAddress, sizeof (IP4_ADDR));\r
+    NetCopyMem (&IpInfo->SubnetMask, &Ip4ConfigData->SubnetMask, sizeof (IP4_ADDR));\r
 \r
     Status = Ip->Receive (Ip, &IpInfo->DummyRcvToken);\r
     if (EFI_ERROR (Status)) {\r
index c797952f65842ea5f122a1c8941c34aad42c10f4..c844a841006bfd528c4d9ca8e9a9196895468cbf 100644 (file)
@@ -46,6 +46,7 @@
   DebugLib\r
   UefiBootServicesTableLib\r
   MemoryAllocationLib\r
+  BaseMemoryLib\r
 \r
 [Protocols]\r
   gEfiIp4ProtocolGuid                           # PROTOCOL ALWAYS_CONSUMED\r
index b66348c284c9c7401e5f725c99c52fc7cd79cc5e..d56456afb20e59aabde2f1643e6d7c7e729dd1af 100644 (file)
@@ -30,6 +30,7 @@ Abstract:
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
+#include <library/BaseMemoryLib.h>\r
 \r
 STATIC\r
 VOID\r
@@ -77,6 +78,7 @@ UdpIoWrapTx (
   EFI_UDP4_TRANSMIT_DATA    *UdpTxData;\r
   EFI_STATUS                Status;\r
   UINT32                    Count;\r
+  IP4_ADDR                  Ip;\r
 \r
   Token = NetAllocatePool (sizeof (UDP_TX_TOKEN) +\r
                            sizeof (EFI_UDP4_FRAGMENT_DATA) * (Packet->BlockOpNum - 1));\r
@@ -116,15 +118,21 @@ UdpIoWrapTx (
   UdpTxData->GatewayAddress = NULL;\r
 \r
   if (EndPoint != NULL) {\r
-    EFI_IP4 (Token->UdpSession.SourceAddress)      = HTONL (EndPoint->LocalAddr);\r
-    EFI_IP4 (Token->UdpSession.DestinationAddress) = HTONL (EndPoint->RemoteAddr);\r
-    Token->UdpSession.SourcePort                   = EndPoint->LocalPort;\r
-    Token->UdpSession.DestinationPort              = EndPoint->RemotePort;\r
-    UdpTxData->UdpSessionData                      = &Token->UdpSession;\r
+    Ip = HTONL (EndPoint->LocalAddr);\r
+    NetCopyMem (&Token->UdpSession.SourceAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
+\r
+    Ip = HTONL (EndPoint->RemoteAddr);\r
+    NetCopyMem (&Token->UdpSession.DestinationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
+\r
+    Token->UdpSession.SourcePort      = EndPoint->LocalPort;\r
+    Token->UdpSession.DestinationPort = EndPoint->RemotePort;\r
+    UdpTxData->UdpSessionData         = &Token->UdpSession;\r
   }\r
 \r
   if (Gateway != 0) {\r
-    EFI_IP4 (Token->Gateway)  = HTONL (Gateway);\r
+    Ip = HTONL (Gateway);\r
+    NetCopyMem (&Token->Gateway, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
+\r
     UdpTxData->GatewayAddress = &Token->Gateway;\r
   }\r
 \r
@@ -670,11 +678,14 @@ UdpIoOnDgramRcvd (
   }\r
 \r
   UdpSession        = &UdpRxData->UdpSession;\r
-  Points.LocalAddr  = EFI_NTOHL (UdpSession->DestinationAddress);\r
   Points.LocalPort  = UdpSession->DestinationPort;\r
-  Points.RemoteAddr = EFI_NTOHL (UdpSession->SourceAddress);\r
   Points.RemotePort = UdpSession->SourcePort;\r
 \r
+  NetCopyMem (&Points.LocalAddr, &UdpSession->DestinationAddress, sizeof (IP4_ADDR));\r
+  NetCopyMem (&Points.RemoteAddr, &UdpSession->SourceAddress, sizeof (IP4_ADDR));\r
+  Points.LocalAddr  = NTOHL (Points.LocalAddr);\r
+  Points.RemoteAddr = NTOHL (Points.RemoteAddr);\r
+\r
   Token->CallBack (Netbuf, &Points, EFI_SUCCESS, Token->Context);\r
 \r
 ON_EXIT:\r
index 32ccb96c3219160ba243584b2ef104772614f3d6..7a20e80d3c48dc7ca7fc0bb3db949b5897ce138a 100644 (file)
@@ -46,6 +46,7 @@
   DebugLib\r
   UefiBootServicesTableLib\r
   MemoryAllocationLib\r
+  BaseMemoryLib\r
 \r
 [Protocols]\r
   gEfiUdp4ServiceBindingProtocolGuid            # PROTOCOL ALWAYS_CONSUMED\r
index 903494ecb732fab970c0c48435bb1de5628888ed..28082db04290bfb6527105b2db02dce33604345e 100644 (file)
@@ -305,11 +305,16 @@ Mtftp4SendRequest (
   Packet->OpCode = HTONS (Instance->Operation);\r
   Cur            = Packet->Rrq.Filename;\r
   Cur            = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Token->Filename);\r
+  Cur           += AsciiStrLen ((CHAR8 *) Token->Filename);\r
   Cur            = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Mode);\r
+  Cur           += AsciiStrLen ((CHAR8 *) Mode);\r
 \r
   for (Index = 0; Index < Token->OptionCount; ++Index) {\r
-    Cur = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Options[Index].OptionStr);\r
-    Cur = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Options[Index].ValueStr);\r
+    Cur  = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Options[Index].OptionStr);\r
+    Cur += AsciiStrLen ((CHAR8 *) Options[Index].OptionStr);\r
+\r
+    Cur  = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Options[Index].ValueStr);\r
+    Cur += AsciiStrLen ((CHAR8 *) (CHAR8 *) Options[Index].ValueStr);\r
   }\r
 \r
   return Mtftp4SendPacket (Instance, Nbuf);\r
index 0b845ee9adf996f726b7565e6389af083e3b8297..a6a6913333333334317a9281278f722c8c349f17 100644 (file)
@@ -707,6 +707,8 @@ Tcp4Dispatcher (
 \r
     return Tcp4Route (Tcb, (TCP4_ROUTE_INFO *) Data);\r
 \r
+  default:\r
+    return EFI_UNSUPPORTED;\r
   }\r
 \r
   return EFI_SUCCESS;\r