]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/HttpBootDxe/HttpBootConfig.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootConfig.c
1 /** @file
2 Helper functions for configuring or getting the parameters relating to HTTP Boot.
3
4 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "HttpBootDxe.h"
10 #include <Library/UefiBootManagerLib.h>
11
12 CHAR16 mHttpBootConfigStorageName[] = L"HTTP_BOOT_CONFIG_IFR_NVDATA";
13
14 /**
15 Add new boot option for HTTP boot.
16
17 @param[in] Private Pointer to the driver private data.
18 @param[in] UsingIpv6 Set to TRUE if creating boot option for IPv6.
19 @param[in] Description The description text of the boot option.
20 @param[in] Uri The URI string of the boot file.
21
22 @retval EFI_SUCCESS The boot option is created successfully.
23 @retval Others Failed to create new boot option.
24
25 **/
26 EFI_STATUS
27 HttpBootAddBootOption (
28 IN HTTP_BOOT_PRIVATE_DATA *Private,
29 IN BOOLEAN UsingIpv6,
30 IN CHAR16 *Description,
31 IN CHAR16 *Uri
32 )
33 {
34 EFI_DEV_PATH *Node;
35 EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
36 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
37 UINTN Length;
38 CHAR8 AsciiUri[URI_STR_MAX_SIZE];
39 EFI_STATUS Status;
40 UINTN Index;
41 EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
42
43 NewDevicePath = NULL;
44 Node = NULL;
45 TmpDevicePath = NULL;
46
47 if (StrLen (Description) == 0) {
48 return EFI_INVALID_PARAMETER;
49 }
50
51 //
52 // Convert the scheme to all lower case.
53 //
54 for (Index = 0; Index < StrLen (Uri); Index++) {
55 if (Uri[Index] == L':') {
56 break;
57 }
58
59 if ((Uri[Index] >= L'A') && (Uri[Index] <= L'Z')) {
60 Uri[Index] -= (CHAR16)(L'A' - L'a');
61 }
62 }
63
64 //
65 // Only accept empty URI, or http and https URI.
66 //
67 if ((StrLen (Uri) != 0) && (StrnCmp (Uri, L"http://", 7) != 0) && (StrnCmp (Uri, L"https://", 8) != 0)) {
68 return EFI_INVALID_PARAMETER;
69 }
70
71 //
72 // Create a new device path by appending the IP node and URI node to
73 // the driver's parent device path
74 //
75 if (!UsingIpv6) {
76 Node = AllocateZeroPool (sizeof (IPv4_DEVICE_PATH));
77 if (Node == NULL) {
78 Status = EFI_OUT_OF_RESOURCES;
79 goto ON_EXIT;
80 }
81
82 Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
83 Node->Ipv4.Header.SubType = MSG_IPv4_DP;
84 SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
85 } else {
86 Node = AllocateZeroPool (sizeof (IPv6_DEVICE_PATH));
87 if (Node == NULL) {
88 Status = EFI_OUT_OF_RESOURCES;
89 goto ON_EXIT;
90 }
91
92 Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
93 Node->Ipv6.Header.SubType = MSG_IPv6_DP;
94 SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
95 }
96
97 TmpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
98 FreePool (Node);
99 if (TmpDevicePath == NULL) {
100 return EFI_OUT_OF_RESOURCES;
101 }
102
103 //
104 // Update the URI node with the input boot file URI.
105 //
106 UnicodeStrToAsciiStrS (Uri, AsciiUri, sizeof (AsciiUri));
107 Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize (AsciiUri);
108 Node = AllocatePool (Length);
109 if (Node == NULL) {
110 Status = EFI_OUT_OF_RESOURCES;
111 FreePool (TmpDevicePath);
112 goto ON_EXIT;
113 }
114
115 Node->DevPath.Type = MESSAGING_DEVICE_PATH;
116 Node->DevPath.SubType = MSG_URI_DP;
117 SetDevicePathNodeLength (Node, Length);
118 CopyMem ((UINT8 *)Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), AsciiUri, AsciiStrSize (AsciiUri));
119 NewDevicePath = AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
120 FreePool (Node);
121 FreePool (TmpDevicePath);
122 if (NewDevicePath == NULL) {
123 Status = EFI_OUT_OF_RESOURCES;
124 goto ON_EXIT;
125 }
126
127 //
128 // Add a new load option.
129 //
130 Status = EfiBootManagerInitializeLoadOption (
131 &NewOption,
132 LoadOptionNumberUnassigned,
133 LoadOptionTypeBoot,
134 LOAD_OPTION_ACTIVE,
135 Description,
136 NewDevicePath,
137 NULL,
138 0
139 );
140 if (EFI_ERROR (Status)) {
141 goto ON_EXIT;
142 }
143
144 Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN)-1);
145 EfiBootManagerFreeLoadOption (&NewOption);
146
147 ON_EXIT:
148
149 if (NewDevicePath != NULL) {
150 FreePool (NewDevicePath);
151 }
152
153 return Status;
154 }
155
156 /**
157
158 This function allows the caller to request the current
159 configuration for one or more named elements. The resulting
160 string is in <ConfigAltResp> format. Also, any and all alternative
161 configuration strings shall be appended to the end of the
162 current configuration string. If they are, they must appear
163 after the current configuration. They must contain the same
164 routing (GUID, NAME, PATH) as the current configuration string.
165 They must have an additional description indicating the type of
166 alternative configuration the string represents,
167 "ALTCFG=<StringToken>". That <StringToken> (when
168 converted from Hex UNICODE to binary) is a reference to a
169 string in the associated string pack.
170
171 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
172
173 @param[in] Request A null-terminated Unicode string in
174 <ConfigRequest> format. Note that this
175 includes the routing information as well as
176 the configurable name / value pairs. It is
177 invalid for this string to be in
178 <MultiConfigRequest> format.
179
180 @param[out] Progress On return, points to a character in the
181 Request string. Points to the string's null
182 terminator if request was successful. Points
183 to the most recent "&" before the first
184 failing name / value pair (or the beginning
185 of the string if the failure is in the first
186 name / value pair) if the request was not successful.
187
188 @param[out] Results A null-terminated Unicode string in
189 <ConfigAltResp> format which has all values
190 filled in for the names in the Request string.
191 String to be allocated by the called function.
192
193 @retval EFI_SUCCESS The Results string is filled with the
194 values corresponding to all requested
195 names.
196
197 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
198 parts of the results that must be
199 stored awaiting possible future
200 protocols.
201
202 @retval EFI_INVALID_PARAMETER For example, passing in a NULL
203 for the Request parameter
204 would result in this type of
205 error. In this case, the
206 Progress parameter would be
207 set to NULL.
208
209 @retval EFI_NOT_FOUND Routing data doesn't match any
210 known driver. Progress set to the
211 first character in the routing header.
212 Note: There is no requirement that the
213 driver validate the routing data. It
214 must skip the <ConfigHdr> in order to
215 process the names.
216
217 @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set
218 to most recent "&" before the
219 error or the beginning of the
220 string.
221
222 @retval EFI_INVALID_PARAMETER Unknown name. Progress points
223 to the & before the name in
224 question.
225
226 **/
227 EFI_STATUS
228 EFIAPI
229 HttpBootFormExtractConfig (
230 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
231 IN CONST EFI_STRING Request,
232 OUT EFI_STRING *Progress,
233 OUT EFI_STRING *Results
234 )
235 {
236 EFI_STATUS Status;
237 UINTN BufferSize;
238 HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
239 EFI_STRING ConfigRequestHdr;
240 EFI_STRING ConfigRequest;
241 BOOLEAN AllocatedRequest;
242 UINTN Size;
243
244 if ((Progress == NULL) || (Results == NULL)) {
245 return EFI_INVALID_PARAMETER;
246 }
247
248 *Progress = Request;
249 if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gHttpBootConfigGuid, mHttpBootConfigStorageName)) {
250 return EFI_NOT_FOUND;
251 }
252
253 ConfigRequestHdr = NULL;
254 ConfigRequest = NULL;
255 AllocatedRequest = FALSE;
256 Size = 0;
257
258 CallbackInfo = HTTP_BOOT_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
259 //
260 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
261 //
262 BufferSize = sizeof (HTTP_BOOT_CONFIG_IFR_NVDATA);
263 ZeroMem (&CallbackInfo->HttpBootNvData, BufferSize);
264 StrCpyS (CallbackInfo->HttpBootNvData.Description, DESCRIPTION_STR_MAX_SIZE / sizeof (CHAR16), HTTP_BOOT_DEFAULT_DESCRIPTION_STR);
265
266 ConfigRequest = Request;
267 if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
268 //
269 // Request has no request element, construct full request string.
270 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
271 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
272 //
273 ConfigRequestHdr = HiiConstructConfigHdr (&gHttpBootConfigGuid, mHttpBootConfigStorageName, CallbackInfo->ChildHandle);
274 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
275 ConfigRequest = AllocateZeroPool (Size);
276 if (ConfigRequest == NULL) {
277 return EFI_OUT_OF_RESOURCES;
278 }
279
280 AllocatedRequest = TRUE;
281 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
282 FreePool (ConfigRequestHdr);
283 }
284
285 Status = gHiiConfigRouting->BlockToConfig (
286 gHiiConfigRouting,
287 ConfigRequest,
288 (UINT8 *)&CallbackInfo->HttpBootNvData,
289 BufferSize,
290 Results,
291 Progress
292 );
293
294 //
295 // Free the allocated config request string.
296 //
297 if (AllocatedRequest) {
298 FreePool (ConfigRequest);
299 ConfigRequest = NULL;
300 }
301
302 //
303 // Set Progress string to the original request string.
304 //
305 if (Request == NULL) {
306 *Progress = NULL;
307 } else if (StrStr (Request, L"OFFSET") == NULL) {
308 *Progress = Request + StrLen (Request);
309 }
310
311 return Status;
312 }
313
314 /**
315
316 This function applies changes in a driver's configuration.
317 Input is a Configuration, which has the routing data for this
318 driver followed by name / value configuration pairs. The driver
319 must apply those pairs to its configurable storage. If the
320 driver's configuration is stored in a linear block of data
321 and the driver's name / value pairs are in <BlockConfig>
322 format, it may use the ConfigToBlock helper function (above) to
323 simplify the job.
324
325 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
326
327 @param[in] Configuration A null-terminated Unicode string in
328 <ConfigString> format.
329
330 @param[out] Progress A pointer to a string filled in with the
331 offset of the most recent '&' before the
332 first failing name / value pair (or the
333 beginning of the string if the failure
334 is in the first name / value pair) or
335 the terminating NULL if all was
336 successful.
337
338 @retval EFI_SUCCESS The results have been distributed or are
339 awaiting distribution.
340
341 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
342 parts of the results that must be
343 stored awaiting possible future
344 protocols.
345
346 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
347 Results parameter would result
348 in this type of error.
349
350 @retval EFI_NOT_FOUND Target for the specified routing data
351 was not found.
352
353 **/
354 EFI_STATUS
355 EFIAPI
356 HttpBootFormRouteConfig (
357 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
358 IN CONST EFI_STRING Configuration,
359 OUT EFI_STRING *Progress
360 )
361 {
362 EFI_STATUS Status;
363 UINTN BufferSize;
364 HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
365 HTTP_BOOT_PRIVATE_DATA *Private;
366
367 if (Progress == NULL) {
368 return EFI_INVALID_PARAMETER;
369 }
370
371 *Progress = Configuration;
372
373 if (Configuration == NULL) {
374 return EFI_INVALID_PARAMETER;
375 }
376
377 //
378 // Check routing data in <ConfigHdr>.
379 // Note: there is no name for Name/Value storage, only GUID will be checked
380 //
381 if (!HiiIsConfigHdrMatch (Configuration, &gHttpBootConfigGuid, mHttpBootConfigStorageName)) {
382 return EFI_NOT_FOUND;
383 }
384
385 CallbackInfo = HTTP_BOOT_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
386 Private = HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_INFO (CallbackInfo);
387
388 BufferSize = sizeof (HTTP_BOOT_CONFIG_IFR_NVDATA);
389 ZeroMem (&CallbackInfo->HttpBootNvData, BufferSize);
390
391 Status = gHiiConfigRouting->ConfigToBlock (
392 gHiiConfigRouting,
393 Configuration,
394 (UINT8 *)&CallbackInfo->HttpBootNvData,
395 &BufferSize,
396 Progress
397 );
398 if (EFI_ERROR (Status)) {
399 return Status;
400 }
401
402 //
403 // Create a new boot option according to the configuration data.
404 //
405 HttpBootAddBootOption (
406 Private,
407 (CallbackInfo->HttpBootNvData.IpVersion == HTTP_BOOT_IP_VERSION_6) ? TRUE : FALSE,
408 CallbackInfo->HttpBootNvData.Description,
409 CallbackInfo->HttpBootNvData.Uri
410 );
411
412 return EFI_SUCCESS;
413 }
414
415 /**
416
417 This function is called to provide results data to the driver.
418 This data consists of a unique key that is used to identify
419 which data is either being passed back or being asked for.
420
421 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
422 @param[in] Action Specifies the type of action taken by the browser.
423 @param[in] QuestionId A unique value which is sent to the original
424 exporting driver so that it can identify the type
425 of data to expect. The format of the data tends to
426 vary based on the opcode that generated the callback.
427 @param[in] Type The type of value for the question.
428 @param[in, out] Value A pointer to the data being sent to the original
429 exporting driver.
430 @param[out] ActionRequest On return, points to the action requested by the
431 callback function.
432
433 @retval EFI_SUCCESS The callback successfully handled the action.
434 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
435 variable and its data.
436 @retval EFI_DEVICE_ERROR The variable could not be saved.
437 @retval EFI_UNSUPPORTED The specified Action is not supported by the
438 callback.
439 **/
440 EFI_STATUS
441 EFIAPI
442 HttpBootFormCallback (
443 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
444 IN EFI_BROWSER_ACTION Action,
445 IN EFI_QUESTION_ID QuestionId,
446 IN UINT8 Type,
447 IN OUT EFI_IFR_TYPE_VALUE *Value,
448 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
449 )
450 {
451 EFI_INPUT_KEY Key;
452 CHAR16 *Uri;
453 UINTN UriLen;
454 CHAR8 *AsciiUri;
455 HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
456 EFI_STATUS Status;
457
458 Uri = NULL;
459 UriLen = 0;
460 AsciiUri = NULL;
461 Status = EFI_SUCCESS;
462
463 if ((This == NULL) || (Value == NULL)) {
464 return EFI_INVALID_PARAMETER;
465 }
466
467 CallbackInfo = HTTP_BOOT_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
468
469 if (Action != EFI_BROWSER_ACTION_CHANGING) {
470 return EFI_UNSUPPORTED;
471 }
472
473 switch (QuestionId) {
474 case KEY_INITIATOR_URI:
475 //
476 // Get user input URI string
477 //
478 Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
479 if (Uri == NULL) {
480 return EFI_INVALID_PARAMETER;
481 }
482
483 //
484 // The URI should be either an empty string (for corporate environment) ,or http(s) for home environment.
485 // Pop up a message box for the unsupported URI.
486 //
487 if (StrLen (Uri) != 0) {
488 UriLen = StrLen (Uri) + 1;
489 AsciiUri = AllocateZeroPool (UriLen);
490 if (AsciiUri == NULL) {
491 FreePool (Uri);
492 return EFI_OUT_OF_RESOURCES;
493 }
494
495 UnicodeStrToAsciiStrS (Uri, AsciiUri, UriLen);
496
497 Status = HttpBootCheckUriScheme (AsciiUri);
498
499 if (Status == EFI_INVALID_PARAMETER) {
500 DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status));
501
502 CreatePopUp (
503 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
504 &Key,
505 L"ERROR: Unsupported URI!",
506 L"Only supports HTTP and HTTPS",
507 NULL
508 );
509 } else if (Status == EFI_ACCESS_DENIED) {
510 DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status));
511
512 CreatePopUp (
513 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
514 &Key,
515 L"ERROR: Unsupported URI!",
516 L"HTTP is disabled",
517 NULL
518 );
519 }
520 }
521
522 if (Uri != NULL) {
523 FreePool (Uri);
524 }
525
526 if (AsciiUri != NULL) {
527 FreePool (AsciiUri);
528 }
529
530 break;
531
532 default:
533 break;
534 }
535
536 return Status;
537 }
538
539 /**
540 Initialize the configuration form.
541
542 @param[in] Private Pointer to the driver private data.
543
544 @retval EFI_SUCCESS The configuration form is initialized.
545 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
546
547 **/
548 EFI_STATUS
549 HttpBootConfigFormInit (
550 IN HTTP_BOOT_PRIVATE_DATA *Private
551 )
552 {
553 EFI_STATUS Status;
554 HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
555 VENDOR_DEVICE_PATH VendorDeviceNode;
556 CHAR16 *MacString;
557 CHAR16 *OldMenuString;
558 CHAR16 MenuString[128];
559
560 CallbackInfo = &Private->CallbackInfo;
561
562 if (CallbackInfo->Initialized) {
563 return EFI_SUCCESS;
564 }
565
566 CallbackInfo->Signature = HTTP_BOOT_FORM_CALLBACK_INFO_SIGNATURE;
567
568 //
569 // Construct device path node for EFI HII Config Access protocol,
570 // which consists of controller physical device path and one hardware
571 // vendor guid node.
572 //
573 ZeroMem (&VendorDeviceNode, sizeof (VENDOR_DEVICE_PATH));
574 VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH;
575 VendorDeviceNode.Header.SubType = HW_VENDOR_DP;
576 CopyGuid (&VendorDeviceNode.Guid, &gEfiCallerIdGuid);
577 SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH));
578 CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode (
579 Private->ParentDevicePath,
580 (EFI_DEVICE_PATH_PROTOCOL *)&VendorDeviceNode
581 );
582 if (CallbackInfo->HiiVendorDevicePath == NULL) {
583 Status = EFI_OUT_OF_RESOURCES;
584 goto Error;
585 }
586
587 CallbackInfo->ConfigAccess.ExtractConfig = HttpBootFormExtractConfig;
588 CallbackInfo->ConfigAccess.RouteConfig = HttpBootFormRouteConfig;
589 CallbackInfo->ConfigAccess.Callback = HttpBootFormCallback;
590
591 //
592 // Install Device Path Protocol and Config Access protocol to driver handle.
593 //
594 Status = gBS->InstallMultipleProtocolInterfaces (
595 &CallbackInfo->ChildHandle,
596 &gEfiDevicePathProtocolGuid,
597 CallbackInfo->HiiVendorDevicePath,
598 &gEfiHiiConfigAccessProtocolGuid,
599 &CallbackInfo->ConfigAccess,
600 NULL
601 );
602 if (EFI_ERROR (Status)) {
603 goto Error;
604 }
605
606 //
607 // Publish our HII data.
608 //
609 CallbackInfo->RegisteredHandle = HiiAddPackages (
610 &gHttpBootConfigGuid,
611 CallbackInfo->ChildHandle,
612 HttpBootDxeStrings,
613 HttpBootConfigVfrBin,
614 NULL
615 );
616 if (CallbackInfo->RegisteredHandle == NULL) {
617 Status = EFI_OUT_OF_RESOURCES;
618 goto Error;
619 }
620
621 //
622 // Append MAC string in the menu help string
623 //
624 Status = NetLibGetMacString (Private->Controller, NULL, &MacString);
625 if (!EFI_ERROR (Status)) {
626 OldMenuString = HiiGetString (
627 CallbackInfo->RegisteredHandle,
628 STRING_TOKEN (STR_HTTP_BOOT_CONFIG_FORM_HELP),
629 NULL
630 );
631 UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);
632 HiiSetString (
633 CallbackInfo->RegisteredHandle,
634 STRING_TOKEN (STR_HTTP_BOOT_CONFIG_FORM_HELP),
635 MenuString,
636 NULL
637 );
638
639 FreePool (MacString);
640 FreePool (OldMenuString);
641
642 CallbackInfo->Initialized = TRUE;
643 return EFI_SUCCESS;
644 }
645
646 Error:
647
648 HttpBootConfigFormUnload (Private);
649 return Status;
650 }
651
652 /**
653 Unload the configuration form, this includes: delete all the configuration
654 entries, uninstall the form callback protocol, and free the resources used.
655 The form will only be unload completely when both IP4 and IP6 stack are stopped.
656
657 @param[in] Private Pointer to the driver private data.
658
659 @retval EFI_SUCCESS The configuration form is unloaded.
660 @retval Others Failed to unload the form.
661
662 **/
663 EFI_STATUS
664 HttpBootConfigFormUnload (
665 IN HTTP_BOOT_PRIVATE_DATA *Private
666 )
667 {
668 HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
669
670 if ((Private->Ip4Nic != NULL) || (Private->Ip6Nic != NULL)) {
671 //
672 // Only unload the configuration form when both IP4 and IP6 stack are stopped.
673 //
674 return EFI_SUCCESS;
675 }
676
677 CallbackInfo = &Private->CallbackInfo;
678 if (CallbackInfo->ChildHandle != NULL) {
679 //
680 // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL
681 //
682 gBS->UninstallMultipleProtocolInterfaces (
683 CallbackInfo->ChildHandle,
684 &gEfiDevicePathProtocolGuid,
685 CallbackInfo->HiiVendorDevicePath,
686 &gEfiHiiConfigAccessProtocolGuid,
687 &CallbackInfo->ConfigAccess,
688 NULL
689 );
690 CallbackInfo->ChildHandle = NULL;
691 }
692
693 if (CallbackInfo->HiiVendorDevicePath != NULL) {
694 FreePool (CallbackInfo->HiiVendorDevicePath);
695 CallbackInfo->HiiVendorDevicePath = NULL;
696 }
697
698 if (CallbackInfo->RegisteredHandle != NULL) {
699 //
700 // Remove HII package list
701 //
702 HiiRemovePackages (CallbackInfo->RegisteredHandle);
703 CallbackInfo->RegisteredHandle = NULL;
704 }
705
706 return EFI_SUCCESS;
707 }