]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/HttpBootDxe/HttpBootDxe.c
NetworkPkg: Apply uncrustify changes
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootDxe.c
1 /** @file
2 Driver Binding functions implementation for UEFI HTTP boot.
3
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "HttpBootDxe.h"
10
11 ///
12 /// Driver Binding Protocol instance
13 ///
14 EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp4DxeDriverBinding = {
15 HttpBootIp4DxeDriverBindingSupported,
16 HttpBootIp4DxeDriverBindingStart,
17 HttpBootIp4DxeDriverBindingStop,
18 HTTP_BOOT_DXE_VERSION,
19 NULL,
20 NULL
21 };
22
23 EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = {
24 HttpBootIp6DxeDriverBindingSupported,
25 HttpBootIp6DxeDriverBindingStart,
26 HttpBootIp6DxeDriverBindingStop,
27 HTTP_BOOT_DXE_VERSION,
28 NULL,
29 NULL
30 };
31
32 /**
33 Check whether UNDI protocol supports IPv6.
34
35 @param[in] Private Pointer to HTTP_BOOT_PRIVATE_DATA.
36 @param[out] Ipv6Support TRUE if UNDI supports IPv6.
37
38 @retval EFI_SUCCESS Get the result whether UNDI supports IPv6 by NII or AIP protocol successfully.
39 @retval EFI_NOT_FOUND Don't know whether UNDI supports IPv6 since NII or AIP is not available.
40
41 **/
42 EFI_STATUS
43 HttpBootCheckIpv6Support (
44 IN HTTP_BOOT_PRIVATE_DATA *Private,
45 OUT BOOLEAN *Ipv6Support
46 )
47 {
48 EFI_HANDLE Handle;
49 EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
50 EFI_STATUS Status;
51 EFI_GUID *InfoTypesBuffer;
52 UINTN InfoTypeBufferCount;
53 UINTN TypeIndex;
54 BOOLEAN Supported;
55 VOID *InfoBlock;
56 UINTN InfoBlockSize;
57
58 ASSERT (Private != NULL && Ipv6Support != NULL);
59
60 //
61 // Check whether the UNDI supports IPv6 by NII protocol.
62 //
63 if (Private->Nii != NULL) {
64 *Ipv6Support = Private->Nii->Ipv6Supported;
65 return EFI_SUCCESS;
66 }
67
68 //
69 // Get the NIC handle by SNP protocol.
70 //
71 Handle = NetLibGetSnpHandle (Private->Controller, NULL);
72 if (Handle == NULL) {
73 return EFI_NOT_FOUND;
74 }
75
76 Aip = NULL;
77 Status = gBS->HandleProtocol (
78 Handle,
79 &gEfiAdapterInformationProtocolGuid,
80 (VOID *)&Aip
81 );
82 if (EFI_ERROR (Status) || (Aip == NULL)) {
83 return EFI_NOT_FOUND;
84 }
85
86 InfoTypesBuffer = NULL;
87 InfoTypeBufferCount = 0;
88 Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
89 if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) {
90 FreePool (InfoTypesBuffer);
91 return EFI_NOT_FOUND;
92 }
93
94 Supported = FALSE;
95 for (TypeIndex = 0; TypeIndex < InfoTypeBufferCount; TypeIndex++) {
96 if (CompareGuid (&InfoTypesBuffer[TypeIndex], &gEfiAdapterInfoUndiIpv6SupportGuid)) {
97 Supported = TRUE;
98 break;
99 }
100 }
101
102 FreePool (InfoTypesBuffer);
103 if (!Supported) {
104 return EFI_NOT_FOUND;
105 }
106
107 //
108 // We now have adapter information block.
109 //
110 InfoBlock = NULL;
111 InfoBlockSize = 0;
112 Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
113 if (EFI_ERROR (Status) || (InfoBlock == NULL)) {
114 FreePool (InfoBlock);
115 return EFI_NOT_FOUND;
116 }
117
118 *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InfoBlock)->Ipv6Support;
119 FreePool (InfoBlock);
120
121 return EFI_SUCCESS;
122 }
123
124 /**
125 Destroy the HTTP child based on IPv4 stack.
126
127 @param[in] This Pointer to the EFI_DRIVER_BINDING_PROTOCOL.
128 @param[in] Private Pointer to HTTP_BOOT_PRIVATE_DATA.
129
130 **/
131 VOID
132 HttpBootDestroyIp4Children (
133 IN EFI_DRIVER_BINDING_PROTOCOL *This,
134 IN HTTP_BOOT_PRIVATE_DATA *Private
135 )
136 {
137 ASSERT (This != NULL);
138 ASSERT (Private != NULL);
139
140 if (Private->Dhcp4Child != NULL) {
141 gBS->CloseProtocol (
142 Private->Dhcp4Child,
143 &gEfiDhcp4ProtocolGuid,
144 This->DriverBindingHandle,
145 Private->Controller
146 );
147
148 NetLibDestroyServiceChild (
149 Private->Controller,
150 This->DriverBindingHandle,
151 &gEfiDhcp4ServiceBindingProtocolGuid,
152 Private->Dhcp4Child
153 );
154 }
155
156 if ((Private->Ip6Nic == NULL) && Private->HttpCreated) {
157 HttpIoDestroyIo (&Private->HttpIo);
158 Private->HttpCreated = FALSE;
159 }
160
161 if (Private->Ip4Nic != NULL) {
162 gBS->CloseProtocol (
163 Private->Controller,
164 &gEfiCallerIdGuid,
165 This->DriverBindingHandle,
166 Private->Ip4Nic->Controller
167 );
168
169 gBS->UninstallMultipleProtocolInterfaces (
170 Private->Ip4Nic->Controller,
171 &gEfiLoadFileProtocolGuid,
172 &Private->Ip4Nic->LoadFile,
173 &gEfiDevicePathProtocolGuid,
174 Private->Ip4Nic->DevicePath,
175 NULL
176 );
177 FreePool (Private->Ip4Nic);
178 Private->Ip4Nic = NULL;
179 }
180 }
181
182 /**
183 Destroy the HTTP child based on IPv6 stack.
184
185 @param[in] This Pointer to the EFI_DRIVER_BINDING_PROTOCOL.
186 @param[in] Private Pointer to HTTP_BOOT_PRIVATE_DATA.
187
188 **/
189 VOID
190 HttpBootDestroyIp6Children (
191 IN EFI_DRIVER_BINDING_PROTOCOL *This,
192 IN HTTP_BOOT_PRIVATE_DATA *Private
193 )
194 {
195 ASSERT (This != NULL);
196 ASSERT (Private != NULL);
197
198 if (Private->Ip6Child != NULL) {
199 gBS->CloseProtocol (
200 Private->Ip6Child,
201 &gEfiIp6ProtocolGuid,
202 This->DriverBindingHandle,
203 Private->Controller
204 );
205
206 NetLibDestroyServiceChild (
207 Private->Controller,
208 This->DriverBindingHandle,
209 &gEfiIp6ServiceBindingProtocolGuid,
210 Private->Ip6Child
211 );
212 }
213
214 if (Private->Dhcp6Child != NULL) {
215 gBS->CloseProtocol (
216 Private->Dhcp6Child,
217 &gEfiDhcp6ProtocolGuid,
218 This->DriverBindingHandle,
219 Private->Controller
220 );
221
222 NetLibDestroyServiceChild (
223 Private->Controller,
224 This->DriverBindingHandle,
225 &gEfiDhcp6ServiceBindingProtocolGuid,
226 Private->Dhcp6Child
227 );
228 }
229
230 if ((Private->Ip4Nic == NULL) && Private->HttpCreated) {
231 HttpIoDestroyIo (&Private->HttpIo);
232 Private->HttpCreated = FALSE;
233 }
234
235 if (Private->Ip6Nic != NULL) {
236 gBS->CloseProtocol (
237 Private->Controller,
238 &gEfiCallerIdGuid,
239 This->DriverBindingHandle,
240 Private->Ip6Nic->Controller
241 );
242
243 gBS->UninstallMultipleProtocolInterfaces (
244 Private->Ip6Nic->Controller,
245 &gEfiLoadFileProtocolGuid,
246 &Private->Ip6Nic->LoadFile,
247 &gEfiDevicePathProtocolGuid,
248 Private->Ip6Nic->DevicePath,
249 NULL
250 );
251 FreePool (Private->Ip6Nic);
252 Private->Ip6Nic = NULL;
253 }
254 }
255
256 /**
257 Tests to see if this driver supports a given controller. If a child device is provided,
258 it further tests to see if this driver supports creating a handle for the specified child device.
259
260 This function checks to see if the driver specified by This supports the device specified by
261 ControllerHandle. Drivers will typically use the device path attached to
262 ControllerHandle and/or the services from the bus I/O abstraction attached to
263 ControllerHandle to determine if the driver supports ControllerHandle. This function
264 may be called many times during platform initialization. In order to reduce boot times, the tests
265 performed by this function must be very small, and take as little time as possible to execute. This
266 function must not change the state of any hardware devices, and this function must be aware that the
267 device specified by ControllerHandle may already be managed by the same driver or a
268 different driver. This function must match its calls to AllocatePages() with FreePages(),
269 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
270 Because ControllerHandle may have been previously started by the same driver, if a protocol is
271 already in the opened state, then it must not be closed with CloseProtocol(). This is required
272 to guarantee the state of ControllerHandle is not modified by this function.
273
274 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
275 @param[in] ControllerHandle The handle of the controller to test. This handle
276 must support a protocol interface that supplies
277 an I/O abstraction to the driver.
278 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
279 parameter is ignored by device drivers, and is optional for bus
280 drivers. For bus drivers, if this parameter is not NULL, then
281 the bus driver must determine if the bus controller specified
282 by ControllerHandle and the child controller specified
283 by RemainingDevicePath are both supported by this
284 bus driver.
285
286 @retval EFI_SUCCESS The device specified by ControllerHandle and
287 RemainingDevicePath is supported by the driver specified by This.
288 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
289 RemainingDevicePath is already being managed by the driver
290 specified by This.
291 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
292 RemainingDevicePath is already being managed by a different
293 driver or an application that requires exclusive access.
294 Currently not implemented.
295 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
296 RemainingDevicePath is not supported by the driver specified by This.
297 **/
298 EFI_STATUS
299 EFIAPI
300 HttpBootIp4DxeDriverBindingSupported (
301 IN EFI_DRIVER_BINDING_PROTOCOL *This,
302 IN EFI_HANDLE ControllerHandle,
303 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
304 )
305 {
306 EFI_STATUS Status;
307
308 //
309 // Try to open the DHCP4, HTTP4 and Device Path protocol.
310 //
311 Status = gBS->OpenProtocol (
312 ControllerHandle,
313 &gEfiDhcp4ServiceBindingProtocolGuid,
314 NULL,
315 This->DriverBindingHandle,
316 ControllerHandle,
317 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
318 );
319 if (EFI_ERROR (Status)) {
320 return Status;
321 }
322
323 Status = gBS->OpenProtocol (
324 ControllerHandle,
325 &gEfiHttpServiceBindingProtocolGuid,
326 NULL,
327 This->DriverBindingHandle,
328 ControllerHandle,
329 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
330 );
331 if (EFI_ERROR (Status)) {
332 return Status;
333 }
334
335 Status = gBS->OpenProtocol (
336 ControllerHandle,
337 &gEfiDevicePathProtocolGuid,
338 NULL,
339 This->DriverBindingHandle,
340 ControllerHandle,
341 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
342 );
343
344 return Status;
345 }
346
347 /**
348 Starts a device controller or a bus controller.
349
350 The Start() function is designed to be invoked from the EFI boot service ConnectController().
351 As a result, much of the error checking on the parameters to Start() has been moved into this
352 common boot service. It is legal to call Start() from other locations,
353 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
354 1. ControllerHandle must be a valid EFI_HANDLE.
355 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
356 EFI_DEVICE_PATH_PROTOCOL.
357 3. Prior to calling Start(), the Supported() function for the driver specified by This must
358 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
359
360 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
361 @param[in] ControllerHandle The handle of the controller to start. This handle
362 must support a protocol interface that supplies
363 an I/O abstraction to the driver.
364 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
365 parameter is ignored by device drivers, and is optional for bus
366 drivers. For a bus driver, if this parameter is NULL, then handles
367 for all the children of Controller are created by this driver.
368 If this parameter is not NULL and the first Device Path Node is
369 not the End of Device Path Node, then only the handle for the
370 child device specified by the first Device Path Node of
371 RemainingDevicePath is created by this driver.
372 If the first Device Path Node of RemainingDevicePath is
373 the End of Device Path Node, no child handle is created by this
374 driver.
375
376 @retval EFI_SUCCESS The device was started.
377 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
378 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
379 @retval Others The driver failed to start the device.
380
381 **/
382 EFI_STATUS
383 EFIAPI
384 HttpBootIp4DxeDriverBindingStart (
385 IN EFI_DRIVER_BINDING_PROTOCOL *This,
386 IN EFI_HANDLE ControllerHandle,
387 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
388 )
389 {
390 EFI_STATUS Status;
391 HTTP_BOOT_PRIVATE_DATA *Private;
392 EFI_DEV_PATH *Node;
393 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
394 UINT32 *Id;
395 BOOLEAN FirstStart;
396
397 FirstStart = FALSE;
398
399 Status = gBS->OpenProtocol (
400 ControllerHandle,
401 &gEfiCallerIdGuid,
402 (VOID **)&Id,
403 This->DriverBindingHandle,
404 ControllerHandle,
405 EFI_OPEN_PROTOCOL_GET_PROTOCOL
406 );
407
408 if (!EFI_ERROR (Status)) {
409 Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
410 } else {
411 FirstStart = TRUE;
412
413 //
414 // Initialize the private data structure.
415 //
416 Private = AllocateZeroPool (sizeof (HTTP_BOOT_PRIVATE_DATA));
417 if (Private == NULL) {
418 return EFI_OUT_OF_RESOURCES;
419 }
420
421 Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
422 Private->Controller = ControllerHandle;
423 InitializeListHead (&Private->CacheList);
424 //
425 // Get the NII interface if it exists, it's not required.
426 //
427 Status = gBS->OpenProtocol (
428 ControllerHandle,
429 &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
430 (VOID **)&Private->Nii,
431 This->DriverBindingHandle,
432 ControllerHandle,
433 EFI_OPEN_PROTOCOL_GET_PROTOCOL
434 );
435 if (EFI_ERROR (Status)) {
436 Private->Nii = NULL;
437 }
438
439 //
440 // Open Device Path Protocol to prepare for appending IP and URI node.
441 //
442 Status = gBS->OpenProtocol (
443 ControllerHandle,
444 &gEfiDevicePathProtocolGuid,
445 (VOID **)&Private->ParentDevicePath,
446 This->DriverBindingHandle,
447 ControllerHandle,
448 EFI_OPEN_PROTOCOL_GET_PROTOCOL
449 );
450 if (EFI_ERROR (Status)) {
451 goto ON_ERROR;
452 }
453
454 //
455 // Initialize the HII configuration form.
456 //
457 Status = HttpBootConfigFormInit (Private);
458 if (EFI_ERROR (Status)) {
459 goto ON_ERROR;
460 }
461
462 //
463 // Install a protocol with Caller Id Guid to the NIC, this is just to build the relationship between
464 // NIC handle and the private data.
465 //
466 Status = gBS->InstallProtocolInterface (
467 &ControllerHandle,
468 &gEfiCallerIdGuid,
469 EFI_NATIVE_INTERFACE,
470 &Private->Id
471 );
472 if (EFI_ERROR (Status)) {
473 goto ON_ERROR;
474 }
475 }
476
477 if (Private->Ip4Nic != NULL) {
478 //
479 // Already created before
480 //
481 return EFI_SUCCESS;
482 }
483
484 Private->Ip4Nic = AllocateZeroPool (sizeof (HTTP_BOOT_VIRTUAL_NIC));
485 if (Private->Ip4Nic == NULL) {
486 Status = EFI_OUT_OF_RESOURCES;
487 goto ON_ERROR;
488 }
489
490 Private->Ip4Nic->Private = Private;
491 Private->Ip4Nic->ImageHandle = This->DriverBindingHandle;
492 Private->Ip4Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;
493
494 //
495 // Create DHCP4 child instance.
496 //
497 Status = NetLibCreateServiceChild (
498 ControllerHandle,
499 This->DriverBindingHandle,
500 &gEfiDhcp4ServiceBindingProtocolGuid,
501 &Private->Dhcp4Child
502 );
503 if (EFI_ERROR (Status)) {
504 goto ON_ERROR;
505 }
506
507 Status = gBS->OpenProtocol (
508 Private->Dhcp4Child,
509 &gEfiDhcp4ProtocolGuid,
510 (VOID **)&Private->Dhcp4,
511 This->DriverBindingHandle,
512 ControllerHandle,
513 EFI_OPEN_PROTOCOL_BY_DRIVER
514 );
515 if (EFI_ERROR (Status)) {
516 goto ON_ERROR;
517 }
518
519 //
520 // Get the Ip4Config2 protocol, it's required to configure the default gateway address.
521 //
522 Status = gBS->OpenProtocol (
523 ControllerHandle,
524 &gEfiIp4Config2ProtocolGuid,
525 (VOID **)&Private->Ip4Config2,
526 This->DriverBindingHandle,
527 ControllerHandle,
528 EFI_OPEN_PROTOCOL_GET_PROTOCOL
529 );
530 if (EFI_ERROR (Status)) {
531 goto ON_ERROR;
532 }
533
534 //
535 // Append IPv4 device path node.
536 //
537 Node = AllocateZeroPool (sizeof (IPv4_DEVICE_PATH));
538 if (Node == NULL) {
539 Status = EFI_OUT_OF_RESOURCES;
540 goto ON_ERROR;
541 }
542
543 Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
544 Node->Ipv4.Header.SubType = MSG_IPv4_DP;
545 SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
546 Node->Ipv4.StaticIpAddress = FALSE;
547 DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
548 FreePool (Node);
549 if (DevicePath == NULL) {
550 Status = EFI_OUT_OF_RESOURCES;
551 goto ON_ERROR;
552 }
553
554 //
555 // Append URI device path node.
556 //
557 Node = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));
558 if (Node == NULL) {
559 Status = EFI_OUT_OF_RESOURCES;
560 goto ON_ERROR;
561 }
562
563 Node->DevPath.Type = MESSAGING_DEVICE_PATH;
564 Node->DevPath.SubType = MSG_URI_DP;
565 SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL));
566 Private->Ip4Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
567 FreePool (Node);
568 FreePool (DevicePath);
569 if (Private->Ip4Nic->DevicePath == NULL) {
570 Status = EFI_OUT_OF_RESOURCES;
571 goto ON_ERROR;
572 }
573
574 //
575 // Create a child handle for the HTTP boot and install DevPath and Load file protocol on it.
576 //
577 CopyMem (&Private->Ip4Nic->LoadFile, &gHttpBootDxeLoadFile, sizeof (EFI_LOAD_FILE_PROTOCOL));
578 Status = gBS->InstallMultipleProtocolInterfaces (
579 &Private->Ip4Nic->Controller,
580 &gEfiLoadFileProtocolGuid,
581 &Private->Ip4Nic->LoadFile,
582 &gEfiDevicePathProtocolGuid,
583 Private->Ip4Nic->DevicePath,
584 NULL
585 );
586 if (EFI_ERROR (Status)) {
587 goto ON_ERROR;
588 }
589
590 //
591 // Open the Caller Id child to setup a parent-child relationship between
592 // real NIC handle and the HTTP boot Ipv4 NIC handle.
593 //
594 Status = gBS->OpenProtocol (
595 ControllerHandle,
596 &gEfiCallerIdGuid,
597 (VOID **)&Id,
598 This->DriverBindingHandle,
599 Private->Ip4Nic->Controller,
600 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
601 );
602 if (EFI_ERROR (Status)) {
603 goto ON_ERROR;
604 }
605
606 return EFI_SUCCESS;
607
608 ON_ERROR:
609 if (Private != NULL) {
610 if (FirstStart) {
611 gBS->UninstallProtocolInterface (
612 ControllerHandle,
613 &gEfiCallerIdGuid,
614 &Private->Id
615 );
616 }
617
618 HttpBootDestroyIp4Children (This, Private);
619 HttpBootConfigFormUnload (Private);
620
621 if (FirstStart) {
622 FreePool (Private);
623 }
624 }
625
626 return Status;
627 }
628
629 /**
630 Stops a device controller or a bus controller.
631
632 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
633 As a result, much of the error checking on the parameters to Stop() has been moved
634 into this common boot service. It is legal to call Stop() 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 that was used on a previous call to this
637 same driver's Start() function.
638 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
639 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
640 Start() function, and the Start() function must have called OpenProtocol() on
641 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
642
643 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
644 @param[in] ControllerHandle A handle to the device being stopped. The handle must
645 support a bus specific I/O protocol for the driver
646 to use to stop the device.
647 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
648 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
649 if NumberOfChildren is 0.
650
651 @retval EFI_SUCCESS The device was stopped.
652 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
653
654 **/
655 EFI_STATUS
656 EFIAPI
657 HttpBootIp4DxeDriverBindingStop (
658 IN EFI_DRIVER_BINDING_PROTOCOL *This,
659 IN EFI_HANDLE ControllerHandle,
660 IN UINTN NumberOfChildren,
661 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
662 )
663 {
664 EFI_STATUS Status;
665 EFI_LOAD_FILE_PROTOCOL *LoadFile;
666 HTTP_BOOT_PRIVATE_DATA *Private;
667 EFI_HANDLE NicHandle;
668 UINT32 *Id;
669
670 //
671 // Try to get the Load File Protocol from the controller handle.
672 //
673 Status = gBS->OpenProtocol (
674 ControllerHandle,
675 &gEfiLoadFileProtocolGuid,
676 (VOID **)&LoadFile,
677 This->DriverBindingHandle,
678 ControllerHandle,
679 EFI_OPEN_PROTOCOL_GET_PROTOCOL
680 );
681 if (EFI_ERROR (Status)) {
682 //
683 // If failed, try to find the NIC handle for this controller.
684 //
685 NicHandle = HttpBootGetNicByIp4Children (ControllerHandle);
686 if (NicHandle == NULL) {
687 return EFI_SUCCESS;
688 }
689
690 //
691 // Try to retrieve the private data by the Caller Id Guid.
692 //
693 Status = gBS->OpenProtocol (
694 NicHandle,
695 &gEfiCallerIdGuid,
696 (VOID **)&Id,
697 This->DriverBindingHandle,
698 ControllerHandle,
699 EFI_OPEN_PROTOCOL_GET_PROTOCOL
700 );
701 if (EFI_ERROR (Status)) {
702 return Status;
703 }
704
705 Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
706 } else {
707 Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
708 NicHandle = Private->Controller;
709 }
710
711 //
712 // Disable the HTTP boot function.
713 //
714 Status = HttpBootStop (Private);
715 if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_STARTED)) {
716 return Status;
717 }
718
719 //
720 // Destroy all child instance and uninstall protocol interface.
721 //
722 HttpBootDestroyIp4Children (This, Private);
723
724 if ((Private->Ip4Nic == NULL) && (Private->Ip6Nic == NULL)) {
725 //
726 // Release the cached data.
727 //
728 HttpBootFreeCacheList (Private);
729
730 //
731 // Unload the config form.
732 //
733 HttpBootConfigFormUnload (Private);
734
735 gBS->UninstallProtocolInterface (
736 NicHandle,
737 &gEfiCallerIdGuid,
738 &Private->Id
739 );
740 FreePool (Private);
741 }
742
743 return EFI_SUCCESS;
744 }
745
746 /**
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.
749
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.
763
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
774 bus driver.
775
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
780 specified by This.
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.
787 **/
788 EFI_STATUS
789 EFIAPI
790 HttpBootIp6DxeDriverBindingSupported (
791 IN EFI_DRIVER_BINDING_PROTOCOL *This,
792 IN EFI_HANDLE ControllerHandle,
793 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
794 )
795 {
796 EFI_STATUS Status;
797
798 //
799 // Try to open the DHCP6, HTTP and Device Path protocol.
800 //
801 Status = gBS->OpenProtocol (
802 ControllerHandle,
803 &gEfiDhcp6ServiceBindingProtocolGuid,
804 NULL,
805 This->DriverBindingHandle,
806 ControllerHandle,
807 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
808 );
809 if (EFI_ERROR (Status)) {
810 return Status;
811 }
812
813 Status = gBS->OpenProtocol (
814 ControllerHandle,
815 &gEfiHttpServiceBindingProtocolGuid,
816 NULL,
817 This->DriverBindingHandle,
818 ControllerHandle,
819 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
820 );
821 if (EFI_ERROR (Status)) {
822 return Status;
823 }
824
825 Status = gBS->OpenProtocol (
826 ControllerHandle,
827 &gEfiDevicePathProtocolGuid,
828 NULL,
829 This->DriverBindingHandle,
830 ControllerHandle,
831 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
832 );
833
834 return Status;
835 }
836
837 /**
838 Starts a device controller or a bus controller.
839
840 The Start() function is designed to be invoked from the EFI boot service ConnectController().
841 As a result, much of the error checking on the parameters to Start() has been moved into this
842 common boot service. It is legal to call Start() from other locations,
843 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
844 1. ControllerHandle must be a valid EFI_HANDLE.
845 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
846 EFI_DEVICE_PATH_PROTOCOL.
847 3. Prior to calling Start(), the Supported() function for the driver specified by This must
848 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
849
850 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
851 @param[in] ControllerHandle The handle of the controller to start. This handle
852 must support a protocol interface that supplies
853 an I/O abstraction to the driver.
854 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
855 parameter is ignored by device drivers, and is optional for bus
856 drivers. For a bus driver, if this parameter is NULL, then handles
857 for all the children of Controller are created by this driver.
858 If this parameter is not NULL and the first Device Path Node is
859 not the End of Device Path Node, then only the handle for the
860 child device specified by the first Device Path Node of
861 RemainingDevicePath is created by this driver.
862 If the first Device Path Node of RemainingDevicePath is
863 the End of Device Path Node, no child handle is created by this
864 driver.
865
866 @retval EFI_SUCCESS The device was started.
867 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
868 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
869 @retval Others The driver failed to start the device.
870
871 **/
872 EFI_STATUS
873 EFIAPI
874 HttpBootIp6DxeDriverBindingStart (
875 IN EFI_DRIVER_BINDING_PROTOCOL *This,
876 IN EFI_HANDLE ControllerHandle,
877 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
878 )
879 {
880 EFI_STATUS Status;
881 HTTP_BOOT_PRIVATE_DATA *Private;
882 EFI_DEV_PATH *Node;
883 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
884 UINT32 *Id;
885 BOOLEAN Ipv6Available;
886 BOOLEAN FirstStart;
887
888 FirstStart = FALSE;
889
890 Status = gBS->OpenProtocol (
891 ControllerHandle,
892 &gEfiCallerIdGuid,
893 (VOID **)&Id,
894 This->DriverBindingHandle,
895 ControllerHandle,
896 EFI_OPEN_PROTOCOL_GET_PROTOCOL
897 );
898
899 if (!EFI_ERROR (Status)) {
900 Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
901 } else {
902 FirstStart = TRUE;
903
904 //
905 // Initialize the private data structure.
906 //
907 Private = AllocateZeroPool (sizeof (HTTP_BOOT_PRIVATE_DATA));
908 if (Private == NULL) {
909 return EFI_OUT_OF_RESOURCES;
910 }
911
912 Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
913 Private->Controller = ControllerHandle;
914 InitializeListHead (&Private->CacheList);
915 //
916 // Get the NII interface if it exists, it's not required.
917 //
918 Status = gBS->OpenProtocol (
919 ControllerHandle,
920 &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
921 (VOID **)&Private->Nii,
922 This->DriverBindingHandle,
923 ControllerHandle,
924 EFI_OPEN_PROTOCOL_GET_PROTOCOL
925 );
926 if (EFI_ERROR (Status)) {
927 Private->Nii = NULL;
928 }
929
930 //
931 // Open Device Path Protocol to prepare for appending IP and URI node.
932 //
933 Status = gBS->OpenProtocol (
934 ControllerHandle,
935 &gEfiDevicePathProtocolGuid,
936 (VOID **)&Private->ParentDevicePath,
937 This->DriverBindingHandle,
938 ControllerHandle,
939 EFI_OPEN_PROTOCOL_GET_PROTOCOL
940 );
941 if (EFI_ERROR (Status)) {
942 goto ON_ERROR;
943 }
944
945 //
946 // Initialize the HII configuration form.
947 //
948 Status = HttpBootConfigFormInit (Private);
949 if (EFI_ERROR (Status)) {
950 goto ON_ERROR;
951 }
952
953 //
954 // Install a protocol with Caller Id Guid to the NIC, this is just to build the relationship between
955 // NIC handle and the private data.
956 //
957 Status = gBS->InstallProtocolInterface (
958 &ControllerHandle,
959 &gEfiCallerIdGuid,
960 EFI_NATIVE_INTERFACE,
961 &Private->Id
962 );
963 if (EFI_ERROR (Status)) {
964 goto ON_ERROR;
965 }
966 }
967
968 //
969 // Set IPv6 available flag.
970 //
971 Status = HttpBootCheckIpv6Support (Private, &Ipv6Available);
972 if (EFI_ERROR (Status)) {
973 //
974 // Fail to get the data whether UNDI supports IPv6.
975 // Set default value to TRUE.
976 //
977 Ipv6Available = TRUE;
978 }
979
980 if (!Ipv6Available) {
981 Status = EFI_UNSUPPORTED;
982 goto ON_ERROR;
983 }
984
985 if (Private->Ip6Nic != NULL) {
986 //
987 // Already created before
988 //
989 return EFI_SUCCESS;
990 }
991
992 Private->Ip6Nic = AllocateZeroPool (sizeof (HTTP_BOOT_VIRTUAL_NIC));
993 if (Private->Ip6Nic == NULL) {
994 Status = EFI_OUT_OF_RESOURCES;
995 goto ON_ERROR;
996 }
997
998 Private->Ip6Nic->Private = Private;
999 Private->Ip6Nic->ImageHandle = This->DriverBindingHandle;
1000 Private->Ip6Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;
1001
1002 //
1003 // Create Dhcp6 child and open Dhcp6 protocol
1004 Status = NetLibCreateServiceChild (
1005 ControllerHandle,
1006 This->DriverBindingHandle,
1007 &gEfiDhcp6ServiceBindingProtocolGuid,
1008 &Private->Dhcp6Child
1009 );
1010 if (EFI_ERROR (Status)) {
1011 goto ON_ERROR;
1012 }
1013
1014 Status = gBS->OpenProtocol (
1015 Private->Dhcp6Child,
1016 &gEfiDhcp6ProtocolGuid,
1017 (VOID **)&Private->Dhcp6,
1018 This->DriverBindingHandle,
1019 ControllerHandle,
1020 EFI_OPEN_PROTOCOL_BY_DRIVER
1021 );
1022 if (EFI_ERROR (Status)) {
1023 goto ON_ERROR;
1024 }
1025
1026 //
1027 // Create Ip6 child and open Ip6 protocol for background ICMP packets.
1028 //
1029 Status = NetLibCreateServiceChild (
1030 ControllerHandle,
1031 This->DriverBindingHandle,
1032 &gEfiIp6ServiceBindingProtocolGuid,
1033 &Private->Ip6Child
1034 );
1035 if (EFI_ERROR (Status)) {
1036 goto ON_ERROR;
1037 }
1038
1039 Status = gBS->OpenProtocol (
1040 Private->Ip6Child,
1041 &gEfiIp6ProtocolGuid,
1042 (VOID **)&Private->Ip6,
1043 This->DriverBindingHandle,
1044 ControllerHandle,
1045 EFI_OPEN_PROTOCOL_BY_DRIVER
1046 );
1047 if (EFI_ERROR (Status)) {
1048 goto ON_ERROR;
1049 }
1050
1051 //
1052 // Locate Ip6Config protocol, it's required to configure the default gateway address.
1053 //
1054 Status = gBS->OpenProtocol (
1055 ControllerHandle,
1056 &gEfiIp6ConfigProtocolGuid,
1057 (VOID **)&Private->Ip6Config,
1058 This->DriverBindingHandle,
1059 ControllerHandle,
1060 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1061 );
1062 if (EFI_ERROR (Status)) {
1063 goto ON_ERROR;
1064 }
1065
1066 //
1067 // Append IPv6 device path node.
1068 //
1069 Node = AllocateZeroPool (sizeof (IPv6_DEVICE_PATH));
1070 if (Node == NULL) {
1071 Status = EFI_OUT_OF_RESOURCES;
1072 goto ON_ERROR;
1073 }
1074
1075 Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
1076 Node->Ipv6.Header.SubType = MSG_IPv6_DP;
1077 Node->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
1078 SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
1079 DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH *)Node);
1080 FreePool (Node);
1081 if (DevicePath == NULL) {
1082 Status = EFI_OUT_OF_RESOURCES;
1083 goto ON_ERROR;
1084 }
1085
1086 //
1087 // Append URI device path node.
1088 //
1089 Node = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));
1090 if (Node == NULL) {
1091 Status = EFI_OUT_OF_RESOURCES;
1092 goto ON_ERROR;
1093 }
1094
1095 Node->DevPath.Type = MESSAGING_DEVICE_PATH;
1096 Node->DevPath.SubType = MSG_URI_DP;
1097 SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL));
1098 Private->Ip6Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
1099 FreePool (Node);
1100 FreePool (DevicePath);
1101 if (Private->Ip6Nic->DevicePath == NULL) {
1102 Status = EFI_OUT_OF_RESOURCES;
1103 goto ON_ERROR;
1104 }
1105
1106 //
1107 // Create a child handle for the HTTP boot and install DevPath and Load file protocol on it.
1108 //
1109 CopyMem (&Private->Ip6Nic->LoadFile, &gHttpBootDxeLoadFile, sizeof (Private->LoadFile));
1110 Status = gBS->InstallMultipleProtocolInterfaces (
1111 &Private->Ip6Nic->Controller,
1112 &gEfiLoadFileProtocolGuid,
1113 &Private->Ip6Nic->LoadFile,
1114 &gEfiDevicePathProtocolGuid,
1115 Private->Ip6Nic->DevicePath,
1116 NULL
1117 );
1118 if (EFI_ERROR (Status)) {
1119 goto ON_ERROR;
1120 }
1121
1122 //
1123 // Open the Caller Id child to setup a parent-child relationship between
1124 // real NIC handle and the HTTP boot child handle.
1125 //
1126 Status = gBS->OpenProtocol (
1127 ControllerHandle,
1128 &gEfiCallerIdGuid,
1129 (VOID **)&Id,
1130 This->DriverBindingHandle,
1131 Private->Ip6Nic->Controller,
1132 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1133 );
1134 if (EFI_ERROR (Status)) {
1135 goto ON_ERROR;
1136 }
1137
1138 return EFI_SUCCESS;
1139
1140 ON_ERROR:
1141 if (Private != NULL) {
1142 if (FirstStart) {
1143 gBS->UninstallProtocolInterface (
1144 ControllerHandle,
1145 &gEfiCallerIdGuid,
1146 &Private->Id
1147 );
1148 }
1149
1150 HttpBootDestroyIp6Children (This, Private);
1151 HttpBootConfigFormUnload (Private);
1152
1153 if (FirstStart) {
1154 FreePool (Private);
1155 }
1156 }
1157
1158 return Status;
1159 }
1160
1161 /**
1162 Stops a device controller or a bus controller.
1163
1164 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
1165 As a result, much of the error checking on the parameters to Stop() has been moved
1166 into this common boot service. It is legal to call Stop() from other locations,
1167 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
1168 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
1169 same driver's Start() function.
1170 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
1171 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
1172 Start() function, and the Start() function must have called OpenProtocol() on
1173 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
1174
1175 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
1176 @param[in] ControllerHandle A handle to the device being stopped. The handle must
1177 support a bus specific I/O protocol for the driver
1178 to use to stop the device.
1179 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
1180 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
1181 if NumberOfChildren is 0.
1182
1183 @retval EFI_SUCCESS The device was stopped.
1184 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
1185
1186 **/
1187 EFI_STATUS
1188 EFIAPI
1189 HttpBootIp6DxeDriverBindingStop (
1190 IN EFI_DRIVER_BINDING_PROTOCOL *This,
1191 IN EFI_HANDLE ControllerHandle,
1192 IN UINTN NumberOfChildren,
1193 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
1194 )
1195 {
1196 EFI_STATUS Status;
1197 EFI_LOAD_FILE_PROTOCOL *LoadFile;
1198 HTTP_BOOT_PRIVATE_DATA *Private;
1199 EFI_HANDLE NicHandle;
1200 UINT32 *Id;
1201
1202 //
1203 // Try to get the Load File Protocol from the controller handle.
1204 //
1205 Status = gBS->OpenProtocol (
1206 ControllerHandle,
1207 &gEfiLoadFileProtocolGuid,
1208 (VOID **)&LoadFile,
1209 This->DriverBindingHandle,
1210 ControllerHandle,
1211 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1212 );
1213 if (EFI_ERROR (Status)) {
1214 //
1215 // If failed, try to find the NIC handle for this controller.
1216 //
1217 NicHandle = HttpBootGetNicByIp6Children (ControllerHandle);
1218 if (NicHandle == NULL) {
1219 return EFI_SUCCESS;
1220 }
1221
1222 //
1223 // Try to retrieve the private data by the Caller Id Guid.
1224 //
1225 Status = gBS->OpenProtocol (
1226 NicHandle,
1227 &gEfiCallerIdGuid,
1228 (VOID **)&Id,
1229 This->DriverBindingHandle,
1230 ControllerHandle,
1231 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1232 );
1233 if (EFI_ERROR (Status)) {
1234 return Status;
1235 }
1236
1237 Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
1238 } else {
1239 Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
1240 NicHandle = Private->Controller;
1241 }
1242
1243 //
1244 // Disable the HTTP boot function.
1245 //
1246 Status = HttpBootStop (Private);
1247 if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_STARTED)) {
1248 return Status;
1249 }
1250
1251 //
1252 // Destroy all child instance and uninstall protocol interface.
1253 //
1254 HttpBootDestroyIp6Children (This, Private);
1255
1256 if ((Private->Ip4Nic == NULL) && (Private->Ip6Nic == NULL)) {
1257 //
1258 // Release the cached data.
1259 //
1260 HttpBootFreeCacheList (Private);
1261
1262 //
1263 // Unload the config form.
1264 //
1265 HttpBootConfigFormUnload (Private);
1266
1267 gBS->UninstallProtocolInterface (
1268 NicHandle,
1269 &gEfiCallerIdGuid,
1270 &Private->Id
1271 );
1272 FreePool (Private);
1273 }
1274
1275 return EFI_SUCCESS;
1276 }
1277
1278 /**
1279 This is the declaration of an EFI image entry point. This entry point is
1280 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
1281 both device drivers and bus drivers.
1282
1283 @param[in] ImageHandle The firmware allocated handle for the UEFI image.
1284 @param[in] SystemTable A pointer to the EFI System Table.
1285
1286 @retval EFI_SUCCESS The operation completed successfully.
1287 @retval Others An unexpected error occurred.
1288
1289 **/
1290 EFI_STATUS
1291 EFIAPI
1292 HttpBootDxeDriverEntryPoint (
1293 IN EFI_HANDLE ImageHandle,
1294 IN EFI_SYSTEM_TABLE *SystemTable
1295 )
1296 {
1297 EFI_STATUS Status;
1298
1299 //
1300 // Install UEFI Driver Model protocol(s).
1301 //
1302 Status = EfiLibInstallDriverBindingComponentName2 (
1303 ImageHandle,
1304 SystemTable,
1305 &gHttpBootIp4DxeDriverBinding,
1306 ImageHandle,
1307 &gHttpBootDxeComponentName,
1308 &gHttpBootDxeComponentName2
1309 );
1310 if (EFI_ERROR (Status)) {
1311 return Status;
1312 }
1313
1314 Status = EfiLibInstallDriverBindingComponentName2 (
1315 ImageHandle,
1316 SystemTable,
1317 &gHttpBootIp6DxeDriverBinding,
1318 NULL,
1319 &gHttpBootDxeComponentName,
1320 &gHttpBootDxeComponentName2
1321 );
1322 if (EFI_ERROR (Status)) {
1323 EfiLibUninstallDriverBindingComponentName2 (
1324 &gHttpBootIp4DxeDriverBinding,
1325 &gHttpBootDxeComponentName,
1326 &gHttpBootDxeComponentName2
1327 );
1328 }
1329
1330 return Status;
1331 }