2 Miscellaneous definitions for iSCSI driver.
4 Copyright (c) 2004 - 2008, Intel Corporation.<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _ISCSI_MISC_H_
16 #define _ISCSI_MISC_H_
18 #include <Library/BaseLib.h>
20 typedef struct _ISCSI_SESSION_CONFIG_DATA ISCSI_SESSION_CONFIG_DATA
;
26 BOOLEAN InitiatorInfoFromDhcp
;
27 EFI_IPv4_ADDRESS LocalIp
;
28 EFI_IPv4_ADDRESS SubnetMask
;
29 EFI_IPv4_ADDRESS Gateway
;
31 BOOLEAN TargetInfoFromDhcp
;
32 CHAR8 TargetName
[ISCSI_NAME_MAX_SIZE
];
33 EFI_IPv4_ADDRESS TargetIp
;
36 } ISCSI_SESSION_CONFIG_NVDATA
;
39 struct _ISCSI_SESSION_CONFIG_DATA
{
40 ISCSI_SESSION_CONFIG_NVDATA NvData
;
42 EFI_IPv4_ADDRESS PrimaryDns
;
43 EFI_IPv4_ADDRESS SecondaryDns
;
44 EFI_IPv4_ADDRESS DhcpServer
;
48 Calculate the prefix length of the IPv4 subnet mask.
50 @param[in] SubnetMask The IPv4 subnet mask.
52 @return The prefix length of the subnet mask.
53 @retval 0 Other errors as indicated.
56 IScsiGetSubnetMaskPrefixLength (
57 IN EFI_IPv4_ADDRESS
*SubnetMask
61 Convert the hexadecimal encoded LUN string into the 64-bit LUN.
63 @param[in] Str The hexadecimal encoded LUN string.
64 @param[out] Lun Storage to return the 64-bit LUN.
66 @retval EFI_SUCCESS The 64-bit LUN is stored in Lun.
67 @retval EFI_INVALID_PARAMETER The string is malformatted.
76 Convert the 64-bit LUN into the hexadecimal encoded LUN string.
78 @param[in] Lun The 64-bit LUN.
79 @param[out] Str The storage to return the hexadecimal encoded LUN string.
82 IScsiLunToUnicodeStr (
88 Convert the ASCII string into a UNICODE string.
90 @param[in] Source The ASCII string.
91 @param[out] Destination The storage to return the UNICODE string.
93 @return CHAR16 * Pointer to the UNICODE string.
96 IScsiAsciiStrToUnicodeStr (
98 OUT CHAR16
*Destination
102 Convert the UNICODE string into an ASCII string.
104 @param[in] Source The UNICODE string.
105 @param[out] Destination The storage to return the ASCII string.
107 @return CHAR8 * Pointer to the ASCII string.
110 IScsiUnicodeStrToAsciiStr (
112 OUT CHAR8
*Destination
116 Convert the mac address into a hexadecimal encoded "-" seperated string.
118 @param[in] Mac The mac address.
119 @param[in] Len Length in bytes of the mac address.
120 @param[out] Str The storage to return the mac string.
124 IN EFI_MAC_ADDRESS
*Mac
,
130 Convert the decimal dotted IPv4 address into the binary IPv4 address.
132 @param[in] Str The UNICODE string.
133 @param[out] Ip The storage to return the ASCII string.
135 @retval EFI_SUCCESS The binary IP address is returned in Ip.
136 @retval EFI_INVALID_PARAMETER The IP string is malformatted.
141 OUT EFI_IPv4_ADDRESS
*Ip
145 Convert the binary encoded buffer into a hexadecimal encoded string.
147 @param[in] BinBuffer The buffer containing the binary data.
148 @param[in] BinLength Length of the binary buffer.
149 @param[in, out] HexStr Pointer to the string.
150 @param[in, out] HexLength The length of the string.
152 @retval EFI_SUCCESS The binary data is converted to the hexadecimal string
153 and the length of the string is updated.
154 @retval EFI_BUFFER_TOO_SMALL The string is too small.
155 @retval EFI_INVALID_PARAMETER The IP string is malformatted.
161 IN OUT CHAR8
*HexStr
,
162 IN OUT UINT32
*HexLength
166 Convert the hexadecimal string into a binary encoded buffer.
168 @param[in, out] BinBuffer The binary buffer.
169 @param[in, out] BinLength Length of the binary buffer.
170 @param[in] HexStr The hexadecimal string.
172 @retval EFI_SUCCESS The hexadecimal string is converted into a binary
174 @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.
178 IN OUT UINT8
*BinBuffer
,
179 IN OUT UINT32
*BinLength
,
184 Generate random numbers.
186 @param[in, out] Rand The buffer to contain random numbers.
187 @param[in] RandLength The length of the Rand buffer.
196 Create the iSCSI driver data..
198 @param[in] Image The handle of the driver image.
199 @param[in] Controller The handle of the controller.
201 @return The iSCSI driver data created.
202 @retval NULL Other errors as indicated.
205 IScsiCreateDriverData (
207 IN EFI_HANDLE Controller
211 Clean the iSCSI driver data.
213 @param[in] Private The iSCSI driver data.
216 IScsiCleanDriverData (
217 IN ISCSI_DRIVER_DATA
*Private
221 Get the various configuration data of this iSCSI instance.
223 @param[in] Private The iSCSI driver data.
225 @retval EFI_SUCCESS The configuration of this instance is got.
226 @retval EFI_ABORTED The operation was aborted.
227 @retval Others Other errors as indicated.
231 IN ISCSI_DRIVER_DATA
*Private
235 Get the device path of the iSCSI tcp connection and update it.
237 @param[in] Private The iSCSI driver data.
239 @return The updated device path.
240 @retval NULL Other errors as indicated.
242 EFI_DEVICE_PATH_PROTOCOL
*
243 IScsiGetTcpConnDevicePath (
244 IN ISCSI_DRIVER_DATA
*Private
248 Abort the session when the transition from BS to RT is initiated.
250 @param[in] Event The event signaled.
251 @param[in] Context The iSCSI driver data.
255 IScsiOnExitBootService (