]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
Fix a bug about the iSCSI DHCP dependency issue.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiMisc.h
index 33315ae581915efcd4d2532222122f8ab8616d25..b310c9c579aabcd39276be6a01780690709965ef 100644 (file)
@@ -1,7 +1,8 @@
-/*++\r
+/** @file\r
+  Miscellaneous definitions for iSCSI driver.\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2013, 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\r
@@ -9,21 +10,17 @@ 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
-  IScsiMisc.h\r
-\r
-Abstract:\r
-\r
-  Miscellaneous definitions for iSCSI driver.\r
-\r
---*/\r
+**/\r
 \r
 #ifndef _ISCSI_MISC_H_\r
 #define _ISCSI_MISC_H_\r
 \r
+#include <Library/BaseLib.h>\r
+\r
+typedef struct _ISCSI_SESSION_CONFIG_DATA ISCSI_SESSION_CONFIG_DATA;\r
+\r
 #pragma pack(1)\r
-typedef struct _ISCSI_SESSION_CONFIG_NVDATA {\r
+typedef struct {\r
   BOOLEAN           Enabled;\r
 \r
   BOOLEAN           InitiatorInfoFromDhcp;\r
@@ -36,6 +33,8 @@ typedef struct _ISCSI_SESSION_CONFIG_NVDATA {
   EFI_IPv4_ADDRESS  TargetIp;\r
   UINT16            TargetPort;\r
   UINT8             BootLun[8];\r
+\r
+  UINT8             IsId[6];\r
 } ISCSI_SESSION_CONFIG_NVDATA;\r
 #pragma pack()\r
 \r
@@ -47,48 +46,118 @@ struct _ISCSI_SESSION_CONFIG_DATA {
   EFI_IPv4_ADDRESS            DhcpServer;\r
 };\r
 \r
+/**\r
+  Calculate the prefix length of the IPv4 subnet mask.\r
+\r
+  @param[in]  SubnetMask The IPv4 subnet mask.\r
+\r
+  @return The prefix length of the subnet mask.\r
+  @retval 0 Other errors as indicated.\r
+**/\r
 UINT8\r
 IScsiGetSubnetMaskPrefixLength (\r
   IN EFI_IPv4_ADDRESS  *SubnetMask\r
   );\r
 \r
+/**\r
+  Convert the hexadecimal encoded LUN string into the 64-bit LUN. \r
+\r
+  @param[in]   Str             The hexadecimal encoded LUN string.\r
+  @param[out]  Lun             Storage to return the 64-bit LUN.\r
+\r
+  @retval EFI_SUCCESS           The 64-bit LUN is stored in Lun.\r
+  @retval EFI_INVALID_PARAMETER The string is malformatted.\r
+**/\r
 EFI_STATUS\r
 IScsiAsciiStrToLun (\r
   IN  CHAR8  *Str,\r
   OUT UINT8  *Lun\r
   );\r
 \r
+/**\r
+  Convert the 64-bit LUN into the hexadecimal encoded LUN string.\r
+\r
+  @param[in]   Lun The 64-bit LUN.\r
+  @param[out]  Str The storage to return the hexadecimal encoded LUN string.\r
+**/\r
 VOID\r
 IScsiLunToUnicodeStr (\r
   IN UINT8    *Lun,\r
-  OUT CHAR16  *String\r
+  OUT CHAR16  *Str\r
   );\r
 \r
-CHAR16                    *\r
+/**\r
+  Convert the ASCII string into a UNICODE string.\r
+\r
+  @param[in]   Source      The ASCII string.\r
+  @param[out]  Destination The storage to return the UNICODE string.\r
+\r
+  @return CHAR16 *         Pointer to the UNICODE string.\r
+**/\r
+CHAR16 *\r
 IScsiAsciiStrToUnicodeStr (\r
   IN  CHAR8   *Source,\r
   OUT CHAR16  *Destination\r
   );\r
 \r
-CHAR8                     *\r
+/**\r
+  Convert the UNICODE string into an ASCII string.\r
+\r
+  @param[in]  Source       The UNICODE string.\r
+  @param[out] Destination  The storage to return the ASCII string.\r
+\r
+  @return CHAR8 *          Pointer to the ASCII string.\r
+**/\r
+CHAR8 *\r
 IScsiUnicodeStrToAsciiStr (\r
   IN  CHAR16  *Source,\r
   OUT CHAR8   *Destination\r
   );\r
 \r
+/**\r
+  Convert the mac address into a hexadecimal encoded "-" seperated string.\r
+\r
+  @param[in]  Mac     The mac address.\r
+  @param[in]  Len     Length in bytes of the mac address.\r
+  @param[in]  VlanId  VLAN ID of the network device.\r
+  @param[out] Str     The storage to return the mac string.\r
+**/\r
 VOID\r
 IScsiMacAddrToStr (\r
   IN  EFI_MAC_ADDRESS  *Mac,\r
   IN  UINT32           Len,\r
+  IN  UINT16           VlanId,\r
   OUT CHAR16           *Str\r
   );\r
 \r
+/**\r
+  Convert the decimal dotted IPv4 address into the binary IPv4 address.\r
+\r
+  @param[in]   Str             The UNICODE string.\r
+  @param[out]  Ip              The storage to return the ASCII string.\r
+\r
+  @retval EFI_SUCCESS           The binary IP address is returned in Ip.\r
+  @retval EFI_INVALID_PARAMETER The IP string is malformatted.\r
+**/\r
 EFI_STATUS\r
 IScsiAsciiStrToIp (\r
   IN  CHAR8             *Str,\r
   OUT EFI_IPv4_ADDRESS  *Ip\r
   );\r
 \r
+/**\r
+  Convert the binary encoded buffer into a hexadecimal encoded string.\r
+\r
+  @param[in]       BinBuffer   The buffer containing the binary data.\r
+  @param[in]       BinLength   Length of the binary buffer.\r
+  @param[in, out]  HexStr      Pointer to the string.\r
+  @param[in, out]  HexLength   The length of the string.\r
+\r
+  @retval EFI_SUCCESS          The binary data is converted to the hexadecimal string \r
+                               and the length of the string is updated.\r
+  @retval EFI_BUFFER_TOO_SMALL The string is too small.\r
+  @retval EFI_INVALID_PARAMETER The IP string is malformatted.\r
+**/\r
 EFI_STATUS\r
 IScsiBinToHex (\r
   IN     UINT8  *BinBuffer,\r
@@ -97,6 +166,17 @@ IScsiBinToHex (
   IN OUT UINT32 *HexLength\r
   );\r
 \r
+/**\r
+  Convert the hexadecimal string into a binary encoded buffer.\r
+\r
+  @param[in, out]  BinBuffer   The binary buffer.\r
+  @param[in, out]  BinLength   Length of the binary buffer.\r
+  @param[in]       HexStr      The hexadecimal string.\r
+\r
+  @retval EFI_SUCCESS          The hexadecimal string is converted into a binary\r
+                               encoded buffer.\r
+  @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.\r
+**/\r
 EFI_STATUS\r
 IScsiHexToBin (\r
   IN OUT UINT8  *BinBuffer,\r
@@ -104,33 +184,90 @@ IScsiHexToBin (
   IN     CHAR8  *HexStr\r
   );\r
 \r
+/**\r
+  Generate random numbers.\r
+\r
+  @param[in, out]  Rand       The buffer to contain random numbers.\r
+  @param[in]       RandLength The length of the Rand buffer.\r
+**/\r
 VOID\r
 IScsiGenRandom (\r
   IN OUT UINT8  *Rand,\r
   IN     UINTN  RandLength\r
   );\r
 \r
-ISCSI_DRIVER_DATA         *\r
+/**\r
+  Create the iSCSI driver data..\r
+\r
+  @param[in] Image      The handle of the driver image.\r
+  @param[in] Controller The handle of the controller.\r
+\r
+  @return The iSCSI driver data created.\r
+  @retval NULL Other errors as indicated.\r
+**/\r
+ISCSI_DRIVER_DATA *\r
 IScsiCreateDriverData (\r
   IN EFI_HANDLE  Image,\r
   IN EFI_HANDLE  Controller\r
   );\r
 \r
+/**\r
+  Clean the iSCSI driver data.\r
+\r
+  @param[in]  Private The iSCSI driver data.\r
+**/\r
 VOID\r
 IScsiCleanDriverData (\r
   IN ISCSI_DRIVER_DATA  *Private\r
   );\r
 \r
+/**\r
+  Check wheather the Controller is configured to use DHCP protocol.\r
+\r
+  @param[in]  Controller           The handle of the controller.\r
+  \r
+  @retval TRUE                     The handle of the controller need the Dhcp protocol.\r
+  @retval FALSE                    The handle of the controller does not need the Dhcp protocol.\r
+  \r
+**/\r
+BOOLEAN\r
+IScsiDhcpIsConfigured (\r
+  IN EFI_HANDLE  Controller\r
+  );\r
+\r
+/**\r
+  Get the various configuration data of this iSCSI instance.\r
+\r
+  @param[in]  Private   The iSCSI driver data.\r
+\r
+  @retval EFI_SUCCESS   The configuration of this instance is got.\r
+  @retval EFI_ABORTED   The operation was aborted.\r
+  @retval Others        Other errors as indicated.\r
+**/\r
 EFI_STATUS\r
 IScsiGetConfigData (\r
   IN ISCSI_DRIVER_DATA  *Private\r
   );\r
 \r
-EFI_DEVICE_PATH_PROTOCOL  *\r
+/**\r
+  Get the device path of the iSCSI tcp connection and update it.\r
+\r
+  @param[in]  Private The iSCSI driver data.\r
+\r
+  @return The updated device path.\r
+  @retval NULL Other errors as indicated.\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
 IScsiGetTcpConnDevicePath (\r
   IN ISCSI_DRIVER_DATA  *Private\r
   );\r
 \r
+/**\r
+  Abort the session when the transition from BS to RT is initiated.\r
+\r
+  @param[in]   Event  The event signaled.\r
+  @param[in]  Context The iSCSI driver data.\r
+**/\r
 VOID\r
 EFIAPI\r
 IScsiOnExitBootService (\r
@@ -138,6 +275,6 @@ IScsiOnExitBootService (
   IN VOID       *Context\r
   );\r
 \r
-extern CHAR16 NibbleToHexChar(UINT8 Nibble);\r
+\r
 \r
 #endif\r