2 This driver measures SMBIOS table to TPM.
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
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.
17 #include <Protocol/Smbios.h>
18 #include <IndustryStandard/SmBios.h>
19 #include <IndustryStandard/UefiTcgPlatform.h>
20 #include <Guid/EventGroup.h>
21 #include <Guid/SmBios.h>
22 #include <Library/DebugLib.h>
23 #include <Library/UefiDriverEntryPoint.h>
24 #include <Library/UefiLib.h>
25 #include <Library/BaseLib.h>
26 #include <Library/BaseMemoryLib.h>
27 #include <Library/MemoryAllocationLib.h>
28 #include <Library/UefiBootServicesTableLib.h>
29 #include <Library/TpmMeasurementLib.h>
31 #define FIELD_SIZE_OF(TYPE, Field) ((UINTN)sizeof(((TYPE *)0)->Field))
38 } SMBIOS_FILTER_TABLE
;
39 #define SMBIOS_FILTER_TABLE_FLAG_IS_STRING BIT0
43 SMBIOS_FILTER_TABLE
*Filter
; // NULL means all fields
45 } SMBIOS_FILTER_STRUCT
;
48 // Platform Specific Policy
50 SMBIOS_FILTER_TABLE mSmbiosFilterType1BlackList
[] = {
51 {0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
52 {0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1
, Uuid
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1
, Uuid
), 0},
53 {0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1
, WakeUpType
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1
, WakeUpType
), 0},
55 SMBIOS_FILTER_TABLE mSmbiosFilterType2BlackList
[] = {
56 {0x02, OFFSET_OF(SMBIOS_TABLE_TYPE2
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE2
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
57 {0x02, OFFSET_OF(SMBIOS_TABLE_TYPE2
, LocationInChassis
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE2
, LocationInChassis
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
59 SMBIOS_FILTER_TABLE mSmbiosFilterType3BlackList
[] = {
60 {0x03, OFFSET_OF(SMBIOS_TABLE_TYPE3
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE3
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
61 {0x03, OFFSET_OF(SMBIOS_TABLE_TYPE3
, AssetTag
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE3
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
63 SMBIOS_FILTER_TABLE mSmbiosFilterType4BlackList
[] = {
64 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
65 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, AssetTag
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
66 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, PartNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, PartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
67 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, CoreCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, CoreCount
), 0},
68 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount
), 0},
69 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, ThreadCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, ThreadCount
), 0},
70 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, CoreCount2
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, CoreCount2
), 0},
71 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount2
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount2
), 0},
72 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, ThreadCount2
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, ThreadCount2
), 0},
74 SMBIOS_FILTER_TABLE mSmbiosFilterType17BlackList
[] = {
75 {0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
76 {0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17
, AssetTag
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
77 {0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17
, PartNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17
, PartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
79 SMBIOS_FILTER_TABLE mSmbiosFilterType22BlackList
[] = {
80 {0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
81 {0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22
, SBDSSerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22
, SBDSSerialNumber
), 0},
82 {0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22
, SBDSManufactureDate
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22
, SBDSManufactureDate
), 0},
84 SMBIOS_FILTER_TABLE mSmbiosFilterType23BlackList
[] = {
85 {0x17, OFFSET_OF(SMBIOS_TABLE_TYPE23
, ResetCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE23
, ResetCount
), 0},
87 SMBIOS_FILTER_TABLE mSmbiosFilterType39BlackList
[] = {
88 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
89 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, AssetTagNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, AssetTagNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
90 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, ModelPartNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, ModelPartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
93 SMBIOS_FILTER_STRUCT mSmbiosFilterStandardTableBlackList
[] = {
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])},
106 {0x27, mSmbiosFilterType39BlackList
, sizeof(mSmbiosFilterType39BlackList
)/sizeof(mSmbiosFilterType39BlackList
[0])},
109 EFI_SMBIOS_PROTOCOL
*mSmbios
;
114 This function dump raw data.
117 @param Size raw data size
127 for (Index
= 0; Index
< Size
; Index
++) {
128 DEBUG ((EFI_D_INFO
, "%02x", (UINTN
)Data
[Index
]));
134 This function dump raw data with colume format.
137 @param Size raw data size
150 #define COLUME_SIZE (16 * 2)
152 Count
= Size
/ COLUME_SIZE
;
153 Left
= Size
% COLUME_SIZE
;
154 for (Index
= 0; Index
< Count
; Index
++) {
155 DEBUG ((EFI_D_INFO
, "%04x: ", Index
* COLUME_SIZE
));
156 InternalDumpData (Data
+ Index
* COLUME_SIZE
, COLUME_SIZE
);
157 DEBUG ((EFI_D_INFO
, "\n"));
161 DEBUG ((EFI_D_INFO
, "%04x: ", Index
* COLUME_SIZE
));
162 InternalDumpData (Data
+ Index
* COLUME_SIZE
, Left
);
163 DEBUG ((EFI_D_INFO
, "\n"));
170 This function get filter structure by SMBIOS type.
172 @param Type SMBIOS type
175 SMBIOS_FILTER_STRUCT
*
176 GetFilterStructByType (
181 for (Index
= 0; Index
< sizeof(mSmbiosFilterStandardTableBlackList
)/sizeof(mSmbiosFilterStandardTableBlackList
[0]); Index
++) {
182 if (mSmbiosFilterStandardTableBlackList
[Index
].Type
== Type
) {
183 return &mSmbiosFilterStandardTableBlackList
[Index
];
191 This function get SMBIOS string in SMBIOS table.
193 @param Head SMBIOS table head
194 @param StringId SMBIOS string ID
195 @param StringLen length of SMBIOS string
197 @return SMBIOS string data
200 GetSmbiosStringById (
201 IN EFI_SMBIOS_TABLE_HEADER
*Head
,
202 IN SMBIOS_TABLE_STRING StringId
,
212 CharInStr
= (CHAR8
*)Head
+ Head
->Length
;
217 // look for the two consecutive zeros, check the string limit by the way.
220 while (*CharInStr
!= 0 || *(CharInStr
+1) != 0) {
221 if (*CharInStr
== 0) {
227 for (StrLen
= 0 ; StrLen
< mMaxLen
; StrLen
++) {
228 if (*(CharInStr
+StrLen
) == 0) {
234 if (StrLen
== mMaxLen
) {
239 // forward the pointer
244 if (StringsNumber
== StringId
) {
254 This function update SMBIOS table based on policy.
256 @param TableEntry SMBIOS table
257 @param TableEntrySize SMBIOS table size
262 IN OUT VOID
*TableEntry
,
263 IN UINTN TableEntrySize
266 SMBIOS_FILTER_STRUCT
*FilterStruct
;
267 SMBIOS_FILTER_TABLE
*Filter
;
269 SMBIOS_TABLE_STRING StringId
;
273 DEBUG ((EFI_D_INFO
, "Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE
*)TableEntry
)->Type
));
274 InternalDumpHex (TableEntry
, TableEntrySize
);
276 FilterStruct
= GetFilterStructByType (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
);
277 if (FilterStruct
!= NULL
) {
278 if (FilterStruct
->Filter
== NULL
|| FilterStruct
->FilterCount
== 0) {
279 // zero all table entries, except header
280 ZeroMem ((UINT8
*)TableEntry
+ sizeof(SMBIOS_STRUCTURE
), TableEntrySize
- sizeof(SMBIOS_STRUCTURE
));
282 Filter
= FilterStruct
->Filter
;
283 for (Index
= 0; Index
< FilterStruct
->FilterCount
; Index
++) {
284 if ((Filter
[Index
].Flags
& SMBIOS_FILTER_TABLE_FLAG_IS_STRING
) != 0) {
285 CopyMem (&StringId
, (UINT8
*)TableEntry
+ Filter
[Index
].Offset
, sizeof(StringId
));
287 // set ' ' for string field
288 String
= GetSmbiosStringById (TableEntry
, StringId
, &StringLen
);
289 //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
290 SetMem (String
, StringLen
, ' ');
293 // zero non-string field
294 ZeroMem ((UINT8
*)TableEntry
+ Filter
[Index
].Offset
, Filter
[Index
].Size
);
299 DEBUG ((EFI_D_INFO
, "Filter Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE
*)TableEntry
)->Type
));
300 InternalDumpHex (TableEntry
, TableEntrySize
);
305 Get the full size of SMBIOS structure including optional strings that follow the formatted structure.
307 @param Head Pointer to the beginning of SMBIOS structure.
308 @param NumberOfStrings The returned number of optional strings that follow the formatted structure.
310 @return Size The returned size.
313 GetSmbiosStructureSize (
314 IN EFI_SMBIOS_TABLE_HEADER
*Head
,
315 OUT UINTN
*NumberOfStrings
323 CharInStr
= (CHAR8
*)Head
+ Head
->Length
;
328 // look for the two consecutive zeros, check the string limit by the way.
330 while (*CharInStr
!= 0 || *(CharInStr
+1) != 0) {
331 if (*CharInStr
== 0) {
336 for (StrLen
= 0 ; StrLen
< mMaxLen
; StrLen
++) {
337 if (*(CharInStr
+StrLen
) == 0) {
342 if (StrLen
== mMaxLen
) {
347 // forward the pointer
355 // count ending two zeros.
359 if (NumberOfStrings
!= NULL
) {
360 *NumberOfStrings
= StringsNumber
;
367 This function returns full SMBIOS table length.
369 @param TableAddress SMBIOS table based address
370 @param TableMaximumSize Maximum size of SMBIOS table
372 @return SMBIOS table length
376 GetSmbiosTableLength (
377 IN VOID
*TableAddress
,
378 IN UINTN TableMaximumSize
382 VOID
*TableAddressEnd
;
383 UINTN TableEntryLength
;
385 TableAddressEnd
= (VOID
*)((UINTN
)TableAddress
+ TableMaximumSize
);
386 TableEntry
= TableAddress
;
387 while (TableEntry
< TableAddressEnd
) {
388 TableEntryLength
= GetSmbiosStructureSize (TableEntry
, NULL
);
389 if (TableEntryLength
== 0) {
392 if (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
== 127) {
393 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
396 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
399 return ((UINTN
)TableEntry
- (UINTN
)TableAddress
);
404 This function updatess full SMBIOS table length.
406 @param TableAddress SMBIOS table based address
407 @param TableLength SMBIOS table length
412 IN OUT VOID
*TableAddress
,
416 VOID
*TableAddressEnd
;
418 UINTN TableEntryLength
;
420 TableEntry
= TableAddress
;
421 TableAddressEnd
= (VOID
*)((UINTN
)TableAddress
+ TableLength
);
422 while ((UINTN
)TableEntry
< (UINTN
)TableAddressEnd
) {
423 TableEntryLength
= GetSmbiosStructureSize (TableEntry
, NULL
);
424 if (TableEntryLength
== 0) {
428 FilterSmbiosEntry (TableEntry
, TableEntryLength
);
430 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
435 Measure SMBIOS with EV_EFI_HANDOFF_TABLES to PCR[1]
445 EFI_HANDOFF_TABLE_POINTERS HandoffTables
;
446 SMBIOS_TABLE_ENTRY_POINT
*SmbiosTable
;
447 SMBIOS_TABLE_3_0_ENTRY_POINT
*Smbios3Table
;
448 VOID
*SmbiosTableAddress
;
454 SmbiosTableAddress
= NULL
;
457 if (mSmbios
->MajorVersion
>= 3) {
458 Status
= EfiGetSystemConfigurationTable (
459 &gEfiSmbios3TableGuid
,
460 (VOID
**) &Smbios3Table
462 if (!EFI_ERROR (Status
)) {
463 DEBUG ((EFI_D_INFO
, "Smbios3Table:\n"));
464 DEBUG ((EFI_D_INFO
, " AnchorString - '%c%c%c%c%c'\n",
465 Smbios3Table
->AnchorString
[0],
466 Smbios3Table
->AnchorString
[1],
467 Smbios3Table
->AnchorString
[2],
468 Smbios3Table
->AnchorString
[3],
469 Smbios3Table
->AnchorString
[4]
471 DEBUG ((EFI_D_INFO
, " EntryPointStructureChecksum - 0x%02x\n", Smbios3Table
->EntryPointStructureChecksum
));
472 DEBUG ((EFI_D_INFO
, " EntryPointLength - 0x%02x\n", Smbios3Table
->EntryPointLength
));
473 DEBUG ((EFI_D_INFO
, " MajorVersion - 0x%02x\n", Smbios3Table
->MajorVersion
));
474 DEBUG ((EFI_D_INFO
, " MinorVersion - 0x%02x\n", Smbios3Table
->MinorVersion
));
475 DEBUG ((EFI_D_INFO
, " DocRev - 0x%02x\n", Smbios3Table
->DocRev
));
476 DEBUG ((EFI_D_INFO
, " EntryPointRevision - 0x%02x\n", Smbios3Table
->EntryPointRevision
));
477 DEBUG ((EFI_D_INFO
, " TableMaximumSize - 0x%08x\n", Smbios3Table
->TableMaximumSize
));
478 DEBUG ((EFI_D_INFO
, " TableAddress - 0x%016lx\n", Smbios3Table
->TableAddress
));
481 Status
= EfiGetSystemConfigurationTable (
482 &gEfiSmbiosTableGuid
,
483 (VOID
**) &SmbiosTable
485 if (!EFI_ERROR (Status
)) {
486 DEBUG ((EFI_D_INFO
, "SmbiosTable:\n"));
487 DEBUG ((EFI_D_INFO
, " AnchorString - '%c%c%c%c'\n",
488 Smbios3Table
->AnchorString
[0],
489 Smbios3Table
->AnchorString
[1],
490 Smbios3Table
->AnchorString
[2],
491 Smbios3Table
->AnchorString
[3]
493 DEBUG ((EFI_D_INFO
, " EntryPointStructureChecksum - 0x%02x\n", SmbiosTable
->EntryPointStructureChecksum
));
494 DEBUG ((EFI_D_INFO
, " EntryPointLength - 0x%02x\n", SmbiosTable
->EntryPointLength
));
495 DEBUG ((EFI_D_INFO
, " MajorVersion - 0x%02x\n", SmbiosTable
->MajorVersion
));
496 DEBUG ((EFI_D_INFO
, " MinorVersion - 0x%02x\n", SmbiosTable
->MinorVersion
));
497 DEBUG ((EFI_D_INFO
, " MaxStructureSize - 0x%08x\n", SmbiosTable
->MaxStructureSize
));
498 DEBUG ((EFI_D_INFO
, " EntryPointRevision - 0x%02x\n", SmbiosTable
->EntryPointRevision
));
499 DEBUG ((EFI_D_INFO
, " FormattedArea - '%c%c%c%c%c'\n",
500 SmbiosTable
->FormattedArea
[0],
501 SmbiosTable
->FormattedArea
[1],
502 SmbiosTable
->FormattedArea
[2],
503 SmbiosTable
->FormattedArea
[3],
504 SmbiosTable
->FormattedArea
[4]
506 DEBUG ((EFI_D_INFO
, " IntermediateAnchorString - '%c%c%c%c%c'\n",
507 SmbiosTable
->IntermediateAnchorString
[0],
508 SmbiosTable
->IntermediateAnchorString
[1],
509 SmbiosTable
->IntermediateAnchorString
[2],
510 SmbiosTable
->IntermediateAnchorString
[3],
511 SmbiosTable
->IntermediateAnchorString
[4]
513 DEBUG ((EFI_D_INFO
, " IntermediateChecksum - 0x%02x\n", SmbiosTable
->IntermediateChecksum
));
514 DEBUG ((EFI_D_INFO
, " TableLength - 0x%04x\n", SmbiosTable
->TableLength
));
515 DEBUG ((EFI_D_INFO
, " TableAddress - 0x%08x\n", SmbiosTable
->TableAddress
));
516 DEBUG ((EFI_D_INFO
, " NumberOfSmbiosStructures - 0x%04x\n", SmbiosTable
->NumberOfSmbiosStructures
));
517 DEBUG ((EFI_D_INFO
, " SmbiosBcdRevision - 0x%02x\n", SmbiosTable
->SmbiosBcdRevision
));
520 if (Smbios3Table
!= NULL
) {
521 SmbiosTableAddress
= (VOID
*)(UINTN
)Smbios3Table
->TableAddress
;
522 TableLength
= GetSmbiosTableLength (SmbiosTableAddress
, Smbios3Table
->TableMaximumSize
);
523 } else if (SmbiosTable
!= NULL
) {
524 SmbiosTableAddress
= (VOID
*)(UINTN
)SmbiosTable
->TableAddress
;
525 TableLength
= SmbiosTable
->TableLength
;
528 if (SmbiosTableAddress
!= NULL
) {
529 DEBUG ((DEBUG_INFO
, "The Smbios Table starts at: 0x%x\n", SmbiosTableAddress
));
530 DEBUG ((DEBUG_INFO
, "The Smbios Table size: 0x%x\n", TableLength
));
531 InternalDumpHex ((UINT8
*)(UINTN
)SmbiosTableAddress
, TableLength
);
533 TableAddress
= AllocateCopyPool ((UINTN
)TableLength
, (VOID
*)(UINTN
)SmbiosTableAddress
);
534 if (TableAddress
== NULL
) {
538 FilterSmbiosTable (TableAddress
, TableLength
);
540 DEBUG ((DEBUG_INFO
, "The final Smbios Table starts at: 0x%x\n", TableAddress
));
541 DEBUG ((DEBUG_INFO
, "The final Smbios Table size: 0x%x\n", TableLength
));
542 InternalDumpHex (TableAddress
, TableLength
);
544 HandoffTables
.NumberOfTables
= 1;
545 HandoffTables
.TableEntry
[0].VendorGuid
= gEfiSmbiosTableGuid
;
546 HandoffTables
.TableEntry
[0].VendorTable
= SmbiosTable
;
547 Status
= TpmMeasureAndLogData (
549 EV_EFI_HANDOFF_TABLES
, // EventType
550 &HandoffTables
, // EventLog
551 sizeof (HandoffTables
), // LogLen
552 TableAddress
, // HashData
553 TableLength
// HashDataLen
555 if (EFI_ERROR (Status
)) {
565 Driver to produce Smbios measurement.
567 @param ImageHandle Module's image handle
568 @param SystemTable Pointer of EFI_SYSTEM_TABLE
570 @retval EFI_SUCCESS Smbios protocol installed
571 @retval Other No protocol installed, unload driver.
576 SmbiosMeasurementDriverEntryPoint (
577 IN EFI_HANDLE ImageHandle
,
578 IN EFI_SYSTEM_TABLE
*SystemTable
584 Status
= gBS
->LocateProtocol (&gEfiSmbiosProtocolGuid
, NULL
, &mSmbios
);
585 ASSERT_EFI_ERROR (Status
);
586 DEBUG ((DEBUG_INFO
, "The Smbios Table Version: %x.%x\n", mSmbios
->MajorVersion
, mSmbios
->MinorVersion
));
588 if (mSmbios
->MajorVersion
< 2 || (mSmbios
->MajorVersion
== 2 && mSmbios
->MinorVersion
< 7)){
589 mMaxLen
= SMBIOS_STRING_MAX_LENGTH
;
590 } else if (mSmbios
->MajorVersion
< 3) {
592 // Reference SMBIOS 2.7, chapter 6.1.3, it will have no limit on the length of each individual text string.
593 // However, the length of the entire structure table (including all strings) must be reported
594 // in the Structure Table Length field of the SMBIOS Structure Table Entry Point,
595 // which is a WORD field limited to 65,535 bytes.
597 mMaxLen
= SMBIOS_TABLE_MAX_LENGTH
;
600 // SMBIOS 3.0 defines the Structure table maximum size as DWORD field limited to 0xFFFFFFFF bytes.
601 // Locate the end of string as long as possible.
603 mMaxLen
= SMBIOS_3_0_TABLE_MAX_LENGTH
;
607 // Measure Smbios tables
609 Status
= EfiCreateEventReadyToBootEx (