summaryrefslogtreecommitdiff
path: root/Platform/Intel/MinPlatformPkg/Test
diff options
context:
space:
mode:
Diffstat (limited to 'Platform/Intel/MinPlatformPkg/Test')
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpi.c340
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiDmar.c210
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiHpet.c52
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMadt.c241
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMcfg.c63
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiWsmt.c45
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpBootVariable.c195
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpConsoleVariable.c69
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpDevicePath.c78
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpEsrt.c120
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpGcd.c230
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpHsti.c123
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpLoadedImage.c203
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemAttribute.c89
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemMap.c219
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemoryTypeInformation.c158
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpPci.c384
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpSmmInfo.c80
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpVariable.c173
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c335
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf86
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpFvInfo.c118
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpHob.c377
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpMtrr.c77
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpSmramHob.c95
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.c204
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.inf58
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecDumpCpuInfo.c39
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.c40
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf37
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpLoadedImage.c111
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpMemAttribute.c86
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpSmrr.c125
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c172
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf59
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c133
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.inf32
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.c611
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.h61
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPointAip.c175
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPointLib.inf48
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.c541
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.h44
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPointLib.inf44
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.c634
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.h71
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointAip.c175
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointCommunication.c379
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointLib.inf50
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDump.c412
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDumpApp.inf49
51 files changed, 8550 insertions, 0 deletions
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpi.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpi.c
new file mode 100644
index 0000000000..c5c79ac40d
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpi.c
@@ -0,0 +1,340 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h>
+#include <IndustryStandard/HighPrecisionEventTimerTable.h>
+#include <IndustryStandard/DmaRemappingReportingTable.h>
+#include <IndustryStandard/WindowsSmmSecurityMitigationTable.h>
+#include <Guid/Acpi.h>
+
+BOOLEAN mDmarFound = FALSE;
+BOOLEAN mWsmtFound = FALSE;
+
+EFI_STATUS
+DumpAcpiMadt (
+ IN EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *Madt
+ );
+
+EFI_STATUS
+DumpAcpiMcfg (
+ IN EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER *Mcfg
+ );
+
+EFI_STATUS
+DumpAcpiHpet (
+ IN EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_HEADER *Hpet
+ );
+
+EFI_STATUS
+DumpAcpiDmar (
+ IN EFI_ACPI_DMAR_HEADER *Dmar
+ );
+
+EFI_STATUS
+DumpAcpiWsmt (
+ IN EFI_ACPI_WSMT_TABLE *Wsmt
+ );
+
+VOID
+DumpCharArray (
+ IN CHAR8 *Ch,
+ IN UINTN Size
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < Size; Index++) {
+ DEBUG ((DEBUG_INFO, "%c", Ch[Index]));
+ }
+}
+
+VOID
+DumpAcpiTableHeader (
+ IN EFI_ACPI_DESCRIPTION_HEADER *Table
+ )
+{
+ DEBUG ((DEBUG_INFO, " "));
+ DumpCharArray ((CHAR8 *)&Table->Signature, sizeof(Table->Signature));
+ DEBUG ((DEBUG_INFO, " : (0x%016lx) 0x%02x \'", Table, Table->Revision));
+ DumpCharArray (Table->OemId, sizeof(Table->OemId));
+ DEBUG ((DEBUG_INFO, "\' \'"));
+ DumpCharArray ((CHAR8 *)&Table->OemTableId, sizeof(Table->OemTableId));
+ DEBUG ((DEBUG_INFO, "\' 0x%08x \'", Table->OemRevision));
+ DumpCharArray ((CHAR8 *)&Table->CreatorId, sizeof(Table->CreatorId));
+ DEBUG ((DEBUG_INFO, "\' 0x%08x |\n", Table->CreatorRevision));
+}
+
+EFI_STATUS
+DumpAcpiFadt (
+ IN EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt
+ )
+{
+ DumpAcpiTableHeader (&Fadt->Header);
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " SCI=0x%04x", Fadt->SciInt));
+ DEBUG ((DEBUG_INFO, " SMI=0x%08x", Fadt->SmiCmd));
+ DEBUG ((DEBUG_INFO, " AcpiEnable=0x%02x", Fadt->AcpiEnable));
+ DEBUG ((DEBUG_INFO, " AcpiDisable=0x%02x", Fadt->AcpiDisable));
+ DEBUG ((DEBUG_INFO, "\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+DumpAcpiFacs (
+ IN EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs
+ )
+{
+ DEBUG ((DEBUG_INFO, " "));
+ DumpCharArray ((CHAR8 *)&Facs->Signature, sizeof(Facs->Signature));
+ DEBUG ((DEBUG_INFO, " : (0x%016lx) 0x%02x\n", Facs, Facs->Version));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " HardwareSignature=%08x\n", Facs->HardwareSignature));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+DumpAcpiTable (
+ IN EFI_ACPI_DESCRIPTION_HEADER *Table
+ )
+{
+ EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
+ EFI_STATUS Status;
+
+ if (Table == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ switch (Table->Signature) {
+ case EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE:
+ Fadt = (EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE *)Table;
+ Status = DumpAcpiFadt (Fadt);
+ if (Fadt->Header.Revision >= EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION) {
+ if (Fadt->XFirmwareCtrl != 0) {
+ DumpAcpiFacs ((EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)Fadt->XFirmwareCtrl);
+ } else {
+ DumpAcpiFacs ((EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)Fadt->FirmwareCtrl);
+ }
+ if (Fadt->XDsdt != 0) {
+ DumpAcpiTable ((EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Fadt->XDsdt);
+ } else {
+ DumpAcpiTable ((EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Fadt->Dsdt);
+ }
+ } else {
+ DumpAcpiFacs ((EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)Fadt->FirmwareCtrl);
+ DumpAcpiTable ((EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Fadt->Dsdt);
+ }
+ return Status;
+ case EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE:
+ Status = DumpAcpiMadt ((EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *)Table);
+ return Status;
+ case EFI_ACPI_2_0_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_SIGNATURE:
+ Status = DumpAcpiMcfg ((EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER *)Table);
+ return Status;
+ case EFI_ACPI_3_0_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE:
+ Status = DumpAcpiHpet ((EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_HEADER *)Table);
+ return Status;
+ case EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE:
+ Status = DumpAcpiDmar ((EFI_ACPI_DMAR_HEADER *)Table);
+ mDmarFound = TRUE;
+ return Status;
+ case EFI_ACPI_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE:
+ Status = DumpAcpiWsmt ((EFI_ACPI_WSMT_TABLE *)Table);
+ mWsmtFound = TRUE;
+ return Status;
+ default:
+ break;
+ }
+ DumpAcpiTableHeader (Table);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+DumpAcpiRsdt (
+ IN EFI_ACPI_DESCRIPTION_HEADER *Rsdt
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINT32 EntryCount;
+ UINT32 *EntryPtr;
+ EFI_ACPI_DESCRIPTION_HEADER *Table;
+ BOOLEAN Result;
+
+ if (Rsdt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ EntryCount = (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32);
+ EntryPtr = (UINT32 *)(Rsdt + 1);
+ Result = TRUE;
+ for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {
+ Table = (EFI_ACPI_DESCRIPTION_HEADER *)((UINTN)(*EntryPtr));
+ Status = DumpAcpiTable (Table);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ }
+ if (!Result) {
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+DumpAcpiXsdt (
+ IN EFI_ACPI_DESCRIPTION_HEADER *Xsdt
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINT32 EntryCount;
+ UINT64 EntryPtr;
+ UINTN BasePtr;
+ EFI_ACPI_DESCRIPTION_HEADER *Table;
+ BOOLEAN Result;
+
+ if (Xsdt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT64);
+
+ BasePtr = (UINTN)(Xsdt + 1);
+ Result = TRUE;
+ for (Index = 0; Index < EntryCount; Index ++) {
+ CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), sizeof(UINT64));
+ Table = (EFI_ACPI_DESCRIPTION_HEADER *)((UINTN)(EntryPtr));
+ Status = DumpAcpiTable (Table);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ }
+ if (!Result) {
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+DumpAcpiRsdp (
+ IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp
+ )
+{
+ EFI_STATUS Status;
+ EFI_ACPI_DESCRIPTION_HEADER *Rsdt;
+ EFI_ACPI_DESCRIPTION_HEADER *Xsdt;
+
+ DumpCharArray ((CHAR8 *)&Rsdp->Signature, sizeof(Rsdp->Signature));
+ DEBUG ((DEBUG_INFO, ": (0x%016lx) 0x%02x \'", Rsdp, Rsdp->Revision));
+ DumpCharArray (Rsdp->OemId, sizeof(Rsdp->OemId));
+ DEBUG ((DEBUG_INFO, "\'\n"));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " RSDT=0x%08x XSDT=0x%016lx\n", Rsdp->RsdtAddress, Rsdp->XsdtAddress));
+
+ if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) {
+ DumpAcpiTable ((EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->XsdtAddress);
+ }
+ DumpAcpiTable ((EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->RsdtAddress);
+
+ //
+ // Search XSDT
+ //
+ if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) {
+ Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN) Rsdp->XsdtAddress;
+ Status = DumpAcpiXsdt (Xsdt);
+ } else {
+ //
+ // Search RSDT
+ //
+ Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN) Rsdp->RsdtAddress;
+ Status = DumpAcpiRsdt (Rsdt);
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+DumpAcpiWithGuid (
+ IN EFI_GUID *AcpiTableGuid
+ )
+{
+ VOID *Rsdp;
+ EFI_STATUS Status;
+
+ Status = EfiGetSystemConfigurationTable (AcpiTableGuid, &Rsdp);
+ if (EFI_ERROR(Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ Status = DumpAcpiRsdp (Rsdp);
+
+ return Status;
+}
+
+EFI_STATUS
+TestPointDumpAcpi (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpAcpi - Enter\n"));
+
+ DEBUG ((DEBUG_INFO, "AcpiTable :\n"));
+ DEBUG ((DEBUG_INFO, " Table Address Rev OemId OemTableId OemRev Creat CreatorRev\n"));
+ Status = DumpAcpiWithGuid (&gEfiAcpi20TableGuid);
+ if (Status == EFI_NOT_FOUND) {
+ Status = DumpAcpiWithGuid (&gEfiAcpi10TableGuid);
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpAcpi - Exit\n"));
+
+ if (EFI_ERROR(Status)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_5 TEST_POINT_READY_TO_BOOT TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_5
+ );
+ }
+
+ if (!mWsmtFound) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_6 TEST_POINT_READY_TO_BOOT TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_6
+ );
+ Status = EFI_INVALID_PARAMETER;
+ }
+ if (!mDmarFound) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_7 TEST_POINT_READY_TO_BOOT TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_7
+ );
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ if (!mDmarFound) {
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiDmar.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiDmar.c
new file mode 100644
index 0000000000..7277389a23
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiDmar.c
@@ -0,0 +1,210 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/DmaRemappingReportingTable.h>
+
+VOID
+DumpCharArray (
+ IN CHAR8 *Ch,
+ IN UINTN Size
+ );
+
+VOID
+DumpAcpiTableHeader (
+ IN EFI_ACPI_DESCRIPTION_HEADER *Table
+ );
+
+CHAR8 *mDmarTypeString[] = {
+ "DRHD ",
+ "RMRR ",
+ "ATSR ",
+ "RHSA ",
+ "ANDD ",
+};
+
+CHAR8 mUnknownStr[11];
+
+CHAR8 *
+ShortNameOfDmarType(
+ IN UINT16 Type
+ )
+{
+ if (Type < sizeof(mDmarTypeString) / sizeof(mDmarTypeString[0])) {
+ return mDmarTypeString[Type];
+ } else {
+ AsciiSPrint(mUnknownStr, sizeof(mUnknownStr), "[%04x]", Type);
+ return mUnknownStr;
+ }
+}
+
+CHAR8 *mDmarDeviceTypeString[] = {
+ "[00]",
+ "PCI",
+ "P2P",
+ "IOAPIC",
+ "HPET",
+ "ACPI",
+};
+
+CHAR8 *
+ShortNameOfDmarDeviceType(
+ IN UINT8 Type
+ )
+{
+ if (Type < sizeof(mDmarDeviceTypeString) / sizeof(mDmarDeviceTypeString[0])) {
+ return mDmarDeviceTypeString[Type];
+ } else {
+ AsciiSPrint(mUnknownStr, sizeof(mUnknownStr), "[%02x]", Type);
+ return mUnknownStr;
+ }
+}
+
+VOID
+DumpDmarDeviceScope (
+ IN EFI_ACPI_DMAR_DEVICE_SCOPE_STRUCTURE_HEADER *DmarDeviceScope,
+ IN UINTN Size
+ )
+{
+ EFI_ACPI_DMAR_DEVICE_SCOPE_STRUCTURE_HEADER *Device;
+ EFI_ACPI_DMAR_PCI_PATH *PciPathScope;
+ EFI_ACPI_DMAR_PCI_PATH *PciPath;
+ UINTN PciPathSize;
+
+ Device = DmarDeviceScope;
+ while ((UINTN)Device < (UINTN)DmarDeviceScope + Size) {
+ DEBUG ((DEBUG_INFO, " ("));
+ DEBUG ((DEBUG_INFO, ShortNameOfDmarDeviceType(Device->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", Device->Type));
+ DEBUG ((DEBUG_INFO, " EnumId=0x%02x", Device->EnumerationId));
+ DEBUG ((DEBUG_INFO, " Bus=0x%02x", Device->StartBusNumber));
+
+ PciPathScope = (EFI_ACPI_DMAR_PCI_PATH *)(DmarDeviceScope + 1);
+ PciPathSize = Device->Length - sizeof(EFI_ACPI_DMAR_DEVICE_SCOPE_STRUCTURE_HEADER);
+ PciPath = PciPathScope;
+ while ((UINTN)PciPath < (UINTN)PciPathScope + PciPathSize) {
+ DEBUG ((DEBUG_INFO, " Pci=0x%02x/0x%02x", PciPath->Device, PciPath->Function));
+ PciPath ++;
+ }
+
+ DEBUG ((DEBUG_INFO, ")"));
+ Device = (EFI_ACPI_DMAR_DEVICE_SCOPE_STRUCTURE_HEADER *)((UINTN)Device + Device->Length);
+ }
+}
+
+EFI_STATUS
+DumpAcpiDmar (
+ IN EFI_ACPI_DMAR_HEADER *Dmar
+ )
+{
+ EFI_ACPI_DMAR_STRUCTURE_HEADER *DmarStructHeader;
+ INTN DmarLen;
+ EFI_ACPI_DMAR_DRHD_HEADER *Drhd;
+ EFI_ACPI_DMAR_RMRR_HEADER *Rmrr;
+ EFI_ACPI_DMAR_ATSR_HEADER *Atsr;
+ EFI_ACPI_DMAR_RHSA_HEADER *Rhsa;
+ EFI_ACPI_DMAR_ANDD_HEADER *Andd;
+
+ DumpAcpiTableHeader (&Dmar->Header);
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " HostAddressWidth=0x%02x Flags=0x%02x\n", Dmar->HostAddressWidth, Dmar->Flags));
+
+ //
+ // Sub table
+ //
+ DmarLen = Dmar->Header.Length - sizeof(EFI_ACPI_DMAR_HEADER);
+ DmarStructHeader = (EFI_ACPI_DMAR_STRUCTURE_HEADER *)(Dmar + 1);
+ while (DmarLen > 0) {
+ switch (DmarStructHeader->Type) {
+ case EFI_ACPI_DMAR_TYPE_DRHD:
+ Drhd = (EFI_ACPI_DMAR_DRHD_HEADER *)DmarStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfDmarType(DmarStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%04x]", DmarStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " Flags=0x%02x", Drhd->Flags));
+ DEBUG ((DEBUG_INFO, " Segment=0x%04x", Drhd->SegmentNumber));
+ DEBUG ((DEBUG_INFO, " Register=0x%016lx", Drhd->RegisterBaseAddress));
+ if ((Drhd->Flags & EFI_ACPI_DMAR_DRHD_FLAGS_INCLUDE_PCI_ALL) != 0) {
+ DEBUG ((DEBUG_INFO, " (INCLUDE_PCI_ALL)"));
+ } else {
+ DumpDmarDeviceScope ((EFI_ACPI_DMAR_DEVICE_SCOPE_STRUCTURE_HEADER *)(Drhd + 1), Drhd->Header.Length - sizeof(EFI_ACPI_DMAR_DRHD_HEADER));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_DMAR_TYPE_RMRR:
+ Rmrr = (EFI_ACPI_DMAR_RMRR_HEADER *)DmarStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfDmarType(DmarStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%04x]", DmarStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " Segment=0x%04x", Rmrr->SegmentNumber));
+ DEBUG ((DEBUG_INFO, " Reserved=(0x%016lx-0x%016lx)", Rmrr->ReservedMemoryRegionBaseAddress, Rmrr->ReservedMemoryRegionLimitAddress));
+ DumpDmarDeviceScope ((EFI_ACPI_DMAR_DEVICE_SCOPE_STRUCTURE_HEADER *)(Rmrr + 1), Rmrr->Header.Length - sizeof(EFI_ACPI_DMAR_RMRR_HEADER));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_DMAR_TYPE_ATSR:
+ Atsr = (EFI_ACPI_DMAR_ATSR_HEADER *)DmarStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfDmarType(DmarStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%04x]", DmarStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " Flags=0x%02x", Atsr->Flags));
+ DEBUG ((DEBUG_INFO, " Segment=0x%04x", Atsr->SegmentNumber));
+ if ((Atsr->Flags & EFI_ACPI_DMAR_ATSR_FLAGS_ALL_PORTS) != 0) {
+ DEBUG ((DEBUG_INFO, " (ALL_PORTS)"));
+ } else {
+ DumpDmarDeviceScope ((EFI_ACPI_DMAR_DEVICE_SCOPE_STRUCTURE_HEADER *)(Atsr + 1), Atsr->Header.Length - sizeof(EFI_ACPI_DMAR_ATSR_HEADER));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_DMAR_TYPE_RHSA:
+ Rhsa = (EFI_ACPI_DMAR_RHSA_HEADER *)DmarStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfDmarType(DmarStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%04x]", DmarStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " Register=0x%016lx", Rhsa->RegisterBaseAddress));
+ DEBUG ((DEBUG_INFO, " ProximityDomain=0x%08x", Rhsa->ProximityDomain));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_DMAR_TYPE_ANDD:
+ Andd = (EFI_ACPI_DMAR_ANDD_HEADER *)DmarStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfDmarType(DmarStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%04x]", DmarStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " DeviceNumber=0x%02x", Andd->AcpiDeviceNumber));
+ DEBUG ((DEBUG_INFO, " ObjectName=%a", Andd + 1));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ default:
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfDmarType(DmarStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ }
+ DmarStructHeader = (EFI_ACPI_DMAR_STRUCTURE_HEADER *)((UINT8 *)DmarStructHeader + DmarStructHeader->Length);
+ DmarLen -= DmarStructHeader->Length;
+ }
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiHpet.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiHpet.c
new file mode 100644
index 0000000000..4eba26ca8f
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiHpet.c
@@ -0,0 +1,52 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/HighPrecisionEventTimerTable.h>
+
+VOID
+DumpCharArray (
+ IN CHAR8 *Ch,
+ IN UINTN Size
+ );
+
+VOID
+DumpAcpiTableHeader (
+ IN EFI_ACPI_DESCRIPTION_HEADER *Table
+ );
+
+EFI_STATUS
+DumpAcpiHpet (
+ IN EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_HEADER *Hpet
+ )
+{
+ DumpAcpiTableHeader (&Hpet->Header);
+
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " Timer :"));
+ DEBUG ((DEBUG_INFO, " BlockId=0x%08x", Hpet->EventTimerBlockId));
+ DEBUG ((DEBUG_INFO, " BaseAddress=0x%016lx", Hpet->BaseAddressLower32Bit.Address));
+ DEBUG ((DEBUG_INFO, " HpetNumber=0x%08x", Hpet->HpetNumber));
+ DEBUG ((DEBUG_INFO, " MinClockTick=0x%04x", Hpet->MainCounterMinimumClockTickInPeriodicMode));
+ DEBUG ((DEBUG_INFO, " PageProtection=0x%02x", Hpet->PageProtectionAndOemAttribute));
+ DEBUG ((DEBUG_INFO, "\n"));
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMadt.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMadt.c
new file mode 100644
index 0000000000..9da138daad
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMadt.c
@@ -0,0 +1,241 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <IndustryStandard/Acpi.h>
+
+VOID
+DumpCharArray (
+ IN CHAR8 *Ch,
+ IN UINTN Size
+ );
+
+VOID
+DumpAcpiTableHeader (
+ IN EFI_ACPI_DESCRIPTION_HEADER *Table
+ );
+
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+} APIC_STRUCT_HEADER;
+
+CHAR8 *mMadtTypeString[] = {
+ "APIC ",
+ "IO_APIC ",
+ "INT_SRC_OR",
+ "NNI_SRC ",
+ "APIC_NMI ",
+ "APIC_OR ",
+ "IO_SAPIC ",
+ "SAPIC ",
+ "PL_INT_SRC",
+ "X2APIC ",
+ "X2APIC_NMI",
+};
+
+CHAR8 mUnknownStr[11];
+
+CHAR8 *
+ShortNameOfMadtType(
+ IN UINT8 Type
+ )
+{
+ if (Type < sizeof(mMadtTypeString) / sizeof(mMadtTypeString[0])) {
+ return mMadtTypeString[Type];
+ } else {
+ AsciiSPrint(mUnknownStr, sizeof(mUnknownStr), "[%02x] ", Type);
+ return mUnknownStr;
+ }
+}
+
+EFI_STATUS
+DumpAcpiMadt (
+ IN EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *Madt
+ )
+{
+ APIC_STRUCT_HEADER *ApicStructHeader;
+ INTN MadtLen;
+ EFI_ACPI_4_0_PROCESSOR_LOCAL_APIC_STRUCTURE *ProcessorLocalApic;
+ EFI_ACPI_4_0_IO_APIC_STRUCTURE *IOApic;
+ EFI_ACPI_4_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE *InterruptSourceOverride;
+ EFI_ACPI_4_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE *NonMaskableInterruptSource;
+ EFI_ACPI_4_0_LOCAL_APIC_NMI_STRUCTURE *LocalApicNMI;
+ EFI_ACPI_4_0_LOCAL_APIC_ADDRESS_OVERRIDE_STRUCTURE *LocalApicAddressOverride;
+ EFI_ACPI_4_0_IO_SAPIC_STRUCTURE *IOSapic;
+ EFI_ACPI_4_0_PROCESSOR_LOCAL_SAPIC_STRUCTURE *ProcessorLocalSapic;
+ EFI_ACPI_4_0_PLATFORM_INTERRUPT_SOURCES_STRUCTURE *PlatformInterruptSource;
+ EFI_ACPI_4_0_PROCESSOR_LOCAL_X2APIC_STRUCTURE *ProcessorLocalX2Apic;
+ EFI_ACPI_4_0_LOCAL_X2APIC_NMI_STRUCTURE *LocalX2ApicNmi;
+
+ DumpAcpiTableHeader (&Madt->Header);
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " LocalApicAddress=0x%08x\n", Madt->LocalApicAddress));
+
+ //
+ // Sub table
+ //
+ MadtLen = Madt->Header.Length - sizeof(EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER);
+ ApicStructHeader = (APIC_STRUCT_HEADER *)(Madt + 1);
+ while (MadtLen > 0) {
+ switch (ApicStructHeader->Type) {
+ case EFI_ACPI_4_0_PROCESSOR_LOCAL_APIC:
+ ProcessorLocalApic = (EFI_ACPI_4_0_PROCESSOR_LOCAL_APIC_STRUCTURE *)ApicStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", ApicStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " ID=0x%02x", ProcessorLocalApic->AcpiProcessorId));
+ DEBUG ((DEBUG_INFO, " ApicId=0x%02x", ProcessorLocalApic->ApicId));
+ if ((ProcessorLocalApic->Flags & EFI_ACPI_4_0_LOCAL_APIC_ENABLED) != 0) {
+ DEBUG ((DEBUG_INFO, " (Enabled)"));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_4_0_IO_APIC:
+ IOApic = (EFI_ACPI_4_0_IO_APIC_STRUCTURE *)ApicStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", ApicStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " IoApicId=0x%02x", IOApic->IoApicId));
+ DEBUG ((DEBUG_INFO, " Address=0x%08x", IOApic->IoApicAddress));
+ DEBUG ((DEBUG_INFO, " InterruptBase=0x%08x", IOApic->GlobalSystemInterruptBase));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_4_0_INTERRUPT_SOURCE_OVERRIDE:
+ InterruptSourceOverride = (EFI_ACPI_4_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE *)ApicStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", ApicStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " Bus=0x%02x", InterruptSourceOverride->Bus));
+ DEBUG ((DEBUG_INFO, " Source=0x%02x", InterruptSourceOverride->Source));
+ DEBUG ((DEBUG_INFO, " Interrupt=0x%08x", InterruptSourceOverride->GlobalSystemInterrupt));
+ DEBUG ((DEBUG_INFO, " Flags=0x%04x", InterruptSourceOverride->Flags));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_4_0_NON_MASKABLE_INTERRUPT_SOURCE:
+ NonMaskableInterruptSource = (EFI_ACPI_4_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE *)ApicStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", ApicStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " Interrupt=0x%08x", NonMaskableInterruptSource->GlobalSystemInterrupt));
+ DEBUG ((DEBUG_INFO, " Flags=0x%04x", NonMaskableInterruptSource->Flags));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_4_0_LOCAL_APIC_NMI:
+ LocalApicNMI = (EFI_ACPI_4_0_LOCAL_APIC_NMI_STRUCTURE *)ApicStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", ApicStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " ID=0x%02x", LocalApicNMI->AcpiProcessorId));
+ DEBUG ((DEBUG_INFO, " Lint=0x%02x", LocalApicNMI->LocalApicLint));
+ DEBUG ((DEBUG_INFO, " Flags=0x%04x", LocalApicNMI->Flags));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_4_0_LOCAL_APIC_ADDRESS_OVERRIDE:
+ LocalApicAddressOverride = (EFI_ACPI_4_0_LOCAL_APIC_ADDRESS_OVERRIDE_STRUCTURE *)ApicStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", ApicStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " LocalApicAddress=0x%016lx", LocalApicAddressOverride->LocalApicAddress));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_4_0_IO_SAPIC:
+ IOSapic = (EFI_ACPI_4_0_IO_SAPIC_STRUCTURE *)ApicStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", ApicStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " IoApicId=0x%02x", IOSapic->IoApicId));
+ DEBUG ((DEBUG_INFO, " InterruptBase=0x%08x", IOSapic->GlobalSystemInterruptBase));
+ DEBUG ((DEBUG_INFO, " IoSapicAddress=0x%016lx", IOSapic->IoSapicAddress));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_4_0_LOCAL_SAPIC:
+ ProcessorLocalSapic = (EFI_ACPI_4_0_PROCESSOR_LOCAL_SAPIC_STRUCTURE *)ApicStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", ApicStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " ID=0x%02x", ProcessorLocalSapic->AcpiProcessorId));
+ DEBUG ((DEBUG_INFO, " LocalSapicId=0x%02x", ProcessorLocalSapic->LocalSapicId));
+ DEBUG ((DEBUG_INFO, " LocalSapicEid=0x%02x", ProcessorLocalSapic->LocalSapicEid));
+ DEBUG ((DEBUG_INFO, " UID=0x%08x", ProcessorLocalSapic->ACPIProcessorUIDValue));
+ if ((ProcessorLocalSapic->Flags & EFI_ACPI_5_0_LOCAL_APIC_ENABLED) != 0) {
+ DEBUG ((DEBUG_INFO, " (Enabled)"));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_4_0_PLATFORM_INTERRUPT_SOURCES:
+ PlatformInterruptSource = (EFI_ACPI_4_0_PLATFORM_INTERRUPT_SOURCES_STRUCTURE *)ApicStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", ApicStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " Type=0x%02x", PlatformInterruptSource->InterruptType));
+ DEBUG ((DEBUG_INFO, " ID=0x%02x", PlatformInterruptSource->ProcessorId));
+ DEBUG ((DEBUG_INFO, " EID=0x%02x", PlatformInterruptSource->ProcessorEid));
+ DEBUG ((DEBUG_INFO, " IoSapicVector=0x%02x", PlatformInterruptSource->IoSapicVector));
+ DEBUG ((DEBUG_INFO, " Interrupt=0x%08x", PlatformInterruptSource->GlobalSystemInterrupt));
+ DEBUG ((DEBUG_INFO, " SourceFlags=0x%08x", PlatformInterruptSource->PlatformInterruptSourceFlags));
+ DEBUG ((DEBUG_INFO, " Flags=0x%04x", PlatformInterruptSource->Flags));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_4_0_PROCESSOR_LOCAL_X2APIC:
+ ProcessorLocalX2Apic = (EFI_ACPI_4_0_PROCESSOR_LOCAL_X2APIC_STRUCTURE *)ApicStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", ApicStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " X2ApicId=0x%08x", ProcessorLocalX2Apic->X2ApicId));
+ DEBUG ((DEBUG_INFO, " UID=0x%08x", ProcessorLocalX2Apic->AcpiProcessorUid));
+ if ((ProcessorLocalX2Apic->Flags & EFI_ACPI_5_0_LOCAL_APIC_ENABLED) != 0) {
+ DEBUG ((DEBUG_INFO, " (Enabled)"));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ case EFI_ACPI_4_0_LOCAL_X2APIC_NMI:
+ LocalX2ApicNmi = (EFI_ACPI_4_0_LOCAL_X2APIC_NMI_STRUCTURE *)ApicStructHeader;
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, ": [0x%02x]", ApicStructHeader->Type));
+ DEBUG ((DEBUG_INFO, " UID=0x%08x", LocalX2ApicNmi->AcpiProcessorUid));
+ DEBUG ((DEBUG_INFO, " Lint=0x%02x", LocalX2ApicNmi->LocalX2ApicLint));
+ DEBUG ((DEBUG_INFO, " Flags=0x%04x", LocalX2ApicNmi->Flags));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ default:
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, ShortNameOfMadtType(ApicStructHeader->Type)));
+ DEBUG ((DEBUG_INFO, "\n"));
+ break;
+ }
+ ApicStructHeader = (APIC_STRUCT_HEADER *)((UINT8 *)ApicStructHeader + ApicStructHeader->Length);
+ MadtLen -= ApicStructHeader->Length;
+ }
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMcfg.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMcfg.c
new file mode 100644
index 0000000000..097a688004
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMcfg.c
@@ -0,0 +1,63 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h>
+
+VOID
+DumpCharArray (
+ IN CHAR8 *Ch,
+ IN UINTN Size
+ );
+
+VOID
+DumpAcpiTableHeader (
+ IN EFI_ACPI_DESCRIPTION_HEADER *Table
+ );
+
+EFI_STATUS
+DumpAcpiMcfg (
+ IN EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER *Mcfg
+ )
+{
+ EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE *Struct;
+ UINTN Count;
+ UINTN Index;
+
+ DumpAcpiTableHeader (&Mcfg->Header);
+
+ Count = Mcfg->Header.Length - sizeof(EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER);
+ Count = Count / sizeof(EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE);
+ Struct = (VOID *)(Mcfg + 1);
+ for (Index = 0; Index < Count; Index++) {
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " Segment :"));
+ DEBUG ((DEBUG_INFO, " BaseAddress=0x%016lx", Struct->BaseAddress));
+ DEBUG ((DEBUG_INFO, " Seg=0x%04x Bus=(0x%02x-0x%02x)",
+ Struct->PciSegmentGroupNumber,
+ Struct->StartBusNumber,
+ Struct->EndBusNumber
+ ));
+ DEBUG ((DEBUG_INFO, "\n"));
+ Struct++;
+ }
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiWsmt.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiWsmt.c
new file mode 100644
index 0000000000..001b1d4357
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiWsmt.c
@@ -0,0 +1,45 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/WindowsSmmSecurityMitigationTable.h>
+
+VOID
+DumpCharArray (
+ IN CHAR8 *Ch,
+ IN UINTN Size
+ );
+
+VOID
+DumpAcpiTableHeader (
+ IN EFI_ACPI_DESCRIPTION_HEADER *Table
+ );
+
+EFI_STATUS
+DumpAcpiWsmt (
+ IN EFI_ACPI_WSMT_TABLE *Wsmt
+ )
+{
+ DumpAcpiTableHeader (&Wsmt->Header);
+ DEBUG ((DEBUG_INFO, " "));
+ DEBUG ((DEBUG_INFO, " ProtectionFlags=0x%08x\n", Wsmt->ProtectionFlags));
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpBootVariable.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpBootVariable.c
new file mode 100644
index 0000000000..763960cf5a
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpBootVariable.c
@@ -0,0 +1,195 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+CHAR16 *mLoadOptionVariableList[] = {
+ L"Boot",
+ L"Driver",
+ L"SysPrep",
+};
+
+CHAR16 *mPlatformRecoveryOptionVariableList[] = {
+ L"PlatformRecovery", // does not have PlatformRecoveryOrder
+};
+
+CHAR16 *mOsRecoveryOptionVariableList[] = {
+ L"OsRecovery", // VariableGuid in OsRecoveryOrder
+};
+
+CHAR16 *mKeyOptionVariableList[] = {
+ L"Key", // does not have KeyOrder
+};
+
+VOID
+DumpLoadOption (
+ IN CHAR16 *OptionName,
+ IN EFI_LOAD_OPTION *LoadOption,
+ IN UINTN Size
+ )
+{
+ CHAR16 *Str;
+ CHAR16 *Description;
+ EFI_DEVICE_PATH_PROTOCOL *FilePathList;
+
+ if (LoadOption == NULL) {
+ DEBUG ((DEBUG_INFO, "%s: <NULL>\n", OptionName));
+ return ;
+ }
+
+ Description = (CHAR16 *)(LoadOption + 1);
+
+ FilePathList = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)Description + StrSize (Description));
+
+ DEBUG ((DEBUG_INFO, "%s: [0x%08x] \"%s\"", OptionName, LoadOption->Attributes, Description));
+ Str = ConvertDevicePathToText(FilePathList, TRUE, TRUE);
+ DEBUG ((DEBUG_INFO, " %s\n", Str));
+ if (Str != NULL) {
+ FreePool (Str);
+ }
+}
+
+VOID
+DumpKeyOption (
+ IN CHAR16 *OptionName,
+ IN EFI_KEY_OPTION *KeyOption,
+ IN UINTN Size
+ )
+{
+ UINTN Index;
+ EFI_INPUT_KEY *Keys;
+
+ Keys = (EFI_INPUT_KEY *)(KeyOption + 1);
+
+ DEBUG ((DEBUG_INFO, "%s: [Boot%04x] 0x%08x", OptionName, KeyOption->BootOption, KeyOption->KeyData.PackedValue));
+ for (Index = 0; Index < KeyOption->KeyData.Options.InputKeyCount; Index++) {
+ DEBUG ((DEBUG_INFO, " (%04x/%04x)", Keys[Index].ScanCode, Keys[Index].UnicodeChar));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+}
+
+VOID
+DumpLoadOptionVariable (
+ VOID
+ )
+{
+ UINT16 *BootOrder;
+ UINTN OrderSize;
+ VOID *Variable;
+ UINTN ListIndex;
+ UINTN Size;
+ UINTN Index;
+ EFI_STATUS Status;
+ CHAR16 BootOptionName[sizeof(L"PlatformRecovery####")];
+ CHAR16 BootOrderName[sizeof(L"PlatformRecoveryOrder")];
+
+ for (ListIndex = 0; ListIndex < sizeof(mLoadOptionVariableList)/sizeof(mLoadOptionVariableList[0]); ListIndex++) {
+ UnicodeSPrint (BootOrderName, sizeof(BootOrderName), L"%sOrder", mLoadOptionVariableList[ListIndex]);
+ Status = GetVariable2 (BootOrderName, &gEfiGlobalVariableGuid, &BootOrder, &OrderSize);
+ if (EFI_ERROR(Status)) {
+ continue;
+ }
+ for (Index = 0; Index < OrderSize/sizeof(CHAR16); Index++) {
+ UnicodeSPrint (BootOptionName, sizeof(BootOptionName), L"%s%04x", mLoadOptionVariableList[ListIndex], BootOrder[Index]);
+ Status = GetVariable2 (BootOptionName, &gEfiGlobalVariableGuid, &Variable, &Size);
+ if (!EFI_ERROR(Status)) {
+ DumpLoadOption (BootOptionName, Variable, Size);
+ } else {
+ DumpLoadOption (BootOptionName, NULL, 0);
+ }
+ }
+ }
+}
+
+VOID
+DumpPlatformRecoveryOptionVariable (
+ VOID
+ )
+{
+ VOID *Variable;
+ UINTN ListIndex;
+ UINTN Size;
+ UINTN Index;
+ EFI_STATUS Status;
+ CHAR16 PlatformRecoveryOptionName[sizeof(L"PlatformRecovery####")];
+
+ for (ListIndex = 0; ListIndex < sizeof(mPlatformRecoveryOptionVariableList)/sizeof(mPlatformRecoveryOptionVariableList[0]); ListIndex++) {
+ for (Index = 0; ; Index++) {
+ UnicodeSPrint (PlatformRecoveryOptionName, sizeof(PlatformRecoveryOptionName), L"%s%04x", mPlatformRecoveryOptionVariableList[ListIndex], Index);
+ Status = GetVariable2 (PlatformRecoveryOptionName, &gEfiGlobalVariableGuid, &Variable, &Size);
+ if (!EFI_ERROR(Status)) {
+ DumpLoadOption (PlatformRecoveryOptionName, Variable, Size);
+ } else {
+ break;
+ }
+ }
+ }
+}
+
+VOID
+DumpOsRecoveryOptionVariable (
+ VOID
+ )
+{
+}
+
+VOID
+DumpKeyOptionVariable (
+ VOID
+ )
+{
+ VOID *Variable;
+ UINTN ListIndex;
+ UINTN Size;
+ UINTN Index;
+ EFI_STATUS Status;
+ CHAR16 KeyOptionName[sizeof(L"Key####")];
+
+ for (ListIndex = 0; ListIndex < sizeof(mKeyOptionVariableList)/sizeof(mKeyOptionVariableList[0]); ListIndex++) {
+ for (Index = 0; ; Index++) {
+ UnicodeSPrint (KeyOptionName, sizeof(KeyOptionName), L"%s%04x", mKeyOptionVariableList[ListIndex], Index);
+ Status = GetVariable2 (KeyOptionName, &gEfiGlobalVariableGuid, &Variable, &Size);
+ if (!EFI_ERROR(Status)) {
+ DumpKeyOption (KeyOptionName, Variable, Size);
+ } else {
+ break;
+ }
+ }
+ }
+}
+
+EFI_STATUS
+TestPointDumpBootVariable (
+ VOID
+ )
+{
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpBootVariable - Enter\n"));
+
+ DumpLoadOptionVariable ();
+ DumpPlatformRecoveryOptionVariable ();
+ DumpOsRecoveryOptionVariable ();
+ DumpKeyOptionVariable ();
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpBootVariable - Exit\n"));
+
+ // Check - TBD
+ return EFI_SUCCESS;
+} \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpConsoleVariable.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpConsoleVariable.c
new file mode 100644
index 0000000000..b78235a73f
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpConsoleVariable.c
@@ -0,0 +1,69 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+CHAR16 *mConsoleVariableList[] = {
+ L"ConIn",
+ L"ConInDev",
+ L"ConOut",
+ L"ConOutDev",
+ L"ErrOut",
+ L"ErrOutDev",
+};
+
+VOID
+DumpDevicePath (
+ IN CHAR16 *Name,
+ IN EFI_DEVICE_PATH *DevicePath,
+ IN UINTN Size
+ )
+{
+ CHAR16 *Str;
+
+ Str = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
+ DEBUG ((DEBUG_INFO, "%s: %s\n", Name, Str));
+ if (Str != NULL) {
+ FreePool (Str);
+ }
+}
+
+EFI_STATUS
+TestPointDumpConsoleVariable (
+ VOID
+ )
+{
+ VOID *Variable;
+ UINTN Size;
+ UINTN Index;
+ EFI_STATUS Status;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpConsoleVariable - Enter\n"));
+ for (Index = 0; Index < sizeof(mConsoleVariableList)/sizeof(mConsoleVariableList[0]); Index++) {
+ Status = GetVariable2 (mConsoleVariableList[Index], &gEfiGlobalVariableGuid, &Variable, &Size);
+ if (!EFI_ERROR(Status)) {
+ DumpDevicePath (mConsoleVariableList[Index], Variable, Size);
+ }
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpConsoleVariable - Exit\n"));
+
+ // Check - TBD
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpDevicePath.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpDevicePath.c
new file mode 100644
index 0000000000..eff049591e
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpDevicePath.c
@@ -0,0 +1,78 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Protocol/LoadedImage.h>
+#include <Protocol/DevicePath.h>
+
+EFI_STATUS
+TestPointDumpDevicePath (
+ VOID
+ )
+{
+ UINTN Index;
+ EFI_HANDLE *HandleBuf;
+ UINTN HandleCount;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
+ CHAR16 *Str;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpDevicePath - Enter\n"));
+ HandleBuf = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDevicePathProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuf
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done ;
+ }
+
+ DEBUG ((DEBUG_INFO, "DeviceList:\n"));
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (
+ HandleBuf[Index],
+ &gEfiDevicePathProtocolGuid,
+ (VOID**)&DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+ Str = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
+ DEBUG ((DEBUG_INFO, " %s\n", Str));
+ if (Str != NULL) {
+ FreePool (Str);
+ }
+ }
+
+Done:
+ if (HandleBuf != NULL) {
+ FreePool (HandleBuf);
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpDevicePath - Enter\n"));
+
+ // Check - TBD
+ return EFI_SUCCESS;
+} \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpEsrt.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpEsrt.c
new file mode 100644
index 0000000000..48c1eaa3a3
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpEsrt.c
@@ -0,0 +1,120 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Guid/SystemResourceTable.h>
+
+CHAR8 *mFwTypeString[] = {
+ " Unknown ",
+ " System ",
+ " Device ",
+ " Driver ",
+};
+
+CHAR8 *mLastAttemptStatusString[] = {
+ "Success",
+ "Error: Unsuccessful",
+ "Error: Insufficient Resources",
+ "Error: Incorrect Version",
+ "Error: Invalid Format",
+ "Error: Auth Error",
+ "Error: Power Event AC",
+ "Error: Power Event Battery",
+};
+
+CHAR8 mUnknownStr[11];
+
+CHAR8 *
+FwTypeToString(
+ IN UINT32 FwType
+ )
+{
+ if (FwType < sizeof(mFwTypeString) / sizeof(mFwTypeString[0])) {
+ return mFwTypeString[FwType];
+ } else {
+ AsciiSPrint(mUnknownStr, sizeof(mUnknownStr), "[%08x]", FwType);
+ return mUnknownStr;
+ }
+}
+
+CHAR8 *
+LastAttemptStatusToString(
+ IN UINT32 LastAttemptStatus
+ )
+{
+ if (LastAttemptStatus < sizeof(mLastAttemptStatusString) / sizeof(mLastAttemptStatusString[0])) {
+ return mLastAttemptStatusString[LastAttemptStatus];
+ } else {
+ return "Error: Unknown";
+ }
+}
+
+VOID
+DumpEsrt (
+ IN EFI_SYSTEM_RESOURCE_TABLE *Esrt
+ )
+{
+ UINTN Index;
+ EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry;
+
+ DEBUG ((DEBUG_INFO, "ESRT Table:"));
+ DEBUG ((DEBUG_INFO, " Count=0x%x", Esrt->FwResourceCount));
+ DEBUG ((DEBUG_INFO, " CountMax=0x%x", Esrt->FwResourceCountMax));
+ DEBUG ((DEBUG_INFO, " Version=0x%lx\n", Esrt->FwResourceVersion));
+
+ DEBUG ((DEBUG_INFO, " FwClass FwType Version LowestVer Flags AttemptVer Attempt\n"));
+//DEBUG ((DEBUG_INFO, " 00000000-0000-0000-0000-000000000000 [00000000] 0x00000000 0x00000000 0x00000000 0x00000000 Success\n"));
+ EsrtEntry = (VOID *)(Esrt + 1);
+ for (Index = 0; Index < Esrt->FwResourceCount; Index++) {
+ DEBUG ((DEBUG_INFO, " %g ", &EsrtEntry->FwClass));
+ DEBUG ((DEBUG_INFO, FwTypeToString(EsrtEntry->FwType)));
+ DEBUG ((DEBUG_INFO, " 0x%08x", EsrtEntry->FwVersion));
+ DEBUG ((DEBUG_INFO, " 0x%08x", EsrtEntry->LowestSupportedFwVersion));
+ DEBUG ((DEBUG_INFO, " 0x%08x", EsrtEntry->CapsuleFlags));
+ DEBUG ((DEBUG_INFO, " 0x%08x ", EsrtEntry->LastAttemptVersion));
+ DEBUG ((DEBUG_INFO, LastAttemptStatusToString(EsrtEntry->LastAttemptStatus)));
+ DEBUG ((DEBUG_INFO, "\n"));
+ EsrtEntry++;
+ }
+}
+
+EFI_STATUS
+TestPointDumpEsrt (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_SYSTEM_RESOURCE_TABLE *Esrt;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpEsrt - Enter\n"));
+ Status = EfiGetSystemConfigurationTable (&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
+ if (!EFI_ERROR(Status)) {
+ DumpEsrt(Esrt);
+ } else {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_9 TEST_POINT_READY_TO_BOOT TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_9
+ );
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpEsrt - Exit\n"));
+
+ return Status;
+} \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpGcd.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpGcd.c
new file mode 100644
index 0000000000..46fde33ab1
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpGcd.c
@@ -0,0 +1,230 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DxeServicesTableLib.h>
+
+CHAR8 *mGcdMemoryTypeShortName[] = {
+ " NE ",
+ " RSVD",
+ " SYS ",
+ " MMIO",
+ " PERS",
+ " RELI",
+};
+
+CHAR8 mUnknownStr[11];
+
+CHAR8 *
+ShortNameOfGcdMemoryType(
+ IN UINT32 Type
+ )
+{
+ if (Type < sizeof(mGcdMemoryTypeShortName) / sizeof(mGcdMemoryTypeShortName[0])) {
+ return mGcdMemoryTypeShortName[Type];
+ } else {
+ return " ???? ";
+ }
+}
+
+CHAR8 *mGcdIoTypeShortName[] = {
+ " NE ",
+ " RSVD",
+ " SYS ",
+};
+
+CHAR8 *
+ShortNameOfGcdIoType(
+ IN UINT32 Type
+ )
+{
+ if (Type < sizeof(mGcdIoTypeShortName) / sizeof(mGcdIoTypeShortName[0])) {
+ return mGcdIoTypeShortName[Type];
+ } else {
+ return " ???? ";
+ }
+}
+
+VOID
+PrintBitMask (
+ IN UINT64 Bit,
+ IN UINT64 Capabilities,
+ IN UINT64 Attributes
+ )
+{
+ if ((Capabilities & Bit) != 0) {
+ if ((Attributes & Bit) != 0) {
+ DEBUG ((DEBUG_INFO, "1"));
+ } else {
+ DEBUG ((DEBUG_INFO, "0"));
+ }
+ } else {
+ DEBUG ((DEBUG_INFO, "-"));
+ }
+}
+
+VOID
+PrintMemoryDescriptorHeader (
+ VOID
+ )
+{
+ if (sizeof(UINT64) == sizeof(UINTN)) {
+ DEBUG ((DEBUG_INFO, " U \n"));
+ DEBUG ((DEBUG_INFO, " RRMNXRWCWWWU \n"));
+ DEBUG ((DEBUG_INFO, "Base Address End Address Type TORVPPPEBTCC Image Device \n"));
+ DEBUG ((DEBUG_INFO, "================ ================ ==== ============ ================ ================\n"));
+ } else {
+ DEBUG ((DEBUG_INFO, " U \n"));
+ DEBUG ((DEBUG_INFO, " RRMNXRWCWWWU \n"));
+ DEBUG ((DEBUG_INFO, "Base Address End Address Type TORVPPPEBTCC Image Device \n"));
+ DEBUG ((DEBUG_INFO, "================ ================ ==== ============ ======== ========\n"));
+ }
+}
+
+VOID
+PrintMemoryDescriptor (
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemoryDescriptor
+ )
+{
+ DEBUG ((DEBUG_INFO,
+ "%016lx-%016lx",
+ MemoryDescriptor->BaseAddress,
+ MemoryDescriptor->BaseAddress + MemoryDescriptor->Length - 1
+ ));
+
+ DEBUG ((DEBUG_INFO, ShortNameOfGcdMemoryType(MemoryDescriptor->GcdMemoryType)));
+ DEBUG ((DEBUG_INFO, " "));
+
+ if (MemoryDescriptor->GcdMemoryType != EfiGcdMemoryTypeNonExistent) {
+ PrintBitMask (EFI_MEMORY_RUNTIME, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ PrintBitMask (EFI_MEMORY_RO, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ PrintBitMask (EFI_MEMORY_MORE_RELIABLE, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ PrintBitMask (EFI_MEMORY_NV, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ PrintBitMask (EFI_MEMORY_XP, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ PrintBitMask (EFI_MEMORY_RP, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ PrintBitMask (EFI_MEMORY_WP, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ PrintBitMask (EFI_MEMORY_UCE, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ PrintBitMask (EFI_MEMORY_WB, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ PrintBitMask (EFI_MEMORY_WT, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ PrintBitMask (EFI_MEMORY_WC, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ PrintBitMask (EFI_MEMORY_UC, MemoryDescriptor->Capabilities, MemoryDescriptor->Attributes);
+ } else {
+ DEBUG ((DEBUG_INFO, " "));
+ }
+
+ if (sizeof(UINT64) == sizeof(UINTN)) {
+ if (MemoryDescriptor->ImageHandle != NULL) {
+ DEBUG ((DEBUG_INFO, " %016lx", (UINT64)(UINTN)MemoryDescriptor->ImageHandle));
+ if (MemoryDescriptor->DeviceHandle != NULL) {
+ DEBUG ((DEBUG_INFO, " %016lx", (UINT64)(UINTN)MemoryDescriptor->ImageHandle));
+ }
+ }
+ } else {
+ if (MemoryDescriptor->ImageHandle != NULL) {
+ DEBUG ((DEBUG_INFO, " %08x", MemoryDescriptor->ImageHandle));
+ if (MemoryDescriptor->DeviceHandle != NULL) {
+ DEBUG ((DEBUG_INFO, " %08x", MemoryDescriptor->ImageHandle));
+ }
+ }
+ }
+
+ DEBUG ((DEBUG_INFO, "\n"));
+}
+
+VOID
+PrintIoDescriptorHeader (
+ VOID
+ )
+{
+ DEBUG ((DEBUG_INFO, "Base Address End Address Type Image Device \n"));
+ DEBUG ((DEBUG_INFO, "================ ================ ==== ======== ========\n"));
+}
+
+VOID
+PrintIoDescriptor (
+ EFI_GCD_IO_SPACE_DESCRIPTOR *IoDescriptor
+ )
+{
+ DEBUG ((DEBUG_INFO,
+ "%016lx-%016lx",
+ IoDescriptor->BaseAddress,
+ IoDescriptor->BaseAddress + IoDescriptor->Length - 1
+ ));
+
+ DEBUG ((DEBUG_INFO, ShortNameOfGcdIoType (IoDescriptor->GcdIoType)));
+
+ if (IoDescriptor->ImageHandle != NULL) {
+ DEBUG ((DEBUG_INFO, " %08x", IoDescriptor->ImageHandle));
+ if (IoDescriptor->DeviceHandle != NULL) {
+ DEBUG ((DEBUG_INFO, " %08x", IoDescriptor->ImageHandle));
+ }
+ }
+
+ DEBUG ((DEBUG_INFO, "\n"));
+}
+
+EFI_STATUS
+TestPointDumpGcd (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemoryMap;
+ EFI_GCD_IO_SPACE_DESCRIPTOR *IoMap;
+ UINTN NumberOfDescriptors;
+ UINTN Index;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpGcd - Enter\n"));
+ DEBUG ((DEBUG_INFO, "GCD MEM:\n"));
+ NumberOfDescriptors = 0;
+ MemoryMap = NULL;
+ Status = gDS->GetMemorySpaceMap (
+ &NumberOfDescriptors,
+ &MemoryMap
+ );
+ if (!EFI_ERROR (Status)) {
+ PrintMemoryDescriptorHeader ();
+ for (Index = 0; Index < NumberOfDescriptors; Index++) {
+ PrintMemoryDescriptor (&MemoryMap[Index]);
+ }
+ } else {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_END_OF_DXE_ERROR_CODE_3 TEST_POINT_END_OF_DXE TEST_POINT_BYTE2_END_OF_DXE_ERROR_STRING_3
+ );
+ goto Done;
+ }
+
+ DEBUG ((DEBUG_INFO, "GCD IO:\n"));
+ NumberOfDescriptors = 0;
+ IoMap = NULL;
+ Status = gDS->GetIoSpaceMap (
+ &NumberOfDescriptors,
+ &IoMap
+ );
+ if (!EFI_ERROR (Status)) {
+ PrintIoDescriptorHeader ();
+ for (Index = 0; Index < NumberOfDescriptors; Index++) {
+ PrintIoDescriptor (&IoMap[Index]);
+ }
+ }
+
+Done:
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpGcd - Exit\n"));
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpHsti.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpHsti.c
new file mode 100644
index 0000000000..826a0b1ba4
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpHsti.c
@@ -0,0 +1,123 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/HstiLib.h>
+#include <IndustryStandard/Hsti.h>
+
+/**
+ Dump HSTI info
+
+ @param[in] HstiData - Pointer to HSTI data
+**/
+VOID
+DumpHsti (
+ IN VOID *HstiData
+ )
+{
+ ADAPTER_INFO_PLATFORM_SECURITY *Hsti;
+ UINT8 *SecurityFeatures;
+ CHAR16 *ErrorString;
+ UINTN Index;
+ CHAR16 ErrorChar;
+
+ Hsti = HstiData;
+ DEBUG ((DEBUG_INFO, "HSTI\n"));
+ DEBUG ((DEBUG_INFO, " Version - 0x%08x\n", Hsti->Version));
+ DEBUG ((DEBUG_INFO, " Role - 0x%08x\n", Hsti->Role));
+ DEBUG ((DEBUG_INFO, " ImplementationID - %S\n", Hsti->ImplementationID));
+ DEBUG ((DEBUG_INFO, " SecurityFeaturesSize - 0x%08x\n", Hsti->SecurityFeaturesSize));
+
+ SecurityFeatures = (UINT8 *) (Hsti + 1);
+ DEBUG ((DEBUG_INFO, " SecurityFeaturesRequired - "));
+ for (Index = 0; Index < Hsti->SecurityFeaturesSize; Index++) {
+ DEBUG ((DEBUG_INFO, "%02x ", SecurityFeatures[Index]));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+
+ SecurityFeatures = (UINT8 *) (SecurityFeatures + Hsti->SecurityFeaturesSize);
+ DEBUG ((DEBUG_INFO, " SecurityFeaturesImplemented - "));
+ for (Index = 0; Index < Hsti->SecurityFeaturesSize; Index++) {
+ DEBUG ((DEBUG_INFO, "%02x ", SecurityFeatures[Index]));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+
+ SecurityFeatures = (UINT8 *) (SecurityFeatures + Hsti->SecurityFeaturesSize);
+ DEBUG ((DEBUG_INFO, " SecurityFeaturesVerified - "));
+ for (Index = 0; Index < Hsti->SecurityFeaturesSize; Index++) {
+ DEBUG ((DEBUG_INFO, "%02x ", SecurityFeatures[Index]));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+
+ ErrorString = (CHAR16 *) (SecurityFeatures + Hsti->SecurityFeaturesSize);
+ DEBUG ((DEBUG_INFO, " ErrorString - \""));
+ CopyMem (&ErrorChar, ErrorString, sizeof (ErrorChar));
+ for (; ErrorChar != 0;) {
+ DEBUG ((DEBUG_INFO, "%c", ErrorChar));
+ ErrorString++;
+ CopyMem (&ErrorChar, ErrorString, sizeof (ErrorChar));
+ }
+ DEBUG ((DEBUG_INFO, "\"\n"));
+}
+
+UINT32 mRole[] = {
+ PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE,
+ PLATFORM_SECURITY_ROLE_PLATFORM_IBV,
+ PLATFORM_SECURITY_ROLE_IMPLEMENTOR_OEM,
+ PLATFORM_SECURITY_ROLE_IMPLEMENTOR_ODM,
+};
+
+EFI_STATUS
+TestPointDumpHsti (
+ VOID
+ )
+{
+ VOID *Hsti;
+ UINTN HstiSize;
+ EFI_STATUS Status;
+ UINTN Index;
+ BOOLEAN Result;
+
+ Result = TRUE;
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpHsti - Enter\n"));
+ for (Index = 0; Index < sizeof(mRole)/sizeof(mRole[0]); Index++) {
+ Status = HstiLibGetTable (mRole[Index], NULL, &Hsti, &HstiSize);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "HSTI (Role - 0x%08x) not found!\n", mRole[Index]));
+ if (mRole[Index] <= PLATFORM_SECURITY_ROLE_PLATFORM_IBV) {
+ Result = FALSE;
+ }
+ continue;
+ }
+ DumpHsti (Hsti);
+ FreePool (Hsti);
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpHsti - Exit\n"));
+
+ if (!Result) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_8 TEST_POINT_READY_TO_BOOT TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_8
+ );
+ return EFI_NOT_FOUND;
+ }
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpLoadedImage.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpLoadedImage.c
new file mode 100644
index 0000000000..8b717e08ed
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpLoadedImage.c
@@ -0,0 +1,203 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/PeCoffGetEntryPointLib.h>
+#include <Protocol/LoadedImage.h>
+
+BOOLEAN
+IsRuntimeImage (
+ IN VOID *Pe32Data
+ )
+{
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ UINT16 Magic;
+ UINT16 Subsystem;
+
+ ASSERT (Pe32Data != NULL);
+
+ DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
+ if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image header.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
+ } else {
+ //
+ // DOS image header is not present, so PE header is at the image base.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
+ }
+
+ if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
+ //
+ // NOTE: We use Machine field to identify PE32/PE32+, instead of Magic.
+ // It is due to backward-compatibility, for some system might
+ // generate PE32+ image with PE32 Magic.
+ //
+ switch (Hdr.Pe32->FileHeader.Machine) {
+ case IMAGE_FILE_MACHINE_I386:
+ //
+ // Assume PE32 image with IA32 Machine field.
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+ break;
+ case IMAGE_FILE_MACHINE_X64:
+ case IMAGE_FILE_MACHINE_IA64:
+ //
+ // Assume PE32+ image with x64 or IA64 Machine field
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ break;
+ default:
+ //
+ // For unknow Machine field, use Magic in optional Header
+ //
+ Magic = Hdr.Pe32->OptionalHeader.Magic;
+ }
+
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ Subsystem = Hdr.Pe32->OptionalHeader.Subsystem;
+ } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
+ Subsystem = Hdr.Pe32Plus->OptionalHeader.Subsystem;
+ }
+ if (Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+VOID
+DumpLoadedImage (
+ IN UINTN Index,
+ IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath
+ )
+{
+ CHAR16 *Str;
+ CHAR8 *PdbPointer;
+
+ DEBUG ((DEBUG_INFO, "[0x%04x]:", Index));
+ if (IsRuntimeImage (LoadedImage->ImageBase)) {
+ DEBUG ((DEBUG_INFO, " (RT)"));
+ } else {
+ DEBUG ((DEBUG_INFO, " "));
+ }
+ DEBUG ((DEBUG_INFO, " 0x%016lx-0x%016lx", (UINT64)(UINTN)LoadedImage->ImageBase, LoadedImage->ImageSize));
+
+ if (LoadedImageDevicePath != NULL) {
+ Str = ConvertDevicePathToText(LoadedImageDevicePath, TRUE, TRUE);
+ DEBUG ((DEBUG_INFO, " LoadedImageDevicePath=%s", Str));
+ if (Str != NULL) {
+ FreePool (Str);
+ }
+ } else {
+ if (LoadedImage->FilePath != NULL) {
+ Str = ConvertDevicePathToText(LoadedImage->FilePath, TRUE, TRUE);
+ DEBUG ((DEBUG_INFO, " FilePath=%s", Str));
+ if (Str != NULL) {
+ FreePool (Str);
+ }
+ }
+
+ if (DevicePath != NULL) {
+ Str = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
+ DEBUG ((DEBUG_INFO, " DevicePath=%s", Str));
+ if (Str != NULL) {
+ FreePool (Str);
+ }
+ }
+ }
+
+ PdbPointer = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);
+ if (PdbPointer != NULL) {
+ DEBUG ((DEBUG_INFO, " (pdb - %a)", PdbPointer));
+ }
+
+ DEBUG ((DEBUG_INFO, "\n"));
+}
+
+EFI_STATUS
+TestPointDumpLoadedImage (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ UINTN Index;
+ EFI_HANDLE *HandleBuf;
+ UINTN HandleCount;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpLoadedImage - Enter\n"));
+ HandleBuf = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiLoadedImageProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuf
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done ;
+ }
+
+ DEBUG ((DEBUG_INFO, "LoadedImage (%d):\n", HandleCount));
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (
+ HandleBuf[Index],
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
+ if (EFI_ERROR(Status)) {
+ continue;
+ }
+
+ Status = gBS->HandleProtocol (LoadedImage->DeviceHandle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath);
+ if (EFI_ERROR(Status)) {
+ DevicePath = NULL;
+ }
+
+ Status = gBS->HandleProtocol (HandleBuf[Index], &gEfiLoadedImageDevicePathProtocolGuid, (VOID **)&LoadedImageDevicePath);
+ if (EFI_ERROR(Status)) {
+ LoadedImageDevicePath = NULL;
+ }
+
+ DumpLoadedImage (Index, LoadedImage, DevicePath, LoadedImageDevicePath);
+ }
+
+Done:
+
+ if (HandleBuf != NULL) {
+ FreePool (HandleBuf);
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpLoadedImage - Exit\n"));
+
+ // Check - TBD
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemAttribute.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemAttribute.c
new file mode 100644
index 0000000000..57a86963f2
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemAttribute.c
@@ -0,0 +1,89 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Guid/MemoryAttributesTable.h>
+
+CHAR8 *
+ShortNameOfMemoryType(
+ IN UINT32 Type
+ );
+
+VOID
+DumpMemoryAttributesTable (
+ IN EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable
+ )
+{
+ UINTN Index;
+ EFI_MEMORY_DESCRIPTOR *Entry;
+ UINT64 Pages[EfiMaxMemoryType];
+
+ ZeroMem (Pages, sizeof(Pages));
+
+ DEBUG ((DEBUG_INFO, "MemoryAttributesTable:"));
+ DEBUG ((DEBUG_INFO, " Version=0x%x", MemoryAttributesTable->Version));
+ DEBUG ((DEBUG_INFO, " Count=0x%x", MemoryAttributesTable->NumberOfEntries));
+ DEBUG ((DEBUG_INFO, " DescriptorSize=0x%x\n", MemoryAttributesTable->DescriptorSize));
+ Entry = (EFI_MEMORY_DESCRIPTOR *)(MemoryAttributesTable + 1);
+ DEBUG ((DEBUG_INFO, "Type Start End # Pages Attributes\n"));
+ for (Index = 0; Index < MemoryAttributesTable->NumberOfEntries; Index++) {
+ DEBUG ((DEBUG_INFO, ShortNameOfMemoryType(Entry->Type)));
+ DEBUG ((DEBUG_INFO, " %016LX-%016LX %016LX %016LX\n",
+ Entry->PhysicalStart,
+ Entry->PhysicalStart+MultU64x64 (SIZE_4KB,Entry->NumberOfPages) - 1,
+ Entry->NumberOfPages,
+ Entry->Attribute
+ ));
+ if (Entry->Type < EfiMaxMemoryType) {
+ Pages[Entry->Type] += Entry->NumberOfPages;
+ }
+ Entry = NEXT_MEMORY_DESCRIPTOR (Entry, MemoryAttributesTable->DescriptorSize);
+ }
+
+ DEBUG ((DEBUG_INFO, "\n"));
+ DEBUG ((DEBUG_INFO, " RT_Code : %14ld Pages (%ld Bytes)\n", Pages[EfiRuntimeServicesCode], MultU64x64(SIZE_4KB, Pages[EfiRuntimeServicesCode])));
+ DEBUG ((DEBUG_INFO, " RT_Data : %14ld Pages (%ld Bytes)\n", Pages[EfiRuntimeServicesData], MultU64x64(SIZE_4KB, Pages[EfiRuntimeServicesData])));
+ DEBUG ((DEBUG_INFO, " -------------- \n"));
+}
+
+EFI_STATUS
+TestPointDumpMemAttribute (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *MemoryAttributesTable;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpMemAttribute - Enter\n"));
+ Status = EfiGetSystemConfigurationTable (&gEfiMemoryAttributesTableGuid, &MemoryAttributesTable);
+ if (!EFI_ERROR (Status)) {
+ DumpMemoryAttributesTable(MemoryAttributesTable);
+ } else {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_4 TEST_POINT_READY_TO_BOOT TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_4
+ );
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpMemAttribute - Exit\n"));
+
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemMap.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemMap.c
new file mode 100644
index 0000000000..6d59c7773c
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemMap.c
@@ -0,0 +1,219 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PrintLib.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseMemoryLib.h>
+
+CHAR8 *mMemoryTypeShortName[] = {
+ "Reserved ",
+ "LoaderCode",
+ "LoaderData",
+ "BS_Code ",
+ "BS_Data ",
+ "RT_Code ",
+ "RT_Data ",
+ "Available ",
+ "Unusable ",
+ "ACPI_Recl ",
+ "ACPI_NVS ",
+ "MMIO ",
+ "MMIO_Port ",
+ "PalCode ",
+ "Persistent",
+};
+
+CHAR8 mUnknownStr[11];
+
+CHAR8 *
+ShortNameOfMemoryType(
+ IN UINT32 Type
+ )
+{
+ if (Type < sizeof(mMemoryTypeShortName) / sizeof(mMemoryTypeShortName[0])) {
+ return mMemoryTypeShortName[Type];
+ } else {
+ AsciiSPrint(mUnknownStr, sizeof(mUnknownStr), "[%08x]", Type);
+ return mUnknownStr;
+ }
+}
+
+
+/**
+ Dump memory map.
+
+ @param MemoryMap A pointer to the buffer in which firmware places
+ the current memory map.
+ @param MemoryMapSize Size, in bytes, of the MemoryMap buffer.
+ @param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
+**/
+VOID
+DumpMemoryMap (
+ IN EFI_MEMORY_DESCRIPTOR *MemoryMap,
+ IN UINTN MemoryMapSize,
+ IN UINTN DescriptorSize
+ )
+{
+ EFI_MEMORY_DESCRIPTOR *Entry;
+ UINTN NumberOfEntries;
+ UINTN Index;
+ UINT64 Pages[EfiMaxMemoryType];
+
+ ZeroMem (Pages, sizeof(Pages));
+
+ DEBUG ((EFI_D_INFO, "MemoryMap:\n"));
+
+ Entry = MemoryMap;
+ NumberOfEntries = MemoryMapSize / DescriptorSize;
+ DEBUG ((DEBUG_INFO, "Type Start End # Pages Attributes\n"));
+ for (Index = 0; Index < NumberOfEntries; Index++) {
+ DEBUG ((DEBUG_INFO, ShortNameOfMemoryType(Entry->Type)));
+ DEBUG ((DEBUG_INFO, " %016LX-%016LX %016LX %016LX\n",
+ Entry->PhysicalStart,
+ Entry->PhysicalStart+MultU64x64 (SIZE_4KB,Entry->NumberOfPages) - 1,
+ Entry->NumberOfPages,
+ Entry->Attribute
+ ));
+ if (Entry->Type < EfiMaxMemoryType) {
+ Pages[Entry->Type] += Entry->NumberOfPages;
+ }
+ Entry = NEXT_MEMORY_DESCRIPTOR (Entry, DescriptorSize);
+ }
+
+ DEBUG ((DEBUG_INFO, "\n"));
+ DEBUG ((DEBUG_INFO, " Reserved : %14ld Pages (%ld Bytes)\n", Pages[EfiReservedMemoryType], MultU64x64(SIZE_4KB, Pages[EfiReservedMemoryType])));
+ DEBUG ((DEBUG_INFO, " LoaderCode: %14ld Pages (%ld Bytes)\n", Pages[EfiLoaderCode], MultU64x64(SIZE_4KB, Pages[EfiLoaderCode])));
+ DEBUG ((DEBUG_INFO, " LoaderData: %14ld Pages (%ld Bytes)\n", Pages[EfiLoaderData], MultU64x64(SIZE_4KB, Pages[EfiLoaderData])));
+ DEBUG ((DEBUG_INFO, " BS_Code : %14ld Pages (%ld Bytes)\n", Pages[EfiBootServicesCode], MultU64x64(SIZE_4KB, Pages[EfiBootServicesCode])));
+ DEBUG ((DEBUG_INFO, " BS_Data : %14ld Pages (%ld Bytes)\n", Pages[EfiBootServicesData], MultU64x64(SIZE_4KB, Pages[EfiBootServicesData])));
+ DEBUG ((DEBUG_INFO, " RT_Code : %14ld Pages (%ld Bytes)\n", Pages[EfiRuntimeServicesCode], MultU64x64(SIZE_4KB, Pages[EfiRuntimeServicesCode])));
+ DEBUG ((DEBUG_INFO, " RT_Data : %14ld Pages (%ld Bytes)\n", Pages[EfiRuntimeServicesData], MultU64x64(SIZE_4KB, Pages[EfiRuntimeServicesData])));
+ DEBUG ((DEBUG_INFO, " ACPI_Recl : %14ld Pages (%ld Bytes)\n", Pages[EfiACPIReclaimMemory], MultU64x64(SIZE_4KB, Pages[EfiACPIReclaimMemory])));
+ DEBUG ((DEBUG_INFO, " ACPI_NVS : %14ld Pages (%ld Bytes)\n", Pages[EfiACPIMemoryNVS], MultU64x64(SIZE_4KB, Pages[EfiACPIMemoryNVS])));
+ DEBUG ((DEBUG_INFO, " MMIO : %14ld Pages (%ld Bytes)\n", Pages[EfiMemoryMappedIO], MultU64x64(SIZE_4KB, Pages[EfiMemoryMappedIO])));
+ DEBUG ((DEBUG_INFO, " MMIO_Port : %14ld Pages (%ld Bytes)\n", Pages[EfiMemoryMappedIOPortSpace], MultU64x64(SIZE_4KB, Pages[EfiMemoryMappedIOPortSpace])));
+ DEBUG ((DEBUG_INFO, " PalCode : %14ld Pages (%ld Bytes)\n", Pages[EfiPalCode], MultU64x64(SIZE_4KB, Pages[EfiPalCode])));
+ DEBUG ((DEBUG_INFO, " Available : %14ld Pages (%ld Bytes)\n", Pages[EfiConventionalMemory], MultU64x64(SIZE_4KB, Pages[EfiConventionalMemory])));
+ DEBUG ((DEBUG_INFO, " Persistent: %14ld Pages (%ld Bytes)\n", Pages[EfiPersistentMemory], MultU64x64(SIZE_4KB, Pages[EfiPersistentMemory])));
+ DEBUG ((DEBUG_INFO, " -------------- \n"));
+}
+
+BOOLEAN
+IsGoodMemoryMap (
+ IN EFI_MEMORY_DESCRIPTOR *MemoryMap,
+ IN UINTN MemoryMapSize,
+ IN UINTN DescriptorSize
+ )
+{
+ EFI_MEMORY_DESCRIPTOR *Entry;
+ UINTN NumberOfEntries;
+ UINTN Index;
+ UINT64 EntryCount[EfiMaxMemoryType];
+
+ ZeroMem (EntryCount, sizeof(EntryCount));
+
+ Entry = MemoryMap;
+ NumberOfEntries = MemoryMapSize / DescriptorSize;
+ for (Index = 0; Index < NumberOfEntries; Index++) {
+ if (Entry->Type < EfiMaxMemoryType) {
+ EntryCount[Entry->Type] ++;
+ }
+ Entry = NEXT_MEMORY_DESCRIPTOR (Entry, DescriptorSize);
+ }
+ if ((EntryCount[EfiRuntimeServicesCode] > 1) ||
+ (EntryCount[EfiRuntimeServicesData] > 1) ||
+ (EntryCount[EfiACPIReclaimMemory] > 1) ||
+ (EntryCount[EfiACPIMemoryNVS] > 1) ) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+}
+
+EFI_STATUS
+TestPointDumpMemMap (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINTN MapKey;
+ UINT32 DescriptorVersion;
+ EFI_MEMORY_DESCRIPTOR *MemoryMap;
+ UINTN UefiMemoryMapSize;
+ UINTN UefiDescriptorSize;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpMemMap - Enter\n"));
+ UefiMemoryMapSize = 0;
+ MemoryMap = NULL;
+ Status = gBS->GetMemoryMap (
+ &UefiMemoryMapSize,
+ MemoryMap,
+ &MapKey,
+ &UefiDescriptorSize,
+ &DescriptorVersion
+ );
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+
+ do {
+ Status = gBS->AllocatePool (EfiBootServicesData, UefiMemoryMapSize, (VOID **)&MemoryMap);
+ ASSERT (MemoryMap != NULL);
+ if (MemoryMap == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done ;
+ }
+
+ Status = gBS->GetMemoryMap (
+ &UefiMemoryMapSize,
+ MemoryMap,
+ &MapKey,
+ &UefiDescriptorSize,
+ &DescriptorVersion
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (MemoryMap);
+ MemoryMap = NULL;
+ }
+ } while (Status == EFI_BUFFER_TOO_SMALL);
+
+ if (MemoryMap == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done ;
+ }
+
+ DumpMemoryMap (MemoryMap, UefiMemoryMapSize, UefiDescriptorSize);
+
+ Result = IsGoodMemoryMap (MemoryMap, UefiMemoryMapSize, UefiDescriptorSize);
+ if (!Result) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_END_OF_DXE_ERROR_CODE_2 TEST_POINT_END_OF_DXE TEST_POINT_BYTE2_END_OF_DXE_ERROR_STRING_2
+ );
+ Status = EFI_INVALID_PARAMETER;
+ } else {
+ Status = EFI_SUCCESS;
+ }
+
+ gBS->FreePool (MemoryMap);
+
+Done:
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpMemMap - Exit\n"));
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemoryTypeInformation.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemoryTypeInformation.c
new file mode 100644
index 0000000000..b25404a564
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemoryTypeInformation.c
@@ -0,0 +1,158 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/HobLib.h>
+
+#include <Guid/MemoryTypeInformation.h>
+
+CHAR8 *
+ShortNameOfMemoryType(
+ IN UINT32 Type
+ );
+
+VOID
+DumpMemoryTypeInfoSummary (
+ IN EFI_MEMORY_TYPE_INFORMATION *CurrentMemoryTypeInformation,
+ IN EFI_MEMORY_TYPE_INFORMATION *PreviousMemoryTypeInformation
+ )
+{
+ UINTN Index;
+ UINTN Index1;
+ EFI_BOOT_MODE BootMode;
+ UINT32 Previous;
+ UINT32 Current;
+ UINT32 Next;
+ BOOLEAN MemoryTypeInformationModified;
+
+ MemoryTypeInformationModified = FALSE;
+ BootMode = GetBootModeHob();
+
+ //
+ // Use a heuristic to adjust the Memory Type Information for the next boot
+ //
+ DEBUG ((DEBUG_INFO, "\n"));
+ DEBUG ((DEBUG_INFO, " (HOB) (ConfTabl) (Var) \n"));
+ DEBUG ((DEBUG_INFO, " Memory Previous Current Next \n"));
+ DEBUG ((DEBUG_INFO, " Type Pages Pages Pages \n"));
+ DEBUG ((DEBUG_INFO, "========== ======== ======== ========\n"));
+
+ for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {
+
+ for (Index1 = 0; CurrentMemoryTypeInformation[Index1].Type != EfiMaxMemoryType; Index1++) {
+ if (PreviousMemoryTypeInformation[Index].Type == CurrentMemoryTypeInformation[Index1].Type) {
+ break;
+ }
+ }
+ if (CurrentMemoryTypeInformation[Index1].Type == EfiMaxMemoryType) {
+ continue;
+ }
+
+ //
+ // Previous is the number of pages pre-allocated
+ // Current is the number of pages actually needed
+ //
+ Previous = PreviousMemoryTypeInformation[Index].NumberOfPages;
+ Current = CurrentMemoryTypeInformation[Index1].NumberOfPages;
+ Next = Previous;
+
+ //
+ // Inconsistent Memory Reserved across bootings may lead to S4 fail
+ // Write next varible to 125% * current when the pre-allocated memory is:
+ // 1. More than 150% of needed memory and boot mode is BOOT_WITH_DEFAULT_SETTING
+ // 2. Less than the needed memory
+ //
+ if ((Current + (Current >> 1)) < Previous) {
+ if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) {
+ Next = Current + (Current >> 2);
+ }
+ } else if (Current > Previous) {
+ Next = Current + (Current >> 2);
+ }
+ if (Next > 0 && Next < 4) {
+ Next = 4;
+ }
+
+ if (Next != Previous) {
+ PreviousMemoryTypeInformation[Index].NumberOfPages = Next;
+ MemoryTypeInformationModified = TRUE;
+ }
+
+ DEBUG ((DEBUG_INFO, ShortNameOfMemoryType(PreviousMemoryTypeInformation[Index].Type)));
+ DEBUG ((DEBUG_INFO, " %08x %08x %08x\n", Previous, Current, Next));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+
+ if (MemoryTypeInformationModified) {
+ DEBUG ((DEBUG_INFO, "MemoryTypeInformation - Modified. RESET Needed!\n"));
+ } else {
+ DEBUG ((DEBUG_INFO, "MemoryTypeInformation - Unmodified.\n"));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+}
+
+EFI_STATUS
+TestPointDumpMemoryTypeInformation (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ VOID *CurrentMemoryTypeInformation;
+ VOID *PreviousMemoryTypeInformation;
+ VOID *VariableMemoryTypeInformation;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpMemoryTypeInformation - Enter\n"));
+ CurrentMemoryTypeInformation = NULL;
+ PreviousMemoryTypeInformation = NULL;
+
+ Status = EfiGetSystemConfigurationTable (&gEfiMemoryTypeInformationGuid, &CurrentMemoryTypeInformation);
+ if (EFI_ERROR(Status)) {
+ goto Done;
+ }
+
+ GuidHob = GetFirstGuidHob (&gEfiMemoryTypeInformationGuid);
+ if (GuidHob != NULL) {
+ PreviousMemoryTypeInformation = GET_GUID_HOB_DATA(GuidHob);
+ } else {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+
+ GetVariable2 (
+ EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
+ &gEfiMemoryTypeInformationGuid,
+ &VariableMemoryTypeInformation,
+ NULL
+ );
+
+ if ((CurrentMemoryTypeInformation != NULL) && (PreviousMemoryTypeInformation != NULL)) {
+ DumpMemoryTypeInfoSummary(CurrentMemoryTypeInformation, PreviousMemoryTypeInformation);
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpMemoryTypeInformation - Exit\n"));
+
+Done:
+ if (EFI_ERROR(Status)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_2 TEST_POINT_READY_TO_BOOT TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_2
+ );
+ }
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpPci.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpPci.c
new file mode 100644
index 0000000000..b1d0ff331c
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpPci.c
@@ -0,0 +1,384 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/PciIo.h>
+#include <Protocol/PciRootBridgeIo.h>
+#include <IndustryStandard/Pci.h>
+
+#pragma pack(1)
+
+//
+// Data region after PCI configuration header(for cardbus bridge)
+//
+typedef struct {
+ UINT16 SubVendorId; // Subsystem Vendor ID
+ UINT16 SubSystemId; // Subsystem ID
+ UINT32 LegacyBase; // Optional 16-Bit PC Card Legacy
+ // Mode Base Address
+ //
+ UINT32 Data[46];
+} PCI_CARDBUS_DATA;
+
+typedef union {
+ PCI_DEVICE_HEADER_TYPE_REGION Device;
+ PCI_BRIDGE_CONTROL_REGISTER Bridge;
+ PCI_CARDBUS_CONTROL_REGISTER CardBus;
+} NON_COMMON_UNION;
+
+typedef struct {
+ PCI_DEVICE_INDEPENDENT_REGION Common;
+ NON_COMMON_UNION NonCommon;
+ UINT32 Data[48];
+} PCI_CONFIG_SPACE;
+
+#pragma pack()
+
+VOID
+DumpPciDevice (
+ IN UINT8 Bus,
+ IN UINT8 Device,
+ IN UINT8 Function,
+ IN PCI_TYPE00 *PciData
+ )
+{
+//DEBUG ((DEBUG_INFO, " 00/00/00 : [0000][0000] [00|00|00] 00000000 00000000 00000000 00000000 00000000 00000000 0000\n"));
+ DEBUG ((DEBUG_INFO, " %02x/%02x/%02x :",
+ Bus,
+ Device,
+ Function
+ ));
+ DEBUG ((DEBUG_INFO, " [%04x][%04x]",
+ PciData->Hdr.VendorId,
+ PciData->Hdr.DeviceId
+ ));
+ DEBUG ((DEBUG_INFO, " [%02x|%02x|%02x]",
+ PciData->Hdr.ClassCode[2],
+ PciData->Hdr.ClassCode[1],
+ PciData->Hdr.ClassCode[0]
+ ));
+ DEBUG ((DEBUG_INFO, " %08x %08x %08x %08x %08x %08x",
+ PciData->Device.Bar[0],
+ PciData->Device.Bar[1],
+ PciData->Device.Bar[2],
+ PciData->Device.Bar[3],
+ PciData->Device.Bar[4],
+ PciData->Device.Bar[6]
+ ));
+ DEBUG ((DEBUG_INFO, " %04x\n",
+ PciData->Hdr.Command
+ ));
+}
+
+VOID
+DumpPciBridge (
+ IN UINT8 Bus,
+ IN UINT8 Device,
+ IN UINT8 Function,
+ IN PCI_TYPE01 *PciData
+ )
+{
+//DEBUG ((DEBUG_INFO, " 00/00/00*: [0000][0000] [00|00|00] 00000000 00000000 [00|00|00] [00:00] [0000:0000] [0000:0000] [00000000:00000000] [0000:0000] 0000 0000\n"));
+ DEBUG ((DEBUG_INFO, " %02x/%02x/%02x*:",
+ Bus,
+ Device,
+ Function
+ ));
+ DEBUG ((DEBUG_INFO, " [%04x][%04x]",
+ PciData->Hdr.VendorId,
+ PciData->Hdr.DeviceId
+ ));
+ DEBUG ((DEBUG_INFO, " [%02x|%02x|%02x]",
+ PciData->Hdr.ClassCode[2],
+ PciData->Hdr.ClassCode[1],
+ PciData->Hdr.ClassCode[0]
+ ));
+ DEBUG ((DEBUG_INFO, " %08x %08x",
+ PciData->Bridge.Bar[0],
+ PciData->Bridge.Bar[1]
+ ));
+ DEBUG ((DEBUG_INFO, " [%02x|%02x|%02x]",
+ PciData->Bridge.PrimaryBus,
+ PciData->Bridge.SecondaryBus,
+ PciData->Bridge.SubordinateBus
+ ));
+ DEBUG ((DEBUG_INFO, " [00:00] [0000:0000] [0000:0000]",
+ PciData->Bridge.IoBase,
+ PciData->Bridge.IoLimit,
+ PciData->Bridge.MemoryBase,
+ PciData->Bridge.MemoryLimit,
+ PciData->Bridge.PrefetchableMemoryBase,
+ PciData->Bridge.PrefetchableMemoryLimit
+ ));
+ DEBUG ((DEBUG_INFO, " [00000000:00000000] [0000:0000]",
+ PciData->Bridge.PrefetchableBaseUpper32,
+ PciData->Bridge.PrefetchableLimitUpper32,
+ PciData->Bridge.IoBaseUpper16,
+ PciData->Bridge.IoLimitUpper16
+ ));
+ DEBUG ((DEBUG_INFO, " %04x ",
+ PciData->Bridge.BridgeControl
+ ));
+ DEBUG ((DEBUG_INFO, " %04x\n",
+ PciData->Hdr.Command
+ ));
+}
+
+/**
+ This function gets the protocol interface from the given handle, and
+ obtains its address space descriptors.
+
+ @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
+ @param[out] IoDev Handle used to access configuration space of PCI device.
+ @param[out] Descriptors Points to the address space descriptors.
+
+ @retval EFI_SUCCESS The command completed successfully
+**/
+EFI_STATUS
+PciGetProtocolAndResource (
+ IN EFI_HANDLE Handle,
+ OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev,
+ OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Get inferface from protocol
+ //
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiPciRootBridgeIoProtocolGuid,
+ (VOID**)IoDev
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Call Configuration() to get address space descriptors
+ //
+ Status = (*IoDev)->Configuration (*IoDev, (VOID**)Descriptors);
+ if (Status == EFI_UNSUPPORTED) {
+ *Descriptors = NULL;
+ return EFI_SUCCESS;
+
+ } else {
+ return Status;
+ }
+}
+
+/**
+ This function get the next bus range of given address space descriptors.
+ It also moves the pointer backward a node, to get prepared to be called
+ again.
+
+ @param[in, out] Descriptors Points to current position of a serial of address space
+ descriptors.
+ @param[out] MinBus The lower range of bus number.
+ @param[out] MaxBus The upper range of bus number.
+ @param[out] IsEnd Meet end of the serial of descriptors.
+
+ @retval EFI_SUCCESS The command completed successfully.
+**/
+EFI_STATUS
+PciGetNextBusRange (
+ IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors,
+ OUT UINT16 *MinBus,
+ OUT UINT16 *MaxBus,
+ OUT BOOLEAN *IsEnd
+ )
+{
+ *IsEnd = FALSE;
+
+ //
+ // When *Descriptors is NULL, Configuration() is not implemented, so assume
+ // range is 0~PCI_MAX_BUS
+ //
+ if ((*Descriptors) == NULL) {
+ *MinBus = 0;
+ *MaxBus = PCI_MAX_BUS;
+ return EFI_SUCCESS;
+ }
+ //
+ // *Descriptors points to one or more address space descriptors, which
+ // ends with a end tagged descriptor. Examine each of the descriptors,
+ // if a bus typed one is found and its bus range covers bus, this handle
+ // is the handle we are looking for.
+ //
+
+ while ((*Descriptors)->Desc != ACPI_END_TAG_DESCRIPTOR) {
+ if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {
+ *MinBus = (UINT16) (*Descriptors)->AddrRangeMin;
+ *MaxBus = (UINT16) (*Descriptors)->AddrRangeMax;
+ (*Descriptors)++;
+ return (EFI_SUCCESS);
+ }
+
+ (*Descriptors)++;
+ }
+
+ if ((*Descriptors)->Desc == ACPI_END_TAG_DESCRIPTOR) {
+ *IsEnd = TRUE;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+TestPointDumpPci (
+ VOID
+ )
+{
+ UINT16 Bus;
+ UINT16 Device;
+ UINT16 Func;
+ UINT64 Address;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev;
+ EFI_STATUS Status;
+ PCI_TYPE00 PciData;
+ UINTN Index;
+ EFI_HANDLE *HandleBuf;
+ UINTN HandleCount;
+ EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;
+ UINT16 MinBus;
+ UINT16 MaxBus;
+ BOOLEAN IsEnd;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpPci - Enter\n"));
+ HandleBuf = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiPciRootBridgeIoProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuf
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done ;
+ }
+
+ DEBUG ((DEBUG_INFO, " B D F* VID DID Class[CSP] Bar0 Bar1 Bus[PSS] Io[BL] Memory[BL]"));
+ DEBUG ((DEBUG_INFO, " PMemory[BL] PMemoryU[BL] IoU[BL] BriCtl Command\n"));
+
+ DEBUG ((DEBUG_INFO, " B D F VID DID Class[CSP] Bar0 Bar1 Bar2 Bar3 Bar4 Bar5 Command\n"));
+
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = PciGetProtocolAndResource (
+ HandleBuf[Index],
+ &IoDev,
+ &Descriptors
+ );
+ while (TRUE) {
+ Status = PciGetNextBusRange (&Descriptors, &MinBus, &MaxBus, &IsEnd);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ if (IsEnd) {
+ break;
+ }
+
+ for (Bus = MinBus; Bus <= MaxBus; Bus++) {
+ //
+ // For each devices, enumerate all functions it contains
+ //
+ for (Device = 0; Device <= PCI_MAX_DEVICE; Device++) {
+ //
+ // For each function, read its configuration space and print summary
+ //
+ for (Func = 0; Func <= PCI_MAX_FUNC; Func++) {
+ Address = EFI_PCI_ADDRESS (Bus, Device, Func, 0);
+ IoDev->Pci.Read (
+ IoDev,
+ EfiPciWidthUint16,
+ Address,
+ 1,
+ &PciData.Hdr.VendorId
+ );
+
+ //
+ // If VendorId = 0xffff, there does not exist a device at this
+ // location. For each device, if there is any function on it,
+ // there must be 1 function at Function 0. So if Func = 0, there
+ // will be no more functions in the same device, so we can break
+ // loop to deal with the next device.
+ //
+ if (PciData.Hdr.VendorId == 0xffff && Func == 0) {
+ break;
+ }
+
+ if (PciData.Hdr.VendorId != 0xffff) {
+ IoDev->Pci.Read (
+ IoDev,
+ EfiPciWidthUint32,
+ Address,
+ sizeof (PciData) / sizeof (UINT32),
+ &PciData
+ );
+
+ if (IS_PCI_BRIDGE(&PciData)) {
+ // Bridge
+ DumpPciBridge ((UINT8)Bus, (UINT8)Device, (UINT8)Func, (PCI_TYPE01 *)&PciData);
+ } else if (IS_CARDBUS_BRIDGE(&PciData)) {
+ // CardBus Bridge
+ } else {
+ // Device
+ DumpPciDevice ((UINT8)Bus, (UINT8)Device, (UINT8)Func, &PciData);
+ }
+
+ //
+ // If this is not a multi-function device, we can leave the loop
+ // to deal with the next device.
+ //
+ if (Func == 0 && ((PciData.Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00)) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ //
+ // If Descriptor is NULL, Configuration() returns EFI_UNSUPPRORED,
+ // we assume the bus range is 0~PCI_MAX_BUS. After enumerated all
+ // devices on all bus, we can leave loop.
+ //
+ if (Descriptors == NULL) {
+ break;
+ }
+ }
+ }
+
+Done:
+ if (HandleBuf != NULL) {
+ FreePool (HandleBuf);
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpPci - Exit\n"));
+
+ if (EFI_ERROR(Status)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_ERROR_CODE_1 TEST_POINT_PCI_ENUMERATION_DONE TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_ERROR_STRING_1
+ );
+ }
+
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpSmmInfo.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpSmmInfo.c
new file mode 100644
index 0000000000..0934038208
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpSmmInfo.c
@@ -0,0 +1,80 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Protocol/SmmAccess2.h>
+
+VOID
+DumpSmramDescriptor (
+ IN UINTN NumberOfSmmReservedRegions,
+ IN EFI_SMRAM_DESCRIPTOR *Descriptor
+ );
+
+VOID
+DumpSmramInfo (
+ VOID
+ )
+{
+}
+
+EFI_STATUS
+TestPointDumpSmmInfo (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
+ UINTN Size;
+ EFI_SMRAM_DESCRIPTOR *SmramRanges;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpSmmInfo - Enter\n"));
+
+ Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess);
+ if (EFI_ERROR (Status)) {
+ goto Done ;
+ }
+
+ Size = 0;
+ Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+
+ SmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateZeroPool (Size);
+ ASSERT (SmramRanges != NULL);
+
+ Status = SmmAccess->GetCapabilities (SmmAccess, &Size, SmramRanges);
+ ASSERT_EFI_ERROR (Status);
+
+ DEBUG ((DEBUG_INFO, "SMRAM Info\n"));
+ DumpSmramDescriptor (Size / sizeof (EFI_SMRAM_DESCRIPTOR), SmramRanges);
+
+ FreePool (SmramRanges);
+
+Done:
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpSmmInfo - Exit\n"));
+
+ if (EFI_ERROR(Status)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_ERROR_CODE_1 TEST_POINT_DXE_SMM_READY_TO_LOCK TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_ERROR_STRING_1
+ );
+ }
+
+ return Status;
+} \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpVariable.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpVariable.c
new file mode 100644
index 0000000000..4512a2385d
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpVariable.c
@@ -0,0 +1,173 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/VarCheck.h>
+
+#define INIT_NAME_BUFFER_SIZE 128
+
+CHAR8 *mAttributeShortName[] = {
+ "NV",
+ "BS",
+ "RT",
+ "HR",
+ "AU",
+ "AT",
+ "AP",
+};
+
+VOID
+DumpVarAttrName (
+ IN UINT32 Attributes
+ )
+{
+ UINTN Index;
+ BOOLEAN IsFirst;
+
+ IsFirst = TRUE;
+ DEBUG ((DEBUG_INFO, "("));
+ for (Index = 0; Index < sizeof(mAttributeShortName)/sizeof(mAttributeShortName[0]); Index++) {
+ if ((Attributes & (1 << Index)) != 0) {
+ if (!IsFirst) {
+ DEBUG ((DEBUG_INFO, "|"));
+ }
+ DEBUG ((DEBUG_INFO, mAttributeShortName[Index]));
+ if (IsFirst) {
+ IsFirst = FALSE;
+ }
+ }
+ }
+ DEBUG ((DEBUG_INFO, ")"));
+}
+
+VOID
+DumpVarProperty (
+ IN VAR_CHECK_VARIABLE_PROPERTY *VariableProperty
+ )
+{
+ if ((VariableProperty->Property & VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) != 0) {
+ DEBUG ((DEBUG_INFO, " (RO)"));
+ }
+}
+
+EFI_STATUS
+TestPointDumpVariable (
+ VOID
+ )
+{
+ CHAR16 *VariableName;
+ UINTN NameSize;
+ UINTN NameBufferSize;
+ EFI_STATUS Status;
+ EFI_GUID Guid;
+ UINTN VarSize;
+ UINT32 Attributes;
+ VOID *VarData;
+ EDKII_VAR_CHECK_PROTOCOL *VarCheck;
+ VAR_CHECK_VARIABLE_PROPERTY VariableProperty;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpVariable - Enter\n"));
+
+ Status = gBS->LocateProtocol (&gEdkiiVarCheckProtocolGuid, NULL, (VOID **)&VarCheck);
+ DEBUG ((DEBUG_INFO, "VarCheck - %r\n", Status));
+
+ Status = EFI_SUCCESS;
+ DEBUG ((DEBUG_INFO, "Variable List:\n"));
+ NameBufferSize = INIT_NAME_BUFFER_SIZE;
+ VariableName = AllocateZeroPool(NameBufferSize);
+ if (VariableName == NULL) {
+ goto Done ;
+ }
+ *VariableName = CHAR_NULL;
+
+ while (!EFI_ERROR(Status)) {
+ //
+ // Get Name/Guid
+ //
+ NameSize = NameBufferSize;
+ Status = gRT->GetNextVariableName(&NameSize, VariableName, &Guid);
+ if (Status == EFI_NOT_FOUND){
+ Status = EFI_SUCCESS;
+ break;
+ } else if (Status == EFI_BUFFER_TOO_SMALL) {
+ NameBufferSize = NameSize > NameBufferSize * 2 ? NameSize : NameBufferSize * 2;
+ if (VariableName != NULL) {
+ FreePool (VariableName);
+ }
+ VariableName = AllocateZeroPool(NameBufferSize);
+ if (VariableName == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ break;
+ }
+ NameSize = NameBufferSize;
+ Status = gRT->GetNextVariableName(&NameSize, VariableName, &Guid);
+ }
+
+ if (EFI_ERROR(Status)) {
+ break;
+ }
+
+ //
+ // Get Attributes/Size
+ //
+ VarSize = 0;
+ Attributes = 0;
+ Status = gRT->GetVariable(VariableName, &Guid, &Attributes, &VarSize, NULL);
+ if (Status == EFI_BUFFER_TOO_SMALL){
+ VarData = AllocateZeroPool (VarSize);
+ if (VarData == NULL) {
+ goto Done;
+ }
+ Status = gRT->GetVariable(VariableName, &Guid, &Attributes, &VarSize, VarData);
+ if (!EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO,
+ " Name=L\"%s\" Guid=%g Size=0x%x Attr=0x%x ",
+ VariableName,
+ &Guid,
+ VarSize,
+ Attributes
+ ));
+ DumpVarAttrName (Attributes);
+
+ if (VarCheck != NULL) {
+ Status = VarCheck->VariablePropertyGet (VariableName, &Guid, &VariableProperty);
+ if (!EFI_ERROR(Status)) {
+ DumpVarProperty (&VariableProperty);
+ }
+ }
+
+ DEBUG ((DEBUG_INFO, "\n"));
+ FreePool (VarData);
+ Status = EFI_SUCCESS;
+ }
+ }
+ }
+
+ if (VariableName != NULL) {
+ FreePool (VariableName);
+ }
+
+Done:
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpVariable - Exit\n"));
+
+ // Check - TBD
+ return EFI_SUCCESS;
+} \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c
new file mode 100644
index 0000000000..f7801bf4b2
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c
@@ -0,0 +1,335 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseMemoryLib.h>
+
+EFI_STATUS
+TestPointDumpGcd (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpMemMap (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpMemAttribute (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpPci (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpConsoleVariable (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpBootVariable (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpDevicePath (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpMemoryTypeInformation (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpAcpi (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpHsti (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpVariable (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpEsrt (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpSmmInfo (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpLoadedImage (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointPciEnumerationDone (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "======== TestPointPciEnumerationDone - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointDumpPci ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 2,
+ TEST_POINT_BYTE2_PCI_ENUMERATION_DONE
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointPciEnumerationDone - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfDxe (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfDxe - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointDumpLoadedImage ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpMemMap ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpGcd ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpConsoleVariable ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpBootVariable ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 2,
+ TEST_POINT_BYTE2_END_OF_DXE
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfDxe - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointDxeSmmReadyToLock (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "======== TestPointDxeSmmReadyToLock - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointDumpSmmInfo ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 2,
+ TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointDxeSmmReadyToLock - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBoot (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBoot - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointDumpLoadedImage ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpMemMap ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpGcd ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpDevicePath ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpConsoleVariable ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpBootVariable ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpMemoryTypeInformation ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpVariable ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ Status = TestPointDumpMemAttribute ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpAcpi ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpEsrt ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpHsti ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 2,
+ TEST_POINT_BYTE2_READY_TO_BOOT
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBoot - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointExitBootServices (
+ VOID
+ )
+{
+ DEBUG ((DEBUG_INFO, "======== TestPointExitBootServices - Enter\n"));
+
+ DEBUG ((DEBUG_INFO, "======== TestPointExitBootServices - Exit\n"));
+
+ return EFI_SUCCESS;
+}
+
+GLOBAL_REMOVE_IF_UNREFERENCED ADAPTER_INFO_PLATFORM_TEST_POINT_STRUCT mTestPointStruct = {
+ PLATFORM_TEST_POINT_VERSION,
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ {TEST_POINT_IMPLEMENTATION_ID_PLATFORM},
+ TEST_POINT_FEATURE_SIZE,
+ {0}, // FeaturesRequired
+ {0}, // FeaturesImplemented
+ {0}, // FeaturesVerified
+ 0,
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED UINT8 mFeatureImplemented[TEST_POINT_FEATURE_SIZE];
+
+/**
+ Initialize feature data
+**/
+VOID
+InitData (
+ IN UINT32 Role
+ )
+{
+ EFI_STATUS Status;
+
+ ASSERT (PcdGetSize(PcdTestPointIbvPlatformFeature) == sizeof(mFeatureImplemented));
+ CopyMem (mFeatureImplemented, PcdGetPtr(PcdTestPointIbvPlatformFeature), sizeof(mFeatureImplemented));
+
+ mTestPointStruct.Role = Role;
+ CopyMem (mTestPointStruct.FeaturesImplemented, mFeatureImplemented, sizeof(mFeatureImplemented));
+ Status = TestPointLibSetTable (
+ &mTestPointStruct,
+ sizeof(mTestPointStruct)
+ );
+ if (EFI_ERROR (Status)) {
+ if (Status != EFI_ALREADY_STARTED) {
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+}
+
+EFI_STATUS
+EFIAPI
+DxeTestPointCheckLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ InitData (PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV);
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf
new file mode 100644
index 0000000000..beec4a2193
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf
@@ -0,0 +1,86 @@
+## @file
+# Component information file for Board Init Test Library
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials are licensed and made available under
+# the terms and conditions of the BSD License which accompanies this distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeTestPointCheckLib
+ FILE_GUID = 74A1F91F-AD11-49C5-96B8-A579F4AA65F1
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TestPointCheckLib
+ CONSTRUCTOR = DxeTestPointCheckLibConstructor
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ DxeServicesTableLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ UefiLib
+ PrintLib
+ DevicePathLib
+ HobLib
+ PeCoffGetEntryPointLib
+ HstiLib
+ TestPointLib
+
+[Packages]
+ MinPlatformPkg/MinPlatformPkg.dec
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[Sources]
+ DxeTestPointCheckLib.c
+ DxeDumpGcd.c
+ DxeDumpMemMap.c
+ DxeDumpMemAttribute.c
+ DxeDumpPci.c
+ DxeDumpConsoleVariable.c
+ DxeDumpBootVariable.c
+ DxeDumpVariable.c
+ DxeDumpDevicePath.c
+ DxeDumpMemoryTypeInformation.c
+ DxeDumpAcpi.c
+ DxeDumpAcpiMadt.c
+ DxeDumpAcpiMcfg.c
+ DxeDumpAcpiHpet.c
+ DxeDumpAcpiDmar.c
+ DxeDumpAcpiWsmt.c
+ DxeDumpHsti.c
+ DxeDumpEsrt.c
+ DxeDumpLoadedImage.c
+ DxeDumpSmmInfo.c
+ PeiDumpSmramHob.c
+
+[Guids]
+ gEfiMemoryAttributesTableGuid
+ gEfiGlobalVariableGuid
+ gEfiAcpi20TableGuid
+ gEfiAcpi10TableGuid
+ gEfiMemoryTypeInformationGuid
+ gEfiSystemResourceTableGuid
+ gEfiSmmPeiSmramMemoryReserveGuid
+
+[Protocols]
+ gEfiPciIoProtocolGuid
+ gEfiPciRootBridgeIoProtocolGuid
+ gEfiSmmAccess2ProtocolGuid
+ gEdkiiVarCheckProtocolGuid
+ gEfiLoadedImageProtocolGuid
+ gEfiLoadedImageDevicePathProtocolGuid
+ gEfiDevicePathProtocolGuid
+
+[Pcd]
+ gPlatformModuleTokenSpaceGuid.PcdTestPointIbvPlatformFeature \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpFvInfo.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpFvInfo.c
new file mode 100644
index 0000000000..c32c03b2c7
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpFvInfo.c
@@ -0,0 +1,118 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiPei.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Ppi/FirmwareVolumeInfo.h>
+#include <Ppi/FirmwareVolumeInfo2.h>
+
+EFI_STATUS
+TestPointDumpFvInfo (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_PEI_PPI_DESCRIPTOR *Descriptor;
+ EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfo;
+ EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *FvInfo2;
+ UINTN Index;
+ UINTN Index2;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpFvInfo - Enter\n"));
+ DEBUG ((DEBUG_INFO, "FV Info PPI\n"));
+ for (Index = 0; ; Index++) {
+ Status = PeiServicesLocatePpi (
+ &gEfiPeiFirmwareVolumeInfoPpiGuid,
+ Index,
+ &Descriptor,
+ (VOID **)&FvInfo
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ DEBUG ((DEBUG_INFO,
+ " BA=%08x L=%08x Format={%g}",
+ (UINT32)(UINTN)FvInfo->FvInfo,
+ FvInfo->FvInfoSize,
+ &FvInfo->FvFormat,
+ FvInfo->ParentFvName,
+ FvInfo->ParentFileName
+ ));
+ if (FvInfo->ParentFvName != NULL) {
+ DEBUG ((DEBUG_INFO,
+ " ParentFv={%g}",
+ FvInfo->ParentFvName
+ ));
+ }
+ if (FvInfo->ParentFileName != NULL) {
+ DEBUG ((DEBUG_INFO,
+ " ParentFileName={%g}",
+ FvInfo->ParentFileName
+ ));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+ }
+
+ DEBUG ((DEBUG_INFO, "FV Info2 PPI\n"));
+ for (Index2 = 0; ; Index2++) {
+ Status = PeiServicesLocatePpi (
+ &gEfiPeiFirmwareVolumeInfo2PpiGuid,
+ Index2,
+ &Descriptor,
+ (VOID **)&FvInfo2
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ DEBUG ((DEBUG_INFO,
+ " BA=%08x L=%08x Format={%g}",
+ (UINT32)(UINTN)FvInfo2->FvInfo,
+ FvInfo2->FvInfoSize,
+ &FvInfo2->FvFormat,
+ FvInfo2->ParentFvName,
+ FvInfo2->ParentFileName,
+ FvInfo2->AuthenticationStatus
+ ));
+ if (FvInfo2->ParentFvName != NULL) {
+ DEBUG ((DEBUG_INFO,
+ " ParentFv={%g}",
+ FvInfo2->ParentFvName
+ ));
+ }
+ if (FvInfo2->ParentFileName != NULL) {
+ DEBUG ((DEBUG_INFO,
+ " ParentFileName={%g}",
+ FvInfo2->ParentFileName
+ ));
+ }
+ DEBUG ((DEBUG_INFO,
+ " Auth=%08x\n",
+ FvInfo2->AuthenticationStatus
+ ));
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpFvInfo - Exit\n"));
+
+ if ((Index == 0) && (Index2 == 0)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_END_OF_PEI_ERROR_CODE_3 TEST_POINT_END_OF_PEI TEST_POINT_BYTE1_END_OF_PEI_ERROR_STRING_3
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpHob.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpHob.c
new file mode 100644
index 0000000000..9ef96936c0
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpHob.c
@@ -0,0 +1,377 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiPei.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/HobLib.h>
+#include <Library/PrintLib.h>
+#include <Guid/MemoryAllocationHob.h>
+
+#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
+ EFI_RESOURCE_ATTRIBUTE_TESTED | \
+ EFI_RESOURCE_ATTRIBUTE_16_BIT_IO | \
+ EFI_RESOURCE_ATTRIBUTE_32_BIT_IO | \
+ EFI_RESOURCE_ATTRIBUTE_64_BIT_IO \
+ )
+
+#define TESTED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_TESTED)
+
+#define INITIALIZED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED)
+
+#define PRESENT_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT)
+
+CHAR8 *mMemoryTypeShortName[] = {
+ "Reserved",
+ "LoaderCode",
+ "LoaderData",
+ "BS_Code",
+ "BS_Data",
+ "RT_Code",
+ "RT_Data",
+ "Available",
+ "Unusable",
+ "ACPI_Recl",
+ "ACPI_NVS",
+ "MMIO",
+ "MMIO_Port",
+ "PalCode",
+ "Persistent",
+};
+
+CHAR8 *mResourceTypeShortName[] = {
+ "Mem",
+ "MMIO",
+ "I/O",
+ "FD",
+ "MM Port I/O",
+ "Reserved Mem",
+ "Reserved I/O",
+};
+
+CHAR8 mUnknownStr[11];
+
+CHAR8 *
+ShortNameOfMemoryType (
+ IN UINT32 Type
+ )
+{
+ if (Type < sizeof(mMemoryTypeShortName) / sizeof(mMemoryTypeShortName[0])) {
+ return mMemoryTypeShortName[Type];
+ } else {
+ AsciiSPrint(mUnknownStr, sizeof(mUnknownStr), "%08x", Type);
+ return mUnknownStr;
+ }
+}
+
+CHAR8 *
+ShortNameOfResourceType (
+ IN UINT32 Type
+ )
+{
+ if (Type < sizeof(mResourceTypeShortName) / sizeof(mResourceTypeShortName[0])) {
+ return mResourceTypeShortName[Type];
+ } else {
+ AsciiSPrint(mUnknownStr, sizeof(mUnknownStr), "%08x", Type);
+ return mUnknownStr;
+ }
+}
+
+EFI_STATUS
+DumpPhitHob (
+ IN VOID *HobList
+ )
+{
+ EFI_HOB_HANDOFF_INFO_TABLE *PhitHob;
+
+ PhitHob = HobList;
+ ASSERT(GET_HOB_TYPE(HobList) == EFI_HOB_TYPE_HANDOFF);
+ DEBUG ((DEBUG_INFO, "PHIT HOB\n"));
+ DEBUG ((DEBUG_INFO, " PhitHob - 0x%x\n", PhitHob));
+ DEBUG ((DEBUG_INFO, " BootMode - 0x%x\n", PhitHob->BootMode));
+ DEBUG ((DEBUG_INFO, " EfiMemoryTop - 0x%016lx\n", PhitHob->EfiMemoryTop));
+ DEBUG ((DEBUG_INFO, " EfiMemoryBottom - 0x%016lx\n", PhitHob->EfiMemoryBottom));
+ DEBUG ((DEBUG_INFO, " EfiFreeMemoryTop - 0x%016lx\n", PhitHob->EfiFreeMemoryTop));
+ DEBUG ((DEBUG_INFO, " EfiFreeMemoryBottom - 0x%016lx\n", PhitHob->EfiFreeMemoryBottom));
+ DEBUG ((DEBUG_INFO, " EfiEndOfHobList - 0x%lx\n", PhitHob->EfiEndOfHobList));
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+DumpCpuHob (
+ IN VOID *HobList
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_HOB_CPU *CpuHob;
+
+ DEBUG ((DEBUG_INFO, "CPU HOBs\n"));
+ for (Hob.Raw = HobList; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
+ if (GET_HOB_TYPE(Hob) == EFI_HOB_TYPE_CPU) {
+ CpuHob = Hob.Cpu;
+ DEBUG ((DEBUG_INFO,
+ " SizeOfMemorySpace=%x SizeOfIoSpace=%x\n",
+ CpuHob->SizeOfMemorySpace,
+ CpuHob->SizeOfIoSpace
+ ));
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+DumpResourceHob (
+ IN VOID *HobList
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
+
+ DEBUG ((DEBUG_INFO, "Resource Descriptor HOBs\n"));
+ for (Hob.Raw = HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
+
+ if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
+
+ ResourceHob = Hob.ResourceDescriptor;
+
+ DEBUG ((DEBUG_INFO,
+ " BA=%016lx L=%016lx Attr=%08x ",
+ ResourceHob->PhysicalStart,
+ ResourceHob->ResourceLength,
+ ResourceHob->ResourceAttribute
+ ));
+
+ DEBUG ((DEBUG_INFO, ShortNameOfResourceType(ResourceHob->ResourceType)));
+ switch (ResourceHob->ResourceType) {
+ case EFI_RESOURCE_SYSTEM_MEMORY:
+ if ((ResourceHob->ResourceAttribute & EFI_RESOURCE_ATTRIBUTE_PERSISTENT) != 0) {
+ DEBUG ((DEBUG_INFO, " (Persistent)"));
+ } else if ((ResourceHob->ResourceAttribute & EFI_RESOURCE_ATTRIBUTE_MORE_RELIABLE) != 0) {
+ DEBUG ((DEBUG_INFO, " (MoreReliable)"));
+ } else if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES) {
+ DEBUG ((DEBUG_INFO, " (Tested)"));
+ } else if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == INITIALIZED_MEMORY_ATTRIBUTES) {
+ DEBUG ((DEBUG_INFO, " (Init)"));
+ } else if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == PRESENT_MEMORY_ATTRIBUTES) {
+ DEBUG ((DEBUG_INFO, " (Present)"));
+ } else {
+ DEBUG ((DEBUG_INFO, " (Unknown)"));
+ }
+ break;
+ default:
+ break;
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+DumpFvHob (
+ IN VOID *HobList
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
+ EFI_HOB_FIRMWARE_VOLUME2 *FirmwareVolume2Hob;
+ BOOLEAN Found;
+
+ Found = FALSE;
+ DEBUG ((DEBUG_INFO, "FV HOBs\n"));
+ for (Hob.Raw = HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
+ if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV) {
+
+ FirmwareVolumeHob = Hob.FirmwareVolume;
+
+ DEBUG ((DEBUG_INFO,
+ " BA=%016lx L=%016lx\n",
+ FirmwareVolumeHob->BaseAddress,
+ FirmwareVolumeHob->Length
+ ));
+ Found = TRUE;
+ }
+ }
+
+ DEBUG ((DEBUG_INFO, "FV2 HOBs\n"));
+ for (Hob.Raw = HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
+ if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV2) {
+
+ FirmwareVolume2Hob = Hob.FirmwareVolume2;
+
+ DEBUG ((DEBUG_INFO,
+ " BA=%016lx L=%016lx Fv={%g} File={%g}\n",
+ FirmwareVolume2Hob->BaseAddress,
+ FirmwareVolume2Hob->Length,
+ &FirmwareVolume2Hob->FvName,
+ &FirmwareVolume2Hob->FileName
+ ));
+ Found = TRUE;
+ }
+ }
+
+ if (!Found) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_END_OF_PEI_ERROR_CODE_3 TEST_POINT_END_OF_PEI TEST_POINT_BYTE1_END_OF_PEI_ERROR_STRING_3
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+DumpMemoryAllocationHob (
+ IN VOID *HobList
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_HOB_MEMORY_ALLOCATION *MemoryHob;
+
+ DEBUG ((DEBUG_INFO, "Memory Allocation HOBs\n"));
+ for (Hob.Raw = HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
+ if (GET_HOB_TYPE(Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) {
+
+ MemoryHob = Hob.MemoryAllocation;
+
+ DEBUG ((DEBUG_INFO,
+ " BA=%016lx L=%016lx ",
+ MemoryHob->AllocDescriptor.MemoryBaseAddress,
+ MemoryHob->AllocDescriptor.MemoryLength
+ ));
+ DEBUG ((DEBUG_INFO, ShortNameOfMemoryType(MemoryHob->AllocDescriptor.MemoryType)));
+ if (!IsZeroGuid(&MemoryHob->AllocDescriptor.Name)) {
+ if (CompareGuid(&gEfiHobMemoryAllocStackGuid, &MemoryHob->AllocDescriptor.Name)) {
+ DEBUG ((DEBUG_INFO,
+ " {Stack}",
+ &MemoryHob->AllocDescriptor.Name
+ ));
+ } else if (CompareGuid(&gEfiHobMemoryAllocBspStoreGuid, &MemoryHob->AllocDescriptor.Name)) {
+ DEBUG ((DEBUG_INFO,
+ " {BspStore}",
+ &MemoryHob->AllocDescriptor.Name
+ ));
+ } else if (CompareGuid(&gEfiHobMemoryAllocModuleGuid, &MemoryHob->AllocDescriptor.Name)) {
+ DEBUG ((DEBUG_INFO,
+ " {Module=%g,Entry=0x%lx}",
+ &((EFI_HOB_MEMORY_ALLOCATION_MODULE *)MemoryHob)->ModuleName,
+ ((EFI_HOB_MEMORY_ALLOCATION_MODULE *)MemoryHob)->EntryPoint
+ ));
+ } else {
+ DEBUG ((DEBUG_INFO,
+ " {%g}",
+ &MemoryHob->AllocDescriptor.Name
+ ));
+ }
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+DumpGuidHob (
+ IN VOID *HobList
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ DEBUG ((DEBUG_INFO, "GUID HOBs\n"));
+ for (Hob.Raw = HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
+ if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_GUID_EXTENSION) {
+
+ GuidHob = Hob.Guid;
+
+ DEBUG ((DEBUG_INFO,
+ " GUID=%g DataSize=0x%x\n",
+ &GuidHob->Name,
+ GET_GUID_HOB_DATA_SIZE(GuidHob)
+ ));
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+TestPointDumpHob (
+ IN BOOLEAN PhitHobOnly
+ )
+{
+ VOID *HobList;
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpHob - Enter\n"));
+ //
+ // Get Hob list
+ //
+ HobList = GetHobList ();
+
+ Result = TRUE;
+
+ Status = DumpPhitHob (HobList);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ if (PhitHobOnly) {
+ goto Done ;
+ }
+
+ Status = DumpCpuHob (HobList);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ Status = DumpResourceHob (HobList);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ Status = DumpFvHob (HobList);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ Status = DumpMemoryAllocationHob (HobList);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ Status = DumpGuidHob (HobList);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+Done:
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpHob - Exit\n"));
+
+ if (!Result) {
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
+
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpMtrr.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpMtrr.c
new file mode 100644
index 0000000000..e50e10b0d5
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpMtrr.c
@@ -0,0 +1,77 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiPei.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MtrrLib.h>
+
+EFI_STATUS
+TestPointDumpMtrr (
+ IN BOOLEAN IsForDxe
+ )
+{
+ MTRR_SETTINGS LocalMtrrs;
+ MTRR_SETTINGS *Mtrrs;
+ UINTN Index;
+ UINTN VariableMtrrCount;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpMtrr - Enter\n"));
+
+ MtrrGetAllMtrrs (&LocalMtrrs);
+ Mtrrs = &LocalMtrrs;
+ DEBUG ((DEBUG_INFO, "MTRR Default Type: %016lx\n", Mtrrs->MtrrDefType));
+ for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) {
+ DEBUG ((DEBUG_INFO, "Fixed MTRR[%02d] : %016lx\n", Index, Mtrrs->Fixed.Mtrr[Index]));
+ }
+
+ VariableMtrrCount = GetVariableMtrrCount ();
+ for (Index = 0; Index < VariableMtrrCount; Index++) {
+ DEBUG ((DEBUG_INFO, "Variable MTRR[%02d]: Base=%016lx Mask=%016lx\n",
+ Index,
+ Mtrrs->Variables.Mtrr[Index].Base,
+ Mtrrs->Variables.Mtrr[Index].Mask
+ ));
+ }
+ DEBUG ((DEBUG_INFO, "\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpMtrr - Exit\n"));
+
+ // Check - TBD
+ if (IsForDxe) {
+ Result = TRUE;
+ } else {
+ Result = TRUE;
+ }
+
+ if (!Result) {
+ if (IsForDxe) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_ERROR_CODE_2 TEST_POINT_END_OF_PEI TEST_POINT_BYTE1_MEMORY_DISCOVERED_ERROR_STRING_2
+ );
+ } else {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE,
+ NULL,
+ TEST_POINT_BYTE1_END_OF_PEI_ERROR_CODE_2 TEST_POINT_MEMORY_DISCOVERED TEST_POINT_BYTE1_END_OF_PEI_ERROR_STRING_2
+ );
+ }
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpSmramHob.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpSmramHob.c
new file mode 100644
index 0000000000..a8e2f91679
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpSmramHob.c
@@ -0,0 +1,95 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiPei.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/HobLib.h>
+#include <Guid/SmramMemoryReserve.h>
+
+CHAR8 *mSmramStateName[] = {
+ "Open",
+ "Closed",
+ "Locked",
+ "Cacheable",
+ "Allocated",
+ "NeedTest",
+ "NeedEccInit",
+};
+
+VOID
+DumpSmramDescriptor (
+ IN UINTN NumberOfSmmReservedRegions,
+ IN EFI_SMRAM_DESCRIPTOR *Descriptor
+ )
+{
+ UINTN Index;
+ UINTN BitIndex;
+
+ for (Index = 0; Index < NumberOfSmmReservedRegions; Index++) {
+ DEBUG ((DEBUG_INFO,
+ " BA=%016lx (A=%016lx) L=%016lx State=%016lx",
+ Descriptor[Index].PhysicalStart,
+ Descriptor[Index].CpuStart,
+ Descriptor[Index].PhysicalSize,
+ Descriptor[Index].RegionState
+ ));
+ DEBUG ((DEBUG_INFO, " ("));
+ for (BitIndex = 0; BitIndex < sizeof(mSmramStateName)/sizeof(mSmramStateName[0]); BitIndex++) {
+ if ((Descriptor[Index].RegionState & LShiftU64 (1, BitIndex)) != 0) {
+ DEBUG ((DEBUG_INFO, mSmramStateName[BitIndex]));
+ DEBUG ((DEBUG_INFO, ","));
+ }
+ }
+ DEBUG ((DEBUG_INFO, ")\n"));
+ }
+}
+
+EFI_STATUS
+TestPointDumpSmramHob (
+ VOID
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *SmramHobDescriptorBlock;
+ BOOLEAN Found;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpSmramHob - Enter\n"));
+ Hob.Raw = GetHobList ();
+ DEBUG ((DEBUG_INFO, "SMRAM HOB\n"));
+ while (!END_OF_HOB_LIST (Hob)) {
+ if (Hob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) {
+ if (CompareGuid (&Hob.Guid->Name, &gEfiSmmPeiSmramMemoryReserveGuid)) {
+ SmramHobDescriptorBlock = (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *) (Hob.Guid + 1);
+ DumpSmramDescriptor (SmramHobDescriptorBlock->NumberOfSmmReservedRegions, SmramHobDescriptorBlock->Descriptor);
+ Found = TRUE;
+ break;
+ }
+ }
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpSmramHob - Exit\n"));
+
+ if (!Found) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_ERROR_CODE_3 TEST_POINT_MEMORY_DISCOVERED TEST_POINT_BYTE1_MEMORY_DISCOVERED_ERROR_STRING_3
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.c
new file mode 100644
index 0000000000..754771eafd
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.c
@@ -0,0 +1,204 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiPei.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+
+EFI_STATUS
+TestPointDumpMtrr (
+ IN BOOLEAN IsForDxe
+ );
+
+EFI_STATUS
+TestPointDumpHob (
+ IN BOOLEAN PhitHobOnly
+ );
+
+EFI_STATUS
+TestPointDumpFvInfo (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpSmramHob (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointDebugInitDone (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "======== TestPointDebugInitDone - Enter\n"));
+ DEBUG ((DEBUG_INFO, "!!! DebugInitialized !!!\n"));
+
+ Result = TRUE;
+ Status = TestPointDumpHob (TRUE);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 1,
+ TEST_POINT_BYTE1_DEBUG_INIT_DONE
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointDebugInitDone - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointMemoryDiscovered (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "======== TestPointMemoryDiscovered - Enter\n"));
+ Result = TRUE;
+ Status = TestPointDumpMtrr (FALSE);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpHob (FALSE);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpFvInfo ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpSmramHob ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 1,
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointMemoryDiscovered - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfPei (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfPei - Enter\n"));
+ Result = TRUE;
+ Status = TestPointDumpMtrr (TRUE);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpHob (FALSE);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpFvInfo ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpSmramHob ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 1,
+ TEST_POINT_BYTE1_END_OF_PEI
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfPei - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+GLOBAL_REMOVE_IF_UNREFERENCED ADAPTER_INFO_PLATFORM_TEST_POINT_STRUCT mTestPointStruct = {
+ PLATFORM_TEST_POINT_VERSION,
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ {TEST_POINT_IMPLEMENTATION_ID_PLATFORM},
+ TEST_POINT_FEATURE_SIZE,
+ {0}, // FeaturesRequired
+ {0}, // FeaturesImplemented
+ {0}, // FeaturesVerified
+ 0,
+};
+
+/**
+ Initialize feature data
+**/
+VOID
+InitData (
+ IN UINT32 Role
+ )
+{
+ EFI_STATUS Status;
+ UINT8 FeatureImplemented[TEST_POINT_FEATURE_SIZE];
+ ADAPTER_INFO_PLATFORM_TEST_POINT_STRUCT TestPointStruct;
+
+ ASSERT (PcdGetSize(PcdTestPointIbvPlatformFeature) == sizeof(FeatureImplemented));
+ CopyMem (FeatureImplemented, PcdGetPtr(PcdTestPointIbvPlatformFeature), sizeof(FeatureImplemented));
+
+ CopyMem (&TestPointStruct, &mTestPointStruct, sizeof(TestPointStruct));
+ TestPointStruct.Role = Role;
+ CopyMem (TestPointStruct.FeaturesImplemented, FeatureImplemented, sizeof(FeatureImplemented));
+ Status = TestPointLibSetTable (
+ &TestPointStruct,
+ sizeof(TestPointStruct)
+ );
+ if (EFI_ERROR (Status)) {
+ if (Status != EFI_ALREADY_STARTED) {
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+}
+
+EFI_STATUS
+EFIAPI
+PeiTestPointCheckLibConstructor (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ InitData (PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV);
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.inf
new file mode 100644
index 0000000000..11b4ce6756
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.inf
@@ -0,0 +1,58 @@
+## @file
+# Component information file for Board Init Test Library
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials are licensed and made available under
+# the terms and conditions of the BSD License which accompanies this distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiTestPointCheckLib
+ FILE_GUID = 2EBA7FD0-1AAC-4DCC-B42A-C12905A61133
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TestPointCheckLib
+ CONSTRUCTOR = PeiTestPointCheckLibConstructor
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ BaseMemoryLib
+ MtrrLib
+ HobLib
+ PrintLib
+ PeiServicesLib
+ TestPointLib
+
+[Packages]
+ MinPlatformPkg/MinPlatformPkg.dec
+ MdePkg/MdePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
+
+[Sources]
+ PeiTestPointCheckLib.c
+ PeiDumpMtrr.c
+ PeiDumpHob.c
+ PeiDumpFvInfo.c
+ PeiDumpSmramHob.c
+
+[Pcd]
+ gPlatformModuleTokenSpaceGuid.PcdTestPointIbvPlatformFeature
+
+[Guids]
+ gEfiHobMemoryAllocStackGuid
+ gEfiHobMemoryAllocBspStoreGuid
+ gEfiHobMemoryAllocModuleGuid
+ gEfiSmmPeiSmramMemoryReserveGuid
+
+[Ppis]
+ gEfiPeiFirmwareVolumeInfoPpiGuid
+ gEfiPeiFirmwareVolumeInfo2PpiGuid \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecDumpCpuInfo.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecDumpCpuInfo.c
new file mode 100644
index 0000000000..9ec3044353
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecDumpCpuInfo.c
@@ -0,0 +1,39 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiPei.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/DebugLib.h>
+#include <Register/Cpuid.h>
+#include <Register/Msr.h>
+
+VOID
+TestPointDumpCpuInfo (
+ VOID
+ )
+{
+ UINT32 RegEax;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpCpuInfo - Enter\n"));
+
+ DEBUG((DEBUG_INFO, "CPU info\n"));
+ AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, NULL);
+ DEBUG((DEBUG_INFO, " CPUID = 0x%08x\n", RegEax));
+
+ DEBUG((DEBUG_INFO, " Microcode ID (0x%08x) = 0x%016lx\n", MSR_IA32_BIOS_SIGN_ID, AsmReadMsr64 (MSR_IA32_BIOS_SIGN_ID)));
+ DEBUG((DEBUG_INFO, " Platform ID (0x%08x) = 0x%016lx\n", MSR_IA32_PLATFORM_ID, AsmReadMsr64 (MSR_IA32_PLATFORM_ID)));
+ //DEBUG((DEBUG_INFO, " PLATFORM_INFO (0x%08x) = 0x%016lx\n", MSR_NEHALEM_PLATFORM_INFO, AsmReadMsr64 (MSR_NEHALEM_PLATFORM_INFO)));
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpCpuInfo - Exit\n"));
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.c
new file mode 100644
index 0000000000..8d10a255e1
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.c
@@ -0,0 +1,40 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/DebugLib.h>
+
+VOID
+TestPointDumpCpuInfo (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointTempMemoryInitDone (
+ IN VOID *TempRamStart,
+ IN VOID *TempRamEnd
+ )
+{
+ DEBUG ((DEBUG_INFO, "======== TestPointTempMemoryInitDone - Enter\n"));
+
+ DEBUG ((DEBUG_INFO, "TempRamStart - 0x%08x\n", TempRamStart));
+ DEBUG ((DEBUG_INFO, "TempRamEnd - 0x%08x\n", TempRamEnd));
+
+ TestPointDumpCpuInfo ();
+
+ DEBUG ((DEBUG_INFO, "======== TestPointTempMemoryInitDone - Exit\n"));
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf
new file mode 100644
index 0000000000..c7445d9222
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf
@@ -0,0 +1,37 @@
+## @file
+# Component information file for Board Init Test Library
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials are licensed and made available under
+# the terms and conditions of the BSD License which accompanies this distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SecTestPointCheckLib
+ FILE_GUID = 1BC3BD18-CDB3-4475-95B1-B2A5F4F026E3
+ MODULE_TYPE = SEC
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TestPointCheckLib
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+
+[Packages]
+ MinPlatformPkg/MinPlatformPkg.dec
+ MdePkg/MdePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
+
+[Sources]
+ SecTestPointCheckLib.c
+ SecDumpCpuInfo.c
+
+[Pcd]
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpLoadedImage.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpLoadedImage.c
new file mode 100644
index 0000000000..63b20edc6a
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpLoadedImage.c
@@ -0,0 +1,111 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiSmm.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/PeCoffGetEntryPointLib.h>
+#include <Protocol/LoadedImage.h>
+#include <Protocol/DevicePath.h>
+
+VOID
+DumpLoadedImage (
+ IN UINTN Index,
+ IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath
+ );
+
+EFI_STATUS
+TestPointDumpSmmLoadedImage (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ UINTN Index;
+ UINTN HandleBufSize;
+ EFI_HANDLE *HandleBuf;
+ UINTN HandleCount;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpSmmLoadedImage - Enter\n"));
+ HandleBuf = NULL;
+ HandleBufSize = 0;
+ Status = gSmst->SmmLocateHandle (
+ ByProtocol,
+ &gEfiLoadedImageProtocolGuid,
+ NULL,
+ &HandleBufSize,
+ HandleBuf
+ );
+ if (Status != EFI_BUFFER_TOO_SMALL) {
+ goto Done ;
+ }
+ HandleBuf = AllocateZeroPool (HandleBufSize);
+ if (HandleBuf == NULL) {
+ goto Done ;
+ }
+ Status = gSmst->SmmLocateHandle (
+ ByProtocol,
+ &gEfiLoadedImageProtocolGuid,
+ NULL,
+ &HandleBufSize,
+ HandleBuf
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done ;
+ }
+ HandleCount = HandleBufSize / sizeof(EFI_HANDLE);
+
+ DEBUG ((DEBUG_INFO, "SmmLoadedImage (%d):\n", HandleCount));
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gSmst->SmmHandleProtocol (
+ HandleBuf[Index],
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
+ if (EFI_ERROR(Status)) {
+ continue;
+ }
+
+ Status = gSmst->SmmHandleProtocol (LoadedImage->DeviceHandle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath);
+ if (EFI_ERROR(Status)) {
+ DevicePath = NULL;
+ }
+
+ Status = gSmst->SmmHandleProtocol (HandleBuf[Index], &gEfiLoadedImageDevicePathProtocolGuid, (VOID **)&LoadedImageDevicePath);
+ if (EFI_ERROR(Status)) {
+ LoadedImageDevicePath = NULL;
+ }
+
+ DumpLoadedImage (Index, LoadedImage, DevicePath, LoadedImageDevicePath);
+ }
+
+Done:
+
+ if (HandleBuf != NULL) {
+ FreePool (HandleBuf);
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpSmmLoadedImage - Exit\n"));
+
+ // Check - TBD
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpMemAttribute.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpMemAttribute.c
new file mode 100644
index 0000000000..bf7008c160
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpMemAttribute.c
@@ -0,0 +1,86 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiSmm.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Guid/MemoryAttributesTable.h>
+#include <Guid/PiSmmMemoryAttributesTable.h>
+
+VOID
+DumpMemoryAttributesTable (
+ IN EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable
+ );
+
+/**
+ Retrieves a pointer to the system configuration table from the SMM System Table
+ based on a specified GUID.
+
+ @param[in] TableGuid The pointer to table's GUID type.
+ @param[out] Table The pointer to the table associated with TableGuid in the EFI System Table.
+
+ @retval EFI_SUCCESS A configuration table matching TableGuid was found.
+ @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found.
+
+**/
+EFI_STATUS
+EFIAPI
+SmmGetSystemConfigurationTable (
+ IN EFI_GUID *TableGuid,
+ OUT VOID **Table
+ )
+{
+ UINTN Index;
+
+ ASSERT (TableGuid != NULL);
+ ASSERT (Table != NULL);
+
+ *Table = NULL;
+ for (Index = 0; Index < gSmst->NumberOfTableEntries; Index++) {
+ if (CompareGuid (TableGuid, &(gSmst->SmmConfigurationTable[Index].VendorGuid))) {
+ *Table = gSmst->SmmConfigurationTable[Index].VendorTable;
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+TestPointDumpSmmMemAttribute (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *MemoryAttributesTable;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpSmmMemAttribute - Enter\n"));
+ Status = SmmGetSystemConfigurationTable (&gEdkiiPiSmmMemoryAttributesTableGuid, (VOID **)&MemoryAttributesTable);
+ if (!EFI_ERROR (Status)) {
+ DumpMemoryAttributesTable((EFI_MEMORY_ATTRIBUTES_TABLE *)MemoryAttributesTable);
+ } else {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_SMM_READY_TO_LOCK_ERROR_CODE_1 TEST_POINT_SMM_READY_TO_LOCK TEST_POINT_BYTE2_SMM_READY_TO_LOCK_ERROR_STRING_1
+ );
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpSmmMemAttribute - Exit\n"));
+
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpSmrr.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpSmrr.c
new file mode 100644
index 0000000000..f10db06574
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpSmrr.c
@@ -0,0 +1,125 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <PiSmm.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+
+#include <Register/Cpuid.h>
+#include <Register/Msr.h>
+
+//
+// Machine Specific Registers (MSRs)
+//
+#define SMM_FEATURES_LIB_IA32_MTRR_CAP 0x0FE
+#define SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE 0x1F2
+#define SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK 0x1F3
+#define SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE 0x0A0
+#define SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK 0x0A1
+
+BOOLEAN mSmrrSupported = FALSE;
+//
+// Set default value to assume IA-32 Architectural MSRs are used
+//
+UINT32 mSmrrPhysBaseMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE;
+UINT32 mSmrrPhysMaskMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK;
+
+EFI_STATUS
+TestPointDumpSmrr (
+ VOID
+ )
+{
+ UINT64 SmrrBase;
+ UINT64 SmrrMask;
+
+ UINT32 RegEax;
+ UINT32 RegEdx;
+ UINTN FamilyId;
+ UINTN ModelId;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpSmrr - Enter\n"));
+
+ //
+ // Retrieve CPU Family and Model
+ //
+ AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, &RegEdx);
+ FamilyId = (RegEax >> 8) & 0xf;
+ ModelId = (RegEax >> 4) & 0xf;
+ if (FamilyId == 0x06 || FamilyId == 0x0f) {
+ ModelId = ModelId | ((RegEax >> 12) & 0xf0);
+ }
+
+ //
+ // Check CPUID(CPUID_VERSION_INFO).EDX[12] for MTRR capability
+ //
+ if ((RegEdx & BIT12) != 0) {
+ //
+ // Check MTRR_CAP MSR bit 11 for SMRR support
+ //
+ if ((AsmReadMsr64 (SMM_FEATURES_LIB_IA32_MTRR_CAP) & BIT11) != 0) {
+ mSmrrSupported = TRUE;
+ }
+ }
+
+ //
+ // Intel(R) 64 and IA-32 Architectures Software Developer's Manual
+ // Volume 3C, Section 35.3 MSRs in the Intel(R) Atom(TM) Processor Family
+ //
+ // If CPU Family/Model is 06_1CH, 06_26H, 06_27H, 06_35H or 06_36H, then
+ // SMRR Physical Base and SMM Physical Mask MSRs are not available.
+ //
+ if (FamilyId == 0x06) {
+ if (ModelId == 0x1C || ModelId == 0x26 || ModelId == 0x27 || ModelId == 0x35 || ModelId == 0x36) {
+ mSmrrSupported = FALSE;
+ }
+ }
+
+ //
+ // Intel(R) 64 and IA-32 Architectures Software Developer's Manual
+ // Volume 3C, Section 35.2 MSRs in the Intel(R) Core(TM) 2 Processor Family
+ //
+ // If CPU Family/Model is 06_0F or 06_17, then use Intel(R) Core(TM) 2
+ // Processor Family MSRs
+ //
+ if (FamilyId == 0x06) {
+ if (ModelId == 0x17 || ModelId == 0x0f) {
+ mSmrrPhysBaseMsr = SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE;
+ mSmrrPhysMaskMsr = SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK;
+ }
+ }
+
+ if (mSmrrSupported) {
+ SmrrBase = AsmReadMsr64 (mSmrrPhysBaseMsr);
+ SmrrMask = AsmReadMsr64 (mSmrrPhysMaskMsr);
+ DEBUG ((DEBUG_INFO, "SMRR : Base=%016lx Make=%016lx\n", SmrrBase, SmrrMask));
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpSmrr - Exit\n"));
+
+ // Check - TBD
+ Result = TRUE;
+
+ if (!Result) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_SMM_READY_TO_LOCK_ERROR_CODE_2 TEST_POINT_SMM_READY_TO_LOCK TEST_POINT_BYTE2_SMM_READY_TO_LOCK_ERROR_STRING_2
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c
new file mode 100644
index 0000000000..e99fefa386
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c
@@ -0,0 +1,172 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiSmm.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+
+EFI_STATUS
+TestPointDumpSmrr (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpSmmLoadedImage (
+ VOID
+ );
+
+EFI_STATUS
+TestPointDumpSmmMemAttribute (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointSmmEndOfDxe (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmEndOfDxe - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointDumpSmmLoadedImage ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 3,
+ TEST_POINT_BYTE3_SMM_END_OF_DXE
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmEndOfDxe - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointSmmReadyToLock (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToLock - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointDumpSmrr ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ Status = TestPointDumpSmmMemAttribute ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 3,
+ TEST_POINT_BYTE3_SMM_READY_TO_LOCK
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToLock - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointSmmReadyToBoot (
+ VOID
+ )
+{
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToBoot - Enter\n"));
+
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToBoot - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointSmmExitBootServices (
+ VOID
+ )
+{
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmExitBootServices - Enter\n"));
+
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmExitBootServices - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+GLOBAL_REMOVE_IF_UNREFERENCED ADAPTER_INFO_PLATFORM_TEST_POINT_STRUCT mTestPointStruct = {
+ PLATFORM_TEST_POINT_VERSION,
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ {TEST_POINT_IMPLEMENTATION_ID_PLATFORM},
+ TEST_POINT_FEATURE_SIZE,
+ {0}, // FeaturesRequired
+ {0}, // FeaturesImplemented
+ {0}, // FeaturesVerified
+ 0,
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED UINT8 mFeatureImplemented[TEST_POINT_FEATURE_SIZE];
+
+/**
+ Initialize feature data
+**/
+VOID
+InitData (
+ IN UINT32 Role
+ )
+{
+ EFI_STATUS Status;
+
+ ASSERT (PcdGetSize(PcdTestPointIbvPlatformFeature) == sizeof(mFeatureImplemented));
+ CopyMem (mFeatureImplemented, PcdGetPtr(PcdTestPointIbvPlatformFeature), sizeof(mFeatureImplemented));
+
+ mTestPointStruct.Role = Role;
+ CopyMem (mTestPointStruct.FeaturesImplemented, mFeatureImplemented, sizeof(mFeatureImplemented));
+ Status = TestPointLibSetTable (
+ &mTestPointStruct,
+ sizeof(mTestPointStruct)
+ );
+ if (EFI_ERROR (Status)) {
+ if (Status != EFI_ALREADY_STARTED) {
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+}
+
+EFI_STATUS
+EFIAPI
+SmmTestPointCheckLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ InitData (PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV);
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf
new file mode 100644
index 0000000000..f17c96cecb
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf
@@ -0,0 +1,59 @@
+## @file
+# Component information file for Board Init Test Library
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials are licensed and made available under
+# the terms and conditions of the BSD License which accompanies this distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SmmTestPointCheckLib
+ FILE_GUID = 74A1F91F-AD11-49C5-96B8-A579F4AA65F1
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TestPointCheckLib
+ CONSTRUCTOR = SmmTestPointCheckLibConstructor
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ SmmServicesTableLib
+ MemoryAllocationLib
+ DevicePathLib
+ PeCoffGetEntryPointLib
+ TestPointLib
+
+[Packages]
+ MinPlatformPkg/MinPlatformPkg.dec
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
+
+[Sources]
+ SmmTestPointCheckLib.c
+ SmmDumpMemAttribute.c
+ DxeDumpMemAttribute.c
+ DxeDumpMemMap.c
+ SmmDumpLoadedImage.c
+ DxeDumpLoadedImage.c
+ SmmDumpSmrr.c
+
+[Pcd]
+ gPlatformModuleTokenSpaceGuid.PcdTestPointIbvPlatformFeature
+
+[Guids]
+ gEdkiiPiSmmMemoryAttributesTableGuid
+ gEfiMemoryAttributesTableGuid
+
+[Protocols]
+ gEfiLoadedImageProtocolGuid
+ gEfiLoadedImageDevicePathProtocolGuid
+ gEfiDevicePathProtocolGuid
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c
new file mode 100644
index 0000000000..db932318b7
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c
@@ -0,0 +1,133 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <Library/TestPointCheckLib.h>
+
+EFI_STATUS
+EFIAPI
+TestPointTempMemoryInitDone (
+ IN VOID *TempRamStart,
+ IN VOID *TempRamEnd
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointDebugInitDone (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointMemoryDiscovered (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfPei (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointPciEnumerationDone (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfDxe (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointDxeSmmReadyToLock (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBoots (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointExitBootServices (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointSmmEndOfDxe (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointSmmReadyToLock (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointSmmReadyToBoot (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointSmmExitBootServices (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.inf
new file mode 100644
index 0000000000..9801c2d68f
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.inf
@@ -0,0 +1,32 @@
+## @file
+# Component information file for Board Init Test Library
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials are licensed and made available under
+# the terms and conditions of the BSD License which accompanies this distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TestPointCheckLibNull
+ FILE_GUID = 657A478B-16B9-4B6D-9C41-BEF86197BDF4
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TestPointCheckLib
+
+[LibraryClasses]
+ BaseLib
+
+[Packages]
+ MinPlatformPkg/MinPlatformPkg.dec
+ MdePkg/MdePkg.dec
+
+[Sources]
+ TestPointCheckLibNull.c
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.c
new file mode 100644
index 0000000000..40474cd4f2
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.c
@@ -0,0 +1,611 @@
+/** @file
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "DxeTestPoint.h"
+
+/**
+ Find TestPoint table in AIP protocol, and return the data.
+ This API will return the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param TestPointData TestPoint data. This buffer is allocated by callee, and it
+ is the responsibility of the caller to free it after
+ using it.
+ @param TestPointSize TestPoint size
+
+ @return Aip The AIP protocol having this TestPoint.
+ @return NULL There is not TestPoint table with the Role and ImplementationID published in system.
+**/
+VOID *
+InternalTestPointFindAip (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID OPTIONAL,
+ OUT VOID **TestPointData OPTIONAL,
+ OUT UINTN *TestPointSize OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ UINTN NoHandles;
+ EFI_HANDLE *Handles;
+ UINTN Index;
+ EFI_GUID *InfoTypesBuffer;
+ UINTN InfoTypesBufferCount;
+ UINTN InfoTypesIndex;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *AipCandidate;
+ VOID *InformationBlock;
+ UINTN InformationBlockSize;
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiAdapterInformationProtocolGuid,
+ NULL,
+ &NoHandles,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ TestPoint = NULL;
+ Aip = NULL;
+ InformationBlock = NULL;
+ InformationBlockSize = 0;
+ for (Index = 0; Index < NoHandles; Index++) {
+ Status = gBS->HandleProtocol (
+ Handles[Index],
+ &gEfiAdapterInformationProtocolGuid,
+ (VOID **)&Aip
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ //
+ // Check AIP
+ //
+ Status = Aip->GetSupportedTypes (
+ Aip,
+ &InfoTypesBuffer,
+ &InfoTypesBufferCount
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ AipCandidate = NULL;
+ for (InfoTypesIndex = 0; InfoTypesIndex < InfoTypesBufferCount; InfoTypesIndex++) {
+ if (CompareGuid (&InfoTypesBuffer[InfoTypesIndex], &gAdapterInfoPlatformTestPointGuid)) {
+ AipCandidate = Aip;
+ break;
+ }
+ }
+ FreePool (InfoTypesBuffer);
+
+ if (AipCandidate == NULL) {
+ continue;
+ }
+
+ //
+ // Check Role
+ //
+ Aip = AipCandidate;
+ Status = Aip->GetInformation (
+ Aip,
+ &gAdapterInfoPlatformTestPointGuid,
+ &InformationBlock,
+ &InformationBlockSize
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ TestPoint = InformationBlock;
+ if ((TestPoint->Role == Role) &&
+ ((ImplementationID == NULL) || (StrCmp (ImplementationID, TestPoint->ImplementationID) == 0))) {
+ break;
+ } else {
+ TestPoint = NULL;
+ FreePool (InformationBlock);
+ continue;
+ }
+ }
+ FreePool (Handles);
+
+ if (TestPoint == NULL) {
+ return NULL;
+ }
+
+ if (TestPointData != NULL) {
+ *TestPointData = InformationBlock;
+ }
+ if (TestPointSize != NULL) {
+ *TestPointSize = InformationBlockSize;
+ }
+ return Aip;
+}
+
+/**
+ Return if input TestPoint data is valid.
+
+ @param TestPointData TestPoint data
+ @param TestPointSize TestPoint size
+
+ @retval TRUE TestPoint data is valid.
+ @retval FALSE TestPoint data is not valid.
+**/
+BOOLEAN
+InternalTestPointIsValidTable (
+ IN VOID *TestPointData,
+ IN UINTN TestPointSize
+ )
+{
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN Index;
+ CHAR16 *ErrorString;
+ CHAR16 ErrorChar;
+ UINTN ErrorStringSize;
+ UINTN ErrorStringLength;
+
+ TestPoint = TestPointData;
+
+ //
+ // basic check for header
+ //
+ if (TestPointData == NULL) {
+ DEBUG ((EFI_D_ERROR, "TestPointData == NULL\n"));
+ return FALSE;
+ }
+ if (TestPointSize < sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) {
+ DEBUG ((EFI_D_ERROR, "TestPointSize < sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)\n"));
+ return FALSE;
+ }
+ if (((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < TestPoint->FeaturesSize) {
+ DEBUG ((EFI_D_ERROR, "((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < FeaturesSize\n"));
+ return FALSE;
+ }
+
+ //
+ // Check Version
+ //
+ if (TestPoint->Version != PLATFORM_TEST_POINT_VERSION) {
+ DEBUG ((EFI_D_ERROR, "Version != PLATFORM_TEST_POINT_VERSION\n"));
+ return FALSE;
+ }
+
+ //
+ // Check Role
+ //
+ if ((TestPoint->Role < PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE) ||
+ (TestPoint->Role > PLATFORM_TEST_POINT_ROLE_IMPLEMENTOR_ODM)) {
+ DEBUG ((EFI_D_ERROR, "Role < PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE ||\n"));
+ DEBUG ((EFI_D_ERROR, "Role > PLATFORM_TEST_POINT_ROLE_IMPLEMENTOR_ODM\n"));
+ return FALSE;
+ }
+
+ //
+ // Check ImplementationID
+ //
+ for (Index = 0; Index < sizeof(TestPoint->ImplementationID)/sizeof(TestPoint->ImplementationID[0]); Index++) {
+ if (TestPoint->ImplementationID[Index] == 0) {
+ break;
+ }
+ }
+ if (Index == sizeof(TestPoint->ImplementationID)/sizeof(TestPoint->ImplementationID[0])) {
+ DEBUG ((EFI_D_ERROR, "ImplementationID is no NUL CHAR\n"));
+ return FALSE;
+ }
+
+ ErrorStringSize = TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3;
+ ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3);
+
+ //
+ // basic check for ErrorString
+ //
+ if (ErrorStringSize == 0) {
+ DEBUG ((EFI_D_ERROR, "ErrorStringSize == 0\n"));
+ return FALSE;
+ }
+ if ((ErrorStringSize & BIT0) != 0) {
+ DEBUG ((EFI_D_ERROR, "(ErrorStringSize & BIT0) != 0\n"));
+ return FALSE;
+ }
+
+ //
+ // ErrorString might not be CHAR16 aligned.
+ //
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ for (ErrorStringLength = 0; (ErrorChar != 0) && (ErrorStringLength < (ErrorStringSize/2)); ErrorStringLength++) {
+ ErrorString++;
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ }
+
+ //
+ // check the length of ErrorString
+ //
+ if (ErrorChar != 0) {
+ DEBUG ((EFI_D_ERROR, "ErrorString has no NUL CHAR\n"));
+ return FALSE;
+ }
+ if (ErrorStringLength == (ErrorStringSize/2)) {
+ DEBUG ((EFI_D_ERROR, "ErrorString Length incorrect\n"));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ Publish TestPoint table in AIP protocol.
+
+ One system should have only one PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE.
+
+ If the Role is NOT PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE,
+ FeaturesRequired field will be ignored.
+
+ @param TestPoint TestPoint data
+ @param TestPointSize TestPoint size
+
+ @retval EFI_SUCCESS The TestPoint data is published in AIP protocol.
+ @retval EFI_ALREADY_STARTED There is already TestPoint table with Role and ImplementationID published in system.
+ @retval EFI_VOLUME_CORRUPTED The input TestPoint data is invalid.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to publish TestPoint data in AIP protocol.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibSetTable (
+ IN VOID *TestPoint,
+ IN UINTN TestPointSize
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ TEST_POINT_AIP_PRIVATE_DATA *TestPointAip;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ UINT32 Role;
+ CHAR16 *ImplementationID;
+ UINT32 FeaturesSize;
+ UINT8 *FeaturesRequired;
+
+ if (!InternalTestPointIsValidTable (TestPoint, TestPointSize)) {
+ return EFI_VOLUME_CORRUPTED;
+ }
+
+ Role = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->Role;
+ ImplementationID = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->ImplementationID;
+ Aip = InternalTestPointFindAip (Role, ImplementationID, NULL, NULL);
+ if (Aip != NULL) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ TestPointAip = AllocateZeroPool (sizeof(TEST_POINT_AIP_PRIVATE_DATA));
+ if (TestPointAip == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ TestPointAip->TestPoint = AllocateCopyPool (TestPointSize, TestPoint);
+ if (TestPointAip->TestPoint == NULL) {
+ FreePool (TestPointAip);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ if (Role != PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE) {
+ FeaturesRequired = (UINT8 *)TestPointAip->TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT);
+ FeaturesSize = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->FeaturesSize;
+ ZeroMem (FeaturesRequired, FeaturesSize);
+ }
+
+ TestPointAip->Signature = TEST_POINT_AIP_PRIVATE_SIGNATURE;
+ CopyMem (&TestPointAip->Aip, &mAdapterInformationProtocol, sizeof(EFI_ADAPTER_INFORMATION_PROTOCOL));
+ TestPointAip->TestPointSize = TestPointSize;
+ TestPointAip->TestPointMaxSize = TestPointSize;
+
+ Handle = NULL;
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Handle,
+ &gEfiAdapterInformationProtocolGuid,
+ &TestPointAip->Aip,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ FreePool (TestPointAip->TestPoint);
+ FreePool (TestPointAip);
+ }
+
+ return Status;
+}
+
+/**
+ Search TestPoint table in AIP protocol, and return the data.
+ This API will return the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param TestPoint TestPoint data. This buffer is allocated by callee, and it
+ is the responsibility of the caller to free it after
+ using it.
+ @param TestPointSize TestPoint size
+
+ @retval EFI_SUCCESS The TestPoint data in AIP protocol is returned.
+ @retval EFI_NOT_FOUND There is not TestPoint table with the Role and ImplementationID published in system.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibGetTable (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID OPTIONAL,
+ OUT VOID **TestPoint,
+ OUT UINTN *TestPointSize
+ )
+{
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+
+ Aip = InternalTestPointFindAip (Role, ImplementationID, TestPoint, TestPointSize);
+ if (Aip == NULL) {
+ return EFI_NOT_FOUND;
+ }
+ return EFI_SUCCESS;
+}
+
+/**
+ Record FeaturesVerified in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ByteIndex Byte index of FeaturesVerified of TestPoint data.
+ @param BitMask Bit mask of FeaturesVerified of TestPoint data.
+ @param Set TRUE means to set the FeaturesVerified bit.
+ FALSE means to clear the FeaturesVerified bit.
+
+ @retval EFI_SUCCESS The FeaturesVerified of TestPoint data updated in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_UNSUPPORTED The ByteIndex is invalid.
+**/
+EFI_STATUS
+InternalTestPointRecordFeaturesVerified (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN UINT32 ByteIndex,
+ IN UINT8 Bit,
+ IN BOOLEAN Set
+ )
+{
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN TestPointSize;
+ UINT8 *FeaturesVerified;
+ EFI_STATUS Status;
+
+ Aip = InternalTestPointFindAip (Role, ImplementationID, (VOID **)&TestPoint, &TestPointSize);
+ if (Aip == NULL) {
+ return EFI_NOT_STARTED;
+ }
+
+ if (ByteIndex >= TestPoint->FeaturesSize) {
+ return EFI_UNSUPPORTED;
+ }
+
+ FeaturesVerified = (UINT8 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 2);
+
+ if (Set) {
+ FeaturesVerified[ByteIndex] = (UINT8)(FeaturesVerified[ByteIndex] | (Bit));
+ } else {
+ FeaturesVerified[ByteIndex] = (UINT8)(FeaturesVerified[ByteIndex] & (~Bit));
+ }
+
+ Status = Aip->SetInformation (
+ Aip,
+ &gAdapterInfoPlatformTestPointGuid,
+ TestPoint,
+ TestPointSize
+ );
+ return Status;
+}
+
+/**
+ Set FeaturesVerified in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ByteIndex Byte index of FeaturesVerified of TestPoint data.
+ @param BitMask Bit mask of FeaturesVerified of TestPoint data.
+
+ @retval EFI_SUCCESS The FeaturesVerified of TestPoint data updated in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_UNSUPPORTED The ByteIndex is invalid.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibSetFeaturesVerified (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN UINT32 ByteIndex,
+ IN UINT8 BitMask
+ )
+{
+ return InternalTestPointRecordFeaturesVerified (
+ Role,
+ ImplementationID,
+ ByteIndex,
+ BitMask,
+ TRUE
+ );
+}
+
+/**
+ Clear FeaturesVerified in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ByteIndex Byte index of FeaturesVerified of TestPoint data.
+ @param BitMask Bit mask of FeaturesVerified of TestPoint data.
+
+ @retval EFI_SUCCESS The FeaturesVerified of TestPoint data updated in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_UNSUPPORTED The ByteIndex is invalid.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibClearFeaturesVerified (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN UINT32 ByteIndex,
+ IN UINT8 BitMask
+ )
+{
+ return InternalTestPointRecordFeaturesVerified (
+ Role,
+ ImplementationID,
+ ByteIndex,
+ BitMask,
+ FALSE
+ );
+}
+
+/**
+ Record ErrorString in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ErrorString ErrorString of TestPoint data.
+ @param Append TRUE means to append the ErrorString to TestPoint table.
+ FALSE means to set the ErrorString in TestPoint table.
+
+ @retval EFI_SUCCESS The ErrorString of TestPoint data is published in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.
+**/
+EFI_STATUS
+InternalTestPointRecordErrorString (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN CHAR16 *ErrorString,
+ IN BOOLEAN Append
+ )
+{
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN TestPointSize;
+ UINTN StringSize;
+ VOID *NewTestPoint;
+ UINTN NewTestPointSize;
+ UINTN Offset;
+ EFI_STATUS Status;
+
+ Aip = InternalTestPointFindAip (Role, ImplementationID, (VOID **)&TestPoint, &TestPointSize);
+ if (Aip == NULL) {
+ return EFI_NOT_STARTED;
+ }
+
+ if (Append) {
+ Offset = TestPointSize - sizeof(CHAR16);
+ } else {
+ Offset = sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 3;
+ }
+ StringSize = StrSize (ErrorString);
+
+ NewTestPointSize = Offset + StringSize;
+ NewTestPoint = AllocatePool (NewTestPointSize);
+ if (NewTestPoint == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CopyMem (NewTestPoint, TestPoint, Offset);
+ CopyMem ((UINT8 *)NewTestPoint + Offset, ErrorString, StringSize);
+
+ Status = Aip->SetInformation (
+ Aip,
+ &gAdapterInfoPlatformTestPointGuid,
+ NewTestPoint,
+ NewTestPointSize
+ );
+ return Status;
+}
+
+/**
+ Append ErrorString in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ErrorString ErrorString of TestPoint data.
+
+ @retval EFI_SUCCESS The ErrorString of TestPoint data is updated in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibAppendErrorString (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN CHAR16 *ErrorString
+ )
+{
+ DEBUG ((DEBUG_ERROR, "TestPointLibAppendErrorString - (0x%x) %s\n", Role, ErrorString));
+ return InternalTestPointRecordErrorString (
+ Role,
+ ImplementationID,
+ ErrorString,
+ TRUE
+ );
+}
+
+/**
+ Set a new ErrorString in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ErrorString ErrorString of TestPoint data.
+
+ @retval EFI_SUCCESS The ErrorString of TestPoint data is updated in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibSetErrorString (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN CHAR16 *ErrorString
+ )
+{
+ DEBUG ((DEBUG_ERROR, "TestPointLibSetErrorString - %s\n", ErrorString));
+ return InternalTestPointRecordErrorString (
+ Role,
+ ImplementationID,
+ ErrorString,
+ FALSE
+ );
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.h b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.h
new file mode 100644
index 0000000000..e152f95a13
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.h
@@ -0,0 +1,61 @@
+/** @file
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _DXE_TEST_POINT_DXE_H_
+#define _DXE_TEST_POINT_DXE_H_
+
+#include <PiDxe.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+#include <Library/TestPointLib.h>
+
+#include <Protocol/AdapterInformation.h>
+
+#define TEST_POINT_AIP_PRIVATE_SIGNATURE SIGNATURE_32('T', 'S', 'P', 'T')
+
+typedef struct {
+ UINT32 Signature;
+ EFI_ADAPTER_INFORMATION_PROTOCOL Aip;
+ VOID *TestPoint;
+ UINTN TestPointSize;
+ UINTN TestPointMaxSize;
+} TEST_POINT_AIP_PRIVATE_DATA;
+
+#define TEST_POINT_AIP_PRIVATE_DATA_FROM_THIS(a) \
+ CR (a, \
+ TEST_POINT_AIP_PRIVATE_DATA, \
+ Aip, \
+ TEST_POINT_AIP_PRIVATE_SIGNATURE \
+ )
+
+extern EFI_ADAPTER_INFORMATION_PROTOCOL mAdapterInformationProtocol;
+
+/**
+ Return if input TestPoint data is valid.
+
+ @param TestPointData TestPoint data
+ @param TestPointSize TestPoint size
+
+ @retval TRUE TestPoint data is valid.
+ @retval FALSE TestPoint data is not valid.
+**/
+BOOLEAN
+InternalTestPointIsValidTable (
+ IN VOID *TestPointData,
+ IN UINTN TestPointSize
+ );
+
+#endif \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPointAip.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPointAip.c
new file mode 100644
index 0000000000..2e807932f8
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPointAip.c
@@ -0,0 +1,175 @@
+/** @file
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "DxeTestPoint.h"
+
+/**
+ Returns the current state information for the adapter.
+
+ This function returns information of type InformationType from the adapter.
+ If an adapter does not support the requested informational type, then
+ EFI_UNSUPPORTED is returned.
+
+ @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.
+ @param[in] InformationType A pointer to an EFI_GUID that defines the contents of InformationBlock.
+ @param[out] InformationBlock The service returns a pointer to the buffer with the InformationBlock
+ structure which contains details about the data specific to InformationType.
+ @param[out] InformationBlockSize The driver returns the size of the InformationBlock in bytes.
+
+ @retval EFI_SUCCESS The InformationType information was retrieved.
+ @retval EFI_UNSUPPORTED The InformationType is not known.
+ @retval EFI_DEVICE_ERROR The device reported an error.
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
+ @retval EFI_INVALID_PARAMETER This is NULL.
+ @retval EFI_INVALID_PARAMETER InformationBlock is NULL.
+ @retval EFI_INVALID_PARAMETER InformationBlockSize is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+TestPointAipGetInfo (
+ IN EFI_ADAPTER_INFORMATION_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ OUT VOID **InformationBlock,
+ OUT UINTN *InformationBlockSize
+ )
+{
+ TEST_POINT_AIP_PRIVATE_DATA *TestPointAip;
+
+ if ((This == NULL) || (InformationBlock == NULL) || (InformationBlockSize == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (!CompareGuid (InformationType, &gAdapterInfoPlatformTestPointGuid)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ TestPointAip = TEST_POINT_AIP_PRIVATE_DATA_FROM_THIS(This);
+
+ *InformationBlock = AllocateCopyPool (TestPointAip->TestPointSize, TestPointAip->TestPoint);
+ if (*InformationBlock == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ *InformationBlockSize = TestPointAip->TestPointSize;
+ return EFI_SUCCESS;
+}
+
+/**
+ Sets state information for an adapter.
+
+ This function sends information of type InformationType for an adapter.
+ If an adapter does not support the requested information type, then EFI_UNSUPPORTED
+ is returned.
+
+ @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.
+ @param[in] InformationType A pointer to an EFI_GUID that defines the contents of InformationBlock.
+ @param[in] InformationBlock A pointer to the InformationBlock structure which contains details
+ about the data specific to InformationType.
+ @param[in] InformationBlockSize The size of the InformationBlock in bytes.
+
+ @retval EFI_SUCCESS The information was received and interpreted successfully.
+ @retval EFI_UNSUPPORTED The InformationType is not known.
+ @retval EFI_DEVICE_ERROR The device reported an error.
+ @retval EFI_INVALID_PARAMETER This is NULL.
+ @retval EFI_INVALID_PARAMETER InformationBlock is NULL.
+ @retval EFI_WRITE_PROTECTED The InformationType cannot be modified using EFI_ADAPTER_INFO_SET_INFO().
+
+**/
+EFI_STATUS
+EFIAPI
+TestPointAipSetInfo (
+ IN EFI_ADAPTER_INFORMATION_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN VOID *InformationBlock,
+ IN UINTN InformationBlockSize
+ )
+{
+ TEST_POINT_AIP_PRIVATE_DATA *TestPointAip;
+ VOID *NewTestPoint;
+
+ if ((This == NULL) || (InformationBlock == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (!CompareGuid (InformationType, &gAdapterInfoPlatformTestPointGuid)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (!InternalTestPointIsValidTable (InformationBlock, InformationBlockSize)) {
+ return EFI_VOLUME_CORRUPTED;
+ }
+
+ TestPointAip = TEST_POINT_AIP_PRIVATE_DATA_FROM_THIS(This);
+
+ if (InformationBlockSize > TestPointAip->TestPointMaxSize) {
+ NewTestPoint = AllocateZeroPool (InformationBlockSize);
+ if (NewTestPoint == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ FreePool (TestPointAip->TestPoint);
+ TestPointAip->TestPoint = NewTestPoint;
+ TestPointAip->TestPointSize = 0;
+ TestPointAip->TestPointMaxSize = InformationBlockSize;
+ }
+
+ CopyMem (TestPointAip->TestPoint, InformationBlock, InformationBlockSize);
+ TestPointAip->TestPointSize = InformationBlockSize;
+ return EFI_SUCCESS;
+}
+
+/**
+ Get a list of supported information types for this instance of the protocol.
+
+ This function returns a list of InformationType GUIDs that are supported on an
+ adapter with this instance of EFI_ADAPTER_INFORMATION_PROTOCOL. The list is returned
+ in InfoTypesBuffer, and the number of GUID pointers in InfoTypesBuffer is returned in
+ InfoTypesBufferCount.
+
+ @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.
+ @param[out] InfoTypesBuffer A pointer to the array of InformationType GUIDs that are supported
+ by This.
+ @param[out] InfoTypesBufferCount A pointer to the number of GUIDs present in InfoTypesBuffer.
+
+ @retval EFI_SUCCESS The list of information type GUIDs that are supported on this adapter was
+ returned in InfoTypesBuffer. The number of information type GUIDs was
+ returned in InfoTypesBufferCount.
+ @retval EFI_INVALID_PARAMETER This is NULL.
+ @retval EFI_INVALID_PARAMETER InfoTypesBuffer is NULL.
+ @retval EFI_INVALID_PARAMETER InfoTypesBufferCount is NULL.
+ @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the results.
+
+**/
+EFI_STATUS
+EFIAPI
+TestPointAipGetSupportedTypes (
+ IN EFI_ADAPTER_INFORMATION_PROTOCOL *This,
+ OUT EFI_GUID **InfoTypesBuffer,
+ OUT UINTN *InfoTypesBufferCount
+ )
+{
+ if ((This == NULL) || (InfoTypesBuffer == NULL) || (InfoTypesBufferCount == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *InfoTypesBuffer = AllocateCopyPool (sizeof(gAdapterInfoPlatformTestPointGuid), &gAdapterInfoPlatformTestPointGuid);
+ if (*InfoTypesBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ *InfoTypesBufferCount = 1;
+
+ return EFI_SUCCESS;
+}
+
+EFI_ADAPTER_INFORMATION_PROTOCOL mAdapterInformationProtocol = {
+ TestPointAipGetInfo,
+ TestPointAipSetInfo,
+ TestPointAipGetSupportedTypes,
+};
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPointLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPointLib.inf
new file mode 100644
index 0000000000..5c394645d7
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPointLib.inf
@@ -0,0 +1,48 @@
+## @file
+# DXE instance of TestPoint Library.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeTestPointLib
+ FILE_GUID = 9FDFABCE-7931-462F-8EDF-8C43AD58169C
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TestPointLib
+
+[Sources]
+ DxeTestPointAip.c
+ DxeTestPoint.c
+ DxeTestPoint.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ DebugLib
+ UefiBootServicesTableLib
+
+[Guids]
+## SOMETIMES_PRODUCES ## GUID
+## SOMETIMES_CONSUMES ## GUID
+ gAdapterInfoPlatformTestPointGuid
+
+[Protocols]
+## SOMETIMES_PRODUCES
+## SOMETIMES_CONSUMES
+ gEfiAdapterInformationProtocolGuid
+
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.c
new file mode 100644
index 0000000000..f648e589b7
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.c
@@ -0,0 +1,541 @@
+/** @file
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "PeiTestPoint.h"
+
+UINTN
+InternalGetTestPointInfoSize (
+ IN ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint,
+ IN UINTN MaxSize
+ )
+{
+ CHAR16 *ErrorString;
+ UINTN ErrorStringLength;
+ UINTN ErrorStringMaxSize;
+ CHAR16 ErrorChar;
+
+ ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + 3 * TestPoint->FeaturesSize);
+
+ ErrorStringMaxSize = MaxSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3;
+ //
+ // ErrorString might not be CHAR16 aligned.
+ //
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ for (ErrorStringLength = 0; (ErrorChar != 0) && (ErrorStringLength < (ErrorStringMaxSize/2)); ErrorStringLength++) {
+ ErrorString++;
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ }
+
+ return sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + 3 * TestPoint->FeaturesSize + (ErrorStringLength + 1) * sizeof(CHAR16);
+}
+
+/**
+ Find TestPoint table in AIP protocol, and return the data.
+ This API will return the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param TestPointData TestPoint data. This buffer is allocated by callee, and it
+ is the responsibility of the caller to free it after
+ using it.
+ @param TestPointSize TestPoint size
+
+ @return Status
+**/
+EFI_STATUS
+InternalTestPointFindAip (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID OPTIONAL,
+ OUT VOID **TestPointData OPTIONAL,
+ OUT UINTN *TestPointSize OPTIONAL,
+ OUT UINTN *TestPointMaxSize OPTIONAL
+ )
+{
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN Size;
+ UINTN MaxSize;
+ EFI_PEI_HOB_POINTERS Hob;
+
+ Hob.Raw = GetHobList ();
+ while (TRUE) {
+ Hob.Raw = GetNextGuidHob (&gAdapterInfoPlatformTestPointGuid, Hob.Raw);
+ if (Hob.Raw == NULL) {
+ return EFI_NOT_FOUND;
+ }
+ TestPoint = GET_GUID_HOB_DATA (Hob);
+ MaxSize = GET_GUID_HOB_DATA_SIZE (Hob);
+ Size = InternalGetTestPointInfoSize (TestPoint, MaxSize);
+
+ if ((TestPoint->Role == Role) &&
+ ((ImplementationID == NULL) || (StrCmp (ImplementationID, TestPoint->ImplementationID) == 0))) {
+ break;
+ }
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ if (Hob.Raw == NULL) {
+ return EFI_NOT_FOUND;
+ }
+ }
+
+ if (TestPointData != NULL) {
+ *TestPointData = TestPoint;
+ }
+ if (TestPointSize != NULL) {
+ *TestPointSize = Size;
+ }
+ if (TestPointMaxSize != NULL) {
+ *TestPointMaxSize = MaxSize;
+ }
+ return EFI_SUCCESS;
+}
+
+/**
+ Return if input TestPoint data is valid.
+
+ @param TestPointData TestPoint data
+ @param TestPointSize TestPoint size
+
+ @retval TRUE TestPoint data is valid.
+ @retval FALSE TestPoint data is not valid.
+**/
+BOOLEAN
+InternalTestPointIsValidTable (
+ IN VOID *TestPointData,
+ IN UINTN TestPointSize
+ )
+{
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN Index;
+ CHAR16 *ErrorString;
+ CHAR16 ErrorChar;
+ UINTN ErrorStringSize;
+ UINTN ErrorStringLength;
+
+ TestPoint = TestPointData;
+
+ //
+ // basic check for header
+ //
+ if (TestPointData == NULL) {
+ DEBUG ((EFI_D_ERROR, "TestPointData == NULL\n"));
+ return FALSE;
+ }
+ if (TestPointSize < sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) {
+ DEBUG ((EFI_D_ERROR, "TestPointSize < sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)\n"));
+ return FALSE;
+ }
+ if (((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < TestPoint->FeaturesSize) {
+ DEBUG ((EFI_D_ERROR, "((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < FeaturesSize\n"));
+ return FALSE;
+ }
+
+ //
+ // Check Version
+ //
+ if (TestPoint->Version != PLATFORM_TEST_POINT_VERSION) {
+ DEBUG ((EFI_D_ERROR, "Version != PLATFORM_TEST_POINT_VERSION\n"));
+ return FALSE;
+ }
+
+ //
+ // Check Role
+ //
+ if ((TestPoint->Role < PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE) ||
+ (TestPoint->Role > PLATFORM_TEST_POINT_ROLE_IMPLEMENTOR_ODM)) {
+ DEBUG ((EFI_D_ERROR, "Role < PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE ||\n"));
+ DEBUG ((EFI_D_ERROR, "Role > PLATFORM_TEST_POINT_ROLE_IMPLEMENTOR_ODM\n"));
+ return FALSE;
+ }
+
+ //
+ // Check ImplementationID
+ //
+ for (Index = 0; Index < sizeof(TestPoint->ImplementationID)/sizeof(TestPoint->ImplementationID[0]); Index++) {
+ if (TestPoint->ImplementationID[Index] == 0) {
+ break;
+ }
+ }
+ if (Index == sizeof(TestPoint->ImplementationID)/sizeof(TestPoint->ImplementationID[0])) {
+ DEBUG ((EFI_D_ERROR, "ImplementationID is no NUL CHAR\n"));
+ return FALSE;
+ }
+
+ ErrorStringSize = TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3;
+ ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3);
+
+ //
+ // basic check for ErrorString
+ //
+ if (ErrorStringSize == 0) {
+ DEBUG ((EFI_D_ERROR, "ErrorStringSize == 0\n"));
+ return FALSE;
+ }
+ if ((ErrorStringSize & BIT0) != 0) {
+ DEBUG ((EFI_D_ERROR, "(ErrorStringSize & BIT0) != 0\n"));
+ return FALSE;
+ }
+
+ //
+ // ErrorString might not be CHAR16 aligned.
+ //
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ for (ErrorStringLength = 0; (ErrorChar != 0) && (ErrorStringLength < (ErrorStringSize/2)); ErrorStringLength++) {
+ ErrorString++;
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ }
+
+ //
+ // check the length of ErrorString
+ //
+ if (ErrorChar != 0) {
+ DEBUG ((EFI_D_ERROR, "ErrorString has no NUL CHAR\n"));
+ return FALSE;
+ }
+ if (ErrorStringLength == (ErrorStringSize/2)) {
+ DEBUG ((EFI_D_ERROR, "ErrorString Length incorrect\n"));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ Publish TestPoint table in hob.
+
+ One system should have only one PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE.
+
+ If the Role is NOT PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE,
+ FeaturesRequired field will be ignored.
+
+ @param TestPoint TestPoint data
+ @param TestPointSize TestPoint size
+
+ @retval EFI_SUCCESS The TestPoint data is published in hob.
+ @retval EFI_ALREADY_STARTED There is already TestPoint table with Role and ImplementationID published in system.
+ @retval EFI_VOLUME_CORRUPTED The input TestPoint data is invalid.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to publish TestPoint data in hob.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibSetTable (
+ IN VOID *TestPoint,
+ IN UINTN TestPointSize
+ )
+{
+ VOID *NewTestPoint;
+ EFI_STATUS Status;
+ UINT32 Role;
+ CHAR16 *ImplementationID;
+ UINT32 FeaturesSize;
+ UINT8 *FeaturesRequired;
+
+ if (!InternalTestPointIsValidTable (TestPoint, TestPointSize)) {
+ return EFI_VOLUME_CORRUPTED;
+ }
+
+ Role = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->Role;
+ ImplementationID = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->ImplementationID;
+ Status = InternalTestPointFindAip (Role, ImplementationID, NULL, NULL, NULL);
+ if (!EFI_ERROR(Status)) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ NewTestPoint = BuildGuidHob (&gAdapterInfoPlatformTestPointGuid, TestPointSize);
+ if (NewTestPoint == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ if (Role != PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE) {
+ FeaturesRequired = (UINT8 *)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT);
+ FeaturesSize = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->FeaturesSize;
+ ZeroMem (FeaturesRequired, FeaturesSize);
+ }
+
+ CopyMem (NewTestPoint, TestPoint, TestPointSize);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Search TestPoint table in hob, and return the data.
+ This API will return the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param TestPoint TestPoint data.
+ @param TestPointSize TestPoint size
+
+ @retval EFI_SUCCESS The TestPoint data in hob is returned.
+ @retval EFI_NOT_FOUND There is not TestPoint table with the Role and ImplementationID published in system.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibGetTable (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID OPTIONAL,
+ OUT VOID **TestPoint,
+ OUT UINTN *TestPointSize
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalTestPointFindAip (Role, ImplementationID, TestPoint, TestPointSize, NULL);
+ return Status;
+}
+
+/**
+ Record FeaturesVerified in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ByteIndex Byte index of FeaturesVerified of TestPoint data.
+ @param BitMask Bit mask of FeaturesVerified of TestPoint data.
+ @param Set TRUE means to set the FeaturesVerified bit.
+ FALSE means to clear the FeaturesVerified bit.
+
+ @retval EFI_SUCCESS The FeaturesVerified of TestPoint data updated in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_UNSUPPORTED The ByteIndex is invalid.
+**/
+EFI_STATUS
+InternalTestPointRecordFeaturesVerified (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN UINT32 ByteIndex,
+ IN UINT8 Bit,
+ IN BOOLEAN Set
+ )
+{
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN TestPointSize;
+ UINT8 *FeaturesVerified;
+ EFI_STATUS Status;
+
+ Status = InternalTestPointFindAip (Role, ImplementationID, (VOID **)&TestPoint, &TestPointSize, NULL);
+ if (EFI_ERROR(Status)) {
+ return EFI_NOT_STARTED;
+ }
+
+ if (ByteIndex >= TestPoint->FeaturesSize) {
+ return EFI_UNSUPPORTED;
+ }
+
+ FeaturesVerified = (UINT8 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 2);
+
+ if (Set) {
+ FeaturesVerified[ByteIndex] = (UINT8)(FeaturesVerified[ByteIndex] | (Bit));
+ } else {
+ FeaturesVerified[ByteIndex] = (UINT8)(FeaturesVerified[ByteIndex] & (~Bit));
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Set FeaturesVerified in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ByteIndex Byte index of FeaturesVerified of TestPoint data.
+ @param BitMask Bit mask of FeaturesVerified of TestPoint data.
+
+ @retval EFI_SUCCESS The FeaturesVerified of TestPoint data updated in hob.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_UNSUPPORTED The ByteIndex is invalid.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibSetFeaturesVerified (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN UINT32 ByteIndex,
+ IN UINT8 BitMask
+ )
+{
+ return InternalTestPointRecordFeaturesVerified (
+ Role,
+ ImplementationID,
+ ByteIndex,
+ BitMask,
+ TRUE
+ );
+}
+
+/**
+ Clear FeaturesVerified in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ByteIndex Byte index of FeaturesVerified of TestPoint data.
+ @param BitMask Bit mask of FeaturesVerified of TestPoint data.
+
+ @retval EFI_SUCCESS The FeaturesVerified of TestPoint data updated in hob.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_UNSUPPORTED The ByteIndex is invalid.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibClearFeaturesVerified (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN UINT32 ByteIndex,
+ IN UINT8 BitMask
+ )
+{
+ return InternalTestPointRecordFeaturesVerified (
+ Role,
+ ImplementationID,
+ ByteIndex,
+ BitMask,
+ FALSE
+ );
+}
+
+/**
+ Record ErrorString in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ErrorString ErrorString of TestPoint data.
+ @param Append TRUE means to append the ErrorString to TestPoint table.
+ FALSE means to set the ErrorString in TestPoint table.
+
+ @retval EFI_SUCCESS The ErrorString of TestPoint data is published in hob.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.
+**/
+EFI_STATUS
+InternalTestPointRecordErrorString (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN CHAR16 *ErrorString,
+ IN BOOLEAN Append
+ )
+{
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN TestPointSize;
+ UINTN StringSize;
+ VOID *NewTestPoint;
+ UINTN NewTestPointSize;
+ UINTN Offset;
+ EFI_STATUS Status;
+ UINTN TestPointMaxSize;
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ Status = InternalTestPointFindAip (Role, ImplementationID, (VOID **)&TestPoint, &TestPointSize, &TestPointMaxSize);
+ if (EFI_ERROR(Status)) {
+ return EFI_NOT_STARTED;
+ }
+
+ if (Append) {
+ Offset = TestPointSize - sizeof(CHAR16);
+ } else {
+ Offset = sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 3;
+ }
+ StringSize = StrSize (ErrorString);
+
+ NewTestPointSize = Offset + StringSize;
+ if (NewTestPointSize > TestPointMaxSize) {
+ NewTestPoint = BuildGuidHob (&gAdapterInfoPlatformTestPointGuid, NewTestPointSize);
+ if (NewTestPoint == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ CopyMem (NewTestPoint, TestPoint, TestPointSize);
+
+ // remove old data
+ GuidHob = (VOID *)((UINT8 *)TestPoint - sizeof (EFI_HOB_GUID_TYPE));
+ ZeroMem (&GuidHob->Name, sizeof(GuidHob->Name));
+
+ TestPoint = NewTestPoint;
+ }
+
+ CopyMem ((UINT8 *)TestPoint + Offset, ErrorString, StringSize);
+
+ return Status;
+}
+
+/**
+ Append ErrorString in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ErrorString ErrorString of TestPoint data.
+
+ @retval EFI_SUCCESS The ErrorString of TestPoint data is updated in hob.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibAppendErrorString (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN CHAR16 *ErrorString
+ )
+{
+ DEBUG ((DEBUG_ERROR, "TestPointLibAppendErrorString - (0x%x) %s\n", Role, ErrorString));
+ return InternalTestPointRecordErrorString (
+ Role,
+ ImplementationID,
+ ErrorString,
+ TRUE
+ );
+}
+
+/**
+ Set a new ErrorString in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ErrorString ErrorString of TestPoint data.
+
+ @retval EFI_SUCCESS The ErrorString of TestPoint data is updated in hob.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibSetErrorString (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN CHAR16 *ErrorString
+ )
+{
+ DEBUG ((DEBUG_ERROR, "TestPointLibSetErrorString - %s\n", ErrorString));
+ return InternalTestPointRecordErrorString (
+ Role,
+ ImplementationID,
+ ErrorString,
+ FALSE
+ );
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.h b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.h
new file mode 100644
index 0000000000..c2aa72e0ee
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.h
@@ -0,0 +1,44 @@
+/** @file
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PEI_TEST_POINT_DXE_H_
+#define _PEI_TEST_POINT_DXE_H_
+
+#include <PiPei.h>
+#include <PiDxe.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/HobLib.h>
+#include <Library/DebugLib.h>
+#include <Library/TestPointLib.h>
+
+#include <Protocol/AdapterInformation.h>
+
+/**
+ Return if input TestPoint data is valid.
+
+ @param TestPointData TestPoint data
+ @param TestPointSize TestPoint size
+
+ @retval TRUE TestPoint data is valid.
+ @retval FALSE TestPoint data is not valid.
+**/
+BOOLEAN
+InternalTestPointIsValidTable (
+ IN VOID *TestPointData,
+ IN UINTN TestPointSize
+ );
+
+#endif \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPointLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPointLib.inf
new file mode 100644
index 0000000000..7fa2a471b4
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPointLib.inf
@@ -0,0 +1,44 @@
+## @file
+# PEI instance of TestPoint Library.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiTestPointLib
+ FILE_GUID = 9FDFABCE-7931-462F-8EDF-8C43AD58169C
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TestPointLib
+
+[Sources]
+ PeiTestPoint.c
+ PeiTestPoint.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ DebugLib
+ PeiServicesLib
+ HobLib
+
+[Guids]
+## SOMETIMES_PRODUCES ## GUID
+## SOMETIMES_CONSUMES ## GUID
+ gAdapterInfoPlatformTestPointGuid
+
+
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.c
new file mode 100644
index 0000000000..746d0308da
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.c
@@ -0,0 +1,634 @@
+/** @file
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "SmmTestPoint.h"
+
+/**
+ Find TestPoint table in AIP protocol, and return the data.
+ This API will return the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param TestPointData TestPoint data. This buffer is allocated by callee, and it
+ is the responsibility of the caller to free it after
+ using it.
+ @param TestPointSize TestPoint size
+
+ @return Aip The AIP protocol having this TestPoint.
+ @return NULL There is not TestPoint table with the Role and ImplementationID published in system.
+**/
+VOID *
+InternalTestPointFindAip (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID OPTIONAL,
+ OUT VOID **TestPointData OPTIONAL,
+ OUT UINTN *TestPointSize OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ UINTN HandleBufSize;
+ UINTN NoHandles;
+ EFI_HANDLE *Handles;
+ UINTN Index;
+ EFI_GUID *InfoTypesBuffer;
+ UINTN InfoTypesBufferCount;
+ UINTN InfoTypesIndex;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *AipCandidate;
+ VOID *InformationBlock;
+ UINTN InformationBlockSize;
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+
+ HandleBufSize = 0;
+ Handles = NULL;
+ Status = gSmst->SmmLocateHandle (
+ ByProtocol,
+ &gEfiAdapterInformationProtocolGuid,
+ NULL,
+ &HandleBufSize,
+ Handles
+ );
+ if (Status != EFI_BUFFER_TOO_SMALL) {
+ return NULL ;
+ }
+ Handles = AllocateZeroPool (HandleBufSize);
+ if (Handles == NULL) {
+ return NULL;
+ }
+
+ Status = gSmst->SmmLocateHandle (
+ ByProtocol,
+ &gEfiAdapterInformationProtocolGuid,
+ NULL,
+ &HandleBufSize,
+ Handles
+ );
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+ NoHandles = HandleBufSize / sizeof(EFI_HANDLE);
+
+ TestPoint = NULL;
+ Aip = NULL;
+ InformationBlock = NULL;
+ InformationBlockSize = 0;
+ for (Index = 0; Index < NoHandles; Index++) {
+ Status = gSmst->SmmHandleProtocol (
+ Handles[Index],
+ &gEfiAdapterInformationProtocolGuid,
+ (VOID **)&Aip
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ //
+ // Check AIP
+ //
+ Status = Aip->GetSupportedTypes (
+ Aip,
+ &InfoTypesBuffer,
+ &InfoTypesBufferCount
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ AipCandidate = NULL;
+ for (InfoTypesIndex = 0; InfoTypesIndex < InfoTypesBufferCount; InfoTypesIndex++) {
+ if (CompareGuid (&InfoTypesBuffer[InfoTypesIndex], &gAdapterInfoPlatformTestPointGuid)) {
+ AipCandidate = Aip;
+ break;
+ }
+ }
+ FreePool (InfoTypesBuffer);
+
+ if (AipCandidate == NULL) {
+ continue;
+ }
+
+ //
+ // Check Role
+ //
+ Aip = AipCandidate;
+ Status = Aip->GetInformation (
+ Aip,
+ &gAdapterInfoPlatformTestPointGuid,
+ &InformationBlock,
+ &InformationBlockSize
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ TestPoint = InformationBlock;
+ if ((TestPoint->Role == Role) &&
+ ((ImplementationID == NULL) || (StrCmp (ImplementationID, TestPoint->ImplementationID) == 0))) {
+ break;
+ } else {
+ TestPoint = NULL;
+ FreePool (InformationBlock);
+ continue;
+ }
+ }
+ FreePool (Handles);
+
+ if (TestPoint == NULL) {
+ return NULL;
+ }
+
+ if (TestPointData != NULL) {
+ *TestPointData = InformationBlock;
+ }
+ if (TestPointSize != NULL) {
+ *TestPointSize = InformationBlockSize;
+ }
+ return Aip;
+}
+
+/**
+ Return if input TestPoint data is valid.
+
+ @param TestPointData TestPoint data
+ @param TestPointSize TestPoint size
+
+ @retval TRUE TestPoint data is valid.
+ @retval FALSE TestPoint data is not valid.
+**/
+BOOLEAN
+InternalTestPointIsValidTable (
+ IN VOID *TestPointData,
+ IN UINTN TestPointSize
+ )
+{
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN Index;
+ CHAR16 *ErrorString;
+ CHAR16 ErrorChar;
+ UINTN ErrorStringSize;
+ UINTN ErrorStringLength;
+
+ TestPoint = TestPointData;
+
+ //
+ // basic check for header
+ //
+ if (TestPointData == NULL) {
+ DEBUG ((EFI_D_ERROR, "TestPointData == NULL\n"));
+ return FALSE;
+ }
+ if (TestPointSize < sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) {
+ DEBUG ((EFI_D_ERROR, "TestPointSize < sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)\n"));
+ return FALSE;
+ }
+ if (((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < TestPoint->FeaturesSize) {
+ DEBUG ((EFI_D_ERROR, "((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < FeaturesSize\n"));
+ return FALSE;
+ }
+
+ //
+ // Check Version
+ //
+ if (TestPoint->Version != PLATFORM_TEST_POINT_VERSION) {
+ DEBUG ((EFI_D_ERROR, "Version != PLATFORM_TEST_POINT_VERSION\n"));
+ return FALSE;
+ }
+
+ //
+ // Check Role
+ //
+ if ((TestPoint->Role < PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE) ||
+ (TestPoint->Role > PLATFORM_TEST_POINT_ROLE_IMPLEMENTOR_ODM)) {
+ DEBUG ((EFI_D_ERROR, "Role < PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE ||\n"));
+ DEBUG ((EFI_D_ERROR, "Role > PLATFORM_TEST_POINT_ROLE_IMPLEMENTOR_ODM\n"));
+ return FALSE;
+ }
+
+ //
+ // Check ImplementationID
+ //
+ for (Index = 0; Index < sizeof(TestPoint->ImplementationID)/sizeof(TestPoint->ImplementationID[0]); Index++) {
+ if (TestPoint->ImplementationID[Index] == 0) {
+ break;
+ }
+ }
+ if (Index == sizeof(TestPoint->ImplementationID)/sizeof(TestPoint->ImplementationID[0])) {
+ DEBUG ((EFI_D_ERROR, "ImplementationID is no NUL CHAR\n"));
+ return FALSE;
+ }
+
+ ErrorStringSize = TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3;
+ ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3);
+
+ //
+ // basic check for ErrorString
+ //
+ if (ErrorStringSize == 0) {
+ DEBUG ((EFI_D_ERROR, "ErrorStringSize == 0\n"));
+ return FALSE;
+ }
+ if ((ErrorStringSize & BIT0) != 0) {
+ DEBUG ((EFI_D_ERROR, "(ErrorStringSize & BIT0) != 0\n"));
+ return FALSE;
+ }
+
+ //
+ // ErrorString might not be CHAR16 aligned.
+ //
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ for (ErrorStringLength = 0; (ErrorChar != 0) && (ErrorStringLength < (ErrorStringSize/2)); ErrorStringLength++) {
+ ErrorString++;
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ }
+
+ //
+ // check the length of ErrorString
+ //
+ if (ErrorChar != 0) {
+ DEBUG ((EFI_D_ERROR, "ErrorString has no NUL CHAR\n"));
+ return FALSE;
+ }
+ if (ErrorStringLength == (ErrorStringSize/2)) {
+ DEBUG ((EFI_D_ERROR, "ErrorString Length incorrect\n"));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ Publish TestPoint table in AIP protocol.
+
+ One system should have only one PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE.
+
+ If the Role is NOT PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE,
+ FeaturesRequired field will be ignored.
+
+ @param TestPoint TestPoint data
+ @param TestPointSize TestPoint size
+
+ @retval EFI_SUCCESS The TestPoint data is published in AIP protocol.
+ @retval EFI_ALREADY_STARTED There is already TestPoint table with Role and ImplementationID published in system.
+ @retval EFI_VOLUME_CORRUPTED The input TestPoint data is invalid.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to publish TestPoint data in AIP protocol.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibSetTable (
+ IN VOID *TestPoint,
+ IN UINTN TestPointSize
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ TEST_POINT_AIP_PRIVATE_DATA *TestPointAip;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ UINT32 Role;
+ CHAR16 *ImplementationID;
+ UINT32 FeaturesSize;
+ UINT8 *FeaturesRequired;
+
+ if (!InternalTestPointIsValidTable (TestPoint, TestPointSize)) {
+ return EFI_VOLUME_CORRUPTED;
+ }
+
+ Role = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->Role;
+ ImplementationID = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->ImplementationID;
+ Aip = InternalTestPointFindAip (Role, ImplementationID, NULL, NULL);
+ if (Aip != NULL) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ TestPointAip = AllocateZeroPool (sizeof(TEST_POINT_AIP_PRIVATE_DATA));
+ if (TestPointAip == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ TestPointAip->TestPoint = AllocateCopyPool (TestPointSize, TestPoint);
+ if (TestPointAip->TestPoint == NULL) {
+ FreePool (TestPointAip);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ if (Role != PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE) {
+ FeaturesRequired = (UINT8 *)TestPointAip->TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT);
+ FeaturesSize = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->FeaturesSize;
+ ZeroMem (FeaturesRequired, FeaturesSize);
+ }
+
+ TestPointAip->Signature = TEST_POINT_AIP_PRIVATE_SIGNATURE;
+ CopyMem (&TestPointAip->Aip, &mAdapterInformationProtocol, sizeof(EFI_ADAPTER_INFORMATION_PROTOCOL));
+ TestPointAip->TestPointSize = TestPointSize;
+ TestPointAip->TestPointMaxSize = TestPointSize;
+
+ Handle = NULL;
+ Status = gSmst->SmmInstallProtocolInterface (
+ &Handle,
+ &gEfiAdapterInformationProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &TestPointAip->Aip
+ );
+ if (EFI_ERROR (Status)) {
+ FreePool (TestPointAip->TestPoint);
+ FreePool (TestPointAip);
+ }
+
+ if (!EFI_ERROR(Status)) {
+ RegisterSmmTestPointSmiHandler ();
+ }
+
+ return Status;
+}
+
+/**
+ Search TestPoint table in AIP protocol, and return the data.
+ This API will return the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param TestPoint TestPoint data. This buffer is allocated by callee, and it
+ is the responsibility of the caller to free it after
+ using it.
+ @param TestPointSize TestPoint size
+
+ @retval EFI_SUCCESS The TestPoint data in AIP protocol is returned.
+ @retval EFI_NOT_FOUND There is not TestPoint table with the Role and ImplementationID published in system.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibGetTable (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID OPTIONAL,
+ OUT VOID **TestPoint,
+ OUT UINTN *TestPointSize
+ )
+{
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+
+ Aip = InternalTestPointFindAip (Role, ImplementationID, TestPoint, TestPointSize);
+ if (Aip == NULL) {
+ return EFI_NOT_FOUND;
+ }
+ return EFI_SUCCESS;
+}
+
+/**
+ Record FeaturesVerified in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ByteIndex Byte index of FeaturesVerified of TestPoint data.
+ @param BitMask Bit mask of FeaturesVerified of TestPoint data.
+ @param Set TRUE means to set the FeaturesVerified bit.
+ FALSE means to clear the FeaturesVerified bit.
+
+ @retval EFI_SUCCESS The FeaturesVerified of TestPoint data updated in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_UNSUPPORTED The ByteIndex is invalid.
+**/
+EFI_STATUS
+InternalTestPointRecordFeaturesVerified (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN UINT32 ByteIndex,
+ IN UINT8 Bit,
+ IN BOOLEAN Set
+ )
+{
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN TestPointSize;
+ UINT8 *FeaturesVerified;
+ EFI_STATUS Status;
+
+ Aip = InternalTestPointFindAip (Role, ImplementationID, (VOID **)&TestPoint, &TestPointSize);
+ if (Aip == NULL) {
+ return EFI_NOT_STARTED;
+ }
+
+ if (ByteIndex >= TestPoint->FeaturesSize) {
+ return EFI_UNSUPPORTED;
+ }
+
+ FeaturesVerified = (UINT8 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 2);
+
+ if (Set) {
+ FeaturesVerified[ByteIndex] = (UINT8)(FeaturesVerified[ByteIndex] | (Bit));
+ } else {
+ FeaturesVerified[ByteIndex] = (UINT8)(FeaturesVerified[ByteIndex] & (~Bit));
+ }
+
+ Status = Aip->SetInformation (
+ Aip,
+ &gAdapterInfoPlatformTestPointGuid,
+ TestPoint,
+ TestPointSize
+ );
+ return Status;
+}
+
+/**
+ Set FeaturesVerified in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ByteIndex Byte index of FeaturesVerified of TestPoint data.
+ @param BitMask Bit mask of FeaturesVerified of TestPoint data.
+
+ @retval EFI_SUCCESS The FeaturesVerified of TestPoint data updated in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_UNSUPPORTED The ByteIndex is invalid.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibSetFeaturesVerified (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN UINT32 ByteIndex,
+ IN UINT8 BitMask
+ )
+{
+ return InternalTestPointRecordFeaturesVerified (
+ Role,
+ ImplementationID,
+ ByteIndex,
+ BitMask,
+ TRUE
+ );
+}
+
+/**
+ Clear FeaturesVerified in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ByteIndex Byte index of FeaturesVerified of TestPoint data.
+ @param BitMask Bit mask of FeaturesVerified of TestPoint data.
+
+ @retval EFI_SUCCESS The FeaturesVerified of TestPoint data updated in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_UNSUPPORTED The ByteIndex is invalid.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibClearFeaturesVerified (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN UINT32 ByteIndex,
+ IN UINT8 BitMask
+ )
+{
+ return InternalTestPointRecordFeaturesVerified (
+ Role,
+ ImplementationID,
+ ByteIndex,
+ BitMask,
+ FALSE
+ );
+}
+
+/**
+ Record ErrorString in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ErrorString ErrorString of TestPoint data.
+ @param Append TRUE means to append the ErrorString to TestPoint table.
+ FALSE means to set the ErrorString in TestPoint table.
+
+ @retval EFI_SUCCESS The ErrorString of TestPoint data is published in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.
+**/
+EFI_STATUS
+InternalTestPointRecordErrorString (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN CHAR16 *ErrorString,
+ IN BOOLEAN Append
+ )
+{
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN TestPointSize;
+ UINTN StringSize;
+ VOID *NewTestPoint;
+ UINTN NewTestPointSize;
+ UINTN Offset;
+ EFI_STATUS Status;
+
+ Aip = InternalTestPointFindAip (Role, ImplementationID, (VOID **)&TestPoint, &TestPointSize);
+ if (Aip == NULL) {
+ return EFI_NOT_STARTED;
+ }
+
+ if (Append) {
+ Offset = TestPointSize - sizeof(CHAR16);
+ } else {
+ Offset = sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 3;
+ }
+ StringSize = StrSize (ErrorString);
+
+ NewTestPointSize = Offset + StringSize;
+ NewTestPoint = AllocatePool (NewTestPointSize);
+ if (NewTestPoint == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CopyMem (NewTestPoint, TestPoint, Offset);
+ CopyMem ((UINT8 *)NewTestPoint + Offset, ErrorString, StringSize);
+
+ Status = Aip->SetInformation (
+ Aip,
+ &gAdapterInfoPlatformTestPointGuid,
+ NewTestPoint,
+ NewTestPointSize
+ );
+ return Status;
+}
+
+/**
+ Append ErrorString in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ErrorString ErrorString of TestPoint data.
+
+ @retval EFI_SUCCESS The ErrorString of TestPoint data is updated in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibAppendErrorString (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN CHAR16 *ErrorString
+ )
+{
+ DEBUG ((DEBUG_ERROR, "TestPointLibAppendErrorString - (0x%x) %s\n", Role, ErrorString));
+ return InternalTestPointRecordErrorString (
+ Role,
+ ImplementationID,
+ ErrorString,
+ TRUE
+ );
+}
+
+/**
+ Set a new ErrorString in published TestPoint table.
+ This API will update the TestPoint table with indicated Role and ImplementationID,
+ NULL ImplementationID means to find the first TestPoint table with indicated Role.
+
+ @param Role Role of TestPoint data.
+ @param ImplementationID ImplementationID of TestPoint data.
+ NULL means find the first one match Role.
+ @param ErrorString ErrorString of TestPoint data.
+
+ @retval EFI_SUCCESS The ErrorString of TestPoint data is updated in AIP protocol.
+ @retval EFI_NOT_STARTED There is not TestPoint table with the Role and ImplementationID published in system.
+ @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.
+**/
+EFI_STATUS
+EFIAPI
+TestPointLibSetErrorString (
+ IN UINT32 Role,
+ IN CHAR16 *ImplementationID, OPTIONAL
+ IN CHAR16 *ErrorString
+ )
+{
+ DEBUG ((DEBUG_ERROR, "TestPointLibSetErrorString - %s\n", ErrorString));
+ return InternalTestPointRecordErrorString (
+ Role,
+ ImplementationID,
+ ErrorString,
+ FALSE
+ );
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.h b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.h
new file mode 100644
index 0000000000..4a7429f569
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.h
@@ -0,0 +1,71 @@
+/** @file
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _SMM_TEST_POINT_DXE_H_
+#define _SMM_TEST_POINT_DXE_H_
+
+#include <PiSmm.h>
+#include <PiDxe.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/SmmMemLib.h>
+#include <Library/DebugLib.h>
+#include <Library/TestPointLib.h>
+
+#include <Protocol/AdapterInformation.h>
+
+#define TEST_POINT_AIP_PRIVATE_SIGNATURE SIGNATURE_32('T', 'S', 'P', 'T')
+
+typedef struct {
+ UINT32 Signature;
+ EFI_ADAPTER_INFORMATION_PROTOCOL Aip;
+ VOID *TestPoint;
+ UINTN TestPointSize;
+ UINTN TestPointMaxSize;
+} TEST_POINT_AIP_PRIVATE_DATA;
+
+#define TEST_POINT_AIP_PRIVATE_DATA_FROM_THIS(a) \
+ CR (a, \
+ TEST_POINT_AIP_PRIVATE_DATA, \
+ Aip, \
+ TEST_POINT_AIP_PRIVATE_SIGNATURE \
+ )
+
+extern EFI_ADAPTER_INFORMATION_PROTOCOL mAdapterInformationProtocol;
+
+/**
+ Return if input TestPoint data is valid.
+
+ @param TestPointData TestPoint data
+ @param TestPointSize TestPoint size
+
+ @retval TRUE TestPoint data is valid.
+ @retval FALSE TestPoint data is not valid.
+**/
+BOOLEAN
+InternalTestPointIsValidTable (
+ IN VOID *TestPointData,
+ IN UINTN TestPointSize
+ );
+
+/**
+ Register SMM TestPoint handler.
+**/
+VOID
+RegisterSmmTestPointSmiHandler (
+ VOID
+ );
+
+#endif \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointAip.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointAip.c
new file mode 100644
index 0000000000..11aea2c91f
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointAip.c
@@ -0,0 +1,175 @@
+/** @file
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "SmmTestPoint.h"
+
+/**
+ Returns the current state information for the adapter.
+
+ This function returns information of type InformationType from the adapter.
+ If an adapter does not support the requested informational type, then
+ EFI_UNSUPPORTED is returned.
+
+ @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.
+ @param[in] InformationType A pointer to an EFI_GUID that defines the contents of InformationBlock.
+ @param[out] InformationBlock The service returns a pointer to the buffer with the InformationBlock
+ structure which contains details about the data specific to InformationType.
+ @param[out] InformationBlockSize The driver returns the size of the InformationBlock in bytes.
+
+ @retval EFI_SUCCESS The InformationType information was retrieved.
+ @retval EFI_UNSUPPORTED The InformationType is not known.
+ @retval EFI_DEVICE_ERROR The device reported an error.
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
+ @retval EFI_INVALID_PARAMETER This is NULL.
+ @retval EFI_INVALID_PARAMETER InformationBlock is NULL.
+ @retval EFI_INVALID_PARAMETER InformationBlockSize is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+TestPointAipGetInfo (
+ IN EFI_ADAPTER_INFORMATION_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ OUT VOID **InformationBlock,
+ OUT UINTN *InformationBlockSize
+ )
+{
+ TEST_POINT_AIP_PRIVATE_DATA *TestPointAip;
+
+ if ((This == NULL) || (InformationBlock == NULL) || (InformationBlockSize == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (!CompareGuid (InformationType, &gAdapterInfoPlatformTestPointGuid)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ TestPointAip = TEST_POINT_AIP_PRIVATE_DATA_FROM_THIS(This);
+
+ *InformationBlock = AllocateCopyPool (TestPointAip->TestPointSize, TestPointAip->TestPoint);
+ if (*InformationBlock == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ *InformationBlockSize = TestPointAip->TestPointSize;
+ return EFI_SUCCESS;
+}
+
+/**
+ Sets state information for an adapter.
+
+ This function sends information of type InformationType for an adapter.
+ If an adapter does not support the requested information type, then EFI_UNSUPPORTED
+ is returned.
+
+ @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.
+ @param[in] InformationType A pointer to an EFI_GUID that defines the contents of InformationBlock.
+ @param[in] InformationBlock A pointer to the InformationBlock structure which contains details
+ about the data specific to InformationType.
+ @param[in] InformationBlockSize The size of the InformationBlock in bytes.
+
+ @retval EFI_SUCCESS The information was received and interpreted successfully.
+ @retval EFI_UNSUPPORTED The InformationType is not known.
+ @retval EFI_DEVICE_ERROR The device reported an error.
+ @retval EFI_INVALID_PARAMETER This is NULL.
+ @retval EFI_INVALID_PARAMETER InformationBlock is NULL.
+ @retval EFI_WRITE_PROTECTED The InformationType cannot be modified using EFI_ADAPTER_INFO_SET_INFO().
+
+**/
+EFI_STATUS
+EFIAPI
+TestPointAipSetInfo (
+ IN EFI_ADAPTER_INFORMATION_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN VOID *InformationBlock,
+ IN UINTN InformationBlockSize
+ )
+{
+ TEST_POINT_AIP_PRIVATE_DATA *TestPointAip;
+ VOID *NewTestPoint;
+
+ if ((This == NULL) || (InformationBlock == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (!CompareGuid (InformationType, &gAdapterInfoPlatformTestPointGuid)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (!InternalTestPointIsValidTable (InformationBlock, InformationBlockSize)) {
+ return EFI_VOLUME_CORRUPTED;
+ }
+
+ TestPointAip = TEST_POINT_AIP_PRIVATE_DATA_FROM_THIS(This);
+
+ if (InformationBlockSize > TestPointAip->TestPointMaxSize) {
+ NewTestPoint = AllocateZeroPool (InformationBlockSize);
+ if (NewTestPoint == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ FreePool (TestPointAip->TestPoint);
+ TestPointAip->TestPoint = NewTestPoint;
+ TestPointAip->TestPointSize = 0;
+ TestPointAip->TestPointMaxSize = InformationBlockSize;
+ }
+
+ CopyMem (TestPointAip->TestPoint, InformationBlock, InformationBlockSize);
+ TestPointAip->TestPointSize = InformationBlockSize;
+ return EFI_SUCCESS;
+}
+
+/**
+ Get a list of supported information types for this instance of the protocol.
+
+ This function returns a list of InformationType GUIDs that are supported on an
+ adapter with this instance of EFI_ADAPTER_INFORMATION_PROTOCOL. The list is returned
+ in InfoTypesBuffer, and the number of GUID pointers in InfoTypesBuffer is returned in
+ InfoTypesBufferCount.
+
+ @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance.
+ @param[out] InfoTypesBuffer A pointer to the array of InformationType GUIDs that are supported
+ by This.
+ @param[out] InfoTypesBufferCount A pointer to the number of GUIDs present in InfoTypesBuffer.
+
+ @retval EFI_SUCCESS The list of information type GUIDs that are supported on this adapter was
+ returned in InfoTypesBuffer. The number of information type GUIDs was
+ returned in InfoTypesBufferCount.
+ @retval EFI_INVALID_PARAMETER This is NULL.
+ @retval EFI_INVALID_PARAMETER InfoTypesBuffer is NULL.
+ @retval EFI_INVALID_PARAMETER InfoTypesBufferCount is NULL.
+ @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the results.
+
+**/
+EFI_STATUS
+EFIAPI
+TestPointAipGetSupportedTypes (
+ IN EFI_ADAPTER_INFORMATION_PROTOCOL *This,
+ OUT EFI_GUID **InfoTypesBuffer,
+ OUT UINTN *InfoTypesBufferCount
+ )
+{
+ if ((This == NULL) || (InfoTypesBuffer == NULL) || (InfoTypesBufferCount == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *InfoTypesBuffer = AllocateCopyPool (sizeof(gAdapterInfoPlatformTestPointGuid), &gAdapterInfoPlatformTestPointGuid);
+ if (*InfoTypesBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ *InfoTypesBufferCount = 1;
+
+ return EFI_SUCCESS;
+}
+
+EFI_ADAPTER_INFORMATION_PROTOCOL mAdapterInformationProtocol = {
+ TestPointAipGetInfo,
+ TestPointAipSetInfo,
+ TestPointAipGetSupportedTypes,
+};
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointCommunication.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointCommunication.c
new file mode 100644
index 0000000000..e6fb7bea0e
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointCommunication.c
@@ -0,0 +1,379 @@
+/** @file
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "SmmTestPoint.h"
+
+EFI_STATUS
+GetAllSmmTestPointData (
+ IN OUT UINTN *DataSize,
+ IN OUT VOID *Data
+ )
+{
+ EFI_STATUS Status;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ UINTN NoHandles;
+ EFI_HANDLE *Handles;
+ UINTN HandleBufSize;
+ UINTN Index;
+ EFI_GUID *InfoTypesBuffer;
+ UINTN InfoTypesBufferCount;
+ UINTN InfoTypesIndex;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *AipCandidate;
+ VOID *InformationBlock;
+ UINTN InformationBlockSize;
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN TotalSize;
+ EFI_STATUS RetStatus;
+
+ TotalSize = 0;
+
+ Handles = NULL;
+ HandleBufSize = 0;
+ Status = gSmst->SmmLocateHandle (
+ ByProtocol,
+ &gEfiAdapterInformationProtocolGuid,
+ NULL,
+ &HandleBufSize,
+ Handles
+ );
+ if (Status != EFI_BUFFER_TOO_SMALL) {
+ RetStatus = EFI_NOT_FOUND;
+ goto Done ;
+ }
+ Handles = AllocateZeroPool (HandleBufSize);
+ if (Handles == NULL) {
+ RetStatus = EFI_OUT_OF_RESOURCES;
+ goto Done ;
+ }
+ Status = gSmst->SmmLocateHandle (
+ ByProtocol,
+ &gEfiAdapterInformationProtocolGuid,
+ NULL,
+ &HandleBufSize,
+ Handles
+ );
+ if (EFI_ERROR (Status)) {
+ RetStatus = Status;
+ goto Done ;
+ }
+ NoHandles = HandleBufSize / sizeof(EFI_HANDLE);
+
+ RetStatus = EFI_SUCCESS;
+
+ TestPoint = NULL;
+ Aip = NULL;
+ InformationBlock = NULL;
+ InformationBlockSize = 0;
+ for (Index = 0; Index < NoHandles; Index++) {
+ Status = gSmst->SmmHandleProtocol (
+ Handles[Index],
+ &gEfiAdapterInformationProtocolGuid,
+ (VOID **)&Aip
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ //
+ // Check AIP
+ //
+ Status = Aip->GetSupportedTypes (
+ Aip,
+ &InfoTypesBuffer,
+ &InfoTypesBufferCount
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ AipCandidate = NULL;
+ for (InfoTypesIndex = 0; InfoTypesIndex < InfoTypesBufferCount; InfoTypesIndex++) {
+ if (CompareGuid (&InfoTypesBuffer[InfoTypesIndex], &gAdapterInfoPlatformTestPointGuid)) {
+ AipCandidate = Aip;
+ break;
+ }
+ }
+ FreePool (InfoTypesBuffer);
+
+ if (AipCandidate == NULL) {
+ continue;
+ }
+
+ //
+ // Check Role
+ //
+ Aip = AipCandidate;
+ Status = Aip->GetInformation (
+ Aip,
+ &gAdapterInfoPlatformTestPointGuid,
+ &InformationBlock,
+ &InformationBlockSize
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ if ((Data != NULL) && (TotalSize + InformationBlockSize <= *DataSize)) {
+ CopyMem ((UINT8 *)Data + TotalSize, InformationBlock, InformationBlockSize);
+ } else {
+ RetStatus = EFI_BUFFER_TOO_SMALL;
+ }
+ TotalSize += InformationBlockSize;
+
+ FreePool (InformationBlock);
+ }
+
+Done:
+
+ *DataSize = TotalSize;
+
+ if (Handles != NULL) {
+ FreePool (Handles);
+ }
+
+ return RetStatus;
+}
+
+/**
+ SMM test point SMI handler to get info.
+
+ @param SmiHandlerTestPointParameterGetInfo The parameter of SMM test point SMI handler get info.
+
+**/
+VOID
+SmmTestPointSmiHandlerGetInfo (
+ IN SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO *SmiHandlerTestPointParameterGetInfo
+ )
+{
+ UINTN DataSize;
+ EFI_STATUS Status;
+
+ DataSize = 0;
+ Status = GetAllSmmTestPointData (&DataSize, NULL);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ SmiHandlerTestPointParameterGetInfo->DataSize = DataSize;
+ SmiHandlerTestPointParameterGetInfo->Header.ReturnStatus = 0;
+ } else {
+ SmiHandlerTestPointParameterGetInfo->DataSize = 0;
+ SmiHandlerTestPointParameterGetInfo->Header.ReturnStatus = (UINT64)(INT64)(INTN)EFI_NOT_FOUND;
+ }
+}
+
+/**
+ Copy SMM Test Point data.
+
+ @param DataBuffer The buffer to hold SMM Test Point data.
+ @param DataSize On input, data buffer size.
+ On output, actual data buffer size copied.
+ @param DataOffset On input, data buffer offset to copy.
+ On output, next time data buffer offset to copy.
+
+**/
+VOID
+SmiHandlerTestPointCopyData (
+ IN VOID *InputData,
+ IN UINTN InputDataSize,
+ OUT VOID *DataBuffer,
+ IN OUT UINT64 *DataSize,
+ IN OUT UINT64 *DataOffset
+ )
+{
+ if (*DataOffset >= InputDataSize) {
+ *DataOffset = InputDataSize;
+ return;
+ }
+ if (InputDataSize - *DataOffset < *DataSize) {
+ *DataSize = InputDataSize - *DataOffset;
+ }
+
+ CopyMem(
+ DataBuffer,
+ (UINT8 *)InputData + *DataOffset,
+ (UINTN)*DataSize
+ );
+ *DataOffset = *DataOffset + *DataSize;
+}
+
+/**
+ SMM test point SMI handler to get data by offset.
+
+ @param SmiHandlerTestPointParameterGetDataByOffset The parameter of SMM test point SMI handler get data by offset.
+
+**/
+VOID
+SmmTestPointSmiHandlerGetDataByOffset (
+ IN SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET *SmiHandlerTestPointParameterGetDataByOffset
+ )
+{
+ SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET SmiHandlerTestPointGetDataByOffset;
+ VOID *Data;
+ UINTN DataSize;
+ EFI_STATUS Status;
+
+ Data = NULL;
+
+ CopyMem (
+ &SmiHandlerTestPointGetDataByOffset,
+ SmiHandlerTestPointParameterGetDataByOffset,
+ sizeof(SmiHandlerTestPointGetDataByOffset)
+ );
+
+ //
+ // Sanity check
+ //
+ if (!SmmIsBufferOutsideSmmValid((UINTN)SmiHandlerTestPointGetDataByOffset.DataBuffer, (UINTN)SmiHandlerTestPointGetDataByOffset.DataSize)) {
+ DEBUG((DEBUG_ERROR, "SmmTestPointSmiHandlerGetDataByOffset: SmmTestPoint get data in SMRAM or overflow!\n"));
+ SmiHandlerTestPointParameterGetDataByOffset->Header.ReturnStatus = (UINT64)(INT64)(INTN)EFI_ACCESS_DENIED;
+ goto Done;
+ }
+
+ DataSize = 0;
+ Status = GetAllSmmTestPointData (&DataSize, NULL);
+ if (Status != EFI_BUFFER_TOO_SMALL) {
+ SmiHandlerTestPointParameterGetDataByOffset->Header.ReturnStatus = (UINT64)(INT64)(INTN)EFI_NOT_FOUND;
+ goto Done;
+ }
+ Data = AllocatePool (DataSize);
+ if (Data == NULL) {
+ SmiHandlerTestPointParameterGetDataByOffset->Header.ReturnStatus = (UINT64)(INT64)(INTN)EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+ Status = GetAllSmmTestPointData (&DataSize, Data);
+ if (EFI_ERROR(Status)) {
+ SmiHandlerTestPointParameterGetDataByOffset->Header.ReturnStatus = (UINT64)(INT64)(INTN)Status;
+ goto Done;
+ }
+
+ SmiHandlerTestPointCopyData (
+ Data,
+ DataSize,
+ (VOID *)(UINTN)SmiHandlerTestPointGetDataByOffset.DataBuffer,
+ &SmiHandlerTestPointGetDataByOffset.DataSize,
+ &SmiHandlerTestPointGetDataByOffset.DataOffset
+ );
+
+ CopyMem (
+ SmiHandlerTestPointParameterGetDataByOffset,
+ &SmiHandlerTestPointGetDataByOffset,
+ sizeof(SmiHandlerTestPointGetDataByOffset)
+ );
+
+ SmiHandlerTestPointParameterGetDataByOffset->Header.ReturnStatus = 0;
+
+Done:
+ if (Data != NULL) {
+ FreePool (Data);
+ }
+}
+
+/**
+ Dispatch function for a Software SMI handler.
+
+ Caution: This function may receive untrusted input.
+ Communicate buffer and buffer size are external input, so this function will do basic validation.
+
+ @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
+ @param Context Points to an optional handler context which was specified when the
+ handler was registered.
+ @param CommBuffer A pointer to a collection of data in memory that will
+ be conveyed from a non-SMM environment into an SMM environment.
+ @param CommBufferSize The size of the CommBuffer.
+
+ @retval EFI_SUCCESS Command is handled successfully.
+**/
+EFI_STATUS
+EFIAPI
+SmmTestPointSmiHandler (
+ IN EFI_HANDLE DispatchHandle,
+ IN CONST VOID *Context OPTIONAL,
+ IN OUT VOID *CommBuffer OPTIONAL,
+ IN OUT UINTN *CommBufferSize OPTIONAL
+ )
+{
+ SMI_HANDLER_TEST_POINT_PARAMETER_HEADER *SmiHandlerTestPointParameterHeader;
+ UINTN TempCommBufferSize;
+
+ DEBUG((DEBUG_ERROR, "SmmTestPointSmiHandler Enter\n"));
+
+ //
+ // If input is invalid, stop processing this SMI
+ //
+ if (CommBuffer == NULL || CommBufferSize == NULL) {
+ return EFI_SUCCESS;
+ }
+
+ TempCommBufferSize = *CommBufferSize;
+
+ if (TempCommBufferSize < sizeof(SMI_HANDLER_TEST_POINT_PARAMETER_HEADER)) {
+ DEBUG((DEBUG_ERROR, "SmmTestPointSmiHandler: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+
+ if (!SmmIsBufferOutsideSmmValid((UINTN)CommBuffer, TempCommBufferSize)) {
+ DEBUG((DEBUG_ERROR, "SmmTestPointSmiHandler: SMM communication buffer in SMRAM or overflow!\n"));
+ return EFI_SUCCESS;
+ }
+
+ SmiHandlerTestPointParameterHeader = (SMI_HANDLER_TEST_POINT_PARAMETER_HEADER *)((UINTN)CommBuffer);
+ SmiHandlerTestPointParameterHeader->ReturnStatus = (UINT64)-1;
+
+ switch (SmiHandlerTestPointParameterHeader->Command) {
+ case SMI_HANDLER_TEST_POINT_COMMAND_GET_INFO:
+ DEBUG((DEBUG_ERROR, "SmiHandlerTestPointHandlerGetInfo\n"));
+ if (TempCommBufferSize != sizeof(SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO)) {
+ DEBUG((DEBUG_ERROR, "SmmTestPointSmiHandler: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ SmmTestPointSmiHandlerGetInfo((SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO *)(UINTN)CommBuffer);
+ break;
+ case SMI_HANDLER_TEST_POINT_COMMAND_GET_DATA_BY_OFFSET:
+ DEBUG((DEBUG_ERROR, "SmiHandlerTestPointHandlerGetDataByOffset\n"));
+ if (TempCommBufferSize != sizeof(SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET)) {
+ DEBUG((DEBUG_ERROR, "SmmTestPointSmiHandler: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ SmmTestPointSmiHandlerGetDataByOffset((SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET *)(UINTN)CommBuffer);
+ break;
+ default:
+ break;
+ }
+
+ DEBUG((DEBUG_ERROR, "SmmTestPointSmiHandler Exit\n"));
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Register SMM TestPoint handler.
+**/
+VOID
+RegisterSmmTestPointSmiHandler (
+ VOID
+ )
+{
+ EFI_HANDLE DispatchHandle;
+ EFI_STATUS Status;
+ STATIC BOOLEAN Registered = FALSE;
+
+ if (Registered) {
+ return ;
+ }
+
+ Status = gSmst->SmiHandlerRegister (
+ SmmTestPointSmiHandler,
+ &gAdapterInfoPlatformTestPointGuid,
+ &DispatchHandle
+ );
+ ASSERT_EFI_ERROR (Status);
+ Registered = TRUE;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointLib.inf
new file mode 100644
index 0000000000..4a03657d4f
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointLib.inf
@@ -0,0 +1,50 @@
+## @file
+# SMM instance of TestPoint Library.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SmmTestPointLib
+ FILE_GUID = 221290AE-AB4C-4FE1-B4C3-43A43BE13645
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TestPointLib
+
+[Sources]
+ SmmTestPointCommunication.c
+ SmmTestPointAip.c
+ SmmTestPoint.c
+ SmmTestPoint.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ DebugLib
+ SmmServicesTableLib
+ SmmMemLib
+
+[Guids]
+## SOMETIMES_PRODUCES ## GUID
+## SOMETIMES_CONSUMES ## GUID
+ gAdapterInfoPlatformTestPointGuid
+
+[Protocols]
+## SOMETIMES_PRODUCES
+## SOMETIMES_CONSUMES
+ gEfiAdapterInformationProtocolGuid
+
diff --git a/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDump.c b/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDump.c
new file mode 100644
index 0000000000..e35ae95222
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDump.c
@@ -0,0 +1,412 @@
+/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiDxe.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/HobLib.h>
+#include <Library/TestPointLib.h>
+#include <Protocol/AdapterInformation.h>
+#include <Protocol/SmmCommunication.h>
+#include <Guid/PiSmmCommunicationRegionTable.h>
+
+VOID
+DumpTestPoint (
+ IN VOID *TestPointData
+ )
+{
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINT8 *Features;
+ CHAR16 *ErrorString;
+ UINTN Index;
+ CHAR16 ErrorChar;
+
+ TestPoint = TestPointData;
+ Print (L"TestPoint\n");
+ Print (L" Version - 0x%08x\n", TestPoint->Version);
+ Print (L" Role - 0x%08x\n", TestPoint->Role);
+ Print (L" ImplementationID - %S\n", TestPoint->ImplementationID);
+ Print (L" FeaturesSize - 0x%08x\n", TestPoint->FeaturesSize);
+
+ Features = (UINT8 *)(TestPoint + 1);
+ Print (L" FeaturesRequired - ");
+ for (Index = 0; Index < TestPoint->FeaturesSize; Index++) {
+ Print (L"%02x ", Features[Index]);
+ }
+ Print (L"\n");
+
+ Features = (UINT8 *)(Features + TestPoint->FeaturesSize);
+ Print (L" FeaturesImplemented - ");
+ for (Index = 0; Index < TestPoint->FeaturesSize; Index++) {
+ Print (L"%02x ", Features[Index]);
+ }
+ Print (L"\n");
+
+ Features = (UINT8 *)(Features + TestPoint->FeaturesSize);
+ Print (L" FeaturesVerified - ");
+ for (Index = 0; Index < TestPoint->FeaturesSize; Index++) {
+ Print (L"%02x ", Features[Index]);
+ }
+ Print (L"\n");
+
+ ErrorString = (CHAR16 *)(Features + TestPoint->FeaturesSize);
+ Print (L" ErrorString - \"");
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ for (; ErrorChar != 0;) {
+ if (ErrorChar == L'\r') {
+ Print (L"\\r");
+ } else if (ErrorChar == L'\n') {
+ Print (L"\\n");
+ } else {
+ Print (L"%c", ErrorChar);
+ }
+ ErrorString++;
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ }
+ Print (L"\"\n");
+}
+
+VOID
+DumpTestPointDataPei (
+ IN UINT32 Role OPTIONAL,
+ IN CHAR16 *ImplementationID OPTIONAL
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+
+ Hob.Raw = GetHobList ();
+ while (TRUE) {
+ Hob.Raw = GetNextGuidHob (&gAdapterInfoPlatformTestPointGuid, Hob.Raw);
+ if (Hob.Raw == NULL) {
+ return ;
+ }
+ TestPoint = GET_GUID_HOB_DATA (Hob);
+
+ if ((Role == 0) ||
+ ((TestPoint->Role == Role) &&
+ ((ImplementationID == NULL) || (StrCmp (ImplementationID, TestPoint->ImplementationID) == 0)))) {
+ DumpTestPoint (TestPoint);
+ }
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ if (Hob.Raw == NULL) {
+ return ;
+ }
+ }
+}
+
+VOID
+DumpTestPointDataDxe (
+ IN UINT32 Role OPTIONAL,
+ IN CHAR16 *ImplementationID OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ UINTN NoHandles;
+ EFI_HANDLE *Handles;
+ UINTN Index;
+ EFI_GUID *InfoTypesBuffer;
+ UINTN InfoTypesBufferCount;
+ UINTN InfoTypesIndex;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *AipCandidate;
+ VOID *InformationBlock;
+ UINTN InformationBlockSize;
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiAdapterInformationProtocolGuid,
+ NULL,
+ &NoHandles,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ TestPoint = NULL;
+ Aip = NULL;
+ InformationBlock = NULL;
+ InformationBlockSize = 0;
+ for (Index = 0; Index < NoHandles; Index++) {
+ Status = gBS->HandleProtocol (
+ Handles[Index],
+ &gEfiAdapterInformationProtocolGuid,
+ (VOID **)&Aip
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ //
+ // Check AIP
+ //
+ Status = Aip->GetSupportedTypes (
+ Aip,
+ &InfoTypesBuffer,
+ &InfoTypesBufferCount
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ AipCandidate = NULL;
+ for (InfoTypesIndex = 0; InfoTypesIndex < InfoTypesBufferCount; InfoTypesIndex++) {
+ if (CompareGuid (&InfoTypesBuffer[InfoTypesIndex], &gAdapterInfoPlatformTestPointGuid)) {
+ AipCandidate = Aip;
+ break;
+ }
+ }
+ FreePool (InfoTypesBuffer);
+
+ if (AipCandidate == NULL) {
+ continue;
+ }
+
+ //
+ // Check Role
+ //
+ Aip = AipCandidate;
+ Status = Aip->GetInformation (
+ Aip,
+ &gAdapterInfoPlatformTestPointGuid,
+ &InformationBlock,
+ &InformationBlockSize
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ TestPoint = InformationBlock;
+
+ if ((Role == 0) ||
+ ((TestPoint->Role == Role) &&
+ ((ImplementationID == NULL) || (StrCmp (ImplementationID, TestPoint->ImplementationID) == 0)))) {
+ DumpTestPoint (TestPoint);
+ }
+ FreePool (InformationBlock);
+ }
+ FreePool (Handles);
+}
+
+UINTN mSmmTestPointDatabaseSize;
+VOID *mSmmTestPointDatabase;
+
+VOID
+GetTestPointDataSmm (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINTN CommSize;
+ UINT8 *CommBuffer;
+ EFI_SMM_COMMUNICATE_HEADER *CommHeader;
+ SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO *CommGetInfo;
+ SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET *CommGetData;
+ EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
+ UINTN MinimalSizeNeeded;
+ EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *PiSmmCommunicationRegionTable;
+ UINT32 Index;
+ EFI_MEMORY_DESCRIPTOR *Entry;
+ VOID *Buffer;
+ UINTN Size;
+ UINTN Offset;
+
+ Status = gBS->LocateProtocol(&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&SmmCommunication);
+ if (EFI_ERROR(Status)) {
+ Print(L"SmiHandlerTestPoint: Locate SmmCommunication protocol - %r\n", Status);
+ return ;
+ }
+
+ MinimalSizeNeeded = EFI_PAGE_SIZE;
+
+ Status = EfiGetSystemConfigurationTable(
+ &gEdkiiPiSmmCommunicationRegionTableGuid,
+ (VOID **)&PiSmmCommunicationRegionTable
+ );
+ if (EFI_ERROR(Status)) {
+ Print(L"SmiHandlerTestPoint: Get PiSmmCommunicationRegionTable - %r\n", Status);
+ return ;
+ }
+ ASSERT(PiSmmCommunicationRegionTable != NULL);
+ Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
+ Size = 0;
+ for (Index = 0; Index < PiSmmCommunicationRegionTable->NumberOfEntries; Index++) {
+ if (Entry->Type == EfiConventionalMemory) {
+ Size = EFI_PAGES_TO_SIZE((UINTN)Entry->NumberOfPages);
+ if (Size >= MinimalSizeNeeded) {
+ break;
+ }
+ }
+ Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
+ }
+ ASSERT(Index < PiSmmCommunicationRegionTable->NumberOfEntries);
+ CommBuffer = (UINT8 *)(UINTN)Entry->PhysicalStart;
+
+ //
+ // Get Size
+ //
+ CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
+ CopyMem(&CommHeader->HeaderGuid, &gAdapterInfoPlatformTestPointGuid, sizeof(gAdapterInfoPlatformTestPointGuid));
+ CommHeader->MessageLength = sizeof(SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO);
+
+ CommGetInfo = (SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO *)&CommBuffer[OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data)];
+ CommGetInfo->Header.Command = SMI_HANDLER_TEST_POINT_COMMAND_GET_INFO;
+ CommGetInfo->Header.DataLength = sizeof(*CommGetInfo);
+ CommGetInfo->Header.ReturnStatus = (UINT64)-1;
+ CommGetInfo->DataSize = 0;
+
+ CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLength;
+ Status = SmmCommunication->Communicate(SmmCommunication, CommBuffer, &CommSize);
+ if (EFI_ERROR(Status)) {
+ Print(L"SmiHandlerTestPoint: SmmCommunication - %r\n", Status);
+ return ;
+ }
+
+ if (CommGetInfo->Header.ReturnStatus != 0) {
+ Print(L"SmiHandlerTestPoint: GetInfo - 0x%0x\n", CommGetInfo->Header.ReturnStatus);
+ return ;
+ }
+
+ mSmmTestPointDatabaseSize = (UINTN)CommGetInfo->DataSize;
+
+ //
+ // Get Data
+ //
+ mSmmTestPointDatabase = AllocateZeroPool(mSmmTestPointDatabaseSize);
+ if (mSmmTestPointDatabase == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ Print(L"SmiHandlerTestPoint: AllocateZeroPool (0x%x) for dump buffer - %r\n", mSmmTestPointDatabaseSize, Status);
+ return ;
+ }
+
+ CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
+ CopyMem(&CommHeader->HeaderGuid, &gAdapterInfoPlatformTestPointGuid, sizeof(gAdapterInfoPlatformTestPointGuid));
+ CommHeader->MessageLength = sizeof(SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET);
+
+ CommGetData = (SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET *)&CommBuffer[OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data)];
+ CommGetData->Header.Command = SMI_HANDLER_TEST_POINT_COMMAND_GET_DATA_BY_OFFSET;
+ CommGetData->Header.DataLength = sizeof(*CommGetData);
+ CommGetData->Header.ReturnStatus = (UINT64)-1;
+
+ CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLength;
+ Buffer = (UINT8 *)CommHeader + CommSize;
+ Size -= CommSize;
+
+ CommGetData->DataBuffer = (PHYSICAL_ADDRESS)(UINTN)Buffer;
+ CommGetData->DataOffset = 0;
+ while (CommGetData->DataOffset < mSmmTestPointDatabaseSize) {
+ Offset = (UINTN)CommGetData->DataOffset;
+ if (Size <= (mSmmTestPointDatabaseSize - CommGetData->DataOffset)) {
+ CommGetData->DataSize = (UINT64)Size;
+ } else {
+ CommGetData->DataSize = (UINT64)(mSmmTestPointDatabaseSize - CommGetData->DataOffset);
+ }
+ Status = SmmCommunication->Communicate(SmmCommunication, CommBuffer, &CommSize);
+ ASSERT_EFI_ERROR(Status);
+
+ if (CommGetData->Header.ReturnStatus != 0) {
+ FreePool(mSmmTestPointDatabase);
+ mSmmTestPointDatabase = NULL;
+ Print(L"SmiHandlerTestPoint: GetData - 0x%x\n", CommGetData->Header.ReturnStatus);
+ return ;
+ }
+ CopyMem((UINT8 *)mSmmTestPointDatabase + Offset, (VOID *)(UINTN)CommGetData->DataBuffer, (UINTN)CommGetData->DataSize);
+ }
+
+ DEBUG ((DEBUG_INFO, "SmmTestPointDatabaseSize - 0x%x\n", mSmmTestPointDatabaseSize));
+
+ return ;
+}
+
+UINTN
+GetTestPointInfoSize (
+ IN ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint,
+ IN UINTN MaxSize
+ )
+{
+ CHAR16 *ErrorString;
+ UINTN ErrorStringLength;
+ UINTN ErrorStringMaxSize;
+ CHAR16 ErrorChar;
+
+ ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + 3 * TestPoint->FeaturesSize);
+
+ ErrorStringMaxSize = MaxSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3;
+ //
+ // ErrorString might not be CHAR16 aligned.
+ //
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ for (ErrorStringLength = 0; (ErrorChar != 0) && (ErrorStringLength < (ErrorStringMaxSize/2)); ErrorStringLength++) {
+ ErrorString++;
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ }
+
+ return sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + 3 * TestPoint->FeaturesSize + (ErrorStringLength + 1) * sizeof(CHAR16);
+}
+
+VOID
+DumpTestPointDataSmm (
+ IN UINT32 Role OPTIONAL,
+ IN CHAR16 *ImplementationID OPTIONAL
+ )
+{
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN Size;
+
+ GetTestPointDataSmm ();
+
+ if (mSmmTestPointDatabaseSize == 0) {
+ return ;
+ }
+ if (mSmmTestPointDatabase == NULL) {
+ return ;
+ }
+
+ TestPoint = mSmmTestPointDatabase;
+ while ((UINTN)TestPoint < (UINTN)mSmmTestPointDatabase + mSmmTestPointDatabaseSize) {
+ if ((Role == 0) ||
+ ((TestPoint->Role == Role) &&
+ ((ImplementationID == NULL) || (StrCmp (ImplementationID, TestPoint->ImplementationID) == 0)))) {
+ DumpTestPoint (TestPoint);
+ }
+
+ //
+ // Next
+ //
+ Size = GetTestPointInfoSize (TestPoint, (UINTN)mSmmTestPointDatabase + mSmmTestPointDatabaseSize - (UINTN)TestPoint);
+ TestPoint = (ADAPTER_INFO_PLATFORM_TEST_POINT *)((UINTN)TestPoint + Size);
+ }
+}
+
+EFI_STATUS
+EFIAPI
+TestPointDumpAppEntrypoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ Print(L"TestPoint PEI:\n");
+ DumpTestPointDataPei (0, NULL);
+ Print(L"TestPoint DXE:\n");
+ DumpTestPointDataDxe (0, NULL);
+ Print(L"TestPoint SMM:\n");
+ DumpTestPointDataSmm (0, NULL);
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDumpApp.inf b/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDumpApp.inf
new file mode 100644
index 0000000000..73ca073fe2
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDumpApp.inf
@@ -0,0 +1,49 @@
+## @file
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials are licensed and made available under
+# the terms and conditions of the BSD License that accompanies this distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TestPointDumpApp
+ FILE_GUID = C19F7B48-9D41-4975-A9CC-BC42B4DC3732
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = TestPointDumpAppEntrypoint
+
+[Sources]
+ TestPointDump.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ UefiApplicationEntryPoint
+ BaseLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ DebugLib
+ UefiBootServicesTableLib
+ UefiLib
+ HobLib
+
+[Guids]
+ gAdapterInfoPlatformTestPointGuid
+ gEdkiiPiSmmCommunicationRegionTableGuid
+
+[Protocols]
+ gEfiAdapterInformationProtocolGuid
+ gEfiSmmCommunicationProtocolGuid
+
+[Depex]
+ TRUE \ No newline at end of file