#include <Protocol/DevicePath.h>\r
#include <Protocol/TcgService.h>\r
#include <Protocol/AcpiTable.h>\r
+#include <Protocol/MpService.h>\r
\r
#include <Library/DebugLib.h>\r
#include <Library/BaseMemoryLib.h>\r
UINTN mBootAttempts = 0;\r
CHAR16 mBootVarName[] = L"BootOrder";\r
\r
+/**\r
+ Get All processors EFI_CPU_LOCATION in system. LocationBuf is allocated inside the function\r
+ Caller is responsible to free LocationBuf.\r
+\r
+ @param[out] LocationBuf Returns Processor Location Buffer.\r
+ @param[out] Num Returns processor number.\r
+\r
+ @retval EFI_SUCCESS Operation completed successfully.\r
+ @retval EFI_UNSUPPORTED MpService protocol not found.\r
+\r
+**/\r
+EFI_STATUS\r
+GetProcessorsCpuLocation (\r
+ OUT EFI_CPU_PHYSICAL_LOCATION **LocationBuf,\r
+ OUT UINTN *Num\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_MP_SERVICES_PROTOCOL *MpProtocol;\r
+ UINTN ProcessorNum;\r
+ UINTN EnabledProcessorNum;\r
+ EFI_PROCESSOR_INFORMATION ProcessorInfo;\r
+ EFI_CPU_PHYSICAL_LOCATION *ProcessorLocBuf;\r
+ UINTN Index;\r
+\r
+ Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **) &MpProtocol);\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // MP protocol is not installed\r
+ //\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Status = MpProtocol->GetNumberOfProcessors(\r
+ MpProtocol,\r
+ &ProcessorNum,\r
+ &EnabledProcessorNum\r
+ );\r
+ if (EFI_ERROR(Status)){\r
+ return Status;\r
+ }\r
+\r
+ Status = gBS->AllocatePool(\r
+ EfiBootServicesData,\r
+ sizeof(EFI_CPU_PHYSICAL_LOCATION) * ProcessorNum,\r
+ &ProcessorLocBuf\r
+ );\r
+ if (EFI_ERROR(Status)){\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Get each processor Location info\r
+ //\r
+ for (Index = 0; Index < ProcessorNum; Index++) {\r
+ Status = MpProtocol->GetProcessorInfo(\r
+ MpProtocol,\r
+ Index,\r
+ &ProcessorInfo\r
+ );\r
+ if (EFI_ERROR(Status)){\r
+ FreePool(ProcessorLocBuf);\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Get all Processor Location info & measure\r
+ //\r
+ CopyMem(\r
+ &ProcessorLocBuf[Index],\r
+ &ProcessorInfo.Location,\r
+ sizeof(EFI_CPU_PHYSICAL_LOCATION)\r
+ );\r
+ }\r
+\r
+ *LocationBuf = ProcessorLocBuf;\r
+ *Num = ProcessorNum;\r
+\r
+ return Status;\r
+}\r
+\r
/**\r
This service provides EFI protocol capability information, state information \r
about the TPM, and Event Log state information.\r
SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;\r
TCG_PCR_EVENT_HDR TcgEvent;\r
EFI_HANDOFF_TABLE_POINTERS HandoffTables;\r
+ UINTN ProcessorNum;\r
+ EFI_CPU_PHYSICAL_LOCATION *ProcessorLocBuf;\r
\r
+ //\r
+ // Measure SMBIOS with EV_EFI_HANDOFF_TABLES to PCR[1]\r
+ //\r
Status = EfiGetSystemConfigurationTable (\r
&gEfiSmbiosTableGuid,\r
(VOID **) &SmbiosTable\r
);\r
}\r
\r
+ if (PcdGet8 (PcdTpmPlatformClass) == TCG_PLATFORM_TYPE_SERVER) {\r
+ //\r
+ // Tcg Server spec. \r
+ // Measure each processor EFI_CPU_PHYSICAL_LOCATION with EV_TABLE_OF_DEVICES to PCR[1]\r
+ //\r
+ Status = GetProcessorsCpuLocation(&ProcessorLocBuf, &ProcessorNum);\r
+\r
+ if (!EFI_ERROR(Status)){\r
+ TcgEvent.PCRIndex = 1;\r
+ TcgEvent.EventType = EV_TABLE_OF_DEVICES;\r
+ TcgEvent.EventSize = sizeof (HandoffTables);\r
+\r
+ HandoffTables.NumberOfTables = 1;\r
+ HandoffTables.TableEntry[0].VendorGuid = gEfiMpServiceProtocolGuid;\r
+ HandoffTables.TableEntry[0].VendorTable = ProcessorLocBuf;\r
+\r
+ Status = TcgDxeHashLogExtendEventI (\r
+ &mTcgDxeData,\r
+ (UINT8*)(UINTN)ProcessorLocBuf,\r
+ sizeof(EFI_CPU_PHYSICAL_LOCATION) * ProcessorNum,\r
+ &TcgEvent,\r
+ (UINT8*)&HandoffTables\r
+ );\r
+\r
+ FreePool(ProcessorLocBuf);\r
+ }\r
+ }\r
+\r
return Status;\r
}\r
\r