diff options
author | Jiewen Yao <jiewen.yao@intel.com> | 2017-05-20 15:42:12 +0800 |
---|---|---|
committer | Jiewen Yao <jiewen.yao@intel.com> | 2017-06-23 11:54:49 +0800 |
commit | 1f003fafade69043b4fd587dd30fc63997df0d3e (patch) | |
tree | 1cb078c51efe0c56ce1b0eb3598a121862c7376f /Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib | |
parent | 012d883a848bf7af8b4859394bb32f8b2a45313f (diff) | |
download | edk2-platforms-1f003fafade69043b4fd587dd30fc63997df0d3e.tar.xz |
Add MinPlatform.
reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
reviewed-by: Michael A Kubacki <michael.a.kubacki@intel.com>
reviewed-by: Amy Chan <amy.chan@intel.com>
reviewed-by: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib')
35 files changed, 5091 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
|