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