2 This driver measures SMBIOS table to TPM.
4 Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Protocol/Smbios.h>
12 #include <IndustryStandard/SmBios.h>
13 #include <IndustryStandard/UefiTcgPlatform.h>
14 #include <Guid/EventGroup.h>
15 #include <Guid/SmBios.h>
16 #include <Library/DebugLib.h>
17 #include <Library/UefiDriverEntryPoint.h>
18 #include <Library/UefiLib.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/MemoryAllocationLib.h>
22 #include <Library/UefiBootServicesTableLib.h>
23 #include <Library/TpmMeasurementLib.h>
25 #define FIELD_SIZE_OF(TYPE, Field) ((UINTN)sizeof(((TYPE *)0)->Field))
32 } SMBIOS_FILTER_TABLE
;
33 #define SMBIOS_FILTER_TABLE_FLAG_IS_STRING BIT0
37 SMBIOS_FILTER_TABLE
*Filter
; // NULL means all fields
39 } SMBIOS_FILTER_STRUCT
;
42 // Platform Specific Policy
44 SMBIOS_FILTER_TABLE mSmbiosFilterType1BlackList
[] = {
45 {0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
46 {0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1
, Uuid
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1
, Uuid
), 0},
47 {0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1
, WakeUpType
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1
, WakeUpType
), 0},
49 SMBIOS_FILTER_TABLE mSmbiosFilterType2BlackList
[] = {
50 {0x02, OFFSET_OF(SMBIOS_TABLE_TYPE2
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE2
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
51 {0x02, OFFSET_OF(SMBIOS_TABLE_TYPE2
, LocationInChassis
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE2
, LocationInChassis
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
53 SMBIOS_FILTER_TABLE mSmbiosFilterType3BlackList
[] = {
54 {0x03, OFFSET_OF(SMBIOS_TABLE_TYPE3
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE3
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
55 {0x03, OFFSET_OF(SMBIOS_TABLE_TYPE3
, AssetTag
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE3
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
57 SMBIOS_FILTER_TABLE mSmbiosFilterType4BlackList
[] = {
58 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
59 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, AssetTag
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
60 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, PartNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, PartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
61 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, CoreCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, CoreCount
), 0},
62 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount
), 0},
63 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, ThreadCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, ThreadCount
), 0},
64 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, CoreCount2
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, CoreCount2
), 0},
65 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount2
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount2
), 0},
66 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, ThreadCount2
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, ThreadCount2
), 0},
68 SMBIOS_FILTER_TABLE mSmbiosFilterType17BlackList
[] = {
69 {0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
70 {0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17
, AssetTag
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
71 {0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17
, PartNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17
, PartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
73 SMBIOS_FILTER_TABLE mSmbiosFilterType22BlackList
[] = {
74 {0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
75 {0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22
, SBDSSerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22
, SBDSSerialNumber
), 0},
76 {0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22
, SBDSManufactureDate
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22
, SBDSManufactureDate
), 0},
78 SMBIOS_FILTER_TABLE mSmbiosFilterType23BlackList
[] = {
79 {0x17, OFFSET_OF(SMBIOS_TABLE_TYPE23
, ResetCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE23
, ResetCount
), 0},
81 SMBIOS_FILTER_TABLE mSmbiosFilterType27BlackList
[] = {
82 {0x1B, OFFSET_OF(SMBIOS_TABLE_TYPE27
, NominalSpeed
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE27
, NominalSpeed
), 0},
84 SMBIOS_FILTER_TABLE mSmbiosFilterType39BlackList
[] = {
85 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
86 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, AssetTagNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, AssetTagNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
87 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, ModelPartNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, ModelPartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
90 SMBIOS_FILTER_STRUCT mSmbiosFilterStandardTableBlackList
[] = {
91 {0x01, mSmbiosFilterType1BlackList
, sizeof(mSmbiosFilterType1BlackList
)/sizeof(mSmbiosFilterType1BlackList
[0])},
92 {0x02, mSmbiosFilterType2BlackList
, sizeof(mSmbiosFilterType2BlackList
)/sizeof(mSmbiosFilterType2BlackList
[0])},
93 {0x03, mSmbiosFilterType3BlackList
, sizeof(mSmbiosFilterType3BlackList
)/sizeof(mSmbiosFilterType3BlackList
[0])},
94 {0x04, mSmbiosFilterType4BlackList
, sizeof(mSmbiosFilterType4BlackList
)/sizeof(mSmbiosFilterType4BlackList
[0])},
97 {0x11, mSmbiosFilterType17BlackList
, sizeof(mSmbiosFilterType17BlackList
)/sizeof(mSmbiosFilterType17BlackList
[0])},
99 {0x16, mSmbiosFilterType22BlackList
, sizeof(mSmbiosFilterType22BlackList
)/sizeof(mSmbiosFilterType22BlackList
[0])},
100 {0x17, mSmbiosFilterType23BlackList
, sizeof(mSmbiosFilterType23BlackList
)/sizeof(mSmbiosFilterType23BlackList
[0])},
101 {0x1B, mSmbiosFilterType27BlackList
, sizeof(mSmbiosFilterType27BlackList
)/sizeof(mSmbiosFilterType27BlackList
[0])},
104 {0x27, mSmbiosFilterType39BlackList
, sizeof(mSmbiosFilterType39BlackList
)/sizeof(mSmbiosFilterType39BlackList
[0])},
107 EFI_SMBIOS_PROTOCOL
*mSmbios
;
112 This function dump raw data.
115 @param Size raw data size
125 for (Index
= 0; Index
< Size
; Index
++) {
126 DEBUG ((EFI_D_VERBOSE
, "%02x", (UINTN
)Data
[Index
]));
132 This function dump raw data with colume format.
135 @param Size raw data size
148 #define COLUME_SIZE (16 * 2)
150 Count
= Size
/ COLUME_SIZE
;
151 Left
= Size
% COLUME_SIZE
;
152 for (Index
= 0; Index
< Count
; Index
++) {
153 DEBUG ((EFI_D_VERBOSE
, "%04x: ", Index
* COLUME_SIZE
));
154 InternalDumpData (Data
+ Index
* COLUME_SIZE
, COLUME_SIZE
);
155 DEBUG ((EFI_D_VERBOSE
, "\n"));
159 DEBUG ((EFI_D_VERBOSE
, "%04x: ", Index
* COLUME_SIZE
));
160 InternalDumpData (Data
+ Index
* COLUME_SIZE
, Left
);
161 DEBUG ((EFI_D_VERBOSE
, "\n"));
168 This function get filter structure by SMBIOS type.
170 @param Type SMBIOS type
173 SMBIOS_FILTER_STRUCT
*
174 GetFilterStructByType (
179 for (Index
= 0; Index
< sizeof(mSmbiosFilterStandardTableBlackList
)/sizeof(mSmbiosFilterStandardTableBlackList
[0]); Index
++) {
180 if (mSmbiosFilterStandardTableBlackList
[Index
].Type
== Type
) {
181 return &mSmbiosFilterStandardTableBlackList
[Index
];
189 This function get SMBIOS string in SMBIOS table.
191 @param Head SMBIOS table head
192 @param StringId SMBIOS string ID
193 @param StringLen length of SMBIOS string
195 @return SMBIOS string data
198 GetSmbiosStringById (
199 IN EFI_SMBIOS_TABLE_HEADER
*Head
,
200 IN SMBIOS_TABLE_STRING StringId
,
210 CharInStr
= (CHAR8
*)Head
+ Head
->Length
;
215 // look for the two consecutive zeros, check the string limit by the way.
218 while (*CharInStr
!= 0 || *(CharInStr
+1) != 0) {
219 if (*CharInStr
== 0) {
225 for (StrLen
= 0 ; StrLen
< mMaxLen
; StrLen
++) {
226 if (*(CharInStr
+StrLen
) == 0) {
232 if (StrLen
== mMaxLen
) {
237 // forward the pointer
242 if (StringsNumber
== StringId
) {
252 This function update SMBIOS table based on policy.
254 @param TableEntry SMBIOS table
255 @param TableEntrySize SMBIOS table size
260 IN OUT VOID
*TableEntry
,
261 IN UINTN TableEntrySize
264 SMBIOS_FILTER_STRUCT
*FilterStruct
;
265 SMBIOS_FILTER_TABLE
*Filter
;
267 SMBIOS_TABLE_STRING StringId
;
271 DEBUG ((EFI_D_INFO
, "Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE
*)TableEntry
)->Type
));
272 DEBUG_CODE (InternalDumpHex (TableEntry
, TableEntrySize
););
275 // Skip measurement for OEM types.
277 if (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
>= SMBIOS_OEM_BEGIN
) {
278 // zero all table fields, except header
279 ZeroMem ((UINT8
*)TableEntry
+ sizeof(SMBIOS_STRUCTURE
), TableEntrySize
- sizeof(SMBIOS_STRUCTURE
));
281 FilterStruct
= GetFilterStructByType (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
);
282 if (FilterStruct
!= NULL
) {
283 if (FilterStruct
->Filter
== NULL
|| FilterStruct
->FilterCount
== 0) {
284 // zero all table fields, except header
285 ZeroMem ((UINT8
*)TableEntry
+ sizeof(SMBIOS_STRUCTURE
), TableEntrySize
- sizeof(SMBIOS_STRUCTURE
));
287 Filter
= FilterStruct
->Filter
;
288 for (Index
= 0; Index
< FilterStruct
->FilterCount
; Index
++) {
289 if (((SMBIOS_STRUCTURE
*) TableEntry
)->Length
>= (Filter
[Index
].Offset
+ Filter
[Index
].Size
)) {
291 // The field is present in the SMBIOS entry.
293 if ((Filter
[Index
].Flags
& SMBIOS_FILTER_TABLE_FLAG_IS_STRING
) != 0) {
294 CopyMem (&StringId
, (UINT8
*)TableEntry
+ Filter
[Index
].Offset
, sizeof(StringId
));
296 // set ' ' for string field
297 String
= GetSmbiosStringById (TableEntry
, StringId
, &StringLen
);
298 ASSERT (String
!= NULL
);
299 //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
300 SetMem (String
, StringLen
, ' ');
303 // zero non-string field
304 ZeroMem ((UINT8
*)TableEntry
+ Filter
[Index
].Offset
, Filter
[Index
].Size
);
311 DEBUG ((EFI_D_INFO
, "Filter Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE
*)TableEntry
)->Type
));
312 DEBUG_CODE (InternalDumpHex (TableEntry
, TableEntrySize
););
317 Get the full size of SMBIOS structure including optional strings that follow the formatted structure.
319 @param Head Pointer to the beginning of SMBIOS structure.
320 @param NumberOfStrings The returned number of optional strings that follow the formatted structure.
322 @return Size The returned size.
325 GetSmbiosStructureSize (
326 IN EFI_SMBIOS_TABLE_HEADER
*Head
,
327 OUT UINTN
*NumberOfStrings
335 CharInStr
= (CHAR8
*)Head
+ Head
->Length
;
340 // look for the two consecutive zeros, check the string limit by the way.
342 while (*CharInStr
!= 0 || *(CharInStr
+1) != 0) {
343 if (*CharInStr
== 0) {
348 for (StrLen
= 0 ; StrLen
< mMaxLen
; StrLen
++) {
349 if (*(CharInStr
+StrLen
) == 0) {
354 if (StrLen
== mMaxLen
) {
359 // forward the pointer
367 // count ending two zeros.
371 if (NumberOfStrings
!= NULL
) {
372 *NumberOfStrings
= StringsNumber
;
379 This function returns full SMBIOS table length.
381 @param TableAddress SMBIOS table based address
382 @param TableMaximumSize Maximum size of SMBIOS table
384 @return SMBIOS table length
388 GetSmbiosTableLength (
389 IN VOID
*TableAddress
,
390 IN UINTN TableMaximumSize
394 VOID
*TableAddressEnd
;
395 UINTN TableEntryLength
;
397 TableAddressEnd
= (VOID
*)((UINTN
)TableAddress
+ TableMaximumSize
);
398 TableEntry
= TableAddress
;
399 while (TableEntry
< TableAddressEnd
) {
400 TableEntryLength
= GetSmbiosStructureSize (TableEntry
, NULL
);
401 if (TableEntryLength
== 0) {
404 if (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
== 127) {
405 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
408 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
411 return ((UINTN
)TableEntry
- (UINTN
)TableAddress
);
416 This function updatess full SMBIOS table length.
418 @param TableAddress SMBIOS table based address
419 @param TableLength SMBIOS table length
424 IN OUT VOID
*TableAddress
,
428 VOID
*TableAddressEnd
;
430 UINTN TableEntryLength
;
432 TableEntry
= TableAddress
;
433 TableAddressEnd
= (VOID
*)((UINTN
)TableAddress
+ TableLength
);
434 while ((UINTN
)TableEntry
< (UINTN
)TableAddressEnd
) {
435 TableEntryLength
= GetSmbiosStructureSize (TableEntry
, NULL
);
436 if (TableEntryLength
== 0) {
440 FilterSmbiosEntry (TableEntry
, TableEntryLength
);
442 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
447 Measure SMBIOS with EV_EFI_HANDOFF_TABLES to PCR[1].
449 @param[in] Event Event whose notification function is being invoked.
450 @param[in] Context Pointer to the notification function's context.
461 EFI_HANDOFF_TABLE_POINTERS HandoffTables
;
462 SMBIOS_TABLE_ENTRY_POINT
*SmbiosTable
;
463 SMBIOS_TABLE_3_0_ENTRY_POINT
*Smbios3Table
;
464 VOID
*SmbiosTableAddress
;
470 SmbiosTableAddress
= NULL
;
473 if (mSmbios
->MajorVersion
>= 3) {
474 Status
= EfiGetSystemConfigurationTable (
475 &gEfiSmbios3TableGuid
,
476 (VOID
**) &Smbios3Table
478 if (!EFI_ERROR (Status
)) {
479 DEBUG ((EFI_D_INFO
, "Smbios3Table:\n"));
480 DEBUG ((EFI_D_INFO
, " AnchorString - '%c%c%c%c%c'\n",
481 Smbios3Table
->AnchorString
[0],
482 Smbios3Table
->AnchorString
[1],
483 Smbios3Table
->AnchorString
[2],
484 Smbios3Table
->AnchorString
[3],
485 Smbios3Table
->AnchorString
[4]
487 DEBUG ((EFI_D_INFO
, " EntryPointStructureChecksum - 0x%02x\n", Smbios3Table
->EntryPointStructureChecksum
));
488 DEBUG ((EFI_D_INFO
, " EntryPointLength - 0x%02x\n", Smbios3Table
->EntryPointLength
));
489 DEBUG ((EFI_D_INFO
, " MajorVersion - 0x%02x\n", Smbios3Table
->MajorVersion
));
490 DEBUG ((EFI_D_INFO
, " MinorVersion - 0x%02x\n", Smbios3Table
->MinorVersion
));
491 DEBUG ((EFI_D_INFO
, " DocRev - 0x%02x\n", Smbios3Table
->DocRev
));
492 DEBUG ((EFI_D_INFO
, " EntryPointRevision - 0x%02x\n", Smbios3Table
->EntryPointRevision
));
493 DEBUG ((EFI_D_INFO
, " TableMaximumSize - 0x%08x\n", Smbios3Table
->TableMaximumSize
));
494 DEBUG ((EFI_D_INFO
, " TableAddress - 0x%016lx\n", Smbios3Table
->TableAddress
));
498 if (Smbios3Table
== NULL
) {
499 Status
= EfiGetSystemConfigurationTable (
500 &gEfiSmbiosTableGuid
,
501 (VOID
**) &SmbiosTable
503 if (!EFI_ERROR (Status
)) {
504 DEBUG ((EFI_D_INFO
, "SmbiosTable:\n"));
505 DEBUG ((EFI_D_INFO
, " AnchorString - '%c%c%c%c'\n",
506 SmbiosTable
->AnchorString
[0],
507 SmbiosTable
->AnchorString
[1],
508 SmbiosTable
->AnchorString
[2],
509 SmbiosTable
->AnchorString
[3]
511 DEBUG ((EFI_D_INFO
, " EntryPointStructureChecksum - 0x%02x\n", SmbiosTable
->EntryPointStructureChecksum
));
512 DEBUG ((EFI_D_INFO
, " EntryPointLength - 0x%02x\n", SmbiosTable
->EntryPointLength
));
513 DEBUG ((EFI_D_INFO
, " MajorVersion - 0x%02x\n", SmbiosTable
->MajorVersion
));
514 DEBUG ((EFI_D_INFO
, " MinorVersion - 0x%02x\n", SmbiosTable
->MinorVersion
));
515 DEBUG ((EFI_D_INFO
, " MaxStructureSize - 0x%08x\n", SmbiosTable
->MaxStructureSize
));
516 DEBUG ((EFI_D_INFO
, " EntryPointRevision - 0x%02x\n", SmbiosTable
->EntryPointRevision
));
517 DEBUG ((EFI_D_INFO
, " FormattedArea - '%c%c%c%c%c'\n",
518 SmbiosTable
->FormattedArea
[0],
519 SmbiosTable
->FormattedArea
[1],
520 SmbiosTable
->FormattedArea
[2],
521 SmbiosTable
->FormattedArea
[3],
522 SmbiosTable
->FormattedArea
[4]
524 DEBUG ((EFI_D_INFO
, " IntermediateAnchorString - '%c%c%c%c%c'\n",
525 SmbiosTable
->IntermediateAnchorString
[0],
526 SmbiosTable
->IntermediateAnchorString
[1],
527 SmbiosTable
->IntermediateAnchorString
[2],
528 SmbiosTable
->IntermediateAnchorString
[3],
529 SmbiosTable
->IntermediateAnchorString
[4]
531 DEBUG ((EFI_D_INFO
, " IntermediateChecksum - 0x%02x\n", SmbiosTable
->IntermediateChecksum
));
532 DEBUG ((EFI_D_INFO
, " TableLength - 0x%04x\n", SmbiosTable
->TableLength
));
533 DEBUG ((EFI_D_INFO
, " TableAddress - 0x%08x\n", SmbiosTable
->TableAddress
));
534 DEBUG ((EFI_D_INFO
, " NumberOfSmbiosStructures - 0x%04x\n", SmbiosTable
->NumberOfSmbiosStructures
));
535 DEBUG ((EFI_D_INFO
, " SmbiosBcdRevision - 0x%02x\n", SmbiosTable
->SmbiosBcdRevision
));
539 if (Smbios3Table
!= NULL
) {
540 SmbiosTableAddress
= (VOID
*)(UINTN
)Smbios3Table
->TableAddress
;
541 TableLength
= GetSmbiosTableLength (SmbiosTableAddress
, Smbios3Table
->TableMaximumSize
);
542 } else if (SmbiosTable
!= NULL
) {
543 SmbiosTableAddress
= (VOID
*)(UINTN
)SmbiosTable
->TableAddress
;
544 TableLength
= SmbiosTable
->TableLength
;
547 if (SmbiosTableAddress
!= NULL
) {
548 DEBUG ((DEBUG_INFO
, "The Smbios Table starts at: 0x%x\n", SmbiosTableAddress
));
549 DEBUG ((DEBUG_INFO
, "The Smbios Table size: 0x%x\n", TableLength
));
550 DEBUG_CODE (InternalDumpHex ((UINT8
*)(UINTN
)SmbiosTableAddress
, TableLength
););
552 TableAddress
= AllocateCopyPool ((UINTN
)TableLength
, (VOID
*)(UINTN
)SmbiosTableAddress
);
553 if (TableAddress
== NULL
) {
557 FilterSmbiosTable (TableAddress
, TableLength
);
559 DEBUG ((DEBUG_INFO
, "The final Smbios Table starts at: 0x%x\n", TableAddress
));
560 DEBUG ((DEBUG_INFO
, "The final Smbios Table size: 0x%x\n", TableLength
));
561 DEBUG_CODE (InternalDumpHex (TableAddress
, TableLength
););
563 HandoffTables
.NumberOfTables
= 1;
564 if (Smbios3Table
!= NULL
) {
565 CopyGuid (&(HandoffTables
.TableEntry
[0].VendorGuid
), &gEfiSmbios3TableGuid
);
566 HandoffTables
.TableEntry
[0].VendorTable
= Smbios3Table
;
568 CopyGuid (&(HandoffTables
.TableEntry
[0].VendorGuid
), &gEfiSmbiosTableGuid
);
569 HandoffTables
.TableEntry
[0].VendorTable
= SmbiosTable
;
571 Status
= TpmMeasureAndLogData (
573 EV_EFI_HANDOFF_TABLES
, // EventType
574 &HandoffTables
, // EventLog
575 sizeof (HandoffTables
), // LogLen
576 TableAddress
, // HashData
577 TableLength
// HashDataLen
579 if (EFI_ERROR (Status
)) {
589 Driver to produce Smbios measurement.
591 @param ImageHandle Module's image handle
592 @param SystemTable Pointer of EFI_SYSTEM_TABLE
594 @return Status returned from EfiCreateEventReadyToBootEx().
599 SmbiosMeasurementDriverEntryPoint (
600 IN EFI_HANDLE ImageHandle
,
601 IN EFI_SYSTEM_TABLE
*SystemTable
607 Status
= gBS
->LocateProtocol (&gEfiSmbiosProtocolGuid
, NULL
, (VOID
**) &mSmbios
);
608 ASSERT_EFI_ERROR (Status
);
609 DEBUG ((DEBUG_INFO
, "The Smbios Table Version: %x.%x\n", mSmbios
->MajorVersion
, mSmbios
->MinorVersion
));
611 if (mSmbios
->MajorVersion
< 2 || (mSmbios
->MajorVersion
== 2 && mSmbios
->MinorVersion
< 7)){
612 mMaxLen
= SMBIOS_STRING_MAX_LENGTH
;
613 } else if (mSmbios
->MajorVersion
< 3) {
615 // Reference SMBIOS 2.7, chapter 6.1.3, it will have no limit on the length of each individual text string.
616 // However, the length of the entire structure table (including all strings) must be reported
617 // in the Structure Table Length field of the SMBIOS Structure Table Entry Point,
618 // which is a WORD field limited to 65,535 bytes.
620 mMaxLen
= SMBIOS_TABLE_MAX_LENGTH
;
623 // SMBIOS 3.0 defines the Structure table maximum size as DWORD field limited to 0xFFFFFFFF bytes.
624 // Locate the end of string as long as possible.
626 mMaxLen
= SMBIOS_3_0_TABLE_MAX_LENGTH
;
630 // Measure Smbios tables
632 Status
= EfiCreateEventReadyToBootEx (