2 The driver binding and service binding protocol for HttpDxe driver.
4 Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "HttpDriver.h"
19 EFI_HTTP_UTILITIES_PROTOCOL
*mHttpUtilities
= NULL
;
22 /// Driver Binding Protocol instance
24 EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp4DriverBinding
= {
25 HttpDxeIp4DriverBindingSupported
,
26 HttpDxeIp4DriverBindingStart
,
27 HttpDxeIp4DriverBindingStop
,
33 EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp6DriverBinding
= {
34 HttpDxeIp6DriverBindingSupported
,
35 HttpDxeIp6DriverBindingStart
,
36 HttpDxeIp6DriverBindingStop
,
44 Create a HTTP driver service binding private instance.
46 @param[in] Controller The controller that has TCP4 service binding
48 @param[out] ServiceData Point to HTTP driver private instance.
50 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
51 @retval EFI_SUCCESS A new HTTP driver private instance is created.
56 IN EFI_HANDLE Controller
,
57 OUT HTTP_SERVICE
**ServiceData
60 HTTP_SERVICE
*HttpService
;
62 ASSERT (ServiceData
!= NULL
);
65 HttpService
= AllocateZeroPool (sizeof (HTTP_SERVICE
));
66 if (HttpService
== NULL
) {
67 return EFI_OUT_OF_RESOURCES
;
70 HttpService
->Signature
= HTTP_SERVICE_SIGNATURE
;
71 HttpService
->ServiceBinding
.CreateChild
= HttpServiceBindingCreateChild
;
72 HttpService
->ServiceBinding
.DestroyChild
= HttpServiceBindingDestroyChild
;
73 HttpService
->ControllerHandle
= Controller
;
74 HttpService
->ChildrenNumber
= 0;
75 InitializeListHead (&HttpService
->ChildrenList
);
77 *ServiceData
= HttpService
;
82 Release all the resource used the HTTP service binding instance.
84 @param[in] HttpService The HTTP private instance.
85 @param[in] UsingIpv6 Indicate use TCP4 protocol or TCP6 protocol.
86 if TRUE, use Tcp6 protocol.
87 if FALSE, use Tcp4 protocl.
91 IN HTTP_SERVICE
*HttpService
,
96 if (HttpService
== NULL
) {
100 if (HttpService
->Tcp4ChildHandle
!= NULL
) {
102 HttpService
->Tcp4ChildHandle
,
103 &gEfiTcp4ProtocolGuid
,
104 HttpService
->Ip4DriverBindingHandle
,
105 HttpService
->ControllerHandle
108 NetLibDestroyServiceChild (
109 HttpService
->ControllerHandle
,
110 HttpService
->Ip4DriverBindingHandle
,
111 &gEfiTcp4ServiceBindingProtocolGuid
,
112 HttpService
->Tcp4ChildHandle
115 HttpService
->Tcp4ChildHandle
= NULL
;
118 if (HttpService
->Tcp6ChildHandle
!= NULL
) {
120 HttpService
->Tcp6ChildHandle
,
121 &gEfiTcp6ProtocolGuid
,
122 HttpService
->Ip6DriverBindingHandle
,
123 HttpService
->ControllerHandle
126 NetLibDestroyServiceChild (
127 HttpService
->ControllerHandle
,
128 HttpService
->Ip6DriverBindingHandle
,
129 &gEfiTcp6ServiceBindingProtocolGuid
,
130 HttpService
->Tcp6ChildHandle
133 HttpService
->Tcp6ChildHandle
= NULL
;
140 The event process routine when the http utilities protocol is installed
143 @param[in] Event Not used.
144 @param[in] Context The pointer to the IP4 config2 instance data or IP6 Config instance data.
149 HttpUtilitiesInstalledCallback (
154 gBS
->LocateProtocol (
155 &gEfiHttpUtilitiesProtocolGuid
,
157 (VOID
**) &mHttpUtilities
161 // Close the event if Http utilities protocol is loacted.
163 if (mHttpUtilities
!= NULL
&& Event
!= NULL
) {
164 gBS
->CloseEvent (Event
);
169 This is the declaration of an EFI image entry point. This entry point is
170 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
171 both device drivers and bus drivers.
173 @param ImageHandle The firmware allocated handle for the UEFI image.
174 @param SystemTable A pointer to the EFI System Table.
176 @retval EFI_SUCCESS The operation completed successfully.
177 @retval Others An unexpected error occurred.
182 HttpDxeDriverEntryPoint (
183 IN EFI_HANDLE ImageHandle
,
184 IN EFI_SYSTEM_TABLE
*SystemTable
190 gBS
->LocateProtocol (
191 &gEfiHttpUtilitiesProtocolGuid
,
193 (VOID
**) &mHttpUtilities
196 if (mHttpUtilities
== NULL
) {
198 // No Http utilities protocol, register a notify.
200 EfiCreateProtocolNotifyEvent (
201 &gEfiHttpUtilitiesProtocolGuid
,
203 HttpUtilitiesInstalledCallback
,
210 // Install UEFI Driver Model protocol(s).
212 Status
= EfiLibInstallDriverBindingComponentName2 (
215 &gHttpDxeIp4DriverBinding
,
217 &gHttpDxeComponentName
,
218 &gHttpDxeComponentName2
220 if (EFI_ERROR (Status
)) {
224 Status
= EfiLibInstallDriverBindingComponentName2 (
227 &gHttpDxeIp6DriverBinding
,
229 &gHttpDxeComponentName
,
230 &gHttpDxeComponentName2
232 if (EFI_ERROR (Status
)) {
233 gBS
->UninstallMultipleProtocolInterfaces (
235 &gEfiDriverBindingProtocolGuid
,
236 &gHttpDxeIp4DriverBinding
,
237 &gEfiComponentName2ProtocolGuid
,
238 &gHttpDxeComponentName2
,
239 &gEfiComponentNameProtocolGuid
,
240 &gHttpDxeComponentName
,
248 Callback function which provided by user to remove one node in NetDestroyLinkList process.
250 @param[in] Entry The entry to be removed.
251 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
253 @retval EFI_INVALID_PARAMETER Any input parameter is NULL.
254 @retval EFI_SUCCESS The entry has been removed successfully.
255 @retval Others Fail to remove the entry.
260 HttpDestroyChildEntryInHandleBuffer (
261 IN LIST_ENTRY
*Entry
,
265 HTTP_PROTOCOL
*HttpInstance
;
266 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
267 UINTN NumberOfChildren
;
268 EFI_HANDLE
*ChildHandleBuffer
;
270 if (Entry
== NULL
|| Context
== NULL
) {
271 return EFI_INVALID_PARAMETER
;
274 HttpInstance
= NET_LIST_USER_STRUCT_S (Entry
, HTTP_PROTOCOL
, Link
, HTTP_PROTOCOL_SIGNATURE
);
275 ServiceBinding
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->ServiceBinding
;
276 NumberOfChildren
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->NumberOfChildren
;
277 ChildHandleBuffer
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->ChildHandleBuffer
;
279 if (!NetIsInHandleBuffer (HttpInstance
->Handle
, NumberOfChildren
, ChildHandleBuffer
)) {
283 return ServiceBinding
->DestroyChild (ServiceBinding
, HttpInstance
->Handle
);
287 Test to see if this driver supports ControllerHandle. This is the worker function for
288 HttpDxeIp4(6)DriverBindingSupported.
290 @param[in] This The pointer to the driver binding protocol.
291 @param[in] ControllerHandle The handle of device to be tested.
292 @param[in] RemainingDevicePath Optional parameter used to pick a specific child
293 device to be started.
294 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
296 @retval EFI_SUCCESS This driver supports this device.
297 @retval EFI_UNSUPPORTED This driver does not support this device.
303 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
304 IN EFI_HANDLE ControllerHandle
,
305 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
310 EFI_GUID
*TcpServiceBindingProtocolGuid
;
312 if (IpVersion
== IP_VERSION_4
) {
313 TcpServiceBindingProtocolGuid
= &gEfiTcp4ServiceBindingProtocolGuid
;
315 TcpServiceBindingProtocolGuid
= &gEfiTcp6ServiceBindingProtocolGuid
;
318 Status
= gBS
->OpenProtocol (
320 TcpServiceBindingProtocolGuid
,
322 This
->DriverBindingHandle
,
324 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
327 if (EFI_ERROR (Status
)) {
328 return EFI_UNSUPPORTED
;
335 Start this driver on ControllerHandle. This is the worker function for
336 HttpDxeIp4(6)DriverBindingStart.
338 @param[in] This The pointer to the driver binding protocol.
339 @param[in] ControllerHandle The handle of device to be started.
340 @param[in] RemainingDevicePath Optional parameter used to pick a specific child
341 device to be started.
342 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
345 @retval EFI_SUCCESS This driver is installed to ControllerHandle.
346 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
347 @retval other This driver does not support this device.
353 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
354 IN EFI_HANDLE ControllerHandle
,
355 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
360 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
361 HTTP_SERVICE
*HttpService
;
368 // Test for the Http service binding protocol
370 Status
= gBS
->OpenProtocol (
372 &gEfiHttpServiceBindingProtocolGuid
,
373 (VOID
**) &ServiceBinding
,
374 This
->DriverBindingHandle
,
376 EFI_OPEN_PROTOCOL_GET_PROTOCOL
379 if (!EFI_ERROR (Status
)) {
380 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding
);
382 Status
= HttpCreateService (ControllerHandle
, &HttpService
);
383 if (EFI_ERROR (Status
)) {
387 ASSERT (HttpService
!= NULL
);
390 // Install the HttpServiceBinding Protocol onto Controller
392 Status
= gBS
->InstallMultipleProtocolInterfaces (
394 &gEfiHttpServiceBindingProtocolGuid
,
395 &HttpService
->ServiceBinding
,
399 if (EFI_ERROR (Status
)) {
404 if (IpVersion
== IP_VERSION_4
) {
405 HttpService
->Ip4DriverBindingHandle
= This
->DriverBindingHandle
;
407 if (HttpService
->Tcp4ChildHandle
== NULL
) {
409 // Create a TCP4 child instance, but do not configure it. This will establish the parent-child relationship.
411 Status
= NetLibCreateServiceChild (
413 This
->DriverBindingHandle
,
414 &gEfiTcp4ServiceBindingProtocolGuid
,
415 &HttpService
->Tcp4ChildHandle
418 if (EFI_ERROR (Status
)) {
422 Status
= gBS
->OpenProtocol (
423 HttpService
->Tcp4ChildHandle
,
424 &gEfiTcp4ProtocolGuid
,
426 This
->DriverBindingHandle
,
428 EFI_OPEN_PROTOCOL_BY_DRIVER
431 if (EFI_ERROR (Status
)) {
436 return EFI_ALREADY_STARTED
;
441 HttpService
->Ip6DriverBindingHandle
= This
->DriverBindingHandle
;
443 if (HttpService
->Tcp6ChildHandle
== NULL
) {
445 // Create a TCP6 child instance, but do not configure it. This will establish the parent-child relationship.
447 Status
= NetLibCreateServiceChild (
449 This
->DriverBindingHandle
,
450 &gEfiTcp6ServiceBindingProtocolGuid
,
451 &HttpService
->Tcp6ChildHandle
454 if (EFI_ERROR (Status
)) {
458 Status
= gBS
->OpenProtocol (
459 HttpService
->Tcp6ChildHandle
,
460 &gEfiTcp6ProtocolGuid
,
462 This
->DriverBindingHandle
,
464 EFI_OPEN_PROTOCOL_BY_DRIVER
467 if (EFI_ERROR (Status
)) {
472 return EFI_ALREADY_STARTED
;
481 if (HttpService
!= NULL
) {
482 HttpCleanService (HttpService
, UsingIpv6
);
483 if (HttpService
->Tcp4ChildHandle
== NULL
&& HttpService
->Tcp6ChildHandle
== NULL
) {
484 FreePool (HttpService
);
494 Stop this driver on ControllerHandle. This is the worker function for
495 HttpDxeIp4(6)DriverBindingStop.
497 @param[in] This Protocol instance pointer.
498 @param[in] ControllerHandle Handle of device to stop driver on.
499 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
500 children is zero stop the entire bus driver.
501 @param[in] ChildHandleBuffer List of Child Handles to Stop.
502 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
504 @retval EFI_SUCCESS This driver was removed ControllerHandle.
505 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
506 @retval Others This driver was not removed from this device
512 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
513 IN EFI_HANDLE ControllerHandle
,
514 IN UINTN NumberOfChildren
,
515 IN EFI_HANDLE
*ChildHandleBuffer
,
519 EFI_HANDLE NicHandle
;
521 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
522 HTTP_SERVICE
*HttpService
;
524 HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context
;
528 // HTTP driver opens TCP4(6) child, So, Controller is a TCP4(6)
529 // child handle. Locate the Nic handle first. Then get the
530 // HTTP private data back.
532 if (IpVersion
== IP_VERSION_4
) {
534 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp4ProtocolGuid
);
537 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp6ProtocolGuid
);
540 if (NicHandle
== NULL
) {
544 Status
= gBS
->OpenProtocol (
546 &gEfiHttpServiceBindingProtocolGuid
,
547 (VOID
**) &ServiceBinding
,
548 This
->DriverBindingHandle
,
550 EFI_OPEN_PROTOCOL_GET_PROTOCOL
553 if (!EFI_ERROR (Status
)) {
555 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding
);
557 if (NumberOfChildren
!= 0) {
559 // Destroy the HTTP child instance in ChildHandleBuffer.
561 List
= &HttpService
->ChildrenList
;
562 Context
.ServiceBinding
= ServiceBinding
;
563 Context
.NumberOfChildren
= NumberOfChildren
;
564 Context
.ChildHandleBuffer
= ChildHandleBuffer
;
565 Status
= NetDestroyLinkList (
567 HttpDestroyChildEntryInHandleBuffer
,
573 HttpCleanService (HttpService
, UsingIpv6
);
575 if (HttpService
->Tcp4ChildHandle
== NULL
&& HttpService
->Tcp6ChildHandle
== NULL
) {
576 gBS
->UninstallProtocolInterface (
578 &gEfiHttpServiceBindingProtocolGuid
,
581 FreePool (HttpService
);
583 Status
= EFI_SUCCESS
;
592 Tests to see if this driver supports a given controller. If a child device is provided,
593 it further tests to see if this driver supports creating a handle for the specified child device.
595 This function checks to see if the driver specified by This supports the device specified by
596 ControllerHandle. Drivers will typically use the device path attached to
597 ControllerHandle and/or the services from the bus I/O abstraction attached to
598 ControllerHandle to determine if the driver supports ControllerHandle. This function
599 may be called many times during platform initialization. In order to reduce boot times, the tests
600 performed by this function must be very small, and take as little time as possible to execute. This
601 function must not change the state of any hardware devices, and this function must be aware that the
602 device specified by ControllerHandle may already be managed by the same driver or a
603 different driver. This function must match its calls to AllocatePages() with FreePages(),
604 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
605 Because ControllerHandle may have been previously started by the same driver, if a protocol is
606 already in the opened state, then it must not be closed with CloseProtocol(). This is required
607 to guarantee the state of ControllerHandle is not modified by this function.
609 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
610 @param[in] ControllerHandle The handle of the controller to test. This handle
611 must support a protocol interface that supplies
612 an I/O abstraction to the driver.
613 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
614 parameter is ignored by device drivers, and is optional for bus
615 drivers. For bus drivers, if this parameter is not NULL, then
616 the bus driver must determine if the bus controller specified
617 by ControllerHandle and the child controller specified
618 by RemainingDevicePath are both supported by this
621 @retval EFI_SUCCESS The device specified by ControllerHandle and
622 RemainingDevicePath is supported by the driver specified by This.
623 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
624 RemainingDevicePath is already being managed by the driver
626 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
627 RemainingDevicePath is already being managed by a different
628 driver or an application that requires exclusive access.
629 Currently not implemented.
630 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
631 RemainingDevicePath is not supported by the driver specified by This.
635 HttpDxeIp4DriverBindingSupported (
636 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
637 IN EFI_HANDLE ControllerHandle
,
638 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
641 return HttpDxeSupported (
650 Starts a device controller or a bus controller.
652 The Start() function is designed to be invoked from the EFI boot service ConnectController().
653 As a result, much of the error checking on the parameters to Start() has been moved into this
654 common boot service. It is legal to call Start() from other locations,
655 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
656 1. ControllerHandle must be a valid EFI_HANDLE.
657 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
658 EFI_DEVICE_PATH_PROTOCOL.
659 3. Prior to calling Start(), the Supported() function for the driver specified by This must
660 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
662 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
663 @param[in] ControllerHandle The handle of the controller to start. This handle
664 must support a protocol interface that supplies
665 an I/O abstraction to the driver.
666 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
667 parameter is ignored by device drivers, and is optional for bus
668 drivers. For a bus driver, if this parameter is NULL, then handles
669 for all the children of Controller are created by this driver.
670 If this parameter is not NULL and the first Device Path Node is
671 not the End of Device Path Node, then only the handle for the
672 child device specified by the first Device Path Node of
673 RemainingDevicePath is created by this driver.
674 If the first Device Path Node of RemainingDevicePath is
675 the End of Device Path Node, no child handle is created by this
678 @retval EFI_SUCCESS The device was started.
679 @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.
680 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
681 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
682 @retval Others The driver failded to start the device.
687 HttpDxeIp4DriverBindingStart (
688 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
689 IN EFI_HANDLE ControllerHandle
,
690 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
693 return HttpDxeStart (
702 Stops a device controller or a bus controller.
704 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
705 As a result, much of the error checking on the parameters to Stop() has been moved
706 into this common boot service. It is legal to call Stop() from other locations,
707 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
708 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
709 same driver's Start() function.
710 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
711 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
712 Start() function, and the Start() function must have called OpenProtocol() on
713 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
715 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
716 @param[in] ControllerHandle A handle to the device being stopped. The handle must
717 support a bus specific I/O protocol for the driver
718 to use to stop the device.
719 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
720 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
721 if NumberOfChildren is 0.
723 @retval EFI_SUCCESS The device was stopped.
724 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
729 HttpDxeIp4DriverBindingStop (
730 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
731 IN EFI_HANDLE ControllerHandle
,
732 IN UINTN NumberOfChildren
,
733 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
746 Tests to see if this driver supports a given controller. If a child device is provided,
747 it further tests to see if this driver supports creating a handle for the specified child device.
749 This function checks to see if the driver specified by This supports the device specified by
750 ControllerHandle. Drivers will typically use the device path attached to
751 ControllerHandle and/or the services from the bus I/O abstraction attached to
752 ControllerHandle to determine if the driver supports ControllerHandle. This function
753 may be called many times during platform initialization. In order to reduce boot times, the tests
754 performed by this function must be very small, and take as little time as possible to execute. This
755 function must not change the state of any hardware devices, and this function must be aware that the
756 device specified by ControllerHandle may already be managed by the same driver or a
757 different driver. This function must match its calls to AllocatePages() with FreePages(),
758 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
759 Because ControllerHandle may have been previously started by the same driver, if a protocol is
760 already in the opened state, then it must not be closed with CloseProtocol(). This is required
761 to guarantee the state of ControllerHandle is not modified by this function.
763 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
764 @param[in] ControllerHandle The handle of the controller to test. This handle
765 must support a protocol interface that supplies
766 an I/O abstraction to the driver.
767 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
768 parameter is ignored by device drivers, and is optional for bus
769 drivers. For bus drivers, if this parameter is not NULL, then
770 the bus driver must determine if the bus controller specified
771 by ControllerHandle and the child controller specified
772 by RemainingDevicePath are both supported by this
775 @retval EFI_SUCCESS The device specified by ControllerHandle and
776 RemainingDevicePath is supported by the driver specified by This.
777 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
778 RemainingDevicePath is already being managed by the driver
780 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
781 RemainingDevicePath is already being managed by a different
782 driver or an application that requires exclusive access.
783 Currently not implemented.
784 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
785 RemainingDevicePath is not supported by the driver specified by This.
789 HttpDxeIp6DriverBindingSupported (
790 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
791 IN EFI_HANDLE ControllerHandle
,
792 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
795 return HttpDxeSupported (
805 Starts a device controller or a bus controller.
807 The Start() function is designed to be invoked from the EFI boot service ConnectController().
808 As a result, much of the error checking on the parameters to Start() has been moved into this
809 common boot service. It is legal to call Start() from other locations,
810 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
811 1. ControllerHandle must be a valid EFI_HANDLE.
812 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
813 EFI_DEVICE_PATH_PROTOCOL.
814 3. Prior to calling Start(), the Supported() function for the driver specified by This must
815 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
817 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
818 @param[in] ControllerHandle The handle of the controller to start. This handle
819 must support a protocol interface that supplies
820 an I/O abstraction to the driver.
821 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
822 parameter is ignored by device drivers, and is optional for bus
823 drivers. For a bus driver, if this parameter is NULL, then handles
824 for all the children of Controller are created by this driver.
825 If this parameter is not NULL and the first Device Path Node is
826 not the End of Device Path Node, then only the handle for the
827 child device specified by the first Device Path Node of
828 RemainingDevicePath is created by this driver.
829 If the first Device Path Node of RemainingDevicePath is
830 the End of Device Path Node, no child handle is created by this
833 @retval EFI_SUCCESS The device was started.
834 @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.
835 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
836 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
837 @retval Others The driver failded to start the device.
842 HttpDxeIp6DriverBindingStart (
843 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
844 IN EFI_HANDLE ControllerHandle
,
845 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
848 return HttpDxeStart (
857 Stops a device controller or a bus controller.
859 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
860 As a result, much of the error checking on the parameters to Stop() has been moved
861 into this common boot service. It is legal to call Stop() from other locations,
862 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
863 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
864 same driver's Start() function.
865 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
866 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
867 Start() function, and the Start() function must have called OpenProtocol() on
868 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
870 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
871 @param[in] ControllerHandle A handle to the device being stopped. The handle must
872 support a bus specific I/O protocol for the driver
873 to use to stop the device.
874 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
875 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
876 if NumberOfChildren is 0.
878 @retval EFI_SUCCESS The device was stopped.
879 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
884 HttpDxeIp6DriverBindingStop (
885 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
886 IN EFI_HANDLE ControllerHandle
,
887 IN UINTN NumberOfChildren
,
888 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
900 Creates a child handle and installs a protocol.
902 The CreateChild() function installs a protocol on ChildHandle.
903 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
904 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
906 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
907 @param ChildHandle Pointer to the handle of the child to create. If it is NULL,
908 then a new handle is created. If it is a pointer to an existing UEFI handle,
909 then the protocol is added to the existing UEFI handle.
911 @retval EFI_SUCCES The protocol was added to ChildHandle.
912 @retval EFI_INVALID_PARAMETER This is NULL, or ChildHandle is NULL.
913 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
915 @retval other The child handle was not created.
920 HttpServiceBindingCreateChild (
921 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
922 IN OUT EFI_HANDLE
*ChildHandle
925 HTTP_SERVICE
*HttpService
;
926 HTTP_PROTOCOL
*HttpInstance
;
930 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
931 return EFI_INVALID_PARAMETER
;
934 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (This
);
935 HttpInstance
= AllocateZeroPool (sizeof (HTTP_PROTOCOL
));
936 if (HttpInstance
== NULL
) {
937 return EFI_OUT_OF_RESOURCES
;
940 HttpInstance
->Signature
= HTTP_PROTOCOL_SIGNATURE
;
941 HttpInstance
->Service
= HttpService
;
942 HttpInstance
->Method
= HttpMethodMax
;
944 CopyMem (&HttpInstance
->Http
, &mEfiHttpTemplate
, sizeof (HttpInstance
->Http
));
945 NetMapInit (&HttpInstance
->TxTokens
);
946 NetMapInit (&HttpInstance
->RxTokens
);
949 // Install HTTP protocol onto ChildHandle
951 Status
= gBS
->InstallMultipleProtocolInterfaces (
953 &gEfiHttpProtocolGuid
,
958 if (EFI_ERROR (Status
)) {
962 HttpInstance
->Handle
= *ChildHandle
;
965 // Add it to the HTTP service's child list.
967 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
969 InsertTailList (&HttpService
->ChildrenList
, &HttpInstance
->Link
);
970 HttpService
->ChildrenNumber
++;
972 gBS
->RestoreTPL (OldTpl
);
978 NetMapClean (&HttpInstance
->TxTokens
);
979 NetMapClean (&HttpInstance
->RxTokens
);
980 FreePool (HttpInstance
);
986 Destroys a child handle with a protocol installed on it.
988 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
989 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
990 last protocol on ChildHandle, then ChildHandle is destroyed.
992 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
993 @param ChildHandle Handle of the child to destroy
995 @retval EFI_SUCCES The protocol was removed from ChildHandle.
996 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
997 @retval EFI_INVALID_PARAMETER Child handle is NULL.
998 @retval other The child handle was not destroyed
1003 HttpServiceBindingDestroyChild (
1004 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
1005 IN EFI_HANDLE ChildHandle
1008 HTTP_SERVICE
*HttpService
;
1009 HTTP_PROTOCOL
*HttpInstance
;
1010 EFI_HTTP_PROTOCOL
*Http
;
1014 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
1015 return EFI_INVALID_PARAMETER
;
1018 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (This
);
1019 Status
= gBS
->OpenProtocol (
1021 &gEfiHttpProtocolGuid
,
1025 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1027 if (EFI_ERROR (Status
)) {
1028 return EFI_UNSUPPORTED
;
1031 HttpInstance
= HTTP_INSTANCE_FROM_PROTOCOL (Http
);
1032 if (HttpInstance
->Service
!= HttpService
) {
1033 return EFI_INVALID_PARAMETER
;
1036 if (HttpInstance
->InDestroy
) {
1040 HttpInstance
->InDestroy
= TRUE
;
1043 // Uninstall the HTTP protocol.
1045 Status
= gBS
->UninstallProtocolInterface (
1047 &gEfiHttpProtocolGuid
,
1051 if (EFI_ERROR (Status
)) {
1052 HttpInstance
->InDestroy
= FALSE
;
1056 HttpCleanProtocol (HttpInstance
);
1058 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1060 RemoveEntryList (&HttpInstance
->Link
);
1061 HttpService
->ChildrenNumber
--;
1063 gBS
->RestoreTPL (OldTpl
);
1065 FreePool (HttpInstance
);