2 This driver measures SMBIOS table to TPM.
4 Copyright (c) 2015 - 2017, 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 mSmbiosFilterType27BlackList
[] = {
88 {0x1B, OFFSET_OF(SMBIOS_TABLE_TYPE27
, NominalSpeed
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE27
, NominalSpeed
), 0},
90 SMBIOS_FILTER_TABLE mSmbiosFilterType39BlackList
[] = {
91 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
92 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, AssetTagNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, AssetTagNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
93 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, ModelPartNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, ModelPartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
96 SMBIOS_FILTER_STRUCT mSmbiosFilterStandardTableBlackList
[] = {
97 {0x01, mSmbiosFilterType1BlackList
, sizeof(mSmbiosFilterType1BlackList
)/sizeof(mSmbiosFilterType1BlackList
[0])},
98 {0x02, mSmbiosFilterType2BlackList
, sizeof(mSmbiosFilterType2BlackList
)/sizeof(mSmbiosFilterType2BlackList
[0])},
99 {0x03, mSmbiosFilterType3BlackList
, sizeof(mSmbiosFilterType3BlackList
)/sizeof(mSmbiosFilterType3BlackList
[0])},
100 {0x04, mSmbiosFilterType4BlackList
, sizeof(mSmbiosFilterType4BlackList
)/sizeof(mSmbiosFilterType4BlackList
[0])},
103 {0x11, mSmbiosFilterType17BlackList
, sizeof(mSmbiosFilterType17BlackList
)/sizeof(mSmbiosFilterType17BlackList
[0])},
105 {0x16, mSmbiosFilterType22BlackList
, sizeof(mSmbiosFilterType22BlackList
)/sizeof(mSmbiosFilterType22BlackList
[0])},
106 {0x17, mSmbiosFilterType23BlackList
, sizeof(mSmbiosFilterType23BlackList
)/sizeof(mSmbiosFilterType23BlackList
[0])},
107 {0x1B, mSmbiosFilterType27BlackList
, sizeof(mSmbiosFilterType27BlackList
)/sizeof(mSmbiosFilterType27BlackList
[0])},
110 {0x27, mSmbiosFilterType39BlackList
, sizeof(mSmbiosFilterType39BlackList
)/sizeof(mSmbiosFilterType39BlackList
[0])},
113 EFI_SMBIOS_PROTOCOL
*mSmbios
;
118 This function dump raw data.
121 @param Size raw data size
131 for (Index
= 0; Index
< Size
; Index
++) {
132 DEBUG ((EFI_D_VERBOSE
, "%02x", (UINTN
)Data
[Index
]));
138 This function dump raw data with colume format.
141 @param Size raw data size
154 #define COLUME_SIZE (16 * 2)
156 Count
= Size
/ COLUME_SIZE
;
157 Left
= Size
% COLUME_SIZE
;
158 for (Index
= 0; Index
< Count
; Index
++) {
159 DEBUG ((EFI_D_VERBOSE
, "%04x: ", Index
* COLUME_SIZE
));
160 InternalDumpData (Data
+ Index
* COLUME_SIZE
, COLUME_SIZE
);
161 DEBUG ((EFI_D_VERBOSE
, "\n"));
165 DEBUG ((EFI_D_VERBOSE
, "%04x: ", Index
* COLUME_SIZE
));
166 InternalDumpData (Data
+ Index
* COLUME_SIZE
, Left
);
167 DEBUG ((EFI_D_VERBOSE
, "\n"));
174 This function get filter structure by SMBIOS type.
176 @param Type SMBIOS type
179 SMBIOS_FILTER_STRUCT
*
180 GetFilterStructByType (
185 for (Index
= 0; Index
< sizeof(mSmbiosFilterStandardTableBlackList
)/sizeof(mSmbiosFilterStandardTableBlackList
[0]); Index
++) {
186 if (mSmbiosFilterStandardTableBlackList
[Index
].Type
== Type
) {
187 return &mSmbiosFilterStandardTableBlackList
[Index
];
195 This function get SMBIOS string in SMBIOS table.
197 @param Head SMBIOS table head
198 @param StringId SMBIOS string ID
199 @param StringLen length of SMBIOS string
201 @return SMBIOS string data
204 GetSmbiosStringById (
205 IN EFI_SMBIOS_TABLE_HEADER
*Head
,
206 IN SMBIOS_TABLE_STRING StringId
,
216 CharInStr
= (CHAR8
*)Head
+ Head
->Length
;
221 // look for the two consecutive zeros, check the string limit by the way.
224 while (*CharInStr
!= 0 || *(CharInStr
+1) != 0) {
225 if (*CharInStr
== 0) {
231 for (StrLen
= 0 ; StrLen
< mMaxLen
; StrLen
++) {
232 if (*(CharInStr
+StrLen
) == 0) {
238 if (StrLen
== mMaxLen
) {
243 // forward the pointer
248 if (StringsNumber
== StringId
) {
258 This function update SMBIOS table based on policy.
260 @param TableEntry SMBIOS table
261 @param TableEntrySize SMBIOS table size
266 IN OUT VOID
*TableEntry
,
267 IN UINTN TableEntrySize
270 SMBIOS_FILTER_STRUCT
*FilterStruct
;
271 SMBIOS_FILTER_TABLE
*Filter
;
273 SMBIOS_TABLE_STRING StringId
;
277 DEBUG ((EFI_D_INFO
, "Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE
*)TableEntry
)->Type
));
278 DEBUG_CODE (InternalDumpHex (TableEntry
, TableEntrySize
););
281 // Skip measurement for OEM types.
283 if (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
>= SMBIOS_OEM_BEGIN
) {
284 // zero all table fields, except header
285 ZeroMem ((UINT8
*)TableEntry
+ sizeof(SMBIOS_STRUCTURE
), TableEntrySize
- sizeof(SMBIOS_STRUCTURE
));
287 FilterStruct
= GetFilterStructByType (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
);
288 if (FilterStruct
!= NULL
) {
289 if (FilterStruct
->Filter
== NULL
|| FilterStruct
->FilterCount
== 0) {
290 // zero all table fields, except header
291 ZeroMem ((UINT8
*)TableEntry
+ sizeof(SMBIOS_STRUCTURE
), TableEntrySize
- sizeof(SMBIOS_STRUCTURE
));
293 Filter
= FilterStruct
->Filter
;
294 for (Index
= 0; Index
< FilterStruct
->FilterCount
; Index
++) {
295 if (((SMBIOS_STRUCTURE
*) TableEntry
)->Length
>= (Filter
[Index
].Offset
+ Filter
[Index
].Size
)) {
297 // The field is present in the SMBIOS entry.
299 if ((Filter
[Index
].Flags
& SMBIOS_FILTER_TABLE_FLAG_IS_STRING
) != 0) {
300 CopyMem (&StringId
, (UINT8
*)TableEntry
+ Filter
[Index
].Offset
, sizeof(StringId
));
302 // set ' ' for string field
303 String
= GetSmbiosStringById (TableEntry
, StringId
, &StringLen
);
304 ASSERT (String
!= NULL
);
305 //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
306 SetMem (String
, StringLen
, ' ');
309 // zero non-string field
310 ZeroMem ((UINT8
*)TableEntry
+ Filter
[Index
].Offset
, Filter
[Index
].Size
);
317 DEBUG ((EFI_D_INFO
, "Filter Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE
*)TableEntry
)->Type
));
318 DEBUG_CODE (InternalDumpHex (TableEntry
, TableEntrySize
););
323 Get the full size of SMBIOS structure including optional strings that follow the formatted structure.
325 @param Head Pointer to the beginning of SMBIOS structure.
326 @param NumberOfStrings The returned number of optional strings that follow the formatted structure.
328 @return Size The returned size.
331 GetSmbiosStructureSize (
332 IN EFI_SMBIOS_TABLE_HEADER
*Head
,
333 OUT UINTN
*NumberOfStrings
341 CharInStr
= (CHAR8
*)Head
+ Head
->Length
;
346 // look for the two consecutive zeros, check the string limit by the way.
348 while (*CharInStr
!= 0 || *(CharInStr
+1) != 0) {
349 if (*CharInStr
== 0) {
354 for (StrLen
= 0 ; StrLen
< mMaxLen
; StrLen
++) {
355 if (*(CharInStr
+StrLen
) == 0) {
360 if (StrLen
== mMaxLen
) {
365 // forward the pointer
373 // count ending two zeros.
377 if (NumberOfStrings
!= NULL
) {
378 *NumberOfStrings
= StringsNumber
;
385 This function returns full SMBIOS table length.
387 @param TableAddress SMBIOS table based address
388 @param TableMaximumSize Maximum size of SMBIOS table
390 @return SMBIOS table length
394 GetSmbiosTableLength (
395 IN VOID
*TableAddress
,
396 IN UINTN TableMaximumSize
400 VOID
*TableAddressEnd
;
401 UINTN TableEntryLength
;
403 TableAddressEnd
= (VOID
*)((UINTN
)TableAddress
+ TableMaximumSize
);
404 TableEntry
= TableAddress
;
405 while (TableEntry
< TableAddressEnd
) {
406 TableEntryLength
= GetSmbiosStructureSize (TableEntry
, NULL
);
407 if (TableEntryLength
== 0) {
410 if (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
== 127) {
411 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
414 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
417 return ((UINTN
)TableEntry
- (UINTN
)TableAddress
);
422 This function updatess full SMBIOS table length.
424 @param TableAddress SMBIOS table based address
425 @param TableLength SMBIOS table length
430 IN OUT VOID
*TableAddress
,
434 VOID
*TableAddressEnd
;
436 UINTN TableEntryLength
;
438 TableEntry
= TableAddress
;
439 TableAddressEnd
= (VOID
*)((UINTN
)TableAddress
+ TableLength
);
440 while ((UINTN
)TableEntry
< (UINTN
)TableAddressEnd
) {
441 TableEntryLength
= GetSmbiosStructureSize (TableEntry
, NULL
);
442 if (TableEntryLength
== 0) {
446 FilterSmbiosEntry (TableEntry
, TableEntryLength
);
448 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
453 Measure SMBIOS with EV_EFI_HANDOFF_TABLES to PCR[1].
455 @param[in] Event Event whose notification function is being invoked.
456 @param[in] Context Pointer to the notification function's context.
467 EFI_HANDOFF_TABLE_POINTERS HandoffTables
;
468 SMBIOS_TABLE_ENTRY_POINT
*SmbiosTable
;
469 SMBIOS_TABLE_3_0_ENTRY_POINT
*Smbios3Table
;
470 VOID
*SmbiosTableAddress
;
476 SmbiosTableAddress
= NULL
;
479 if (mSmbios
->MajorVersion
>= 3) {
480 Status
= EfiGetSystemConfigurationTable (
481 &gEfiSmbios3TableGuid
,
482 (VOID
**) &Smbios3Table
484 if (!EFI_ERROR (Status
)) {
485 DEBUG ((EFI_D_INFO
, "Smbios3Table:\n"));
486 DEBUG ((EFI_D_INFO
, " AnchorString - '%c%c%c%c%c'\n",
487 Smbios3Table
->AnchorString
[0],
488 Smbios3Table
->AnchorString
[1],
489 Smbios3Table
->AnchorString
[2],
490 Smbios3Table
->AnchorString
[3],
491 Smbios3Table
->AnchorString
[4]
493 DEBUG ((EFI_D_INFO
, " EntryPointStructureChecksum - 0x%02x\n", Smbios3Table
->EntryPointStructureChecksum
));
494 DEBUG ((EFI_D_INFO
, " EntryPointLength - 0x%02x\n", Smbios3Table
->EntryPointLength
));
495 DEBUG ((EFI_D_INFO
, " MajorVersion - 0x%02x\n", Smbios3Table
->MajorVersion
));
496 DEBUG ((EFI_D_INFO
, " MinorVersion - 0x%02x\n", Smbios3Table
->MinorVersion
));
497 DEBUG ((EFI_D_INFO
, " DocRev - 0x%02x\n", Smbios3Table
->DocRev
));
498 DEBUG ((EFI_D_INFO
, " EntryPointRevision - 0x%02x\n", Smbios3Table
->EntryPointRevision
));
499 DEBUG ((EFI_D_INFO
, " TableMaximumSize - 0x%08x\n", Smbios3Table
->TableMaximumSize
));
500 DEBUG ((EFI_D_INFO
, " TableAddress - 0x%016lx\n", Smbios3Table
->TableAddress
));
504 if (Smbios3Table
== NULL
) {
505 Status
= EfiGetSystemConfigurationTable (
506 &gEfiSmbiosTableGuid
,
507 (VOID
**) &SmbiosTable
509 if (!EFI_ERROR (Status
)) {
510 DEBUG ((EFI_D_INFO
, "SmbiosTable:\n"));
511 DEBUG ((EFI_D_INFO
, " AnchorString - '%c%c%c%c'\n",
512 SmbiosTable
->AnchorString
[0],
513 SmbiosTable
->AnchorString
[1],
514 SmbiosTable
->AnchorString
[2],
515 SmbiosTable
->AnchorString
[3]
517 DEBUG ((EFI_D_INFO
, " EntryPointStructureChecksum - 0x%02x\n", SmbiosTable
->EntryPointStructureChecksum
));
518 DEBUG ((EFI_D_INFO
, " EntryPointLength - 0x%02x\n", SmbiosTable
->EntryPointLength
));
519 DEBUG ((EFI_D_INFO
, " MajorVersion - 0x%02x\n", SmbiosTable
->MajorVersion
));
520 DEBUG ((EFI_D_INFO
, " MinorVersion - 0x%02x\n", SmbiosTable
->MinorVersion
));
521 DEBUG ((EFI_D_INFO
, " MaxStructureSize - 0x%08x\n", SmbiosTable
->MaxStructureSize
));
522 DEBUG ((EFI_D_INFO
, " EntryPointRevision - 0x%02x\n", SmbiosTable
->EntryPointRevision
));
523 DEBUG ((EFI_D_INFO
, " FormattedArea - '%c%c%c%c%c'\n",
524 SmbiosTable
->FormattedArea
[0],
525 SmbiosTable
->FormattedArea
[1],
526 SmbiosTable
->FormattedArea
[2],
527 SmbiosTable
->FormattedArea
[3],
528 SmbiosTable
->FormattedArea
[4]
530 DEBUG ((EFI_D_INFO
, " IntermediateAnchorString - '%c%c%c%c%c'\n",
531 SmbiosTable
->IntermediateAnchorString
[0],
532 SmbiosTable
->IntermediateAnchorString
[1],
533 SmbiosTable
->IntermediateAnchorString
[2],
534 SmbiosTable
->IntermediateAnchorString
[3],
535 SmbiosTable
->IntermediateAnchorString
[4]
537 DEBUG ((EFI_D_INFO
, " IntermediateChecksum - 0x%02x\n", SmbiosTable
->IntermediateChecksum
));
538 DEBUG ((EFI_D_INFO
, " TableLength - 0x%04x\n", SmbiosTable
->TableLength
));
539 DEBUG ((EFI_D_INFO
, " TableAddress - 0x%08x\n", SmbiosTable
->TableAddress
));
540 DEBUG ((EFI_D_INFO
, " NumberOfSmbiosStructures - 0x%04x\n", SmbiosTable
->NumberOfSmbiosStructures
));
541 DEBUG ((EFI_D_INFO
, " SmbiosBcdRevision - 0x%02x\n", SmbiosTable
->SmbiosBcdRevision
));
545 if (Smbios3Table
!= NULL
) {
546 SmbiosTableAddress
= (VOID
*)(UINTN
)Smbios3Table
->TableAddress
;
547 TableLength
= GetSmbiosTableLength (SmbiosTableAddress
, Smbios3Table
->TableMaximumSize
);
548 } else if (SmbiosTable
!= NULL
) {
549 SmbiosTableAddress
= (VOID
*)(UINTN
)SmbiosTable
->TableAddress
;
550 TableLength
= SmbiosTable
->TableLength
;
553 if (SmbiosTableAddress
!= NULL
) {
554 DEBUG ((DEBUG_INFO
, "The Smbios Table starts at: 0x%x\n", SmbiosTableAddress
));
555 DEBUG ((DEBUG_INFO
, "The Smbios Table size: 0x%x\n", TableLength
));
556 DEBUG_CODE (InternalDumpHex ((UINT8
*)(UINTN
)SmbiosTableAddress
, TableLength
););
558 TableAddress
= AllocateCopyPool ((UINTN
)TableLength
, (VOID
*)(UINTN
)SmbiosTableAddress
);
559 if (TableAddress
== NULL
) {
563 FilterSmbiosTable (TableAddress
, TableLength
);
565 DEBUG ((DEBUG_INFO
, "The final Smbios Table starts at: 0x%x\n", TableAddress
));
566 DEBUG ((DEBUG_INFO
, "The final Smbios Table size: 0x%x\n", TableLength
));
567 DEBUG_CODE (InternalDumpHex (TableAddress
, TableLength
););
569 HandoffTables
.NumberOfTables
= 1;
570 if (Smbios3Table
!= NULL
) {
571 CopyGuid (&(HandoffTables
.TableEntry
[0].VendorGuid
), &gEfiSmbios3TableGuid
);
572 HandoffTables
.TableEntry
[0].VendorTable
= Smbios3Table
;
574 CopyGuid (&(HandoffTables
.TableEntry
[0].VendorGuid
), &gEfiSmbiosTableGuid
);
575 HandoffTables
.TableEntry
[0].VendorTable
= SmbiosTable
;
577 Status
= TpmMeasureAndLogData (
579 EV_EFI_HANDOFF_TABLES
, // EventType
580 &HandoffTables
, // EventLog
581 sizeof (HandoffTables
), // LogLen
582 TableAddress
, // HashData
583 TableLength
// HashDataLen
585 if (EFI_ERROR (Status
)) {
595 Driver to produce Smbios measurement.
597 @param ImageHandle Module's image handle
598 @param SystemTable Pointer of EFI_SYSTEM_TABLE
600 @return Status returned from EfiCreateEventReadyToBootEx().
605 SmbiosMeasurementDriverEntryPoint (
606 IN EFI_HANDLE ImageHandle
,
607 IN EFI_SYSTEM_TABLE
*SystemTable
613 Status
= gBS
->LocateProtocol (&gEfiSmbiosProtocolGuid
, NULL
, (VOID
**) &mSmbios
);
614 ASSERT_EFI_ERROR (Status
);
615 DEBUG ((DEBUG_INFO
, "The Smbios Table Version: %x.%x\n", mSmbios
->MajorVersion
, mSmbios
->MinorVersion
));
617 if (mSmbios
->MajorVersion
< 2 || (mSmbios
->MajorVersion
== 2 && mSmbios
->MinorVersion
< 7)){
618 mMaxLen
= SMBIOS_STRING_MAX_LENGTH
;
619 } else if (mSmbios
->MajorVersion
< 3) {
621 // Reference SMBIOS 2.7, chapter 6.1.3, it will have no limit on the length of each individual text string.
622 // However, the length of the entire structure table (including all strings) must be reported
623 // in the Structure Table Length field of the SMBIOS Structure Table Entry Point,
624 // which is a WORD field limited to 65,535 bytes.
626 mMaxLen
= SMBIOS_TABLE_MAX_LENGTH
;
629 // SMBIOS 3.0 defines the Structure table maximum size as DWORD field limited to 0xFFFFFFFF bytes.
630 // Locate the end of string as long as possible.
632 mMaxLen
= SMBIOS_3_0_TABLE_MAX_LENGTH
;
636 // Measure Smbios tables
638 Status
= EfiCreateEventReadyToBootEx (