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