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

@@ -23,100 +23,100 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/PcdLib.h>
#include <Library/TpmMeasurementLib.h>
#define FIELD_SIZE_OF(TYPE, Field) ((UINTN)sizeof(((TYPE *)0)->Field))
#define FIELD_SIZE_OF(TYPE, Field) ((UINTN)sizeof(((TYPE *)0)->Field))
typedef struct {
UINT8 Type;
UINTN Offset;
UINTN Size;
UINT32 Flags;
UINT8 Type;
UINTN Offset;
UINTN Size;
UINT32 Flags;
} SMBIOS_FILTER_TABLE;
#define SMBIOS_FILTER_TABLE_FLAG_IS_STRING BIT0
typedef struct {
UINT8 Type;
SMBIOS_FILTER_TABLE *Filter; // NULL means all fields
UINTN FilterCount;
UINT8 Type;
SMBIOS_FILTER_TABLE *Filter; // NULL means all fields
UINTN FilterCount;
} SMBIOS_FILTER_STRUCT;
//
// Platform Specific Policy
//
SMBIOS_FILTER_TABLE mSmbiosFilterType1BlackList[] = {
{0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1, SerialNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1, Uuid), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1, Uuid), 0},
{0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1, WakeUpType), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1, WakeUpType), 0},
{ 0x01, OFFSET_OF (SMBIOS_TABLE_TYPE1, SerialNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE1, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
{ 0x01, OFFSET_OF (SMBIOS_TABLE_TYPE1, Uuid), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE1, Uuid), 0 },
{ 0x01, OFFSET_OF (SMBIOS_TABLE_TYPE1, WakeUpType), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE1, WakeUpType), 0 },
};
SMBIOS_FILTER_TABLE mSmbiosFilterType2BlackList[] = {
{0x02, OFFSET_OF(SMBIOS_TABLE_TYPE2, SerialNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE2, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{0x02, OFFSET_OF(SMBIOS_TABLE_TYPE2, LocationInChassis), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE2, LocationInChassis), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{ 0x02, OFFSET_OF (SMBIOS_TABLE_TYPE2, SerialNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE2, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
{ 0x02, OFFSET_OF (SMBIOS_TABLE_TYPE2, LocationInChassis), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE2, LocationInChassis), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
};
SMBIOS_FILTER_TABLE mSmbiosFilterType3BlackList[] = {
{0x03, OFFSET_OF(SMBIOS_TABLE_TYPE3, SerialNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE3, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{0x03, OFFSET_OF(SMBIOS_TABLE_TYPE3, AssetTag), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE3, AssetTag), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{ 0x03, OFFSET_OF (SMBIOS_TABLE_TYPE3, SerialNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE3, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
{ 0x03, OFFSET_OF (SMBIOS_TABLE_TYPE3, AssetTag), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE3, AssetTag), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
};
SMBIOS_FILTER_TABLE mSmbiosFilterType4BlackList[] = {
{0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4, SerialNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4, AssetTag), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4, AssetTag), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4, PartNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4, PartNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4, CoreCount), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4, CoreCount), 0},
{0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4, EnabledCoreCount), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4, EnabledCoreCount), 0},
{0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4, ThreadCount), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4, ThreadCount), 0},
{0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4, CoreCount2), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4, CoreCount2), 0},
{0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4, EnabledCoreCount2), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4, EnabledCoreCount2), 0},
{0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4, ThreadCount2), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4, ThreadCount2), 0},
{0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4, Voltage), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4, Voltage), 0},
{ 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4, SerialNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
{ 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4, AssetTag), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4, AssetTag), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
{ 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4, PartNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4, PartNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
{ 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4, CoreCount), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4, CoreCount), 0 },
{ 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4, EnabledCoreCount), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4, EnabledCoreCount), 0 },
{ 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4, ThreadCount), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4, ThreadCount), 0 },
{ 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4, CoreCount2), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4, CoreCount2), 0 },
{ 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4, EnabledCoreCount2), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4, EnabledCoreCount2), 0 },
{ 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4, ThreadCount2), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4, ThreadCount2), 0 },
{ 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4, Voltage), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4, Voltage), 0 },
};
SMBIOS_FILTER_TABLE mSmbiosFilterType17BlackList[] = {
{0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17, SerialNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17, AssetTag), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17, AssetTag), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17, PartNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17, PartNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{ 0x11, OFFSET_OF (SMBIOS_TABLE_TYPE17, SerialNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE17, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
{ 0x11, OFFSET_OF (SMBIOS_TABLE_TYPE17, AssetTag), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE17, AssetTag), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
{ 0x11, OFFSET_OF (SMBIOS_TABLE_TYPE17, PartNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE17, PartNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
};
SMBIOS_FILTER_TABLE mSmbiosFilterType22BlackList[] = {
{0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22, SerialNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22, SBDSSerialNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22, SBDSSerialNumber), 0},
{0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22, SBDSManufactureDate), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22, SBDSManufactureDate), 0},
{ 0x16, OFFSET_OF (SMBIOS_TABLE_TYPE22, SerialNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE22, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
{ 0x16, OFFSET_OF (SMBIOS_TABLE_TYPE22, SBDSSerialNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE22, SBDSSerialNumber), 0 },
{ 0x16, OFFSET_OF (SMBIOS_TABLE_TYPE22, SBDSManufactureDate), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE22, SBDSManufactureDate), 0 },
};
SMBIOS_FILTER_TABLE mSmbiosFilterType23BlackList[] = {
{0x17, OFFSET_OF(SMBIOS_TABLE_TYPE23, ResetCount), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE23, ResetCount), 0},
{ 0x17, OFFSET_OF (SMBIOS_TABLE_TYPE23, ResetCount), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE23, ResetCount), 0 },
};
SMBIOS_FILTER_TABLE mSmbiosFilterType27BlackList[] = {
{0x1B, OFFSET_OF(SMBIOS_TABLE_TYPE27, NominalSpeed), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE27, NominalSpeed), 0},
{ 0x1B, OFFSET_OF (SMBIOS_TABLE_TYPE27, NominalSpeed), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE27, NominalSpeed), 0 },
};
SMBIOS_FILTER_TABLE mSmbiosFilterType39BlackList[] = {
{0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39, SerialNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39, AssetTagNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39, AssetTagNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39, ModelPartNumber), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39, ModelPartNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
{ 0x27, OFFSET_OF (SMBIOS_TABLE_TYPE39, SerialNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE39, SerialNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
{ 0x27, OFFSET_OF (SMBIOS_TABLE_TYPE39, AssetTagNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE39, AssetTagNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
{ 0x27, OFFSET_OF (SMBIOS_TABLE_TYPE39, ModelPartNumber), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE39, ModelPartNumber), SMBIOS_FILTER_TABLE_FLAG_IS_STRING },
};
SMBIOS_FILTER_STRUCT mSmbiosFilterStandardTableBlackList[] = {
{0x01, mSmbiosFilterType1BlackList, sizeof(mSmbiosFilterType1BlackList)/sizeof(mSmbiosFilterType1BlackList[0])},
{0x02, mSmbiosFilterType2BlackList, sizeof(mSmbiosFilterType2BlackList)/sizeof(mSmbiosFilterType2BlackList[0])},
{0x03, mSmbiosFilterType3BlackList, sizeof(mSmbiosFilterType3BlackList)/sizeof(mSmbiosFilterType3BlackList[0])},
{0x04, mSmbiosFilterType4BlackList, sizeof(mSmbiosFilterType4BlackList)/sizeof(mSmbiosFilterType4BlackList[0])},
{0x0B, NULL, 0},
{0x0F, NULL, 0},
{0x11, mSmbiosFilterType17BlackList, sizeof(mSmbiosFilterType17BlackList)/sizeof(mSmbiosFilterType17BlackList[0])},
{0x12, NULL, 0},
{0x16, mSmbiosFilterType22BlackList, sizeof(mSmbiosFilterType22BlackList)/sizeof(mSmbiosFilterType22BlackList[0])},
{0x17, mSmbiosFilterType23BlackList, sizeof(mSmbiosFilterType23BlackList)/sizeof(mSmbiosFilterType23BlackList[0])},
{0x1B, mSmbiosFilterType27BlackList, sizeof(mSmbiosFilterType27BlackList)/sizeof(mSmbiosFilterType27BlackList[0])},
{0x1F, NULL, 0},
{0x21, NULL, 0},
{0x27, mSmbiosFilterType39BlackList, sizeof(mSmbiosFilterType39BlackList)/sizeof(mSmbiosFilterType39BlackList[0])},
{ 0x01, mSmbiosFilterType1BlackList, sizeof (mSmbiosFilterType1BlackList)/sizeof (mSmbiosFilterType1BlackList[0]) },
{ 0x02, mSmbiosFilterType2BlackList, sizeof (mSmbiosFilterType2BlackList)/sizeof (mSmbiosFilterType2BlackList[0]) },
{ 0x03, mSmbiosFilterType3BlackList, sizeof (mSmbiosFilterType3BlackList)/sizeof (mSmbiosFilterType3BlackList[0]) },
{ 0x04, mSmbiosFilterType4BlackList, sizeof (mSmbiosFilterType4BlackList)/sizeof (mSmbiosFilterType4BlackList[0]) },
{ 0x0B, NULL, 0 },
{ 0x0F, NULL, 0 },
{ 0x11, mSmbiosFilterType17BlackList, sizeof (mSmbiosFilterType17BlackList)/sizeof (mSmbiosFilterType17BlackList[0]) },
{ 0x12, NULL, 0 },
{ 0x16, mSmbiosFilterType22BlackList, sizeof (mSmbiosFilterType22BlackList)/sizeof (mSmbiosFilterType22BlackList[0]) },
{ 0x17, mSmbiosFilterType23BlackList, sizeof (mSmbiosFilterType23BlackList)/sizeof (mSmbiosFilterType23BlackList[0]) },
{ 0x1B, mSmbiosFilterType27BlackList, sizeof (mSmbiosFilterType27BlackList)/sizeof (mSmbiosFilterType27BlackList[0]) },
{ 0x1F, NULL, 0 },
{ 0x21, NULL, 0 },
{ 0x27, mSmbiosFilterType39BlackList, sizeof (mSmbiosFilterType39BlackList)/sizeof (mSmbiosFilterType39BlackList[0]) },
};
EFI_SMBIOS_PROTOCOL *mSmbios;
UINTN mMaxLen;
EFI_SMBIOS_PROTOCOL *mSmbios;
UINTN mMaxLen;
#pragma pack (1)
#define SMBIOS_HANDOFF_TABLE_DESC "SmbiosTable"
typedef struct {
UINT8 TableDescriptionSize;
UINT8 TableDescription[sizeof(SMBIOS_HANDOFF_TABLE_DESC)];
UINT64 NumberOfTables;
EFI_CONFIGURATION_TABLE TableEntry[1];
UINT8 TableDescriptionSize;
UINT8 TableDescription[sizeof (SMBIOS_HANDOFF_TABLE_DESC)];
UINT64 NumberOfTables;
EFI_CONFIGURATION_TABLE TableEntry[1];
} SMBIOS_HANDOFF_TABLE_POINTERS2;
#pragma pack ()
@@ -136,6 +136,7 @@ InternalDumpData (
)
{
UINTN Index;
for (Index = 0; Index < Size; Index++) {
DEBUG ((DEBUG_VERBOSE, "%02x", (UINTN)Data[Index]));
}
@@ -155,11 +156,11 @@ InternalDumpHex (
IN UINTN Size
)
{
UINTN Index;
UINTN Count;
UINTN Left;
UINTN Index;
UINTN Count;
UINTN Left;
#define COLUME_SIZE (16 * 2)
#define COLUME_SIZE (16 * 2)
Count = Size / COLUME_SIZE;
Left = Size % COLUME_SIZE;
@@ -176,7 +177,6 @@ InternalDumpHex (
}
}
/**
This function get filter structure by SMBIOS type.
@@ -186,15 +186,17 @@ InternalDumpHex (
**/
SMBIOS_FILTER_STRUCT *
GetFilterStructByType (
IN UINT8 Type
IN UINT8 Type
)
{
UINTN Index;
for (Index = 0; Index < sizeof(mSmbiosFilterStandardTableBlackList)/sizeof(mSmbiosFilterStandardTableBlackList[0]); Index++) {
for (Index = 0; Index < sizeof (mSmbiosFilterStandardTableBlackList)/sizeof (mSmbiosFilterStandardTableBlackList[0]); Index++) {
if (mSmbiosFilterStandardTableBlackList[Index].Type == Type) {
return &mSmbiosFilterStandardTableBlackList[Index];
}
}
return NULL;
}
@@ -210,9 +212,9 @@ GetFilterStructByType (
**/
CHAR8 *
GetSmbiosStringById (
IN EFI_SMBIOS_TABLE_HEADER *Head,
IN SMBIOS_TABLE_STRING StringId,
OUT UINTN *StringLen
IN EFI_SMBIOS_TABLE_HEADER *Head,
IN SMBIOS_TABLE_STRING StringId,
OUT UINTN *StringLen
)
{
UINTN Size;
@@ -221,10 +223,10 @@ GetSmbiosStringById (
UINTN StringsNumber;
CHAR8 *String;
CharInStr = (CHAR8 *)Head + Head->Length;
Size = Head->Length;
CharInStr = (CHAR8 *)Head + Head->Length;
Size = Head->Length;
StringsNumber = 0;
StrLen = 0;
StrLen = 0;
//
// look for the two consecutive zeros, check the string limit by the way.
//
@@ -234,13 +236,15 @@ GetSmbiosStringById (
Size += 1;
CharInStr++;
}
String = CharInStr;
for (StrLen = 0 ; StrLen < mMaxLen; StrLen++) {
for (StrLen = 0; StrLen < mMaxLen; StrLen++) {
if (*(CharInStr+StrLen) == 0) {
break;
}
}
*StringLen = StrLen;
if (StrLen == mMaxLen) {
@@ -250,8 +254,8 @@ GetSmbiosStringById (
//
// forward the pointer
//
CharInStr += StrLen;
Size += StrLen;
CharInStr += StrLen;
Size += StrLen;
StringsNumber += 1;
if (StringsNumber == StringId) {
break;
@@ -271,8 +275,8 @@ GetSmbiosStringById (
**/
VOID
FilterSmbiosEntry (
IN OUT VOID *TableEntry,
IN UINTN TableEntrySize
IN OUT VOID *TableEntry,
IN UINTN TableEntrySize
)
{
SMBIOS_FILTER_STRUCT *FilterStruct;
@@ -283,37 +287,40 @@ FilterSmbiosEntry (
UINTN StringLen;
DEBUG ((DEBUG_INFO, "Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE *)TableEntry)->Type));
DEBUG_CODE (InternalDumpHex (TableEntry, TableEntrySize););
DEBUG_CODE (
InternalDumpHex (TableEntry, TableEntrySize);
);
//
// Skip measurement for OEM types.
//
if (((SMBIOS_STRUCTURE *)TableEntry)->Type >= SMBIOS_OEM_BEGIN) {
// zero all table fields, except header
ZeroMem ((UINT8 *)TableEntry + sizeof(SMBIOS_STRUCTURE), TableEntrySize - sizeof(SMBIOS_STRUCTURE));
ZeroMem ((UINT8 *)TableEntry + sizeof (SMBIOS_STRUCTURE), TableEntrySize - sizeof (SMBIOS_STRUCTURE));
} else {
FilterStruct = GetFilterStructByType (((SMBIOS_STRUCTURE *)TableEntry)->Type);
if (FilterStruct != NULL) {
if (FilterStruct->Filter == NULL || FilterStruct->FilterCount == 0) {
if ((FilterStruct->Filter == NULL) || (FilterStruct->FilterCount == 0)) {
// zero all table fields, except header
ZeroMem ((UINT8 *)TableEntry + sizeof(SMBIOS_STRUCTURE), TableEntrySize - sizeof(SMBIOS_STRUCTURE));
ZeroMem ((UINT8 *)TableEntry + sizeof (SMBIOS_STRUCTURE), TableEntrySize - sizeof (SMBIOS_STRUCTURE));
} else {
Filter = FilterStruct->Filter;
for (Index = 0; Index < FilterStruct->FilterCount; Index++) {
if (((SMBIOS_STRUCTURE *) TableEntry)->Length >= (Filter[Index].Offset + Filter[Index].Size)) {
if (((SMBIOS_STRUCTURE *)TableEntry)->Length >= (Filter[Index].Offset + Filter[Index].Size)) {
//
// The field is present in the SMBIOS entry.
//
if ((Filter[Index].Flags & SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) {
CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset, sizeof(StringId));
CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset, sizeof (StringId));
if (StringId != 0) {
// set ' ' for string field
String = GetSmbiosStringById (TableEntry, StringId, &StringLen);
ASSERT (String != NULL);
//DEBUG ((DEBUG_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
// DEBUG ((DEBUG_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
SetMem (String, StringLen, ' ');
}
}
// zero non-string field
ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset, Filter[Index].Size);
}
@@ -323,7 +330,9 @@ FilterSmbiosEntry (
}
DEBUG ((DEBUG_INFO, "Filter Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE *)TableEntry)->Type));
DEBUG_CODE (InternalDumpHex (TableEntry, TableEntrySize););
DEBUG_CODE (
InternalDumpHex (TableEntry, TableEntrySize);
);
}
/**
@@ -337,8 +346,8 @@ FilterSmbiosEntry (
**/
UINTN
GetSmbiosStructureSize (
IN EFI_SMBIOS_TABLE_HEADER *Head,
OUT UINTN *NumberOfStrings
IN EFI_SMBIOS_TABLE_HEADER *Head,
OUT UINTN *NumberOfStrings
)
{
UINTN Size;
@@ -346,10 +355,10 @@ GetSmbiosStructureSize (
CHAR8 *CharInStr;
UINTN StringsNumber;
CharInStr = (CHAR8 *)Head + Head->Length;
Size = Head->Length;
CharInStr = (CHAR8 *)Head + Head->Length;
Size = Head->Length;
StringsNumber = 0;
StrLen = 0;
StrLen = 0;
//
// look for the two consecutive zeros, check the string limit by the way.
//
@@ -359,7 +368,7 @@ GetSmbiosStructureSize (
CharInStr++;
}
for (StrLen = 0 ; StrLen < mMaxLen; StrLen++) {
for (StrLen = 0; StrLen < mMaxLen; StrLen++) {
if (*(CharInStr+StrLen) == 0) {
break;
}
@@ -372,8 +381,8 @@ GetSmbiosStructureSize (
//
// forward the pointer
//
CharInStr += StrLen;
Size += StrLen;
CharInStr += StrLen;
Size += StrLen;
StringsNumber += 1;
}
@@ -385,6 +394,7 @@ GetSmbiosStructureSize (
if (NumberOfStrings != NULL) {
*NumberOfStrings = StringsNumber;
}
return Size;
}
@@ -400,25 +410,27 @@ GetSmbiosStructureSize (
**/
UINTN
GetSmbiosTableLength (
IN VOID *TableAddress,
IN UINTN TableMaximumSize
IN VOID *TableAddress,
IN UINTN TableMaximumSize
)
{
VOID *TableEntry;
VOID *TableAddressEnd;
UINTN TableEntryLength;
VOID *TableEntry;
VOID *TableAddressEnd;
UINTN TableEntryLength;
TableAddressEnd = (VOID *)((UINTN)TableAddress + TableMaximumSize);
TableEntry = TableAddress;
TableEntry = TableAddress;
while (TableEntry < TableAddressEnd) {
TableEntryLength = GetSmbiosStructureSize (TableEntry, NULL);
if (TableEntryLength == 0) {
break;
}
if (((SMBIOS_STRUCTURE *)TableEntry)->Type == 127) {
TableEntry = (VOID *)((UINTN)TableEntry + TableEntryLength);
break;
}
TableEntry = (VOID *)((UINTN)TableEntry + TableEntryLength);
}
@@ -443,7 +455,7 @@ FilterSmbiosTable (
VOID *TableEntry;
UINTN TableEntryLength;
TableEntry = TableAddress;
TableEntry = TableAddress;
TableAddressEnd = (VOID *)((UINTN)TableAddress + TableLength);
while ((UINTN)TableEntry < (UINTN)TableAddressEnd) {
TableEntryLength = GetSmbiosStructureSize (TableEntry, NULL);
@@ -467,35 +479,37 @@ FilterSmbiosTable (
VOID
EFIAPI
MeasureSmbiosTable (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
EFI_HANDOFF_TABLE_POINTERS HandoffTables;
SMBIOS_HANDOFF_TABLE_POINTERS2 SmbiosHandoffTables2;
UINT32 EventType;
VOID *EventLog;
UINT32 EventLogSize;
SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;
SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios3Table;
VOID *SmbiosTableAddress;
VOID *TableAddress;
UINTN TableLength;
EFI_STATUS Status;
EFI_HANDOFF_TABLE_POINTERS HandoffTables;
SMBIOS_HANDOFF_TABLE_POINTERS2 SmbiosHandoffTables2;
UINT32 EventType;
VOID *EventLog;
UINT32 EventLogSize;
SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;
SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios3Table;
VOID *SmbiosTableAddress;
VOID *TableAddress;
UINTN TableLength;
SmbiosTable = NULL;
Smbios3Table = NULL;
SmbiosTable = NULL;
Smbios3Table = NULL;
SmbiosTableAddress = NULL;
TableLength = 0;
TableLength = 0;
if (mSmbios->MajorVersion >= 3) {
Status = EfiGetSystemConfigurationTable (
&gEfiSmbios3TableGuid,
(VOID **) &Smbios3Table
(VOID **)&Smbios3Table
);
if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "Smbios3Table:\n"));
DEBUG ((DEBUG_INFO, " AnchorString - '%c%c%c%c%c'\n",
DEBUG ((
DEBUG_INFO,
" AnchorString - '%c%c%c%c%c'\n",
Smbios3Table->AnchorString[0],
Smbios3Table->AnchorString[1],
Smbios3Table->AnchorString[2],
@@ -516,11 +530,13 @@ MeasureSmbiosTable (
if (Smbios3Table == NULL) {
Status = EfiGetSystemConfigurationTable (
&gEfiSmbiosTableGuid,
(VOID **) &SmbiosTable
(VOID **)&SmbiosTable
);
if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "SmbiosTable:\n"));
DEBUG ((DEBUG_INFO, " AnchorString - '%c%c%c%c'\n",
DEBUG ((
DEBUG_INFO,
" AnchorString - '%c%c%c%c'\n",
SmbiosTable->AnchorString[0],
SmbiosTable->AnchorString[1],
SmbiosTable->AnchorString[2],
@@ -532,14 +548,18 @@ MeasureSmbiosTable (
DEBUG ((DEBUG_INFO, " MinorVersion - 0x%02x\n", SmbiosTable->MinorVersion));
DEBUG ((DEBUG_INFO, " MaxStructureSize - 0x%08x\n", SmbiosTable->MaxStructureSize));
DEBUG ((DEBUG_INFO, " EntryPointRevision - 0x%02x\n", SmbiosTable->EntryPointRevision));
DEBUG ((DEBUG_INFO, " FormattedArea - '%c%c%c%c%c'\n",
DEBUG ((
DEBUG_INFO,
" FormattedArea - '%c%c%c%c%c'\n",
SmbiosTable->FormattedArea[0],
SmbiosTable->FormattedArea[1],
SmbiosTable->FormattedArea[2],
SmbiosTable->FormattedArea[3],
SmbiosTable->FormattedArea[4]
));
DEBUG ((DEBUG_INFO, " IntermediateAnchorString - '%c%c%c%c%c'\n",
DEBUG ((
DEBUG_INFO,
" IntermediateAnchorString - '%c%c%c%c%c'\n",
SmbiosTable->IntermediateAnchorString[0],
SmbiosTable->IntermediateAnchorString[1],
SmbiosTable->IntermediateAnchorString[2],
@@ -556,27 +576,31 @@ MeasureSmbiosTable (
if (Smbios3Table != NULL) {
SmbiosTableAddress = (VOID *)(UINTN)Smbios3Table->TableAddress;
TableLength = GetSmbiosTableLength (SmbiosTableAddress, Smbios3Table->TableMaximumSize);
TableLength = GetSmbiosTableLength (SmbiosTableAddress, Smbios3Table->TableMaximumSize);
} else if (SmbiosTable != NULL) {
SmbiosTableAddress = (VOID *)(UINTN)SmbiosTable->TableAddress;
TableLength = SmbiosTable->TableLength;
TableLength = SmbiosTable->TableLength;
}
if (SmbiosTableAddress != NULL) {
DEBUG ((DEBUG_INFO, "The Smbios Table starts at: 0x%x\n", SmbiosTableAddress));
DEBUG ((DEBUG_INFO, "The Smbios Table size: 0x%x\n", TableLength));
DEBUG_CODE (InternalDumpHex ((UINT8 *)(UINTN)SmbiosTableAddress, TableLength););
DEBUG_CODE (
InternalDumpHex ((UINT8 *)(UINTN)SmbiosTableAddress, TableLength);
);
TableAddress = AllocateCopyPool ((UINTN)TableLength, (VOID *)(UINTN)SmbiosTableAddress);
if (TableAddress == NULL) {
return ;
return;
}
FilterSmbiosTable (TableAddress, TableLength);
DEBUG ((DEBUG_INFO, "The final Smbios Table starts at: 0x%x\n", TableAddress));
DEBUG ((DEBUG_INFO, "The final Smbios Table size: 0x%x\n", TableLength));
DEBUG_CODE (InternalDumpHex (TableAddress, TableLength););
DEBUG_CODE (
InternalDumpHex (TableAddress, TableLength);
);
HandoffTables.NumberOfTables = 1;
if (Smbios3Table != NULL) {
@@ -586,19 +610,21 @@ MeasureSmbiosTable (
CopyGuid (&(HandoffTables.TableEntry[0].VendorGuid), &gEfiSmbiosTableGuid);
HandoffTables.TableEntry[0].VendorTable = SmbiosTable;
}
EventType = EV_EFI_HANDOFF_TABLES;
EventLog = &HandoffTables;
EventType = EV_EFI_HANDOFF_TABLES;
EventLog = &HandoffTables;
EventLogSize = sizeof (HandoffTables);
if (PcdGet32(PcdTcgPfpMeasurementRevision) >= TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_105) {
SmbiosHandoffTables2.TableDescriptionSize = sizeof(SmbiosHandoffTables2.TableDescription);
CopyMem (SmbiosHandoffTables2.TableDescription, SMBIOS_HANDOFF_TABLE_DESC, sizeof(SmbiosHandoffTables2.TableDescription));
if (PcdGet32 (PcdTcgPfpMeasurementRevision) >= TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_105) {
SmbiosHandoffTables2.TableDescriptionSize = sizeof (SmbiosHandoffTables2.TableDescription);
CopyMem (SmbiosHandoffTables2.TableDescription, SMBIOS_HANDOFF_TABLE_DESC, sizeof (SmbiosHandoffTables2.TableDescription));
SmbiosHandoffTables2.NumberOfTables = HandoffTables.NumberOfTables;
CopyMem (&(SmbiosHandoffTables2.TableEntry[0]), &(HandoffTables.TableEntry[0]), sizeof(SmbiosHandoffTables2.TableEntry[0]));
EventType = EV_EFI_HANDOFF_TABLES2;
EventLog = &SmbiosHandoffTables2;
CopyMem (&(SmbiosHandoffTables2.TableEntry[0]), &(HandoffTables.TableEntry[0]), sizeof (SmbiosHandoffTables2.TableEntry[0]));
EventType = EV_EFI_HANDOFF_TABLES2;
EventLog = &SmbiosHandoffTables2;
EventLogSize = sizeof (SmbiosHandoffTables2);
}
Status = TpmMeasureAndLogData (
1, // PCRIndex
EventType, // EventType
@@ -608,11 +634,11 @@ MeasureSmbiosTable (
TableLength // HashDataLen
);
if (!EFI_ERROR (Status)) {
gBS->CloseEvent (Event) ;
gBS->CloseEvent (Event);
}
}
return ;
return;
}
/**
@@ -628,18 +654,18 @@ MeasureSmbiosTable (
EFI_STATUS
EFIAPI
SmbiosMeasurementDriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_EVENT Event;
EFI_STATUS Status;
EFI_EVENT Event;
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **) &mSmbios);
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
ASSERT_EFI_ERROR (Status);
DEBUG ((DEBUG_INFO, "The Smbios Table Version: %x.%x\n", mSmbios->MajorVersion, mSmbios->MinorVersion));
if (mSmbios->MajorVersion < 2 || (mSmbios->MajorVersion == 2 && mSmbios->MinorVersion < 7)){
if ((mSmbios->MajorVersion < 2) || ((mSmbios->MajorVersion == 2) && (mSmbios->MinorVersion < 7))) {
mMaxLen = SMBIOS_STRING_MAX_LENGTH;
} else if (mSmbios->MajorVersion < 3) {
//