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 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 EfiLibUninstallDriverBindingComponentName2 (
234 &gHttpDxeIp4DriverBinding
,
235 &gHttpDxeComponentName
,
236 &gHttpDxeComponentName2
243 Callback function which provided by user to remove one node in NetDestroyLinkList process.
245 @param[in] Entry The entry to be removed.
246 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
248 @retval EFI_INVALID_PARAMETER Any input parameter is NULL.
249 @retval EFI_SUCCESS The entry has been removed successfully.
250 @retval Others Fail to remove the entry.
255 HttpDestroyChildEntryInHandleBuffer (
256 IN LIST_ENTRY
*Entry
,
260 HTTP_PROTOCOL
*HttpInstance
;
261 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
262 UINTN NumberOfChildren
;
263 EFI_HANDLE
*ChildHandleBuffer
;
265 if (Entry
== NULL
|| Context
== NULL
) {
266 return EFI_INVALID_PARAMETER
;
269 HttpInstance
= NET_LIST_USER_STRUCT_S (Entry
, HTTP_PROTOCOL
, Link
, HTTP_PROTOCOL_SIGNATURE
);
270 ServiceBinding
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->ServiceBinding
;
271 NumberOfChildren
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->NumberOfChildren
;
272 ChildHandleBuffer
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->ChildHandleBuffer
;
274 if (!NetIsInHandleBuffer (HttpInstance
->Handle
, NumberOfChildren
, ChildHandleBuffer
)) {
278 return ServiceBinding
->DestroyChild (ServiceBinding
, HttpInstance
->Handle
);
282 Test to see if this driver supports ControllerHandle. This is the worker function for
283 HttpDxeIp4(6)DriverBindingSupported.
285 @param[in] This The pointer to the driver binding protocol.
286 @param[in] ControllerHandle The handle of device to be tested.
287 @param[in] RemainingDevicePath Optional parameter used to pick a specific child
288 device to be started.
289 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
291 @retval EFI_SUCCESS This driver supports this device.
292 @retval EFI_UNSUPPORTED This driver does not support this device.
298 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
299 IN EFI_HANDLE ControllerHandle
,
300 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
305 EFI_GUID
*TcpServiceBindingProtocolGuid
;
307 if (IpVersion
== IP_VERSION_4
) {
308 TcpServiceBindingProtocolGuid
= &gEfiTcp4ServiceBindingProtocolGuid
;
310 TcpServiceBindingProtocolGuid
= &gEfiTcp6ServiceBindingProtocolGuid
;
313 Status
= gBS
->OpenProtocol (
315 TcpServiceBindingProtocolGuid
,
317 This
->DriverBindingHandle
,
319 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
322 if (EFI_ERROR (Status
)) {
323 return EFI_UNSUPPORTED
;
330 Start this driver on ControllerHandle. This is the worker function for
331 HttpDxeIp4(6)DriverBindingStart.
333 @param[in] This The pointer to the driver binding protocol.
334 @param[in] ControllerHandle The handle of device to be started.
335 @param[in] RemainingDevicePath Optional parameter used to pick a specific child
336 device to be started.
337 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
340 @retval EFI_SUCCESS This driver is installed to ControllerHandle.
341 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
342 @retval other This driver does not support this device.
348 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
349 IN EFI_HANDLE ControllerHandle
,
350 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
355 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
356 HTTP_SERVICE
*HttpService
;
363 // Test for the Http service binding protocol
365 Status
= gBS
->OpenProtocol (
367 &gEfiHttpServiceBindingProtocolGuid
,
368 (VOID
**) &ServiceBinding
,
369 This
->DriverBindingHandle
,
371 EFI_OPEN_PROTOCOL_GET_PROTOCOL
374 if (!EFI_ERROR (Status
)) {
375 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding
);
377 Status
= HttpCreateService (ControllerHandle
, &HttpService
);
378 if (EFI_ERROR (Status
)) {
382 ASSERT (HttpService
!= NULL
);
385 // Install the HttpServiceBinding Protocol onto Controller
387 Status
= gBS
->InstallMultipleProtocolInterfaces (
389 &gEfiHttpServiceBindingProtocolGuid
,
390 &HttpService
->ServiceBinding
,
394 if (EFI_ERROR (Status
)) {
399 if (IpVersion
== IP_VERSION_4
) {
400 HttpService
->Ip4DriverBindingHandle
= This
->DriverBindingHandle
;
402 if (HttpService
->Tcp4ChildHandle
== NULL
) {
404 // Create a TCP4 child instance, but do not configure it. This will establish the parent-child relationship.
406 Status
= NetLibCreateServiceChild (
408 This
->DriverBindingHandle
,
409 &gEfiTcp4ServiceBindingProtocolGuid
,
410 &HttpService
->Tcp4ChildHandle
413 if (EFI_ERROR (Status
)) {
417 Status
= gBS
->OpenProtocol (
418 HttpService
->Tcp4ChildHandle
,
419 &gEfiTcp4ProtocolGuid
,
421 This
->DriverBindingHandle
,
423 EFI_OPEN_PROTOCOL_BY_DRIVER
426 if (EFI_ERROR (Status
)) {
431 return EFI_ALREADY_STARTED
;
436 HttpService
->Ip6DriverBindingHandle
= This
->DriverBindingHandle
;
438 if (HttpService
->Tcp6ChildHandle
== NULL
) {
440 // Create a TCP6 child instance, but do not configure it. This will establish the parent-child relationship.
442 Status
= NetLibCreateServiceChild (
444 This
->DriverBindingHandle
,
445 &gEfiTcp6ServiceBindingProtocolGuid
,
446 &HttpService
->Tcp6ChildHandle
449 if (EFI_ERROR (Status
)) {
453 Status
= gBS
->OpenProtocol (
454 HttpService
->Tcp6ChildHandle
,
455 &gEfiTcp6ProtocolGuid
,
457 This
->DriverBindingHandle
,
459 EFI_OPEN_PROTOCOL_BY_DRIVER
462 if (EFI_ERROR (Status
)) {
467 return EFI_ALREADY_STARTED
;
476 if (HttpService
!= NULL
) {
477 HttpCleanService (HttpService
, UsingIpv6
);
478 if (HttpService
->Tcp4ChildHandle
== NULL
&& HttpService
->Tcp6ChildHandle
== NULL
) {
479 FreePool (HttpService
);
489 Stop this driver on ControllerHandle. This is the worker function for
490 HttpDxeIp4(6)DriverBindingStop.
492 @param[in] This Protocol instance pointer.
493 @param[in] ControllerHandle Handle of device to stop driver on.
494 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
495 children is zero stop the entire bus driver.
496 @param[in] ChildHandleBuffer List of Child Handles to Stop.
497 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
499 @retval EFI_SUCCESS This driver was removed ControllerHandle.
500 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
501 @retval Others This driver was not removed from this device
507 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
508 IN EFI_HANDLE ControllerHandle
,
509 IN UINTN NumberOfChildren
,
510 IN EFI_HANDLE
*ChildHandleBuffer
,
514 EFI_HANDLE NicHandle
;
516 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
517 HTTP_SERVICE
*HttpService
;
519 HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context
;
523 // HTTP driver opens TCP4(6) child, So, Controller is a TCP4(6)
524 // child handle. Locate the Nic handle first. Then get the
525 // HTTP private data back.
527 if (IpVersion
== IP_VERSION_4
) {
529 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp4ProtocolGuid
);
532 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp6ProtocolGuid
);
535 if (NicHandle
== NULL
) {
539 Status
= gBS
->OpenProtocol (
541 &gEfiHttpServiceBindingProtocolGuid
,
542 (VOID
**) &ServiceBinding
,
543 This
->DriverBindingHandle
,
545 EFI_OPEN_PROTOCOL_GET_PROTOCOL
548 if (!EFI_ERROR (Status
)) {
550 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding
);
552 if (NumberOfChildren
!= 0) {
554 // Destroy the HTTP child instance in ChildHandleBuffer.
556 List
= &HttpService
->ChildrenList
;
557 Context
.ServiceBinding
= ServiceBinding
;
558 Context
.NumberOfChildren
= NumberOfChildren
;
559 Context
.ChildHandleBuffer
= ChildHandleBuffer
;
560 Status
= NetDestroyLinkList (
562 HttpDestroyChildEntryInHandleBuffer
,
568 HttpCleanService (HttpService
, UsingIpv6
);
570 if (HttpService
->Tcp4ChildHandle
== NULL
&& HttpService
->Tcp6ChildHandle
== NULL
) {
571 gBS
->UninstallProtocolInterface (
573 &gEfiHttpServiceBindingProtocolGuid
,
576 FreePool (HttpService
);
578 Status
= EFI_SUCCESS
;
587 Tests to see if this driver supports a given controller. If a child device is provided,
588 it further tests to see if this driver supports creating a handle for the specified child device.
590 This function checks to see if the driver specified by This supports the device specified by
591 ControllerHandle. Drivers will typically use the device path attached to
592 ControllerHandle and/or the services from the bus I/O abstraction attached to
593 ControllerHandle to determine if the driver supports ControllerHandle. This function
594 may be called many times during platform initialization. In order to reduce boot times, the tests
595 performed by this function must be very small, and take as little time as possible to execute. This
596 function must not change the state of any hardware devices, and this function must be aware that the
597 device specified by ControllerHandle may already be managed by the same driver or a
598 different driver. This function must match its calls to AllocatePages() with FreePages(),
599 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
600 Because ControllerHandle may have been previously started by the same driver, if a protocol is
601 already in the opened state, then it must not be closed with CloseProtocol(). This is required
602 to guarantee the state of ControllerHandle is not modified by this function.
604 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
605 @param[in] ControllerHandle The handle of the controller to test. This handle
606 must support a protocol interface that supplies
607 an I/O abstraction to the driver.
608 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
609 parameter is ignored by device drivers, and is optional for bus
610 drivers. For bus drivers, if this parameter is not NULL, then
611 the bus driver must determine if the bus controller specified
612 by ControllerHandle and the child controller specified
613 by RemainingDevicePath are both supported by this
616 @retval EFI_SUCCESS The device specified by ControllerHandle and
617 RemainingDevicePath is supported by the driver specified by This.
618 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
619 RemainingDevicePath is already being managed by the driver
621 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
622 RemainingDevicePath is already being managed by a different
623 driver or an application that requires exclusive access.
624 Currently not implemented.
625 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
626 RemainingDevicePath is not supported by the driver specified by This.
630 HttpDxeIp4DriverBindingSupported (
631 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
632 IN EFI_HANDLE ControllerHandle
,
633 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
636 return HttpDxeSupported (
645 Starts a device controller or a bus controller.
647 The Start() function is designed to be invoked from the EFI boot service ConnectController().
648 As a result, much of the error checking on the parameters to Start() has been moved into this
649 common boot service. It is legal to call Start() from other locations,
650 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
651 1. ControllerHandle must be a valid EFI_HANDLE.
652 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
653 EFI_DEVICE_PATH_PROTOCOL.
654 3. Prior to calling Start(), the Supported() function for the driver specified by This must
655 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
657 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
658 @param[in] ControllerHandle The handle of the controller to start. This handle
659 must support a protocol interface that supplies
660 an I/O abstraction to the driver.
661 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
662 parameter is ignored by device drivers, and is optional for bus
663 drivers. For a bus driver, if this parameter is NULL, then handles
664 for all the children of Controller are created by this driver.
665 If this parameter is not NULL and the first Device Path Node is
666 not the End of Device Path Node, then only the handle for the
667 child device specified by the first Device Path Node of
668 RemainingDevicePath is created by this driver.
669 If the first Device Path Node of RemainingDevicePath is
670 the End of Device Path Node, no child handle is created by this
673 @retval EFI_SUCCESS The device was started.
674 @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.
675 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
676 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
677 @retval Others The driver failded to start the device.
682 HttpDxeIp4DriverBindingStart (
683 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
684 IN EFI_HANDLE ControllerHandle
,
685 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
688 return HttpDxeStart (
697 Stops a device controller or a bus controller.
699 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
700 As a result, much of the error checking on the parameters to Stop() has been moved
701 into this common boot service. It is legal to call Stop() from other locations,
702 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
703 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
704 same driver's Start() function.
705 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
706 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
707 Start() function, and the Start() function must have called OpenProtocol() on
708 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
710 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
711 @param[in] ControllerHandle A handle to the device being stopped. The handle must
712 support a bus specific I/O protocol for the driver
713 to use to stop the device.
714 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
715 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
716 if NumberOfChildren is 0.
718 @retval EFI_SUCCESS The device was stopped.
719 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
724 HttpDxeIp4DriverBindingStop (
725 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
726 IN EFI_HANDLE ControllerHandle
,
727 IN UINTN NumberOfChildren
,
728 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
741 Tests to see if this driver supports a given controller. If a child device is provided,
742 it further tests to see if this driver supports creating a handle for the specified child device.
744 This function checks to see if the driver specified by This supports the device specified by
745 ControllerHandle. Drivers will typically use the device path attached to
746 ControllerHandle and/or the services from the bus I/O abstraction attached to
747 ControllerHandle to determine if the driver supports ControllerHandle. This function
748 may be called many times during platform initialization. In order to reduce boot times, the tests
749 performed by this function must be very small, and take as little time as possible to execute. This
750 function must not change the state of any hardware devices, and this function must be aware that the
751 device specified by ControllerHandle may already be managed by the same driver or a
752 different driver. This function must match its calls to AllocatePages() with FreePages(),
753 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
754 Because ControllerHandle may have been previously started by the same driver, if a protocol is
755 already in the opened state, then it must not be closed with CloseProtocol(). This is required
756 to guarantee the state of ControllerHandle is not modified by this function.
758 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
759 @param[in] ControllerHandle The handle of the controller to test. This handle
760 must support a protocol interface that supplies
761 an I/O abstraction to the driver.
762 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
763 parameter is ignored by device drivers, and is optional for bus
764 drivers. For bus drivers, if this parameter is not NULL, then
765 the bus driver must determine if the bus controller specified
766 by ControllerHandle and the child controller specified
767 by RemainingDevicePath are both supported by this
770 @retval EFI_SUCCESS The device specified by ControllerHandle and
771 RemainingDevicePath is supported by the driver specified by This.
772 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
773 RemainingDevicePath is already being managed by the driver
775 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
776 RemainingDevicePath is already being managed by a different
777 driver or an application that requires exclusive access.
778 Currently not implemented.
779 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
780 RemainingDevicePath is not supported by the driver specified by This.
784 HttpDxeIp6DriverBindingSupported (
785 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
786 IN EFI_HANDLE ControllerHandle
,
787 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
790 return HttpDxeSupported (
800 Starts a device controller or a bus controller.
802 The Start() function is designed to be invoked from the EFI boot service ConnectController().
803 As a result, much of the error checking on the parameters to Start() has been moved into this
804 common boot service. It is legal to call Start() from other locations,
805 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
806 1. ControllerHandle must be a valid EFI_HANDLE.
807 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
808 EFI_DEVICE_PATH_PROTOCOL.
809 3. Prior to calling Start(), the Supported() function for the driver specified by This must
810 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
812 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
813 @param[in] ControllerHandle The handle of the controller to start. This handle
814 must support a protocol interface that supplies
815 an I/O abstraction to the driver.
816 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
817 parameter is ignored by device drivers, and is optional for bus
818 drivers. For a bus driver, if this parameter is NULL, then handles
819 for all the children of Controller are created by this driver.
820 If this parameter is not NULL and the first Device Path Node is
821 not the End of Device Path Node, then only the handle for the
822 child device specified by the first Device Path Node of
823 RemainingDevicePath is created by this driver.
824 If the first Device Path Node of RemainingDevicePath is
825 the End of Device Path Node, no child handle is created by this
828 @retval EFI_SUCCESS The device was started.
829 @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.
830 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
831 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
832 @retval Others The driver failded to start the device.
837 HttpDxeIp6DriverBindingStart (
838 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
839 IN EFI_HANDLE ControllerHandle
,
840 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
843 return HttpDxeStart (
852 Stops a device controller or a bus controller.
854 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
855 As a result, much of the error checking on the parameters to Stop() has been moved
856 into this common boot service. It is legal to call Stop() from other locations,
857 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
858 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
859 same driver's Start() function.
860 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
861 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
862 Start() function, and the Start() function must have called OpenProtocol() on
863 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
865 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
866 @param[in] ControllerHandle A handle to the device being stopped. The handle must
867 support a bus specific I/O protocol for the driver
868 to use to stop the device.
869 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
870 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
871 if NumberOfChildren is 0.
873 @retval EFI_SUCCESS The device was stopped.
874 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
879 HttpDxeIp6DriverBindingStop (
880 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
881 IN EFI_HANDLE ControllerHandle
,
882 IN UINTN NumberOfChildren
,
883 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
895 Creates a child handle and installs a protocol.
897 The CreateChild() function installs a protocol on ChildHandle.
898 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
899 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
901 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
902 @param ChildHandle Pointer to the handle of the child to create. If it is NULL,
903 then a new handle is created. If it is a pointer to an existing UEFI handle,
904 then the protocol is added to the existing UEFI handle.
906 @retval EFI_SUCCES The protocol was added to ChildHandle.
907 @retval EFI_INVALID_PARAMETER This is NULL, or ChildHandle is NULL.
908 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
910 @retval other The child handle was not created.
915 HttpServiceBindingCreateChild (
916 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
917 IN OUT EFI_HANDLE
*ChildHandle
920 HTTP_SERVICE
*HttpService
;
921 HTTP_PROTOCOL
*HttpInstance
;
925 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
926 return EFI_INVALID_PARAMETER
;
929 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (This
);
930 HttpInstance
= AllocateZeroPool (sizeof (HTTP_PROTOCOL
));
931 if (HttpInstance
== NULL
) {
932 return EFI_OUT_OF_RESOURCES
;
935 HttpInstance
->Signature
= HTTP_PROTOCOL_SIGNATURE
;
936 HttpInstance
->Service
= HttpService
;
937 HttpInstance
->Method
= HttpMethodMax
;
939 CopyMem (&HttpInstance
->Http
, &mEfiHttpTemplate
, sizeof (HttpInstance
->Http
));
940 NetMapInit (&HttpInstance
->TxTokens
);
941 NetMapInit (&HttpInstance
->RxTokens
);
944 // Install HTTP protocol onto ChildHandle
946 Status
= gBS
->InstallMultipleProtocolInterfaces (
948 &gEfiHttpProtocolGuid
,
953 if (EFI_ERROR (Status
)) {
957 HttpInstance
->Handle
= *ChildHandle
;
960 // Add it to the HTTP service's child list.
962 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
964 InsertTailList (&HttpService
->ChildrenList
, &HttpInstance
->Link
);
965 HttpService
->ChildrenNumber
++;
967 gBS
->RestoreTPL (OldTpl
);
973 NetMapClean (&HttpInstance
->TxTokens
);
974 NetMapClean (&HttpInstance
->RxTokens
);
975 FreePool (HttpInstance
);
981 Destroys a child handle with a protocol installed on it.
983 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
984 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
985 last protocol on ChildHandle, then ChildHandle is destroyed.
987 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
988 @param ChildHandle Handle of the child to destroy
990 @retval EFI_SUCCES The protocol was removed from ChildHandle.
991 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
992 @retval EFI_INVALID_PARAMETER Child handle is NULL.
993 @retval other The child handle was not destroyed
998 HttpServiceBindingDestroyChild (
999 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
1000 IN EFI_HANDLE ChildHandle
1003 HTTP_SERVICE
*HttpService
;
1004 HTTP_PROTOCOL
*HttpInstance
;
1005 EFI_HTTP_PROTOCOL
*Http
;
1009 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
1010 return EFI_INVALID_PARAMETER
;
1013 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (This
);
1014 Status
= gBS
->OpenProtocol (
1016 &gEfiHttpProtocolGuid
,
1020 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1022 if (EFI_ERROR (Status
)) {
1023 return EFI_UNSUPPORTED
;
1026 HttpInstance
= HTTP_INSTANCE_FROM_PROTOCOL (Http
);
1027 if (HttpInstance
->Service
!= HttpService
) {
1028 return EFI_INVALID_PARAMETER
;
1031 if (HttpInstance
->InDestroy
) {
1035 HttpInstance
->InDestroy
= TRUE
;
1038 // Uninstall the HTTP protocol.
1040 Status
= gBS
->UninstallProtocolInterface (
1042 &gEfiHttpProtocolGuid
,
1046 if (EFI_ERROR (Status
)) {
1047 HttpInstance
->InDestroy
= FALSE
;
1051 HttpCleanProtocol (HttpInstance
);
1053 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1055 RemoveEntryList (&HttpInstance
->Link
);
1056 HttpService
->ChildrenNumber
--;
1058 gBS
->RestoreTPL (OldTpl
);
1060 FreePool (HttpInstance
);