1 /** @file 2 Var Check Hii generation from Hii Database. 3 4 Copyright (c) 2015, 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 "VarCheckHiiGen.h" 16 17 /** 18 Generate from Hii Database. 19 20 **/ 21 VOID 22 VarCheckHiiGenFromHiiDatabase ( 23 VOID 24 ) 25 { 26 EFI_STATUS Status; 27 UINTN BufferSize; 28 VOID *Buffer; 29 EFI_PHYSICAL_ADDRESS BufferAddress; 30 EFI_HII_DATABASE_PROTOCOL *HiiDatabase; 31 32 // 33 // Locate HII Database protocol 34 // 35 Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &HiiDatabase); 36 if (EFI_ERROR (Status)) { 37 return; 38 } 39 40 // 41 // Call first time with zero buffer length. 42 // Should fail with EFI_BUFFER_TOO_SMALL. 43 // 44 BufferSize = 0; 45 Buffer = NULL; 46 Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer); 47 if (Status == EFI_BUFFER_TOO_SMALL) { 48 // 49 // Allocate buffer to hold the HII Database. 50 // 51 Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData, EFI_SIZE_TO_PAGES (BufferSize), &BufferAddress); 52 ASSERT_EFI_ERROR (Status); 53 Buffer = (VOID *) (UINTN) BufferAddress; 54 55 // 56 // Export HII Database into the buffer. 57 // 58 Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer); 59 ASSERT_EFI_ERROR (Status); 60 61 DEBUG ((EFI_D_INFO, "VarCheckHiiGenDxeFromHii - HII Database exported at 0x%x, size = 0x%x\n", Buffer, BufferSize)); 62 63 #ifdef DUMP_HII_DATA 64 DEBUG_CODE ( 65 DumpHiiDatabase (Buffer, BufferSize); 66 ); 67 #endif 68 69 VarCheckParseHiiDatabase (Buffer, BufferSize); 70 71 gBS->FreePages (BufferAddress, EFI_SIZE_TO_PAGES (BufferSize)); 72 } 73 } 74