2 The header files of the driver binding and service binding protocol for DnsDxe driver.
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #define _DNS_DRIVER_H_
12 #include <Protocol/DriverBinding.h>
13 #include <Protocol/ServiceBinding.h>
18 typedef struct _DNS_DRIVER_DATA DNS_DRIVER_DATA
;
23 typedef struct _DNS_SERVICE DNS_SERVICE
;
26 /// Dns instance block
28 typedef struct _DNS_INSTANCE DNS_INSTANCE
;
30 #define DNS_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'N', 'S', 'S')
32 #define DNS_INSTANCE_SIGNATURE SIGNATURE_32 ('D', 'N', 'S', 'I')
34 struct _DNS_DRIVER_DATA
{
35 EFI_EVENT Timer
; /// Ticking timer for DNS cache update.
37 LIST_ENTRY Dns4CacheList
;
38 LIST_ENTRY Dns4ServerList
;
40 LIST_ENTRY Dns6CacheList
;
41 LIST_ENTRY Dns6ServerList
;
46 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
48 UINT16 Dns4ChildrenNum
;
49 LIST_ENTRY Dns4ChildrenList
;
51 UINT16 Dns6ChildrenNum
;
52 LIST_ENTRY Dns6ChildrenList
;
54 EFI_HANDLE ControllerHandle
;
55 EFI_HANDLE ImageHandle
;
57 EFI_EVENT TimerToGetMap
;
59 EFI_EVENT Timer
; /// Ticking timer for packet retransmission.
65 struct _DNS_INSTANCE
{
69 EFI_DNS4_PROTOCOL Dns4
;
70 EFI_DNS6_PROTOCOL Dns6
;
76 EFI_HANDLE ChildHandle
;
78 EFI_DNS4_CONFIG_DATA Dns4CfgData
;
79 EFI_DNS6_CONFIG_DATA Dns6CfgData
;
81 EFI_IP_ADDRESS SessionDnsServer
;
90 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
91 UINTN NumberOfChildren
;
92 EFI_HANDLE
*ChildHandleBuffer
;
93 } DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
;
95 extern DNS_DRIVER_DATA
*mDriverData
;
97 #define DNS_SERVICE_FROM_THIS(a) \
98 CR (a, DNS_SERVICE, ServiceBinding, DNS_SERVICE_SIGNATURE)
100 #define DNS_INSTANCE_FROM_THIS_PROTOCOL4(a) \
101 CR (a, DNS_INSTANCE, Dns4, DNS_INSTANCE_SIGNATURE)
103 #define DNS_INSTANCE_FROM_THIS_PROTOCOL6(a) \
104 CR (a, DNS_INSTANCE, Dns6, DNS_INSTANCE_SIGNATURE)
108 Destroy the DNS instance and recycle the resources.
110 @param[in] Instance The pointer to the DNS instance.
115 IN DNS_INSTANCE
*Instance
119 Create the DNS instance and initialize it.
121 @param[in] Service The pointer to the DNS service.
122 @param[out] Instance The pointer to the DNS instance.
124 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
125 @retval EFI_SUCCESS The DNS instance is created.
130 IN DNS_SERVICE
*Service
,
131 OUT DNS_INSTANCE
**Instance
135 Callback function which provided by user to remove one node in NetDestroyLinkList process.
137 @param[in] Entry The entry to be removed.
138 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
140 @retval EFI_SUCCESS The entry has been removed successfully.
141 @retval Others Fail to remove the entry.
146 DnsDestroyChildEntryInHandleBuffer (
147 IN LIST_ENTRY
*Entry
,
152 Config a NULL UDP that is used to keep the connection between UDP and DNS.
154 Just leave the Udp child unconfigured. When UDP is unloaded,
155 DNS will be informed with DriverBinding Stop.
157 @param UdpIo The UDP_IO to configure
158 @param Context The opaque parameter to the callback
160 @retval EFI_SUCCESS It always return EFI_SUCCESS directly.
171 Release all the resource used the DNS service binding instance.
173 @param DnsSb The Dns service binding instance.
178 IN DNS_SERVICE
*DnsSb
182 Create then initialize a Dns service binding instance.
184 @param Controller The controller to install the DNS service
186 @param Image The driver binding image of the DNS driver
187 @param IpVersion IpVersion for this service
188 @param Service The variable to receive the created service
191 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to create the instance.
192 @retval EFI_DEVICE_ERROR Failed to create a NULL UDP port to keep
194 @retval EFI_SUCCESS The service instance is created for the
200 IN EFI_HANDLE Controller
,
203 OUT DNS_SERVICE
**Service
209 @param ImageHandle Handle that identifies the image to be unloaded.
211 @retval EFI_SUCCESS The image has been unloaded.
212 @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
218 IN EFI_HANDLE ImageHandle
222 This is the declaration of an EFI image entry point. This entry point is
223 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
224 both device drivers and bus drivers.
226 @param ImageHandle The firmware allocated handle for the UEFI image.
227 @param SystemTable A pointer to the EFI System Table.
229 @retval EFI_SUCCESS The operation completed successfully.
230 @retval Others An unexpected error occurred.
234 DnsDriverEntryPoint (
235 IN EFI_HANDLE ImageHandle
,
236 IN EFI_SYSTEM_TABLE
*SystemTable
240 Tests to see if this driver supports a given controller. If a child device is provided,
241 it further tests to see if this driver supports creating a handle for the specified child device.
243 This function checks to see if the driver specified by This supports the device specified by
244 ControllerHandle. Drivers will typically use the device path attached to
245 ControllerHandle and/or the services from the bus I/O abstraction attached to
246 ControllerHandle to determine if the driver supports ControllerHandle. This function
247 may be called many times during platform initialization. In order to reduce boot times, the tests
248 performed by this function must be very small, and take as little time as possible to execute. This
249 function must not change the state of any hardware devices, and this function must be aware that the
250 device specified by ControllerHandle may already be managed by the same driver or a
251 different driver. This function must match its calls to AllocatePages() with FreePages(),
252 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
253 Because ControllerHandle may have been previously started by the same driver, if a protocol is
254 already in the opened state, then it must not be closed with CloseProtocol(). This is required
255 to guarantee the state of ControllerHandle is not modified by this function.
257 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
258 @param[in] ControllerHandle The handle of the controller to test. This handle
259 must support a protocol interface that supplies
260 an I/O abstraction to the driver.
261 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
262 parameter is ignored by device drivers, and is optional for bus
263 drivers. For bus drivers, if this parameter is not NULL, then
264 the bus driver must determine if the bus controller specified
265 by ControllerHandle and the child controller specified
266 by RemainingDevicePath are both supported by this
269 @retval EFI_SUCCESS The device specified by ControllerHandle and
270 RemainingDevicePath is supported by the driver specified by This.
271 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
272 RemainingDevicePath is already being managed by the driver
274 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
275 RemainingDevicePath is already being managed by a different
276 driver or an application that requires exclusive access.
277 Currently not implemented.
278 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
279 RemainingDevicePath is not supported by the driver specified by This.
283 Dns4DriverBindingSupported (
284 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
285 IN EFI_HANDLE ControllerHandle
,
286 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
290 Starts a device controller or a bus controller.
292 The Start() function is designed to be invoked from the EFI boot service ConnectController().
293 As a result, much of the error checking on the parameters to Start() has been moved into this
294 common boot service. It is legal to call Start() from other locations,
295 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
296 1. ControllerHandle must be a valid EFI_HANDLE.
297 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
298 EFI_DEVICE_PATH_PROTOCOL.
299 3. Prior to calling Start(), the Supported() function for the driver specified by This must
300 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
302 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
303 @param[in] ControllerHandle The handle of the controller to start. This handle
304 must support a protocol interface that supplies
305 an I/O abstraction to the driver.
306 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
307 parameter is ignored by device drivers, and is optional for bus
308 drivers. For a bus driver, if this parameter is NULL, then handles
309 for all the children of Controller are created by this driver.
310 If this parameter is not NULL and the first Device Path Node is
311 not the End of Device Path Node, then only the handle for the
312 child device specified by the first Device Path Node of
313 RemainingDevicePath is created by this driver.
314 If the first Device Path Node of RemainingDevicePath is
315 the End of Device Path Node, no child handle is created by this
318 @retval EFI_SUCCESS The device was started.
319 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
320 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
321 @retval Others The driver failded to start the device.
326 Dns4DriverBindingStart (
327 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
328 IN EFI_HANDLE ControllerHandle
,
329 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
333 Stops a device controller or a bus controller.
335 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
336 As a result, much of the error checking on the parameters to Stop() has been moved
337 into this common boot service. It is legal to call Stop() from other locations,
338 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
339 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
340 same driver's Start() function.
341 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
342 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
343 Start() function, and the Start() function must have called OpenProtocol() on
344 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
346 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
347 @param[in] ControllerHandle A handle to the device being stopped. The handle must
348 support a bus specific I/O protocol for the driver
349 to use to stop the device.
350 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
351 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
352 if NumberOfChildren is 0.
354 @retval EFI_SUCCESS The device was stopped.
355 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
360 Dns4DriverBindingStop (
361 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
362 IN EFI_HANDLE ControllerHandle
,
363 IN UINTN NumberOfChildren
,
364 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
368 Tests to see if this driver supports a given controller. If a child device is provided,
369 it further tests to see if this driver supports creating a handle for the specified child device.
371 This function checks to see if the driver specified by This supports the device specified by
372 ControllerHandle. Drivers will typically use the device path attached to
373 ControllerHandle and/or the services from the bus I/O abstraction attached to
374 ControllerHandle to determine if the driver supports ControllerHandle. This function
375 may be called many times during platform initialization. In order to reduce boot times, the tests
376 performed by this function must be very small, and take as little time as possible to execute. This
377 function must not change the state of any hardware devices, and this function must be aware that the
378 device specified by ControllerHandle may already be managed by the same driver or a
379 different driver. This function must match its calls to AllocatePages() with FreePages(),
380 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
381 Because ControllerHandle may have been previously started by the same driver, if a protocol is
382 already in the opened state, then it must not be closed with CloseProtocol(). This is required
383 to guarantee the state of ControllerHandle is not modified by this function.
385 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
386 @param[in] ControllerHandle The handle of the controller to test. This handle
387 must support a protocol interface that supplies
388 an I/O abstraction to the driver.
389 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
390 parameter is ignored by device drivers, and is optional for bus
391 drivers. For bus drivers, if this parameter is not NULL, then
392 the bus driver must determine if the bus controller specified
393 by ControllerHandle and the child controller specified
394 by RemainingDevicePath are both supported by this
397 @retval EFI_SUCCESS The device specified by ControllerHandle and
398 RemainingDevicePath is supported by the driver specified by This.
399 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
400 RemainingDevicePath is already being managed by the driver
402 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
403 RemainingDevicePath is already being managed by a different
404 driver or an application that requires exclusive access.
405 Currently not implemented.
406 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
407 RemainingDevicePath is not supported by the driver specified by This.
411 Dns6DriverBindingSupported (
412 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
413 IN EFI_HANDLE ControllerHandle
,
414 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
418 Starts a device controller or a bus controller.
420 The Start() function is designed to be invoked from the EFI boot service ConnectController().
421 As a result, much of the error checking on the parameters to Start() has been moved into this
422 common boot service. It is legal to call Start() from other locations,
423 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
424 1. ControllerHandle must be a valid EFI_HANDLE.
425 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
426 EFI_DEVICE_PATH_PROTOCOL.
427 3. Prior to calling Start(), the Supported() function for the driver specified by This must
428 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
430 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
431 @param[in] ControllerHandle The handle of the controller to start. This handle
432 must support a protocol interface that supplies
433 an I/O abstraction to the driver.
434 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
435 parameter is ignored by device drivers, and is optional for bus
436 drivers. For a bus driver, if this parameter is NULL, then handles
437 for all the children of Controller are created by this driver.
438 If this parameter is not NULL and the first Device Path Node is
439 not the End of Device Path Node, then only the handle for the
440 child device specified by the first Device Path Node of
441 RemainingDevicePath is created by this driver.
442 If the first Device Path Node of RemainingDevicePath is
443 the End of Device Path Node, no child handle is created by this
446 @retval EFI_SUCCESS The device was started.
447 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
448 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
449 @retval Others The driver failded to start the device.
454 Dns6DriverBindingStart (
455 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
456 IN EFI_HANDLE ControllerHandle
,
457 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
461 Stops a device controller or a bus controller.
463 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
464 As a result, much of the error checking on the parameters to Stop() has been moved
465 into this common boot service. It is legal to call Stop() from other locations,
466 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
467 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
468 same driver's Start() function.
469 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
470 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
471 Start() function, and the Start() function must have called OpenProtocol() on
472 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
474 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
475 @param[in] ControllerHandle A handle to the device being stopped. The handle must
476 support a bus specific I/O protocol for the driver
477 to use to stop the device.
478 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
479 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
480 if NumberOfChildren is 0.
482 @retval EFI_SUCCESS The device was stopped.
483 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
488 Dns6DriverBindingStop (
489 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
490 IN EFI_HANDLE ControllerHandle
,
491 IN UINTN NumberOfChildren
,
492 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
496 Creates a child handle and installs a protocol.
498 The CreateChild() function installs a protocol on ChildHandle.
499 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
500 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
502 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
503 @param[in] ChildHandle Pointer to the handle of the child to create. If it is NULL,
504 then a new handle is created. If it is a pointer to an existing UEFI handle,
505 then the protocol is added to the existing UEFI handle.
507 @retval EFI_SUCCES The protocol was added to ChildHandle.
508 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
509 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
511 @retval other The child handle was not created
516 Dns4ServiceBindingCreateChild (
517 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
518 IN EFI_HANDLE
*ChildHandle
522 Destroys a child handle with a protocol installed on it.
524 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
525 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
526 last protocol on ChildHandle, then ChildHandle is destroyed.
528 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
529 @param[in] ChildHandle Handle of the child to destroy
531 @retval EFI_SUCCES The protocol was removed from ChildHandle.
532 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
533 @retval EFI_INVALID_PARAMETER Child handle is NULL.
534 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
535 because its services are being used.
536 @retval other The child handle was not destroyed
541 Dns4ServiceBindingDestroyChild (
542 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
543 IN EFI_HANDLE ChildHandle
547 Creates a child handle and installs a protocol.
549 The CreateChild() function installs a protocol on ChildHandle.
550 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
551 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
553 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
554 @param[in] ChildHandle Pointer to the handle of the child to create. If it is NULL,
555 then a new handle is created. If it is a pointer to an existing UEFI handle,
556 then the protocol is added to the existing UEFI handle.
558 @retval EFI_SUCCES The protocol was added to ChildHandle.
559 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
560 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
562 @retval other The child handle was not created
567 Dns6ServiceBindingCreateChild (
568 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
569 IN EFI_HANDLE
*ChildHandle
573 Destroys a child handle with a protocol installed on it.
575 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
576 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
577 last protocol on ChildHandle, then ChildHandle is destroyed.
579 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
580 @param[in] ChildHandle Handle of the child to destroy
582 @retval EFI_SUCCES The protocol was removed from ChildHandle.
583 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
584 @retval EFI_INVALID_PARAMETER Child handle is NULL.
585 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
586 because its services are being used.
587 @retval other The child handle was not destroyed
592 Dns6ServiceBindingDestroyChild (
593 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
594 IN EFI_HANDLE ChildHandle