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)
107 Destroy the DNS instance and recycle the resources.
109 @param[in] Instance The pointer to the DNS instance.
114 IN DNS_INSTANCE
*Instance
118 Create the DNS instance and initialize it.
120 @param[in] Service The pointer to the DNS service.
121 @param[out] Instance The pointer to the DNS instance.
123 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
124 @retval EFI_SUCCESS The DNS instance is created.
129 IN DNS_SERVICE
*Service
,
130 OUT DNS_INSTANCE
**Instance
134 Callback function which provided by user to remove one node in NetDestroyLinkList process.
136 @param[in] Entry The entry to be removed.
137 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
139 @retval EFI_SUCCESS The entry has been removed successfully.
140 @retval Others Fail to remove the entry.
145 DnsDestroyChildEntryInHandleBuffer (
146 IN LIST_ENTRY
*Entry
,
151 Config a NULL UDP that is used to keep the connection between UDP and DNS.
153 Just leave the Udp child unconfigured. When UDP is unloaded,
154 DNS will be informed with DriverBinding Stop.
156 @param UdpIo The UDP_IO to configure
157 @param Context The opaque parameter to the callback
159 @retval EFI_SUCCESS It always return EFI_SUCCESS directly.
170 Release all the resource used the DNS service binding instance.
172 @param DnsSb The Dns service binding instance.
177 IN DNS_SERVICE
*DnsSb
181 Create then initialize a Dns service binding instance.
183 @param Controller The controller to install the DNS service
185 @param Image The driver binding image of the DNS driver
186 @param IpVersion IpVersion for this service
187 @param Service The variable to receive the created service
190 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to create the instance.
191 @retval EFI_DEVICE_ERROR Failed to create a NULL UDP port to keep
193 @retval EFI_SUCCESS The service instance is created for the
199 IN EFI_HANDLE Controller
,
202 OUT DNS_SERVICE
**Service
208 @param ImageHandle Handle that identifies the image to be unloaded.
210 @retval EFI_SUCCESS The image has been unloaded.
211 @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
217 IN EFI_HANDLE ImageHandle
221 This is the declaration of an EFI image entry point. This entry point is
222 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
223 both device drivers and bus drivers.
225 @param ImageHandle The firmware allocated handle for the UEFI image.
226 @param SystemTable A pointer to the EFI System Table.
228 @retval EFI_SUCCESS The operation completed successfully.
229 @retval Others An unexpected error occurred.
233 DnsDriverEntryPoint (
234 IN EFI_HANDLE ImageHandle
,
235 IN EFI_SYSTEM_TABLE
*SystemTable
239 Tests to see if this driver supports a given controller. If a child device is provided,
240 it further tests to see if this driver supports creating a handle for the specified child device.
242 This function checks to see if the driver specified by This supports the device specified by
243 ControllerHandle. Drivers will typically use the device path attached to
244 ControllerHandle and/or the services from the bus I/O abstraction attached to
245 ControllerHandle to determine if the driver supports ControllerHandle. This function
246 may be called many times during platform initialization. In order to reduce boot times, the tests
247 performed by this function must be very small, and take as little time as possible to execute. This
248 function must not change the state of any hardware devices, and this function must be aware that the
249 device specified by ControllerHandle may already be managed by the same driver or a
250 different driver. This function must match its calls to AllocatePages() with FreePages(),
251 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
252 Because ControllerHandle may have been previously started by the same driver, if a protocol is
253 already in the opened state, then it must not be closed with CloseProtocol(). This is required
254 to guarantee the state of ControllerHandle is not modified by this function.
256 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
257 @param[in] ControllerHandle The handle of the controller to test. This handle
258 must support a protocol interface that supplies
259 an I/O abstraction to the driver.
260 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
261 parameter is ignored by device drivers, and is optional for bus
262 drivers. For bus drivers, if this parameter is not NULL, then
263 the bus driver must determine if the bus controller specified
264 by ControllerHandle and the child controller specified
265 by RemainingDevicePath are both supported by this
268 @retval EFI_SUCCESS The device specified by ControllerHandle and
269 RemainingDevicePath is supported by the driver specified by This.
270 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
271 RemainingDevicePath is already being managed by the driver
273 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
274 RemainingDevicePath is already being managed by a different
275 driver or an application that requires exclusive access.
276 Currently not implemented.
277 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
278 RemainingDevicePath is not supported by the driver specified by This.
282 Dns4DriverBindingSupported (
283 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
284 IN EFI_HANDLE ControllerHandle
,
285 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
289 Starts a device controller or a bus controller.
291 The Start() function is designed to be invoked from the EFI boot service ConnectController().
292 As a result, much of the error checking on the parameters to Start() has been moved into this
293 common boot service. It is legal to call Start() from other locations,
294 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
295 1. ControllerHandle must be a valid EFI_HANDLE.
296 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
297 EFI_DEVICE_PATH_PROTOCOL.
298 3. Prior to calling Start(), the Supported() function for the driver specified by This must
299 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
301 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
302 @param[in] ControllerHandle The handle of the controller to start. This handle
303 must support a protocol interface that supplies
304 an I/O abstraction to the driver.
305 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
306 parameter is ignored by device drivers, and is optional for bus
307 drivers. For a bus driver, if this parameter is NULL, then handles
308 for all the children of Controller are created by this driver.
309 If this parameter is not NULL and the first Device Path Node is
310 not the End of Device Path Node, then only the handle for the
311 child device specified by the first Device Path Node of
312 RemainingDevicePath is created by this driver.
313 If the first Device Path Node of RemainingDevicePath is
314 the End of Device Path Node, no child handle is created by this
317 @retval EFI_SUCCESS The device was started.
318 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
319 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
320 @retval Others The driver failed to start the device.
325 Dns4DriverBindingStart (
326 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
327 IN EFI_HANDLE ControllerHandle
,
328 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
332 Stops a device controller or a bus controller.
334 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
335 As a result, much of the error checking on the parameters to Stop() has been moved
336 into this common boot service. It is legal to call Stop() from other locations,
337 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
338 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
339 same driver's Start() function.
340 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
341 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
342 Start() function, and the Start() function must have called OpenProtocol() on
343 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
345 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
346 @param[in] ControllerHandle A handle to the device being stopped. The handle must
347 support a bus specific I/O protocol for the driver
348 to use to stop the device.
349 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
350 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
351 if NumberOfChildren is 0.
353 @retval EFI_SUCCESS The device was stopped.
354 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
359 Dns4DriverBindingStop (
360 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
361 IN EFI_HANDLE ControllerHandle
,
362 IN UINTN NumberOfChildren
,
363 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
367 Tests to see if this driver supports a given controller. If a child device is provided,
368 it further tests to see if this driver supports creating a handle for the specified child device.
370 This function checks to see if the driver specified by This supports the device specified by
371 ControllerHandle. Drivers will typically use the device path attached to
372 ControllerHandle and/or the services from the bus I/O abstraction attached to
373 ControllerHandle to determine if the driver supports ControllerHandle. This function
374 may be called many times during platform initialization. In order to reduce boot times, the tests
375 performed by this function must be very small, and take as little time as possible to execute. This
376 function must not change the state of any hardware devices, and this function must be aware that the
377 device specified by ControllerHandle may already be managed by the same driver or a
378 different driver. This function must match its calls to AllocatePages() with FreePages(),
379 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
380 Because ControllerHandle may have been previously started by the same driver, if a protocol is
381 already in the opened state, then it must not be closed with CloseProtocol(). This is required
382 to guarantee the state of ControllerHandle is not modified by this function.
384 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
385 @param[in] ControllerHandle The handle of the controller to test. This handle
386 must support a protocol interface that supplies
387 an I/O abstraction to the driver.
388 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
389 parameter is ignored by device drivers, and is optional for bus
390 drivers. For bus drivers, if this parameter is not NULL, then
391 the bus driver must determine if the bus controller specified
392 by ControllerHandle and the child controller specified
393 by RemainingDevicePath are both supported by this
396 @retval EFI_SUCCESS The device specified by ControllerHandle and
397 RemainingDevicePath is supported by the driver specified by This.
398 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
399 RemainingDevicePath is already being managed by the driver
401 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
402 RemainingDevicePath is already being managed by a different
403 driver or an application that requires exclusive access.
404 Currently not implemented.
405 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
406 RemainingDevicePath is not supported by the driver specified by This.
410 Dns6DriverBindingSupported (
411 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
412 IN EFI_HANDLE ControllerHandle
,
413 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
417 Starts a device controller or a bus controller.
419 The Start() function is designed to be invoked from the EFI boot service ConnectController().
420 As a result, much of the error checking on the parameters to Start() has been moved into this
421 common boot service. It is legal to call Start() from other locations,
422 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
423 1. ControllerHandle must be a valid EFI_HANDLE.
424 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
425 EFI_DEVICE_PATH_PROTOCOL.
426 3. Prior to calling Start(), the Supported() function for the driver specified by This must
427 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
429 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
430 @param[in] ControllerHandle The handle of the controller to start. This handle
431 must support a protocol interface that supplies
432 an I/O abstraction to the driver.
433 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
434 parameter is ignored by device drivers, and is optional for bus
435 drivers. For a bus driver, if this parameter is NULL, then handles
436 for all the children of Controller are created by this driver.
437 If this parameter is not NULL and the first Device Path Node is
438 not the End of Device Path Node, then only the handle for the
439 child device specified by the first Device Path Node of
440 RemainingDevicePath is created by this driver.
441 If the first Device Path Node of RemainingDevicePath is
442 the End of Device Path Node, no child handle is created by this
445 @retval EFI_SUCCESS The device was started.
446 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
447 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
448 @retval Others The driver failed to start the device.
453 Dns6DriverBindingStart (
454 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
455 IN EFI_HANDLE ControllerHandle
,
456 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
460 Stops a device controller or a bus controller.
462 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
463 As a result, much of the error checking on the parameters to Stop() has been moved
464 into this common boot service. It is legal to call Stop() from other locations,
465 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
466 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
467 same driver's Start() function.
468 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
469 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
470 Start() function, and the Start() function must have called OpenProtocol() on
471 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
473 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
474 @param[in] ControllerHandle A handle to the device being stopped. The handle must
475 support a bus specific I/O protocol for the driver
476 to use to stop the device.
477 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
478 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
479 if NumberOfChildren is 0.
481 @retval EFI_SUCCESS The device was stopped.
482 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
487 Dns6DriverBindingStop (
488 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
489 IN EFI_HANDLE ControllerHandle
,
490 IN UINTN NumberOfChildren
,
491 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
495 Creates a child handle and installs a protocol.
497 The CreateChild() function installs a protocol on ChildHandle.
498 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
499 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
501 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
502 @param[in] ChildHandle Pointer to the handle of the child to create. If it is NULL,
503 then a new handle is created. If it is a pointer to an existing UEFI handle,
504 then the protocol is added to the existing UEFI handle.
506 @retval EFI_SUCCESS The protocol was added to ChildHandle.
507 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
508 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
510 @retval other The child handle was not created
515 Dns4ServiceBindingCreateChild (
516 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
517 IN EFI_HANDLE
*ChildHandle
521 Destroys a child handle with a protocol installed on it.
523 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
524 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
525 last protocol on ChildHandle, then ChildHandle is destroyed.
527 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
528 @param[in] ChildHandle Handle of the child to destroy
530 @retval EFI_SUCCESS The protocol was removed from ChildHandle.
531 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
532 @retval EFI_INVALID_PARAMETER Child handle is NULL.
533 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
534 because its services are being used.
535 @retval other The child handle was not destroyed
540 Dns4ServiceBindingDestroyChild (
541 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
542 IN EFI_HANDLE ChildHandle
546 Creates a child handle and installs a protocol.
548 The CreateChild() function installs a protocol on ChildHandle.
549 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
550 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
552 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
553 @param[in] ChildHandle Pointer to the handle of the child to create. If it is NULL,
554 then a new handle is created. If it is a pointer to an existing UEFI handle,
555 then the protocol is added to the existing UEFI handle.
557 @retval EFI_SUCCESS The protocol was added to ChildHandle.
558 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
559 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
561 @retval other The child handle was not created
566 Dns6ServiceBindingCreateChild (
567 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
568 IN EFI_HANDLE
*ChildHandle
572 Destroys a child handle with a protocol installed on it.
574 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
575 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
576 last protocol on ChildHandle, then ChildHandle is destroyed.
578 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
579 @param[in] ChildHandle Handle of the child to destroy
581 @retval EFI_SUCCESS The protocol was removed from ChildHandle.
582 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
583 @retval EFI_INVALID_PARAMETER Child handle is NULL.
584 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
585 because its services are being used.
586 @retval other The child handle was not destroyed
591 Dns6ServiceBindingDestroyChild (
592 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
593 IN EFI_HANDLE ChildHandle