2 Var Check Hii generation from Hii Database.
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "VarCheckHiiGen.h"
12 Generate from Hii Database.
16 VarCheckHiiGenFromHiiDatabase (
23 EFI_PHYSICAL_ADDRESS BufferAddress
;
24 EFI_HII_DATABASE_PROTOCOL
*HiiDatabase
;
27 // Locate HII Database protocol
29 Status
= gBS
->LocateProtocol (&gEfiHiiDatabaseProtocolGuid
, NULL
, (VOID
**) &HiiDatabase
);
30 if (EFI_ERROR (Status
)) {
35 // Call first time with zero buffer length.
36 // Should fail with EFI_BUFFER_TOO_SMALL.
40 Status
= HiiDatabase
->ExportPackageLists (HiiDatabase
, 0, &BufferSize
, Buffer
);
41 if (Status
== EFI_BUFFER_TOO_SMALL
) {
43 // Allocate buffer to hold the HII Database.
45 Status
= gBS
->AllocatePages (AllocateAnyPages
, EfiBootServicesData
, EFI_SIZE_TO_PAGES (BufferSize
), &BufferAddress
);
46 ASSERT_EFI_ERROR (Status
);
47 Buffer
= (VOID
*) (UINTN
) BufferAddress
;
50 // Export HII Database into the buffer.
52 Status
= HiiDatabase
->ExportPackageLists (HiiDatabase
, 0, &BufferSize
, Buffer
);
53 ASSERT_EFI_ERROR (Status
);
55 DEBUG ((DEBUG_INFO
, "VarCheckHiiGenDxeFromHii - HII Database exported at 0x%x, size = 0x%x\n", Buffer
, BufferSize
));
59 DumpHiiDatabase (Buffer
, BufferSize
);
63 VarCheckParseHiiDatabase (Buffer
, BufferSize
);
65 gBS
->FreePages (BufferAddress
, EFI_SIZE_TO_PAGES (BufferSize
));