]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
BaseTools:Change the path of the file that Binary Cache
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Impl.c
index 54384e143e2d290668c2d6687a7bc63d38309389..70bd693e4e3a6f172a543421a850e10cf5bebd1d 100644 (file)
@@ -1,15 +1,9 @@
 /** @file\r
   Interface routine for Mtftp4.\r
-  \r
-(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
-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<BR>\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
+(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -80,6 +74,9 @@ Mtftp4CleanOperation (
   Instance->Operation     = 0;\r
 \r
   Instance->BlkSize       = MTFTP4_DEFAULT_BLKSIZE;\r
+  Instance->WindowSize    = 1;\r
+  Instance->TotalBlock    = 0;\r
+  Instance->AckedBlock    = 0;\r
   Instance->LastBlock     = 0;\r
   Instance->ServerIp      = 0;\r
   Instance->ListeningPort = 0;\r
@@ -96,9 +93,9 @@ Mtftp4CleanOperation (
 \r
 \r
 /**\r
-  Check packet for GetInfo. \r
-  \r
-  GetInfo is implemented with EfiMtftp4ReadFile. It use Mtftp4GetInfoCheckPacket \r
+  Check packet for GetInfo.\r
+\r
+  GetInfo is implemented with EfiMtftp4ReadFile. It use Mtftp4GetInfoCheckPacket\r
   to inspect the first packet from server, then abort the session.\r
 \r
   @param  This                   The MTFTP4 protocol instance\r
@@ -167,10 +164,10 @@ Mtftp4GetInfoCheckPacket (
 \r
 \r
 /**\r
-  Check whether the override data is valid. \r
-  \r
+  Check whether the override data is valid.\r
+\r
   It will first validate whether the server is a valid unicast. If a gateway\r
-  is provided in the Override, it also check that it is a unicast on the \r
+  is provided in the Override, it also check that it is a unicast on the\r
   connected network.\r
 \r
   @param  Instance               The MTFTP instance\r
@@ -178,7 +175,7 @@ Mtftp4GetInfoCheckPacket (
 \r
   @retval TRUE                   The override data is valid\r
   @retval FALSE                  The override data is invalid\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 Mtftp4OverrideValid (\r
@@ -219,9 +216,9 @@ Mtftp4OverrideValid (
 \r
 /**\r
   Poll the UDP to get the IP4 default address, which may be retrieved\r
-  by DHCP. \r
-  \r
-  The default time out value is 5 seconds. If IP has retrieved the default address, \r
+  by DHCP.\r
+\r
+  The default time out value is 5 seconds. If IP has retrieved the default address,\r
   the UDP is reconfigured.\r
 \r
   @param  Instance               The Mtftp instance\r
@@ -308,7 +305,7 @@ Mtftp4ConfigUnicastPort (
   UdpConfig.UseDefaultAddress  = Config->UseDefaultSetting;\r
   IP4_COPY_ADDRESS (&UdpConfig.StationAddress, &Config->StationIp);\r
   IP4_COPY_ADDRESS (&UdpConfig.SubnetMask, &Config->SubnetMask);\r
-  UdpConfig.StationPort        = 0;\r
+  UdpConfig.StationPort        = Config->LocalPort;\r
   UdpConfig.RemotePort         = 0;\r
 \r
   Ip = HTONL (Instance->ServerIp);\r
@@ -366,6 +363,7 @@ Mtftp4Start (
   EFI_MTFTP4_CONFIG_DATA    *Config;\r
   EFI_TPL                   OldTpl;\r
   EFI_STATUS                Status;\r
+  EFI_STATUS                TokenStatus;\r
 \r
   //\r
   // Validate the parameters\r
@@ -393,7 +391,9 @@ Mtftp4Start (
 \r
   Instance = MTFTP4_PROTOCOL_FROM_THIS (This);\r
 \r
-  Status = EFI_SUCCESS;\r
+  Status      = EFI_SUCCESS;\r
+  TokenStatus = EFI_SUCCESS;\r
+\r
   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
 \r
   if (Instance->State != MTFTP4_STATE_CONFIGED) {\r
@@ -404,6 +404,10 @@ Mtftp4Start (
     Status = EFI_ACCESS_DENIED;\r
   }\r
 \r
+  if ((Token->OverrideData != NULL) && !Mtftp4OverrideValid (Instance, Token->OverrideData)) {\r
+    Status = EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   if (EFI_ERROR (Status)) {\r
     gBS->RestoreTPL (OldTpl);\r
     return Status;\r
@@ -416,20 +420,17 @@ Mtftp4Start (
   Instance->Operation = Operation;\r
   Override            = Token->OverrideData;\r
 \r
-  if ((Override != NULL) && !Mtftp4OverrideValid (Instance, Override)) {\r
-    Status = EFI_INVALID_PARAMETER;\r
-    goto ON_ERROR;\r
-  }\r
-\r
   if (Token->OptionCount != 0) {\r
     Status = Mtftp4ParseOption (\r
                Token->OptionList,\r
                Token->OptionCount,\r
                TRUE,\r
+               Instance->Operation,\r
                &Instance->RequestOption\r
                );\r
 \r
     if (EFI_ERROR (Status)) {\r
+      TokenStatus = EFI_DEVICE_ERROR;\r
       goto ON_ERROR;\r
     }\r
   }\r
@@ -440,6 +441,7 @@ Mtftp4Start (
   Config                  = &Instance->Config;\r
   Instance->Token         = Token;\r
   Instance->BlkSize       = MTFTP4_DEFAULT_BLKSIZE;\r
+  Instance->WindowSize    = MTFTP4_DEFAULT_WINDOWSIZE;\r
 \r
   CopyMem (&Instance->ServerIp, &Config->ServerIp, sizeof (IP4_ADDR));\r
   Instance->ServerIp      = NTOHL (Instance->ServerIp);\r
@@ -482,8 +484,8 @@ Mtftp4Start (
   // Config the unicast UDP child to send initial request\r
   //\r
   Status = Mtftp4ConfigUnicastPort (Instance->UnicastPort, Instance);\r
-\r
   if (EFI_ERROR (Status)) {\r
+    TokenStatus = EFI_DEVICE_ERROR;\r
     goto ON_ERROR;\r
   }\r
 \r
@@ -501,12 +503,13 @@ Mtftp4Start (
     Status = Mtftp4RrqStart (Instance, Operation);\r
   }\r
 \r
-  gBS->RestoreTPL (OldTpl);\r
-\r
   if (EFI_ERROR (Status)) {\r
+    TokenStatus = EFI_DEVICE_ERROR;\r
     goto ON_ERROR;\r
   }\r
 \r
+  gBS->RestoreTPL(OldTpl);\r
+\r
   if (Token->Event != NULL) {\r
     return EFI_SUCCESS;\r
   }\r
@@ -522,7 +525,7 @@ Mtftp4Start (
   return Token->Status;\r
 \r
 ON_ERROR:\r
-  Mtftp4CleanOperation (Instance, Status);\r
+  Mtftp4CleanOperation (Instance, TokenStatus);\r
   gBS->RestoreTPL (OldTpl);\r
 \r
   return Status;\r
@@ -532,17 +535,17 @@ ON_ERROR:
 /**\r
   Reads the current operational settings.\r
 \r
-  The GetModeData()function reads the current operational settings of this \r
+  The GetModeData()function reads the current operational settings of this\r
   EFI MTFTPv4 Protocol driver instance.\r
 \r
   @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance.\r
   @param  ModeData               Pointer to storage for the EFI MTFTPv4 Protocol\r
-                                 driver mode data. \r
+                                 driver mode data.\r
 \r
   @retval EFI_SUCCESS            The configuration data was successfully returned.\r
   @retval EFI_OUT_OF_RESOURCES   The required mode data could not be allocated.\r
   @retval EFI_INVALID_PARAMETER  This is NULL or ModeData is NULL.\r
-  \r
+\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -575,49 +578,49 @@ EfiMtftp4GetModeData (
 \r
 \r
 /**\r
-  Initializes, changes, or resets the default operational setting for this \r
+  Initializes, changes, or resets the default operational setting for this\r
   EFI MTFTPv4 Protocol driver instance.\r
-  \r
-  The Configure() function is used to set and change the configuration data for \r
-  this EFI MTFTPv4 Protocol driver instance. The configuration data can be reset \r
-  to startup defaults by calling Configure() with MtftpConfigData set to NULL. \r
-  Whenever the instance is reset, any pending operation is aborted. By changing \r
-  the EFI MTFTPv4 Protocol driver instance configuration data, the client can \r
-  connect to different MTFTPv4 servers. The configuration parameters in \r
-  MtftpConfigData are used as the default parameters in later MTFTPv4 operations \r
+\r
+  The Configure() function is used to set and change the configuration data for\r
+  this EFI MTFTPv4 Protocol driver instance. The configuration data can be reset\r
+  to startup defaults by calling Configure() with MtftpConfigData set to NULL.\r
+  Whenever the instance is reset, any pending operation is aborted. By changing\r
+  the EFI MTFTPv4 Protocol driver instance configuration data, the client can\r
+  connect to different MTFTPv4 servers. The configuration parameters in\r
+  MtftpConfigData are used as the default parameters in later MTFTPv4 operations\r
   and can be overridden in later operations.\r
-  \r
+\r
   @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance\r
-  @param  ConfigData             MtftpConfigDataPointer to the configuration data \r
+  @param  ConfigData             MtftpConfigDataPointer to the configuration data\r
                                  structure\r
 \r
-  @retval EFI_SUCCESS            The EFI MTFTPv4 Protocol driver was configured \r
+  @retval EFI_SUCCESS            The EFI MTFTPv4 Protocol driver was configured\r
                                  successfully.\r
   @retval EFI_INVALID_PARAMETER  One or more following conditions are TRUE:\r
                                  1.This is NULL.\r
-                                 2.MtftpConfigData.UseDefaultSetting is FALSE and \r
-                                   MtftpConfigData.StationIp is not a valid IPv4 \r
+                                 2.MtftpConfigData.UseDefaultSetting is FALSE and\r
+                                   MtftpConfigData.StationIp is not a valid IPv4\r
                                    unicast address.\r
-                                 3.MtftpCofigData.UseDefaultSetting is FALSE and \r
+                                 3.MtftpCofigData.UseDefaultSetting is FALSE and\r
                                    MtftpConfigData.SubnetMask is invalid.\r
-                                 4.MtftpCofigData.ServerIp is not a valid IPv4 \r
+                                 4.MtftpCofigData.ServerIp is not a valid IPv4\r
                                    unicast address.\r
-                                 5.MtftpConfigData.UseDefaultSetting is FALSE and \r
-                                   MtftpConfigData.GatewayIp is not a valid IPv4 \r
-                                   unicast address or is not in the same subnet \r
+                                 5.MtftpConfigData.UseDefaultSetting is FALSE and\r
+                                   MtftpConfigData.GatewayIp is not a valid IPv4\r
+                                   unicast address or is not in the same subnet\r
                                    with station address.\r
-  @retval EFI_ACCESS_DENIED      The EFI configuration could not be changed at this \r
-                                 time because there is one MTFTP background operation \r
+  @retval EFI_ACCESS_DENIED      The EFI configuration could not be changed at this\r
+                                 time because there is one MTFTP background operation\r
                                  in progress.\r
-  @retval EFI_NO_MAPPING         When using a default address, configuration \r
+  @retval EFI_NO_MAPPING         When using a default address, configuration\r
                                  (DHCP, BOOTP, RARP, etc.) has not finished yet.\r
-  @retval EFI_UNSUPPORTED        A configuration protocol (DHCP, BOOTP, RARP, etc.) \r
-                                 could not be located when clients choose to use \r
+  @retval EFI_UNSUPPORTED        A configuration protocol (DHCP, BOOTP, RARP, etc.)\r
+                                 could not be located when clients choose to use\r
                                  the default address settings.\r
-  @retval EFI_OUT_OF_RESOURCES   The EFI MTFTPv4 Protocol driver instance data could \r
+  @retval EFI_OUT_OF_RESOURCES   The EFI MTFTPv4 Protocol driver instance data could\r
                                  not be allocated.\r
-  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred. \r
-                                 The EFI MTFTPv4 Protocol driver instance is not \r
+  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.\r
+                                 The EFI MTFTPv4 Protocol driver instance is not\r
                                  configured.\r
 \r
 **/\r
