26#define FIELD_SIZE_OF(TYPE, Field) ((UINTN)sizeof(((TYPE *)0)->Field))
34#define SMBIOS_FILTER_TABLE_FLAG_IS_STRING BIT0
94 { 0x01, mSmbiosFilterType1BlackList,
sizeof (mSmbiosFilterType1BlackList)/
sizeof (mSmbiosFilterType1BlackList[0]) },
95 { 0x02, mSmbiosFilterType2BlackList,
sizeof (mSmbiosFilterType2BlackList)/
sizeof (mSmbiosFilterType2BlackList[0]) },
96 { 0x03, mSmbiosFilterType3BlackList,
sizeof (mSmbiosFilterType3BlackList)/
sizeof (mSmbiosFilterType3BlackList[0]) },
97 { 0x04, mSmbiosFilterType4BlackList,
sizeof (mSmbiosFilterType4BlackList)/
sizeof (mSmbiosFilterType4BlackList[0]) },
100 { 0x11, mSmbiosFilterType17BlackList,
sizeof (mSmbiosFilterType17BlackList)/
sizeof (mSmbiosFilterType17BlackList[0]) },
102 { 0x16, mSmbiosFilterType22BlackList,
sizeof (mSmbiosFilterType22BlackList)/
sizeof (mSmbiosFilterType22BlackList[0]) },
103 { 0x17, mSmbiosFilterType23BlackList,
sizeof (mSmbiosFilterType23BlackList)/
sizeof (mSmbiosFilterType23BlackList[0]) },
104 { 0x1B, mSmbiosFilterType27BlackList,
sizeof (mSmbiosFilterType27BlackList)/
sizeof (mSmbiosFilterType27BlackList[0]) },
107 { 0x27, mSmbiosFilterType39BlackList,
sizeof (mSmbiosFilterType39BlackList)/
sizeof (mSmbiosFilterType39BlackList[0]) },
115#define SMBIOS_HANDOFF_TABLE_DESC "SmbiosTable"
117 UINT8 TableDescriptionSize;
118 UINT8 TableDescription[
sizeof (SMBIOS_HANDOFF_TABLE_DESC)];
119 UINT64 NumberOfTables;
141 for (Index = 0; Index < Size; Index++) {
142 DEBUG ((DEBUG_VERBOSE,
"%02x", (
UINTN)Data[Index]));
164 #define COLUME_SIZE (16 * 2)
166 Count = Size / COLUME_SIZE;
167 Left = Size % COLUME_SIZE;
168 for (Index = 0; Index < Count; Index++) {
169 DEBUG ((DEBUG_VERBOSE,
"%04x: ", Index * COLUME_SIZE));
171 DEBUG ((DEBUG_VERBOSE,
"\n"));
175 DEBUG ((DEBUG_VERBOSE,
"%04x: ", Index * COLUME_SIZE));
177 DEBUG ((DEBUG_VERBOSE,
"\n"));
195 for (Index = 0; Index <
sizeof (mSmbiosFilterStandardTableBlackList)/
sizeof (mSmbiosFilterStandardTableBlackList[0]); Index++) {
196 if (mSmbiosFilterStandardTableBlackList[Index].Type == Type) {
197 return &mSmbiosFilterStandardTableBlackList[Index];
227 CharInStr = (CHAR8 *)Head + Head->Length;
235 while (*CharInStr != 0 || *(CharInStr+1) != 0) {
236 if (*CharInStr == 0) {
244 if (*(CharInStr+
StrLen) == 0) {
261 if (StringsNumber == StringId) {
279 IN OUT VOID *TableEntry,
303 if (FilterStruct !=
NULL) {
304 if ((FilterStruct->Filter ==
NULL) || (FilterStruct->FilterCount == 0)) {
308 Filter = FilterStruct->Filter;
309 for (Index = 0; Index < FilterStruct->FilterCount; Index++) {
310 if (((
SMBIOS_STRUCTURE *)TableEntry)->Length >= (Filter[Index].Offset + Filter[Index].Size)) {
314 if ((Filter[Index].Flags & SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) {
315 CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset,
sizeof (StringId));
319 ASSERT (String !=
NULL);
321 SetMem (String, StringLen,
' ');
326 ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset, Filter[Index].Size);
359 CharInStr = (CHAR8 *)Head + Head->Length;
366 while (*CharInStr != 0 || *(CharInStr+1) != 0) {
367 if (*CharInStr == 0) {
373 if (*(CharInStr+
StrLen) == 0) {
395 if (NumberOfStrings !=
NULL) {
396 *NumberOfStrings = StringsNumber;
414 IN VOID *TableAddress,
419 VOID *TableAddressEnd;
420 UINTN TableEntryLength;
422 TableAddressEnd = (VOID *)((
UINTN)TableAddress + TableMaximumSize);
423 TableEntry = TableAddress;
424 while (TableEntry < TableAddressEnd) {
426 if (TableEntryLength == 0) {
431 TableEntry = (VOID *)((
UINTN)TableEntry + TableEntryLength);
435 TableEntry = (VOID *)((
UINTN)TableEntry + TableEntryLength);
438 return ((
UINTN)TableEntry - (
UINTN)TableAddress);
451 IN OUT VOID *TableAddress,
455 VOID *TableAddressEnd;
457 UINTN TableEntryLength;
459 TableEntry = TableAddress;
460 TableAddressEnd = (VOID *)((
UINTN)TableAddress + TableLength);
461 while ((
UINTN)TableEntry < (
UINTN)TableAddressEnd) {
463 if (TableEntryLength == 0) {
469 TableEntry = (VOID *)((
UINTN)TableEntry + TableEntryLength);
495 VOID *SmbiosTableAddress;
501 SmbiosTableAddress =
NULL;
506 &gEfiSmbios3TableGuid,
507 (VOID **)&Smbios3Table
509 if (!EFI_ERROR (Status)) {
510 DEBUG ((DEBUG_INFO,
"Smbios3Table:\n"));
513 " AnchorString - '%c%c%c%c%c'\n",
514 Smbios3Table->AnchorString[0],
515 Smbios3Table->AnchorString[1],
516 Smbios3Table->AnchorString[2],
517 Smbios3Table->AnchorString[3],
518 Smbios3Table->AnchorString[4]
520 DEBUG ((DEBUG_INFO,
" EntryPointStructureChecksum - 0x%02x\n", Smbios3Table->EntryPointStructureChecksum));
521 DEBUG ((DEBUG_INFO,
" EntryPointLength - 0x%02x\n", Smbios3Table->EntryPointLength));
522 DEBUG ((DEBUG_INFO,
" MajorVersion - 0x%02x\n", Smbios3Table->MajorVersion));
523 DEBUG ((DEBUG_INFO,
" MinorVersion - 0x%02x\n", Smbios3Table->MinorVersion));
524 DEBUG ((DEBUG_INFO,
" DocRev - 0x%02x\n", Smbios3Table->DocRev));
525 DEBUG ((DEBUG_INFO,
" EntryPointRevision - 0x%02x\n", Smbios3Table->EntryPointRevision));
526 DEBUG ((DEBUG_INFO,
" TableMaximumSize - 0x%08x\n", Smbios3Table->TableMaximumSize));
527 DEBUG ((DEBUG_INFO,
" TableAddress - 0x%016lx\n", Smbios3Table->TableAddress));
531 if (Smbios3Table ==
NULL) {
533 &gEfiSmbiosTableGuid,
534 (VOID **)&SmbiosTable
536 if (!EFI_ERROR (Status)) {
537 DEBUG ((DEBUG_INFO,
"SmbiosTable:\n"));
540 " AnchorString - '%c%c%c%c'\n",
541 SmbiosTable->AnchorString[0],
542 SmbiosTable->AnchorString[1],
543 SmbiosTable->AnchorString[2],
544 SmbiosTable->AnchorString[3]
546 DEBUG ((DEBUG_INFO,
" EntryPointStructureChecksum - 0x%02x\n", SmbiosTable->EntryPointStructureChecksum));
547 DEBUG ((DEBUG_INFO,
" EntryPointLength - 0x%02x\n", SmbiosTable->EntryPointLength));
548 DEBUG ((DEBUG_INFO,
" MajorVersion - 0x%02x\n", SmbiosTable->MajorVersion));
549 DEBUG ((DEBUG_INFO,
" MinorVersion - 0x%02x\n", SmbiosTable->MinorVersion));
550 DEBUG ((DEBUG_INFO,
" MaxStructureSize - 0x%08x\n", SmbiosTable->MaxStructureSize));
551 DEBUG ((DEBUG_INFO,
" EntryPointRevision - 0x%02x\n", SmbiosTable->EntryPointRevision));
554 " FormattedArea - '%c%c%c%c%c'\n",
555 SmbiosTable->FormattedArea[0],
556 SmbiosTable->FormattedArea[1],
557 SmbiosTable->FormattedArea[2],
558 SmbiosTable->FormattedArea[3],
559 SmbiosTable->FormattedArea[4]
563 " IntermediateAnchorString - '%c%c%c%c%c'\n",
564 SmbiosTable->IntermediateAnchorString[0],
565 SmbiosTable->IntermediateAnchorString[1],
566 SmbiosTable->IntermediateAnchorString[2],
567 SmbiosTable->IntermediateAnchorString[3],
568 SmbiosTable->IntermediateAnchorString[4]
570 DEBUG ((DEBUG_INFO,
" IntermediateChecksum - 0x%02x\n", SmbiosTable->IntermediateChecksum));
571 DEBUG ((DEBUG_INFO,
" TableLength - 0x%04x\n", SmbiosTable->TableLength));
572 DEBUG ((DEBUG_INFO,
" TableAddress - 0x%08x\n", SmbiosTable->TableAddress));
573 DEBUG ((DEBUG_INFO,
" NumberOfSmbiosStructures - 0x%04x\n", SmbiosTable->NumberOfSmbiosStructures));
574 DEBUG ((DEBUG_INFO,
" SmbiosBcdRevision - 0x%02x\n", SmbiosTable->SmbiosBcdRevision));
578 if (Smbios3Table !=
NULL) {
579 SmbiosTableAddress = (VOID *)(
UINTN)Smbios3Table->TableAddress;
581 }
else if (SmbiosTable !=
NULL) {
582 SmbiosTableAddress = (VOID *)(
UINTN)SmbiosTable->TableAddress;
583 TableLength = SmbiosTable->TableLength;
586 if (SmbiosTableAddress !=
NULL) {
587 DEBUG ((DEBUG_INFO,
"The Smbios Table starts at: 0x%x\n", SmbiosTableAddress));
588 DEBUG ((DEBUG_INFO,
"The Smbios Table size: 0x%x\n", TableLength));
594 if (TableAddress ==
NULL) {
600 DEBUG ((DEBUG_INFO,
"The final Smbios Table starts at: 0x%x\n", TableAddress));
601 DEBUG ((DEBUG_INFO,
"The final Smbios Table size: 0x%x\n", TableLength));
606 HandoffTables.NumberOfTables = 1;
607 if (Smbios3Table !=
NULL) {
609 HandoffTables.TableEntry[0].
VendorTable = Smbios3Table;
612 HandoffTables.TableEntry[0].
VendorTable = SmbiosTable;
615 EventType = EV_EFI_HANDOFF_TABLES;
616 EventLog = &HandoffTables;
617 EventLogSize =
sizeof (HandoffTables);
619 if (
PcdGet32 (PcdTcgPfpMeasurementRevision) >= TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_105) {
620 SmbiosHandoffTables2.TableDescriptionSize =
sizeof (SmbiosHandoffTables2.TableDescription);
621 CopyMem (SmbiosHandoffTables2.TableDescription, SMBIOS_HANDOFF_TABLE_DESC, sizeof (SmbiosHandoffTables2.TableDescription));
622 SmbiosHandoffTables2.NumberOfTables = HandoffTables.NumberOfTables;
623 CopyMem (&(SmbiosHandoffTables2.TableEntry[0]), &(HandoffTables.TableEntry[0]), sizeof (SmbiosHandoffTables2.TableEntry[0]));
624 EventType = EV_EFI_HANDOFF_TABLES2;
625 EventLog = &SmbiosHandoffTables2;
626 EventLogSize =
sizeof (SmbiosHandoffTables2);
637 if (!EFI_ERROR (Status)) {
638 gBS->CloseEvent (Event);
665 Status =
gBS->LocateProtocol (&gEfiSmbiosProtocolGuid,
NULL, (VOID **)&mSmbios);
678 mMaxLen = SMBIOS_TABLE_MAX_LENGTH;
684 mMaxLen = SMBIOS_3_0_TABLE_MAX_LENGTH;
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
UINT8 SMBIOS_TABLE_STRING
#define SMBIOS_STRING_MAX_LENGTH
#define OFFSET_OF(TYPE, Field)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define DEBUG_CODE(Expression)
#define PcdGet32(TokenName)
VOID InternalDumpData(IN UINT8 *Data, IN UINTN Size)
UINTN GetSmbiosTableLength(IN VOID *TableAddress, IN UINTN TableMaximumSize)
VOID EFIAPI MeasureSmbiosTable(IN EFI_EVENT Event, IN VOID *Context)
UINTN GetSmbiosStructureSize(IN EFI_SMBIOS_TABLE_HEADER *Head, OUT UINTN *NumberOfStrings)
EFI_STATUS EFIAPI SmbiosMeasurementDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID InternalDumpHex(IN UINT8 *Data, IN UINTN Size)
CHAR8 * GetSmbiosStringById(IN EFI_SMBIOS_TABLE_HEADER *Head, IN SMBIOS_TABLE_STRING StringId, OUT UINTN *StringLen)
VOID FilterSmbiosEntry(IN OUT VOID *TableEntry, IN UINTN TableEntrySize)
VOID FilterSmbiosTable(IN OUT VOID *TableAddress, IN UINTN TableLength)
SMBIOS_FILTER_STRUCT * GetFilterStructByType(IN UINT8 Type)
EFI_STATUS EFIAPI TpmMeasureAndLogData(IN UINT32 PcrIndex, IN UINT32 EventType, IN VOID *EventLog, IN UINT32 LogLen, IN VOID *HashData, IN UINT64 HashDataLen)
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
EFI_STATUS EFIAPI EfiCreateEventReadyToBootEx(IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, IN VOID *NotifyContext OPTIONAL, OUT EFI_EVENT *ReadyToBootEvent)
UINT8 MajorVersion
The major revision of the SMBIOS specification supported.
UINT8 MinorVersion
The minor revision of the SMBIOS specification supported.