]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
remove EFI_EVENT_ alias, replace them with EVT_
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiMisc.c
index 985f02e94012edaec18d9cfca08f8030e85d2eb4..4bd72ae25a168e6e771fd2cf4022c57e7b7c79af 100644 (file)
@@ -1,6 +1,7 @@
-/*++\r
+/** @file\r
+  Miscellaneous routines for IScsi driver.\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
+Copyright (c) 2004 - 2008, 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
@@ -15,75 +16,31 @@ Module Name:
 \r
 Abstract:\r
 \r
-  Miscellaneous routines for iSCSI driver.\r
+  Miscellaneous routines for IScsi driver.\r
 \r
---*/\r
+**/\r
 \r
 #include "IScsiImpl.h"\r
 \r
 STATIC CONST CHAR8  IScsiHexString[] = "0123456789ABCDEFabcdef";\r
 \r
-static\r
-BOOLEAN\r
-IsHexDigit (\r
-  OUT UINT8      *Digit,\r
-  IN  CHAR16      Char\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
-    Determines if a Unicode character is a hexadecimal digit.\r
-    The test is case insensitive.\r
-\r
-  Arguments:\r
-    Digit - Pointer to byte that receives the value of the hex character.\r
-    Char  - Unicode character to test.\r
-\r
-  Returns:\r
-    TRUE  - If the character is a hexadecimal digit.\r
-    FALSE - Otherwise.\r
-\r
---*/\r
-{\r
-  if ((Char >= L'0') && (Char <= L'9')) {\r
-    *Digit = (UINT8) (Char - L'0');\r
-    return TRUE;\r
-  }\r
+/**\r
+  Removes (trims) specified leading and trailing characters from a string.\r
 \r
-  if ((Char >= L'A') && (Char <= L'F')) {\r
-    *Digit = (UINT8) (Char - L'A' + 0x0A);\r
-    return TRUE;\r
-  }\r
+  @param  str[in][out] Pointer to the null-terminated string to be trimmed. On return, \r
+                       str will hold the trimmed string. \r
 \r
-  if ((Char >= L'a') && (Char <= L'f')) {\r
-    *Digit = (UINT8) (Char - L'a' + 0x0A);\r
-    return TRUE;\r
-  }\r
+  @param  CharC[in]    Character will be trimmed from str.\r
 \r
-  return FALSE;\r
-}\r
+  @retval NONE.\r
 \r
+**/\r
 static\r
 VOID\r
 StrTrim (\r
   IN OUT CHAR16   *str,\r
   IN     CHAR16   CharC\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Removes (trims) specified leading and trailing characters from a string.\r
-  \r
-Arguments: \r
-  \r
-  str     - Pointer to the null-terminated string to be trimmed. On return, \r
-            str will hold the trimmed string. \r
-  CharC       - Character will be trimmed from str.\r
-  \r
-Returns:\r
-\r
---*/\r
 {\r
   CHAR16  *p1;\r
   CHAR16  *p2;\r
@@ -123,25 +80,18 @@ Returns:
   }\r
 }\r
 \r
-UINT8\r
-IScsiGetSubnetMaskPrefixLength (\r
-  IN EFI_IPv4_ADDRESS  *SubnetMask\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Calculate the prefix length of the IPv4 subnet mask.\r
 \r
-Arguments:\r
-\r
-  SubnetMask - The IPv4 subnet mask.\r
-\r
-Returns:\r
+  @param  SubnetMask[in] The IPv4 subnet mask.\r
 \r
-  The prefix length of the subnet mask.\r
+  @retval The prefix length of the subnet mask.\r
 \r
---*/\r
+**/\r
+UINT8\r
+IScsiGetSubnetMaskPrefixLength (\r
+  IN EFI_IPv4_ADDRESS  *SubnetMask\r
+  )\r
 {\r
   UINT8   Len;\r
   UINT32  ReverseMask;\r
@@ -170,28 +120,23 @@ Returns:
   return (UINT8) (32 - Len);\r
 }\r
 \r
-EFI_STATUS\r
-IScsiAsciiStrToLun (\r
-  IN  CHAR8  *Str,\r
-  OUT UINT8  *Lun\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Convert the hexadecimal encoded LUN string into the 64-bit LUN. \r
 \r
-Arguments:\r
+  @param  Str[in]               The hexadecimal encoded LUN string.\r
 \r
-  Str - The hexadecimal encoded LUN string.\r
-  Lun - Storage to return the 64-bit LUN.\r
+  @param  Lun[out]              Storage to return the 64-bit LUN.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS           The 64-bit LUN is stored in Lun.\r
 \r
-  EFI_SUCCESS           - The 64-bit LUN is stored in Lun.\r
-  EFI_INVALID_PARAMETER - The string is malformatted.\r
+  @retval EFI_INVALID_PARAMETER The string is malformatted.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+IScsiAsciiStrToLun (\r
+  IN  CHAR8  *Str,\r
+  OUT UINT8  *Lun\r
+  )\r
 {\r
   UINT32  Index;\r
   CHAR8   *LunUnitStr[4];\r
@@ -245,27 +190,21 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-VOID\r
-IScsiLunToUnicodeStr (\r
-  IN UINT8    *Lun,\r
-  OUT CHAR16  *Str\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Convert the 64-bit LUN into the hexadecimal encoded LUN string.\r
 \r
-Arguments:\r
+  @param  Lun[in]  The 64-bit LUN.\r
 \r
-  Lun - The 64-bit LUN.\r
-  Str - The storage to return the hexadecimal encoded LUN string.\r
+  @param  Str[out] The storage to return the hexadecimal encoded LUN string.\r
 \r
-Returns:\r
+  @retval None.\r
 \r
-  None.\r
-\r
---*/\r
+**/\r
+VOID\r
+IScsiLunToUnicodeStr (\r
+  IN UINT8    *Lun,\r
+  OUT CHAR16  *Str\r
+  )\r
 {\r
   UINTN   Index;\r
   CHAR16  *TempStr;\r
@@ -301,27 +240,21 @@ Returns:
   }\r
 }\r
 \r
-CHAR16 *\r
-IScsiAsciiStrToUnicodeStr (\r
-  IN  CHAR8   *Source,\r
-  OUT CHAR16  *Destination\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Convert the ASCII string into a UNICODE string.\r
 \r
-Arguments:\r
-\r
-  Source      - The ASCII string.\r
-  Destination - The storage to return the UNICODE string.\r
+  @param  Source[out]      The ASCII string.\r
 \r
-Returns:\r
+  @param  Destination[out] The storage to return the UNICODE string.\r
 \r
-  Pointer to the UNICODE string.\r
+  @retval CHAR16 *         Pointer to the UNICODE string.\r
 \r
---*/\r
+**/\r
+CHAR16 *\r
+IScsiAsciiStrToUnicodeStr (\r
+  IN  CHAR8   *Source,\r
+  OUT CHAR16  *Destination\r
+  )\r
 {\r
   ASSERT (Destination != NULL);\r
   ASSERT (Source != NULL);\r
@@ -335,27 +268,21 @@ Returns:
   return Destination;\r
 }\r
 \r
-CHAR8 *\r
-IScsiUnicodeStrToAsciiStr (\r
-  IN  CHAR16  *Source,\r
-  OUT CHAR8   *Destination\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Convert the UNICODE string into an ASCII string.\r
 \r
-Arguments:\r
-\r
-  Source      - The UNICODE string.\r
-  Destination - The storage to return the ASCII string.\r
+  @param  Source[in]       The UNICODE string.\r
 \r
-Returns:\r
+  @param  Destination[out] The storage to return the ASCII string.\r
 \r
-  Pointer to the ASCII string.\r
+  @retval CHAR8 *          Pointer to the ASCII string.\r
 \r
---*/\r
+**/\r
+CHAR8 *\r
+IScsiUnicodeStrToAsciiStr (\r
+  IN  CHAR16  *Source,\r
+  OUT CHAR8   *Destination\r
+  )\r
 {\r
   ASSERT (Destination != NULL);\r
   ASSERT (Source != NULL);\r
@@ -374,28 +301,23 @@ Returns:
   return Destination;\r
 }\r
 \r
-EFI_STATUS\r
-IScsiAsciiStrToIp (\r
-  IN  CHAR8             *Str,\r
-  OUT EFI_IPv4_ADDRESS  *Ip\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Convert the decimal dotted IPv4 address into the binary IPv4 address.\r
 \r
-Arguments:\r
+  @param  Str[in]               The UNICODE string.\r
 \r
-  Str - The UNICODE string.\r
-  Ip  - The storage to return the ASCII string.\r
+  @param  Ip[out]               The storage to return the ASCII string.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS           The binary IP address is returned in Ip.\r
 \r
-  EFI_SUCCESS           - The binary IP address is returned in Ip.\r
-  EFI_INVALID_PARAMETER - The IP string is malformatted.\r
+  @retval EFI_INVALID_PARAMETER The IP string is malformatted.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+IScsiAsciiStrToIp (\r
+  IN  CHAR8             *Str,\r
+  OUT EFI_IPv4_ADDRESS  *Ip\r
+  )\r
 {\r
   UINTN Index;\r
   UINTN Number;\r
@@ -445,29 +367,24 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-VOID\r
-IScsiMacAddrToStr (\r
-  IN  EFI_MAC_ADDRESS  *Mac,\r
-  IN  UINT32           Len,\r
-  OUT CHAR16           *Str\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Convert the mac address into a hexadecimal encoded "-" seperated string.\r
 \r
-Arguments:\r
+  @param  Mac[in]  The mac address.\r
 \r
-  Mac - The mac address.\r
-  Len - Length in bytes of the mac address.\r
-  Str - The storage to return the mac string.\r
+  @param  Len[in]  Length in bytes of the mac address.\r
 \r
-Returns:\r
+  @param  Str[out] The storage to return the mac string.\r
 \r
-  None.\r
+  @retval None.\r
 \r
---*/\r
+**/\r
+VOID\r
+IScsiMacAddrToStr (\r
+  IN  EFI_MAC_ADDRESS  *Mac,\r
+  IN  UINT32           Len,\r
+  OUT CHAR16           *Str\r
+  )\r
 {\r
   UINT32  Index;\r
 \r
@@ -480,33 +397,30 @@ Returns:
   Str[3 * Index - 1] = L'\0';\r
 }\r
 \r
-EFI_STATUS\r
-IScsiBinToHex (\r
-  IN     UINT8  *BinBuffer,\r
-  IN     UINT32 BinLength,\r
-  IN OUT CHAR8  *HexStr,\r
-  IN OUT UINT32 *HexLength\r
-  )\r
-/*++\r
+/**\r
+  Convert the binary encoded buffer into a hexadecimal encoded string.\r
 \r
-Routine Description:\r
+  @param  BinBuffer[in]        The buffer containing the binary data.\r
 \r
-  Convert the binary encoded buffer into a hexadecimal encoded string.\r
+  @param  BinLength[in]        Length of the binary buffer.\r
 \r
-Arguments:\r
+  @param  HexStr[in][out]      Pointer to the string.\r
 \r
-  BinBuffer - The buffer containing the binary data.\r
-  BinLength - Length of the binary buffer.\r
-  HexStr    - Pointer to the string.\r
-  HexLength - The length of the string.\r
+  @param  HexLength[in][out]   The length of the string.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS          The binary data is converted to the hexadecimal string \r
+                               and the length of the string is updated.\r
 \r
-  EFI_SUCCESS          - The binary data is converted to the hexadecimal string \r
-                         and the length of the string is updated.\r
-  EFI_BUFFER_TOO_SMALL - The string is too small.\r
+  @retval EFI_BUFFER_TOO_SMALL The string is too small.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+IScsiBinToHex (\r
+  IN     UINT8  *BinBuffer,\r
+  IN     UINT32 BinLength,\r
+  IN OUT CHAR8  *HexStr,\r
+  IN OUT UINT32 *HexLength\r
+  )\r
 {\r
   UINTN Index;\r
 \r
@@ -536,31 +450,27 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-IScsiHexToBin (\r
-  IN OUT UINT8  *BinBuffer,\r
-  IN OUT UINT32 *BinLength,\r
-  IN     CHAR8  *HexStr\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Convert the hexadecimal string into a binary encoded buffer.\r
 \r
-Arguments:\r
+  @param  BinBuffer[in][out]   The binary buffer.\r
+\r
+  @param  BinLength[in][out]   Length of the binary buffer.\r
 \r
-  BinBuffer - The binary buffer.\r
-  BinLength - Length of the binary buffer.\r
-  HexStr    - The hexadecimal string.\r
+  @param  HexStr[in]           The hexadecimal string.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS          The hexadecimal string is converted into a binary\r
+                               encoded buffer.\r
 \r
-  EFI_SUCCESS          - The hexadecimal string is converted into a binary \r
-                         encoded buffer.\r
-  EFI_BUFFER_TOO_SMALL - The binary buffer is too small to hold the converted data.s\r
+  @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.s\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+IScsiHexToBin (\r
+  IN OUT UINT8  *BinBuffer,\r
+  IN OUT UINT32 *BinLength,\r
+  IN     CHAR8  *HexStr\r
+  )\r
 {\r
   UINTN   Index;\r
   UINT32  HexCount;\r
@@ -613,27 +523,21 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-VOID\r
-IScsiGenRandom (\r
-  IN OUT UINT8  *Rand,\r
-  IN     UINTN  RandLength\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Generate random numbers.\r
 \r
-Arguments:\r
+  @param  Rand[in][out]  The buffer to contain random numbers.\r
 \r
-  Rand       - The buffer to contain random numbers.\r
-  RandLength - The length of the Rand buffer.\r
+  @param  RandLength[in] The length of the Rand buffer.\r
 \r
-Returns:\r
+  @retval None.\r
 \r
-  None.\r
-\r
---*/\r
+**/\r
+VOID\r
+IScsiGenRandom (\r
+  IN OUT UINT8  *Rand,\r
+  IN     UINTN  RandLength\r
+  )\r
 {\r
   UINT32  Random;\r
 \r
@@ -644,27 +548,21 @@ Returns:
   }\r
 }\r
 \r
-ISCSI_DRIVER_DATA *\r
-IScsiCreateDriverData (\r
-  IN EFI_HANDLE  Image,\r
-  IN EFI_HANDLE  Controller\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Create the iSCSI driver data..\r
 \r
-Arguments:\r
+  @param  Image[in]      The handle of the driver image.\r
 \r
-  Image      - The handle of the driver image.\r
-  Controller - The handle of the controller.\r
+  @param  Controller[in] The handle of the controller.\r
 \r
-Returns:\r
+  @retval The iSCSI driver data created.\r
 \r
-  The iSCSI driver data created.\r
-\r
---*/\r
+**/\r
+ISCSI_DRIVER_DATA *\r
+IScsiCreateDriverData (\r
+  IN EFI_HANDLE  Image,\r
+  IN EFI_HANDLE  Controller\r
+  )\r
 {\r
   ISCSI_DRIVER_DATA *Private;\r
   EFI_STATUS        Status;\r
@@ -683,7 +581,7 @@ Returns:
   // as to abort the iSCSI session.\r
   //\r
   Status = gBS->CreateEvent (\r
-                  EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r
+                  EVT_SIGNAL_EXIT_BOOT_SERVICES,\r
                   TPL_CALLBACK,\r
                   IScsiOnExitBootService,\r
                   Private,\r
@@ -725,25 +623,18 @@ Returns:
   return Private;\r
 }\r
 \r
-VOID\r
-IScsiCleanDriverData (\r
-  IN ISCSI_DRIVER_DATA  *Private\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Clean the iSCSI driver data.\r
 \r
-Arguments:\r
-\r
-  Private - The iSCSI driver data.\r
-\r
-Returns:\r
+  @param  Private[in] The iSCSI driver data.\r
 \r
- None.\r
 @retval None.\r
 \r
---*/\r
+**/\r
+VOID\r
+IScsiCleanDriverData (\r
+  IN ISCSI_DRIVER_DATA  *Private\r
+  )\r
 {\r
   if (Private->DevicePath != NULL) {\r
     gBS->UninstallProtocolInterface (\r
@@ -768,26 +659,21 @@ Returns:
   gBS->FreePool (Private);\r
 }\r
 \r
-EFI_STATUS\r
-IScsiGetConfigData (\r
-  IN ISCSI_DRIVER_DATA  *Private\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Get the various configuration data of this iSCSI instance.\r
 \r
-Arguments:\r
-\r
-  Private - The iSCSI driver data.\r
+  @param  Private[in]   The iSCSI driver data.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS   The configuration of this instance is got.\r
 \r
-  EFI_SUCCESS   - The configuration of this instance is got.\r
-  EFI_NOT_FOUND - This iSCSI instance is not configured yet.\r
+  @retval EFI_NOT_FOUND This iSCSI instance is not configured yet.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+IScsiGetConfigData (\r
+  IN ISCSI_DRIVER_DATA  *Private\r
+  )\r
 {\r
   EFI_STATUS                  Status;\r
   ISCSI_SESSION               *Session;\r
@@ -866,25 +752,18 @@ Returns:
   return Status;\r
 }\r
 \r
-EFI_DEVICE_PATH_PROTOCOL *\r
-IScsiGetTcpConnDevicePath (\r
-  IN ISCSI_DRIVER_DATA  *Private\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Get the device path of the iSCSI tcp connection and update it.\r
 \r
-Arguments:\r
+  @param  Private[in] The iSCSI driver data.\r
 \r
-  Private - The iSCSI driver data.\r
+  @retval The updated device path.\r
 \r
-Returns:\r
-\r
-  The updated device path.\r
-\r
---*/\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+IScsiGetTcpConnDevicePath (\r
+  IN ISCSI_DRIVER_DATA  *Private\r
+  )\r
 {\r
   ISCSI_SESSION             *Session;\r
   ISCSI_CONNECTION          *Conn;\r
@@ -937,28 +816,22 @@ Returns:
   return DevicePath;\r
 }\r
 \r
+/**\r
+  Abort the session when the transition from BS to RT is initiated.\r
+\r
+  @param  Event[in]   The event signaled.\r
+\r
+  @param  Context[in] The iSCSI driver data.\r
+\r
+  @retval None.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 IScsiOnExitBootService (\r
   IN EFI_EVENT  Event,\r
   IN VOID       *Context\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Abort the session when the transition from BS to RT is initiated.\r
-\r
-Arguments:\r
-\r
-  Event   - The event signaled.\r
-  Context - The iSCSI driver data.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   ISCSI_DRIVER_DATA *Private;\r
 \r