2 The header files of the driver binding and service binding protocol for DnsDxe driver.
4 Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
5 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
8 http://opensource.org/licenses/bsd-license.php
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.
15 #ifndef _DNS_DRIVER_H_
16 #define _DNS_DRIVER_H_
18 #include <Protocol/DriverBinding.h>
19 #include <Protocol/ServiceBinding.h>
24 typedef struct _DNS_DRIVER_DATA DNS_DRIVER_DATA
;
29 typedef struct _DNS_SERVICE DNS_SERVICE
;
32 /// Dns instance block
34 typedef struct _DNS_INSTANCE DNS_INSTANCE
;
36 #define DNS_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'N', 'S', 'S')
38 #define DNS_INSTANCE_SIGNATURE SIGNATURE_32 ('D', 'N', 'S', 'I')
40 struct _DNS_DRIVER_DATA
{
41 EFI_EVENT Timer
; /// Ticking timer for DNS cache update.
43 LIST_ENTRY Dns4CacheList
;
44 LIST_ENTRY Dns4ServerList
;
46 LIST_ENTRY Dns6CacheList
;
47 LIST_ENTRY Dns6ServerList
;
52 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
54 UINT16 Dns4ChildrenNum
;
55 LIST_ENTRY Dns4ChildrenList
;
57 UINT16 Dns6ChildrenNum
;
58 LIST_ENTRY Dns6ChildrenList
;
60 EFI_HANDLE ControllerHandle
;
61 EFI_HANDLE ImageHandle
;
63 EFI_EVENT TimerToGetMap
;
65 EFI_EVENT Timer
; /// Ticking timer for packet retransmission.
71 struct _DNS_INSTANCE
{
75 EFI_DNS4_PROTOCOL Dns4
;
76 EFI_DNS6_PROTOCOL Dns6
;
82 EFI_HANDLE ChildHandle
;
84 EFI_DNS4_CONFIG_DATA Dns4CfgData
;
85 EFI_DNS6_CONFIG_DATA Dns6CfgData
;
87 EFI_IP_ADDRESS SessionDnsServer
;
96 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
97 UINTN NumberOfChildren
;
98 EFI_HANDLE
*ChildHandleBuffer
;
99 } DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
;
101 extern DNS_DRIVER_DATA
*mDriverData
;
103 #define DNS_SERVICE_FROM_THIS(a) \
104 CR (a, DNS_SERVICE, ServiceBinding, DNS_SERVICE_SIGNATURE)
106 #define DNS_INSTANCE_FROM_THIS_PROTOCOL4(a) \
107 CR (a, DNS_INSTANCE, Dns4, DNS_INSTANCE_SIGNATURE)
109 #define DNS_INSTANCE_FROM_THIS_PROTOCOL6(a) \
110 CR (a, DNS_INSTANCE, Dns6, DNS_INSTANCE_SIGNATURE)
114 Destroy the DNS instance and recycle the resources.
116 @param[in] Instance The pointer to the DNS instance.
121 IN DNS_INSTANCE
*Instance
125 Create the DNS instance and initialize it.
127 @param[in] Service The pointer to the DNS service.
128 @param[out] Instance The pointer to the DNS instance.
130 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
131 @retval EFI_SUCCESS The DNS instance is created.
136 IN DNS_SERVICE
*Service
,
137 OUT DNS_INSTANCE
**Instance
141 Callback function which provided by user to remove one node in NetDestroyLinkList process.
143 @param[in] Entry The entry to be removed.
144 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
146 @retval EFI_SUCCESS The entry has been removed successfully.
147 @retval Others Fail to remove the entry.
152 DnsDestroyChildEntryInHandleBuffer (
153 IN LIST_ENTRY
*Entry
,
158 Config a NULL UDP that is used to keep the connection between UDP and DNS.
160 Just leave the Udp child unconfigured. When UDP is unloaded,
161 DNS will be informed with DriverBinding Stop.
163 @param UdpIo The UDP_IO to configure
164 @param Context The opaque parameter to the callback
166 @retval EFI_SUCCESS It always return EFI_SUCCESS directly.
177 Release all the resource used the DNS service binding instance.
179 @param DnsSb The Dns service binding instance.
184 IN DNS_SERVICE
*DnsSb
188 Create then initialize a Dns service binding instance.
190 @param Controller The controller to install the DNS service
192 @param Image The driver binding image of the DNS driver
193 @param IpVersion IpVersion for this service
194 @param Service The variable to receive the created service
197 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to create the instance.
198 @retval EFI_DEVICE_ERROR Failed to create a NULL UDP port to keep
200 @retval EFI_SUCCESS The service instance is created for the
206 IN EFI_HANDLE Controller
,
209 OUT DNS_SERVICE
**Service
215 @param ImageHandle Handle that identifies the image to be unloaded.
217 @retval EFI_SUCCESS The image has been unloaded.
218 @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
224 IN EFI_HANDLE ImageHandle
228 This is the declaration of an EFI image entry point. This entry point is
229 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
230 both device drivers and bus drivers.
232 @param ImageHandle The firmware allocated handle for the UEFI image.
233 @param SystemTable A pointer to the EFI System Table.
235 @retval EFI_SUCCESS The operation completed successfully.
236 @retval Others An unexpected error occurred.
240 DnsDriverEntryPoint (
241 IN EFI_HANDLE ImageHandle
,
242 IN EFI_SYSTEM_TABLE
*SystemTable
246 Tests to see if this driver supports a given controller. If a child device is provided,
247 it further tests to see if this driver supports creating a handle for the specified child device.
249 This function checks to see if the driver specified by This supports the device specified by
250 ControllerHandle. Drivers will typically use the device path attached to
251 ControllerHandle and/or the services from the bus I/O abstraction attached to
252 ControllerHandle to determine if the driver supports ControllerHandle. This function
253 may be called many times during platform initialization. In order to reduce boot times, the tests
254 performed by this function must be very small, and take as little time as possible to execute. This
255 function must not change the state of any hardware devices, and this function must be aware that the
256 device specified by ControllerHandle may already be managed by the same driver or a
257 different driver. This function must match its calls to AllocatePages() with FreePages(),
258 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
259 Because ControllerHandle may have been previously started by the same driver, if a protocol is
260 already in the opened state, then it must not be closed with CloseProtocol(). This is required
261 to guarantee the state of ControllerHandle is not modified by this function.
263 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
264 @param[in] ControllerHandle The handle of the controller to test. This handle
265 must support a protocol interface that supplies
266 an I/O abstraction to the driver.
267 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
268 parameter is ignored by device drivers, and is optional for bus
269 drivers. For bus drivers, if this parameter is not NULL, then
270 the bus driver must determine if the bus controller specified
271 by ControllerHandle and the child controller specified
272 by RemainingDevicePath are both supported by this
275 @retval EFI_SUCCESS The device specified by ControllerHandle and
276 RemainingDevicePath is supported by the driver specified by This.
277 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
278 RemainingDevicePath is already being managed by the driver
280 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
281 RemainingDevicePath is already being managed by a different
282 driver or an application that requires exclusive access.
283 Currently not implemented.
284 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
285 RemainingDevicePath is not supported by the driver specified by This.
289 Dns4DriverBindingSupported (
290 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
291 IN EFI_HANDLE ControllerHandle
,
292 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
296 Starts a device controller or a bus controller.
298 The Start() function is designed to be invoked from the EFI boot service ConnectController().
299 As a result, much of the error checking on the parameters to Start() has been moved into this
300 common boot service. It is legal to call Start() from other locations,
301 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
302 1. ControllerHandle must be a valid EFI_HANDLE.
303 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
304 EFI_DEVICE_PATH_PROTOCOL.
305 3. Prior to calling Start(), the Supported() function for the driver specified by This must
306 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
308 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
309 @param[in] ControllerHandle The handle of the controller to start. This handle
310 must support a protocol interface that supplies
311 an I/O abstraction to the driver.
312 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
313 parameter is ignored by device drivers, and is optional for bus
314 drivers. For a bus driver, if this parameter is NULL, then handles
315 for all the children of Controller are created by this driver.
316 If this parameter is not NULL and the first Device Path Node is
317 not the End of Device Path Node, then only the handle for the
318 child device specified by the first Device Path Node of
319 RemainingDevicePath is created by this driver.
320 If the first Device Path Node of RemainingDevicePath is
321 the End of Device Path Node, no child handle is created by this
324 @retval EFI_SUCCESS The device was started.
325 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
326 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
327 @retval Others The driver failded to start the device.
332 Dns4DriverBindingStart (
333 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
334 IN EFI_HANDLE ControllerHandle
,
335 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
339 Stops a device controller or a bus controller.
341 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
342 As a result, much of the error checking on the parameters to Stop() has been moved
343 into this common boot service. It is legal to call Stop() from other locations,
344 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
345 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
346 same driver's Start() function.
347 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
348 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
349 Start() function, and the Start() function must have called OpenProtocol() on
350 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
352 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
353 @param[in] ControllerHandle A handle to the device being stopped. The handle must
354 support a bus specific I/O protocol for the driver
355 to use to stop the device.
356 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
357 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
358 if NumberOfChildren is 0.
360 @retval EFI_SUCCESS The device was stopped.
361 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
366 Dns4DriverBindingStop (
367 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
368 IN EFI_HANDLE ControllerHandle
,
369 IN UINTN NumberOfChildren
,
370 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
374 Tests to see if this driver supports a given controller. If a child device is provided,
375 it further tests to see if this driver supports creating a handle for the specified child device.
377 This function checks to see if the driver specified by This supports the device specified by
378 ControllerHandle. Drivers will typically use the device path attached to
379 ControllerHandle and/or the services from the bus I/O abstraction attached to
380 ControllerHandle to determine if the driver supports ControllerHandle. This function
381 may be called many times during platform initialization. In order to reduce boot times, the tests
382 performed by this function must be very small, and take as little time as possible to execute. This
383 function must not change the state of any hardware devices, and this function must be aware that the
384 device specified by ControllerHandle may already be managed by the same driver or a
385 different driver. This function must match its calls to AllocatePages() with FreePages(),
386 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
387 Because ControllerHandle may have been previously started by the same driver, if a protocol is
388 already in the opened state, then it must not be closed with CloseProtocol(). This is required
389 to guarantee the state of ControllerHandle is not modified by this function.
391 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
392 @param[in] ControllerHandle The handle of the controller to test. This handle
393 must support a protocol interface that supplies
394 an I/O abstraction to the driver.
395 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
396 parameter is ignored by device drivers, and is optional for bus
397 drivers. For bus drivers, if this parameter is not NULL, then
398 the bus driver must determine if the bus controller specified
399 by ControllerHandle and the child controller specified
400 by RemainingDevicePath are both supported by this
403 @retval EFI_SUCCESS The device specified by ControllerHandle and
404 RemainingDevicePath is supported by the driver specified by This.
405 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
406 RemainingDevicePath is already being managed by the driver
408 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
409 RemainingDevicePath is already being managed by a different
410 driver or an application that requires exclusive access.
411 Currently not implemented.
412 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
413 RemainingDevicePath is not supported by the driver specified by This.
417 Dns6DriverBindingSupported (
418 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
419 IN EFI_HANDLE ControllerHandle
,
420 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
424 Starts a device controller or a bus controller.
426 The Start() function is designed to be invoked from the EFI boot service ConnectController().
427 As a result, much of the error checking on the parameters to Start() has been moved into this
428 common boot service. It is legal to call Start() from other locations,
429 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
430 1. ControllerHandle must be a valid EFI_HANDLE.
431 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
432 EFI_DEVICE_PATH_PROTOCOL.
433 3. Prior to calling Start(), the Supported() function for the driver specified by This must
434 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
436 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
437 @param[in] ControllerHandle The handle of the controller to start. This handle
438 must support a protocol interface that supplies
439 an I/O abstraction to the driver.
440 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
441 parameter is ignored by device drivers, and is optional for bus
442 drivers. For a bus driver, if this parameter is NULL, then handles
443 for all the children of Controller are created by this driver.
444 If this parameter is not NULL and the first Device Path Node is
445 not the End of Device Path Node, then only the handle for the
446 child device specified by the first Device Path Node of
447 RemainingDevicePath is created by this driver.
448 If the first Device Path Node of RemainingDevicePath is
449 the End of Device Path Node, no child handle is created by this
452 @retval EFI_SUCCESS The device was started.
453 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
454 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
455 @retval Others The driver failded to start the device.
460 Dns6DriverBindingStart (
461 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
462 IN EFI_HANDLE ControllerHandle
,
463 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
467 Stops a device controller or a bus controller.
469 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
470 As a result, much of the error checking on the parameters to Stop() has been moved
471 into this common boot service. It is legal to call Stop() from other locations,
472 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
473 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
474 same driver's Start() function.
475 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
476 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
477 Start() function, and the Start() function must have called OpenProtocol() on
478 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
480 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
481 @param[in] ControllerHandle A handle to the device being stopped. The handle must
482 support a bus specific I/O protocol for the driver
483 to use to stop the device.
484 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
485 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
486 if NumberOfChildren is 0.
488 @retval EFI_SUCCESS The device was stopped.
489 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
494 Dns6DriverBindingStop (
495 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
496 IN EFI_HANDLE ControllerHandle
,
497 IN UINTN NumberOfChildren
,
498 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
502 Creates a child handle and installs a protocol.
504 The CreateChild() function installs a protocol on ChildHandle.
505 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
506 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
508 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
509 @param[in] ChildHandle Pointer to the handle of the child to create. If it is NULL,
510 then a new handle is created. If it is a pointer to an existing UEFI handle,
511 then the protocol is added to the existing UEFI handle.
513 @retval EFI_SUCCES The protocol was added to ChildHandle.
514 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
515 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
517 @retval other The child handle was not created
522 Dns4ServiceBindingCreateChild (
523 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
524 IN EFI_HANDLE
*ChildHandle
528 Destroys a child handle with a protocol installed on it.
530 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
531 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
532 last protocol on ChildHandle, then ChildHandle is destroyed.
534 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
535 @param[in] ChildHandle Handle of the child to destroy
537 @retval EFI_SUCCES The protocol was removed from ChildHandle.
538 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
539 @retval EFI_INVALID_PARAMETER Child handle is NULL.
540 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
541 because its services are being used.
542 @retval other The child handle was not destroyed
547 Dns4ServiceBindingDestroyChild (
548 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
549 IN EFI_HANDLE ChildHandle
553 Creates a child handle and installs a protocol.
555 The CreateChild() function installs a protocol on ChildHandle.
556 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
557 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
559 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
560 @param[in] ChildHandle Pointer to the handle of the child to create. If it is NULL,
561 then a new handle is created. If it is a pointer to an existing UEFI handle,
562 then the protocol is added to the existing UEFI handle.
564 @retval EFI_SUCCES The protocol was added to ChildHandle.
565 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
566 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
568 @retval other The child handle was not created
573 Dns6ServiceBindingCreateChild (
574 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
575 IN EFI_HANDLE
*ChildHandle
579 Destroys a child handle with a protocol installed on it.
581 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
582 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
583 last protocol on ChildHandle, then ChildHandle is destroyed.
585 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
586 @param[in] ChildHandle Handle of the child to destroy
588 @retval EFI_SUCCES The protocol was removed from ChildHandle.
589 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
590 @retval EFI_INVALID_PARAMETER Child handle is NULL.
591 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
592 because its services are being used.
593 @retval other The child handle was not destroyed
598 Dns6ServiceBindingDestroyChild (
599 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
600 IN EFI_HANDLE ChildHandle