]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
MdeModulePkg GraphicsConsole: Add text mode for PcdConOutColumn/Row
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4ConfigDxe / Ip4Config.h
CommitLineData
83cbd279 1/** @file\r
402fa70f 2 Header file for IP4Config driver.\r
83cbd279 3\r
e5eed7d3
HT
4Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
83cbd279 6are licensed and made available under the terms and conditions of the BSD License\r
402fa70f 7which accompanies this distribution. The full text of the license may be found at<BR>\r
83cbd279 8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT 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
d80ea739 26#include <Protocol/ServiceBinding.h>\r
b2570da8 27\r
63886849 28#include <Guid/MdeModuleHii.h>\r
74df5026 29#include <Guid/NicIp4ConfigNvData.h>\r
63886849 30\r
31#include <Library/DevicePathLib.h>\r
b2570da8 32#include <Library/DebugLib.h>\r
33#include <Library/UefiRuntimeServicesTableLib.h>\r
34#include <Library/UefiDriverEntryPoint.h>\r
35#include <Library/UefiBootServicesTableLib.h>\r
36#include <Library/UefiLib.h>\r
37#include <Library/NetLib.h>\r
38#include <Library/BaseMemoryLib.h>\r
83cbd279 39#include <Library/MemoryAllocationLib.h>\r
63886849 40#include <Library/HiiLib.h>\r
41#include <Library/PrintLib.h>\r
d8d26fb2 42#include <Library/DpcLib.h>\r
d80ea739 43#include <Library/UefiHiiServicesLib.h>\r
83cbd279 44\r
83cbd279 45\r
c8d8f1e3 46//\r
63886849 47// Global variables\r
c8d8f1e3 48//\r
f6b7393c 49extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding;\r
50extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName;\r
51extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2;\r
d80ea739 52\r
f6b7393c 53extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate;\r
c8d8f1e3 54\r
55#define IP4_PROTO_ICMP 0x01\r
56#define IP4_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')\r
57\r
f6b7393c 58#define IP4_CONFIG_STATE_IDLE 0\r
59#define IP4_CONFIG_STATE_STARTED 1\r
60#define IP4_CONFIG_STATE_CONFIGURED 2\r
61\r
62#define DHCP_TAG_PARA_LIST 55\r
63#define DHCP_TAG_NETMASK 1\r
64#define DHCP_TAG_ROUTER 3\r
65\r
83cbd279 66\r
67//\r
68// Configure the DHCP to request the routers and netmask\r
69// from server. The DHCP_TAG_NETMASK is included in Head.\r
70//\r
71#pragma pack(1)\r
72typedef struct {\r
73 EFI_DHCP4_PACKET_OPTION Head;\r
74 UINT8 Route;\r
75} IP4_CONFIG_DHCP4_OPTION;\r
76#pragma pack()\r
77\r
d80ea739 78typedef struct _IP4CONFIG_CALLBACK_INFO {\r
c22b6cdf 79 BOOLEAN Configured;\r
80 BOOLEAN DhcpEnabled;\r
d80ea739 81 EFI_IPv4_ADDRESS LocalIp;\r
82 EFI_IPv4_ADDRESS SubnetMask;\r
83 EFI_IPv4_ADDRESS Gateway;\r
84} IP4_SETTING_INFO;\r
63886849 85\r
72ed3d75 86typedef struct _IP4_CONFIG_INSTANCE {\r
d80ea739 87 UINT32 Signature;\r
88 EFI_HANDLE Controller;\r
89 EFI_HANDLE Image;\r
90 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
83cbd279 91\r
d80ea739 92 EFI_IP4_CONFIG_PROTOCOL Ip4ConfigProtocol;\r
63886849 93\r
d80ea739 94 EFI_HII_CONFIG_ACCESS_PROTOCOL HiiConfigAccessProtocol;\r
95 EFI_HANDLE ChildHandle;\r
96 EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;\r
97 EFI_HII_HANDLE RegisteredHandle;\r
98 IP4_SETTING_INFO Ip4ConfigCallbackInfo;\r
83cbd279 99\r
100 //\r
101 // NicConfig's state, such as IP4_CONFIG_STATE_IDLE\r
102 //\r
d80ea739 103 INTN State;\r
83cbd279 104\r
105 //\r
106 // Mnp child to keep the connection with MNP.\r
107 //\r
d80ea739 108 EFI_MANAGED_NETWORK_PROTOCOL *Mnp;\r
109 EFI_HANDLE MnpHandle;\r
83cbd279 110\r
111 //\r
112 // User's requests data\r
113 //\r
d80ea739 114 EFI_EVENT DoneEvent;\r
115 EFI_EVENT ReconfigEvent;\r
116 EFI_STATUS Result;\r
83cbd279 117\r
118 //\r
119 // Identity of this interface and some configuration info.\r
120 //\r
d80ea739 121 NIC_ADDR NicAddr;\r
74df5026 122 CHAR16 *MacString;\r
d80ea739 123 NIC_IP4_CONFIG_INFO *NicConfig;\r
83cbd279 124\r
125 //\r
126 // DHCP handles to access DHCP\r
127 //\r
d80ea739 128 EFI_DHCP4_PROTOCOL *Dhcp4;\r
129 EFI_HANDLE Dhcp4Handle;\r
130 EFI_EVENT Dhcp4Event;\r
72ed3d75 131} IP4_CONFIG_INSTANCE;\r
83cbd279 132\r
133#define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \\r
134 CR (this, IP4_CONFIG_INSTANCE, Ip4ConfigProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)\r
135\r
d80ea739 136#define IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS(this) \\r
137 CR (this, IP4_CONFIG_INSTANCE, HiiConfigAccessProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)\r
63886849 138\r
139\r
140/**\r
d80ea739 141 Set the IP configure parameters for this NIC.\r
63886849 142\r
d80ea739 143 If Reconfig is TRUE, the IP driver will be informed to discard current\r
144 auto configure parameter and restart the auto configuration process.\r
63886849 145 If current there is a pending auto configuration, EFI_ALREADY_STARTED is\r
146 returned. You can only change the configure setting when either\r
147 the configure has finished or not started yet. If NicConfig, the\r
148 NIC's configure parameter is removed from the variable.\r
149\r
150 @param Instance The IP4 CONFIG instance.\r
d80ea739 151 @param NicConfig The new NIC IP4 configure parameter.\r
63886849 152 @param Reconfig Inform the IP4 driver to restart the auto\r
d80ea739 153 configuration.\r
154\r
155 @retval EFI_SUCCESS The configure parameter for this NIC was\r
156 set successfully.\r
63886849 157 @retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is\r
158 invalid.\r
159 @retval EFI_ALREADY_STARTED There is a pending auto configuration.\r
d80ea739 160 @retval EFI_NOT_FOUND No auto configure parameter is found.\r
63886849 161\r
162**/\r
163EFI_STATUS\r
164EFIAPI\r
165EfiNicIp4ConfigSetInfo (\r
166 IN IP4_CONFIG_INSTANCE *Instance,\r
167 IN NIC_IP4_CONFIG_INFO *NicConfig OPTIONAL,\r
168 IN BOOLEAN Reconfig\r
169 );\r
170\r
171/**\r
74df5026 172 Get the NIC's configure information from the IP4 configure variable.\r
173 It will remove the invalid variable.\r
63886849 174\r
74df5026 175 @param Instance The IP4 CONFIG instance.\r
63886849 176\r
74df5026 177 @return NULL if no configure for the NIC in the variable, or it is invalid.\r
178 Otherwise the pointer to the NIC's IP configure parameter will be returned.\r
63886849 179\r
180**/\r
74df5026 181NIC_IP4_CONFIG_INFO *\r
63886849 182EfiNicIp4ConfigGetInfo (\r
74df5026 183 IN IP4_CONFIG_INSTANCE *Instance\r
63886849 184 );\r
83cbd279 185\r
7bce0c5a 186/**\r
187 Release all the DHCP related resources.\r
188\r
189 @param This The IP4 configure instance\r
190\r
191 @return None\r
192\r
193**/\r
83cbd279 194VOID\r
195Ip4ConfigCleanDhcp4 (\r
c8d8f1e3 196 IN IP4_CONFIG_INSTANCE *This\r
83cbd279 197 );\r
198\r
7bce0c5a 199/**\r
200 Clean up all the configuration parameters.\r
201\r
202 @param Instance The IP4 configure instance\r
203\r
204 @return None\r
205\r
206**/\r
83cbd279 207VOID\r
208Ip4ConfigCleanConfig (\r
209 IN IP4_CONFIG_INSTANCE *Instance\r
210 );\r
63886849 211\r
c8d8f1e3 212//\r
213// EFI Component Name Functions\r
214//\r
215\r
216/**\r
217 Retrieves a Unicode string that is the user readable name of the driver.\r
218\r
219 This function retrieves the user readable name of a driver in the form of a\r
220 Unicode string. If the driver specified by This has a user readable name in\r
221 the language specified by Language, then a pointer to the driver name is\r
222 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
223 by This does not support the language specified by Language,\r
224 then EFI_UNSUPPORTED is returned.\r
225\r
226 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
227 EFI_COMPONENT_NAME_PROTOCOL instance.\r
228 @param Language[in] A pointer to a Null-terminated ASCII string\r
229 array indicating the language. This is the\r
230 language of the driver name that the caller is\r
231 requesting, and it must match one of the\r
232 languages specified in SupportedLanguages. The\r
233 number of languages supported by a driver is up\r
234 to the driver writer. Language is specified\r
63886849 235 in RFC 3066 or ISO 639-2 language code format.\r
c8d8f1e3 236 @param DriverName[out] A pointer to the Unicode string to return.\r
237 This Unicode string is the name of the\r
238 driver specified by This in the language\r
239 specified by Language.\r
240\r
241 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
242 This and the language specified by Language was\r
243 returned in DriverName.\r
244 @retval EFI_INVALID_PARAMETER Language is NULL.\r
245 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
246 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
247 the language specified by Language.\r
248\r
249**/\r
250EFI_STATUS\r
251EFIAPI\r
252Ip4ConfigComponentNameGetDriverName (\r
253 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
254 IN CHAR8 *Language,\r
255 OUT CHAR16 **DriverName\r
256 );\r
257\r
258/**\r
259 Retrieves a Unicode string that is the user readable name of the controller\r
260 that is being managed by a driver.\r
261\r
262 This function retrieves the user readable name of the controller specified by\r
263 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
264 driver specified by This has a user readable name in the language specified by\r
265 Language, then a pointer to the controller name is returned in ControllerName,\r
266 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
267 managing the controller specified by ControllerHandle and ChildHandle,\r
268 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
269 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
270\r
271 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
272 EFI_COMPONENT_NAME_PROTOCOL instance.\r
273 @param ControllerHandle[in] The handle of a controller that the driver\r
274 specified by This is managing. This handle\r
275 specifies the controller whose name is to be\r
276 returned.\r
277 @param ChildHandle[in] The handle of the child controller to retrieve\r
278 the name of. This is an optional parameter that\r
279 may be NULL. It will be NULL for device\r
280 drivers. It will also be NULL for a bus drivers\r
281 that wish to retrieve the name of the bus\r
282 controller. It will not be NULL for a bus\r
283 driver that wishes to retrieve the name of a\r
284 child controller.\r
285 @param Language[in] A pointer to a Null-terminated ASCII string\r
286 array indicating the language. This is the\r
287 language of the driver name that the caller is\r
288 requesting, and it must match one of the\r
289 languages specified in SupportedLanguages. The\r
290 number of languages supported by a driver is up\r
291 to the driver writer. Language is specified in\r
63886849 292 RFC 3066 or ISO 639-2 language code format.\r
c8d8f1e3 293 @param ControllerName[out] A pointer to the Unicode string to return.\r
294 This Unicode string is the name of the\r
295 controller specified by ControllerHandle and\r
296 ChildHandle in the language specified by\r
297 Language from the point of view of the driver\r
298 specified by This.\r
63886849 299\r
c8d8f1e3 300 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
301 the language specified by Language for the\r
302 driver specified by This was returned in\r
303 DriverName.\r
304 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
305 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
306 EFI_HANDLE.\r
307 @retval EFI_INVALID_PARAMETER Language is NULL.\r
308 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
309 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
310 managing the controller specified by\r
311 ControllerHandle and ChildHandle.\r
312 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
313 the language specified by Language.\r
314\r
315**/\r
316EFI_STATUS\r
317EFIAPI\r
318Ip4ConfigComponentNameGetControllerName (\r
319 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
320 IN EFI_HANDLE ControllerHandle,\r
321 IN EFI_HANDLE ChildHandle OPTIONAL,\r
322 IN CHAR8 *Language,\r
323 OUT CHAR16 **ControllerName\r
324 );\r
63886849 325\r
c8d8f1e3 326/**\r
327 Test to see if this driver supports ControllerHandle.\r
328\r
329 @param This Protocol instance pointer.\r
330 @param ControllerHandle Handle of device to test\r
331 @param RemainingDevicePath Optional parameter use to pick a specific child\r
332 device to start.\r
333\r
334 @retval EFI_SUCCES This driver supports this device\r
335 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
336 @retval other This driver does not support this device\r
337\r
338**/\r
339EFI_STATUS\r
340EFIAPI\r
341Ip4ConfigDriverBindingSupported (\r
342 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
343 IN EFI_HANDLE ControllerHandle,\r
344 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
345 );\r
63886849 346\r
c8d8f1e3 347/**\r
348 Start this driver on ControllerHandle.\r
349\r
350 @param This Protocol instance pointer.\r
351 @param ControllerHandle Handle of device to bind driver to\r
352 @param RemainingDevicePath Optional parameter use to pick a specific child\r
353 device to start.\r
354\r
355 @retval EFI_SUCCES This driver is added to ControllerHandle\r
356 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
357 @retval other This driver does not support this device\r
358\r
359**/\r
360EFI_STATUS\r
361EFIAPI\r
362Ip4ConfigDriverBindingStart (\r
363 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
364 IN EFI_HANDLE ControllerHandle,\r
365 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
366 );\r
63886849 367\r
c8d8f1e3 368/**\r
369 Stop this driver on ControllerHandle.\r
370\r
371 @param This Protocol instance pointer.\r
372 @param ControllerHandle Handle of device to stop driver on\r
373 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
374 children is zero stop the entire bus driver.\r
375 @param ChildHandleBuffer List of Child Handles to Stop.\r
376\r
377 @retval EFI_SUCCES This driver is removed ControllerHandle\r
378 @retval other This driver was not removed from this device\r
379\r
380**/\r
381EFI_STATUS\r
382EFIAPI\r
383Ip4ConfigDriverBindingStop (\r
384 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
385 IN EFI_HANDLE ControllerHandle,\r
386 IN UINTN NumberOfChildren,\r
387 IN EFI_HANDLE *ChildHandleBuffer\r
388 );\r
63886849 389\r
72ed3d75 390/**\r
391 Starts running the configuration policy for the EFI IPv4 Protocol driver.\r
392\r
393 The Start() function is called to determine and to begin the platform\r
394 configuration policy by the EFI IPv4 Protocol driver. This determination may\r
395 be as simple as returning EFI_UNSUPPORTED if there is no EFI IPv4 Protocol\r
396 driver configuration policy. It may be as involved as loading some defaults\r
397 from nonvolatile storage, downloading dynamic data from a DHCP server, and\r
398 checking permissions with a site policy server.\r
399 Starting the configuration policy is just the beginning. It may finish almost\r
400 instantly or it may take several minutes before it fails to retrieve configuration\r
401 information from one or more servers. Once the policy is started, drivers\r
402 should use the DoneEvent parameter to determine when the configuration policy\r
403 has completed. EFI_IP4_CONFIG_PROTOCOL.GetData() must then be called to\r
404 determine if the configuration succeeded or failed.\r
405 Until the configuration completes successfully, EFI IPv4 Protocol driver instances\r
406 that are attempting to use default configurations must return EFI_NO_MAPPING.\r
407 Once the configuration is complete, the EFI IPv4 Configuration Protocol driver\r
408 signals DoneEvent. The configuration may need to be updated in the future,\r
409 however; in this case, the EFI IPv4 Configuration Protocol driver must signal\r
410 ReconfigEvent, and all EFI IPv4 Protocol driver instances that are using default\r
411 configurations must return EFI_NO_MAPPING until the configuration policy has\r
412 been rerun.\r
413\r
414 @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance.\r
415 @param DoneEvent Event that will be signaled when the EFI IPv4\r
416 Protocol driver configuration policy completes\r
417 execution. This event must be of type EVT_NOTIFY_SIGNAL.\r
418 @param ReconfigEvent Event that will be signaled when the EFI IPv4\r
419 Protocol driver configuration needs to be updated.\r
420 This event must be of type EVT_NOTIFY_SIGNAL.\r
421\r
422 @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol\r
423 driver is now running.\r
424 @retval EFI_INVALID_PARAMETER One or more of the following parameters is NULL:\r
425 This\r
426 DoneEvent\r
427 ReconfigEvent\r
428 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
429 @retval EFI_ALREADY_STARTED The configuration policy for the EFI IPv4 Protocol\r
430 driver was already started.\r
431 @retval EFI_DEVICE_ERROR An unexpected system error or network error occurred.\r
432 @retval EFI_UNSUPPORTED This interface does not support the EFI IPv4 Protocol\r
433 driver configuration.\r
434\r
435**/\r
436EFI_STATUS\r
437EFIAPI\r
438EfiIp4ConfigStart (\r
439 IN EFI_IP4_CONFIG_PROTOCOL *This,\r
440 IN EFI_EVENT DoneEvent,\r
441 IN EFI_EVENT ReconfigEvent\r
442 );\r
443\r
444/**\r
445 Stops running the configuration policy for the EFI IPv4 Protocol driver.\r
446\r
447 The Stop() function stops the configuration policy for the EFI IPv4 Protocol driver.\r
448 All configuration data will be lost after calling Stop().\r
449\r
450 @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance.\r
451\r
452 @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol\r
453 driver has been stopped.\r
454 @retval EFI_INVALID_PARAMETER This is NULL.\r
455 @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol\r
456 driver was not started.\r
457\r
458**/\r
459EFI_STATUS\r
460EFIAPI\r
461EfiIp4ConfigStop (\r
462 IN EFI_IP4_CONFIG_PROTOCOL *This\r
463 );\r
464\r
465/**\r
466 Returns the default configuration data (if any) for the EFI IPv4 Protocol driver.\r
467\r
468 The GetData() function returns the current configuration data for the EFI IPv4\r
469 Protocol driver after the configuration policy has completed.\r
470\r
471 @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance.\r
472 @param ConfigDataSize On input, the size of the ConfigData buffer.\r
473 On output, the count of bytes that were written\r
474 into the ConfigData buffer.\r
475 @param ConfigData Pointer to the EFI IPv4 Configuration Protocol\r
476 driver configuration data structure.\r
477 Type EFI_IP4_IPCONFIG_DATA is defined in\r
478 "Related Definitions" below.\r
479\r
480 @retval EFI_SUCCESS The EFI IPv4 Protocol driver configuration has been returned.\r
481 @retval EFI_INVALID_PARAMETER This is NULL.\r
482 @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol\r
483 driver is not running.\r
484 @retval EFI_NOT_READY EFI IPv4 Protocol driver configuration is still running.\r
485 @retval EFI_ABORTED EFI IPv4 Protocol driver configuration could not complete.\r
486 Currently not implemented.\r
487 @retval EFI_BUFFER_TOO_SMALL *ConfigDataSize is smaller than the configuration\r
488 data buffer or ConfigData is NULL.\r
489\r
490**/\r
491EFI_STATUS\r
492EFIAPI\r
493EfiIp4ConfigGetData (\r
494 IN EFI_IP4_CONFIG_PROTOCOL *This,\r
495 IN OUT UINTN *ConfigDataSize,\r
496 OUT EFI_IP4_IPCONFIG_DATA *ConfigData OPTIONAL\r
497 );\r
498\r
83cbd279 499#endif\r