]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c
MdeModulePkg: Fix device path when boot manager menu is from different FV
[mirror_edk2.git] / MdeModulePkg / Library / VarCheckHiiLib / VarCheckHiiGenFromHii.c
1 /** @file
2 Var Check Hii generation from Hii Database.
3
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "VarCheckHiiGen.h"
10
11 /**
12 Generate from Hii Database.
13
14 **/
15 VOID
16 VarCheckHiiGenFromHiiDatabase (
17 VOID
18 )
19 {
20 EFI_STATUS Status;
21 UINTN BufferSize;
22 VOID *Buffer;
23 EFI_PHYSICAL_ADDRESS BufferAddress;
24 EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
25
26 //
27 // Locate HII Database protocol
28 //
29 Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &HiiDatabase);
30 if (EFI_ERROR (Status)) {
31 return;
32 }
33
34 //
35 // Call first time with zero buffer length.
36 // Should fail with EFI_BUFFER_TOO_SMALL.
37 //
38 BufferSize = 0;
39 Buffer = NULL;
40 Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer);
41 if (Status == EFI_BUFFER_TOO_SMALL) {
42 //
43 // Allocate buffer to hold the HII Database.
44 //
45 Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData, EFI_SIZE_TO_PAGES (BufferSize), &BufferAddress);
46 ASSERT_EFI_ERROR (Status);
47 Buffer = (VOID *) (UINTN) BufferAddress;
48
49 //
50 // Export HII Database into the buffer.
51 //
52 Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer);
53 ASSERT_EFI_ERROR (Status);
54
55 DEBUG ((DEBUG_INFO , "VarCheckHiiGenDxeFromHii - HII Database exported at 0x%x, size = 0x%x\n", Buffer, BufferSize));
56
57 #ifdef DUMP_HII_DATA
58 DEBUG_CODE (
59 DumpHiiDatabase (Buffer, BufferSize);
60 );
61 #endif
62
63 VarCheckParseHiiDatabase (Buffer, BufferSize);
64
65 gBS->FreePages (BufferAddress, EFI_SIZE_TO_PAGES (BufferSize));
66 }
67 }