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