2008-04-17 10:28:51 +02:00
|
|
|
/** @file
|
|
|
|
Miscellaneous definitions for IScsi driver.
|
2007-12-24 03:20:21 +01:00
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
Copyright (c) 2004 - 2008, Intel Corporation.<BR>
|
2008-01-22 09:07:35 +01:00
|
|
|
All rights reserved. This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
2007-12-24 03:20:21 +01:00
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
|
|
|
|
#ifndef _ISCSI_MISC_H_
|
|
|
|
#define _ISCSI_MISC_H_
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
|
|
|
|
typedef struct _ISCSI_SESSION_CONFIG_DATA ISCSI_SESSION_CONFIG_DATA;
|
|
|
|
|
2007-12-24 03:20:21 +01:00
|
|
|
#pragma pack(1)
|
2008-12-10 05:09:23 +01:00
|
|
|
typedef struct {
|
2007-12-24 03:20:21 +01:00
|
|
|
BOOLEAN Enabled;
|
|
|
|
|
|
|
|
BOOLEAN InitiatorInfoFromDhcp;
|
|
|
|
EFI_IPv4_ADDRESS LocalIp;
|
|
|
|
EFI_IPv4_ADDRESS SubnetMask;
|
|
|
|
EFI_IPv4_ADDRESS Gateway;
|
|
|
|
|
|
|
|
BOOLEAN TargetInfoFromDhcp;
|
|
|
|
CHAR8 TargetName[ISCSI_NAME_MAX_SIZE];
|
|
|
|
EFI_IPv4_ADDRESS TargetIp;
|
|
|
|
UINT16 TargetPort;
|
|
|
|
UINT8 BootLun[8];
|
|
|
|
} ISCSI_SESSION_CONFIG_NVDATA;
|
|
|
|
#pragma pack()
|
|
|
|
|
2008-01-04 06:51:44 +01:00
|
|
|
struct _ISCSI_SESSION_CONFIG_DATA {
|
2007-12-24 03:20:21 +01:00
|
|
|
ISCSI_SESSION_CONFIG_NVDATA NvData;
|
|
|
|
|
|
|
|
EFI_IPv4_ADDRESS PrimaryDns;
|
|
|
|
EFI_IPv4_ADDRESS SecondaryDns;
|
|
|
|
EFI_IPv4_ADDRESS DhcpServer;
|
2008-01-04 06:51:44 +01:00
|
|
|
};
|
2007-12-24 03:20:21 +01:00
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Calculate the prefix length of the IPv4 subnet mask.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] SubnetMask The IPv4 subnet mask.
|
2008-04-17 10:28:51 +02:00
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@return The prefix length of the subnet mask.
|
2008-12-12 08:03:44 +01:00
|
|
|
@retval 0 Other errors as indicated.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
UINT8
|
|
|
|
IScsiGetSubnetMaskPrefixLength (
|
|
|
|
IN EFI_IPv4_ADDRESS *SubnetMask
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Convert the hexadecimal encoded LUN string into the 64-bit LUN.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] Str The hexadecimal encoded LUN string.
|
|
|
|
@param[out] Lun Storage to return the 64-bit LUN.
|
2008-04-17 10:28:51 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS The 64-bit LUN is stored in Lun.
|
|
|
|
@retval EFI_INVALID_PARAMETER The string is malformatted.
|
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
EFI_STATUS
|
|
|
|
IScsiAsciiStrToLun (
|
|
|
|
IN CHAR8 *Str,
|
|
|
|
OUT UINT8 *Lun
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Convert the 64-bit LUN into the hexadecimal encoded LUN string.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] Lun The 64-bit LUN.
|
|
|
|
@param[out] Str The storage to return the hexadecimal encoded LUN string.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
VOID
|
|
|
|
IScsiLunToUnicodeStr (
|
|
|
|
IN UINT8 *Lun,
|
2008-12-10 05:09:23 +01:00
|
|
|
OUT CHAR16 *Str
|
2007-12-24 03:20:21 +01:00
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Convert the ASCII string into a UNICODE string.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] Source The ASCII string.
|
|
|
|
@param[out] Destination The storage to return the UNICODE string.
|
2008-04-17 10:28:51 +02:00
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@return CHAR16 * Pointer to the UNICODE string.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
|
|
|
CHAR16 *
|
2007-12-24 03:20:21 +01:00
|
|
|
IScsiAsciiStrToUnicodeStr (
|
|
|
|
IN CHAR8 *Source,
|
|
|
|
OUT CHAR16 *Destination
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Convert the UNICODE string into an ASCII string.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] Source The UNICODE string.
|
|
|
|
@param[out] Destination The storage to return the ASCII string.
|
2008-04-17 10:28:51 +02:00
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@return CHAR8 * Pointer to the ASCII string.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
|
|
|
CHAR8 *
|
2007-12-24 03:20:21 +01:00
|
|
|
IScsiUnicodeStrToAsciiStr (
|
|
|
|
IN CHAR16 *Source,
|
|
|
|
OUT CHAR8 *Destination
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Convert the mac address into a hexadecimal encoded "-" seperated string.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] Mac The mac address.
|
|
|
|
@param[in] Len Length in bytes of the mac address.
|
|
|
|
@param[out] Str The storage to return the mac string.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
VOID
|
|
|
|
IScsiMacAddrToStr (
|
|
|
|
IN EFI_MAC_ADDRESS *Mac,
|
|
|
|
IN UINT32 Len,
|
|
|
|
OUT CHAR16 *Str
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Convert the decimal dotted IPv4 address into the binary IPv4 address.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] Str The UNICODE string.
|
|
|
|
@param[out] Ip The storage to return the ASCII string.
|
2008-04-17 10:28:51 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS The binary IP address is returned in Ip.
|
|
|
|
@retval EFI_INVALID_PARAMETER The IP string is malformatted.
|
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
EFI_STATUS
|
|
|
|
IScsiAsciiStrToIp (
|
|
|
|
IN CHAR8 *Str,
|
|
|
|
OUT EFI_IPv4_ADDRESS *Ip
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Convert the binary encoded buffer into a hexadecimal encoded string.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] BinBuffer The buffer containing the binary data.
|
|
|
|
@param[in] BinLength Length of the binary buffer.
|
|
|
|
@param[in, out] HexStr Pointer to the string.
|
|
|
|
@param[in, out] HexLength The length of the string.
|
2008-04-17 10:28:51 +02:00
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@retval EFI_SUCCESS The binary data is converted to the hexadecimal string
|
2008-04-17 10:28:51 +02:00
|
|
|
and the length of the string is updated.
|
|
|
|
@retval EFI_BUFFER_TOO_SMALL The string is too small.
|
2008-12-10 05:09:23 +01:00
|
|
|
@retval EFI_INVALID_PARAMETER The IP string is malformatted.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
EFI_STATUS
|
|
|
|
IScsiBinToHex (
|
|
|
|
IN UINT8 *BinBuffer,
|
|
|
|
IN UINT32 BinLength,
|
|
|
|
IN OUT CHAR8 *HexStr,
|
|
|
|
IN OUT UINT32 *HexLength
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Convert the hexadecimal string into a binary encoded buffer.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in, out] BinBuffer The binary buffer.
|
|
|
|
@param[in, out] BinLength Length of the binary buffer.
|
|
|
|
@param[in] HexStr The hexadecimal string.
|
2008-04-17 10:28:51 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS The hexadecimal string is converted into a binary
|
|
|
|
encoded buffer.
|
2008-12-12 08:03:44 +01:00
|
|
|
@retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
EFI_STATUS
|
|
|
|
IScsiHexToBin (
|
|
|
|
IN OUT UINT8 *BinBuffer,
|
|
|
|
IN OUT UINT32 *BinLength,
|
|
|
|
IN CHAR8 *HexStr
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Generate random numbers.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in, out] Rand The buffer to contain random numbers.
|
|
|
|
@param[in] RandLength The length of the Rand buffer.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
VOID
|
|
|
|
IScsiGenRandom (
|
|
|
|
IN OUT UINT8 *Rand,
|
|
|
|
IN UINTN RandLength
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Create the iSCSI driver data..
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] Image The handle of the driver image.
|
|
|
|
@param[in] Controller The handle of the controller.
|
2008-04-17 10:28:51 +02:00
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@return The iSCSI driver data created.
|
2008-12-12 08:03:44 +01:00
|
|
|
@retval NULL Other errors as indicated.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
|
|
|
ISCSI_DRIVER_DATA *
|
2007-12-24 03:20:21 +01:00
|
|
|
IScsiCreateDriverData (
|
|
|
|
IN EFI_HANDLE Image,
|
|
|
|
IN EFI_HANDLE Controller
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Clean the iSCSI driver data.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] Private The iSCSI driver data.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
VOID
|
|
|
|
IScsiCleanDriverData (
|
|
|
|
IN ISCSI_DRIVER_DATA *Private
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Get the various configuration data of this iSCSI instance.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] Private The iSCSI driver data.
|
2008-04-17 10:28:51 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS The configuration of this instance is got.
|
2008-12-10 05:09:23 +01:00
|
|
|
@retval EFI_ABORTED The operation was aborted.
|
2008-12-12 08:03:44 +01:00
|
|
|
@retval Others Other errors as indicated.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
EFI_STATUS
|
|
|
|
IScsiGetConfigData (
|
|
|
|
IN ISCSI_DRIVER_DATA *Private
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Get the device path of the iSCSI tcp connection and update it.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] Private The iSCSI driver data.
|
2008-04-17 10:28:51 +02:00
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@return The updated device path.
|
2008-12-12 08:03:44 +01:00
|
|
|
@retval NULL Other errors as indicated.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
2008-12-10 05:09:23 +01:00
|
|
|
EFI_DEVICE_PATH_PROTOCOL *
|
2007-12-24 03:20:21 +01:00
|
|
|
IScsiGetTcpConnDevicePath (
|
|
|
|
IN ISCSI_DRIVER_DATA *Private
|
|
|
|
);
|
|
|
|
|
2008-04-17 10:28:51 +02:00
|
|
|
/**
|
|
|
|
Abort the session when the transition from BS to RT is initiated.
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
@param[in] Event The event signaled.
|
|
|
|
@param[in] Context The iSCSI driver data.
|
2008-04-17 10:28:51 +02:00
|
|
|
**/
|
2007-12-24 03:20:21 +01:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
IScsiOnExitBootService (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
);
|
|
|
|
|
2008-12-10 05:09:23 +01:00
|
|
|
|
2007-12-24 03:20:21 +01:00
|
|
|
|
|
|
|
#endif
|