2 The driver binding and service binding protocol for HttpDxe driver.
4 Copyright (c) 2015 - 2016, 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[in] ImageHandle The HTTP driver's image handle.
49 @param[out] ServiceData Point to HTTP driver private instance.
51 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
52 @retval EFI_SUCCESS A new HTTP driver private instance is created.
57 IN EFI_HANDLE Controller
,
58 IN EFI_HANDLE ImageHandle
,
59 OUT HTTP_SERVICE
**ServiceData
62 HTTP_SERVICE
*HttpService
;
64 ASSERT (ServiceData
!= NULL
);
67 HttpService
= AllocateZeroPool (sizeof (HTTP_SERVICE
));
68 if (HttpService
== NULL
) {
69 return EFI_OUT_OF_RESOURCES
;
72 HttpService
->Signature
= HTTP_SERVICE_SIGNATURE
;
73 HttpService
->ServiceBinding
.CreateChild
= HttpServiceBindingCreateChild
;
74 HttpService
->ServiceBinding
.DestroyChild
= HttpServiceBindingDestroyChild
;
75 HttpService
->ImageHandle
= ImageHandle
;
76 HttpService
->ControllerHandle
= Controller
;
77 HttpService
->ChildrenNumber
= 0;
78 InitializeListHead (&HttpService
->ChildrenList
);
80 *ServiceData
= HttpService
;
85 Release all the resource used the HTTP service binding instance.
87 @param[in] HttpService The HTTP private instance.
88 @param[in] UsingIpv6 Indicate use TCP4 protocol or TCP6 protocol.
89 if TRUE, use Tcp6 protocol.
90 if FALSE, use Tcp4 protocl.
94 IN HTTP_SERVICE
*HttpService
,
99 if (HttpService
== NULL
) {
103 if (HttpService
->Tcp4ChildHandle
!= NULL
) {
105 HttpService
->Tcp4ChildHandle
,
106 &gEfiTcp4ProtocolGuid
,
107 HttpService
->ImageHandle
,
108 HttpService
->ControllerHandle
111 NetLibDestroyServiceChild (
112 HttpService
->ControllerHandle
,
113 HttpService
->ImageHandle
,
114 &gEfiTcp4ServiceBindingProtocolGuid
,
115 HttpService
->Tcp4ChildHandle
118 HttpService
->Tcp4ChildHandle
= NULL
;
121 if (HttpService
->Tcp6ChildHandle
!= NULL
) {
123 HttpService
->Tcp6ChildHandle
,
124 &gEfiTcp6ProtocolGuid
,
125 HttpService
->ImageHandle
,
126 HttpService
->ControllerHandle
129 NetLibDestroyServiceChild (
130 HttpService
->ControllerHandle
,
131 HttpService
->ImageHandle
,
132 &gEfiTcp6ServiceBindingProtocolGuid
,
133 HttpService
->Tcp6ChildHandle
136 HttpService
->Tcp6ChildHandle
= NULL
;
143 The event process routine when the http utilities protocol is installed
146 @param[in] Event Not used.
147 @param[in] Context The pointer to the IP4 config2 instance data or IP6 Config instance data.
152 HttpUtilitiesInstalledCallback (
157 gBS
->LocateProtocol (
158 &gEfiHttpUtilitiesProtocolGuid
,
160 (VOID
**) &mHttpUtilities
164 // Close the event if Http utilities protocol is loacted.
166 if (mHttpUtilities
!= NULL
&& Event
!= NULL
) {
167 gBS
->CloseEvent (Event
);
172 This is the declaration of an EFI image entry point. This entry point is
173 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
174 both device drivers and bus drivers.
176 @param ImageHandle The firmware allocated handle for the UEFI image.
177 @param SystemTable A pointer to the EFI System Table.
179 @retval EFI_SUCCESS The operation completed successfully.
180 @retval Others An unexpected error occurred.
185 HttpDxeDriverEntryPoint (
186 IN EFI_HANDLE ImageHandle
,
187 IN EFI_SYSTEM_TABLE
*SystemTable
193 gBS
->LocateProtocol (
194 &gEfiHttpUtilitiesProtocolGuid
,
196 (VOID
**) &mHttpUtilities
199 if (mHttpUtilities
== NULL
) {
201 // No Http utilities protocol, register a notify.
203 EfiCreateProtocolNotifyEvent (
204 &gEfiHttpUtilitiesProtocolGuid
,
206 HttpUtilitiesInstalledCallback
,
213 // Install UEFI Driver Model protocol(s).
215 Status
= EfiLibInstallDriverBindingComponentName2 (
218 &gHttpDxeIp4DriverBinding
,
220 &gHttpDxeComponentName
,
221 &gHttpDxeComponentName2
223 if (EFI_ERROR (Status
)) {
227 Status
= EfiLibInstallDriverBindingComponentName2 (
230 &gHttpDxeIp6DriverBinding
,
232 &gHttpDxeComponentName
,
233 &gHttpDxeComponentName2
235 if (EFI_ERROR (Status
)) {
236 gBS
->UninstallMultipleProtocolInterfaces (
238 &gEfiDriverBindingProtocolGuid
,
239 &gHttpDxeIp4DriverBinding
,
240 &gEfiComponentName2ProtocolGuid
,
241 &gHttpDxeComponentName2
,
242 &gEfiComponentNameProtocolGuid
,
243 &gHttpDxeComponentName
,
251 Callback function which provided by user to remove one node in NetDestroyLinkList process.
253 @param[in] Entry The entry to be removed.
254 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
256 @retval EFI_INVALID_PARAMETER Any input parameter is NULL.
257 @retval EFI_SUCCESS The entry has been removed successfully.
258 @retval Others Fail to remove the entry.
263 HttpDestroyChildEntryInHandleBuffer (
264 IN LIST_ENTRY
*Entry
,
268 HTTP_PROTOCOL
*HttpInstance
;
269 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
270 UINTN NumberOfChildren
;
271 EFI_HANDLE
*ChildHandleBuffer
;
273 if (Entry
== NULL
|| Context
== NULL
) {
274 return EFI_INVALID_PARAMETER
;
277 HttpInstance
= NET_LIST_USER_STRUCT_S (Entry
, HTTP_PROTOCOL
, Link
, HTTP_PROTOCOL_SIGNATURE
);
278 ServiceBinding
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->ServiceBinding
;
279 NumberOfChildren
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->NumberOfChildren
;
280 ChildHandleBuffer
= ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*) Context
)->ChildHandleBuffer
;
282 if (!NetIsInHandleBuffer (HttpInstance
->Handle
, NumberOfChildren
, ChildHandleBuffer
)) {
286 return ServiceBinding
->DestroyChild (ServiceBinding
, HttpInstance
->Handle
);
290 Test to see if this driver supports ControllerHandle. This is the worker function for
291 HttpDxeIp4(6)DriverBindingSupported.
293 @param[in] This The pointer to the driver binding protocol.
294 @param[in] ControllerHandle The handle of device to be tested.
295 @param[in] RemainingDevicePath Optional parameter used to pick a specific child
296 device to be started.
297 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
299 @retval EFI_SUCCESS This driver supports this device.
300 @retval EFI_UNSUPPORTED This driver does not support this device.
306 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
307 IN EFI_HANDLE ControllerHandle
,
308 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
313 EFI_GUID
*TcpServiceBindingProtocolGuid
;
315 if (IpVersion
== IP_VERSION_4
) {
316 TcpServiceBindingProtocolGuid
= &gEfiTcp4ServiceBindingProtocolGuid
;
318 TcpServiceBindingProtocolGuid
= &gEfiTcp6ServiceBindingProtocolGuid
;
321 Status
= gBS
->OpenProtocol (
323 TcpServiceBindingProtocolGuid
,
325 This
->DriverBindingHandle
,
327 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
330 if (EFI_ERROR (Status
)) {
331 return EFI_UNSUPPORTED
;
338 Start this driver on ControllerHandle. This is the worker function for
339 HttpDxeIp4(6)DriverBindingStart.
341 @param[in] This The pointer to the driver binding protocol.
342 @param[in] ControllerHandle The handle of device to be started.
343 @param[in] RemainingDevicePath Optional parameter used to pick a specific child
344 device to be started.
345 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
348 @retval EFI_SUCCESS This driver is installed to ControllerHandle.
349 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
350 @retval other This driver does not support this device.
356 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
357 IN EFI_HANDLE ControllerHandle
,
358 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
363 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
364 HTTP_SERVICE
*HttpService
;
371 // Test for the Http service binding protocol
373 Status
= gBS
->OpenProtocol (
375 &gEfiHttpServiceBindingProtocolGuid
,
376 (VOID
**) &ServiceBinding
,
377 This
->DriverBindingHandle
,
379 EFI_OPEN_PROTOCOL_GET_PROTOCOL
382 if (!EFI_ERROR (Status
)) {
383 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding
);
385 Status
= HttpCreateService (ControllerHandle
, This
->DriverBindingHandle
, &HttpService
);
386 if (EFI_ERROR (Status
)) {
390 ASSERT (HttpService
!= NULL
);
393 // Install the HttpServiceBinding Protocol onto Controller
395 Status
= gBS
->InstallMultipleProtocolInterfaces (
397 &gEfiHttpServiceBindingProtocolGuid
,
398 &HttpService
->ServiceBinding
,
402 if (EFI_ERROR (Status
)) {
407 if (IpVersion
== IP_VERSION_4
) {
409 if (HttpService
->Tcp4ChildHandle
== NULL
) {
411 // Create a TCP4 child instance, but do not configure it. This will establish the parent-child relationship.
413 Status
= NetLibCreateServiceChild (
415 This
->DriverBindingHandle
,
416 &gEfiTcp4ServiceBindingProtocolGuid
,
417 &HttpService
->Tcp4ChildHandle
420 if (EFI_ERROR (Status
)) {
424 Status
= gBS
->OpenProtocol (
425 HttpService
->Tcp4ChildHandle
,
426 &gEfiTcp4ProtocolGuid
,
428 This
->DriverBindingHandle
,
430 EFI_OPEN_PROTOCOL_BY_DRIVER
433 if (EFI_ERROR (Status
)) {
438 return EFI_ALREADY_STARTED
;
444 if (HttpService
->Tcp6ChildHandle
== NULL
) {
446 // Create a TCP6 child instance, but do not configure it. This will establish the parent-child relationship.
448 Status
= NetLibCreateServiceChild (
450 This
->DriverBindingHandle
,
451 &gEfiTcp6ServiceBindingProtocolGuid
,
452 &HttpService
->Tcp6ChildHandle
455 if (EFI_ERROR (Status
)) {
459 Status
= gBS
->OpenProtocol (
460 HttpService
->Tcp6ChildHandle
,
461 &gEfiTcp6ProtocolGuid
,
463 This
->DriverBindingHandle
,
465 EFI_OPEN_PROTOCOL_BY_DRIVER
468 if (EFI_ERROR (Status
)) {
473 return EFI_ALREADY_STARTED
;
482 if (HttpService
!= NULL
) {
483 HttpCleanService (HttpService
, UsingIpv6
);
484 if (HttpService
->Tcp4ChildHandle
== NULL
&& HttpService
->Tcp6ChildHandle
== NULL
) {
485 FreePool (HttpService
);
495 Stop this driver on ControllerHandle. This is the worker function for
496 HttpDxeIp4(6)DriverBindingStop.
498 @param[in] This Protocol instance pointer.
499 @param[in] ControllerHandle Handle of device to stop driver on.
500 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
501 children is zero stop the entire bus driver.
502 @param[in] ChildHandleBuffer List of Child Handles to Stop.
503 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
505 @retval EFI_SUCCESS This driver was removed ControllerHandle.
506 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
507 @retval Others This driver was not removed from this device
513 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
514 IN EFI_HANDLE ControllerHandle
,
515 IN UINTN NumberOfChildren
,
516 IN EFI_HANDLE
*ChildHandleBuffer
,
520 EFI_HANDLE NicHandle
;
522 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
523 HTTP_SERVICE
*HttpService
;
525 HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context
;
529 // HTTP driver opens TCP4(6) child, So, Controller is a TCP4(6)
530 // child handle. Locate the Nic handle first. Then get the
531 // HTTP private data back.
533 if (IpVersion
== IP_VERSION_4
) {
535 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp4ProtocolGuid
);
538 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp6ProtocolGuid
);
541 if (NicHandle
== NULL
) {
545 Status
= gBS
->OpenProtocol (
547 &gEfiHttpServiceBindingProtocolGuid
,
548 (VOID
**) &ServiceBinding
,
549 This
->DriverBindingHandle
,
551 EFI_OPEN_PROTOCOL_GET_PROTOCOL
554 if (!EFI_ERROR (Status
)) {
556 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding
);
558 if (NumberOfChildren
!= 0) {
560 // Destroy the HTTP child instance in ChildHandleBuffer.
562 List
= &HttpService
->ChildrenList
;
563 Context
.ServiceBinding
= ServiceBinding
;
564 Context
.NumberOfChildren
= NumberOfChildren
;
565 Context
.ChildHandleBuffer
= ChildHandleBuffer
;
566 Status
= NetDestroyLinkList (
568 HttpDestroyChildEntryInHandleBuffer
,
574 HttpCleanService (HttpService
, UsingIpv6
);
576 if (HttpService
->Tcp4ChildHandle
== NULL
&& HttpService
->Tcp6ChildHandle
== NULL
) {
577 gBS
->UninstallProtocolInterface (
579 &gEfiHttpServiceBindingProtocolGuid
,
582 FreePool (HttpService
);
584 Status
= EFI_SUCCESS
;
593 Tests to see if this driver supports a given controller. If a child device is provided,
594 it further tests to see if this driver supports creating a handle for the specified child device.
596 This function checks to see if the driver specified by This supports the device specified by
597 ControllerHandle. Drivers will typically use the device path attached to
598 ControllerHandle and/or the services from the bus I/O abstraction attached to
599 ControllerHandle to determine if the driver supports ControllerHandle. This function
600 may be called many times during platform initialization. In order to reduce boot times, the tests
601 performed by this function must be very small, and take as little time as possible to execute. This
602 function must not change the state of any hardware devices, and this function must be aware that the
603 device specified by ControllerHandle may already be managed by the same driver or a
604 different driver. This function must match its calls to AllocatePages() with FreePages(),
605 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
606 Because ControllerHandle may have been previously started by the same driver, if a protocol is
607 already in the opened state, then it must not be closed with CloseProtocol(). This is required
608 to guarantee the state of ControllerHandle is not modified by this function.
610 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
611 @param[in] ControllerHandle The handle of the controller to test. This handle
612 must support a protocol interface that supplies
613 an I/O abstraction to the driver.
614 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
615 parameter is ignored by device drivers, and is optional for bus
616 drivers. For bus drivers, if this parameter is not NULL, then
617 the bus driver must determine if the bus controller specified
618 by ControllerHandle and the child controller specified
619 by RemainingDevicePath are both supported by this
622 @retval EFI_SUCCESS The device specified by ControllerHandle and
623 RemainingDevicePath is supported by the driver specified by This.
624 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
625 RemainingDevicePath is already being managed by the driver
627 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
628 RemainingDevicePath is already being managed by a different
629 driver or an application that requires exclusive access.
630 Currently not implemented.
631 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
632 RemainingDevicePath is not supported by the driver specified by This.
636 HttpDxeIp4DriverBindingSupported (
637 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
638 IN EFI_HANDLE ControllerHandle
,
639 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
642 return HttpDxeSupported (
651 Starts a device controller or a bus controller.
653 The Start() function is designed to be invoked from the EFI boot service ConnectController().
654 As a result, much of the error checking on the parameters to Start() has been moved into this
655 common boot service. It is legal to call Start() from other locations,
656 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
657 1. ControllerHandle must be a valid EFI_HANDLE.
658 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
659 EFI_DEVICE_PATH_PROTOCOL.
660 3. Prior to calling Start(), the Supported() function for the driver specified by This must
661 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
663 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
664 @param[in] ControllerHandle The handle of the controller to start. This handle
665 must support a protocol interface that supplies
666 an I/O abstraction to the driver.
667 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
668 parameter is ignored by device drivers, and is optional for bus
669 drivers. For a bus driver, if this parameter is NULL, then handles
670 for all the children of Controller are created by this driver.
671 If this parameter is not NULL and the first Device Path Node is
672 not the End of Device Path Node, then only the handle for the
673 child device specified by the first Device Path Node of
674 RemainingDevicePath is created by this driver.
675 If the first Device Path Node of RemainingDevicePath is
676 the End of Device Path Node, no child handle is created by this
679 @retval EFI_SUCCESS The device was started.
680 @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.
681 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
682 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
683 @retval Others The driver failded to start the device.
688 HttpDxeIp4DriverBindingStart (
689 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
690 IN EFI_HANDLE ControllerHandle
,
691 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
694 return HttpDxeStart (
703 Stops a device controller or a bus controller.
705 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
706 As a result, much of the error checking on the parameters to Stop() has been moved
707 into this common boot service. It is legal to call Stop() from other locations,
708 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
709 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
710 same driver's Start() function.
711 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
712 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
713 Start() function, and the Start() function must have called OpenProtocol() on
714 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
716 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
717 @param[in] ControllerHandle A handle to the device being stopped. The handle must
718 support a bus specific I/O protocol for the driver
719 to use to stop the device.
720 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
721 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
722 if NumberOfChildren is 0.
724 @retval EFI_SUCCESS The device was stopped.
725 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
730 HttpDxeIp4DriverBindingStop (
731 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
732 IN EFI_HANDLE ControllerHandle
,
733 IN UINTN NumberOfChildren
,
734 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
747 Tests to see if this driver supports a given controller. If a child device is provided,
748 it further tests to see if this driver supports creating a handle for the specified child device.
750 This function checks to see if the driver specified by This supports the device specified by
751 ControllerHandle. Drivers will typically use the device path attached to
752 ControllerHandle and/or the services from the bus I/O abstraction attached to
753 ControllerHandle to determine if the driver supports ControllerHandle. This function
754 may be called many times during platform initialization. In order to reduce boot times, the tests
755 performed by this function must be very small, and take as little time as possible to execute. This
756 function must not change the state of any hardware devices, and this function must be aware that the
757 device specified by ControllerHandle may already be managed by the same driver or a
758 different driver. This function must match its calls to AllocatePages() with FreePages(),
759 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
760 Because ControllerHandle may have been previously started by the same driver, if a protocol is
761 already in the opened state, then it must not be closed with CloseProtocol(). This is required
762 to guarantee the state of ControllerHandle is not modified by this function.
764 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
765 @param[in] ControllerHandle The handle of the controller to test. This handle
766 must support a protocol interface that supplies
767 an I/O abstraction to the driver.
768 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
769 parameter is ignored by device drivers, and is optional for bus
770 drivers. For bus drivers, if this parameter is not NULL, then
771 the bus driver must determine if the bus controller specified
772 by ControllerHandle and the child controller specified
773 by RemainingDevicePath are both supported by this
776 @retval EFI_SUCCESS The device specified by ControllerHandle and
777 RemainingDevicePath is supported by the driver specified by This.
778 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
779 RemainingDevicePath is already being managed by the driver
781 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
782 RemainingDevicePath is already being managed by a different
783 driver or an application that requires exclusive access.
784 Currently not implemented.
785 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
786 RemainingDevicePath is not supported by the driver specified by This.
790 HttpDxeIp6DriverBindingSupported (
791 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
792 IN EFI_HANDLE ControllerHandle
,
793 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
796 return HttpDxeSupported (
806 Starts a device controller or a bus controller.
808 The Start() function is designed to be invoked from the EFI boot service ConnectController().
809 As a result, much of the error checking on the parameters to Start() has been moved into this
810 common boot service. It is legal to call Start() from other locations,
811 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
812 1. ControllerHandle must be a valid EFI_HANDLE.
813 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
814 EFI_DEVICE_PATH_PROTOCOL.
815 3. Prior to calling Start(), the Supported() function for the driver specified by This must
816 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
818 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
819 @param[in] ControllerHandle The handle of the controller to start. This handle
820 must support a protocol interface that supplies
821 an I/O abstraction to the driver.
822 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
823 parameter is ignored by device drivers, and is optional for bus
824 drivers. For a bus driver, if this parameter is NULL, then handles
825 for all the children of Controller are created by this driver.
826 If this parameter is not NULL and the first Device Path Node is
827 not the End of Device Path Node, then only the handle for the
828 child device specified by the first Device Path Node of
829 RemainingDevicePath is created by this driver.
830 If the first Device Path Node of RemainingDevicePath is
831 the End of Device Path Node, no child handle is created by this
834 @retval EFI_SUCCESS The device was started.
835 @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.
836 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
837 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
838 @retval Others The driver failded to start the device.
843 HttpDxeIp6DriverBindingStart (
844 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
845 IN EFI_HANDLE ControllerHandle
,
846 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
849 return HttpDxeStart (
858 Stops a device controller or a bus controller.
860 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
861 As a result, much of the error checking on the parameters to Stop() has been moved
862 into this common boot service. It is legal to call Stop() from other locations,
863 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
864 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
865 same driver's Start() function.
866 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
867 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
868 Start() function, and the Start() function must have called OpenProtocol() on
869 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
871 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
872 @param[in] ControllerHandle A handle to the device being stopped. The handle must
873 support a bus specific I/O protocol for the driver
874 to use to stop the device.
875 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
876 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
877 if NumberOfChildren is 0.
879 @retval EFI_SUCCESS The device was stopped.
880 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
885 HttpDxeIp6DriverBindingStop (
886 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
887 IN EFI_HANDLE ControllerHandle
,
888 IN UINTN NumberOfChildren
,
889 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
901 Creates a child handle and installs a protocol.
903 The CreateChild() function installs a protocol on ChildHandle.
904 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
905 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
907 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
908 @param ChildHandle Pointer to the handle of the child to create. If it is NULL,
909 then a new handle is created. If it is a pointer to an existing UEFI handle,
910 then the protocol is added to the existing UEFI handle.
912 @retval EFI_SUCCES The protocol was added to ChildHandle.
913 @retval EFI_INVALID_PARAMETER This is NULL, or ChildHandle is NULL.
914 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
916 @retval other The child handle was not created.
921 HttpServiceBindingCreateChild (
922 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
923 IN OUT EFI_HANDLE
*ChildHandle
926 HTTP_SERVICE
*HttpService
;
927 HTTP_PROTOCOL
*HttpInstance
;
931 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
932 return EFI_INVALID_PARAMETER
;
935 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (This
);
936 HttpInstance
= AllocateZeroPool (sizeof (HTTP_PROTOCOL
));
937 if (HttpInstance
== NULL
) {
938 return EFI_OUT_OF_RESOURCES
;
941 HttpInstance
->Signature
= HTTP_PROTOCOL_SIGNATURE
;
942 HttpInstance
->Service
= HttpService
;
943 HttpInstance
->Method
= HttpMethodMax
;
945 CopyMem (&HttpInstance
->Http
, &mEfiHttpTemplate
, sizeof (HttpInstance
->Http
));
946 NetMapInit (&HttpInstance
->TxTokens
);
947 NetMapInit (&HttpInstance
->RxTokens
);
950 // Install HTTP protocol onto ChildHandle
952 Status
= gBS
->InstallMultipleProtocolInterfaces (
954 &gEfiHttpProtocolGuid
,
959 if (EFI_ERROR (Status
)) {
963 HttpInstance
->Handle
= *ChildHandle
;
966 // Add it to the HTTP service's child list.
968 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
970 InsertTailList (&HttpService
->ChildrenList
, &HttpInstance
->Link
);
971 HttpService
->ChildrenNumber
++;
973 gBS
->RestoreTPL (OldTpl
);
979 NetMapClean (&HttpInstance
->TxTokens
);
980 NetMapClean (&HttpInstance
->RxTokens
);
981 FreePool (HttpInstance
);
987 Destroys a child handle with a protocol installed on it.
989 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
990 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
991 last protocol on ChildHandle, then ChildHandle is destroyed.
993 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
994 @param ChildHandle Handle of the child to destroy
996 @retval EFI_SUCCES The protocol was removed from ChildHandle.
997 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
998 @retval EFI_INVALID_PARAMETER Child handle is NULL.
999 @retval other The child handle was not destroyed
1004 HttpServiceBindingDestroyChild (
1005 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
1006 IN EFI_HANDLE ChildHandle
1009 HTTP_SERVICE
*HttpService
;
1010 HTTP_PROTOCOL
*HttpInstance
;
1011 EFI_HTTP_PROTOCOL
*Http
;
1015 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
1016 return EFI_INVALID_PARAMETER
;
1019 HttpService
= HTTP_SERVICE_FROM_PROTOCOL (This
);
1020 Status
= gBS
->OpenProtocol (
1022 &gEfiHttpProtocolGuid
,
1026 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1028 if (EFI_ERROR (Status
)) {
1029 return EFI_UNSUPPORTED
;
1032 HttpInstance
= HTTP_INSTANCE_FROM_PROTOCOL (Http
);
1033 if (HttpInstance
->Service
!= HttpService
) {
1034 return EFI_INVALID_PARAMETER
;
1037 if (HttpInstance
->InDestroy
) {
1041 HttpInstance
->InDestroy
= TRUE
;
1044 // Uninstall the HTTP protocol.
1046 Status
= gBS
->UninstallProtocolInterface (
1048 &gEfiHttpProtocolGuid
,
1052 if (EFI_ERROR (Status
)) {
1053 HttpInstance
->InDestroy
= FALSE
;
1057 HttpCleanProtocol (HttpInstance
);
1059 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1061 RemoveEntryList (&HttpInstance
->Link
);
1062 HttpService
->ChildrenNumber
--;
1064 gBS
->RestoreTPL (OldTpl
);
1066 FreePool (HttpInstance
);