2 Miscellaneous definitions for iSCSI driver.
4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 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
;
38 } ISCSI_SESSION_CONFIG_NVDATA
;
41 struct _ISCSI_SESSION_CONFIG_DATA
{
42 ISCSI_SESSION_CONFIG_NVDATA NvData
;
44 EFI_IPv4_ADDRESS PrimaryDns
;
45 EFI_IPv4_ADDRESS SecondaryDns
;
46 EFI_IPv4_ADDRESS DhcpServer
;
50 Calculate the prefix length of the IPv4 subnet mask.
52 @param[in] SubnetMask The IPv4 subnet mask.
54 @return The prefix length of the subnet mask.
55 @retval 0 Other errors as indicated.
58 IScsiGetSubnetMaskPrefixLength (
59 IN EFI_IPv4_ADDRESS
*SubnetMask
63 Convert the hexadecimal encoded LUN string into the 64-bit LUN.
65 @param[in] Str The hexadecimal encoded LUN string.
66 @param[out] Lun Storage to return the 64-bit LUN.
68 @retval EFI_SUCCESS The 64-bit LUN is stored in Lun.
69 @retval EFI_INVALID_PARAMETER The string is malformatted.
78 Convert the 64-bit LUN into the hexadecimal encoded LUN string.
80 @param[in] Lun The 64-bit LUN.
81 @param[out] Str The storage to return the hexadecimal encoded LUN string.
84 IScsiLunToUnicodeStr (
90 Convert the ASCII string into a UNICODE string.
92 @param[in] Source The ASCII string.
93 @param[out] Destination The storage to return the UNICODE string.
95 @return CHAR16 * Pointer to the UNICODE string.
98 IScsiAsciiStrToUnicodeStr (
100 OUT CHAR16
*Destination
104 Convert the UNICODE string into an ASCII string.
106 @param[in] Source The UNICODE string.
107 @param[out] Destination The storage to return the ASCII string.
109 @return CHAR8 * Pointer to the ASCII string.
112 IScsiUnicodeStrToAsciiStr (
114 OUT CHAR8
*Destination
118 Convert the mac address into a hexadecimal encoded "-" seperated string.
120 @param[in] Mac The mac address.
121 @param[in] Len Length in bytes of the mac address.
122 @param[in] VlanId VLAN ID of the network device.
123 @param[out] Str The storage to return the mac string.
127 IN EFI_MAC_ADDRESS
*Mac
,
134 Convert the decimal dotted IPv4 address into the binary IPv4 address.
136 @param[in] Str The UNICODE string.
137 @param[out] Ip The storage to return the ASCII string.
139 @retval EFI_SUCCESS The binary IP address is returned in Ip.
140 @retval EFI_INVALID_PARAMETER The IP string is malformatted.
145 OUT EFI_IPv4_ADDRESS
*Ip
149 Convert the binary encoded buffer into a hexadecimal encoded string.
151 @param[in] BinBuffer The buffer containing the binary data.
152 @param[in] BinLength Length of the binary buffer.
153 @param[in, out] HexStr Pointer to the string.
154 @param[in, out] HexLength The length of the string.
156 @retval EFI_SUCCESS The binary data is converted to the hexadecimal string
157 and the length of the string is updated.
158 @retval EFI_BUFFER_TOO_SMALL The string is too small.
159 @retval EFI_INVALID_PARAMETER The IP string is malformatted.
165 IN OUT CHAR8
*HexStr
,
166 IN OUT UINT32
*HexLength
170 Convert the hexadecimal string into a binary encoded buffer.
172 @param[in, out] BinBuffer The binary buffer.
173 @param[in, out] BinLength Length of the binary buffer.
174 @param[in] HexStr The hexadecimal string.
176 @retval EFI_SUCCESS The hexadecimal string is converted into a binary
178 @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.
182 IN OUT UINT8
*BinBuffer
,
183 IN OUT UINT32
*BinLength
,
188 Generate random numbers.
190 @param[in, out] Rand The buffer to contain random numbers.
191 @param[in] RandLength The length of the Rand buffer.
200 Create the iSCSI driver data..
202 @param[in] Image The handle of the driver image.
203 @param[in] Controller The handle of the controller.
205 @return The iSCSI driver data created.
206 @retval NULL Other errors as indicated.
209 IScsiCreateDriverData (
211 IN EFI_HANDLE Controller
215 Clean the iSCSI driver data.
217 @param[in] Private The iSCSI driver data.
220 IScsiCleanDriverData (
221 IN ISCSI_DRIVER_DATA
*Private
225 Check wheather the Controller is configured to use DHCP protocol.
227 @param[in] Controller The handle of the controller.
229 @retval TRUE The handle of the controller need the Dhcp protocol.
230 @retval FALSE The handle of the controller does not need the Dhcp protocol.
234 IScsiDhcpIsConfigured (
235 IN EFI_HANDLE Controller
239 Get the various configuration data of this iSCSI instance.
241 @param[in] Private The iSCSI driver data.
243 @retval EFI_SUCCESS The configuration of this instance is got.
244 @retval EFI_ABORTED The operation was aborted.
245 @retval Others Other errors as indicated.
249 IN ISCSI_DRIVER_DATA
*Private
253 Get the device path of the iSCSI tcp connection and update it.
255 @param[in] Private The iSCSI driver data.
257 @return The updated device path.
258 @retval NULL Other errors as indicated.
260 EFI_DEVICE_PATH_PROTOCOL
*
261 IScsiGetTcpConnDevicePath (
262 IN ISCSI_DRIVER_DATA
*Private
266 Abort the session when the transition from BS to RT is initiated.
268 @param[in] Event The event signaled.
269 @param[in] Context The iSCSI driver data.
273 IScsiOnExitBootService (
279 Tests whether a controller handle is being managed by IScsi driver.
281 This function tests whether the driver specified by DriverBindingHandle is
282 currently managing the controller specified by ControllerHandle. This test
283 is performed by evaluating if the the protocol specified by ProtocolGuid is
284 present on ControllerHandle and is was opened by DriverBindingHandle and Nic
285 Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
286 If ProtocolGuid is NULL, then ASSERT().
288 @param ControllerHandle A handle for a controller to test.
289 @param DriverBindingHandle Specifies the driver binding handle for the
291 @param ProtocolGuid Specifies the protocol that the driver specified
292 by DriverBindingHandle opens in its Start()
295 @retval EFI_SUCCESS ControllerHandle is managed by the driver
296 specified by DriverBindingHandle.
297 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver
298 specified by DriverBindingHandle.
303 IScsiTestManagedDevice (
304 IN EFI_HANDLE ControllerHandle
,
305 IN EFI_HANDLE DriverBindingHandle
,
306 IN EFI_GUID
*ProtocolGuid