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