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
,
37 Create a HTTP driver service binding private instance.
39 @param[in] Controller The controller that has TCP4 service binding
41 @param[out] ServiceData Point to HTTP driver private instance.
43 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
44 @retval EFI_SUCCESS A new HTTP driver private instance is created.
49 IN EFI_HANDLE Controller
,
50 OUT HTTP_SERVICE
**ServiceData
53 HTTP_SERVICE
*HttpService
;
55 ASSERT (ServiceData
!= NULL
);
58 HttpService
= AllocateZeroPool (sizeof (HTTP_SERVICE
));
59 if (HttpService
== NULL
) {
60 return EFI_OUT_OF_RESOURCES
;
63 HttpService
->Signature
= HTTP_SERVICE_SIGNATURE
;
64 HttpService
->ServiceBinding
.CreateChild
= HttpServiceBindingCreateChild
;
65 HttpService
->ServiceBinding
.DestroyChild
= HttpServiceBindingDestroyChild
;
66 HttpService
->ControllerHandle
= Controller
;
67 HttpService
->ChildrenNumber
= 0;
68 InitializeListHead (&HttpService
->ChildrenList
);
70 *ServiceData
= HttpService
;
75 Release all the resource used the HTTP service binding instance.
77 @param[in] HttpService The HTTP private instance.
78 @param[in] UsingIpv6 Indicate use TCP4 protocol or TCP6 protocol.
79 if TRUE, use Tcp6 protocol.
80 if FALSE, use Tcp4 protocol.
84 IN HTTP_SERVICE
*HttpService
,
88 if (HttpService
== NULL
) {
93 if (HttpService
->Tcp4ChildHandle
!= NULL
) {
95 HttpService
->Tcp4ChildHandle
,
96 &gEfiTcp4ProtocolGuid
,
97 HttpService
->Ip4DriverBindingHandle
,
98 HttpService
->ControllerHandle
101 NetLibDestroyServiceChild (
102 HttpService
->ControllerHandle
,
103 HttpService
->Ip4DriverBindingHandle
,
104 &gEfiTcp4ServiceBindingProtocolGuid
,
105 HttpService
->Tcp4ChildHandle
108 HttpService
->Tcp4ChildHandle
= NULL
;
111 if (HttpService
->Tcp6ChildHandle
!= NULL
) {
113 HttpService
->Tcp6ChildHandle
,
114 &gEfiTcp6ProtocolGuid
,
115 HttpService
->Ip6DriverBindingHandle
,
116 HttpService
->ControllerHandle
119 NetLibDestroyServiceChild (
120 HttpService
->ControllerHandle
,
121 HttpService
->Ip6DriverBindingHandle
,
122 &gEfiTcp6ServiceBindingProtocolGuid
,
123 HttpService
->Tcp6ChildHandle
126 HttpService
->Tcp6ChildHandle
= NULL
;
132 The event process routine when the http utilities protocol is installed
135 @param[in] Event Not used.
136 @param[in] Context The pointer to the IP4 config2 instance data or IP6 Config instance data.
141 HttpUtilitiesInstalledCallback (
146 gBS
->LocateProtocol (
147 &gEfiHttpUtilitiesProtocolGuid
,
149 (VOID
**)&mHttpUtilities
153 // Close the event if Http utilities protocol is located.
155 if ((mHttpUtilities
!= NULL
) && (Event
!= NULL
)) {
156 gBS
->CloseEvent (Event
);
161 This is the declaration of an EFI image entry point. This entry point is
162 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
163 both device drivers and bus drivers.
165 @param ImageHandle The firmware allocated handle for the UEFI image.
166 @param SystemTable A pointer to the EFI System Table.
168 @retval EFI_SUCCESS The operation completed successfully.
169 @retval Others An unexpected error occurred.
174 HttpDxeDriverEntryPoint (
175 IN EFI_HANDLE ImageHandle
,
176 IN EFI_SYSTEM_TABLE
*SystemTable
182 gBS
->LocateProtocol (
183 &gEfiHttpUtilitiesProtocolGuid
,
185 (VOID
**)&mHttpUtilities
188 if (mHttpUtilities
== NULL
) {
190 // No Http utilities protocol, register a notify.
192 EfiCreateProtocolNotifyEvent (
193 &gEfiHttpUtilitiesProtocolGuid
,
195 HttpUtilitiesInstalledCallback
,
202 // Install UEFI Driver Model protocol(s).
204 Status
= EfiLibInstallDriverBindingComponentName2 (
207 &gHttpDxeIp4DriverBinding
,
209 &gHttpDxeComponentName
,
210 &gHttpDxeComponentName2
212 if (EFI_ERROR (Status
)) {
216 Status
= EfiLibInstallDriverBindingComponentName2 (
219 &gHttpDxeIp6DriverBinding
,
221 &gHttpDxeComponentName
,
222 &gHttpDxeComponentName2
224 if (EFI_ERROR (Status
)) {
225 EfiLibUninstallDriverBindingComponentName2 (
226 &gHttpDxeIp4DriverBinding
,
227 &gHttpDxeComponentName
,
228 &gHttpDxeComponentName2
236 Callback function which provided by user to remove one node in NetDestroyLinkList process.
238 @param[in] Entry The entry to be removed.
239 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
241 @retval EFI_INVALID_PARAMETER Any input parameter is NULL.
242 @retval EFI_SUCCESS The entry has been removed successfully.
243 @retval Others Fail to remove the entry.
248 HttpDestroyChildEntryInHandleBuffer (
249 IN LIST_ENTRY
*Entry
,
253 HTTP_PROTOCOL
*HttpInstance
;
254 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
255 UINTN NumberOfChildren
;
256 EFI_HANDLE
*ChildHandleBuffer
;
258 if ((Entry
== NULL
) || (Context
== NULL
)) {
259 return EFI_INVALID_PARAMETER
;
262 HttpInstance
= NET_LIST_USER_STRUCT_S (Entry
, HTTP_PROTOCOL
, Link
, HTTP_PROTOCOL_SIGNATURE
);
263 ServiceBinding
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*)Context
)->ServiceBinding
;
264 NumberOfChildren
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*)Context
)->NumberOfChildren
;
265 ChildHandleBuffer
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*)Context
)->ChildHandleBuffer
;
267 if (!NetIsInHandleBuffer (HttpInstance
->Handle
, NumberOfChildren
, ChildHandleBuffer
)) {
271 return ServiceBinding
->DestroyChild (ServiceBinding
, HttpInstance
->Handle
);
275 Test to see if this driver supports ControllerHandle. This is the worker function for
276 HttpDxeIp4(6)DriverBindingSupported.
278 @param[in] This The pointer to the driver binding protocol.
279 @param[in] ControllerHandle The handle of device to be tested.
280 @param[in] RemainingDevicePath Optional parameter used to pick a specific child
281 device to be started.
282 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
284 @retval EFI_SUCCESS This driver supports this device.
285 @retval EFI_UNSUPPORTED This driver does not support this device.
291 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
292 IN EFI_HANDLE ControllerHandle
,
293 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
298 EFI_GUID
*TcpServiceBindingProtocolGuid
;
300 if (IpVersion
== IP_VERSION_4
) {
301 TcpServiceBindingProtocolGuid
= &gEfiTcp4ServiceBindingProtocolGuid
;
303 TcpServiceBindingProtocolGuid
= &gEfiTcp6ServiceBindingProtocolGuid
;
306 Status
= gBS
->OpenProtocol (
308 TcpServiceBindingProtocolGuid
,
310 This
->DriverBindingHandle
,
312 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
315 if (EFI_ERROR (Status
)) {
316 return EFI_UNSUPPORTED
;
323 Start this driver on ControllerHandle. This is the worker function for
324 HttpDxeIp4(6)DriverBindingStart.
326 @param[in] This The pointer to the driver binding protocol.
327 @param[in] ControllerHandle The handle of device to be started.
328 @param[in] RemainingDevicePath Optional parameter used to pick a specific child
329 device to be started.
330 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
333 @retval EFI_SUCCESS This driver is installed to ControllerHandle.
334 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
335 @retval other This driver does not support this device.
341 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
342 IN EFI_HANDLE ControllerHandle
,
343 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
348 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
349 HTTP_SERVICE
*HttpService
;
356 // Test for the Http service binding protocol
358 Status
= gBS
->OpenProtocol (
360 &gEfiHttpServiceBindingProtocolGuid
,
361 (VOID
**)&ServiceBinding
,
362 This
->DriverBindingHandle
,
364 EFI_OPEN_PROTOCOL_GET_PROTOCOL
367 if (!EFI_ERROR (Status
)) {
368 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding
);
370 Status
= HttpCreateService (ControllerHandle
, &HttpService
);
371 if (EFI_ERROR (Status
)) {
375 ASSERT (HttpService
!= NULL
);
378 // Install the HttpServiceBinding Protocol onto Controller
380 Status
= gBS
->InstallMultipleProtocolInterfaces (
382 &gEfiHttpServiceBindingProtocolGuid
,
383 &HttpService
->ServiceBinding
,
387 if (EFI_ERROR (Status
)) {
392 if (IpVersion
== IP_VERSION_4
) {
393 HttpService
->Ip4DriverBindingHandle
= This
->DriverBindingHandle
;
395 if (HttpService
->Tcp4ChildHandle
== NULL
) {
397 // Create a TCP4 child instance, but do not configure it. This will establish the parent-child relationship.
399 Status
= NetLibCreateServiceChild (
401 This
->DriverBindingHandle
,
402 &gEfiTcp4ServiceBindingProtocolGuid
,
403 &HttpService
->Tcp4ChildHandle
406 if (EFI_ERROR (Status
)) {
410 Status
= gBS
->OpenProtocol (
411 HttpService
->Tcp4ChildHandle
,
412 &gEfiTcp4ProtocolGuid
,
414 This
->DriverBindingHandle
,
416 EFI_OPEN_PROTOCOL_BY_DRIVER
419 if (EFI_ERROR (Status
)) {
423 return EFI_ALREADY_STARTED
;
427 HttpService
->Ip6DriverBindingHandle
= This
->DriverBindingHandle
;
429 if (HttpService
->Tcp6ChildHandle
== NULL
) {
431 // Create a TCP6 child instance, but do not configure it. This will establish the parent-child relationship.
433 Status
= NetLibCreateServiceChild (
435 This
->DriverBindingHandle
,
436 &gEfiTcp6ServiceBindingProtocolGuid
,
437 &HttpService
->Tcp6ChildHandle
440 if (EFI_ERROR (Status
)) {
444 Status
= gBS
->OpenProtocol (
445 HttpService
->Tcp6ChildHandle
,
446 &gEfiTcp6ProtocolGuid
,
448 This
->DriverBindingHandle
,
450 EFI_OPEN_PROTOCOL_BY_DRIVER
453 if (EFI_ERROR (Status
)) {
457 return EFI_ALREADY_STARTED
;
465 if (HttpService
!= NULL
) {
466 HttpCleanService (HttpService
, UsingIpv6
);
467 if ((HttpService
->Tcp4ChildHandle
== NULL
) && (HttpService
->Tcp6ChildHandle
== NULL
)) {
468 FreePool (HttpService
);
476 Stop this driver on ControllerHandle. This is the worker function for
477 HttpDxeIp4(6)DriverBindingStop.
479 @param[in] This Protocol instance pointer.
480 @param[in] ControllerHandle Handle of device to stop driver on.
481 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
482 children is zero stop the entire bus driver.
483 @param[in] ChildHandleBuffer List of Child Handles to Stop.
484 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
486 @retval EFI_SUCCESS This driver was removed ControllerHandle.
487 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
488 @retval Others This driver was not removed from this device
494 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
495 IN EFI_HANDLE ControllerHandle
,
496 IN UINTN NumberOfChildren
,
497 IN EFI_HANDLE
*ChildHandleBuffer
,
501 EFI_HANDLE NicHandle
;
503 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
504 HTTP_SERVICE
*HttpService
;
506 HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context
;
510 // HTTP driver opens TCP4(6) child, So, Controller is a TCP4(6)
511 // child handle. Locate the Nic handle first. Then get the
512 // HTTP private data back.
514 if (IpVersion
== IP_VERSION_4
) {
516 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp4ProtocolGuid
);
519 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp6ProtocolGuid
);
522 if (NicHandle
== NULL
) {
526 Status
= gBS
->OpenProtocol (
528 &gEfiHttpServiceBindingProtocolGuid
,
529 (VOID
**)&ServiceBinding
,
530 This
->DriverBindingHandle
,
532 EFI_OPEN_PROTOCOL_GET_PROTOCOL
535 if (!EFI_ERROR (Status
)) {
536 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding
);
538 if (NumberOfChildren
!= 0) {
540 // Destroy the HTTP child instance in ChildHandleBuffer.
542 List
= &HttpService
->ChildrenList
;
543 Context
.ServiceBinding
= ServiceBinding
;
544 Context
.NumberOfChildren
= NumberOfChildren
;
545 Context
.ChildHandleBuffer
= ChildHandleBuffer
;
546 Status
= NetDestroyLinkList (
548 HttpDestroyChildEntryInHandleBuffer
,
553 HttpCleanService (HttpService
, UsingIpv6
);
555 if ((HttpService
->Tcp4ChildHandle
== NULL
) && (HttpService
->Tcp6ChildHandle
== NULL
)) {
556 gBS
->UninstallProtocolInterface (
558 &gEfiHttpServiceBindingProtocolGuid
,
561 FreePool (HttpService
);
564 Status
= EFI_SUCCESS
;
572 Tests to see if this driver supports a given controller. If a child device is provided,
573 it further tests to see if this driver supports creating a handle for the specified child device.
575 This function checks to see if the driver specified by This supports the device specified by
576 ControllerHandle. Drivers will typically use the device path attached to
577 ControllerHandle and/or the services from the bus I/O abstraction attached to
578 ControllerHandle to determine if the driver supports ControllerHandle. This function
579 may be called many times during platform initialization. In order to reduce boot times, the tests
580 performed by this function must be very small, and take as little time as possible to execute. This
581 function must not change the state of any hardware devices, and this function must be aware that the
582 device specified by ControllerHandle may already be managed by the same driver or a
583 different driver. This function must match its calls to AllocatePages() with FreePages(),
584 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
585 Because ControllerHandle may have been previously started by the same driver, if a protocol is
586 already in the opened state, then it must not be closed with CloseProtocol(). This is required
587 to guarantee the state of ControllerHandle is not modified by this function.
589 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
590 @param[in] ControllerHandle The handle of the controller to test. This handle
591 must support a protocol interface that supplies
592 an I/O abstraction to the driver.
593 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
594 parameter is ignored by device drivers, and is optional for bus
595 drivers. For bus drivers, if this parameter is not NULL, then
596 the bus driver must determine if the bus controller specified
597 by ControllerHandle and the child controller specified
598 by RemainingDevicePath are both supported by this
601 @retval EFI_SUCCESS The device specified by ControllerHandle and
602 RemainingDevicePath is supported by the driver specified by This.
603 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
604 RemainingDevicePath is already being managed by the driver
606 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
607 RemainingDevicePath is already being managed by a different
608 driver or an application that requires exclusive access.
609 Currently not implemented.
610 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
611 RemainingDevicePath is not supported by the driver specified by This.
615 HttpDxeIp4DriverBindingSupported (
616 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
617 IN EFI_HANDLE ControllerHandle
,
618 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
621 return HttpDxeSupported (
630 Starts a device controller or a bus controller.
632 The Start() function is designed to be invoked from the EFI boot service ConnectController().
633 As a result, much of the error checking on the parameters to Start() has been moved into this
634 common boot service. It is legal to call Start() from other locations,
635 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
636 1. ControllerHandle must be a valid EFI_HANDLE.
637 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
638 EFI_DEVICE_PATH_PROTOCOL.
639 3. Prior to calling Start(), the Supported() function for the driver specified by This must
640 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
642 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
643 @param[in] ControllerHandle The handle of the controller to start. This handle
644 must support a protocol interface that supplies
645 an I/O abstraction to the driver.
646 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
647 parameter is ignored by device drivers, and is optional for bus
648 drivers. For a bus driver, if this parameter is NULL, then handles
649 for all the children of Controller are created by this driver.
650 If this parameter is not NULL and the first Device Path Node is
651 not the End of Device Path Node, then only the handle for the
652 child device specified by the first Device Path Node of
653 RemainingDevicePath is created by this driver.
654 If the first Device Path Node of RemainingDevicePath is
655 the End of Device Path Node, no child handle is created by this
658 @retval EFI_SUCCESS The device was started.
659 @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.
660 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
661 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
662 @retval Others The driver failed to start the device.
667 HttpDxeIp4DriverBindingStart (
668 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
669 IN EFI_HANDLE ControllerHandle
,
670 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
673 return HttpDxeStart (
682 Stops a device controller or a bus controller.
684 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
685 As a result, much of the error checking on the parameters to Stop() has been moved
686 into this common boot service. It is legal to call Stop() from other locations,
687 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
688 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
689 same driver's Start() function.
690 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
691 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
692 Start() function, and the Start() function must have called OpenProtocol() on
693 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
695 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
696 @param[in] ControllerHandle A handle to the device being stopped. The handle must
697 support a bus specific I/O protocol for the driver
698 to use to stop the device.
699 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
700 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
701 if NumberOfChildren is 0.
703 @retval EFI_SUCCESS The device was stopped.
704 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
709 HttpDxeIp4DriverBindingStop (
710 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
711 IN EFI_HANDLE ControllerHandle
,
712 IN UINTN NumberOfChildren
,
713 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
726 Tests to see if this driver supports a given controller. If a child device is provided,
727 it further tests to see if this driver supports creating a handle for the specified child device.
729 This function checks to see if the driver specified by This supports the device specified by
730 ControllerHandle. Drivers will typically use the device path attached to
731 ControllerHandle and/or the services from the bus I/O abstraction attached to
732 ControllerHandle to determine if the driver supports ControllerHandle. This function
733 may be called many times during platform initialization. In order to reduce boot times, the tests
734 performed by this function must be very small, and take as little time as possible to execute. This
735 function must not change the state of any hardware devices, and this function must be aware that the
736 device specified by ControllerHandle may already be managed by the same driver or a
737 different driver. This function must match its calls to AllocatePages() with FreePages(),
738 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
739 Because ControllerHandle may have been previously started by the same driver, if a protocol is
740 already in the opened state, then it must not be closed with CloseProtocol(). This is required
741 to guarantee the state of ControllerHandle is not modified by this function.
743 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
744 @param[in] ControllerHandle The handle of the controller to test. This handle
745 must support a protocol interface that supplies
746 an I/O abstraction to the driver.
747 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
748 parameter is ignored by device drivers, and is optional for bus
749 drivers. For bus drivers, if this parameter is not NULL, then
750 the bus driver must determine if the bus controller specified
751 by ControllerHandle and the child controller specified
752 by RemainingDevicePath are both supported by this
755 @retval EFI_SUCCESS The device specified by ControllerHandle and
756 RemainingDevicePath is supported by the driver specified by This.
757 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
758 RemainingDevicePath is already being managed by the driver
760 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
761 RemainingDevicePath is already being managed by a different
762 driver or an application that requires exclusive access.
763 Currently not implemented.
764 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
765 RemainingDevicePath is not supported by the driver specified by This.
769 HttpDxeIp6DriverBindingSupported (
770 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
771 IN EFI_HANDLE ControllerHandle
,
772 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
775 return HttpDxeSupported (
784 Starts a device controller or a bus controller.
786 The Start() function is designed to be invoked from the EFI boot service ConnectController().
787 As a result, much of the error checking on the parameters to Start() has been moved into this
788 common boot service. It is legal to call Start() from other locations,
789 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
790 1. ControllerHandle must be a valid EFI_HANDLE.
791 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
792 EFI_DEVICE_PATH_PROTOCOL.
793 3. Prior to calling Start(), the Supported() function for the driver specified by This must
794 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
796 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
797 @param[in] ControllerHandle The handle of the controller to start. This handle
798 must support a protocol interface that supplies
799 an I/O abstraction to the driver.
800 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
801 parameter is ignored by device drivers, and is optional for bus
802 drivers. For a bus driver, if this parameter is NULL, then handles
803 for all the children of Controller are created by this driver.
804 If this parameter is not NULL and the first Device Path Node is
805 not the End of Device Path Node, then only the handle for the
806 child device specified by the first Device Path Node of
807 RemainingDevicePath is created by this driver.
808 If the first Device Path Node of RemainingDevicePath is
809 the End of Device Path Node, no child handle is created by this
812 @retval EFI_SUCCESS The device was started.
813 @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.
814 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
815 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
816 @retval Others The driver failed to start the device.
821 HttpDxeIp6DriverBindingStart (
822 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
823 IN EFI_HANDLE ControllerHandle
,
824 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
827 return HttpDxeStart (
836 Stops a device controller or a bus controller.
838 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
839 As a result, much of the error checking on the parameters to Stop() has been moved
840 into this common boot service. It is legal to call Stop() from other locations,
841 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
842 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
843 same driver's Start() function.
844 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
845 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
846 Start() function, and the Start() function must have called OpenProtocol() on
847 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
849 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
850 @param[in] ControllerHandle A handle to the device being stopped. The handle must
851 support a bus specific I/O protocol for the driver
852 to use to stop the device.
853 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
854 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
855 if NumberOfChildren is 0.
857 @retval EFI_SUCCESS The device was stopped.
858 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
863 HttpDxeIp6DriverBindingStop (
864 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
865 IN EFI_HANDLE ControllerHandle
,
866 IN UINTN NumberOfChildren
,
867 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
880 Creates a child handle and installs a protocol.
882 The CreateChild() function installs a protocol on ChildHandle.
883 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
884 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
886 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
887 @param ChildHandle Pointer to the handle of the child to create. If it is NULL,
888 then a new handle is created. If it is a pointer to an existing UEFI handle,
889 then the protocol is added to the existing UEFI handle.
891 @retval EFI_SUCCESS The protocol was added to ChildHandle.
892 @retval EFI_INVALID_PARAMETER This is NULL, or ChildHandle is NULL.
893 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
895 @retval other The child handle was not created.
900 HttpServiceBindingCreateChild (
901 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
902 IN OUT EFI_HANDLE
*ChildHandle
905 HTTP_SERVICE
*HttpService
;
906 HTTP_PROTOCOL
*HttpInstance
;
910 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
911 return EFI_INVALID_PARAMETER
;
914 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (This
);
915 HttpInstance
= AllocateZeroPool (sizeof (HTTP_PROTOCOL
));
916 if (HttpInstance
== NULL
) {
917 return EFI_OUT_OF_RESOURCES
;
920 HttpInstance
->Signature
= HTTP_PROTOCOL_SIGNATURE
;
921 HttpInstance
->Service
= HttpService
;
922 HttpInstance
->Method
= HttpMethodMax
;
924 CopyMem (&HttpInstance
->Http
, &mEfiHttpTemplate
, sizeof (HttpInstance
->Http
));
925 NetMapInit (&HttpInstance
->TxTokens
);
926 NetMapInit (&HttpInstance
->RxTokens
);
929 // Install HTTP protocol onto ChildHandle
931 Status
= gBS
->InstallMultipleProtocolInterfaces (
933 &gEfiHttpProtocolGuid
,
938 if (EFI_ERROR (Status
)) {
942 HttpInstance
->Handle
= *ChildHandle
;
945 // Add it to the HTTP service's child list.
947 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
949 InsertTailList (&HttpService
->ChildrenList
, &HttpInstance
->Link
);
950 HttpService
->ChildrenNumber
++;
952 gBS
->RestoreTPL (OldTpl
);
958 NetMapClean (&HttpInstance
->TxTokens
);
959 NetMapClean (&HttpInstance
->RxTokens
);
960 FreePool (HttpInstance
);
966 Destroys a child handle with a protocol installed on it.
968 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
969 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
970 last protocol on ChildHandle, then ChildHandle is destroyed.
972 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
973 @param ChildHandle Handle of the child to destroy
975 @retval EFI_SUCCESS The protocol was removed from ChildHandle.
976 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
977 @retval EFI_INVALID_PARAMETER Child handle is NULL.
978 @retval other The child handle was not destroyed
983 HttpServiceBindingDestroyChild (
984 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
985 IN EFI_HANDLE ChildHandle
988 HTTP_SERVICE
*HttpService
;
989 HTTP_PROTOCOL
*HttpInstance
;
990 EFI_HTTP_PROTOCOL
*Http
;
994 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
995 return EFI_INVALID_PARAMETER
;
998 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (This
);
999 Status
= gBS
->OpenProtocol (
1001 &gEfiHttpProtocolGuid
,
1005 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1007 if (EFI_ERROR (Status
)) {
1008 return EFI_UNSUPPORTED
;
1011 HttpInstance
= HTTP_INSTANCE_FROM_PROTOCOL (Http
);
1012 if (HttpInstance
->Service
!= HttpService
) {
1013 return EFI_INVALID_PARAMETER
;
1016 if (HttpInstance
->InDestroy
) {
1020 HttpInstance
->InDestroy
= TRUE
;
1023 // Uninstall the HTTP protocol.
1025 Status
= gBS
->UninstallProtocolInterface (
1027 &gEfiHttpProtocolGuid
,
1031 if (EFI_ERROR (Status
)) {
1032 HttpInstance
->InDestroy
= FALSE
;
1036 HttpCleanProtocol (HttpInstance
);
1038 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1040 RemoveEntryList (&HttpInstance
->Link
);
1041 HttpService
->ChildrenNumber
--;
1043 gBS
->RestoreTPL (OldTpl
);
1045 FreePool (HttpInstance
);