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