MdeModulePkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the MdeModulePkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:02 -08:00
committed by mergify[bot]
parent 7c7184e201
commit 1436aea4d5
994 changed files with 107608 additions and 101311 deletions

View File

@@ -20,60 +20,60 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define VAR_CHECK_HII_REVISION 0x0002
typedef struct {
UINT16 Revision;
UINT16 HeaderLength;
UINT32 Length; // Length include this header
UINT8 OpCode;
UINT8 Reserved;
UINT16 Size;
UINT32 Attributes;
EFI_GUID Guid;
//CHAR16 Name[];
UINT16 Revision;
UINT16 HeaderLength;
UINT32 Length; // Length include this header
UINT8 OpCode;
UINT8 Reserved;
UINT16 Size;
UINT32 Attributes;
EFI_GUID Guid;
// CHAR16 Name[];
} VAR_CHECK_HII_VARIABLE_HEADER;
typedef struct {
UINT8 OpCode;
UINT8 Length; // Length include this header
UINT16 VarOffset;
UINT8 StorageWidth;
BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
UINT8 OpCode;
UINT8 Length; // Length include this header
UINT16 VarOffset;
UINT8 StorageWidth;
BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
} VAR_CHECK_HII_QUESTION_HEADER;
typedef struct {
UINT8 OpCode;
UINT8 Length; // Length include this header
UINT16 VarOffset;
UINT8 StorageWidth;
BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
//UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64;
UINT8 OpCode;
UINT8 Length; // Length include this header
UINT16 VarOffset;
UINT8 StorageWidth;
BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
// UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64;
} VAR_CHECK_HII_QUESTION_ONEOF;
typedef struct {
UINT8 OpCode;
UINT8 Length; // Length include this header
UINT16 VarOffset;
UINT8 StorageWidth;
BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
UINT8 OpCode;
UINT8 Length; // Length include this header
UINT16 VarOffset;
UINT8 StorageWidth;
BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
} VAR_CHECK_HII_QUESTION_CHECKBOX;
typedef struct {
UINT8 OpCode;
UINT8 Length; // Length include this header
UINT16 VarOffset;
UINT8 StorageWidth;
BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
//UINTx Minimum; // x = UINT8/UINT16/UINT32/UINT64;
//UINTx Maximum; // x = UINT8/UINT16/UINT32/UINT64;
UINT8 OpCode;
UINT8 Length; // Length include this header
UINT16 VarOffset;
UINT8 StorageWidth;
BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
// UINTx Minimum; // x = UINT8/UINT16/UINT32/UINT64;
// UINTx Maximum; // x = UINT8/UINT16/UINT32/UINT64;
} VAR_CHECK_HII_QUESTION_NUMERIC;
typedef struct {
UINT8 OpCode;
UINT8 Length; // Length include this header
UINT16 VarOffset;
UINT8 StorageWidth;
BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
UINT8 MaxContainers;
//UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64;
UINT8 OpCode;
UINT8 Length; // Length include this header
UINT16 VarOffset;
UINT8 StorageWidth;
BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
UINT8 MaxContainers;
// UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64;
} VAR_CHECK_HII_QUESTION_ORDEREDLIST;
#pragma pack ()

View File