@@ -677,8 +680,8 @@ EfiMtftp4Configure (
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
-    if ((Gateway != 0) && \r
-        (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || (Netmask != 0 && !NetIp4IsUnicast (Gateway, Netmask)))) {\r
+    if ((Gateway != 0) &&\r
+        ((Netmask != 0xFFFFFFFF && !IP4_NET_EQUAL (Gateway, Ip, Netmask)) || (Netmask != 0 && !NetIp4IsUnicast (Gateway, Netmask)))) {\r
 \r
       return EFI_INVALID_PARAMETER;\r
     }\r
@@ -703,21 +706,21 @@ EfiMtftp4Configure (
 \r
 /**\r
   Parses the options in an MTFTPv4 OACK packet.\r
-  \r
-  The ParseOptions() function parses the option fields in an MTFTPv4 OACK packet \r
-  and returns the number of options that were found and optionally a list of \r
+\r
+  The ParseOptions() function parses the option fields in an MTFTPv4 OACK packet\r
+  and returns the number of options that were found and optionally a list of\r
   pointers to the options in the packet.\r
-  If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is \r
+  If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is\r
   returned and *OptionCount and *OptionList stop at the last valid option.\r
   The OptionList is allocated by this function, and caller should free it when used.\r
 \r
   @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance.\r
   @param  PacketLen              Length of the OACK packet to be parsed.\r
-  @param  Packet                 Pointer to the OACK packet to be parsed. \r
+  @param  Packet                 Pointer to the OACK packet to be parsed.\r
   @param  OptionCount            Pointer to the number of options in following OptionList.\r
-  @param  OptionList             Pointer to EFI_MTFTP4_OPTION storage. Call the \r
+  @param  OptionList             Pointer to EFI_MTFTP4_OPTION storage. Call the\r
                                  EFI Boot Service FreePool() to release theOptionList\r
-                                 if the options in this OptionList are not needed \r
+                                 if the options in this OptionList are not needed\r
                                  any more\r
 \r
   @retval EFI_SUCCESS            The OACK packet was valid and the OptionCount and\r
@@ -765,25 +768,25 @@ EfiMtftp4ParseOptions (
 \r
 /**\r
   Downloads a file from an MTFTPv4 server.\r
-  \r
-  The ReadFile() function is used to initialize and start an MTFTPv4 download \r
-  process and optionally wait for completion. When the download operation completes, \r
-  whether successfully or not, the Token.Status field is updated by the EFI MTFTPv4 \r
+\r
+  The ReadFile() function is used to initialize and start an MTFTPv4 download\r
+  process and optionally wait for completion. When the download operation completes,\r
+  whether successfully or not, the Token.Status field is updated by the EFI MTFTPv4\r
   Protocol driver and then Token.Event is signaled (if it is not NULL).\r
   Data can be downloaded from the MTFTPv4 server into either of the following locations:\r
   1.A fixed buffer that is pointed to by Token.Buffer\r
   2.A download service function that is pointed to by Token.CheckPacket\r
-  If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket \r
-  will be called first. If the call is successful, the packet will be stored in \r
+  If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket\r
+  will be called first. If the call is successful, the packet will be stored in\r
   Token.Buffer.\r
 \r
   @param  This                  Pointer to the EFI_MTFTP4_PROTOCOL instance\r
-  @param  Token                 Pointer to the token structure to provide the \r
+  @param  Token                 Pointer to the token structure to provide the\r
                                 parameters that are used in this operation.\r
 \r
   @retval EFI_SUCCESS           The data file has been transferred successfully.\r
   @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.\r
-  @retval EFI_BUFFER_TOO_SMALL  BufferSize is not large enough to hold the downloaded \r
+  @retval EFI_BUFFER_TOO_SMALL  BufferSize is not large enough to hold the downloaded\r
                                 data in downloading process.\r
   @retval EFI_ABORTED           Current operation is aborted by user.\r
   @retval EFI_ICMP_ERROR        An ICMP ERROR packet was received.\r
@@ -807,24 +810,24 @@ EfiMtftp4ReadFile (
 /**\r
   Sends a data file to an MTFTPv4 server. May be unsupported in some EFI implementations\r
 \r
-  The WriteFile() function is used to initialize an uploading operation with the \r
-  given option list and optionally wait for completion. If one or more of the \r
-  options is not supported by the server, the unsupported options are ignored and \r
-  a standard TFTP process starts instead. When the upload process completes, \r
-  whether successfully or not, Token.Event is signaled, and the EFI MTFTPv4 Protocol \r
+  The WriteFile() function is used to initialize an uploading operation with the\r
+  given option list and optionally wait for completion. If one or more of the\r
+  options is not supported by the server, the unsupported options are ignored and\r
+  a standard TFTP process starts instead. When the upload process completes,\r
+  whether successfully or not, Token.Event is signaled, and the EFI MTFTPv4 Protocol\r
   driver updates Token.Status.\r
   The caller can supply the data to be uploaded in the following two modes:\r
   1.Through the user-provided buffer\r
   2.Through a callback function\r
   With the user-provided buffer, the Token.BufferSize field indicates the length\r
-  of the buffer, and the driver will upload the data in the buffer. With an \r
-  EFI_MTFTP4_PACKET_NEEDED callback function, the driver will call this callback \r
-  function to get more data from the user to upload. See the definition of \r
-  EFI_MTFTP4_PACKET_NEEDED for more information. These two modes cannot be used at \r
+  of the buffer, and the driver will upload the data in the buffer. With an\r
+  EFI_MTFTP4_PACKET_NEEDED callback function, the driver will call this callback\r
+  function to get more data from the user to upload. See the definition of\r
+  EFI_MTFTP4_PACKET_NEEDED for more information. These two modes cannot be used at\r
   the same time. The callback function will be ignored if the user provides the buffer.\r
 \r
   @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance.\r
-  @param  Token                  Pointer to the token structure to provide the \r
+  @param  Token                  Pointer to the token structure to provide the\r
                                  parameters that are used in this function\r
 \r
   @retval EFI_SUCCESS            The upload session has started.\r
@@ -839,15 +842,15 @@ EfiMtftp4ReadFile (
                                     format.\r
                                  6. Token.Buffer and Token.PacketNeeded are both\r
                                     NULL.\r
-                                 7. One or more IPv4 addresses in Token.OverrideData \r
-                                    are not valid unicast IPv4 addresses if \r
+                                 7. One or more IPv4 addresses in Token.OverrideData\r
+                                    are not valid unicast IPv4 addresses if\r
                                     Token.OverrideData is not NULL.\r
   @retval EFI_UNSUPPORTED        One or more options in the Token.OptionList are in the\r
                                  unsupported list of structure EFI_MTFTP4_MODE_DATA.\r
   @retval EFI_NOT_STARTED        The EFI MTFTPv4 Protocol driver has not been started.\r
-  @retval EFI_NO_MAPPING         When using a default address, configuration (DHCP, \r
+  @retval EFI_NO_MAPPING         When using a default address, configuration (DHCP,\r
                                  BOOTP, RARP, etc.) is not finished yet.\r
-  @retval EFI_ALREADY_STARTED    This Token is already being used in another MTFTPv4 \r
+  @retval EFI_ALREADY_STARTED    This Token is already being used in another MTFTPv4\r
                                  session.\r
   @retval EFI_OUT_OF_RESOURCES   Required system resources could not be allocated.\r
   @retval EFI_ACCESS_DENIED      The previous operation has not completed yet.\r
@@ -866,35 +869,35 @@ EfiMtftp4WriteFile (
 \r
 \r
 /**\r
-  Downloads a data file "directory" from an MTFTPv4 server. \r
+  Downloads a data file "directory" from an MTFTPv4 server.\r
   May be unsupported in some EFI implementations\r
-  \r
-  The ReadDirectory() function is used to return a list of files on the MTFTPv4 \r
-  server that are logically (or operationally) related to Token.Filename. The \r
-  directory request packet that is sent to the server is built with the option \r
+\r
+  The ReadDirectory() function is used to return a list of files on the MTFTPv4\r
+  server that are logically (or operationally) related to Token.Filename. The\r
+  directory request packet that is sent to the server is built with the option\r
   list that was provided by caller, if present.\r
-  The file information that the server returns is put into either of the following \r
+  The file information that the server returns is put into either of the following\r
   locations:\r
   1.A fixed buffer that is pointed to by Token.Buffer\r
   2.A download service function that is pointed to by Token.CheckPacket\r
-  If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket will \r
+  If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket will\r
   be called first. If the call is successful, the packet will be stored in Token.Buffer.\r
-  The returned directory listing in the Token.Buffer or EFI_MTFTP4_PACKET consists \r
-  of a list of two or three variable-length ASCII strings, each terminated by a \r
-  null character, for each file in the directory. If the multicast option is involved, \r
-  the first field of each directory entry is the static multicast IP address and \r
-  UDP port number that is associated with the file name. The format of the field \r
-  is ip:ip:ip:ip:port. If the multicast option is not involved, this field and its \r
+  The returned directory listing in the Token.Buffer or EFI_MTFTP4_PACKET consists\r
+  of a list of two or three variable-length ASCII strings, each terminated by a\r
+  null character, for each file in the directory. If the multicast option is involved,\r
+  the first field of each directory entry is the static multicast IP address and\r
+  UDP port number that is associated with the file name. The format of the field\r
+  is ip:ip:ip:ip:port. If the multicast option is not involved, this field and its\r
   terminating null character are not present.\r
-  The next field of each directory entry is the file name and the last field is \r
-  the file information string. The information string contains the file size and \r
-  the create/modify timestamp. The format of the information string is filesize \r
-  yyyy-mm-dd hh:mm:ss:ffff. The timestamp is Coordinated Universal Time \r
+  The next field of each directory entry is the file name and the last field is\r
+  the file information string. The information string contains the file size and\r
+  the create/modify timestamp. The format of the information string is filesize\r
+  yyyy-mm-dd hh:mm:ss:ffff. The timestamp is Coordinated Universal Time\r
   (UTC; also known as Greenwich Mean Time [GMT]).\r
   The only difference between ReadFile and ReadDirectory is the opcode used.\r
 \r
   @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance\r
-  @param  Token                  Pointer to the token structure to provide the \r
+  @param  Token                  Pointer to the token structure to provide the\r
                                  parameters that are used in this function\r
 \r
   @retval EFI_SUCCESS            The MTFTPv4 related file "directory" has been downloaded.\r
@@ -909,15 +912,15 @@ EfiMtftp4WriteFile (
                                     format.\r
                                  6. Token.Buffer and Token.PacketNeeded are both\r
                                     NULL.\r
-                                 7. One or more IPv4 addresses in Token.OverrideData \r
-                                    are not valid unicast IPv4 addresses if \r
+                                 7. One or more IPv4 addresses in Token.OverrideData\r
+                                    are not valid unicast IPv4 addresses if\r
                                     Token.OverrideData is not NULL.\r
   @retval EFI_UNSUPPORTED        One or more options in the Token.OptionList are in the\r
                                  unsupported list of structure EFI_MTFTP4_MODE_DATA.\r
   @retval EFI_NOT_STARTED        The EFI MTFTPv4 Protocol driver has not been started.\r
-  @retval EFI_NO_MAPPING         When using a default address, configuration (DHCP, \r
+  @retval EFI_NO_MAPPING         When using a default address, configuration (DHCP,\r
                                  BOOTP, RARP, etc.) is not finished yet.\r
-  @retval EFI_ALREADY_STARTED    This Token is already being used in another MTFTPv4 \r
+  @retval EFI_ALREADY_STARTED    This Token is already being used in another MTFTPv4\r
                                  session.\r
   @retval EFI_OUT_OF_RESOURCES   Required system resources could not be allocated.\r
   @retval EFI_ACCESS_DENIED      The previous operation has not completed yet.\r
@@ -936,31 +939,31 @@ EfiMtftp4ReadDirectory (
 \r
 \r
 /**\r
-  Gets information about a file from an MTFTPv4 server. \r
-  \r
-  The GetInfo() function assembles an MTFTPv4 request packet with options; \r
-  sends it to the MTFTPv4 server; and may return an MTFTPv4 OACK, MTFTPv4 ERROR, \r
-  or ICMP ERROR packet. Retries occur only if no response packets are received \r
+  Gets information about a file from an MTFTPv4 server.\r
+\r
+  The GetInfo() function assembles an MTFTPv4 request packet with options;\r
+  sends it to the MTFTPv4 server; and may return an MTFTPv4 OACK, MTFTPv4 ERROR,\r
+  or ICMP ERROR packet. Retries occur only if no response packets are received\r
   from the MTFTPv4 server before the timeout expires.\r
-  It is implemented with EfiMtftp4ReadFile: build a token, then pass it to \r
+  It is implemented with EfiMtftp4ReadFile: build a token, then pass it to\r
   EfiMtftp4ReadFile. In its check packet callback abort the opertions.\r
 \r
   @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance\r
-  @param  OverrideData           Data that is used to override the existing \r
-                                 parameters. If NULL, the default parameters that \r
-                                 were set in the EFI_MTFTP4_PROTOCOL.Configure() \r
+  @param  OverrideData           Data that is used to override the existing\r
+                                 parameters. If NULL, the default parameters that\r
+                                 were set in the EFI_MTFTP4_PROTOCOL.Configure()\r
                                  function are used\r
   @param  Filename               Pointer to null-terminated ASCII file name string\r
-  @param  ModeStr                Pointer to null-terminated ASCII mode string. If NULL, "octet" \r
+  @param  ModeStr                Pointer to null-terminated ASCII mode string. If NULL, "octet"\r
                                  will be used\r
   @param  OptionCount            Number of option/value string pairs in OptionList\r
-  @param  OptionList             Pointer to array of option/value string pairs. \r
+  @param  OptionList             Pointer to array of option/value string pairs.\r
                                  Ignored if OptionCount is zero\r
   @param  PacketLength           The number of bytes in the returned packet\r
-  @param  Packet                 PacketThe pointer to the received packet. This \r
+  @param  Packet                 PacketThe pointer to the received packet. This\r
                                  buffer must be freed by the caller.\r
 \r
-  @retval EFI_SUCCESS            An MTFTPv4 OACK packet was received and is in \r
+  @retval EFI_SUCCESS            An MTFTPv4 OACK packet was received and is in\r
                                  the Buffer.\r
   @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:\r
                                  1.This is NULL.\r
@@ -968,21 +971,21 @@ EfiMtftp4ReadDirectory (
                                  3.OptionCount is not zero and OptionList is NULL.\r
                                  4.One or more options in OptionList have wrong format.\r
                                  5.PacketLength is NULL.\r
-                                 6.One or more IPv4 addresses in OverrideData are \r
-                                   not valid unicast IPv4 addresses if OverrideData \r
+                                 6.One or more IPv4 addresses in OverrideData are\r
+                                   not valid unicast IPv4 addresses if OverrideData\r
                                    is not NULL.\r
   @retval EFI_UNSUPPORTED        One or more options in the OptionList are in the\r
                                  unsupported list of structure EFI_MTFTP4_MODE_DATA\r
   @retval EFI_NOT_STARTED        The EFI MTFTPv4 Protocol driver has not been started.\r
-  @retval EFI_NO_MAPPING         When using a default address, configuration (DHCP, \r
+  @retval EFI_NO_MAPPING         When using a default address, configuration (DHCP,\r
                                  BOOTP, RARP, etc.) has not finished yet.\r
   @retval EFI_ACCESS_DENIED      The previous operation has not completed yet.\r
   @retval EFI_OUT_OF_RESOURCES   Required system resources could not be allocated.\r
-  @retval EFI_TFTP_ERROR         An MTFTPv4 ERROR packet was received and is in \r
+  @retval EFI_TFTP_ERROR         An MTFTPv4 ERROR packet was received and is in\r
                                  the Buffer.\r
-  @retval EFI_ICMP_ERROR         An ICMP ERROR packet was received and the Packet \r
+  @retval EFI_ICMP_ERROR         An ICMP ERROR packet was received and the Packet\r
                                  is set to NULL.\r
-  @retval EFI_PROTOCOL_ERROR     An unexpected MTFTPv4 packet was received and is \r
+  @retval EFI_PROTOCOL_ERROR     An unexpected MTFTPv4 packet was received and is\r
                                  in the Buffer.\r
   @retval EFI_TIMEOUT            No responses were received from the MTFTPv4 server.\r
   @retval EFI_DEVICE_ERROR       An unexpected network error or system error occurred.\r
@@ -1049,15 +1052,15 @@ EfiMtftp4GetInfo (
 /**\r
   Polls for incoming data packets and processes outgoing data packets.\r
 \r
-  The Poll() function can be used by network drivers and applications to increase \r
-  the rate that data packets are moved between the communications device and the \r
+  The Poll() function can be used by network drivers and applications to increase\r
+  the rate that data packets are moved between the communications device and the\r
   transmit and receive queues.\r
-  In some systems, the periodic timer event in the managed network driver may not \r
-  poll the underlying communications device fast enough to transmit and/or receive \r
-  all data packets without missing incoming packets or dropping outgoing packets. \r
-  Drivers and applications that are experiencing packet loss should try calling \r
+  In some systems, the periodic timer event in the managed network driver may not\r
+  poll the underlying communications device fast enough to transmit and/or receive\r
+  all data packets without missing incoming packets or dropping outgoing packets.\r
+  Drivers and applications that are experiencing packet loss should try calling\r
   the Poll() function more often.\r
-  \r
+\r
   @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance\r
 \r
   @retval EFI_SUCCESS            Incoming or outgoing data was processed.\r
@@ -1066,7 +1069,7 @@ EfiMtftp4GetInfo (
                                  BOOTP, RARP, etc.) is not finished yet.\r
   @retval EFI_INVALID_PARAMETER  This is NULL.\r
   @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.\r
-  @retval EFI_TIMEOUT            Data was dropped out of the transmit and/or receive \r
+  @retval EFI_TIMEOUT            Data was dropped out of the transmit and/or receive\r
                                  queue. Consider increasing the polling rate.\r
 \r
 **/\r
@@ -1078,6 +1081,7 @@ EfiMtftp4Poll (
 {\r
   MTFTP4_PROTOCOL           *Instance;\r
   EFI_UDP4_PROTOCOL         *Udp;\r
+  EFI_STATUS                Status;\r
 \r
   if (This == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1092,7 +1096,9 @@ EfiMtftp4Poll (
   }\r
 \r
   Udp = Instance->UnicastPort->Protocol.Udp4;\r
-  return Udp->Poll (Udp);\r
+  Status = Udp->Poll (Udp);\r
+  Mtftp4OnTimerTick (NULL, Instance->Service);\r
+  return Status;\r
 }\r
 \r
 EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate = {\r