]>
Commit | Line | Data |
---|---|---|
12618416 | 1 | /** @file\r |
55a64ae0 | 2 | Miscellaneous definitions for iSCSI driver.\r |
6a690e23 | 3 | \r |
18b24f92 | 4 | Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r |
e5eed7d3 | 5 | This program and the accompanying materials\r |
7a444476 | 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 |
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 | |
20 | typedef struct _ISCSI_SESSION_CONFIG_DATA ISCSI_SESSION_CONFIG_DATA;\r | |
21 | \r | |
6a690e23 | 22 | #pragma pack(1)\r |
52ed4ff9 | 23 | typedef 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 | |
312e3bdf | 36 | \r |
37 | UINT8 IsId[6];\r | |
6a690e23 | 38 | } ISCSI_SESSION_CONFIG_NVDATA;\r |
39 | #pragma pack()\r | |
40 | \r | |
07a7038c | 41 | struct _ISCSI_SESSION_CONFIG_DATA {\r |
6a690e23 | 42 | ISCSI_SESSION_CONFIG_NVDATA NvData;\r |
43 | \r | |
44 | EFI_IPv4_ADDRESS PrimaryDns;\r | |
45 | EFI_IPv4_ADDRESS SecondaryDns;\r | |
46 | EFI_IPv4_ADDRESS DhcpServer;\r | |
07a7038c | 47 | };\r |
6a690e23 | 48 | \r |
12618416 | 49 | /**\r |
50 | Calculate the prefix length of the IPv4 subnet mask.\r | |
51 | \r | |
52ed4ff9 | 52 | @param[in] SubnetMask The IPv4 subnet mask.\r |
12618416 | 53 | \r |
52ed4ff9 | 54 | @return The prefix length of the subnet mask.\r |
963dbb30 | 55 | @retval 0 Other errors as indicated.\r |
12618416 | 56 | **/\r |
6a690e23 | 57 | UINT8\r |
58 | IScsiGetSubnetMaskPrefixLength (\r | |
59 | IN EFI_IPv4_ADDRESS *SubnetMask\r | |
60 | );\r | |
61 | \r | |
12618416 | 62 | /**\r |
63 | Convert the hexadecimal encoded LUN string into the 64-bit LUN. \r | |
64 | \r | |
52ed4ff9 | 65 | @param[in] Str The hexadecimal encoded LUN string.\r |
66 | @param[out] Lun Storage to return the 64-bit LUN.\r | |
12618416 | 67 | \r |
68 | @retval EFI_SUCCESS The 64-bit LUN is stored in Lun.\r | |
12618416 | 69 | @retval EFI_INVALID_PARAMETER The string is malformatted.\r |
12618416 | 70 | **/\r |
6a690e23 | 71 | EFI_STATUS\r |
72 | IScsiAsciiStrToLun (\r | |
73 | IN CHAR8 *Str,\r | |
74 | OUT UINT8 *Lun\r | |
75 | );\r | |
76 | \r | |
12618416 | 77 | /**\r |
78 | Convert the 64-bit LUN into the hexadecimal encoded LUN string.\r | |
79 | \r | |
52ed4ff9 | 80 | @param[in] Lun The 64-bit LUN.\r |
81 | @param[out] Str The storage to return the hexadecimal encoded LUN string.\r | |
12618416 | 82 | **/\r |
6a690e23 | 83 | VOID\r |
84 | IScsiLunToUnicodeStr (\r | |
85 | IN UINT8 *Lun,\r | |
52ed4ff9 | 86 | OUT CHAR16 *Str\r |
6a690e23 | 87 | );\r |
88 | \r | |
12618416 | 89 | /**\r |
90 | Convert the ASCII string into a UNICODE string.\r | |
91 | \r | |
52ed4ff9 | 92 | @param[in] Source The ASCII string.\r |
93 | @param[out] Destination The storage to return the UNICODE string.\r | |
12618416 | 94 | \r |
52ed4ff9 | 95 | @return CHAR16 * Pointer to the UNICODE string.\r |
12618416 | 96 | **/\r |
97 | CHAR16 *\r | |
6a690e23 | 98 | IScsiAsciiStrToUnicodeStr (\r |
99 | IN CHAR8 *Source,\r | |
100 | OUT CHAR16 *Destination\r | |
101 | );\r | |
102 | \r | |
12618416 | 103 | /**\r |
104 | Convert the UNICODE string into an ASCII string.\r | |
105 | \r | |
52ed4ff9 | 106 | @param[in] Source The UNICODE string.\r |
107 | @param[out] Destination The storage to return the ASCII string.\r | |
12618416 | 108 | \r |
52ed4ff9 | 109 | @return CHAR8 * Pointer to the ASCII string.\r |
12618416 | 110 | **/\r |
111 | CHAR8 *\r | |
6a690e23 | 112 | IScsiUnicodeStrToAsciiStr (\r |
113 | IN CHAR16 *Source,\r | |
114 | OUT CHAR8 *Destination\r | |
115 | );\r | |
116 | \r | |
12618416 | 117 | /**\r |
118 | Convert the mac address into a hexadecimal encoded "-" seperated string.\r | |
119 | \r | |
779ae357 | 120 | @param[in] Mac The mac address.\r |
121 | @param[in] Len Length in bytes of the mac address.\r | |
122 | @param[in] VlanId VLAN ID of the network device.\r | |
123 | @param[out] Str The storage to return the mac string.\r | |
12618416 | 124 | **/\r |
6a690e23 | 125 | VOID\r |
126 | IScsiMacAddrToStr (\r | |
127 | IN EFI_MAC_ADDRESS *Mac,\r | |
128 | IN UINT32 Len,\r | |
779ae357 | 129 | IN UINT16 VlanId,\r |
6a690e23 | 130 | OUT CHAR16 *Str\r |
131 | );\r | |
132 | \r | |
12618416 | 133 | /**\r |
134 | Convert the decimal dotted IPv4 address into the binary IPv4 address.\r | |
135 | \r | |
52ed4ff9 | 136 | @param[in] Str The UNICODE string.\r |
137 | @param[out] Ip The storage to return the ASCII string.\r | |
12618416 | 138 | \r |
139 | @retval EFI_SUCCESS The binary IP address is returned in Ip.\r | |
12618416 | 140 | @retval EFI_INVALID_PARAMETER The IP string is malformatted.\r |
12618416 | 141 | **/\r |
6a690e23 | 142 | EFI_STATUS\r |
143 | IScsiAsciiStrToIp (\r | |
144 | IN CHAR8 *Str,\r | |
145 | OUT EFI_IPv4_ADDRESS *Ip\r | |
146 | );\r | |
147 | \r | |
12618416 | 148 | /**\r |
149 | Convert the binary encoded buffer into a hexadecimal encoded string.\r | |
150 | \r | |
52ed4ff9 | 151 | @param[in] BinBuffer The buffer containing the binary data.\r |
152 | @param[in] BinLength Length of the binary buffer.\r | |
153 | @param[in, out] HexStr Pointer to the string.\r | |
154 | @param[in, out] HexLength The length of the string.\r | |
12618416 | 155 | \r |
52ed4ff9 | 156 | @retval EFI_SUCCESS The binary data is converted to the hexadecimal string \r |
12618416 | 157 | and the length of the string is updated.\r |
12618416 | 158 | @retval EFI_BUFFER_TOO_SMALL The string is too small.\r |
52ed4ff9 | 159 | @retval EFI_INVALID_PARAMETER The IP string is malformatted.\r |
12618416 | 160 | **/\r |
6a690e23 | 161 | EFI_STATUS\r |
162 | IScsiBinToHex (\r | |
163 | IN UINT8 *BinBuffer,\r | |
164 | IN UINT32 BinLength,\r | |
165 | IN OUT CHAR8 *HexStr,\r | |
166 | IN OUT UINT32 *HexLength\r | |
167 | );\r | |
168 | \r | |
12618416 | 169 | /**\r |
170 | Convert the hexadecimal string into a binary encoded buffer.\r | |
171 | \r | |
52ed4ff9 | 172 | @param[in, out] BinBuffer The binary buffer.\r |
173 | @param[in, out] BinLength Length of the binary buffer.\r | |
174 | @param[in] HexStr The hexadecimal string.\r | |
12618416 | 175 | \r |
176 | @retval EFI_SUCCESS The hexadecimal string is converted into a binary\r | |
177 | encoded buffer.\r | |
963dbb30 | 178 | @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.\r |
12618416 | 179 | **/\r |
6a690e23 | 180 | EFI_STATUS\r |
181 | IScsiHexToBin (\r | |
182 | IN OUT UINT8 *BinBuffer,\r | |
183 | IN OUT UINT32 *BinLength,\r | |
184 | IN CHAR8 *HexStr\r | |
185 | );\r | |
186 | \r | |
12618416 | 187 | /**\r |
188 | Generate random numbers.\r | |
189 | \r | |
52ed4ff9 | 190 | @param[in, out] Rand The buffer to contain random numbers.\r |
191 | @param[in] RandLength The length of the Rand buffer.\r | |
12618416 | 192 | **/\r |
6a690e23 | 193 | VOID\r |
194 | IScsiGenRandom (\r | |
195 | IN OUT UINT8 *Rand,\r | |
196 | IN UINTN RandLength\r | |
197 | );\r | |
198 | \r | |
12618416 | 199 | /**\r |
200 | Create the iSCSI driver data..\r | |
201 | \r | |
52ed4ff9 | 202 | @param[in] Image The handle of the driver image.\r |
203 | @param[in] Controller The handle of the controller.\r | |
12618416 | 204 | \r |
52ed4ff9 | 205 | @return The iSCSI driver data created.\r |
963dbb30 | 206 | @retval NULL Other errors as indicated.\r |
12618416 | 207 | **/\r |
208 | ISCSI_DRIVER_DATA *\r | |
6a690e23 | 209 | IScsiCreateDriverData (\r |
210 | IN EFI_HANDLE Image,\r | |
211 | IN EFI_HANDLE Controller\r | |
212 | );\r | |
213 | \r | |
12618416 | 214 | /**\r |
215 | Clean the iSCSI driver data.\r | |
216 | \r | |
52ed4ff9 | 217 | @param[in] Private The iSCSI driver data.\r |
12618416 | 218 | **/\r |
6a690e23 | 219 | VOID\r |
220 | IScsiCleanDriverData (\r | |
221 | IN ISCSI_DRIVER_DATA *Private\r | |
222 | );\r | |
223 | \r | |
05a30011 WJ |
224 | /**\r |
225 | Check wheather the Controller is configured to use DHCP protocol.\r | |
226 | \r | |
227 | @param[in] Controller The handle of the controller.\r | |
228 | \r | |
229 | @retval TRUE The handle of the controller need the Dhcp protocol.\r | |
230 | @retval FALSE The handle of the controller does not need the Dhcp protocol.\r | |
231 | \r | |
232 | **/\r | |
233 | BOOLEAN\r | |
234 | IScsiDhcpIsConfigured (\r | |
235 | IN EFI_HANDLE Controller\r | |
236 | );\r | |
237 | \r | |
12618416 | 238 | /**\r |
12618416 | 239 | Get the various configuration data of this iSCSI instance.\r |
240 | \r | |
52ed4ff9 | 241 | @param[in] Private The iSCSI driver data.\r |
12618416 | 242 | \r |
243 | @retval EFI_SUCCESS The configuration of this instance is got.\r | |
52ed4ff9 | 244 | @retval EFI_ABORTED The operation was aborted.\r |
963dbb30 | 245 | @retval Others Other errors as indicated.\r |
12618416 | 246 | **/\r |
6a690e23 | 247 | EFI_STATUS\r |
248 | IScsiGetConfigData (\r | |
249 | IN ISCSI_DRIVER_DATA *Private\r | |
250 | );\r | |
251 | \r | |
12618416 | 252 | /**\r |
253 | Get the device path of the iSCSI tcp connection and update it.\r | |
254 | \r | |
52ed4ff9 | 255 | @param[in] Private The iSCSI driver data.\r |
12618416 | 256 | \r |
52ed4ff9 | 257 | @return The updated device path.\r |
963dbb30 | 258 | @retval NULL Other errors as indicated.\r |
12618416 | 259 | **/\r |
52ed4ff9 | 260 | EFI_DEVICE_PATH_PROTOCOL *\r |
6a690e23 | 261 | IScsiGetTcpConnDevicePath (\r |
262 | IN ISCSI_DRIVER_DATA *Private\r | |
263 | );\r | |
264 | \r | |
12618416 | 265 | /**\r |
266 | Abort the session when the transition from BS to RT is initiated.\r | |
267 | \r | |
52ed4ff9 | 268 | @param[in] Event The event signaled.\r |
269 | @param[in] Context The iSCSI driver data.\r | |
12618416 | 270 | **/\r |
6a690e23 | 271 | VOID\r |
272 | EFIAPI\r | |
273 | IScsiOnExitBootService (\r | |
274 | IN EFI_EVENT Event,\r | |
275 | IN VOID *Context\r | |
276 | );\r | |
277 | \r | |
18b24f92 FS |
278 | /**\r |
279 | Tests whether a controller handle is being managed by IScsi driver.\r | |
280 | \r | |
281 | This function tests whether the driver specified by DriverBindingHandle is\r | |
282 | currently managing the controller specified by ControllerHandle. This test\r | |
283 | is performed by evaluating if the the protocol specified by ProtocolGuid is\r | |
284 | present on ControllerHandle and is was opened by DriverBindingHandle and Nic\r | |
285 | Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. \r | |
286 | If ProtocolGuid is NULL, then ASSERT().\r | |
287 | \r | |
288 | @param ControllerHandle A handle for a controller to test.\r | |
289 | @param DriverBindingHandle Specifies the driver binding handle for the\r | |
290 | driver.\r | |
291 | @param ProtocolGuid Specifies the protocol that the driver specified\r | |
292 | by DriverBindingHandle opens in its Start()\r | |
293 | function.\r | |
294 | \r | |
295 | @retval EFI_SUCCESS ControllerHandle is managed by the driver\r | |
296 | specified by DriverBindingHandle.\r | |
297 | @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver\r | |
298 | specified by DriverBindingHandle.\r | |
52ed4ff9 | 299 | \r |
18b24f92 FS |
300 | **/\r |
301 | EFI_STATUS\r | |
302 | EFIAPI\r | |
303 | IScsiTestManagedDevice (\r | |
304 | IN EFI_HANDLE ControllerHandle,\r | |
305 | IN EFI_HANDLE DriverBindingHandle,\r | |
306 | IN EFI_GUID *ProtocolGuid\r | |
307 | );\r | |
6a690e23 | 308 | \r |
309 | #endif\r |