]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/HttpBootDxe/HttpBootConfig.c
NetworkPkg: Replace UnicodeStrToAsciiStr/AsciiStrToUnicodeStr
[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, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. 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 #include <Library/UefiBootManagerLib.h>
17
18 CHAR16 mHttpBootConfigStorageName[] = L"HTTP_BOOT_CONFIG_IFR_NVDATA";
19
20 /**
21 Add new boot option for HTTP boot.
22
23 @param[in] Private Pointer to the driver private data.
24 @param[in] UsingIpv6 Set to TRUE if creating boot option for IPv6.
25 @param[in] Description The description text of the boot option.
26 @param[in] Uri The URI string of the boot file.
27
28 @retval EFI_SUCCESS The boot option is created successfully.
29 @retval Others Failed to create new boot option.
30
31 **/
32 EFI_STATUS
33 HttpBootAddBootOption (
34 IN HTTP_BOOT_PRIVATE_DATA *Private,
35 IN BOOLEAN UsingIpv6,
36 IN CHAR16 *Description,
37 IN CHAR16 *Uri
38 )
39 {
40 EFI_DEV_PATH *Node;
41 EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
42 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
43 UINTN Length;
44 CHAR8 AsciiUri[URI_STR_MAX_SIZE];
45 EFI_STATUS Status;
46 UINTN Index;
47 EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
48
49 NewDevicePath = NULL;
50 Node = NULL;
51 TmpDevicePath = NULL;
52
53 if (StrLen (Description) == 0) {
54 return EFI_INVALID_PARAMETER;
55 }
56
57 //
58 // Convert the scheme to all lower case.
59 //
60 for (Index = 0; Index < StrLen (Uri); Index++) {
61 if (Uri[Index] == L':') {
62 break;
63 }
64 if (Uri[Index] >= L'A' && Uri[Index] <= L'Z') {
65 Uri[Index] -= (CHAR16)(L'A' - L'a');
66 }
67 }
68
69 //
70 // Only accept empty URI, or http and https URI.
71 //
72 if ((StrLen (Uri) != 0) && (StrnCmp (Uri, L"http://", 7) != 0) && (StrnCmp (Uri, L"https://", 8) != 0)) {
73 return EFI_INVALID_PARAMETER;
74 }
75
76 //
77 // Create a new device path by appending the IP node and URI node to
78 // the driver's parent device path
79 //
80 if (!UsingIpv6) {
81 Node = AllocateZeroPool (sizeof (IPv4_DEVICE_PATH));
82 if (Node == NULL) {
83 Status = EFI_OUT_OF_RESOURCES;
84 goto ON_EXIT;
85 }
86 Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
87 Node->Ipv4.Header.SubType = MSG_IPv4_DP;
88 SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
89 } else {
90 Node = AllocateZeroPool (sizeof (IPv6_DEVICE_PATH));
91 if (Node == NULL) {
92 Status = EFI_OUT_OF_RESOURCES;
93 goto ON_EXIT;
94 }
95 Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
96 Node->Ipv6.Header.SubType = MSG_IPv6_DP;
97 SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
98 }
99 TmpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
100 FreePool (Node);
101 if (TmpDevicePath == NULL) {
102 return EFI_OUT_OF_RESOURCES;
103 }
104 //
105 // Update the URI node with the input boot file URI.
106 //
107 UnicodeStrToAsciiStrS (Uri, AsciiUri, sizeof (AsciiUri));
108 Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize (AsciiUri);
109 Node = AllocatePool (Length);
110 if (Node == NULL) {
111 Status = EFI_OUT_OF_RESOURCES;
112 FreePool (TmpDevicePath);
113 goto ON_EXIT;
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 ASSERT (ConfigRequest != NULL);
277 AllocatedRequest = TRUE;
278 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
279 FreePool (ConfigRequestHdr);
280 }
281
282 Status = gHiiConfigRouting->BlockToConfig (
283 gHiiConfigRouting,
284 ConfigRequest,
285 (UINT8 *) &CallbackInfo->HttpBootNvData,
286 BufferSize,
287 Results,
288 Progress
289 );
290
291 //
292 // Free the allocated config request string.
293 //
294 if (AllocatedRequest) {
295 FreePool (ConfigRequest);
296 ConfigRequest = NULL;
297 }
298 //
299 // Set Progress string to the original request string.
300 //
301 if (Request == NULL) {
302 *Progress = NULL;
303 } else if (StrStr (Request, L"OFFSET") == NULL) {
304 *Progress = Request + StrLen (Request);
305 }
306
307 return Status;
308 }
309
310 /**
311
312 This function applies changes in a driver's configuration.
313 Input is a Configuration, which has the routing data for this
314 driver followed by name / value configuration pairs. The driver
315 must apply those pairs to its configurable storage. If the
316 driver's configuration is stored in a linear block of data
317 and the driver's name / value pairs are in <BlockConfig>
318 format, it may use the ConfigToBlock helper function (above) to
319 simplify the job.
320
321 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
322
323 @param[in] Configuration A null-terminated Unicode string in
324 <ConfigString> format.
325
326 @param[out] Progress A pointer to a string filled in with the
327 offset of the most recent '&' before the
328 first failing name / value pair (or the
329 beginning of the string if the failure
330 is in the first name / value pair) or
331 the terminating NULL if all was
332 successful.
333
334 @retval EFI_SUCCESS The results have been distributed or are
335 awaiting distribution.
336
337 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
338 parts of the results that must be
339 stored awaiting possible future
340 protocols.
341
342 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
343 Results parameter would result
344 in this type of error.
345
346 @retval EFI_NOT_FOUND Target for the specified routing data
347 was not found.
348
349 **/
350 EFI_STATUS
351 EFIAPI
352 HttpBootFormRouteConfig (
353 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
354 IN CONST EFI_STRING Configuration,
355 OUT EFI_STRING *Progress
356 )
357 {
358 EFI_STATUS Status;
359 UINTN BufferSize;
360 HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
361 HTTP_BOOT_PRIVATE_DATA *Private;
362
363 if (Progress == NULL) {
364 return EFI_INVALID_PARAMETER;
365 }
366 *Progress = Configuration;
367
368 if (Configuration == NULL) {
369 return EFI_INVALID_PARAMETER;
370 }
371
372 //
373 // Check routing data in <ConfigHdr>.
374 // Note: there is no name for Name/Value storage, only GUID will be checked
375 //
376 if (!HiiIsConfigHdrMatch (Configuration, &gHttpBootConfigGuid, mHttpBootConfigStorageName)) {
377 return EFI_NOT_FOUND;
378 }
379
380 CallbackInfo = HTTP_BOOT_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
381 Private = HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_INFO (CallbackInfo);
382
383 BufferSize = sizeof (HTTP_BOOT_CONFIG_IFR_NVDATA);
384 ZeroMem (&CallbackInfo->HttpBootNvData, BufferSize);
385
386 Status = gHiiConfigRouting->ConfigToBlock (
387 gHiiConfigRouting,
388 Configuration,
389 (UINT8 *) &CallbackInfo->HttpBootNvData,
390 &BufferSize,
391 Progress
392 );
393 if (EFI_ERROR (Status)) {
394 return Status;
395 }
396
397 //
398 // Create a new boot option according to the configuration data.
399 //
400 HttpBootAddBootOption (
401 Private,
402 (CallbackInfo->HttpBootNvData.IpVersion == HTTP_BOOT_IP_VERSION_6) ? TRUE : FALSE,
403 CallbackInfo->HttpBootNvData.Description,
404 CallbackInfo->HttpBootNvData.Uri
405 );
406
407 return EFI_SUCCESS;
408 }
409
410 /**
411
412 This function is called to provide results data to the driver.
413 This data consists of a unique key that is used to identify
414 which data is either being passed back or being asked for.
415
416 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
417 @param[in] Action Specifies the type of action taken by the browser.
418 @param[in] QuestionId A unique value which is sent to the original
419 exporting driver so that it can identify the type
420 of data to expect. The format of the data tends to
421 vary based on the opcode that generated the callback.
422 @param[in] Type The type of value for the question.
423 @param[in, out] Value A pointer to the data being sent to the original
424 exporting driver.
425 @param[out] ActionRequest On return, points to the action requested by the
426 callback function.
427
428 @retval EFI_SUCCESS The callback successfully handled the action.
429 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
430 variable and its data.
431 @retval EFI_DEVICE_ERROR The variable could not be saved.
432 @retval EFI_UNSUPPORTED The specified Action is not supported by the
433 callback.
434 **/
435 EFI_STATUS
436 EFIAPI
437 HttpBootFormCallback (
438 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
439 IN EFI_BROWSER_ACTION Action,
440 IN EFI_QUESTION_ID QuestionId,
441 IN UINT8 Type,
442 IN OUT EFI_IFR_TYPE_VALUE *Value,
443 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
444 )
445 {
446 EFI_INPUT_KEY Key;
447 UINTN Index;
448 CHAR16 *Uri;
449 HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
450
451 if (This == NULL || Value == NULL) {
452 return EFI_INVALID_PARAMETER;
453 }
454
455 CallbackInfo = HTTP_BOOT_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
456
457 if (Action != EFI_BROWSER_ACTION_CHANGING) {
458 return EFI_UNSUPPORTED;
459 }
460
461 switch (QuestionId) {
462 case KEY_INITIATOR_URI:
463 //
464 // Get user input URI string
465 //
466 Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
467 ASSERT (Uri != NULL);
468 if (Uri == NULL) {
469 return EFI_UNSUPPORTED;
470 }
471
472 //
473 // Convert the scheme to all lower case.
474 //
475 for (Index = 0; Index < StrLen (Uri); Index++) {
476 if (Uri[Index] == L':') {
477 break;
478 }
479 if (Uri[Index] >= L'A' && Uri[Index] <= L'Z') {
480 Uri[Index] -= (CHAR16)(L'A' - L'a');
481 }
482 }
483
484 //
485 // Set the converted URI string back
486 //
487 HiiSetString (CallbackInfo->RegisteredHandle, Value->string, Uri, NULL);
488
489 //
490 // The URI should be either an empty string (for corporate environment) ,or http(s) for home environment.
491 // Pop up a message box for other unsupported URI.
492 //
493 if ((StrLen (Uri) != 0) && (StrnCmp (Uri, L"http://", 7) != 0) && (StrnCmp (Uri, L"https://", 8) != 0)) {
494 CreatePopUp (
495 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
496 &Key,
497 L"ERROR: Unsupported URI!",
498 L"Only supports HTTP and HTTPS",
499 NULL
500 );
501 }
502
503 FreePool (Uri);
504 break;
505
506 default:
507 break;
508 }
509
510 return EFI_SUCCESS;
511 }
512
513 /**
514 Initialize the configuration form.
515
516 @param[in] Private Pointer to the driver private data.
517
518 @retval EFI_SUCCESS The configuration form is initialized.
519 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
520
521 **/
522 EFI_STATUS
523 HttpBootConfigFormInit (
524 IN HTTP_BOOT_PRIVATE_DATA *Private
525 )
526 {
527 EFI_STATUS Status;
528 HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
529 VENDOR_DEVICE_PATH VendorDeviceNode;
530 CHAR16 *MacString;
531 CHAR16 *OldMenuString;
532 CHAR16 MenuString[128];
533
534 CallbackInfo = &Private->CallbackInfo;
535
536 if (CallbackInfo->Initilized) {
537 return EFI_SUCCESS;
538 }
539
540 CallbackInfo->Signature = HTTP_BOOT_FORM_CALLBACK_INFO_SIGNATURE;
541
542 //
543 // Construct device path node for EFI HII Config Access protocol,
544 // which consists of controller physical device path and one hardware
545 // vendor guid node.
546 //
547 ZeroMem (&VendorDeviceNode, sizeof (VENDOR_DEVICE_PATH));
548 VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH;
549 VendorDeviceNode.Header.SubType = HW_VENDOR_DP;
550 CopyGuid (&VendorDeviceNode.Guid, &gEfiCallerIdGuid);
551 SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH));
552 CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode (
553 Private->ParentDevicePath,
554 (EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode
555 );
556 if (CallbackInfo->HiiVendorDevicePath == NULL) {
557 Status = EFI_OUT_OF_RESOURCES;
558 goto Error;
559 }
560
561 CallbackInfo->ConfigAccess.ExtractConfig = HttpBootFormExtractConfig;
562 CallbackInfo->ConfigAccess.RouteConfig = HttpBootFormRouteConfig;
563 CallbackInfo->ConfigAccess.Callback = HttpBootFormCallback;
564
565 //
566 // Install Device Path Protocol and Config Access protocol to driver handle.
567 //
568 Status = gBS->InstallMultipleProtocolInterfaces (
569 &CallbackInfo->ChildHandle,
570 &gEfiDevicePathProtocolGuid,
571 CallbackInfo->HiiVendorDevicePath,
572 &gEfiHiiConfigAccessProtocolGuid,
573 &CallbackInfo->ConfigAccess,
574 NULL
575 );
576 if (EFI_ERROR (Status)) {
577 goto Error;
578 }
579
580 //
581 // Publish our HII data.
582 //
583 CallbackInfo->RegisteredHandle = HiiAddPackages (
584 &gHttpBootConfigGuid,
585 CallbackInfo->ChildHandle,
586 HttpBootDxeStrings,
587 HttpBootConfigVfrBin,
588 NULL
589 );
590 if (CallbackInfo->RegisteredHandle == NULL) {
591 Status = EFI_OUT_OF_RESOURCES;
592 goto Error;
593 }
594
595 //
596 // Append MAC string in the menu help string
597 //
598 Status = NetLibGetMacString (Private->Controller, NULL, &MacString);
599 if (!EFI_ERROR (Status)) {
600 OldMenuString = HiiGetString (
601 CallbackInfo->RegisteredHandle,
602 STRING_TOKEN (STR_HTTP_BOOT_CONFIG_FORM_HELP),
603 NULL
604 );
605 UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);
606 HiiSetString (
607 CallbackInfo->RegisteredHandle,
608 STRING_TOKEN (STR_HTTP_BOOT_CONFIG_FORM_HELP),
609 MenuString,
610 NULL
611 );
612
613 FreePool (MacString);
614 FreePool (OldMenuString);
615
616 CallbackInfo->Initilized = TRUE;
617 return EFI_SUCCESS;
618 }
619
620 Error:
621
622 HttpBootConfigFormUnload (Private);
623 return Status;
624 }
625
626 /**
627 Unload the configuration form, this includes: delete all the configuration
628 entries, uninstall the form callback protocol, and free the resources used.
629 The form will only be unload completely when both IP4 and IP6 stack are stopped.
630
631 @param[in] Private Pointer to the driver private data.
632
633 @retval EFI_SUCCESS The configuration form is unloaded.
634 @retval Others Failed to unload the form.
635
636 **/
637 EFI_STATUS
638 HttpBootConfigFormUnload (
639 IN HTTP_BOOT_PRIVATE_DATA *Private
640 )
641 {
642 HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
643
644 if (Private->Ip4Nic != NULL || Private->Ip6Nic != NULL) {
645 //
646 // Only unload the configuration form when both IP4 and IP6 stack are stopped.
647 //
648 return EFI_SUCCESS;
649 }
650
651 CallbackInfo = &Private->CallbackInfo;
652 if (CallbackInfo->ChildHandle != NULL) {
653 //
654 // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL
655 //
656 gBS->UninstallMultipleProtocolInterfaces (
657 CallbackInfo->ChildHandle,
658 &gEfiDevicePathProtocolGuid,
659 CallbackInfo->HiiVendorDevicePath,
660 &gEfiHiiConfigAccessProtocolGuid,
661 &CallbackInfo->ConfigAccess,
662 NULL
663 );
664 CallbackInfo->ChildHandle = NULL;
665 }
666
667 if (CallbackInfo->HiiVendorDevicePath != NULL) {
668 FreePool (CallbackInfo->HiiVendorDevicePath);
669 CallbackInfo->HiiVendorDevicePath = NULL;
670 }
671
672 if (CallbackInfo->RegisteredHandle != NULL) {
673 //
674 // Remove HII package list
675 //
676 HiiRemovePackages (CallbackInfo->RegisteredHandle);
677 CallbackInfo->RegisteredHandle = NULL;
678 }
679
680 return EFI_SUCCESS;
681 }