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