]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
update file header
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiMisc.h
CommitLineData
12618416 1/** @file\r
2 Miscellaneous definitions for IScsi driver.\r
6a690e23 3\r
52ed4ff9 4Copyright (c) 2004 - 2008, Intel Corporation.<BR>\r
7a444476 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
6a690e23 12\r
12618416 13**/\r
6a690e23 14\r
15#ifndef _ISCSI_MISC_H_\r
16#define _ISCSI_MISC_H_\r
17\r
52ed4ff9 18#include <Library/BaseLib.h>\r
19\r
20typedef struct _ISCSI_SESSION_CONFIG_DATA ISCSI_SESSION_CONFIG_DATA;\r
21\r
6a690e23 22#pragma pack(1)\r
52ed4ff9 23typedef struct {\r
6a690e23 24 BOOLEAN Enabled;\r
25\r
26 BOOLEAN InitiatorInfoFromDhcp;\r
27 EFI_IPv4_ADDRESS LocalIp;\r
28 EFI_IPv4_ADDRESS SubnetMask;\r
29 EFI_IPv4_ADDRESS Gateway;\r
30\r
31 BOOLEAN TargetInfoFromDhcp;\r
32 CHAR8 TargetName[ISCSI_NAME_MAX_SIZE];\r
33 EFI_IPv4_ADDRESS TargetIp;\r
34 UINT16 TargetPort;\r
35 UINT8 BootLun[8];\r
36} ISCSI_SESSION_CONFIG_NVDATA;\r
37#pragma pack()\r
38\r
07a7038c 39struct _ISCSI_SESSION_CONFIG_DATA {\r
6a690e23 40 ISCSI_SESSION_CONFIG_NVDATA NvData;\r
41\r
42 EFI_IPv4_ADDRESS PrimaryDns;\r
43 EFI_IPv4_ADDRESS SecondaryDns;\r
44 EFI_IPv4_ADDRESS DhcpServer;\r
07a7038c 45};\r
6a690e23 46\r
12618416 47/**\r
48 Calculate the prefix length of the IPv4 subnet mask.\r
49\r
52ed4ff9 50 @param[in] SubnetMask The IPv4 subnet mask.\r
12618416 51\r
52ed4ff9 52 @return The prefix length of the subnet mask.\r
53 @return 0 Some unexpected error happened.\r
12618416 54**/\r
6a690e23 55UINT8\r
56IScsiGetSubnetMaskPrefixLength (\r
57 IN EFI_IPv4_ADDRESS *SubnetMask\r
58 );\r
59\r
12618416 60/**\r
61 Convert the hexadecimal encoded LUN string into the 64-bit LUN. \r
62\r
52ed4ff9 63 @param[in] Str The hexadecimal encoded LUN string.\r
64 @param[out] Lun Storage to return the 64-bit LUN.\r
12618416 65\r
66 @retval EFI_SUCCESS The 64-bit LUN is stored in Lun.\r
12618416 67 @retval EFI_INVALID_PARAMETER The string is malformatted.\r
12618416 68**/\r
6a690e23 69EFI_STATUS\r
70IScsiAsciiStrToLun (\r
71 IN CHAR8 *Str,\r
72 OUT UINT8 *Lun\r
73 );\r
74\r
12618416 75/**\r
76 Convert the 64-bit LUN into the hexadecimal encoded LUN string.\r
77\r
52ed4ff9 78 @param[in] Lun The 64-bit LUN.\r
79 @param[out] Str The storage to return the hexadecimal encoded LUN string.\r
12618416 80**/\r
6a690e23 81VOID\r
82IScsiLunToUnicodeStr (\r
83 IN UINT8 *Lun,\r
52ed4ff9 84 OUT CHAR16 *Str\r
6a690e23 85 );\r
86\r
12618416 87/**\r
88 Convert the ASCII string into a UNICODE string.\r
89\r
52ed4ff9 90 @param[in] Source The ASCII string.\r
91 @param[out] Destination The storage to return the UNICODE string.\r
12618416 92\r
52ed4ff9 93 @return CHAR16 * Pointer to the UNICODE string.\r
12618416 94**/\r
95CHAR16 *\r
6a690e23 96IScsiAsciiStrToUnicodeStr (\r
97 IN CHAR8 *Source,\r
98 OUT CHAR16 *Destination\r
99 );\r
100\r
12618416 101/**\r
102 Convert the UNICODE string into an ASCII string.\r
103\r
52ed4ff9 104 @param[in] Source The UNICODE string.\r
105 @param[out] Destination The storage to return the ASCII string.\r
12618416 106\r
52ed4ff9 107 @return CHAR8 * Pointer to the ASCII string.\r
12618416 108**/\r
109CHAR8 *\r
6a690e23 110IScsiUnicodeStrToAsciiStr (\r
111 IN CHAR16 *Source,\r
112 OUT CHAR8 *Destination\r
113 );\r
114\r
12618416 115/**\r
116 Convert the mac address into a hexadecimal encoded "-" seperated string.\r
117\r
52ed4ff9 118 @param[in] Mac The mac address.\r
119 @param[in] Len Length in bytes of the mac address.\r
120 @param[out] Str The storage to return the mac string.\r
12618416 121**/\r
6a690e23 122VOID\r
123IScsiMacAddrToStr (\r
124 IN EFI_MAC_ADDRESS *Mac,\r
125 IN UINT32 Len,\r
126 OUT CHAR16 *Str\r
127 );\r
128\r
12618416 129/**\r
130 Convert the decimal dotted IPv4 address into the binary IPv4 address.\r
131\r
52ed4ff9 132 @param[in] Str The UNICODE string.\r
133 @param[out] Ip The storage to return the ASCII string.\r
12618416 134\r
135 @retval EFI_SUCCESS The binary IP address is returned in Ip.\r
12618416 136 @retval EFI_INVALID_PARAMETER The IP string is malformatted.\r
12618416 137**/\r
6a690e23 138EFI_STATUS\r
139IScsiAsciiStrToIp (\r
140 IN CHAR8 *Str,\r
141 OUT EFI_IPv4_ADDRESS *Ip\r
142 );\r
143\r
12618416 144/**\r
145 Convert the binary encoded buffer into a hexadecimal encoded string.\r
146\r
52ed4ff9 147 @param[in] BinBuffer The buffer containing the binary data.\r
148 @param[in] BinLength Length of the binary buffer.\r
149 @param[in, out] HexStr Pointer to the string.\r
150 @param[in, out] HexLength The length of the string.\r
12618416 151\r
52ed4ff9 152 @retval EFI_SUCCESS The binary data is converted to the hexadecimal string \r
12618416 153 and the length of the string is updated.\r
12618416 154 @retval EFI_BUFFER_TOO_SMALL The string is too small.\r
52ed4ff9 155 @retval EFI_INVALID_PARAMETER The IP string is malformatted.\r
12618416 156**/\r
6a690e23 157EFI_STATUS\r
158IScsiBinToHex (\r
159 IN UINT8 *BinBuffer,\r
160 IN UINT32 BinLength,\r
161 IN OUT CHAR8 *HexStr,\r
162 IN OUT UINT32 *HexLength\r
163 );\r
164\r
12618416 165/**\r
166 Convert the hexadecimal string into a binary encoded buffer.\r
167\r
52ed4ff9 168 @param[in, out] BinBuffer The binary buffer.\r
169 @param[in, out] BinLength Length of the binary buffer.\r
170 @param[in] HexStr The hexadecimal string.\r
12618416 171\r
172 @retval EFI_SUCCESS The hexadecimal string is converted into a binary\r
173 encoded buffer.\r
12618416 174 @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.s\r
12618416 175**/\r
6a690e23 176EFI_STATUS\r
177IScsiHexToBin (\r
178 IN OUT UINT8 *BinBuffer,\r
179 IN OUT UINT32 *BinLength,\r
180 IN CHAR8 *HexStr\r
181 );\r
182\r
12618416 183/**\r
184 Generate random numbers.\r
185\r
52ed4ff9 186 @param[in, out] Rand The buffer to contain random numbers.\r
187 @param[in] RandLength The length of the Rand buffer.\r
12618416 188**/\r
6a690e23 189VOID\r
190IScsiGenRandom (\r
191 IN OUT UINT8 *Rand,\r
192 IN UINTN RandLength\r
193 );\r
194\r
12618416 195/**\r
196 Create the iSCSI driver data..\r
197\r
52ed4ff9 198 @param[in] Image The handle of the driver image.\r
199 @param[in] Controller The handle of the controller.\r
12618416 200\r
52ed4ff9 201 @return The iSCSI driver data created.\r
202 @return NULL Some unexpected error happened.\r
12618416 203**/\r
204ISCSI_DRIVER_DATA *\r
6a690e23 205IScsiCreateDriverData (\r
206 IN EFI_HANDLE Image,\r
207 IN EFI_HANDLE Controller\r
208 );\r
209\r
12618416 210/**\r
211 Clean the iSCSI driver data.\r
212\r
52ed4ff9 213 @param[in] Private The iSCSI driver data.\r
12618416 214**/\r
6a690e23 215VOID\r
216IScsiCleanDriverData (\r
217 IN ISCSI_DRIVER_DATA *Private\r
218 );\r
219\r
12618416 220/**\r
12618416 221 Get the various configuration data of this iSCSI instance.\r
222\r
52ed4ff9 223 @param[in] Private The iSCSI driver data.\r
12618416 224\r
225 @retval EFI_SUCCESS The configuration of this instance is got.\r
52ed4ff9 226 @retval EFI_ABORTED The operation was aborted.\r
227 @retval Others Some unexpected error happened.\r
12618416 228**/\r
6a690e23 229EFI_STATUS\r
230IScsiGetConfigData (\r
231 IN ISCSI_DRIVER_DATA *Private\r
232 );\r
233\r
12618416 234/**\r
235 Get the device path of the iSCSI tcp connection and update it.\r
236\r
52ed4ff9 237 @param[in] Private The iSCSI driver data.\r
12618416 238\r
52ed4ff9 239 @return The updated device path.\r
240 @return NULL Some unexpected error happened.\r
12618416 241**/\r
52ed4ff9 242EFI_DEVICE_PATH_PROTOCOL *\r
6a690e23 243IScsiGetTcpConnDevicePath (\r
244 IN ISCSI_DRIVER_DATA *Private\r
245 );\r
246\r
12618416 247/**\r
248 Abort the session when the transition from BS to RT is initiated.\r
249\r
52ed4ff9 250 @param[in] Event The event signaled.\r
251 @param[in] Context The iSCSI driver data.\r
12618416 252**/\r
6a690e23 253VOID\r
254EFIAPI\r
255IScsiOnExitBootService (\r
256 IN EFI_EVENT Event,\r
257 IN VOID *Context\r
258 );\r
259\r
52ed4ff9 260\r
6a690e23 261\r
262#endif\r