]>
Commit | Line | Data |
---|---|---|
83cbd279 | 1 | /** @file\r |
402fa70f | 2 | Header file for IP4Config driver.\r |
83cbd279 | 3 | \r |
63886849 | 4 | Copyright (c) 2006 - 2009, Intel Corporation.<BR>\r |
83cbd279 | 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 | |
402fa70f | 7 | which accompanies this distribution. The full text of the license may be found at<BR>\r |
83cbd279 | 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 | |
83cbd279 | 13 | **/\r |
14 | \r | |
402fa70f | 15 | #ifndef _EFI_IP4CONFIG_H_\r |
16 | #define _EFI_IP4CONFIG_H_\r | |
83cbd279 | 17 | \r |
c8d8f1e3 | 18 | #include <Uefi.h>\r |
b2570da8 | 19 | \r |
20 | #include <Protocol/Dhcp4.h>\r | |
24e58768 | 21 | #include <Protocol/Ip4Config.h>\r |
b2570da8 | 22 | #include <Protocol/ManagedNetwork.h>\r |
63886849 | 23 | #include <Protocol/HiiConfigAccess.h>\r |
24 | #include <Protocol/HiiDatabase.h>\r | |
25 | #include <Protocol/HiiConfigRouting.h>\r | |
b2570da8 | 26 | \r |
63886849 | 27 | #include <Guid/MdeModuleHii.h>\r |
28 | \r | |
29 | #include <Library/DevicePathLib.h>\r | |
b2570da8 | 30 | #include <Library/DebugLib.h>\r |
31 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
32 | #include <Library/UefiDriverEntryPoint.h>\r | |
33 | #include <Library/UefiBootServicesTableLib.h>\r | |
34 | #include <Library/UefiLib.h>\r | |
35 | #include <Library/NetLib.h>\r | |
36 | #include <Library/BaseMemoryLib.h>\r | |
83cbd279 | 37 | #include <Library/MemoryAllocationLib.h>\r |
63886849 | 38 | #include <Library/HiiLib.h>\r |
39 | #include <Library/PrintLib.h>\r | |
d8d26fb2 | 40 | #include <Library/DpcLib.h>\r |
83cbd279 | 41 | \r |
42 | #include "NicIp4Variable.h"\r | |
43 | \r | |
44 | typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE;\r | |
45 | \r | |
c8d8f1e3 | 46 | //\r |
63886849 | 47 | // Global variables\r |
c8d8f1e3 | 48 | //\r |
f6b7393c | 49 | extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding;\r |
50 | extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName;\r | |
51 | extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2;\r | |
52 | \r | |
53 | extern IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];\r | |
54 | extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate;\r | |
c8d8f1e3 | 55 | \r |
56 | #define IP4_PROTO_ICMP 0x01\r | |
57 | #define IP4_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')\r | |
58 | \r | |
f6b7393c | 59 | #define IP4_CONFIG_STATE_IDLE 0\r |
60 | #define IP4_CONFIG_STATE_STARTED 1\r | |
61 | #define IP4_CONFIG_STATE_CONFIGURED 2\r | |
62 | \r | |
63 | #define DHCP_TAG_PARA_LIST 55\r | |
64 | #define DHCP_TAG_NETMASK 1\r | |
65 | #define DHCP_TAG_ROUTER 3\r | |
66 | \r | |
83cbd279 | 67 | \r |
68 | //\r | |
69 | // Configure the DHCP to request the routers and netmask\r | |
70 | // from server. The DHCP_TAG_NETMASK is included in Head.\r | |
71 | //\r | |
72 | #pragma pack(1)\r | |
73 | typedef struct {\r | |
74 | EFI_DHCP4_PACKET_OPTION Head;\r | |
75 | UINT8 Route;\r | |
76 | } IP4_CONFIG_DHCP4_OPTION;\r | |
77 | #pragma pack()\r | |
78 | \r | |
63886849 | 79 | \r |
80 | typedef struct {\r | |
81 | UINTN DeviceNum;\r | |
82 | BOOLEAN Enabled;\r | |
83 | EFI_IPv4_ADDRESS LocalIp;\r | |
84 | EFI_IPv4_ADDRESS SubnetMask;\r | |
85 | EFI_IPv4_ADDRESS Gateway;\r | |
86 | } IP4_CONFIG_SESSION_DATA;\r | |
87 | \r | |
88 | typedef struct _IP4_CONFIG_FORM_ENTRY {\r | |
89 | LIST_ENTRY Link;\r | |
90 | IP4_CONFIG_INSTANCE *Ip4ConfigInstance;\r | |
91 | EFI_HANDLE Controller;\r | |
779ae357 | 92 | CHAR16 *MacString;\r |
63886849 | 93 | EFI_STRING_ID PortTitleToken;\r |
94 | EFI_STRING_ID PortTitleHelpToken;\r | |
95 | IP4_CONFIG_SESSION_DATA SessionConfigData;\r | |
96 | } IP4CONFIG_FORM_ENTRY;\r | |
97 | \r | |
98 | #define IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')\r | |
99 | \r | |
100 | typedef struct _IP4_FORM_CALLBACK_INFO_INSTANCE {\r | |
101 | UINTN Signature;\r | |
102 | EFI_HANDLE DriverHandle;\r | |
103 | EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;\r | |
104 | EFI_HII_DATABASE_PROTOCOL *HiiDatabase;\r | |
105 | EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting;\r | |
106 | EFI_HII_HANDLE RegisteredHandle;\r | |
107 | IP4CONFIG_FORM_ENTRY *Current;\r | |
108 | } IP4_FORM_CALLBACK_INFO;\r | |
109 | \r | |
110 | #define IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK(Callback) \\r | |
111 | CR ( \\r | |
112 | Callback, \\r | |
113 | IP4_FORM_CALLBACK_INFO, \\r | |
114 | ConfigAccess, \\r | |
115 | IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE \\r | |
116 | )\r | |
117 | \r | |
83cbd279 | 118 | struct _IP4_CONFIG_INSTANCE {\r |
119 | UINT32 Signature;\r | |
120 | EFI_HANDLE Controller;\r | |
121 | EFI_HANDLE Image;\r | |
122 | \r | |
123 | EFI_IP4_CONFIG_PROTOCOL Ip4ConfigProtocol;\r | |
63886849 | 124 | \r |
125 | IP4_FORM_CALLBACK_INFO Ip4FormCallbackInfo;\r | |
83cbd279 | 126 | \r |
127 | //\r | |
128 | // NicConfig's state, such as IP4_CONFIG_STATE_IDLE\r | |
129 | //\r | |
130 | INTN State;\r | |
131 | \r | |
132 | //\r | |
133 | // Mnp child to keep the connection with MNP.\r | |
134 | //\r | |
135 | EFI_MANAGED_NETWORK_PROTOCOL *Mnp;\r | |
136 | EFI_HANDLE MnpHandle;\r | |
137 | \r | |
138 | //\r | |
139 | // User's requests data\r | |
140 | //\r | |
141 | EFI_EVENT DoneEvent;\r | |
142 | EFI_EVENT ReconfigEvent;\r | |
143 | EFI_STATUS Result;\r | |
144 | \r | |
145 | //\r | |
146 | // Identity of this interface and some configuration info.\r | |
147 | //\r | |
148 | NIC_ADDR NicAddr;\r | |
149 | UINT16 NicName[IP4_NIC_NAME_LENGTH];\r | |
150 | UINT32 NicIndex;\r | |
151 | NIC_IP4_CONFIG_INFO *NicConfig;\r | |
152 | \r | |
153 | //\r | |
154 | // DHCP handles to access DHCP\r | |
155 | //\r | |
156 | EFI_DHCP4_PROTOCOL *Dhcp4;\r | |
157 | EFI_HANDLE Dhcp4Handle;\r | |
158 | EFI_EVENT Dhcp4Event;\r | |
159 | };\r | |
160 | \r | |
161 | #define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \\r | |
162 | CR (this, IP4_CONFIG_INSTANCE, Ip4ConfigProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)\r | |
163 | \r | |
63886849 | 164 | #define IP4_CONFIG_INSTANCE_FROM_IP4FORM_CALLBACK_INFO(this) \\r |
165 | CR (this, IP4_CONFIG_INSTANCE, Ip4FormCallbackInfo, IP4_CONFIG_INSTANCE_SIGNATURE)\r | |
166 | \r | |
167 | \r | |
168 | /**\r | |
169 | Set the IP configure parameters for this NIC. \r | |
170 | \r | |
171 | If Reconfig is TRUE, the IP driver will be informed to discard current \r | |
172 | auto configure parameter and restart the auto configuration process. \r | |
173 | If current there is a pending auto configuration, EFI_ALREADY_STARTED is\r | |
174 | returned. You can only change the configure setting when either\r | |
175 | the configure has finished or not started yet. If NicConfig, the\r | |
176 | NIC's configure parameter is removed from the variable.\r | |
177 | \r | |
178 | @param Instance The IP4 CONFIG instance.\r | |
179 | @param NicConfig The new NIC IP4 configure parameter\r | |
180 | @param Reconfig Inform the IP4 driver to restart the auto\r | |
181 | configuration\r | |
182 | \r | |
183 | @retval EFI_SUCCESS The configure parameter for this NIC was \r | |
184 | set successfully .\r | |
185 | @retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is\r | |
186 | invalid.\r | |
187 | @retval EFI_ALREADY_STARTED There is a pending auto configuration.\r | |
188 | @retval EFI_NOT_FOUND No auto configure parameter is found\r | |
189 | \r | |
190 | **/\r | |
191 | EFI_STATUS\r | |
192 | EFIAPI\r | |
193 | EfiNicIp4ConfigSetInfo (\r | |
194 | IN IP4_CONFIG_INSTANCE *Instance,\r | |
195 | IN NIC_IP4_CONFIG_INFO *NicConfig OPTIONAL,\r | |
196 | IN BOOLEAN Reconfig\r | |
197 | );\r | |
198 | \r | |
199 | /**\r | |
200 | Get the configure parameter for this NIC.\r | |
201 | \r | |
202 | @param Instance The IP4 CONFIG Instance.\r | |
203 | @param ConfigLen The length of the NicConfig buffer.\r | |
204 | @param NicConfig The buffer to receive the NIC's configure\r | |
205 | parameter.\r | |
206 | \r | |
207 | @retval EFI_SUCCESS The configure parameter for this NIC was \r | |
208 | obtained successfully .\r | |
209 | @retval EFI_INVALID_PARAMETER This or ConfigLen is NULL.\r | |
210 | @retval EFI_NOT_FOUND There is no configure parameter for the NIC in\r | |
211 | NVRam.\r | |
212 | @retval EFI_BUFFER_TOO_SMALL The ConfigLen is too small or the NicConfig is \r | |
213 | NULL.\r | |
214 | \r | |
215 | **/\r | |
216 | EFI_STATUS\r | |
217 | EFIAPI\r | |
218 | EfiNicIp4ConfigGetInfo (\r | |
219 | IN IP4_CONFIG_INSTANCE *Instance,\r | |
220 | IN OUT UINTN *ConfigLen,\r | |
221 | OUT NIC_IP4_CONFIG_INFO *NicConfig\r | |
222 | );\r | |
83cbd279 | 223 | \r |
7bce0c5a | 224 | /**\r |
225 | Release all the DHCP related resources.\r | |
226 | \r | |
227 | @param This The IP4 configure instance\r | |
228 | \r | |
229 | @return None\r | |
230 | \r | |
231 | **/\r | |
83cbd279 | 232 | VOID\r |
233 | Ip4ConfigCleanDhcp4 (\r | |
c8d8f1e3 | 234 | IN IP4_CONFIG_INSTANCE *This\r |
83cbd279 | 235 | );\r |
236 | \r | |
7bce0c5a | 237 | /**\r |
238 | Clean up all the configuration parameters.\r | |
239 | \r | |
240 | @param Instance The IP4 configure instance\r | |
241 | \r | |
242 | @return None\r | |
243 | \r | |
244 | **/\r | |
83cbd279 | 245 | VOID\r |
246 | Ip4ConfigCleanConfig (\r | |
247 | IN IP4_CONFIG_INSTANCE *Instance\r | |
248 | );\r | |
63886849 | 249 | \r |
c8d8f1e3 | 250 | //\r |
251 | // EFI Component Name Functions\r | |
252 | //\r | |
253 | \r | |
254 | /**\r | |
255 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
256 | \r | |
257 | This function retrieves the user readable name of a driver in the form of a\r | |
258 | Unicode string. If the driver specified by This has a user readable name in\r | |
259 | the language specified by Language, then a pointer to the driver name is\r | |
260 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
261 | by This does not support the language specified by Language,\r | |
262 | then EFI_UNSUPPORTED is returned.\r | |
263 | \r | |
264 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
265 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
266 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
267 | array indicating the language. This is the\r | |
268 | language of the driver name that the caller is\r | |
269 | requesting, and it must match one of the\r | |
270 | languages specified in SupportedLanguages. The\r | |
271 | number of languages supported by a driver is up\r | |
272 | to the driver writer. Language is specified\r | |
63886849 | 273 | in RFC 3066 or ISO 639-2 language code format.\r |
c8d8f1e3 | 274 | @param DriverName[out] A pointer to the Unicode string to return.\r |
275 | This Unicode string is the name of the\r | |
276 | driver specified by This in the language\r | |
277 | specified by Language.\r | |
278 | \r | |
279 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
280 | This and the language specified by Language was\r | |
281 | returned in DriverName.\r | |
282 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
283 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
284 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
285 | the language specified by Language.\r | |
286 | \r | |
287 | **/\r | |
288 | EFI_STATUS\r | |
289 | EFIAPI\r | |
290 | Ip4ConfigComponentNameGetDriverName (\r | |
291 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
292 | IN CHAR8 *Language,\r | |
293 | OUT CHAR16 **DriverName\r | |
294 | );\r | |
295 | \r | |
296 | /**\r | |
297 | Retrieves a Unicode string that is the user readable name of the controller\r | |
298 | that is being managed by a driver.\r | |
299 | \r | |
300 | This function retrieves the user readable name of the controller specified by\r | |
301 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
302 | driver specified by This has a user readable name in the language specified by\r | |
303 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
304 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
305 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
306 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
307 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
308 | \r | |
309 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
310 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
311 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
312 | specified by This is managing. This handle\r | |
313 | specifies the controller whose name is to be\r | |
314 | returned.\r | |
315 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
316 | the name of. This is an optional parameter that\r | |
317 | may be NULL. It will be NULL for device\r | |
318 | drivers. It will also be NULL for a bus drivers\r | |
319 | that wish to retrieve the name of the bus\r | |
320 | controller. It will not be NULL for a bus\r | |
321 | driver that wishes to retrieve the name of a\r | |
322 | child controller.\r | |
323 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
324 | array indicating the language. This is the\r | |
325 | language of the driver name that the caller is\r | |
326 | requesting, and it must match one of the\r | |
327 | languages specified in SupportedLanguages. The\r | |
328 | number of languages supported by a driver is up\r | |
329 | to the driver writer. Language is specified in\r | |
63886849 | 330 | RFC 3066 or ISO 639-2 language code format.\r |
c8d8f1e3 | 331 | @param ControllerName[out] A pointer to the Unicode string to return.\r |
332 | This Unicode string is the name of the\r | |
333 | controller specified by ControllerHandle and\r | |
334 | ChildHandle in the language specified by\r | |
335 | Language from the point of view of the driver\r | |
336 | specified by This.\r | |
63886849 | 337 | \r |
c8d8f1e3 | 338 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r |
339 | the language specified by Language for the\r | |
340 | driver specified by This was returned in\r | |
341 | DriverName.\r | |
342 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
343 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
344 | EFI_HANDLE.\r | |
345 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
346 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
347 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
348 | managing the controller specified by\r | |
349 | ControllerHandle and ChildHandle.\r | |
350 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
351 | the language specified by Language.\r | |
352 | \r | |
353 | **/\r | |
354 | EFI_STATUS\r | |
355 | EFIAPI\r | |
356 | Ip4ConfigComponentNameGetControllerName (\r | |
357 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
358 | IN EFI_HANDLE ControllerHandle,\r | |
359 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
360 | IN CHAR8 *Language,\r | |
361 | OUT CHAR16 **ControllerName\r | |
362 | );\r | |
63886849 | 363 | \r |
c8d8f1e3 | 364 | /**\r |
365 | Test to see if this driver supports ControllerHandle.\r | |
366 | \r | |
367 | @param This Protocol instance pointer.\r | |
368 | @param ControllerHandle Handle of device to test\r | |
369 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
370 | device to start.\r | |
371 | \r | |
372 | @retval EFI_SUCCES This driver supports this device\r | |
373 | @retval EFI_ALREADY_STARTED This driver is already running on this device\r | |
374 | @retval other This driver does not support this device\r | |
375 | \r | |
376 | **/\r | |
377 | EFI_STATUS\r | |
378 | EFIAPI\r | |
379 | Ip4ConfigDriverBindingSupported (\r | |
380 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
381 | IN EFI_HANDLE ControllerHandle,\r | |
382 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
383 | );\r | |
63886849 | 384 | \r |
c8d8f1e3 | 385 | /**\r |
386 | Start this driver on ControllerHandle.\r | |
387 | \r | |
388 | @param This Protocol instance pointer.\r | |
389 | @param ControllerHandle Handle of device to bind driver to\r | |
390 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
391 | device to start.\r | |
392 | \r | |
393 | @retval EFI_SUCCES This driver is added to ControllerHandle\r | |
394 | @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r | |
395 | @retval other This driver does not support this device\r | |
396 | \r | |
397 | **/\r | |
398 | EFI_STATUS\r | |
399 | EFIAPI\r | |
400 | Ip4ConfigDriverBindingStart (\r | |
401 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
402 | IN EFI_HANDLE ControllerHandle,\r | |
403 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
404 | );\r | |
63886849 | 405 | \r |
c8d8f1e3 | 406 | /**\r |
407 | Stop this driver on ControllerHandle.\r | |
408 | \r | |
409 | @param This Protocol instance pointer.\r | |
410 | @param ControllerHandle Handle of device to stop driver on\r | |
411 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
412 | children is zero stop the entire bus driver.\r | |
413 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
414 | \r | |
415 | @retval EFI_SUCCES This driver is removed ControllerHandle\r | |
416 | @retval other This driver was not removed from this device\r | |
417 | \r | |
418 | **/\r | |
419 | EFI_STATUS\r | |
420 | EFIAPI\r | |
421 | Ip4ConfigDriverBindingStop (\r | |
422 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
423 | IN EFI_HANDLE ControllerHandle,\r | |
424 | IN UINTN NumberOfChildren,\r | |
425 | IN EFI_HANDLE *ChildHandleBuffer\r | |
426 | );\r | |
63886849 | 427 | \r |
83cbd279 | 428 | #endif\r |