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