]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.h
BaseTools:Change the path of the file that Binary Cache
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Support.h
index 5e5157be64206165db3a0efb30b07ff5372afe20..cfa7582faa4b9b4cb3a24bbdfb3b8598ade9b811 100644 (file)
@@ -1,22 +1,8 @@
 /** @file\r
+  Support routines for MTFTP.\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
-\r
-Module Name:\r
-\r
-  Mtftp4Support.h\r
-\r
-Abstract:\r
-\r
-  Support routines for MTFTP\r
-\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -29,64 +15,180 @@ Abstract:
 // the holes are filled in, then the download or upload has completed.\r
 //\r
 typedef struct {\r
-  NET_LIST_ENTRY            Link;\r
+  LIST_ENTRY                Link;\r
   INTN                      Start;\r
   INTN                      End;\r
+  INTN                      Round;\r
+  INTN                      Bound;\r
 } MTFTP4_BLOCK_RANGE;\r
 \r
 \r
+/**\r
+  Initialize the block range for either RRQ or WRQ.\r
+\r
+  RRQ and WRQ have different requirements for Start and End.\r
+  For example, during start up, WRQ initializes its whole valid block range\r
+  to [0, 0xffff]. This is bacause the server will send us a ACK0 to inform us\r
+  to start the upload. When the client received ACK0, it will remove 0 from the\r
+  range, get the next block number, which is 1, then upload the BLOCK1. For RRQ\r
+  without option negotiation, the server will directly send us the BLOCK1 in\r
+  response to the client's RRQ. When received BLOCK1, the client will remove\r
+  it from the block range and send an ACK. It also works if there is option\r
+  negotiation.\r
+\r
+  @param  Head                  The block range head to initialize\r
+  @param  Start                 The Start block number.\r
+  @param  End                   The last block number.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory for initial block range\r
+  @retval EFI_SUCCESS           The initial block range is created.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4InitBlockRange (\r
-  IN NET_LIST_ENTRY         *Head,\r
+  IN LIST_ENTRY             *Head,\r
   IN UINT16                 Start,\r
   IN UINT16                 End\r
   );\r
 \r
+/**\r
+  Get the first valid block number on the range list.\r
+\r
+  @param  Head                  The block range head\r
+\r
+  @return The first valid block number, -1 if the block range is empty.\r
+\r
+**/\r
 INTN\r
 Mtftp4GetNextBlockNum (\r
-  IN NET_LIST_ENTRY         *Head\r
+  IN LIST_ENTRY             *Head\r
   );\r
 \r
+/**\r
+  Set the last block number of the block range list.\r
+\r
+  It will remove all the blocks after the Last. MTFTP initialize the block range\r
+  to the maximum possible range, such as [0, 0xffff] for WRQ. When it gets the\r
+  last block number, it will call this function to set the last block number.\r
+\r
+  @param  Head                  The block range list\r
+  @param  Last                  The last block number\r
+\r
+**/\r
 VOID\r
 Mtftp4SetLastBlockNum (\r
-  IN NET_LIST_ENTRY         *Head,\r
+  IN LIST_ENTRY             *Head,\r
   IN UINT16                 Last\r
   );\r
 \r
+/**\r
+  Remove the block number from the block range list.\r
+\r
+  @param  Head                  The block range list to remove from\r
+  @param  Num                   The block number to remove\r
+  @param  Completed             Whether Num is the last block number.\r
+  @param  BlockCounter          The continuous block counter instead of the value after roll-over.\r
+\r
+  @retval EFI_NOT_FOUND         The block number isn't in the block range list\r
+  @retval EFI_SUCCESS           The block number has been removed from the list\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate resource\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4RemoveBlockNum (\r
-  IN NET_LIST_ENTRY         *Head,\r
-  IN UINT16                 Num\r
+  IN LIST_ENTRY             *Head,\r
+  IN UINT16                 Num,\r
+  IN BOOLEAN                Completed,\r
+  OUT UINT64                *BlockCounter\r
   );\r
 \r
+/**\r
+  Set the timeout for the instance. User a longer time for passive instances.\r
+\r
+  @param  Instance              The Mtftp session to set time out\r
+\r
+**/\r
 VOID\r
 Mtftp4SetTimeout (\r
-  IN MTFTP4_PROTOCOL        *Instance\r
+  IN OUT MTFTP4_PROTOCOL        *Instance\r
   );\r
 \r
+/**\r
+  Send the packet for the instance.\r
+\r
+  It will first save a reference to the packet for later retransmission.\r
+  Then determine the destination port, listen port for requests, and connected\r
+  port for others. At last, send the packet out.\r
+\r
+  @param  Instance              The Mtftp instance\r
+  @param  Packet                The packet to send\r
+\r
+  @retval EFI_SUCCESS           The packet is sent out\r
+  @retval Others                Failed to transmit the packet.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4SendPacket (\r
-  IN MTFTP4_PROTOCOL        *Instance,\r
-  IN NET_BUF                *Packet\r
+  IN OUT MTFTP4_PROTOCOL        *Instance,\r
+  IN OUT NET_BUF                *Packet\r
   );\r
 \r
+/**\r
+  Build then transmit the request packet for the MTFTP session.\r
+\r
+  @param  Instance              The Mtftp session\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory for the request\r
+  @retval EFI_SUCCESS           The request is built and sent\r
+  @retval Others                Failed to transmit the packet.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4SendRequest (\r
   IN MTFTP4_PROTOCOL        *Instance\r
   );\r
 \r
+/**\r
+  Build then send an error message.\r
+\r
+  @param  Instance              The MTFTP session\r
+  @param  ErrCode               The error code\r
+  @param  ErrInfo               The error message\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory for the error packet\r
+  @retval EFI_SUCCESS           The error packet is transmitted.\r
+  @retval Others                Failed to transmit the packet.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4SendError (\r
   IN MTFTP4_PROTOCOL        *Instance,\r
   IN UINT16                 ErrCode,\r
-  IN UINT8*                 ErrInfo\r
+  IN UINT8                  *ErrInfo\r
   );\r
 \r
-EFI_STATUS\r
-Mtftp4Retransmit (\r
-  IN MTFTP4_PROTOCOL        *Instance\r
+\r
+/**\r
+  The timer ticking function in TPL_NOTIFY level for the Mtftp service instance.\r
+\r
+  @param  Event                 The ticking event\r
+  @param  Context               The Mtftp service instance\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+Mtftp4OnTimerTickNotifyLevel (\r
+  IN EFI_EVENT              Event,\r
+  IN VOID                   *Context\r
   );\r
 \r
+/**\r
+  The timer ticking function for the Mtftp service instance.\r
+\r
+  @param  Event                 The ticking event\r
+  @param  Context               The Mtftp service instance\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 Mtftp4OnTimerTick (\r