]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiTcp4Io.c
Correct typo in comments, clean IfrSupportLib.h
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiTcp4Io.c
index d43437be2da8d5b8d231682cb8c7f703fb33fcc0..2278fe793779d5d8776c7c6479301c47f1fcf1a0 100644 (file)
@@ -1,6 +1,7 @@
-/*++\r
+/** @file\r
+  The wrap of TCP/IP Socket interface.\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
+Copyright (c) 2004 - 2007, Intel Corporation.<BR>\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
@@ -9,42 +10,37 @@ http://opensource.org/licenses/bsd-license.php
 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
-  IScsiTcp4Io.c\r
-\r
-Abstract:\r
-\r
---*/\r
+**/\r
 \r
 #include "IScsiImpl.h"\r
 \r
+/**\r
+  The common notify function associated with various Tcp4Io events. \r
+\r
+  @param[in]  Event   The event signaled.\r
+  @param[in]  Context The context.\r
+**/\r
 VOID\r
 EFIAPI\r
 Tcp4IoCommonNotify (\r
   IN EFI_EVENT  Event,\r
   IN VOID       *Context\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The common notify function associated with various Tcp4Io events. \r
-\r
-Arguments:\r
-\r
-  Event   - The event signaled.\r
-  Contect - The context.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   *((BOOLEAN *) Context) = TRUE;\r
 }\r
 \r
