]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/HttpBootDxe/HttpBootDxe.c
b1f9042ea349b9b8c74cc35049e320545cdd780c
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootDxe.c
1 /** @file
2 Driver Binding functions implementation for UEFI HTTP boot.
3
4 Copyright (c) 2015 - 2017, 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 (FirstStart) {
619 gBS->UninstallProtocolInterface (
620 ControllerHandle,
621 &gEfiCallerIdGuid,
622 &Private->Id
623 );
624 }
625
626 HttpBootDestroyIp4Children (This, Private);
627 HttpBootConfigFormUnload (Private);
628
629 if (FirstStart && Private != NULL) {
630 FreePool (Private);
631 }
632
633 return Status;
634 }
635
636
637 /**
638 Stops a device controller or a bus controller.
639
640 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
641 As a result, much of the error checking on the parameters to Stop() has been moved
642 into this common boot service. It is legal to call Stop() from other locations,
643 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
644 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
645 same driver's Start() function.
646 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
647 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
648 Start() function, and the Start() function must have called OpenProtocol() on
649 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
650
651 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
652 @param[in] ControllerHandle A handle to the device being stopped. The handle must
653 support a bus specific I/O protocol for the driver
654 to use to stop the device.
655 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
656 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
657 if NumberOfChildren is 0.
658
659 @retval EFI_SUCCESS The device was stopped.
660 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
661
662 **/
663 EFI_STATUS
664 EFIAPI
665 HttpBootIp4DxeDriverBindingStop (
666 IN EFI_DRIVER_BINDING_PROTOCOL *This,
667 IN EFI_HANDLE ControllerHandle,
668 IN UINTN NumberOfChildren,
669 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
670 )
671 {
672 EFI_STATUS Status;
673 EFI_LOAD_FILE_PROTOCOL *LoadFile;
674 HTTP_BOOT_PRIVATE_DATA *Private;
675 EFI_HANDLE NicHandle;
676 UINT32 *Id;
677
678 //
679 // Try to get the Load File Protocol from the controller handle.
680 //
681 Status = gBS->OpenProtocol (
682 ControllerHandle,
683 &gEfiLoadFileProtocolGuid,
684 (VOID **) &LoadFile,
685 This->DriverBindingHandle,
686 ControllerHandle,
687 EFI_OPEN_PROTOCOL_GET_PROTOCOL
688 );
689 if (EFI_ERROR (Status)) {
690 //
691 // If failed, try to find the NIC handle for this controller.
692 //
693 NicHandle = HttpBootGetNicByIp4Children (ControllerHandle);
694 if (NicHandle == NULL) {
695 return EFI_SUCCESS;
696 }
697
698 //
699 // Try to retrieve the private data by the Caller Id Guid.
700 //
701 Status = gBS->OpenProtocol (
702 NicHandle,
703 &gEfiCallerIdGuid,
704 (VOID **) &Id,
705 This->DriverBindingHandle,
706 ControllerHandle,
707 EFI_OPEN_PROTOCOL_GET_PROTOCOL
708 );
709 if (EFI_ERROR (Status)) {
710 return Status;
711 }
712 Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
713 } else {
714 Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
715 NicHandle = Private->Controller;
716 }
717
718 //
719 // Disable the HTTP boot function.
720 //
721 Status = HttpBootStop (Private);
722 if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {
723 return Status;
724 }
725
726 //
727 // Destory all child instance and uninstall protocol interface.
728 //
729 HttpBootDestroyIp4Children (This, Private);
730
731 if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {
732 //
733 // Release the cached data.
734 //
735 HttpBootFreeCacheList (Private);
736
737 //
738 // Unload the config form.
739 //
740 HttpBootConfigFormUnload (Private);
741
742 gBS->UninstallProtocolInterface (
743 NicHandle,
744 &gEfiCallerIdGuid,
745 &Private->Id
746 );
747 FreePool (Private);
748
749 }
750
751 return EFI_SUCCESS;
752 }
753
754 /**
755 Tests to see if this driver supports a given controller. If a child device is provided,
756 it further tests to see if this driver supports creating a handle for the specified child device.
757
758 This function checks to see if the driver specified by This supports the device specified by
759 ControllerHandle. Drivers will typically use the device path attached to
760 ControllerHandle and/or the services from the bus I/O abstraction attached to
761 ControllerHandle to determine if the driver supports ControllerHandle. This function
762 may be called many times during platform initialization. In order to reduce boot times, the tests
763 performed by this function must be very small, and take as little time as possible to execute. This
764 function must not change the state of any hardware devices, and this function must be aware that the
765 device specified by ControllerHandle may already be managed by the same driver or a
766 different driver. This function must match its calls to AllocatePages() with FreePages(),
767 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
768 Because ControllerHandle may have been previously started by the same driver, if a protocol is
769 already in the opened state, then it must not be closed with CloseProtocol(). This is required
770 to guarantee the state of ControllerHandle is not modified by this function.
771
772 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
773 @param[in] ControllerHandle The handle of the controller to test. This handle
774 must support a protocol interface that supplies
775 an I/O abstraction to the driver.
776 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
777 parameter is ignored by device drivers, and is optional for bus
778 drivers. For bus drivers, if this parameter is not NULL, then
779 the bus driver must determine if the bus controller specified
780 by ControllerHandle and the child controller specified
781 by RemainingDevicePath are both supported by this
782 bus driver.
783
784 @retval EFI_SUCCESS The device specified by ControllerHandle and
785 RemainingDevicePath is supported by the driver specified by This.
786 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
787 RemainingDevicePath is already being managed by the driver
788 specified by This.
789 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
790 RemainingDevicePath is already being managed by a different
791 driver or an application that requires exclusive access.
792 Currently not implemented.
793 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
794 RemainingDevicePath is not supported by the driver specified by This.
795 **/
796 EFI_STATUS
797 EFIAPI
798 HttpBootIp6DxeDriverBindingSupported (
799 IN EFI_DRIVER_BINDING_PROTOCOL *This,
800 IN EFI_HANDLE ControllerHandle,
801 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
802 )
803 {
804 EFI_STATUS Status;
805
806 //
807 // Try to open the DHCP6, HTTP and Device Path protocol.
808 //
809 Status = gBS->OpenProtocol (
810 ControllerHandle,
811 &gEfiDhcp6ServiceBindingProtocolGuid,
812 NULL,
813 This->DriverBindingHandle,
814 ControllerHandle,
815 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
816 );
817 if (EFI_ERROR (Status)) {
818 return Status;
819 }
820
821 Status = gBS->OpenProtocol (
822 ControllerHandle,
823 &gEfiHttpServiceBindingProtocolGuid,
824 NULL,
825 This->DriverBindingHandle,
826 ControllerHandle,
827 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
828 );
829 if (EFI_ERROR (Status)) {
830 return Status;
831 }
832
833 Status = gBS->OpenProtocol (
834 ControllerHandle,
835 &gEfiDevicePathProtocolGuid,
836 NULL,
837 This->DriverBindingHandle,
838 ControllerHandle,
839 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
840 );
841
842 return Status;
843
844 }
845
846 /**
847 Starts a device controller or a bus controller.
848
849 The Start() function is designed to be invoked from the EFI boot service ConnectController().
850 As a result, much of the error checking on the parameters to Start() has been moved into this
851 common boot service. It is legal to call Start() from other locations,
852 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
853 1. ControllerHandle must be a valid EFI_HANDLE.
854 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
855 EFI_DEVICE_PATH_PROTOCOL.
856 3. Prior to calling Start(), the Supported() function for the driver specified by This must
857 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
858
859 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
860 @param[in] ControllerHandle The handle of the controller to start. This handle
861 must support a protocol interface that supplies
862 an I/O abstraction to the driver.
863 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
864 parameter is ignored by device drivers, and is optional for bus
865 drivers. For a bus driver, if this parameter is NULL, then handles
866 for all the children of Controller are created by this driver.
867 If this parameter is not NULL and the first Device Path Node is
868 not the End of Device Path Node, then only the handle for the
869 child device specified by the first Device Path Node of
870 RemainingDevicePath is created by this driver.
871 If the first Device Path Node of RemainingDevicePath is
872 the End of Device Path Node, no child handle is created by this
873 driver.
874
875 @retval EFI_SUCCESS The device was started.
876 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
877 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
878 @retval Others The driver failded to start the device.
879
880 **/
881 EFI_STATUS
882 EFIAPI
883 HttpBootIp6DxeDriverBindingStart (
884 IN EFI_DRIVER_BINDING_PROTOCOL *This,
885 IN EFI_HANDLE ControllerHandle,
886 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
887 )
888 {
889 EFI_STATUS Status;
890 HTTP_BOOT_PRIVATE_DATA *Private;
891 EFI_DEV_PATH *Node;
892 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
893 UINT32 *Id;
894 BOOLEAN Ipv6Available;
895 BOOLEAN FirstStart;
896
897 FirstStart = FALSE;
898
899 Status = gBS->OpenProtocol (
900 ControllerHandle,
901 &gEfiCallerIdGuid,
902 (VOID **) &Id,
903 This->DriverBindingHandle,
904 ControllerHandle,
905 EFI_OPEN_PROTOCOL_GET_PROTOCOL
906 );
907
908 if (!EFI_ERROR (Status)) {
909 Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id);
910 } else {
911 FirstStart = TRUE;
912
913 //
914 // Initialize the private data structure.
915 //
916 Private = AllocateZeroPool (sizeof (HTTP_BOOT_PRIVATE_DATA));
917 if (Private == NULL) {
918 return EFI_OUT_OF_RESOURCES;
919 }
920 Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
921 Private->Controller = ControllerHandle;
922 InitializeListHead (&Private->CacheList);
923 //
924 // Get the NII interface if it exists, it's not required.
925 //
926 Status = gBS->OpenProtocol (
927 ControllerHandle,
928 &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
929 (VOID **) &Private->Nii,
930 This->DriverBindingHandle,
931 ControllerHandle,
932 EFI_OPEN_PROTOCOL_GET_PROTOCOL
933 );
934 if (EFI_ERROR (Status)) {
935 Private->Nii = NULL;
936 }
937
938 //
939 // Open Device Path Protocol to prepare for appending IP and URI node.
940 //
941 Status = gBS->OpenProtocol (
942 ControllerHandle,
943 &gEfiDevicePathProtocolGuid,
944 (VOID **) &Private->ParentDevicePath,
945 This->DriverBindingHandle,
946 ControllerHandle,
947 EFI_OPEN_PROTOCOL_GET_PROTOCOL
948 );
949 if (EFI_ERROR (Status)) {
950 goto ON_ERROR;
951 }
952
953 //
954 // Initialize the HII configuration form.
955 //
956 Status = HttpBootConfigFormInit (Private);
957 if (EFI_ERROR (Status)) {
958 goto ON_ERROR;
959 }
960
961 //
962 // Install a protocol with Caller Id Guid to the NIC, this is just to build the relationship between
963 // NIC handle and the private data.
964 //
965 Status = gBS->InstallProtocolInterface (
966 &ControllerHandle,
967 &gEfiCallerIdGuid,
968 EFI_NATIVE_INTERFACE,
969 &Private->Id
970 );
971 if (EFI_ERROR (Status)) {
972 goto ON_ERROR;
973 }
974
975 }
976
977 //
978 // Set IPv6 available flag.
979 //
980 Status = HttpBootCheckIpv6Support (Private, &Ipv6Available);
981 if (EFI_ERROR (Status)) {
982 //
983 // Fail to get the data whether UNDI supports IPv6.
984 // Set default value to TRUE.
985 //
986 Ipv6Available = TRUE;
987 }
988
989 if (!Ipv6Available) {
990 Status = EFI_UNSUPPORTED;
991 goto ON_ERROR;
992 }
993
994 if (Private->Ip6Nic != NULL) {
995 //
996 // Already created before
997 //
998 return EFI_SUCCESS;
999 }
1000
1001 Private->Ip6Nic = AllocateZeroPool (sizeof (HTTP_BOOT_VIRTUAL_NIC));
1002 if (Private->Ip6Nic == NULL) {
1003 Status = EFI_OUT_OF_RESOURCES;
1004 goto ON_ERROR;
1005 }
1006 Private->Ip6Nic->Private = Private;
1007 Private->Ip6Nic->ImageHandle = This->DriverBindingHandle;
1008 Private->Ip6Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;
1009
1010 //
1011 // Create Dhcp6 child and open Dhcp6 protocol
1012 Status = NetLibCreateServiceChild (
1013 ControllerHandle,
1014 This->DriverBindingHandle,
1015 &gEfiDhcp6ServiceBindingProtocolGuid,
1016 &Private->Dhcp6Child
1017 );
1018 if (EFI_ERROR (Status)) {
1019 goto ON_ERROR;
1020 }
1021
1022 Status = gBS->OpenProtocol (
1023 Private->Dhcp6Child,
1024 &gEfiDhcp6ProtocolGuid,
1025 (VOID **) &Private->Dhcp6,
1026 This->DriverBindingHandle,
1027 ControllerHandle,
1028 EFI_OPEN_PROTOCOL_BY_DRIVER
1029 );
1030 if (EFI_ERROR (Status)) {
1031 goto ON_ERROR;
1032 }
1033
1034 //
1035 // Create Ip6 child and open Ip6 protocol for background ICMP packets.
1036 //
1037 Status = NetLibCreateServiceChild (
1038 ControllerHandle,
1039 This->DriverBindingHandle,
1040 &gEfiIp6ServiceBindingProtocolGuid,
1041 &Private->Ip6Child
1042 );
1043 if (EFI_ERROR (Status)) {
1044 goto ON_ERROR;
1045 }
1046
1047 Status = gBS->OpenProtocol (
1048 Private->Ip6Child,
1049 &gEfiIp6ProtocolGuid,
1050 (VOID **) &Private->Ip6,
1051 This->DriverBindingHandle,
1052 ControllerHandle,
1053 EFI_OPEN_PROTOCOL_BY_DRIVER
1054 );
1055 if (EFI_ERROR (Status)) {
1056 goto ON_ERROR;
1057 }
1058
1059 //
1060 // Locate Ip6Config protocol, it's required to configure the default gateway address.
1061 //
1062 Status = gBS->OpenProtocol (
1063 ControllerHandle,
1064 &gEfiIp6ConfigProtocolGuid,
1065 (VOID **) &Private->Ip6Config,
1066 This->DriverBindingHandle,
1067 ControllerHandle,
1068 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1069 );
1070 if (EFI_ERROR (Status)) {
1071 goto ON_ERROR;
1072 }
1073
1074 //
1075 // Append IPv6 device path node.
1076 //
1077 Node = AllocateZeroPool (sizeof (IPv6_DEVICE_PATH));
1078 if (Node == NULL) {
1079 Status = EFI_OUT_OF_RESOURCES;
1080 goto ON_ERROR;
1081 }
1082 Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
1083 Node->Ipv6.Header.SubType = MSG_IPv6_DP;
1084 Node->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
1085 SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
1086 DevicePath = AppendDevicePathNode(Private->ParentDevicePath, (EFI_DEVICE_PATH*) Node);
1087 FreePool(Node);
1088 if (DevicePath == NULL) {
1089 Status = EFI_OUT_OF_RESOURCES;
1090 goto ON_ERROR;
1091 }
1092
1093 //
1094 // Append URI device path node.
1095 //
1096 Node = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));
1097 if (Node == NULL) {
1098 Status = EFI_OUT_OF_RESOURCES;
1099 goto ON_ERROR;
1100 }
1101 Node->DevPath.Type = MESSAGING_DEVICE_PATH;
1102 Node->DevPath.SubType = MSG_URI_DP;
1103 SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL));
1104 Private->Ip6Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
1105 FreePool (Node);
1106 FreePool (DevicePath);
1107 if (Private->Ip6Nic->DevicePath == NULL) {
1108 Status = EFI_OUT_OF_RESOURCES;
1109 goto ON_ERROR;
1110 }
1111
1112 //
1113 // Create a child handle for the HTTP boot and install DevPath and Load file protocol on it.
1114 //
1115 CopyMem (&Private->Ip6Nic->LoadFile, &gHttpBootDxeLoadFile, sizeof (Private->LoadFile));
1116 Status = gBS->InstallMultipleProtocolInterfaces (
1117 &Private->Ip6Nic->Controller,
1118 &gEfiLoadFileProtocolGuid,
1119 &Private->Ip6Nic->LoadFile,
1120 &gEfiDevicePathProtocolGuid,
1121 Private->Ip6Nic->DevicePath,
1122 NULL
1123 );
1124 if (EFI_ERROR (Status)) {
1125 goto ON_ERROR;
1126 }
1127
1128 //
1129 // Open the Caller Id child to setup a parent-child relationship between
1130 // real NIC handle and the HTTP boot child handle.
1131 //
1132 Status = gBS->OpenProtocol (
1133 ControllerHandle,
1134 &gEfiCallerIdGuid,
1135 (VOID **) &Id,
1136 This->DriverBindingHandle,
1137 Private->Ip6Nic->Controller,
1138 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1139 );
1140 if (EFI_ERROR (Status)) {
1141 goto ON_ERROR;
1142 }
1143
1144 return EFI_SUCCESS;
1145
1146 ON_ERROR:
1147 if (FirstStart) {
1148 gBS->UninstallProtocolInterface (
1149 ControllerHandle,
1150 &gEfiCallerIdGuid,
1151 &Private->Id
1152 );
1153 }
1154
1155 HttpBootDestroyIp6Children(This, Private);
1156 HttpBootConfigFormUnload (Private);
1157
1158 if (FirstStart && Private != NULL) {
1159 FreePool (Private);
1160 }
1161
1162 return Status;
1163 }
1164
1165 /**
1166 Stops a device controller or a bus controller.
1167
1168 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
1169 As a result, much of the error checking on the parameters to Stop() has been moved
1170 into this common boot service. It is legal to call Stop() from other locations,
1171 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
1172 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
1173 same driver's Start() function.
1174 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
1175 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
1176 Start() function, and the Start() function must have called OpenProtocol() on
1177 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
1178
1179 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
1180 @param[in] ControllerHandle A handle to the device being stopped. The handle must
1181 support a bus specific I/O protocol for the driver
1182 to use to stop the device.
1183 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
1184 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
1185 if NumberOfChildren is 0.
1186
1187 @retval EFI_SUCCESS The device was stopped.
1188 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
1189
1190 **/
1191 EFI_STATUS
1192 EFIAPI
1193 HttpBootIp6DxeDriverBindingStop (
1194 IN EFI_DRIVER_BINDING_PROTOCOL *This,
1195 IN EFI_HANDLE ControllerHandle,
1196 IN UINTN NumberOfChildren,
1197 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
1198 )
1199 {
1200 EFI_STATUS Status;
1201 EFI_LOAD_FILE_PROTOCOL *LoadFile;
1202 HTTP_BOOT_PRIVATE_DATA *Private;
1203 EFI_HANDLE NicHandle;
1204 UINT32 *Id;
1205
1206 //
1207 // Try to get the Load File Protocol from the controller handle.
1208 //
1209 Status = gBS->OpenProtocol (
1210 ControllerHandle,
1211 &gEfiLoadFileProtocolGuid,
1212 (VOID **) &LoadFile,
1213 This->DriverBindingHandle,
1214 ControllerHandle,
1215 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1216 );
1217 if (EFI_ERROR (Status)) {
1218 //
1219 // If failed, try to find the NIC handle for this controller.
1220 //
1221 NicHandle = HttpBootGetNicByIp6Children (ControllerHandle);
1222 if (NicHandle == NULL) {
1223 return EFI_SUCCESS;
1224 }
1225
1226 //
1227 // Try to retrieve the private data by the Caller Id Guid.
1228 //
1229 Status = gBS->OpenProtocol (
1230 NicHandle,
1231 &gEfiCallerIdGuid,
1232 (VOID **) &Id,
1233 This->DriverBindingHandle,
1234 ControllerHandle,
1235 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1236 );
1237 if (EFI_ERROR (Status)) {
1238 return Status;
1239 }
1240 Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
1241 } else {
1242 Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
1243 NicHandle = Private->Controller;
1244 }
1245
1246 //
1247 // Disable the HTTP boot function.
1248 //
1249 Status = HttpBootStop (Private);
1250 if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {
1251 return Status;
1252 }
1253
1254 //
1255 // Destory all child instance and uninstall protocol interface.
1256 //
1257 HttpBootDestroyIp6Children (This, Private);
1258
1259 if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {
1260 //
1261 // Release the cached data.
1262 //
1263 HttpBootFreeCacheList (Private);
1264
1265 //
1266 // Unload the config form.
1267 //
1268 HttpBootConfigFormUnload (Private);
1269
1270 gBS->UninstallProtocolInterface (
1271 NicHandle,
1272 &gEfiCallerIdGuid,
1273 &Private->Id
1274 );
1275 FreePool (Private);
1276
1277 }
1278
1279 return EFI_SUCCESS;
1280 }
1281 /**
1282 This is the declaration of an EFI image entry point. This entry point is
1283 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
1284 both device drivers and bus drivers.
1285
1286 @param[in] ImageHandle The firmware allocated handle for the UEFI image.
1287 @param[in] SystemTable A pointer to the EFI System Table.
1288
1289 @retval EFI_SUCCESS The operation completed successfully.
1290 @retval Others An unexpected error occurred.
1291
1292 **/
1293 EFI_STATUS
1294 EFIAPI
1295 HttpBootDxeDriverEntryPoint (
1296 IN EFI_HANDLE ImageHandle,
1297 IN EFI_SYSTEM_TABLE *SystemTable
1298 )
1299 {
1300 EFI_STATUS Status;
1301
1302 //
1303 // Install UEFI Driver Model protocol(s).
1304 //
1305 Status = EfiLibInstallDriverBindingComponentName2 (
1306 ImageHandle,
1307 SystemTable,
1308 &gHttpBootIp4DxeDriverBinding,
1309 ImageHandle,
1310 &gHttpBootDxeComponentName,
1311 &gHttpBootDxeComponentName2
1312 );
1313 if (EFI_ERROR (Status)) {
1314 return Status;
1315 }
1316
1317 Status = EfiLibInstallDriverBindingComponentName2 (
1318 ImageHandle,
1319 SystemTable,
1320 &gHttpBootIp6DxeDriverBinding,
1321 NULL,
1322 &gHttpBootDxeComponentName,
1323 &gHttpBootDxeComponentName2
1324 );
1325 if (EFI_ERROR (Status)) {
1326 gBS->UninstallMultipleProtocolInterfaces(
1327 ImageHandle,
1328 &gEfiDriverBindingProtocolGuid,
1329 &gHttpBootIp4DxeDriverBinding,
1330 &gEfiComponentName2ProtocolGuid,
1331 &gHttpBootDxeComponentName2,
1332 &gEfiComponentNameProtocolGuid,
1333 &gHttpBootDxeComponentName,
1334 NULL
1335 );
1336 }
1337 return Status;
1338 }
1339