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