@@ -25,17 +25,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "InternalVarCheckStructure.h"
#include "VarCheckHiiGen.h"
//#define DUMP_VAR_CHECK_HII
//#define DUMP_HII_DATA
// #define DUMP_VAR_CHECK_HII
// #define DUMP_HII_DATA
typedef struct {
UINT8 HiiOpCode;
CHAR8 *HiiOpCodeStr;
UINT8 HiiOpCode;
CHAR8 *HiiOpCodeStr;
} VAR_CHECK_HII_OPCODE_STRING;
typedef struct {
UINT8 PackageType;
CHAR8 *PackageTypeStr;
UINT8 PackageType;
CHAR8 *PackageTypeStr;
} VAR_CHECK_HII_PACKAGE_TYPE_STRING;
/**
@@ -51,7 +51,7 @@ DumpVarCheckHii (
IN UINTN VarCheckHiiBinSize
);
extern VAR_CHECK_HII_VARIABLE_HEADER *mVarCheckHiiBin;
extern UINTN mVarCheckHiiBinSize;
extern VAR_CHECK_HII_VARIABLE_HEADER *mVarCheckHiiBin;
extern UINTN mVarCheckHiiBinSize;
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -19,7 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
VOID
DumpHiiPackage (
IN VOID *HiiPackage
IN VOID *HiiPackage
);
/**
@@ -31,8 +31,8 @@ DumpHiiPackage (
**/
VOID
DumpHiiDatabase (
IN VOID *HiiDatabase,
IN UINTN HiiDatabaseSize
IN VOID *HiiDatabase,
IN UINTN HiiDatabaseSize
);
/**
@@ -50,7 +50,7 @@ DumpHiiDatabase (
**/
VOID *
InternalVarCheckAllocateZeroPool (
IN UINTN AllocationSize
IN UINTN AllocationSize
);
/**
@@ -70,7 +70,7 @@ InternalVarCheckAllocateZeroPool (
VOID
EFIAPI
InternalVarCheckFreePool (
IN VOID *Buffer
IN VOID *Buffer
);
/**
@@ -82,8 +82,8 @@ InternalVarCheckFreePool (
**/
VOID
VarCheckParseHiiPackage (
IN VOID *HiiPackage,
IN BOOLEAN FromFv
IN VOID *HiiPackage,
IN BOOLEAN FromFv
);
/**
@@ -95,8 +95,8 @@ VarCheckParseHiiPackage (
**/
VOID
VarCheckParseHiiDatabase (
IN VOID *HiiDatabase,
IN UINTN HiiDatabaseSize
IN VOID *HiiDatabase,
IN UINTN HiiDatabaseSize
);
/**

View File

@@ -12,26 +12,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_VFR_ATTRACT_GUID \
{ 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } }
EFI_GUID gVfrArrayAttractGuid = EFI_VFR_ATTRACT_GUID;
EFI_GUID gVfrArrayAttractGuid = EFI_VFR_ATTRACT_GUID;
#define ALL_FF_GUID \
{ 0xFFFFFFFF, 0xFFFF, 0xFFFF, { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } }
EFI_GUID mAllFfGuid = ALL_FF_GUID;
EFI_GUID mAllFfGuid = ALL_FF_GUID;
#define VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE SIGNATURE_32 ('V', 'D', 'R', 'I')
#define VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE SIGNATURE_32 ('V', 'D', 'R', 'I')
typedef struct {
UINTN Signature;
LIST_ENTRY Link;
EFI_GUID *DriverGuid;
UINTN Signature;
LIST_ENTRY Link;
EFI_GUID *DriverGuid;
} VAR_CHECK_VFR_DRIVER_INFO;
LIST_ENTRY mVfrDriverList = INITIALIZE_LIST_HEAD_VARIABLE (mVfrDriverList);
LIST_ENTRY mVfrDriverList = INITIALIZE_LIST_HEAD_VARIABLE (mVfrDriverList);
#define VAR_CHECK_VFR_DRIVER_INFO_FROM_LINK(a) CR (a, VAR_CHECK_VFR_DRIVER_INFO, Link, VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE)
#define MAX_MATCH_GUID_NUM 100
#define MAX_MATCH_GUID_NUM 100
/**
Get the address by Guid.
@@ -51,17 +51,17 @@ LIST_ENTRY mVfrDriverList = INITIALIZE_LIST_HEAD_VARIABLE (
**/
EFI_STATUS
GetAddressByGuid (
IN VOID *Ffs,
IN EFI_GUID *Guid,
IN UINTN Length,
OUT UINTN **Offset,
OUT UINT8 *NumOfMatchingGuid
IN VOID *Ffs,
IN EFI_GUID *Guid,
IN UINTN Length,
OUT UINTN **Offset,
OUT UINT8 *NumOfMatchingGuid
)
{
UINTN LoopControl;
BOOLEAN Found;
UINTN LoopControl;
BOOLEAN Found;
if((Ffs == NULL) || (Guid == NULL) || (Length == 0)){
if ((Ffs == NULL) || (Guid == NULL) || (Length == 0)) {
return EFI_NOT_FOUND;
}
@@ -71,7 +71,7 @@ GetAddressByGuid (
Found = FALSE;
for (LoopControl = 0; LoopControl < Length; LoopControl++) {
if (CompareGuid (Guid, (EFI_GUID *) ((UINT8 *) Ffs + LoopControl))) {
if (CompareGuid (Guid, (EFI_GUID *)((UINT8 *)Ffs + LoopControl))) {
Found = TRUE;
//
// If NumOfMatchGuid or Offset are NULL, means user only want
@@ -82,6 +82,7 @@ GetAddressByGuid (
*Offset = InternalVarCheckAllocateZeroPool (sizeof (UINTN) * MAX_MATCH_GUID_NUM);
ASSERT (*Offset != NULL);
}
*(*Offset + *NumOfMatchingGuid) = LoopControl + sizeof (EFI_GUID);
(*NumOfMatchingGuid)++;
} else {
@@ -110,20 +111,21 @@ GetAddressByGuid (
**/
EFI_STATUS
SearchVfrBinInFfs (
IN VOID *Ffs,
IN VOID *EfiAddr,
IN UINTN Length,
OUT UINTN **Offset,
OUT UINT8 *NumOfMatchingOffset
IN VOID *Ffs,
IN VOID *EfiAddr,
IN UINTN Length,
OUT UINTN **Offset,
OUT UINT8 *NumOfMatchingOffset
)
{
UINTN Index;
EFI_STATUS Status;
UINTN VirOffValue;
UINTN Index;
EFI_STATUS Status;
UINTN VirOffValue;
if ((Ffs == NULL) || (Offset == NULL)) {
return EFI_NOT_FOUND;
}
Status = GetAddressByGuid (
Ffs,
&gVfrArrayAttractGuid,
@@ -139,11 +141,11 @@ SearchVfrBinInFfs (
//
// Got the virOffset after the GUID
//
VirOffValue = *(UINTN *) ((UINTN) Ffs + *(*Offset + Index));
VirOffValue = *(UINTN *)((UINTN)Ffs + *(*Offset + Index));
//
// Transfer the offset to the VA address. One modules may own multiple VfrBin address.
//
*(*Offset + Index) = (UINTN) EfiAddr + VirOffValue;
*(*Offset + Index) = (UINTN)EfiAddr + VirOffValue;
}
return Status;
@@ -164,17 +166,17 @@ ParseFfs (
IN EFI_GUID *DriverGuid
)
{
EFI_STATUS Status;
EFI_FV_FILETYPE FoundType;
EFI_FV_FILE_ATTRIBUTES FileAttributes;
UINT32 AuthenticationStatus;
UINTN Size;
VOID *Buffer;
UINTN SectionSize;
VOID *SectionBuffer;
UINTN VfrBinIndex;
UINT8 NumberofMatchingVfrBin;
UINTN *VfrBinBaseAddress;
EFI_STATUS Status;
EFI_FV_FILETYPE FoundType;
EFI_FV_FILE_ATTRIBUTES FileAttributes;
UINT32 AuthenticationStatus;
UINTN Size;
VOID *Buffer;
UINTN SectionSize;
VOID *SectionBuffer;
UINTN VfrBinIndex;
UINT8 NumberofMatchingVfrBin;
UINTN *VfrBinBaseAddress;
Status = Fv2->ReadFile (
Fv2,
@@ -199,42 +201,42 @@ ParseFfs (
&Size,
&AuthenticationStatus
);
if (!EFI_ERROR (Status)) {
Status = SearchVfrBinInFfs (Buffer, 0, Size, &VfrBinBaseAddress, &NumberofMatchingVfrBin);
if (!EFI_ERROR (Status)) {
SectionBuffer = NULL;
Status = Fv2->ReadSection (
Fv2,
DriverGuid,
EFI_SECTION_PE32,
0, // Instance
&SectionBuffer,
&SectionSize,
&AuthenticationStatus
);
if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO , "FfsNameGuid - %g\n", DriverGuid));
DEBUG ((DEBUG_INFO , "NumberofMatchingVfrBin - 0x%02x\n", NumberofMatchingVfrBin));
if (!EFI_ERROR (Status)) {
Status = SearchVfrBinInFfs (Buffer, 0, Size, &VfrBinBaseAddress, &NumberofMatchingVfrBin);
if (!EFI_ERROR (Status)) {
SectionBuffer = NULL;
Status = Fv2->ReadSection (
Fv2,
DriverGuid,
EFI_SECTION_PE32,
0, // Instance
&SectionBuffer,
&SectionSize,
&AuthenticationStatus
);
if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "FfsNameGuid - %g\n", DriverGuid));
DEBUG ((DEBUG_INFO, "NumberofMatchingVfrBin - 0x%02x\n", NumberofMatchingVfrBin));
for (VfrBinIndex = 0; VfrBinIndex < NumberofMatchingVfrBin; VfrBinIndex++) {
#ifdef DUMP_HII_DATA
DEBUG_CODE (
DumpHiiPackage ((UINT8 *) (UINTN) SectionBuffer + VfrBinBaseAddress[VfrBinIndex] + sizeof (UINT32));
);
#endif
VarCheckParseHiiPackage ((UINT8 *) (UINTN) SectionBuffer + VfrBinBaseAddress[VfrBinIndex] + sizeof (UINT32), TRUE);
}
FreePool (SectionBuffer);
for (VfrBinIndex = 0; VfrBinIndex < NumberofMatchingVfrBin; VfrBinIndex++) {
#ifdef DUMP_HII_DATA
DEBUG_CODE (
DumpHiiPackage ((UINT8 *)(UINTN)SectionBuffer + VfrBinBaseAddress[VfrBinIndex] + sizeof (UINT32));
);
#endif
VarCheckParseHiiPackage ((UINT8 *)(UINTN)SectionBuffer + VfrBinBaseAddress[VfrBinIndex] + sizeof (UINT32), TRUE);
}
InternalVarCheckFreePool (VfrBinBaseAddress);
FreePool (SectionBuffer);
}
FreePool (Buffer);
InternalVarCheckFreePool (VfrBinBaseAddress);
}
return TRUE;
FreePool (Buffer);
}
return TRUE;
}
/**
@@ -245,31 +247,31 @@ ParseFfs (
**/
VOID
ParseFv (
IN BOOLEAN ScanAll
IN BOOLEAN ScanAll
)
{
EFI_STATUS Status;
EFI_HANDLE *HandleBuffer;
UINTN HandleCount;
UINTN Index;
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv2;
VOID *Key;
EFI_FV_FILETYPE FileType;
EFI_GUID NameGuid;
EFI_FV_FILE_ATTRIBUTES FileAttributes;
UINTN Size;
UINTN FfsIndex;
VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
LIST_ENTRY *VfrDriverLink;
EFI_STATUS Status;
EFI_HANDLE *HandleBuffer;
UINTN HandleCount;
UINTN Index;
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv2;
VOID *Key;
EFI_FV_FILETYPE FileType;
EFI_GUID NameGuid;
EFI_FV_FILE_ATTRIBUTES FileAttributes;
UINTN Size;
UINTN FfsIndex;
VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
LIST_ENTRY *VfrDriverLink;
HandleBuffer = NULL;
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiFirmwareVolume2ProtocolGuid,
NULL,
&HandleCount,
&HandleBuffer
);
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiFirmwareVolume2ProtocolGuid,
NULL,
&HandleCount,
&HandleBuffer
);
if (EFI_ERROR (Status)) {
return;
}
@@ -278,31 +280,32 @@ ParseFv (
// Search all FVs
//
for (Index = 0; Index < HandleCount; Index++) {
DEBUG ((DEBUG_INFO , "FvIndex - %x\n", Index));
DEBUG ((DEBUG_INFO, "FvIndex - %x\n", Index));
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiFirmwareVolume2ProtocolGuid,
(VOID **) &Fv2
(VOID **)&Fv2
);
ASSERT_EFI_ERROR (Status);
DEBUG_CODE_BEGIN ();
EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *Fvb2;
EFI_PHYSICAL_ADDRESS FvAddress;
UINT64 FvSize;
EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *Fvb2;
EFI_PHYSICAL_ADDRESS FvAddress;
UINT64 FvSize;
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiFirmwareVolumeBlock2ProtocolGuid,
(VOID **)&Fvb2
);
ASSERT_EFI_ERROR (Status);
Status = Fvb2->GetPhysicalAddress (Fvb2, &FvAddress);
if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "FvAddress - 0x%08x\n", FvAddress));
FvSize = ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvAddress)->FvLength;
DEBUG ((DEBUG_INFO, "FvSize - 0x%08x\n", FvSize));
}
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiFirmwareVolumeBlock2ProtocolGuid,
(VOID **) &Fvb2
);
ASSERT_EFI_ERROR (Status);
Status = Fvb2->GetPhysicalAddress (Fvb2, &FvAddress);
if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO , "FvAddress - 0x%08x\n", FvAddress));
FvSize = ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvAddress)->FvLength;
DEBUG ((DEBUG_INFO , "FvSize - 0x%08x\n", FvSize));
}
DEBUG_CODE_END ();
if (ScanAll) {
@@ -314,14 +317,14 @@ ParseFv (
for (FfsIndex = 0; ; FfsIndex++) {
FileType = EFI_FV_FILETYPE_ALL;
Status = Fv2->GetNextFile (
Fv2,
Key,
&FileType,
&NameGuid,
&FileAttributes,
&Size
);
Status = Fv2->GetNextFile (
Fv2,
Key,
&FileType,
&NameGuid,
&FileAttributes,
&Size
);
if (EFI_ERROR (Status)) {
break;
}
@@ -360,19 +363,19 @@ ParseFv (
**/
VOID
CreateVfrDriverList (
IN EFI_GUID *DriverGuidArray
IN EFI_GUID *DriverGuidArray
)
{
UINTN Index;
VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
UINTN Index;
VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
for (Index = 0; !IsZeroGuid (&DriverGuidArray[Index]); Index++) {
DEBUG ((DEBUG_INFO , "CreateVfrDriverList: %g\n", &DriverGuidArray[Index]));
VfrDriverInfo = InternalVarCheckAllocateZeroPool (sizeof (*VfrDriverInfo));
ASSERT (VfrDriverInfo != NULL);
VfrDriverInfo->Signature = VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE;
VfrDriverInfo->DriverGuid = &DriverGuidArray[Index];
InsertTailList (&mVfrDriverList, &VfrDriverInfo->Link);
DEBUG ((DEBUG_INFO, "CreateVfrDriverList: %g\n", &DriverGuidArray[Index]));
VfrDriverInfo = InternalVarCheckAllocateZeroPool (sizeof (*VfrDriverInfo));
ASSERT (VfrDriverInfo != NULL);
VfrDriverInfo->Signature = VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE;
VfrDriverInfo->DriverGuid = &DriverGuidArray[Index];
InsertTailList (&mVfrDriverList, &VfrDriverInfo->Link);
}
}
@@ -385,8 +388,8 @@ DestroyVfrDriverList (
VOID
)
{
VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
LIST_ENTRY *VfrDriverLink;
VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
LIST_ENTRY *VfrDriverLink;
while (mVfrDriverList.ForwardLink != &mVfrDriverList) {
VfrDriverLink = mVfrDriverList.ForwardLink;
@@ -405,15 +408,15 @@ VarCheckHiiGenFromFv (
VOID
)
{
EFI_GUID *DriverGuidArray;
BOOLEAN ScanAll;
EFI_GUID *DriverGuidArray;
BOOLEAN ScanAll;
DEBUG ((DEBUG_INFO , "VarCheckHiiGenDxeFromFv\n"));
DEBUG ((DEBUG_INFO, "VarCheckHiiGenDxeFromFv\n"));
//
// Get vfr driver guid array from PCD.
//
DriverGuidArray = (EFI_GUID *) PcdGetPtr (PcdVarCheckVfrDriverGuidArray);
DriverGuidArray = (EFI_GUID *)PcdGetPtr (PcdVarCheckVfrDriverGuidArray);
if (IsZeroGuid (&DriverGuidArray[0])) {
//

View File

@@ -17,16 +17,16 @@ VarCheckHiiGenFromHiiDatabase (
VOID
)
{
EFI_STATUS Status;
UINTN BufferSize;
VOID *Buffer;
EFI_PHYSICAL_ADDRESS BufferAddress;
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
EFI_STATUS Status;
UINTN BufferSize;
VOID *Buffer;
EFI_PHYSICAL_ADDRESS BufferAddress;
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
//
// Locate HII Database protocol
//
Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &HiiDatabase);
Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&HiiDatabase);
if (EFI_ERROR (Status)) {
return;
}
@@ -36,15 +36,15 @@ VarCheckHiiGenFromHiiDatabase (
// Should fail with EFI_BUFFER_TOO_SMALL.
//
BufferSize = 0;
Buffer = NULL;
Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer);
Buffer = NULL;
Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
//
// Allocate buffer to hold the HII Database.
//
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData, EFI_SIZE_TO_PAGES (BufferSize), &BufferAddress);
ASSERT_EFI_ERROR (Status);
Buffer = (VOID *) (UINTN) BufferAddress;
Buffer = (VOID *)(UINTN)BufferAddress;
//
// Export HII Database into the buffer.
@@ -52,13 +52,13 @@ VarCheckHiiGenFromHiiDatabase (
Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer);
ASSERT_EFI_ERROR (Status);
DEBUG ((DEBUG_INFO , "VarCheckHiiGenDxeFromHii - HII Database exported at 0x%x, size = 0x%x\n", Buffer, BufferSize));
DEBUG ((DEBUG_INFO, "VarCheckHiiGenDxeFromHii - HII Database exported at 0x%x, size = 0x%x\n", Buffer, BufferSize));
#ifdef DUMP_HII_DATA
#ifdef DUMP_HII_DATA
DEBUG_CODE (
DumpHiiDatabase (Buffer, BufferSize);
);
#endif
#endif
VarCheckParseHiiDatabase (Buffer, BufferSize);

View File

@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "VarCheckHii.h"
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckHiiHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckHiiHex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
/**
Dump some hexadecimal data.
@@ -21,21 +21,21 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckHiiHex[] = {'0', '1', '2', '3
**/
VOID
VarCheckHiiInternalDumpHex (
IN UINTN Indent,
IN UINTN Offset,
IN UINTN DataSize,
IN VOID *UserData
IN UINTN Indent,
IN UINTN Offset,
IN UINTN DataSize,
IN VOID *UserData
)
{
UINT8 *Data;
UINT8 *Data;
CHAR8 Val[50];
CHAR8 Val[50];
CHAR8 Str[20];
CHAR8 Str[20];
UINT8 TempByte;
UINTN Size;
UINTN Index;
UINT8 TempByte;
UINTN Size;
UINTN Index;
Data = UserData;
while (DataSize != 0) {
@@ -45,19 +45,19 @@ VarCheckHiiInternalDumpHex (
}
for (Index = 0; Index < Size; Index += 1) {
TempByte = Data[Index];
Val[Index * 3 + 0] = mVarCheckHiiHex[TempByte >> 4];
Val[Index * 3 + 1] = mVarCheckHiiHex[TempByte & 0xF];
Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');
Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
TempByte = Data[Index];
Val[Index * 3 + 0] = mVarCheckHiiHex[TempByte >> 4];
Val[Index * 3 + 1] = mVarCheckHiiHex[TempByte & 0xF];
Val[Index * 3 + 2] = (CHAR8)((Index == 7) ? '-' : ' ');
Str[Index] = (CHAR8)((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
}
Val[Index * 3] = 0;
Str[Index] = 0;
DEBUG ((DEBUG_INFO , "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str));
Val[Index * 3] = 0;
Str[Index] = 0;
DEBUG ((DEBUG_INFO, "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str));
Data += Size;
Offset += Size;
Data += Size;
Offset += Size;
DataSize -= Size;
}
}
@@ -80,35 +80,35 @@ VarCheckHiiQuestion (
IN UINTN DataSize
)
{
UINT64 OneData;
UINT64 Minimum;
UINT64 Maximum;
UINT64 OneValue;
UINT8 *Ptr;
UINT8 Index;
UINT8 MaxContainers;
UINT8 StartBit;
UINT8 EndBit;
UINT8 TotalBits;
UINT16 VarOffsetByteLevel;
UINT8 StorageWidthByteLevel;
UINT64 OneData;
UINT64 Minimum;
UINT64 Maximum;
UINT64 OneValue;
UINT8 *Ptr;
UINT8 Index;
UINT8 MaxContainers;
UINT8 StartBit;
UINT8 EndBit;
UINT8 TotalBits;
UINT16 VarOffsetByteLevel;
UINT8 StorageWidthByteLevel;
if (HiiQuestion->BitFieldStore) {
VarOffsetByteLevel = HiiQuestion->VarOffset / 8;
TotalBits = HiiQuestion->VarOffset % 8 + HiiQuestion->StorageWidth;
StorageWidthByteLevel = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1);
StorageWidthByteLevel = (TotalBits % 8 == 0 ? TotalBits / 8 : TotalBits / 8 + 1);
} else {
VarOffsetByteLevel = HiiQuestion->VarOffset;
StorageWidthByteLevel = HiiQuestion->StorageWidth;
}
if (((UINT32) VarOffsetByteLevel + StorageWidthByteLevel) > DataSize) {
DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", VarOffsetByteLevel, StorageWidthByteLevel, DataSize));
if (((UINT32)VarOffsetByteLevel + StorageWidthByteLevel) > DataSize) {
DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", VarOffsetByteLevel, StorageWidthByteLevel, DataSize));
return FALSE;
}
OneData = 0;
CopyMem (&OneData, (UINT8 *) Data + VarOffsetByteLevel, StorageWidthByteLevel);
CopyMem (&OneData, (UINT8 *)Data + VarOffsetByteLevel, StorageWidthByteLevel);
if (HiiQuestion->BitFieldStore) {
//
// Get the value from the bit field.
@@ -120,8 +120,8 @@ VarCheckHiiQuestion (
switch (HiiQuestion->OpCode) {
case EFI_IFR_ONE_OF_OP:
Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1);
while ((UINTN) Ptr < (UINTN) HiiQuestion + HiiQuestion->Length) {
Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_ONEOF *)HiiQuestion + 1);
while ((UINTN)Ptr < (UINTN)HiiQuestion + HiiQuestion->Length) {
OneValue = 0;
if (HiiQuestion->BitFieldStore) {
//
@@ -131,40 +131,49 @@ VarCheckHiiQuestion (
} else {
CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);
}
if (OneData == OneValue) {
//
// Match
//
break;
}
if (HiiQuestion->BitFieldStore) {
Ptr += sizeof (UINT32);
} else {
Ptr += HiiQuestion->StorageWidth;
}
}
if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) {
if ((UINTN)Ptr >= ((UINTN)HiiQuestion + HiiQuestion->Length)) {
//
// No match
//
DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: OneOf mismatch (0x%lx)\n", OneData));
DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););
DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: OneOf mismatch (0x%lx)\n", OneData));
DEBUG_CODE (
VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
);
return FALSE;
}
break;
case EFI_IFR_CHECKBOX_OP:
if ((OneData != 0) && (OneData != 1)) {
DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: CheckBox mismatch (0x%lx)\n", OneData));
DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););
DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: CheckBox mismatch (0x%lx)\n", OneData));
DEBUG_CODE (
VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
);
return FALSE;
}
break;
case EFI_IFR_NUMERIC_OP:
Minimum = 0;
Maximum = 0;
Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1);
Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_NUMERIC *)HiiQuestion + 1);
if (HiiQuestion->BitFieldStore) {
//
// For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type.
@@ -184,21 +193,25 @@ VarCheckHiiQuestion (
// No need to check Step, because it is ONLY for UI.
//
if ((OneData < Minimum) || (OneData > Maximum)) {
DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: Numeric mismatch (0x%lx)\n", OneData));
DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););
DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: Numeric mismatch (0x%lx)\n", OneData));
DEBUG_CODE (
VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
);
return FALSE;
}
break;
case EFI_IFR_ORDERED_LIST_OP:
MaxContainers = ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers;
if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth * MaxContainers) > DataSize) {
DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x) * MaxContainers(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, MaxContainers, DataSize));
MaxContainers = ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion)->MaxContainers;
if (((UINT32)HiiQuestion->VarOffset + HiiQuestion->StorageWidth * MaxContainers) > DataSize) {
DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x) * MaxContainers(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, MaxContainers, DataSize));
return FALSE;
}
for (Index = 0; Index < MaxContainers; Index++) {
OneData = 0;
CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset + HiiQuestion->StorageWidth * Index, HiiQuestion->StorageWidth);
CopyMem (&OneData, (UINT8 *)Data + HiiQuestion->VarOffset + HiiQuestion->StorageWidth * Index, HiiQuestion->StorageWidth);
if (OneData == 0) {
//
// The value of 0 is used to determine if a particular "slot" in the array is empty.
@@ -206,8 +219,8 @@ VarCheckHiiQuestion (
continue;
}
Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion + 1);
while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) {
Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion + 1);
while ((UINTN)Ptr < ((UINTN)HiiQuestion + HiiQuestion->Length)) {
OneValue = 0;
CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);
if (OneData == OneValue) {
@@ -216,18 +229,25 @@ VarCheckHiiQuestion (
//
break;
}
Ptr += HiiQuestion->StorageWidth;
}
if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) {
if ((UINTN)Ptr >= ((UINTN)HiiQuestion + HiiQuestion->Length)) {
//
// No match
//
DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: OrderedList mismatch\n"));
DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->StorageWidth * MaxContainers, (UINT8 *) Data + HiiQuestion->VarOffset););
DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););
DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: OrderedList mismatch\n"));
DEBUG_CODE (
VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->StorageWidth * MaxContainers, (UINT8 *)Data + HiiQuestion->VarOffset);
);
DEBUG_CODE (
VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
);
return FALSE;
}
}
break;
default:
@@ -238,8 +258,8 @@ VarCheckHiiQuestion (
return TRUE;
}
VAR_CHECK_HII_VARIABLE_HEADER *mVarCheckHiiBin = NULL;
UINTN mVarCheckHiiBinSize = 0;
VAR_CHECK_HII_VARIABLE_HEADER *mVarCheckHiiBin = NULL;
UINTN mVarCheckHiiBinSize = 0;
/**
SetVariable check handler HII.
@@ -257,15 +277,15 @@ UINTN mVarCheckHiiBinSize = 0;
EFI_STATUS
EFIAPI
SetVariableCheckHandlerHii (
IN CHAR16 *VariableName,
IN EFI_GUID *VendorGuid,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data
IN CHAR16 *VariableName,
IN EFI_GUID *VendorGuid,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data
)
{
VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;
VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;
if (mVarCheckHiiBin == NULL) {
return EFI_SUCCESS;
@@ -281,14 +301,15 @@ SetVariableCheckHandlerHii (
//
// For Hii Variable header align.
//
HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (mVarCheckHiiBin);
while ((UINTN) HiiVariable < ((UINTN) mVarCheckHiiBin + mVarCheckHiiBinSize)) {
if ((StrCmp ((CHAR16 *) (HiiVariable + 1), VariableName) == 0) &&
(CompareGuid (&HiiVariable->Guid, VendorGuid))) {
HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *)HEADER_ALIGN (mVarCheckHiiBin);
while ((UINTN)HiiVariable < ((UINTN)mVarCheckHiiBin + mVarCheckHiiBinSize)) {
if ((StrCmp ((CHAR16 *)(HiiVariable + 1), VariableName) == 0) &&
(CompareGuid (&HiiVariable->Guid, VendorGuid)))
{
//
// Found the Hii Variable that could be used to do check.
//
DEBUG ((DEBUG_INFO , "VarCheckHiiVariable - %s:%g with Attributes = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, DataSize));
DEBUG ((DEBUG_INFO, "VarCheckHiiVariable - %s:%g with Attributes = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, DataSize));
if (HiiVariable->Attributes != Attributes) {
DEBUG ((DEBUG_INFO, "VarCheckHiiVariable fail for Attributes - 0x%08x\n", HiiVariable->Attributes));
return EFI_SECURITY_VIOLATION;
@@ -308,24 +329,26 @@ SetVariableCheckHandlerHii (
// Do the check.
// For Hii Question header align.
//
HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->HeaderLength));
while ((UINTN) HiiQuestion < ((UINTN) HiiVariable + HiiVariable->Length)) {
HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *)HEADER_ALIGN (((UINTN)HiiVariable + HiiVariable->HeaderLength));
while ((UINTN)HiiQuestion < ((UINTN)HiiVariable + HiiVariable->Length)) {
if (!VarCheckHiiQuestion (HiiQuestion, Data, DataSize)) {
return EFI_SECURITY_VIOLATION;
}
//
// For Hii Question header align.
//
HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiQuestion + HiiQuestion->Length));
HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *)HEADER_ALIGN (((UINTN)HiiQuestion + HiiQuestion->Length));
}
DEBUG ((DEBUG_INFO, "VarCheckHiiVariable - ALL CHECK PASS!\n"));
return EFI_SUCCESS;
}
//
// For Hii Variable header align.
//
HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->Length));
HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *)HEADER_ALIGN (((UINTN)HiiVariable + HiiVariable->Length));
}
// Not found, so pass.
@@ -333,12 +356,12 @@ SetVariableCheckHandlerHii (
}
#ifdef DUMP_VAR_CHECK_HII
GLOBAL_REMOVE_IF_UNREFERENCED VAR_CHECK_HII_OPCODE_STRING mHiiOpCodeStringTable[] = {
{EFI_IFR_VARSTORE_EFI_OP, "EfiVarStore"},
{EFI_IFR_ONE_OF_OP, "OneOf"},
{EFI_IFR_CHECKBOX_OP, "CheckBox"},
{EFI_IFR_NUMERIC_OP, "Numeric"},
{EFI_IFR_ORDERED_LIST_OP, "OrderedList"},
GLOBAL_REMOVE_IF_UNREFERENCED VAR_CHECK_HII_OPCODE_STRING mHiiOpCodeStringTable[] = {
{ EFI_IFR_VARSTORE_EFI_OP, "EfiVarStore" },
{ EFI_IFR_ONE_OF_OP, "OneOf" },
{ EFI_IFR_CHECKBOX_OP, "CheckBox" },
{ EFI_IFR_NUMERIC_OP, "Numeric" },
{ EFI_IFR_ORDERED_LIST_OP, "OrderedList" },
};
/**
@@ -354,7 +377,8 @@ HiiOpCodeToStr (
IN UINT8 HiiOpCode
)
{
UINTN Index;
UINTN Index;
for (Index = 0; Index < ARRAY_SIZE (mHiiOpCodeStringTable); Index++) {
if (mHiiOpCodeStringTable[Index].HiiOpCode == HiiOpCode) {
return mHiiOpCodeStringTable[Index].HiiOpCodeStr;
@@ -375,21 +399,21 @@ DumpHiiQuestion (
IN VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion
)
{
UINT64 Minimum;
UINT64 Maximum;
UINT64 OneValue;
UINT8 *Ptr;
UINT64 Minimum;
UINT64 Maximum;
UINT64 OneValue;
UINT8 *Ptr;
DEBUG ((DEBUG_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n"));
DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a) (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode), (HiiQuestion->BitFieldStore? "bit level": "byte level")));
DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a) (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode), (HiiQuestion->BitFieldStore ? "bit level" : "byte level")));
DEBUG ((DEBUG_INFO, " Length - 0x%02x\n", HiiQuestion->Length));
DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x (%a)\n", HiiQuestion->VarOffset, (HiiQuestion->BitFieldStore? "bit level": "byte level")));
DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x (%a)\n", HiiQuestion->StorageWidth, (HiiQuestion->BitFieldStore? "bit level": "byte level")));
DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x (%a)\n", HiiQuestion->VarOffset, (HiiQuestion->BitFieldStore ? "bit level" : "byte level")));
DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x (%a)\n", HiiQuestion->StorageWidth, (HiiQuestion->BitFieldStore ? "bit level" : "byte level")));
switch (HiiQuestion->OpCode) {
case EFI_IFR_ONE_OF_OP:
Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1);
while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) {
Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_ONEOF *)HiiQuestion + 1);
while ((UINTN)Ptr < ((UINTN)HiiQuestion + HiiQuestion->Length)) {
OneValue = 0;
if (HiiQuestion->BitFieldStore) {
//
@@ -417,12 +441,14 @@ DumpHiiQuestion (
break;
}
}
if (HiiQuestion->BitFieldStore) {
Ptr += sizeof (UINT32);
} else {
Ptr += HiiQuestion->StorageWidth;
}
}
break;
case EFI_IFR_CHECKBOX_OP:
@@ -431,8 +457,8 @@ DumpHiiQuestion (
case EFI_IFR_NUMERIC_OP:
Minimum = 0;
Maximum = 0;
Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1);
if(HiiQuestion->BitFieldStore) {
Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_NUMERIC *)HiiQuestion + 1);
if (HiiQuestion->BitFieldStore) {
//
// For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type.
//
@@ -471,12 +497,13 @@ DumpHiiQuestion (
break;
}
}
break;
case EFI_IFR_ORDERED_LIST_OP:
DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers));
Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion + 1);
while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) {
DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion)->MaxContainers));
Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion + 1);
while ((UINTN)Ptr < ((UINTN)HiiQuestion + HiiQuestion->Length)) {
OneValue = 0;
CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);
switch (HiiQuestion->StorageWidth) {
@@ -496,8 +523,10 @@ DumpHiiQuestion (
ASSERT (FALSE);
break;
}
Ptr += HiiQuestion->StorageWidth;
}
break;
default:
@@ -517,7 +546,7 @@ DumpHiiVariable (
IN VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable
)
{
VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;
VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;
DEBUG ((DEBUG_INFO, "VAR_CHECK_HII_VARIABLE_HEADER\n"));
DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", HiiVariable->Revision));
@@ -532,8 +561,8 @@ DumpHiiVariable (
//
// For Hii Question header align.
//
HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->HeaderLength));
while ((UINTN) HiiQuestion < ((UINTN) HiiVariable + HiiVariable->Length)) {
HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *)HEADER_ALIGN (((UINTN)HiiVariable + HiiVariable->HeaderLength));
while ((UINTN)HiiQuestion < ((UINTN)HiiVariable + HiiVariable->Length)) {
//
// Dump Hii Question related to the Hii Variable.
//
@@ -541,7 +570,7 @@ DumpHiiVariable (
//
// For Hii Question header align.
//
HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiQuestion + HiiQuestion->Length));
HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *)HEADER_ALIGN (((UINTN)HiiQuestion + HiiQuestion->Length));
}
}
@@ -558,22 +587,23 @@ DumpVarCheckHii (
IN UINTN VarCheckHiiBinSize
)
{
VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
DEBUG ((DEBUG_INFO, "DumpVarCheckHii\n"));
//
// For Hii Variable header align.
//
HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (VarCheckHiiBin);
while ((UINTN) HiiVariable < ((UINTN) VarCheckHiiBin + VarCheckHiiBinSize)) {
HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *)HEADER_ALIGN (VarCheckHiiBin);
while ((UINTN)HiiVariable < ((UINTN)VarCheckHiiBin + VarCheckHiiBinSize)) {
DumpHiiVariable (HiiVariable);
//
// For Hii Variable header align.
//
HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->Length));
HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *)HEADER_ALIGN (((UINTN)HiiVariable + HiiVariable->Length));
}
}
#endif
/**
@@ -588,14 +618,13 @@ DumpVarCheckHii (
EFI_STATUS
EFIAPI
VarCheckHiiLibNullClassConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
VarCheckLibRegisterEndOfDxeCallback (VarCheckHiiGen);
VarCheckLibRegisterAddressPointer ((VOID **) &mVarCheckHiiBin);
VarCheckLibRegisterAddressPointer ((VOID **)&mVarCheckHiiBin);
VarCheckLibRegisterSetVariableCheckHandler (SetVariableCheckHandlerHii);
return EFI_SUCCESS;
}