+/**\r
+  Create a TCP socket with the specified configuration data. \r
+\r
+  @param[in]  Image      The handle of the driver image.\r
+  @param[in]  Controller The handle of the controller.\r
+  @param[in]  ConfigData The Tcp4 configuration data.\r
+  @param[in]  Tcp4Io     The Tcp4Io.\r
+  \r
+  @retval EFI_SUCCESS    The TCP socket is created and configured.\r
+  @retval Others         Failed to create the TCP socket or configure it.\r
+**/\r
 EFI_STATUS\r
 Tcp4IoCreateSocket (\r
   IN EFI_HANDLE           Image,\r
@@ -52,25 +48,6 @@ Tcp4IoCreateSocket (
   IN TCP4_IO_CONFIG_DATA  *ConfigData,\r
   IN TCP4_IO              *Tcp4Io\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Create a TCP socket with the specified configuration data. \r
-\r
-Arguments:\r
-\r
-  Image      - The handle of the driver image.\r
-  Controller - The handle of the controller.\r
-  ConfigData - The Tcp4 configuration data.\r
-  Tcp4Io     - The Tcp4Io.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS - The TCP socket is created and configured.\r
-  other       - Failed to create the TCP socket or configure it.\r
-\r
---*/\r
 {\r
   EFI_STATUS            Status;\r
   EFI_TCP4_PROTOCOL     *Tcp4;\r
@@ -144,9 +121,9 @@ Returns:
   AccessPoint->RemotePort = ConfigData->RemotePort;\r
   AccessPoint->ActiveFlag = TRUE;\r
 \r
-  NetCopyMem (&AccessPoint->StationAddress, &ConfigData->LocalIp, sizeof (EFI_IPv4_ADDRESS));\r
-  NetCopyMem (&AccessPoint->SubnetMask, &ConfigData->SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r
-  NetCopyMem (&AccessPoint->RemoteAddress, &ConfigData->RemoteIp, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&AccessPoint->StationAddress, &ConfigData->LocalIp, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&AccessPoint->SubnetMask, &ConfigData->SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&AccessPoint->RemoteAddress, &ConfigData->RemoteIp, sizeof (EFI_IPv4_ADDRESS));\r
 \r
   //\r
   // Configure the TCP4 protocol.\r
@@ -169,8 +146,8 @@ Returns:
   // Create events for variuos asynchronous operations.\r
   //\r
   Status = gBS->CreateEvent (\r
-                  EFI_EVENT_NOTIFY_SIGNAL,\r
-                  NET_TPL_EVENT,\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
                   Tcp4IoCommonNotify,\r
                   &Tcp4Io->IsConnDone,\r
                   &Tcp4Io->ConnToken.CompletionToken.Event\r
@@ -180,8 +157,8 @@ Returns:
   }\r
 \r
   Status = gBS->CreateEvent (\r
-                  EFI_EVENT_NOTIFY_SIGNAL,\r
-                  NET_TPL_EVENT,\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
                   Tcp4IoCommonNotify,\r
                   &Tcp4Io->IsTxDone,\r
                   &Tcp4Io->TxToken.CompletionToken.Event\r
@@ -191,8 +168,8 @@ Returns:
   }\r
 \r
   Status = gBS->CreateEvent (\r
-                  EFI_EVENT_NOTIFY_SIGNAL,\r
-                  NET_TPL_EVENT,\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
                   Tcp4IoCommonNotify,\r
                   &Tcp4Io->IsRxDone,\r
                   &Tcp4Io->RxToken.CompletionToken.Event\r
@@ -202,8 +179,8 @@ Returns:
   }\r
 \r
   Status = gBS->CreateEvent (\r
-                  EFI_EVENT_NOTIFY_SIGNAL,\r
-                  NET_TPL_EVENT,\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
                   Tcp4IoCommonNotify,\r
                   &Tcp4Io->IsCloseDone,\r
                   &Tcp4Io->CloseToken.CompletionToken.Event\r
@@ -252,25 +229,15 @@ ON_ERROR:
   return Status;\r
 }\r
 \r
+/**\r
+  Destroy the socket. \r
+\r
+  @param[in]  Tcp4Io The Tcp4Io which wraps the socket to be destroyeds.\r
+**/\r
 VOID\r
 Tcp4IoDestroySocket (\r
   IN TCP4_IO  *Tcp4Io\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Destroy the socket. \r
-\r
-Arguments:\r
-\r
-  Tcp4Io - The Tcp4Io which wraps the socket to be destroyeds.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   EFI_TCP4_PROTOCOL *Tcp4;\r
 \r
@@ -297,27 +264,21 @@ Returns:
     );\r
 }\r
 \r
+/**\r
+  Connect to the other endpoint of the TCP socket.\r
+\r
+  @param[in, out]  Tcp4Io    The Tcp4Io wrapping the TCP socket.\r
+  @param[in]       Timeout   The time to wait for connection done.\r
+  \r
+  @retval EFI_SUCCESS          Connect to the other endpoint of the TCP socket successfully.\r
+  @retval EFI_TIMEOUT          Failed to connect to the other endpoint of the TCP socket in the                               specified time period.\r
+  @retval Others               Other errors as indicated.\r
+**/\r
 EFI_STATUS\r
 Tcp4IoConnect (\r
-  IN TCP4_IO    *Tcp4Io,\r
-  IN EFI_EVENT  Timeout\r
+  IN OUT TCP4_IO    *Tcp4Io,\r
+  IN EFI_EVENT      Timeout\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Connect to the other endpoint of the TCP socket.\r
-\r
-Arguments:\r
-\r
-  Tcp4Io  - The Tcp4Io wrapping the TCP socket.\r
-  Timeout - The time to wait for connection done.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   EFI_TCP4_PROTOCOL *Tcp4;\r
   EFI_STATUS        Status;\r
@@ -342,25 +303,15 @@ Returns:
   return Status;\r
 }\r
 \r
+/**\r
+  Reset the socket.\r
+\r
+  @param[in, out]  Tcp4Io The Tcp4Io wrapping the TCP socket.\r
+**/\r
 VOID\r
 Tcp4IoReset (\r
-  IN TCP4_IO  *Tcp4Io\r
+  IN OUT TCP4_IO  *Tcp4Io\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Reset the socket.\r
-\r
-Arguments:\r
-\r
-  Tcp4Io - The Tcp4Io wrapping the TCP socket.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   EFI_STATUS        Status;\r
   EFI_TCP4_PROTOCOL *Tcp4;\r
@@ -379,34 +330,27 @@ Returns:
   }\r
 }\r
 \r
+/**\r
+  Transmit the Packet to the other endpoint of the socket.\r
+\r
+  @param[in]   Tcp4Io          The Tcp4Io wrapping the TCP socket.\r
+  @param[in]   Packet          The packet to transmit.\r
+  \r
+  @retval EFI_SUCCESS          The packet is trasmitted.\r
+  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+  @retval Others               Other errors as indicated.\r
+**/\r
 EFI_STATUS\r
 Tcp4IoTransmit (\r
   IN TCP4_IO  *Tcp4Io,\r
   IN NET_BUF  *Packet\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Transmit the Packet to the other endpoint of the socket.\r
-\r
-Arguments:\r
-\r
-  Tcp4Io - The Tcp4Io wrapping the TCP socket.\r
-  Packet - The packet to transmit\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS          - The packet is trasmitted.\r
-  EFI_OUT_OF_RESOURCES - Failed to allocate memory.\r
-\r
---*/\r
 {\r
   EFI_TCP4_TRANSMIT_DATA  *TxData;\r
   EFI_TCP4_PROTOCOL       *Tcp4;\r
   EFI_STATUS              Status;\r
 \r
-  TxData = NetAllocatePool (sizeof (EFI_TCP4_TRANSMIT_DATA) + (Packet->BlockOpNum - 1) * sizeof (EFI_TCP4_FRAGMENT_DATA));\r
+  TxData = AllocatePool (sizeof (EFI_TCP4_TRANSMIT_DATA) + (Packet->BlockOpNum - 1) * sizeof (EFI_TCP4_FRAGMENT_DATA));\r
   if (TxData == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -442,11 +386,26 @@ Returns:
 \r
 ON_EXIT:\r
 \r
-  NetFreePool (TxData);\r
+  gBS->FreePool (TxData);\r
 \r
   return Status;\r
 }\r
 \r
+/**\r
+  Receive data from the socket.\r
+\r
+  @param[in]  Tcp4Io           The Tcp4Io which wraps the socket to be destroyed.\r
+  @param[in]  Packet           The buffer to hold the data copy from the soket rx buffer.\r
+  @param[in]  AsyncMode        Is this receive asyncronous or not.\r
+  @param[in]  Timeout          The time to wait for receiving the amount of data the Packet\r
+                               can hold.\r
+\r
+  @retval EFI_SUCCESS          The required amount of data is received from the socket.\r
+  @retval EFI_OUT_OF_RESOURCES Failed to allocate momery.\r
+  @retval EFI_TIMEOUT          Failed to receive the required amount of data in the\r
+                               specified time period.\r
+  @retval Others               Other errors as indicated.\r
+**/\r
 EFI_STATUS\r
 Tcp4IoReceive (\r
   IN TCP4_IO    *Tcp4Io,\r
@@ -454,28 +413,6 @@ Tcp4IoReceive (
   IN BOOLEAN    AsyncMode,\r
   IN EFI_EVENT  Timeout\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Receive data from the socket.\r
-\r
-Arguments:\r
-\r
-  Tcp4Io    - The Tcp4Io which wraps the socket to be destroyeds.\r
-  Packet    - The buffer to hold the data copy from the soket rx buffer.\r
-  AsyncMode - Is this receive asyncronous or not.\r
-  Timeout   - The time to wait for receiving the amount of data the Packet\r
-              can hold.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS          - The required amount of data is received from the socket.\r
-  EFI_OUT_OF_RESOURCES - Failed to allocate momery.\r
-  EFI_TIMEOUT          - Failed to receive the required amount of data in the\r
-                         specified time period.\r
-\r
---*/\r
 {\r
   EFI_TCP4_PROTOCOL     *Tcp4;\r
   EFI_TCP4_RECEIVE_DATA RxData;\r
@@ -485,7 +422,7 @@ Returns:
   UINT32                CurrentFragment;\r
 \r
   FragmentCount = Packet->BlockOpNum;\r
-  Fragment      = NetAllocatePool (FragmentCount * sizeof (NET_FRAGMENT));\r
+  Fragment      = AllocatePool (FragmentCount * sizeof (NET_FRAGMENT));\r
   if (Fragment == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -544,7 +481,7 @@ Returns:
 \r
 ON_EXIT:\r
 \r
-  NetFreePool (Fragment);\r
+  gBS->FreePool (Fragment);\r
 \r
   return Status;\r
 }\r