2 The driver binding and service binding protocol for HttpDxe driver.
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "HttpDriver.h"
13 EFI_HTTP_UTILITIES_PROTOCOL
*mHttpUtilities
= NULL
;
16 /// Driver Binding Protocol instance
18 EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp4DriverBinding
= {
19 HttpDxeIp4DriverBindingSupported
,
20 HttpDxeIp4DriverBindingStart
,
21 HttpDxeIp4DriverBindingStop
,
27 EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp6DriverBinding
= {
28 HttpDxeIp6DriverBindingSupported
,
29 HttpDxeIp6DriverBindingStart
,
30 HttpDxeIp6DriverBindingStop
,
38 Create a HTTP driver service binding private instance.
40 @param[in] Controller The controller that has TCP4 service binding
42 @param[out] ServiceData Point to HTTP driver private instance.
44 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
45 @retval EFI_SUCCESS A new HTTP driver private instance is created.
50 IN EFI_HANDLE Controller
,
51 OUT HTTP_SERVICE
**ServiceData
54 HTTP_SERVICE
*HttpService
;
56 ASSERT (ServiceData
!= NULL
);
59 HttpService
= AllocateZeroPool (sizeof (HTTP_SERVICE
));
60 if (HttpService
== NULL
) {
61 return EFI_OUT_OF_RESOURCES
;
64 HttpService
->Signature
= HTTP_SERVICE_SIGNATURE
;
65 HttpService
->ServiceBinding
.CreateChild
= HttpServiceBindingCreateChild
;
66 HttpService
->ServiceBinding
.DestroyChild
= HttpServiceBindingDestroyChild
;
67 HttpService
->ControllerHandle
= Controller
;
68 HttpService
->ChildrenNumber
= 0;
69 InitializeListHead (&HttpService
->ChildrenList
);
71 *ServiceData
= HttpService
;
76 Release all the resource used the HTTP service binding instance.
78 @param[in] HttpService The HTTP private instance.
79 @param[in] UsingIpv6 Indicate use TCP4 protocol or TCP6 protocol.
80 if TRUE, use Tcp6 protocol.
81 if FALSE, use Tcp4 protocl.
85 IN HTTP_SERVICE
*HttpService
,
90 if (HttpService
== NULL
) {
94 if (HttpService
->Tcp4ChildHandle
!= NULL
) {
96 HttpService
->Tcp4ChildHandle
,
97 &gEfiTcp4ProtocolGuid
,
98 HttpService
->Ip4DriverBindingHandle
,
99 HttpService
->ControllerHandle
102 NetLibDestroyServiceChild (
103 HttpService
->ControllerHandle
,
104 HttpService
->Ip4DriverBindingHandle
,
105 &gEfiTcp4ServiceBindingProtocolGuid
,
106 HttpService
->Tcp4ChildHandle
109 HttpService
->Tcp4ChildHandle
= NULL
;
112 if (HttpService
->Tcp6ChildHandle
!= NULL
) {
114 HttpService
->Tcp6ChildHandle
,
115 &gEfiTcp6ProtocolGuid
,
116 HttpService
->Ip6DriverBindingHandle
,
117 HttpService
->ControllerHandle
120 NetLibDestroyServiceChild (
121 HttpService
->ControllerHandle
,
122 HttpService
->Ip6DriverBindingHandle
,
123 &gEfiTcp6ServiceBindingProtocolGuid
,
124 HttpService
->Tcp6ChildHandle
127 HttpService
->Tcp6ChildHandle
= NULL
;
134 The event process routine when the http utilities protocol is installed
137 @param[in] Event Not used.
138 @param[in] Context The pointer to the IP4 config2 instance data or IP6 Config instance data.
143 HttpUtilitiesInstalledCallback (
148 gBS
->LocateProtocol (
149 &gEfiHttpUtilitiesProtocolGuid
,
151 (VOID
**) &mHttpUtilities
155 // Close the event if Http utilities protocol is loacted.
157 if (mHttpUtilities
!= NULL
&& Event
!= NULL
) {
158 gBS
->CloseEvent (Event
);
163 This is the declaration of an EFI image entry point. This entry point is
164 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
165 both device drivers and bus drivers.
167 @param ImageHandle The firmware allocated handle for the UEFI image.
168 @param SystemTable A pointer to the EFI System Table.
170 @retval EFI_SUCCESS The operation completed successfully.
171 @retval Others An unexpected error occurred.
176 HttpDxeDriverEntryPoint (
177 IN EFI_HANDLE ImageHandle
,
178 IN EFI_SYSTEM_TABLE
*SystemTable
184 gBS
->LocateProtocol (
185 &gEfiHttpUtilitiesProtocolGuid
,
187 (VOID
**) &mHttpUtilities
190 if (mHttpUtilities
== NULL
) {
192 // No Http utilities protocol, register a notify.
194 EfiCreateProtocolNotifyEvent (
195 &gEfiHttpUtilitiesProtocolGuid
,
197 HttpUtilitiesInstalledCallback
,
204 // Install UEFI Driver Model protocol(s).
206 Status
= EfiLibInstallDriverBindingComponentName2 (
209 &gHttpDxeIp4DriverBinding
,
211 &gHttpDxeComponentName
,
212 &gHttpDxeComponentName2
214 if (EFI_ERROR (Status
)) {
218 Status
= EfiLibInstallDriverBindingComponentName2 (
221 &gHttpDxeIp6DriverBinding
,
223 &gHttpDxeComponentName
,
224 &gHttpDxeComponentName2
226 if (EFI_ERROR (Status
)) {
227 EfiLibUninstallDriverBindingComponentName2 (
228 &gHttpDxeIp4DriverBinding
,
229 &gHttpDxeComponentName
,
230 &gHttpDxeComponentName2
237 Callback function which provided by user to remove one node in NetDestroyLinkList process.
239 @param[in] Entry The entry to be removed.
240 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
242 @retval EFI_INVALID_PARAMETER Any input parameter is NULL.
243 @retval EFI_SUCCESS The entry has been removed successfully.
244 @retval Others Fail to remove the entry.
249 HttpDestroyChildEntryInHandleBuffer (
250 IN LIST_ENTRY
*Entry
,
254 HTTP_PROTOCOL
*HttpInstance
;
255 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
256 UINTN NumberOfChildren
;
257 EFI_HANDLE
*ChildHandleBuffer
;
259 if (Entry
== NULL
|| Context
== NULL
) {
260 return EFI_INVALID_PARAMETER
;
263 HttpInstance
= NET_LIST_USER_STRUCT_S (Entry
, HTTP_PROTOCOL
, Link
, HTTP_PROTOCOL_SIGNATURE
);
264 ServiceBinding
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->ServiceBinding
;
265 NumberOfChildren
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->NumberOfChildren
;
266 ChildHandleBuffer
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->ChildHandleBuffer
;
268 if (!NetIsInHandleBuffer (HttpInstance
->Handle
, NumberOfChildren
, ChildHandleBuffer
)) {
272 return ServiceBinding
->DestroyChild (ServiceBinding
, HttpInstance
->Handle
);
276 Test to see if this driver supports ControllerHandle. This is the worker function for
277 HttpDxeIp4(6)DriverBindingSupported.
279 @param[in] This The pointer to the driver binding protocol.
280 @param[in] ControllerHandle The handle of device to be tested.
281 @param[in] RemainingDevicePath Optional parameter used to pick a specific child
282 device to be started.
283 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
285 @retval EFI_SUCCESS This driver supports this device.
286 @retval EFI_UNSUPPORTED This driver does not support this device.
292 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
293 IN EFI_HANDLE ControllerHandle
,
294 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
299 EFI_GUID
*TcpServiceBindingProtocolGuid
;
301 if (IpVersion
== IP_VERSION_4
) {
302 TcpServiceBindingProtocolGuid
= &gEfiTcp4ServiceBindingProtocolGuid
;
304 TcpServiceBindingProtocolGuid
= &gEfiTcp6ServiceBindingProtocolGuid
;
307 Status
= gBS
->OpenProtocol (
309 TcpServiceBindingProtocolGuid
,
311 This
->DriverBindingHandle
,
313 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
316 if (EFI_ERROR (Status
)) {
317 return EFI_UNSUPPORTED
;
324 Start this driver on ControllerHandle. This is the worker function for
325 HttpDxeIp4(6)DriverBindingStart.
327 @param[in] This The pointer to the driver binding protocol.
328 @param[in] ControllerHandle The handle of device to be started.
329 @param[in] RemainingDevicePath Optional parameter used to pick a specific child
330 device to be started.
331 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
334 @retval EFI_SUCCESS This driver is installed to ControllerHandle.
335 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
336 @retval other This driver does not support this device.
342 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
343 IN EFI_HANDLE ControllerHandle
,
344 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
349 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
350 HTTP_SERVICE
*HttpService
;
357 // Test for the Http service binding protocol
359 Status
= gBS
->OpenProtocol (
361 &gEfiHttpServiceBindingProtocolGuid
,
362 (VOID
**) &ServiceBinding
,
363 This
->DriverBindingHandle
,
365 EFI_OPEN_PROTOCOL_GET_PROTOCOL
368 if (!EFI_ERROR (Status
)) {
369 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding
);
371 Status
= HttpCreateService (ControllerHandle
, &HttpService
);
372 if (EFI_ERROR (Status
)) {
376 ASSERT (HttpService
!= NULL
);
379 // Install the HttpServiceBinding Protocol onto Controller
381 Status
= gBS
->InstallMultipleProtocolInterfaces (
383 &gEfiHttpServiceBindingProtocolGuid
,
384 &HttpService
->ServiceBinding
,
388 if (EFI_ERROR (Status
)) {
393 if (IpVersion
== IP_VERSION_4
) {
394 HttpService
->Ip4DriverBindingHandle
= This
->DriverBindingHandle
;
396 if (HttpService
->Tcp4ChildHandle
== NULL
) {
398 // Create a TCP4 child instance, but do not configure it. This will establish the parent-child relationship.
400 Status
= NetLibCreateServiceChild (
402 This
->DriverBindingHandle
,
403 &gEfiTcp4ServiceBindingProtocolGuid
,
404 &HttpService
->Tcp4ChildHandle
407 if (EFI_ERROR (Status
)) {
411 Status
= gBS
->OpenProtocol (
412 HttpService
->Tcp4ChildHandle
,
413 &gEfiTcp4ProtocolGuid
,
415 This
->DriverBindingHandle
,
417 EFI_OPEN_PROTOCOL_BY_DRIVER
420 if (EFI_ERROR (Status
)) {
425 return EFI_ALREADY_STARTED
;
430 HttpService
->Ip6DriverBindingHandle
= This
->DriverBindingHandle
;
432 if (HttpService
->Tcp6ChildHandle
== NULL
) {
434 // Create a TCP6 child instance, but do not configure it. This will establish the parent-child relationship.
436 Status
= NetLibCreateServiceChild (
438 This
->DriverBindingHandle
,
439 &gEfiTcp6ServiceBindingProtocolGuid
,
440 &HttpService
->Tcp6ChildHandle
443 if (EFI_ERROR (Status
)) {
447 Status
= gBS
->OpenProtocol (
448 HttpService
->Tcp6ChildHandle
,
449 &gEfiTcp6ProtocolGuid
,
451 This
->DriverBindingHandle
,
453 EFI_OPEN_PROTOCOL_BY_DRIVER
456 if (EFI_ERROR (Status
)) {
461 return EFI_ALREADY_STARTED
;
470 if (HttpService
!= NULL
) {
471 HttpCleanService (HttpService
, UsingIpv6
);
472 if (HttpService
->Tcp4ChildHandle
== NULL
&& HttpService
->Tcp6ChildHandle
== NULL
) {
473 FreePool (HttpService
);
483 Stop this driver on ControllerHandle. This is the worker function for
484 HttpDxeIp4(6)DriverBindingStop.
486 @param[in] This Protocol instance pointer.
487 @param[in] ControllerHandle Handle of device to stop driver on.
488 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
489 children is zero stop the entire bus driver.
490 @param[in] ChildHandleBuffer List of Child Handles to Stop.
491 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
493 @retval EFI_SUCCESS This driver was removed ControllerHandle.
494 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
495 @retval Others This driver was not removed from this device
501 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
502 IN EFI_HANDLE ControllerHandle
,
503 IN UINTN NumberOfChildren
,
504 IN EFI_HANDLE
*ChildHandleBuffer
,
508 EFI_HANDLE NicHandle
;
510 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
511 HTTP_SERVICE
*HttpService
;
513 HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context
;
517 // HTTP driver opens TCP4(6) child, So, Controller is a TCP4(6)
518 // child handle. Locate the Nic handle first. Then get the
519 // HTTP private data back.
521 if (IpVersion
== IP_VERSION_4
) {
523 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp4ProtocolGuid
);
526 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp6ProtocolGuid
);
529 if (NicHandle
== NULL
) {
533 Status
= gBS
->OpenProtocol (
535 &gEfiHttpServiceBindingProtocolGuid
,
536 (VOID
**) &ServiceBinding
,
537 This
->DriverBindingHandle
,
539 EFI_OPEN_PROTOCOL_GET_PROTOCOL
542 if (!EFI_ERROR (Status
)) {
544 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding
);
546 if (NumberOfChildren
!= 0) {
548 // Destroy the HTTP child instance in ChildHandleBuffer.
550 List
= &HttpService
->ChildrenList
;
551 Context
.ServiceBinding
= ServiceBinding
;
552 Context
.NumberOfChildren
= NumberOfChildren
;
553 Context
.ChildHandleBuffer
= ChildHandleBuffer
;
554 Status
= NetDestroyLinkList (
556 HttpDestroyChildEntryInHandleBuffer
,
562 HttpCleanService (HttpService
, UsingIpv6
);
564 if (HttpService
->Tcp4ChildHandle
== NULL
&& HttpService
->Tcp6ChildHandle
== NULL
) {
565 gBS
->UninstallProtocolInterface (
567 &gEfiHttpServiceBindingProtocolGuid
,
570 FreePool (HttpService
);
572 Status
= EFI_SUCCESS
;
581 Tests to see if this driver supports a given controller. If a child device is provided,
582 it further tests to see if this driver supports creating a handle for the specified child device.
584 This function checks to see if the driver specified by This supports the device specified by
585 ControllerHandle. Drivers will typically use the device path attached to
586 ControllerHandle and/or the services from the bus I/O abstraction attached to
587 ControllerHandle to determine if the driver supports ControllerHandle. This function
588 may be called many times during platform initialization. In order to reduce boot times, the tests
589 performed by this function must be very small, and take as little time as possible to execute. This
590 function must not change the state of any hardware devices, and this function must be aware that the
591 device specified by ControllerHandle may already be managed by the same driver or a
592 different driver. This function must match its calls to AllocatePages() with FreePages(),
593 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
594 Because ControllerHandle may have been previously started by the same driver, if a protocol is
595 already in the opened state, then it must not be closed with CloseProtocol(). This is required
596 to guarantee the state of ControllerHandle is not modified by this function.
598 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
599 @param[in] ControllerHandle The handle of the controller to test. This handle
600 must support a protocol interface that supplies
601 an I/O abstraction to the driver.
602 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
603 parameter is ignored by device drivers, and is optional for bus
604 drivers. For bus drivers, if this parameter is not NULL, then
605 the bus driver must determine if the bus controller specified
606 by ControllerHandle and the child controller specified
607 by RemainingDevicePath are both supported by this
610 @retval EFI_SUCCESS The device specified by ControllerHandle and
611 RemainingDevicePath is supported by the driver specified by This.
612 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
613 RemainingDevicePath is already being managed by the driver
615 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
616 RemainingDevicePath is already being managed by a different
617 driver or an application that requires exclusive access.
618 Currently not implemented.
619 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
620 RemainingDevicePath is not supported by the driver specified by This.
624 HttpDxeIp4DriverBindingSupported (
625 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
626 IN EFI_HANDLE ControllerHandle
,
627 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
630 return HttpDxeSupported (
639 Starts a device controller or a bus controller.
641 The Start() function is designed to be invoked from the EFI boot service ConnectController().
642 As a result, much of the error checking on the parameters to Start() has been moved into this
643 common boot service. It is legal to call Start() from other locations,
644 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
645 1. ControllerHandle must be a valid EFI_HANDLE.
646 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
647 EFI_DEVICE_PATH_PROTOCOL.
648 3. Prior to calling Start(), the Supported() function for the driver specified by This must
649 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
651 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
652 @param[in] ControllerHandle The handle of the controller to start. This handle
653 must support a protocol interface that supplies
654 an I/O abstraction to the driver.
655 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
656 parameter is ignored by device drivers, and is optional for bus
657 drivers. For a bus driver, if this parameter is NULL, then handles
658 for all the children of Controller are created by this driver.
659 If this parameter is not NULL and the first Device Path Node is
660 not the End of Device Path Node, then only the handle for the
661 child device specified by the first Device Path Node of
662 RemainingDevicePath is created by this driver.
663 If the first Device Path Node of RemainingDevicePath is
664 the End of Device Path Node, no child handle is created by this
667 @retval EFI_SUCCESS The device was started.
668 @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.
669 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
670 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
671 @retval Others The driver failded to start the device.
676 HttpDxeIp4DriverBindingStart (
677 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
678 IN EFI_HANDLE ControllerHandle
,
679 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
682 return HttpDxeStart (
691 Stops a device controller or a bus controller.
693 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
694 As a result, much of the error checking on the parameters to Stop() has been moved
695 into this common boot service. It is legal to call Stop() from other locations,
696 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
697 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
698 same driver's Start() function.
699 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
700 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
701 Start() function, and the Start() function must have called OpenProtocol() on
702 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
704 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
705 @param[in] ControllerHandle A handle to the device being stopped. The handle must
706 support a bus specific I/O protocol for the driver
707 to use to stop the device.
708 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
709 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
710 if NumberOfChildren is 0.
712 @retval EFI_SUCCESS The device was stopped.
713 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
718 HttpDxeIp4DriverBindingStop (
719 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
720 IN EFI_HANDLE ControllerHandle
,
721 IN UINTN NumberOfChildren
,
722 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
735 Tests to see if this driver supports a given controller. If a child device is provided,
736 it further tests to see if this driver supports creating a handle for the specified child device.
738 This function checks to see if the driver specified by This supports the device specified by
739 ControllerHandle. Drivers will typically use the device path attached to
740 ControllerHandle and/or the services from the bus I/O abstraction attached to
741 ControllerHandle to determine if the driver supports ControllerHandle. This function
742 may be called many times during platform initialization. In order to reduce boot times, the tests
743 performed by this function must be very small, and take as little time as possible to execute. This
744 function must not change the state of any hardware devices, and this function must be aware that the
745 device specified by ControllerHandle may already be managed by the same driver or a
746 different driver. This function must match its calls to AllocatePages() with FreePages(),
747 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
748 Because ControllerHandle may have been previously started by the same driver, if a protocol is
749 already in the opened state, then it must not be closed with CloseProtocol(). This is required
750 to guarantee the state of ControllerHandle is not modified by this function.
752 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
753 @param[in] ControllerHandle The handle of the controller to test. This handle
754 must support a protocol interface that supplies
755 an I/O abstraction to the driver.
756 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
757 parameter is ignored by device drivers, and is optional for bus
758 drivers. For bus drivers, if this parameter is not NULL, then
759 the bus driver must determine if the bus controller specified
760 by ControllerHandle and the child controller specified
761 by RemainingDevicePath are both supported by this
764 @retval EFI_SUCCESS The device specified by ControllerHandle and
765 RemainingDevicePath is supported by the driver specified by This.
766 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
767 RemainingDevicePath is already being managed by the driver
769 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
770 RemainingDevicePath is already being managed by a different
771 driver or an application that requires exclusive access.
772 Currently not implemented.
773 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
774 RemainingDevicePath is not supported by the driver specified by This.
778 HttpDxeIp6DriverBindingSupported (
779 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
780 IN EFI_HANDLE ControllerHandle
,
781 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
784 return HttpDxeSupported (
794 Starts a device controller or a bus controller.
796 The Start() function is designed to be invoked from the EFI boot service ConnectController().
797 As a result, much of the error checking on the parameters to Start() has been moved into this
798 common boot service. It is legal to call Start() from other locations,
799 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
800 1. ControllerHandle must be a valid EFI_HANDLE.
801 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
802 EFI_DEVICE_PATH_PROTOCOL.
803 3. Prior to calling Start(), the Supported() function for the driver specified by This must
804 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
806 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
807 @param[in] ControllerHandle The handle of the controller to start. This handle
808 must support a protocol interface that supplies
809 an I/O abstraction to the driver.
810 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
811 parameter is ignored by device drivers, and is optional for bus
812 drivers. For a bus driver, if this parameter is NULL, then handles
813 for all the children of Controller are created by this driver.
814 If this parameter is not NULL and the first Device Path Node is
815 not the End of Device Path Node, then only the handle for the
816 child device specified by the first Device Path Node of
817 RemainingDevicePath is created by this driver.
818 If the first Device Path Node of RemainingDevicePath is
819 the End of Device Path Node, no child handle is created by this
822 @retval EFI_SUCCESS The device was started.
823 @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.
824 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
825 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
826 @retval Others The driver failded to start the device.
831 HttpDxeIp6DriverBindingStart (
832 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
833 IN EFI_HANDLE ControllerHandle
,
834 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
837 return HttpDxeStart (
846 Stops a device controller or a bus controller.
848 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
849 As a result, much of the error checking on the parameters to Stop() has been moved
850 into this common boot service. It is legal to call Stop() from other locations,
851 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
852 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
853 same driver's Start() function.
854 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
855 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
856 Start() function, and the Start() function must have called OpenProtocol() on
857 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
859 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
860 @param[in] ControllerHandle A handle to the device being stopped. The handle must
861 support a bus specific I/O protocol for the driver
862 to use to stop the device.
863 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
864 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
865 if NumberOfChildren is 0.
867 @retval EFI_SUCCESS The device was stopped.
868 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
873 HttpDxeIp6DriverBindingStop (
874 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
875 IN EFI_HANDLE ControllerHandle
,
876 IN UINTN NumberOfChildren
,
877 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
889 Creates a child handle and installs a protocol.
891 The CreateChild() function installs a protocol on ChildHandle.
892 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
893 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
895 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
896 @param ChildHandle Pointer to the handle of the child to create. If it is NULL,
897 then a new handle is created. If it is a pointer to an existing UEFI handle,
898 then the protocol is added to the existing UEFI handle.
900 @retval EFI_SUCCES The protocol was added to ChildHandle.
901 @retval EFI_INVALID_PARAMETER This is NULL, or ChildHandle is NULL.
902 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
904 @retval other The child handle was not created.
909 HttpServiceBindingCreateChild (
910 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
911 IN OUT EFI_HANDLE
*ChildHandle
914 HTTP_SERVICE
*HttpService
;
915 HTTP_PROTOCOL
*HttpInstance
;
919 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
920 return EFI_INVALID_PARAMETER
;
923 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (This
);
924 HttpInstance
= AllocateZeroPool (sizeof (HTTP_PROTOCOL
));
925 if (HttpInstance
== NULL
) {
926 return EFI_OUT_OF_RESOURCES
;
929 HttpInstance
->Signature
= HTTP_PROTOCOL_SIGNATURE
;
930 HttpInstance
->Service
= HttpService
;
931 HttpInstance
->Method
= HttpMethodMax
;
933 CopyMem (&HttpInstance
->Http
, &mEfiHttpTemplate
, sizeof (HttpInstance
->Http
));
934 NetMapInit (&HttpInstance
->TxTokens
);
935 NetMapInit (&HttpInstance
->RxTokens
);
938 // Install HTTP protocol onto ChildHandle
940 Status
= gBS
->InstallMultipleProtocolInterfaces (
942 &gEfiHttpProtocolGuid
,
947 if (EFI_ERROR (Status
)) {
951 HttpInstance
->Handle
= *ChildHandle
;
954 // Add it to the HTTP service's child list.
956 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
958 InsertTailList (&HttpService
->ChildrenList
, &HttpInstance
->Link
);
959 HttpService
->ChildrenNumber
++;
961 gBS
->RestoreTPL (OldTpl
);
967 NetMapClean (&HttpInstance
->TxTokens
);
968 NetMapClean (&HttpInstance
->RxTokens
);
969 FreePool (HttpInstance
);
975 Destroys a child handle with a protocol installed on it.
977 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
978 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
979 last protocol on ChildHandle, then ChildHandle is destroyed.
981 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
982 @param ChildHandle Handle of the child to destroy
984 @retval EFI_SUCCES The protocol was removed from ChildHandle.
985 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
986 @retval EFI_INVALID_PARAMETER Child handle is NULL.
987 @retval other The child handle was not destroyed
992 HttpServiceBindingDestroyChild (
993 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
994 IN EFI_HANDLE ChildHandle
997 HTTP_SERVICE
*HttpService
;
998 HTTP_PROTOCOL
*HttpInstance
;
999 EFI_HTTP_PROTOCOL
*Http
;
1003 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
1004 return EFI_INVALID_PARAMETER
;
1007 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (This
);
1008 Status
= gBS
->OpenProtocol (
1010 &gEfiHttpProtocolGuid
,
1014 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1016 if (EFI_ERROR (Status
)) {
1017 return EFI_UNSUPPORTED
;
1020 HttpInstance
= HTTP_INSTANCE_FROM_PROTOCOL (Http
);
1021 if (HttpInstance
->Service
!= HttpService
) {
1022 return EFI_INVALID_PARAMETER
;
1025 if (HttpInstance
->InDestroy
) {
1029 HttpInstance
->InDestroy
= TRUE
;
1032 // Uninstall the HTTP protocol.
1034 Status
= gBS
->UninstallProtocolInterface (
1036 &gEfiHttpProtocolGuid
,
1040 if (EFI_ERROR (Status
)) {
1041 HttpInstance
->InDestroy
= FALSE
;
1045 HttpCleanProtocol (HttpInstance
);
1047 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1049 RemoveEntryList (&HttpInstance
->Link
);
1050 HttpService
->ChildrenNumber
--;
1052 gBS
->RestoreTPL (OldTpl
);
1054 FreePool (HttpInstance
);