2 The header files of the driver binding and service binding protocol for DnsDxe driver.
4 Copyright (c) 2015, 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
;
98 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
99 UINTN NumberOfChildren
;
100 EFI_HANDLE
*ChildHandleBuffer
;
101 } DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
;
103 extern DNS_DRIVER_DATA
*mDriverData
;
105 #define DNS_SERVICE_FROM_THIS(a) \
106 CR (a, DNS_SERVICE, ServiceBinding, DNS_SERVICE_SIGNATURE)
108 #define DNS_INSTANCE_FROM_THIS_PROTOCOL4(a) \
109 CR (a, DNS_INSTANCE, Dns4, DNS_INSTANCE_SIGNATURE)
111 #define DNS_INSTANCE_FROM_THIS_PROTOCOL6(a) \
112 CR (a, DNS_INSTANCE, Dns6, DNS_INSTANCE_SIGNATURE)
116 Destroy the DNS instance and recycle the resources.
118 @param[in] Instance The pointer to the DNS instance.
123 IN DNS_INSTANCE
*Instance
127 Create the DNS instance and initialize it.
129 @param[in] Service The pointer to the DNS service.
130 @param[out] Instance The pointer to the DNS instance.
132 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
133 @retval EFI_SUCCESS The DNS instance is created.
138 IN DNS_SERVICE
*Service
,
139 OUT DNS_INSTANCE
**Instance
143 Callback function which provided by user to remove one node in NetDestroyLinkList process.
145 @param[in] Entry The entry to be removed.
146 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
148 @retval EFI_SUCCESS The entry has been removed successfully.
149 @retval Others Fail to remove the entry.
154 DnsDestroyChildEntryInHandleBuffer (
155 IN LIST_ENTRY
*Entry
,
160 Config a NULL UDP that is used to keep the connection between UDP and DNS.
162 Just leave the Udp child unconfigured. When UDP is unloaded,
163 DNS will be informed with DriverBinding Stop.
165 @param UdpIo The UDP_IO to configure
166 @param Context The opaque parameter to the callback
168 @retval EFI_SUCCESS It always return EFI_SUCCESS directly.
179 Release all the resource used the DNS service binding instance.
181 @param DnsSb The Dns service binding instance.
186 IN DNS_SERVICE
*DnsSb
190 Create then initialize a Dns service binding instance.
192 @param Controller The controller to install the DNS service
194 @param Image The driver binding image of the DNS driver
195 @param IpVersion IpVersion for this service
196 @param Service The variable to receive the created service
199 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to create the instance.
200 @retval EFI_DEVICE_ERROR Failed to create a NULL UDP port to keep
202 @retval EFI_SUCCESS The service instance is created for the
208 IN EFI_HANDLE Controller
,
211 OUT DNS_SERVICE
**Service
217 @param ImageHandle Handle that identifies the image to be unloaded.
219 @retval EFI_SUCCESS The image has been unloaded.
220 @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
226 IN EFI_HANDLE ImageHandle
230 This is the declaration of an EFI image entry point. This entry point is
231 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
232 both device drivers and bus drivers.
234 @param ImageHandle The firmware allocated handle for the UEFI image.
235 @param SystemTable A pointer to the EFI System Table.
237 @retval EFI_SUCCESS The operation completed successfully.
238 @retval Others An unexpected error occurred.
242 DnsDriverEntryPoint (
243 IN EFI_HANDLE ImageHandle
,
244 IN EFI_SYSTEM_TABLE
*SystemTable
248 Tests to see if this driver supports a given controller. If a child device is provided,
249 it further tests to see if this driver supports creating a handle for the specified child device.
251 This function checks to see if the driver specified by This supports the device specified by
252 ControllerHandle. Drivers will typically use the device path attached to
253 ControllerHandle and/or the services from the bus I/O abstraction attached to
254 ControllerHandle to determine if the driver supports ControllerHandle. This function
255 may be called many times during platform initialization. In order to reduce boot times, the tests
256 performed by this function must be very small, and take as little time as possible to execute. This
257 function must not change the state of any hardware devices, and this function must be aware that the
258 device specified by ControllerHandle may already be managed by the same driver or a
259 different driver. This function must match its calls to AllocatePages() with FreePages(),
260 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
261 Because ControllerHandle may have been previously started by the same driver, if a protocol is
262 already in the opened state, then it must not be closed with CloseProtocol(). This is required
263 to guarantee the state of ControllerHandle is not modified by this function.
265 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
266 @param[in] ControllerHandle The handle of the controller to test. This handle
267 must support a protocol interface that supplies
268 an I/O abstraction to the driver.
269 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
270 parameter is ignored by device drivers, and is optional for bus
271 drivers. For bus drivers, if this parameter is not NULL, then
272 the bus driver must determine if the bus controller specified
273 by ControllerHandle and the child controller specified
274 by RemainingDevicePath are both supported by this
277 @retval EFI_SUCCESS The device specified by ControllerHandle and
278 RemainingDevicePath is supported by the driver specified by This.
279 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
280 RemainingDevicePath is already being managed by the driver
282 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
283 RemainingDevicePath is already being managed by a different
284 driver or an application that requires exclusive access.
285 Currently not implemented.
286 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
287 RemainingDevicePath is not supported by the driver specified by This.
291 Dns4DriverBindingSupported (
292 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
293 IN EFI_HANDLE ControllerHandle
,
294 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
298 Starts a device controller or a bus controller.
300 The Start() function is designed to be invoked from the EFI boot service ConnectController().
301 As a result, much of the error checking on the parameters to Start() has been moved into this
302 common boot service. It is legal to call Start() from other locations,
303 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
304 1. ControllerHandle must be a valid EFI_HANDLE.
305 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
306 EFI_DEVICE_PATH_PROTOCOL.
307 3. Prior to calling Start(), the Supported() function for the driver specified by This must
308 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
310 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
311 @param[in] ControllerHandle The handle of the controller to start. This handle
312 must support a protocol interface that supplies
313 an I/O abstraction to the driver.
314 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
315 parameter is ignored by device drivers, and is optional for bus
316 drivers. For a bus driver, if this parameter is NULL, then handles
317 for all the children of Controller are created by this driver.
318 If this parameter is not NULL and the first Device Path Node is
319 not the End of Device Path Node, then only the handle for the
320 child device specified by the first Device Path Node of
321 RemainingDevicePath is created by this driver.
322 If the first Device Path Node of RemainingDevicePath is
323 the End of Device Path Node, no child handle is created by this
326 @retval EFI_SUCCESS The device was started.
327 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
328 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
329 @retval Others The driver failded to start the device.
334 Dns4DriverBindingStart (
335 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
336 IN EFI_HANDLE ControllerHandle
,
337 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
341 Stops a device controller or a bus controller.
343 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
344 As a result, much of the error checking on the parameters to Stop() has been moved
345 into this common boot service. It is legal to call Stop() from other locations,
346 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
347 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
348 same driver's Start() function.
349 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
350 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
351 Start() function, and the Start() function must have called OpenProtocol() on
352 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
354 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
355 @param[in] ControllerHandle A handle to the device being stopped. The handle must
356 support a bus specific I/O protocol for the driver
357 to use to stop the device.
358 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
359 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
360 if NumberOfChildren is 0.
362 @retval EFI_SUCCESS The device was stopped.
363 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
368 Dns4DriverBindingStop (
369 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
370 IN EFI_HANDLE ControllerHandle
,
371 IN UINTN NumberOfChildren
,
372 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
376 Tests to see if this driver supports a given controller. If a child device is provided,
377 it further tests to see if this driver supports creating a handle for the specified child device.
379 This function checks to see if the driver specified by This supports the device specified by
380 ControllerHandle. Drivers will typically use the device path attached to
381 ControllerHandle and/or the services from the bus I/O abstraction attached to
382 ControllerHandle to determine if the driver supports ControllerHandle. This function
383 may be called many times during platform initialization. In order to reduce boot times, the tests
384 performed by this function must be very small, and take as little time as possible to execute. This
385 function must not change the state of any hardware devices, and this function must be aware that the
386 device specified by ControllerHandle may already be managed by the same driver or a
387 different driver. This function must match its calls to AllocatePages() with FreePages(),
388 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
389 Because ControllerHandle may have been previously started by the same driver, if a protocol is
390 already in the opened state, then it must not be closed with CloseProtocol(). This is required
391 to guarantee the state of ControllerHandle is not modified by this function.
393 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
394 @param[in] ControllerHandle The handle of the controller to test. This handle
395 must support a protocol interface that supplies
396 an I/O abstraction to the driver.
397 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
398 parameter is ignored by device drivers, and is optional for bus
399 drivers. For bus drivers, if this parameter is not NULL, then
400 the bus driver must determine if the bus controller specified
401 by ControllerHandle and the child controller specified
402 by RemainingDevicePath are both supported by this
405 @retval EFI_SUCCESS The device specified by ControllerHandle and
406 RemainingDevicePath is supported by the driver specified by This.
407 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
408 RemainingDevicePath is already being managed by the driver
410 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
411 RemainingDevicePath is already being managed by a different
412 driver or an application that requires exclusive access.
413 Currently not implemented.
414 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
415 RemainingDevicePath is not supported by the driver specified by This.
419 Dns6DriverBindingSupported (
420 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
421 IN EFI_HANDLE ControllerHandle
,
422 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
426 Starts a device controller or a bus controller.
428 The Start() function is designed to be invoked from the EFI boot service ConnectController().
429 As a result, much of the error checking on the parameters to Start() has been moved into this
430 common boot service. It is legal to call Start() from other locations,
431 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
432 1. ControllerHandle must be a valid EFI_HANDLE.
433 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
434 EFI_DEVICE_PATH_PROTOCOL.
435 3. Prior to calling Start(), the Supported() function for the driver specified by This must
436 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
438 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
439 @param[in] ControllerHandle The handle of the controller to start. This handle
440 must support a protocol interface that supplies
441 an I/O abstraction to the driver.
442 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
443 parameter is ignored by device drivers, and is optional for bus
444 drivers. For a bus driver, if this parameter is NULL, then handles
445 for all the children of Controller are created by this driver.
446 If this parameter is not NULL and the first Device Path Node is
447 not the End of Device Path Node, then only the handle for the
448 child device specified by the first Device Path Node of
449 RemainingDevicePath is created by this driver.
450 If the first Device Path Node of RemainingDevicePath is
451 the End of Device Path Node, no child handle is created by this
454 @retval EFI_SUCCESS The device was started.
455 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
456 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
457 @retval Others The driver failded to start the device.
462 Dns6DriverBindingStart (
463 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
464 IN EFI_HANDLE ControllerHandle
,
465 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
469 Stops a device controller or a bus controller.
471 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
472 As a result, much of the error checking on the parameters to Stop() has been moved
473 into this common boot service. It is legal to call Stop() from other locations,
474 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
475 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
476 same driver's Start() function.
477 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
478 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
479 Start() function, and the Start() function must have called OpenProtocol() on
480 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
482 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
483 @param[in] ControllerHandle A handle to the device being stopped. The handle must
484 support a bus specific I/O protocol for the driver
485 to use to stop the device.
486 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
487 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
488 if NumberOfChildren is 0.
490 @retval EFI_SUCCESS The device was stopped.
491 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
496 Dns6DriverBindingStop (
497 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
498 IN EFI_HANDLE ControllerHandle
,
499 IN UINTN NumberOfChildren
,
500 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
504 Creates a child handle and installs a protocol.
506 The CreateChild() function installs a protocol on ChildHandle.
507 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
508 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
510 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
511 @param[in] ChildHandle Pointer to the handle of the child to create. If it is NULL,
512 then a new handle is created. If it is a pointer to an existing UEFI handle,
513 then the protocol is added to the existing UEFI handle.
515 @retval EFI_SUCCES The protocol was added to ChildHandle.
516 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
517 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
519 @retval other The child handle was not created
524 Dns4ServiceBindingCreateChild (
525 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
526 IN EFI_HANDLE
*ChildHandle
530 Destroys a child handle with a protocol installed on it.
532 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
533 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
534 last protocol on ChildHandle, then ChildHandle is destroyed.
536 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
537 @param[in] ChildHandle Handle of the child to destroy
539 @retval EFI_SUCCES The protocol was removed from ChildHandle.
540 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
541 @retval EFI_INVALID_PARAMETER Child handle is NULL.
542 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
543 because its services are being used.
544 @retval other The child handle was not destroyed
549 Dns4ServiceBindingDestroyChild (
550 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
551 IN EFI_HANDLE ChildHandle
555 Creates a child handle and installs a protocol.
557 The CreateChild() function installs a protocol on ChildHandle.
558 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
559 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
561 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
562 @param[in] ChildHandle Pointer to the handle of the child to create. If it is NULL,
563 then a new handle is created. If it is a pointer to an existing UEFI handle,
564 then the protocol is added to the existing UEFI handle.
566 @retval EFI_SUCCES The protocol was added to ChildHandle.
567 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
568 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
570 @retval other The child handle was not created
575 Dns6ServiceBindingCreateChild (
576 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
577 IN EFI_HANDLE
*ChildHandle
581 Destroys a child handle with a protocol installed on it.
583 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
584 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
585 last protocol on ChildHandle, then ChildHandle is destroyed.
587 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
588 @param[in] ChildHandle Handle of the child to destroy
590 @retval EFI_SUCCES The protocol was removed from ChildHandle.
591 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
592 @retval EFI_INVALID_PARAMETER Child handle is NULL.
593 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
594 because its services are being used.
595 @retval other The child handle was not destroyed
600 Dns6ServiceBindingDestroyChild (
601 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
602 IN EFI_HANDLE ChildHandle