summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiewen Yao <jiewen.yao@intel.com>2017-10-05 22:25:51 +0800
committerJiewen Yao <jiewen.yao@intel.com>2017-10-24 19:43:22 +0800
commit602ca88a55162bf84c369d6924131f128a0ed356 (patch)
tree13a196e6bb2ade628fe877a4c7ed0c71a92535d7
parent5d307a4d238923cf79451899c7e6663ff210e48c (diff)
downloadedk2-platforms-602ca88a55162bf84c369d6924131f128a0ed356.tar.xz
Clean up Checkpoint.
1) CheckPointLib interface to be feature based, instead of phase based. 2) Rename file from Dump to Check. 3) Add TestPointStub to help convert PEI/SMM info to DXE protocol. 4) Implement all check points. Cc: Michael A Kubacki <michael.a.kubacki@intel.com> Cc: Amy Chan <amy.chan@intel.com> Cc: Chasel Chiu <chasel.chiu@intel.com> Cc: Brett Wang <brett.wang@intel.com> Cc: Daocheng Bu <daocheng.bu@intel.com> Cc: Isaac W Oram <isaac.w.oram@intel.com> Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Amy Chan <amy.chan@intel.com>
-rw-r--r--Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/PlatformInit.c2
-rw-r--r--Platform/Intel/MinPlatformPkg/Include/Library/TestPointCheckLib.h306
-rw-r--r--Platform/Intel/MinPlatformPkg/Include/Library/TestPointLib.h6
-rw-r--r--Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec2
-rw-r--r--Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc2
-rw-r--r--Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.c36
-rw-r--r--Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPostMem.c6
-rw-r--r--Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPreMem.c6
-rw-r--r--Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitSmm/PlatformInitSmm.c7
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpi.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpi.c)74
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiDmar.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiDmar.c)0
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiHpet.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiHpet.c)0
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiMadt.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMadt.c)0
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiMcfg.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMcfg.c)0
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiWsmt.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiWsmt.c)0
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpBootVariable.c)111
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckConsoleVariable.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpConsoleVariable.c)33
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckDevicePath.c188
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckEsrt.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpEsrt.c)10
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpGcd.c)35
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckHsti.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpHsti.c)17
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckLoadedImage.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpLoadedImage.c)56
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckMemoryAttribute.c346
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckMemoryMap.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemMap.c)103
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckMemoryTypeInformation.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemoryTypeInformation.c)10
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPci.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpPci.c)78
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPiSignedFvBoot.c33
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmiHandlerInstrument.c684
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmmInfo.c149
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckTcgMor.c69
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckTcgTrustedBoot.c80
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckUefiSecureBoot.c107
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckVariable.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpVariable.c)5
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpDevicePath.c78
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemAttribute.c89
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpSmmInfo.c80
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c619
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf65
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckFvInfo.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpFvInfo.c)78
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckHob.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpHob.c)126
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckMtrr.c442
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckPci.c87
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckSmmInfo.c232
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpMtrr.c77
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpSmramHob.c95
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.c263
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.inf17
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecCheckCpuInfo.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecDumpCpuInfo.c)1
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.c42
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf3
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckCommunicationBuffer.c103
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckLoadedImage.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpLoadedImage.c)5
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckMemoryAttribute.c174
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckPaging.c370
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckSmrr.c (renamed from Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpSmrr.c)24
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpMemAttribute.c86
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c168
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf16
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c191
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.c32
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.c38
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.c32
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDump.c234
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDumpApp.inf3
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c417
-rw-r--r--Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.inf57
66 files changed, 5638 insertions, 1267 deletions
diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/PlatformInit.c b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/PlatformInit.c
index 54eeda36a9..6d810686f3 100644
--- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/PlatformInit.c
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/PlatformInit.c
@@ -49,5 +49,5 @@ PlatformInit (
BoardAfterTempRamInit ();
- TestPointTempMemoryInitDone (StartOfRange, EndOfRange);
+ TestPointTempMemoryFunction (StartOfRange, EndOfRange);
}
diff --git a/Platform/Intel/MinPlatformPkg/Include/Library/TestPointCheckLib.h b/Platform/Intel/MinPlatformPkg/Include/Library/TestPointCheckLib.h
index 7caea0a53e..c551650824 100644
--- a/Platform/Intel/MinPlatformPkg/Include/Library/TestPointCheckLib.h
+++ b/Platform/Intel/MinPlatformPkg/Include/Library/TestPointCheckLib.h
@@ -20,10 +20,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
// Below is Test Point Hook Point.
//
+// Naming: TestPoint<Phase/Event><Function>
+//
+// Phase/Event(PEI) = MemoryDiscovered|EndOfPei
+// Phase/Event(DXE) = PciEnumerationDone|EndOfDxe|DxeSmmReadyToLock|ReadyToBoot
+// Phase/Event(SMM) = SmmEndOfDxe|SmmReadyToLock|SmmReadyToBoot
+//
EFI_STATUS
EFIAPI
-TestPointTempMemoryInitDone (
+TestPointTempMemoryFunction (
IN VOID *TempRamStart,
IN VOID *TempRamEnd
);
@@ -34,39 +40,148 @@ TestPointDebugInitDone (
VOID
);
+
+EFI_STATUS
+EFIAPI
+TestPointMemoryDiscoveredMtrrFunctional (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointMemoryDiscoveredMemoryResourceFunctional (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointMemoryDiscoveredFvInfoFunctional (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfPeiSystemResourceFunctional (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfPeiMtrrFunctional (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfPeiPciBusMasterDisabled (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointPciEnumerationDonePciBusMasterDisabled (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointPciEnumerationDonePciResourceAllocated (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfDxeDmarTableFuntional (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfDxeNoThirdPartyPciOptionRom (
+ VOID
+ );
+
EFI_STATUS
EFIAPI
-TestPointMemoryDiscovered (
+TestPointDxeSmmReadyToLockSmramAligned (
VOID
);
EFI_STATUS
EFIAPI
-TestPointEndOfPei (
+TestPointDxeSmmReadyToLockWsmtTableFuntional (
VOID
);
EFI_STATUS
EFIAPI
-TestPointPciEnumerationDone (
+TestPointReadyToBootAcpiTableFuntional (
VOID
);
EFI_STATUS
EFIAPI
-TestPointEndOfDxe (
+TestPointReadyToBootMemoryTypeInformationFunctional (
VOID
);
EFI_STATUS
EFIAPI
-TestPointDxeSmmReadyToLock (
+TestPointReadyToBootUefiMemoryAttributeTableFunctional (
VOID
);
EFI_STATUS
EFIAPI
-TestPointReadyToBoot (
+TestPointReadyToBootUefiBootVariableFunctional (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootUefiConsoleVariableFunctional (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootHstiTableFunctional (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootEsrtTableFunctional (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootUefiSecureBootEnabled (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootPiSignedFvBootEnabled (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootTcgTrustedBootEnabled (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootTcgMorEnabled (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootSmiHandlerInstrument (
VOID
);
@@ -78,19 +193,25 @@ TestPointExitBootServices (
EFI_STATUS
EFIAPI
-TestPointSmmEndOfDxe (
+TestPointSmmEndOfDxeSmrrFunctional (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+TestPointSmmReadyToLockSmmMemoryAttributeTableFunctional (
VOID
);
EFI_STATUS
EFIAPI
-TestPointSmmReadyToLock (
+TestPointSmmReadyToLockSecureSmmCommunicationBuffer (
VOID
);
EFI_STATUS
EFIAPI
-TestPointSmmReadyToBoot (
+TestPointSmmReadyToBootSmmPageProtection (
VOID
);
@@ -104,9 +225,12 @@ TestPointSmmExitBootServices (
// Below is detail definition for MinPlatform implementation
//
-#define TEST_POINT_IMPLEMENTATION_ID_PLATFORM L"Intel MinPlatform TestPoint"
+#define TEST_POINT_IMPLEMENTATION_ID_PLATFORM L"Intel MinPlatform TestPoint"
+#define TEST_POINT_IMPLEMENTATION_ID_PLATFORM_PEI TEST_POINT_IMPLEMENTATION_ID_PLATFORM L" (PEI)"
+#define TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE TEST_POINT_IMPLEMENTATION_ID_PLATFORM L" (DXE)"
+#define TEST_POINT_IMPLEMENTATION_ID_PLATFORM_SMM TEST_POINT_IMPLEMENTATION_ID_PLATFORM L" (SMM)"
-#define TEST_POINT_FEATURE_SIZE 4
+#define TEST_POINT_FEATURE_SIZE 0x10
#define TEST_POINT_ERROR L"Error "
#define TEST_POINT_PLATFORM_TEST_POINT L" Platform TestPoint"
@@ -115,8 +239,6 @@ TestPointSmmExitBootServices (
#define TEST_POINT_TEMP_MEMORY_INIT_DONE L" - Temp Memory Init Done - "
#define TEST_POINT_BYTE0_TEMP_INIT_DONE BIT0
-#define TEST_POINT_BYTE0_TEMP_MEMORY_INIT_DONE_ERROR_CODE_1 L"0x00000001"
-#define TEST_POINT_BYTE0_TEMP_MEMORY_INIT_DONE_ERROR_STRING_1 L"Invalid Temp Ram\r\n"
// Byte 1 - PEI
#define TEST_POINT_DEBUG_INIT_DONE L" - Debug Init Done - "
@@ -124,82 +246,107 @@ TestPointSmmExitBootServices (
#define TEST_POINT_END_OF_PEI L" - End Of PEI - "
#define TEST_POINT_BYTE1_DEBUG_INIT_DONE BIT0
-#define TEST_POINT_BYTE1_MEMORY_DISCOVERED BIT1
-#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_ERROR_CODE_1 L"0x01010001"
-#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_ERROR_STRING_1 L"Invalid Memory Resource\r\n"
-#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_ERROR_CODE_2 L"0x01010002"
-#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_ERROR_STRING_2 L"Invalid MTRR Setting\r\n"
-#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_ERROR_CODE_3 L"0x01010002"
-#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_ERROR_STRING_3 L"Invalid SMRAM Resource\r\n"
-#define TEST_POINT_BYTE1_END_OF_PEI BIT2
-#define TEST_POINT_BYTE1_END_OF_PEI_ERROR_CODE_1 L"0x01020001"
-#define TEST_POINT_BYTE1_END_OF_PEI_ERROR_STRING_1 L"Invalid System Resource\r\n"
-#define TEST_POINT_BYTE1_END_OF_PEI_ERROR_CODE_2 L"0x01020002"
-#define TEST_POINT_BYTE1_END_OF_PEI_ERROR_STRING_2 L"Invalid MTRR Setting\r\n"
-#define TEST_POINT_BYTE1_END_OF_PEI_ERROR_CODE_3 L"0x01010003"
-#define TEST_POINT_BYTE1_END_OF_PEI_ERROR_STRING_3 L"Invalid FV Information\r\n"
-
-// Byte 2 - DXE
+#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_MTRR_FUNCTIONAL BIT1
+#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_MEMORY_RESOURCE_FUNCTIONAL BIT2
+#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_FV_INFO_FUNCTIONAL BIT3
+#define TEST_POINT_BYTE1_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL BIT4
+#define TEST_POINT_BYTE1_END_OF_PEI_MTRR_FUNCTIONAL BIT5
+#define TEST_POINT_BYTE1_END_OF_PEI_PCI_BUS_MASTER_DISABLED BIT6
+#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_MTRR_FUNCTIONAL_ERROR_CODE L"0x01010000"
+#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_MTRR_FUNCTIONAL_ERROR_STRING L"Invalid MTRR Setting\r\n"
+#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_MEMORY_RESOURCE_FUNCTIONAL_ERROR_CODE L"0x01020000"
+#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_MEMORY_RESOURCE_FUNCTIONAL_ERROR_STRING L"Invalid Memory Resource\r\n"
+#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_FV_INFO_FUNCTIONAL_ERROR_CODE L"0x01030000"
+#define TEST_POINT_BYTE1_MEMORY_DISCOVERED_FV_INFO_FUNCTIONAL_ERROR_STRING L"Invalid FV Information\r\n"
+#define TEST_POINT_BYTE1_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL_ERROR_CODE L"0x01040000"
+#define TEST_POINT_BYTE1_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL_ERROR_STRING L"Invalid System Resource\r\n"
+#define TEST_POINT_BYTE1_END_OF_PEI_MTRR_FUNCTIONAL_ERROR_CODE L"0x01050000"
+#define TEST_POINT_BYTE1_END_OF_PEI_MTRR_FUNCTIONAL_ERROR_STRING L"Invalid MTRR Setting\r\n"
+#define TEST_POINT_BYTE1_END_OF_PEI_PCI_BUS_MASTER_DISABLED_ERROR_CODE L"0x01060000"
+#define TEST_POINT_BYTE1_END_OF_PEI_PCI_BUS_MASTER_DISABLED_ERROR_STRING L"PCI Bus Master Enabled\r\n"
+
+// Byte 2/3/4 - DXE
#define TEST_POINT_PCI_ENUMERATION_DONE L" - PCI Enumeration Done - "
#define TEST_POINT_END_OF_DXE L" - End Of DXE - "
#define TEST_POINT_DXE_SMM_READY_TO_LOCK L" - DXE SMM Ready To Lock - "
#define TEST_POINT_READY_TO_BOOT L" - Ready To Boot - "
#define TEST_POINT_EXIT_BOOT_SERVICES L" - Exit Boot Services - "
-#define TEST_POINT_BYTE2_PCI_ENUMERATION_DONE BIT0
-#define TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_ERROR_CODE_1 L"0x02010001"
-#define TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_ERROR_STRING_1 L"Invalid PCI Resource\r\n"
-#define TEST_POINT_BYTE2_END_OF_DXE BIT1
-#define TEST_POINT_BYTE2_END_OF_DXE_ERROR_CODE_1 L"0x02020001"
-#define TEST_POINT_BYTE2_END_OF_DXE_ERROR_STRING_1 L"Invalid PCI OROM\r\n"
-#define TEST_POINT_BYTE2_END_OF_DXE_ERROR_CODE_2 L"0x02020002"
-#define TEST_POINT_BYTE2_END_OF_DXE_ERROR_STRING_2 L"Invalid Memory Map\r\n"
-#define TEST_POINT_BYTE2_END_OF_DXE_ERROR_CODE_3 L"0x02020003"
-#define TEST_POINT_BYTE2_END_OF_DXE_ERROR_STRING_3 L"Invalid GCD Map\r\n"
-#define TEST_POINT_BYTE2_END_OF_DXE_ERROR_CODE_4 L"0x02020004"
-#define TEST_POINT_BYTE2_END_OF_DXE_ERROR_STRING_4 L"Invalid Console Variable\r\n"
-#define TEST_POINT_BYTE2_END_OF_DXE_ERROR_CODE_5 L"0x02020005"
-#define TEST_POINT_BYTE2_END_OF_DXE_ERROR_STRING_5 L"Invalid Boot Variable\r\n"
-#define TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK BIT2
-#define TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_ERROR_CODE_1 L"0x02040001"
-#define TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_ERROR_STRING_1 L"Invalid SMRAM Information\r\n"
-#define TEST_POINT_BYTE2_READY_TO_BOOT BIT3
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_1 L"0x02080001"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_1 L"Invalid Device\r\n"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_2 L"0x02080002"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_2 L"Invalid Memory Type Information\r\n"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_3 L"0x02080003"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_3 L"Invalid UEFI Variable\r\n"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_4 L"0x02080004"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_4 L"Invalid Memory Attribute Table\r\n"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_5 L"0x02080005"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_5 L"Invalid ACPI Table\r\n"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_6 L"0x02080006"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_6 L"Invalid WSMT Table\r\n"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_7 L"0x02080007"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_7 L"Invalid DMAR Table\r\n"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_8 L"0x02080008"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_8 L"Invalid HSTI\r\n"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_CODE_9 L"0x02080009"
-#define TEST_POINT_BYTE2_READY_TO_BOOT_ERROR_STRING_9 L"Invalid ESRT\r\n"
-#define TEST_POINT_BYTE2_EXIT_BOOT_SERVICES BIT4
-
-// Byte 3 - SMM
+#define TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_PCI_BUS_MASTER_DISABLED BIT0
+#define TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_RESOURCE_ALLOCATED BIT1
+#define TEST_POINT_BYTE2_END_OF_DXE_NO_THIRD_PARTY_PCI_OPTION_ROM BIT2
+#define TEST_POINT_BYTE2_END_OF_DXE_DMAT_TABLE_FUNCTIONAL BIT3
+#define TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_SMRAM_ALIGNED BIT4
+#define TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_WSMT_TABLE_FUNCTIONAL BIT5
+#define TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_PCI_BUS_MASTER_DISABLED_ERROR_CODE L"0x02000000"
+#define TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_PCI_BUS_MASTER_DISABLED_ERROR_STRING L"PCI Bus Master Enabled\r\n"
+#define TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_PCI_RESOURCE_ALLOCATED_ERROR_CODE L"0x02010000"
+#define TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_PCI_RESOURCE_ALLOCATED_ERROR_STRING L"Invalid PCI Resource\r\n"
+#define TEST_POINT_BYTE2_END_OF_DXE_NO_THIRD_PARTY_PCI_OPTION_ROM_ERROR_CODE L"0x02020000"
+#define TEST_POINT_BYTE2_END_OF_DXE_NO_THIRD_PARTY_PCI_OPTION_ROM_ERROR_STRING L"Third Party Option ROM dispatched\r\n"
+#define TEST_POINT_BYTE2_END_OF_DXE_DMAT_TABLE_FUNCTIONAL_ERROR_CODE L"0x02030000"
+#define TEST_POINT_BYTE2_END_OF_DXE_DMAT_TABLE_FUNCTIONAL_ERROR_STRING L"No DMAR table\r\n"
+#define TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_SMRAM_ALIGNED_ERROR_CODE L"0x02040000"
+#define TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_SMRAM_ALIGNED_ERROR_STRING L"Invalid SMRAM Information\r\n"
+#define TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_WSMT_TABLE_FUNCTIONAL_ERROR_CODE L"0x02050000"
+#define TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_WSMT_TABLE_FUNCTIONAL_ERROR_STRING L"No WSMT table\r\n"
+
+#define TEST_POINT_BYTE3_READY_TO_BOOT_ACPI_TABLE_FUNCTIONAL BIT0
+#define TEST_POINT_BYTE3_READY_TO_BOOT_MEMORY_TYPE_INFORMATION_FUNCTIONAL BIT1
+#define TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL BIT2
+#define TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_BOOT_VARIABLE_FUNCTIONAL BIT3
+#define TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_CONSOLE_VARIABLE_FUNCTIONAL BIT4
+#define TEST_POINT_BYTE3_READY_TO_BOOT_HSTI_TABLE_FUNCTIONAL BIT5
+#define TEST_POINT_BYTE3_READY_TO_BOOT_SMI_HANDLER_INSTRUMENT BIT6
+#define TEST_POINT_BYTE3_READY_TO_BOOT_ACPI_TABLE_FUNCTIONAL_ERROR_CODE L"0x03000000"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_ACPI_TABLE_FUNCTIONAL_ERROR_STRING L"Invalid ACPI Table\r\n"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_MEMORY_TYPE_INFORMATION_FUNCTIONAL_ERROR_CODE L"0x03010000"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_MEMORY_TYPE_INFORMATION_FUNCTIONAL_ERROR_STRING L"Invalid Memory Type Information\r\n"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL_ERROR_CODE L"0x03020000"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL_ERROR_STRING L"Invalid Memory Attribute Table\r\n"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_BOOT_VARIABLE_FUNCTIONAL_ERROR_CODE L"0x03030000"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_BOOT_VARIABLE_FUNCTIONAL_ERROR_STRING L"Invalid Boot Variable\r\n"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_CONSOLE_VARIABLE_FUNCTIONAL_ERROR_CODE L"0x03040000"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_CONSOLE_VARIABLE_FUNCTIONAL_ERROR_STRING L"Invalid Console Variable\r\n"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_HSTI_TABLE_FUNCTIONAL_ERROR_CODE L"0x03050000"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_HSTI_TABLE_FUNCTIONAL_ERROR_STRING L"No HSTI\r\n"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_SMI_HANDLER_INSTRUMENT_ERROR_CODE L"0x03060000"
+#define TEST_POINT_BYTE3_READY_TO_BOOT_SMI_HANDLER_INSTRUMENT_ERROR_STRING L"No SMI Instrument\r\n"
+
+#define TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED BIT0
+#define TEST_POINT_BYTE4_READY_TO_BOOT_PI_SIGNED_FV_BOOT_ENABLED BIT1
+#define TEST_POINT_BYTE4_READY_TO_BOOT_TCG_TRUSTED_BOOT_ENABLED BIT2
+#define TEST_POINT_BYTE4_READY_TO_BOOT_TCG_MOR_ENABLED BIT3
+#define TEST_POINT_BYTE4_READY_TO_BOOT_ESRT_TABLE_FUNCTIONAL BIT4
+#define TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED_ERROR_CODE L"0x04000000"
+#define TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED_ERROR_STRING L"UEFI Secure Boot Disable\r\n"
+#define TEST_POINT_BYTE4_READY_TO_BOOT_PI_SIGNED_FV_BOOT_ENABLED_ERROR_CODE L"0x04010000"
+#define TEST_POINT_BYTE4_READY_TO_BOOT_PI_SIGNED_FV_BOOT_ENABLED_ERROR_STRING L"PI Signed FV Boot Disable\r\n"
+#define TEST_POINT_BYTE4_READY_TO_BOOT_TCG_TRUSTED_BOOT_ENABLED_ERROR_CODE L"0x04020000"
+#define TEST_POINT_BYTE4_READY_TO_BOOT_TCG_TRUSTED_BOOT_ENABLED_ERROR_STRING L"TCG Trusted Boot Disable\r\n"
+#define TEST_POINT_BYTE4_READY_TO_BOOT_TCG_MOR_ENABLED_ERROR_CODE L"0x04030000"
+#define TEST_POINT_BYTE4_READY_TO_BOOT_TCG_MOR_ENABLED_ERROR_STRING L"TCG MOR not enabled\r\n"
+#define TEST_POINT_BYTE4_READY_TO_BOOT_ESRT_TABLE_FUNCTIONAL_ERROR_CODE L"0x04040000"
+#define TEST_POINT_BYTE4_READY_TO_BOOT_ESRT_TABLE_FUNCTIONAL_ERROR_STRING L"No ESRT\r\n"
+
+// Byte 5 - SMM
#define TEST_POINT_SMM_END_OF_DXE L" - SMM End Of DXE - "
#define TEST_POINT_SMM_READY_TO_LOCK L" - SMM Ready To Lock - "
#define TEST_POINT_SMM_READY_TO_BOOT L" - SMM Ready To Boot - "
#define TEST_POINT_SMM_EXIT_BOOT_SERVICES L" - SMM Exit Boot Services - "
-#define TEST_POINT_BYTE3_SMM_END_OF_DXE BIT0
-#define TEST_POINT_BYTE3_SMM_END_OF_DXE_ERROR_CODE_1 L"0x03010001"
-#define TEST_POINT_BYTE3_SMM_END_OF_DXE_ERROR_STRING_1 L"Invalid SMM Image\r\n"
-#define TEST_POINT_BYTE3_SMM_READY_TO_LOCK BIT1
-#define TEST_POINT_BYTE2_SMM_READY_TO_LOCK_ERROR_CODE_1 L"0x03020001"
-#define TEST_POINT_BYTE2_SMM_READY_TO_LOCK_ERROR_STRING_1 L"Invalid SMM Memory Attribute Table\r\n"
-#define TEST_POINT_BYTE2_SMM_READY_TO_LOCK_ERROR_CODE_2 L"0x03020002"
-#define TEST_POINT_BYTE2_SMM_READY_TO_LOCK_ERROR_STRING_2 L"Invalid SMRR\r\n"
-#define TEST_POINT_BYTE3_SMM_READY_TO_BOOT BIT2
-#define TEST_POINT_BYTE3_SMM_EXIT_BOOT_SERVICES BIT3
+#define TEST_POINT_BYTE5_SMM_END_OF_DXE_SMRR_FUNCTIONAL BIT0
+#define TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SMM_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL BIT1
+#define TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER BIT2
+#define TEST_POINT_BYTE5_SMM_READY_TO_BOOT_SMM_PAGE_LEVEL_PROTECTION BIT3
+#define TEST_POINT_BYTE5_SMM_END_OF_DXE_SMRR_FUNCTIONAL_ERROR_CODE L"0x05000000"
+#define TEST_POINT_BYTE5_SMM_END_OF_DXE_SMRR_FUNCTIONAL_ERROR_STRING L"Invalid SMRR\r\n"
+#define TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SMM_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL_ERROR_CODE L"0x05010000"
+#define TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SMM_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL_ERROR_STRING L"Invalid SMM Memory Attribute Table\r\n"
+#define TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER_ERROR_CODE L"0x05020000"
+#define TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER_ERROR_STRING L"Unsecure SMM communication buffer\r\n"
+#define TEST_POINT_BYTE5_SMM_READY_TO_BOOT_SMM_PAGE_LEVEL_PROTECTION_ERROR_CODE L"0x05030000"
+#define TEST_POINT_BYTE5_SMM_READY_TO_BOOT_SMM_PAGE_LEVEL_PROTECTION_ERROR_STRING L"SMM page level protection disabled\r\n"
#pragma pack (1)
@@ -208,7 +355,6 @@ typedef struct {
UINT32 Role;
CHAR16 ImplementationID[256];
UINT32 FeaturesSize;
- UINT8 FeaturesRequired[TEST_POINT_FEATURE_SIZE];
UINT8 FeaturesImplemented[TEST_POINT_FEATURE_SIZE];
UINT8 FeaturesVerified[TEST_POINT_FEATURE_SIZE];
CHAR16 End;
diff --git a/Platform/Intel/MinPlatformPkg/Include/Library/TestPointLib.h b/Platform/Intel/MinPlatformPkg/Include/Library/TestPointLib.h
index 49d5f84cb0..a8b21ca001 100644
--- a/Platform/Intel/MinPlatformPkg/Include/Library/TestPointLib.h
+++ b/Platform/Intel/MinPlatformPkg/Include/Library/TestPointLib.h
@@ -33,12 +33,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define PLATFORM_TEST_POINT_ROLE_IMPLEMENTOR_OEM 0x00000003
#define PLATFORM_TEST_POINT_ROLE_IMPLEMENTOR_ODM 0x00000004
+#define TEST_POINT_FEATURES_ITEM_NUMBER 2
+
typedef struct {
UINT32 Version;
UINT32 Role;
CHAR16 ImplementationID[256];
UINT32 FeaturesSize;
-//UINT8 FeaturesRequired[];
//UINT8 FeaturesImplemented[];
//UINT8 FeaturesVerified[];
//CHAR16 ErrorString[];
@@ -53,9 +54,6 @@ typedef struct {
One system should have only one PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE.
- If the Role is NOT PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE,
- FeaturesRequired field will be ignored.
-
@param TestPoint TestPoint data
@param TestPointSize TestPoint size
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
index 0416e1f067..e41880442c 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
@@ -169,7 +169,7 @@ gMinPlatformModuleTokenSpaceGuid.PcdHstiIbvPlatformFeature|{0x00, 0x00, 0x00}|VO
#
# It means BYTE<X> BIT<Y> is for feature <AAA>.
#
-gMinPlatformModuleTokenSpaceGuid.PcdTestPointIbvPlatformFeature|{0x00, 0x07, 0x0F, 0x03}|VOID*|0x00100302
+gMinPlatformModuleTokenSpaceGuid.PcdTestPointIbvPlatformFeature|{0x01, 0x7F, 0x3F, 0x7F, 0x1F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}|VOID*|0x00100302
[PcdsDynamic]
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
index 4d8945244a..9cf1d373fe 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
@@ -49,6 +49,7 @@
gMinPlatformModuleTokenSpaceGuid.PcdUefiSecureBootEnable|FALSE
gMinPlatformModuleTokenSpaceGuid.PcdTpm2Enable|FALSE
gMinPlatformModuleTokenSpaceGuid.PcdPerformanceEnable|FALSE
+ gMinPlatformModuleTokenSpaceGuid.PcdSmiHandlerProfileEnable|FALSE
################################################################################
#
@@ -181,6 +182,7 @@
MinPlatformPkg/Test/Library/TestPointLib/DxeTestPointLib.inf
MinPlatformPkg/Test/Library/TestPointLib/PeiTestPointLib.inf
MinPlatformPkg/Test/Library/TestPointLib/SmmTestPointLib.inf
+ MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.inf
MinPlatformPkg/Test/TestPointDumpApp/TestPointDumpApp.inf
!if gMinPlatformModuleTokenSpaceGuid.PcdTpm2Enable == TRUE
diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.c b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.c
index c8eca1c613..b3a08150a8 100644
--- a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.c
+++ b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.c
@@ -32,6 +32,9 @@ PlatformInitUnRegisterRscHandler (
VOID
);
+EFI_EVENT mRscNotifyEvent = NULL;
+EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;
+
/**
PciEnumerationComplete Protocol notification event handler.
@@ -64,7 +67,9 @@ OnPciEnumerationComplete (
Status = BoardInitAfterPciEnumeration ();
ASSERT_EFI_ERROR(Status);
- TestPointPciEnumerationDone ();
+ TestPointPciEnumerationDonePciBusMasterDisabled ();
+
+ TestPointPciEnumerationDonePciResourceAllocated ();
}
/**
@@ -83,8 +88,10 @@ OnEndOfDxe (
)
{
gBS->CloseEvent (Event);
+
+ TestPointEndOfDxeNoThirdPartyPciOptionRom ();
- TestPointEndOfDxe ();
+ TestPointEndOfDxeDmarTableFuntional ();
}
/**
@@ -116,7 +123,9 @@ OnDxeSmmReadyToLock (
return ;
}
- TestPointDxeSmmReadyToLock ();
+ TestPointDxeSmmReadyToLockSmramAligned ();
+
+ TestPointDxeSmmReadyToLockWsmtTableFuntional ();
}
/**
@@ -247,9 +256,6 @@ BoardNotificationInitEntryPoint (
return EFI_SUCCESS;
}
-EFI_EVENT mRscNotifyEvent = NULL;
-EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;
-
/**
Report status code listener
for OsLoaderLoadImageStart and OsLoaderStartImageStart.
@@ -280,6 +286,7 @@ PlatformInitStatusCodeListener (
)
{
EFI_STATUS Status;
+ STATIC BOOLEAN Tested = FALSE;
//
// Check whether status code is what we are interested in.
@@ -290,7 +297,22 @@ PlatformInitStatusCodeListener (
Status = EFI_SUCCESS;
if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)) {
- TestPointReadyToBoot ();
+ if (!Tested) {
+ TestPointReadyToBootAcpiTableFuntional ();
+ TestPointReadyToBootMemoryTypeInformationFunctional ();
+ TestPointReadyToBootUefiMemoryAttributeTableFunctional ();
+ TestPointReadyToBootUefiBootVariableFunctional ();
+ TestPointReadyToBootUefiConsoleVariableFunctional ();
+ TestPointReadyToBootHstiTableFunctional ();
+ TestPointReadyToBootSmiHandlerInstrument ();
+
+ TestPointReadyToBootUefiSecureBootEnabled ();
+ TestPointReadyToBootPiSignedFvBootEnabled ();
+ TestPointReadyToBootTcgTrustedBootEnabled ();
+ TestPointReadyToBootTcgMorEnabled ();
+ TestPointReadyToBootEsrtTableFunctional ();
+ Tested = TRUE;
+ }
} else if (Value == PcdGet32 (PcdProgressCodeOsLoaderLoad)) {
} else if (Value == PcdGet32 (PcdProgressCodeOsLoaderStart)) {
} else if (Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) {
diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPostMem.c b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPostMem.c
index e8c3485186..99261471fa 100644
--- a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPostMem.c
+++ b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPostMem.c
@@ -189,10 +189,14 @@ PlatformInitEndOfPei (
Status = BoardInitAfterSiliconInit ();
ASSERT_EFI_ERROR (Status);
+ TestPointEndOfPeiSystemResourceFunctional ();
+
+ TestPointEndOfPeiPciBusMasterDisabled ();
+
Status = SetCacheMtrrAfterEndOfPei ();
ASSERT_EFI_ERROR (Status);
- TestPointEndOfPei ();
+ TestPointEndOfPeiMtrrFunctional ();
return Status;
}
diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPreMem.c b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPreMem.c
index d76020d220..77f5a7de4f 100644
--- a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPreMem.c
+++ b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPreMem.c
@@ -412,6 +412,10 @@ MemoryDiscoveredPpiNotifyCallback (
ReportCpuHob ();
+ TestPointMemoryDiscoveredMtrrFunctional ();
+
+ TestPointMemoryDiscoveredMemoryResourceFunctional ();
+
///
/// If S3 resume, then we are done
///
@@ -421,7 +425,7 @@ MemoryDiscoveredPpiNotifyCallback (
ReportFv ();
- TestPointMemoryDiscovered ();
+ TestPointMemoryDiscoveredFvInfoFunctional ();
if (PcdGetBool (PcdStopAfterMemInit)) {
CpuDeadLoop ();
diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitSmm/PlatformInitSmm.c b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitSmm/PlatformInitSmm.c
index c4d3f52436..685e2b5386 100644
--- a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitSmm/PlatformInitSmm.c
+++ b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitSmm/PlatformInitSmm.c
@@ -45,7 +45,7 @@ SmmEndOfDxeEventNotify (
IN EFI_HANDLE Handle
)
{
- TestPointSmmEndOfDxe ();
+ TestPointSmmEndOfDxeSmrrFunctional ();
return EFI_SUCCESS;
}
@@ -66,7 +66,8 @@ SmmReadyToLockEventNotify (
IN EFI_HANDLE Handle
)
{
- TestPointSmmReadyToLock ();
+ TestPointSmmReadyToLockSmmMemoryAttributeTableFunctional ();
+ TestPointSmmReadyToLockSecureSmmCommunicationBuffer ();
return EFI_SUCCESS;
}
@@ -87,7 +88,7 @@ SmmReadyToBootEventNotify (
IN EFI_HANDLE Handle
)
{
- TestPointSmmReadyToBoot ();
+ TestPointSmmReadyToBootSmmPageProtection ();
return EFI_SUCCESS;
}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpi.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpi.c
index c5c79ac40d..e2ee1e201c 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpi.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpi.c
@@ -25,9 +25,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#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
@@ -153,11 +150,9 @@ DumpAcpiTable (
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;
@@ -168,7 +163,9 @@ DumpAcpiTable (
EFI_STATUS
DumpAcpiRsdt (
- IN EFI_ACPI_DESCRIPTION_HEADER *Rsdt
+ IN EFI_ACPI_DESCRIPTION_HEADER *Rsdt,
+ IN UINT32 *Signature, OPTIONAL
+ OUT VOID **OutTable
)
{
EFI_STATUS Status;
@@ -191,6 +188,9 @@ DumpAcpiRsdt (
if (EFI_ERROR(Status)) {
Result = FALSE;
}
+ if (Signature != NULL && Table->Signature == *Signature) {
+ *OutTable = Table;
+ }
}
if (!Result) {
return EFI_INVALID_PARAMETER;
@@ -200,7 +200,9 @@ DumpAcpiRsdt (
EFI_STATUS
DumpAcpiXsdt (
- IN EFI_ACPI_DESCRIPTION_HEADER *Xsdt
+ IN EFI_ACPI_DESCRIPTION_HEADER *Xsdt,
+ IN UINT32 *Signature, OPTIONAL
+ OUT VOID **OutTable
)
{
EFI_STATUS Status;
@@ -226,6 +228,9 @@ DumpAcpiXsdt (
if (EFI_ERROR(Status)) {
Result = FALSE;
}
+ if (Signature != NULL && Table->Signature == *Signature) {
+ *OutTable = Table;
+ }
}
if (!Result) {
return EFI_INVALID_PARAMETER;
@@ -235,7 +240,9 @@ DumpAcpiXsdt (
EFI_STATUS
DumpAcpiRsdp (
- IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp
+ IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp,
+ IN UINT32 *Signature, OPTIONAL
+ OUT VOID **Table
)
{
EFI_STATUS Status;
@@ -259,13 +266,13 @@ DumpAcpiRsdp (
//
if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) {
Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN) Rsdp->XsdtAddress;
- Status = DumpAcpiXsdt (Xsdt);
+ Status = DumpAcpiXsdt (Xsdt, Signature, Table);
} else {
//
// Search RSDT
//
Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN) Rsdp->RsdtAddress;
- Status = DumpAcpiRsdt (Rsdt);
+ Status = DumpAcpiRsdt (Rsdt, Signature, Table);
}
return Status;
@@ -273,7 +280,9 @@ DumpAcpiRsdp (
EFI_STATUS
DumpAcpiWithGuid (
- IN EFI_GUID *AcpiTableGuid
+ IN EFI_GUID *AcpiTableGuid,
+ IN UINT32 *Signature, OPTIONAL
+ OUT VOID **Table
)
{
VOID *Rsdp;
@@ -284,57 +293,66 @@ DumpAcpiWithGuid (
return EFI_NOT_FOUND;
}
- Status = DumpAcpiRsdp (Rsdp);
+ Status = DumpAcpiRsdp (Rsdp, Signature, Table);
return Status;
}
EFI_STATUS
-TestPointDumpAcpi (
- VOID
+TestPointCheckAcpi (
+ IN UINT32 *Signature OPTIONAL
)
{
EFI_STATUS Status;
+ VOID *Table;
- DEBUG ((DEBUG_INFO, "==== TestPointDumpAcpi - Enter\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckAcpi - Enter\n"));
DEBUG ((DEBUG_INFO, "AcpiTable :\n"));
DEBUG ((DEBUG_INFO, " Table Address Rev OemId OemTableId OemRev Creat CreatorRev\n"));
- Status = DumpAcpiWithGuid (&gEfiAcpi20TableGuid);
+ Table = NULL;
+ Status = DumpAcpiWithGuid (&gEfiAcpi20TableGuid, Signature, &Table);
if (Status == EFI_NOT_FOUND) {
- Status = DumpAcpiWithGuid (&gEfiAcpi10TableGuid);
+ Status = DumpAcpiWithGuid (&gEfiAcpi10TableGuid, Signature, &Table);
}
- DEBUG ((DEBUG_INFO, "==== TestPointDumpAcpi - Exit\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckAcpi - Exit\n"));
- if (EFI_ERROR(Status)) {
+ if ((Signature == NULL) && (EFI_ERROR(Status))) {
+ DEBUG ((DEBUG_ERROR, "No ACPI table\n"));
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
+ TEST_POINT_BYTE3_READY_TO_BOOT_ACPI_TABLE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE3_READY_TO_BOOT_ACPI_TABLE_FUNCTIONAL_ERROR_STRING
);
}
- if (!mWsmtFound) {
+ if ((Signature != NULL) && (*Signature == EFI_ACPI_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE) &&
+ ((EFI_ERROR(Status)) || (Table == NULL))) {
+ DEBUG ((DEBUG_ERROR, "No WSMT table\n"));
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
+ TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_WSMT_TABLE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_DXE_SMM_READY_TO_LOCK \
+ TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_WSMT_TABLE_FUNCTIONAL_ERROR_STRING
);
Status = EFI_INVALID_PARAMETER;
}
- if (!mDmarFound) {
+ if ((Signature != NULL) && (*Signature == EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE) &&
+ ((EFI_ERROR(Status)) || (Table == NULL))) {
+ DEBUG ((DEBUG_ERROR, "No DMAR table\n"));
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
+ TEST_POINT_BYTE2_END_OF_DXE_DMAT_TABLE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_END_OF_DXE \
+ TEST_POINT_BYTE2_END_OF_DXE_DMAT_TABLE_FUNCTIONAL_ERROR_STRING
);
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/DxeCheckAcpiDmar.c
index 7277389a23..7277389a23 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiDmar.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiDmar.c
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiHpet.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiHpet.c
index 4eba26ca8f..4eba26ca8f 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiHpet.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiHpet.c
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMadt.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiMadt.c
index 9da138daad..9da138daad 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMadt.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiMadt.c
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMcfg.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiMcfg.c
index 097a688004..097a688004 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiMcfg.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiMcfg.c
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiWsmt.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiWsmt.c
index 001b1d4357..001b1d4357 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpAcpiWsmt.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiWsmt.c
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpBootVariable.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c
index 763960cf5a..1c39b29b8e 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpBootVariable.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c
@@ -21,6 +21,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
+BOOLEAN
+IsDevicePathExist (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ );
+
CHAR16 *mLoadOptionVariableList[] = {
L"Boot",
L"Driver",
@@ -67,6 +72,31 @@ DumpLoadOption (
}
}
+EFI_STATUS
+TestPointCheckLoadOption (
+ IN CHAR16 *OptionName,
+ IN EFI_LOAD_OPTION *LoadOption,
+ IN UINTN Size
+ )
+{
+ CHAR16 *Description;
+ EFI_DEVICE_PATH_PROTOCOL *FilePathList;
+
+ if (LoadOption == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Description = (CHAR16 *)(LoadOption + 1);
+
+ FilePathList = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)Description + StrSize (Description));
+
+ if (!IsDevicePathExist (FilePathList)) {
+ DEBUG ((DEBUG_ERROR, "DevicePath not found!\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
+
VOID
DumpKeyOption (
IN CHAR16 *OptionName,
@@ -86,8 +116,8 @@ DumpKeyOption (
DEBUG ((DEBUG_INFO, "\n"));
}
-VOID
-DumpLoadOptionVariable (
+EFI_STATUS
+TestPointCheckLoadOptionVariable (
VOID
)
{
@@ -100,7 +130,9 @@ DumpLoadOptionVariable (
EFI_STATUS Status;
CHAR16 BootOptionName[sizeof(L"PlatformRecovery####")];
CHAR16 BootOrderName[sizeof(L"PlatformRecoveryOrder")];
+ EFI_STATUS ReturnStatus;
+ ReturnStatus = EFI_SUCCESS;
for (ListIndex = 0; ListIndex < sizeof(mLoadOptionVariableList)/sizeof(mLoadOptionVariableList[0]); ListIndex++) {
UnicodeSPrint (BootOrderName, sizeof(BootOrderName), L"%sOrder", mLoadOptionVariableList[ListIndex]);
Status = GetVariable2 (BootOrderName, &gEfiGlobalVariableGuid, &BootOrder, &OrderSize);
@@ -112,15 +144,28 @@ DumpLoadOptionVariable (
Status = GetVariable2 (BootOptionName, &gEfiGlobalVariableGuid, &Variable, &Size);
if (!EFI_ERROR(Status)) {
DumpLoadOption (BootOptionName, Variable, Size);
+ Status = TestPointCheckLoadOption (BootOptionName, Variable, Size);
+ if (EFI_ERROR(Status)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_BOOT_VARIABLE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_BOOT_VARIABLE_FUNCTIONAL_ERROR_STRING
+ );
+ ReturnStatus = Status;
+ }
} else {
DumpLoadOption (BootOptionName, NULL, 0);
}
}
}
+
+ return ReturnStatus;
}
-VOID
-DumpPlatformRecoveryOptionVariable (
+EFI_STATUS
+TestPointCheckPlatformRecoveryOptionVariable (
VOID
)
{
@@ -130,29 +175,45 @@ DumpPlatformRecoveryOptionVariable (
UINTN Index;
EFI_STATUS Status;
CHAR16 PlatformRecoveryOptionName[sizeof(L"PlatformRecovery####")];
+ EFI_STATUS ReturnStatus;
+ ReturnStatus = EFI_SUCCESS;
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);
+ Status = TestPointCheckLoadOption (PlatformRecoveryOptionName, Variable, Size);
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_BOOT_VARIABLE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_BOOT_VARIABLE_FUNCTIONAL_ERROR_STRING
+ );
+ }
} else {
break;
}
}
}
+
+ return ReturnStatus;
}
-VOID
-DumpOsRecoveryOptionVariable (
+EFI_STATUS
+TestPointCheckOsRecoveryOptionVariable (
VOID
)
{
+ return EFI_SUCCESS;
}
-VOID
-DumpKeyOptionVariable (
+EFI_STATUS
+TestPointCheckKeyOptionVariable (
VOID
)
{
@@ -174,22 +235,38 @@ DumpKeyOptionVariable (
}
}
}
+
+ return EFI_SUCCESS;
}
EFI_STATUS
-TestPointDumpBootVariable (
+TestPointCheckBootVariable (
VOID
)
{
- DEBUG ((DEBUG_INFO, "==== TestPointDumpBootVariable - Enter\n"));
+ EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckBootVariable - Enter\n"));
- DumpLoadOptionVariable ();
- DumpPlatformRecoveryOptionVariable ();
- DumpOsRecoveryOptionVariable ();
- DumpKeyOptionVariable ();
+ Status = TestPointCheckLoadOptionVariable ();
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ }
+ Status = TestPointCheckPlatformRecoveryOptionVariable ();
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ }
+ Status = TestPointCheckOsRecoveryOptionVariable ();
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ }
+ Status = TestPointCheckKeyOptionVariable ();
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ }
- DEBUG ((DEBUG_INFO, "==== TestPointDumpBootVariable - Exit\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckBootVariable - Exit\n"));
- // Check - TBD
- return EFI_SUCCESS;
+ return ReturnStatus;
} \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpConsoleVariable.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckConsoleVariable.c
index b78235a73f..635ca3c48e 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpConsoleVariable.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckConsoleVariable.c
@@ -20,6 +20,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
+BOOLEAN
+IsDevicePathExist (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePathTarget
+ );
+
CHAR16 *mConsoleVariableList[] = {
L"ConIn",
L"ConInDev",
@@ -46,7 +51,7 @@ DumpDevicePath (
}
EFI_STATUS
-TestPointDumpConsoleVariable (
+TestPointCheckConsoleVariable (
VOID
)
{
@@ -54,16 +59,32 @@ TestPointDumpConsoleVariable (
UINTN Size;
UINTN Index;
EFI_STATUS Status;
-
- DEBUG ((DEBUG_INFO, "==== TestPointDumpConsoleVariable - Enter\n"));
+ BOOLEAN Result;
+
+ Result = TRUE;
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckConsoleVariable - 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);
+ if (!IsDevicePathExist (Variable)) {
+ DEBUG ((DEBUG_ERROR, "DevicePath not found!\n"));
+ Result = FALSE;
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_CONSOLE_VARIABLE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_CONSOLE_VARIABLE_FUNCTIONAL_ERROR_STRING
+ );
+ }
}
}
- DEBUG ((DEBUG_INFO, "==== TestPointDumpConsoleVariable - Exit\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckConsoleVariable - Exit\n"));
- // Check - TBD
- return EFI_SUCCESS;
+ if (Result) {
+ return EFI_SUCCESS;
+ } else {
+ return EFI_INVALID_PARAMETER;
+ }
}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckDevicePath.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckDevicePath.c
new file mode 100644
index 0000000000..aee43aa051
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckDevicePath.c
@@ -0,0 +1,188 @@
+/** @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/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Protocol/LoadedImage.h>
+#include <Protocol/DevicePath.h>
+
+VOID
+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 - Exit\n"));
+
+ return ;
+}
+
+/**
+ The DevicePathNode is a single instance.
+ The DevicePathNodeSize must not include END_DEVICE_PATH.
+**/
+BOOLEAN
+IsDevicePathNodeExist (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
+ IN UINTN DevicePathNodeSize
+ )
+{
+ UINTN Index;
+ EFI_HANDLE *HandleBuf;
+ UINTN HandleCount;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
+ BOOLEAN Result;
+ UINTN DevicePathSize;
+
+ if (DevicePathType (DevicePathNode) == HARDWARE_DEVICE_PATH ||
+ DevicePathType (DevicePathNode) == ACPI_DEVICE_PATH) {
+ Result = FALSE;
+ HandleBuf = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDevicePathProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuf
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done ;
+ }
+
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (
+ HandleBuf[Index],
+ &gEfiDevicePathProtocolGuid,
+ (VOID**)&DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+ DevicePathSize = GetDevicePathSize(DevicePath);
+ if (DevicePathSize != DevicePathNodeSize + sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
+ continue;
+ }
+ if (CompareMem (DevicePath, DevicePathNode, DevicePathNodeSize) == 0) {
+ Result = TRUE;
+ break;
+ }
+ }
+
+ Done:
+ if (HandleBuf != NULL) {
+ FreePool (HandleBuf);
+ }
+ return Result;
+ }
+
+ if (DevicePathType (DevicePathNode) == MESSAGING_DEVICE_PATH) {
+ return TRUE;
+ }
+
+ if (DevicePathType (DevicePathNode) == MEDIA_DEVICE_PATH) {
+ return TRUE;
+ }
+
+ if (DevicePathType (DevicePathNode) == BBS_DEVICE_PATH) {
+ return TRUE;
+ }
+
+ return TRUE;
+}
+
+/**
+ The DevicePathTarget might be multiple instance.
+ The DevicePathTarget must be ended with END_ENTIRE_DEVICE_PATH_SUBTYPE.
+**/
+BOOLEAN
+IsDevicePathExist (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
+ BOOLEAN Result;
+
+ TmpDevicePath = DevicePath;
+ DevicePathNode = DevicePath;
+ while (!IsDevicePathEnd (TmpDevicePath)) {
+ if (IsDevicePathEndInstance (TmpDevicePath)) {
+ //
+ // DevicePath is a multi-instance device path
+ //
+ Result = IsDevicePathNodeExist (DevicePathNode, (UINTN)TmpDevicePath - (UINTN)DevicePathNode);
+ if (!Result) {
+ return FALSE;
+ }
+ DevicePathNode = NextDevicePathNode (TmpDevicePath);
+ }
+ TmpDevicePath = NextDevicePathNode (TmpDevicePath);
+ }
+ Result = IsDevicePathNodeExist (DevicePathNode, (UINTN)TmpDevicePath - (UINTN)DevicePathNode);
+ if (!Result) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpEsrt.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckEsrt.c
index 48c1eaa3a3..37ed123457 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpEsrt.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckEsrt.c
@@ -96,14 +96,14 @@ DumpEsrt (
}
EFI_STATUS
-TestPointDumpEsrt (
+TestPointCheckEsrt (
VOID
)
{
EFI_STATUS Status;
EFI_SYSTEM_RESOURCE_TABLE *Esrt;
- DEBUG ((DEBUG_INFO, "==== TestPointDumpEsrt - Enter\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckEsrt - Enter\n"));
Status = EfiGetSystemConfigurationTable (&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
if (!EFI_ERROR(Status)) {
DumpEsrt(Esrt);
@@ -111,10 +111,12 @@ TestPointDumpEsrt (
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
+ TEST_POINT_BYTE4_READY_TO_BOOT_ESRT_TABLE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE4_READY_TO_BOOT_ESRT_TABLE_FUNCTIONAL_ERROR_STRING
);
}
- DEBUG ((DEBUG_INFO, "==== TestPointDumpEsrt - Exit\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckEsrt - 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/DxeCheckGcd.c
index 46fde33ab1..2f40573368 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpGcd.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c
@@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/TestPointCheckLib.h>
#include <Library/TestPointLib.h>
#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
#include <Library/DxeServicesTableLib.h>
CHAR8 *mGcdMemoryTypeShortName[] = {
@@ -177,9 +178,12 @@ PrintIoDescriptor (
DEBUG ((DEBUG_INFO, "\n"));
}
-EFI_STATUS
+VOID
TestPointDumpGcd (
- VOID
+ OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **GcdMemoryMap, OPTIONAL
+ OUT UINTN *GcdMemoryMapNumberOfDescriptors, OPTIONAL
+ OUT EFI_GCD_IO_SPACE_DESCRIPTOR **GcdIoMap, OPTIONAL
+ OUT UINTN *GcdIoMapNumberOfDescriptors OPTIONAL
)
{
EFI_STATUS Status;
@@ -187,6 +191,15 @@ TestPointDumpGcd (
EFI_GCD_IO_SPACE_DESCRIPTOR *IoMap;
UINTN NumberOfDescriptors;
UINTN Index;
+
+ if (GcdMemoryMap != NULL) {
+ *GcdMemoryMap = NULL;
+ *GcdMemoryMapNumberOfDescriptors = 0;
+ }
+ if (GcdIoMap != NULL) {
+ *GcdIoMap = NULL;
+ *GcdIoMapNumberOfDescriptors = 0;
+ }
DEBUG ((DEBUG_INFO, "==== TestPointDumpGcd - Enter\n"));
DEBUG ((DEBUG_INFO, "GCD MEM:\n"));
@@ -201,13 +214,10 @@ TestPointDumpGcd (
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;
+ if (GcdMemoryMap != NULL) {
+ *GcdMemoryMap = AllocateCopyPool (NumberOfDescriptors * sizeof(EFI_GCD_MEMORY_SPACE_DESCRIPTOR), MemoryMap);
+ *GcdMemoryMapNumberOfDescriptors = NumberOfDescriptors;
+ }
}
DEBUG ((DEBUG_INFO, "GCD IO:\n"));
@@ -222,9 +232,12 @@ TestPointDumpGcd (
for (Index = 0; Index < NumberOfDescriptors; Index++) {
PrintIoDescriptor (&IoMap[Index]);
}
+ if (GcdMemoryMap != NULL) {
+ *GcdIoMap = AllocateCopyPool (NumberOfDescriptors * sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ *GcdIoMapNumberOfDescriptors = NumberOfDescriptors;
+ }
}
-Done:
DEBUG ((DEBUG_INFO, "==== TestPointDumpGcd - Exit\n"));
- return Status;
+ return ;
}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpHsti.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckHsti.c
index 826a0b1ba4..909d84ac68 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpHsti.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckHsti.c
@@ -46,13 +46,6 @@ DumpHsti (
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]));
@@ -85,7 +78,7 @@ UINT32 mRole[] = {
};
EFI_STATUS
-TestPointDumpHsti (
+TestPointCheckHsti (
VOID
)
{
@@ -96,7 +89,7 @@ TestPointDumpHsti (
BOOLEAN Result;
Result = TRUE;
- DEBUG ((DEBUG_INFO, "==== TestPointDumpHsti - Enter\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckHsti - Enter\n"));
for (Index = 0; Index < sizeof(mRole)/sizeof(mRole[0]); Index++) {
Status = HstiLibGetTable (mRole[Index], NULL, &Hsti, &HstiSize);
if (EFI_ERROR (Status)) {
@@ -109,13 +102,15 @@ TestPointDumpHsti (
DumpHsti (Hsti);
FreePool (Hsti);
}
- DEBUG ((DEBUG_INFO, "==== TestPointDumpHsti - Exit\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckHsti - 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
+ TEST_POINT_BYTE3_READY_TO_BOOT_HSTI_TABLE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE3_READY_TO_BOOT_HSTI_TABLE_FUNCTIONAL_ERROR_STRING
);
return EFI_NOT_FOUND;
}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpLoadedImage.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckLoadedImage.c
index 8b717e08ed..7aa93d0976 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpLoadedImage.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckLoadedImage.c
@@ -141,7 +141,39 @@ DumpLoadedImage (
}
EFI_STATUS
-TestPointDumpLoadedImage (
+TestPointCheckNon3rdPartyImage (
+ IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath
+ )
+{
+ if (LoadedImageDevicePath != NULL) {
+ // LoadedImageDevicePath should be Fv()/FvFile()
+ if (DevicePathType (LoadedImageDevicePath) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (LoadedImageDevicePath) == MEDIA_PIWG_FW_VOL_DP) {
+ return EFI_SUCCESS;
+ }
+ } else {
+ if (LoadedImage->FilePath != NULL) {
+ // LoadedImage->FilePath should be FvFile()
+ if (DevicePathType (LoadedImage->FilePath) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (LoadedImage->FilePath) == MEDIA_PIWG_FW_FILE_DP) {
+ return EFI_SUCCESS;
+ }
+ }
+ if (DevicePath != NULL) {
+ // DevicePath should be Fv()
+ if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (DevicePath) == MEDIA_PIWG_FW_VOL_DP) {
+ return EFI_SUCCESS;
+ }
+ }
+ }
+ return EFI_INVALID_PARAMETER;
+}
+
+EFI_STATUS
+TestPointCheckLoadedImage (
VOID
)
{
@@ -152,8 +184,10 @@ TestPointDumpLoadedImage (
UINTN HandleCount;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
+ EFI_STATUS ReturnStatus;
- DEBUG ((DEBUG_INFO, "==== TestPointDumpLoadedImage - Enter\n"));
+ ReturnStatus = EFI_SUCCESS;
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckLoadedImage - Enter\n"));
HandleBuf = NULL;
Status = gBS->LocateHandleBuffer (
ByProtocol,
@@ -188,6 +222,19 @@ TestPointDumpLoadedImage (
}
DumpLoadedImage (Index, LoadedImage, DevicePath, LoadedImageDevicePath);
+
+ Status = TestPointCheckNon3rdPartyImage (LoadedImage, DevicePath, LoadedImageDevicePath);
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ DEBUG ((DEBUG_ERROR, "3rd Party Image found - Index (%d)\n", Index));
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_END_OF_DXE_NO_THIRD_PARTY_PCI_OPTION_ROM_ERROR_CODE \
+ TEST_POINT_END_OF_DXE \
+ TEST_POINT_BYTE2_END_OF_DXE_NO_THIRD_PARTY_PCI_OPTION_ROM_ERROR_STRING
+ );
+ }
}
Done:
@@ -196,8 +243,7 @@ Done:
FreePool (HandleBuf);
}
- DEBUG ((DEBUG_INFO, "==== TestPointDumpLoadedImage - Exit\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckLoadedImage - Exit\n"));
- // Check - TBD
- return EFI_SUCCESS;
+ return ReturnStatus;
}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckMemoryAttribute.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckMemoryAttribute.c
new file mode 100644
index 0000000000..af48eb1b43
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckMemoryAttribute.c
@@ -0,0 +1,346 @@
+/** @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 <Library/PeCoffGetEntryPointLib.h>
+#include <Guid/MemoryAttributesTable.h>
+#include <Protocol/Runtime.h>
+
+CHAR8 *
+ShortNameOfMemoryType(
+ IN UINT32 Type
+ );
+
+VOID
+TestPointDumpMemoryAttributesTable (
+ 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
+TestPointCheckMemoryAttribute (
+ IN EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable,
+ IN EFI_PHYSICAL_ADDRESS Base,
+ IN UINT64 Size,
+ IN BOOLEAN IsCode,
+ IN BOOLEAN IsFromSmm
+ )
+{
+ UINTN Index;
+ EFI_MEMORY_DESCRIPTOR *Entry;
+
+ DEBUG ((DEBUG_ERROR, "Attribute Checking 0x%lx - 0x%lx\n", Base, Size));
+ Entry = (EFI_MEMORY_DESCRIPTOR *)(MemoryAttributesTable + 1);
+ for (Index = 0; Index < MemoryAttributesTable->NumberOfEntries; Index++) {
+ if (Base >= Entry->PhysicalStart && Base+Size <= Entry->PhysicalStart+MultU64x64 (SIZE_4KB,Entry->NumberOfPages)) {
+ if (IsFromSmm) {
+ if (IsCode) {
+ if (Entry->Type != EfiRuntimeServicesCode) {
+ DEBUG ((DEBUG_ERROR, "Invalid Entry->Type %d\n", Entry->Type));
+ return EFI_INVALID_PARAMETER;
+ }
+ if ((Entry->Attribute & (EFI_MEMORY_RO | EFI_MEMORY_XP)) != EFI_MEMORY_RO) {
+ DEBUG ((DEBUG_ERROR, "Invalid Code Entry->Attribute 0x%lx\n", Entry->Attribute));
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ if (Entry->Type != EfiRuntimeServicesData) {
+ DEBUG ((DEBUG_ERROR, "Invalid Entry->Type %d\n", Entry->Type));
+ return EFI_INVALID_PARAMETER;
+ }
+ if ((Entry->Attribute & (EFI_MEMORY_RO | EFI_MEMORY_XP)) != EFI_MEMORY_XP) {
+ DEBUG ((DEBUG_ERROR, "Invalid Data Entry->Attribute 0x%lx\n", Entry->Attribute));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ } else {
+ if (Entry->Type != EfiRuntimeServicesCode) {
+ DEBUG ((DEBUG_ERROR, "Invalid Entry->Type %d\n", Entry->Type));
+ return EFI_INVALID_PARAMETER;
+ }
+ if (IsCode) {
+ if ((Entry->Attribute & (EFI_MEMORY_RO | EFI_MEMORY_XP)) != EFI_MEMORY_RO) {
+ DEBUG ((DEBUG_ERROR, "Invalid Code Entry->Attribute 0x%lx\n", Entry->Attribute));
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ if ((Entry->Attribute & (EFI_MEMORY_RO | EFI_MEMORY_XP)) != EFI_MEMORY_XP) {
+ DEBUG ((DEBUG_ERROR, "Invalid Data Entry->Attribute 0x%lx\n", Entry->Attribute));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+TestPointCheckImageMemoryAttribute (
+ IN EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable,
+ IN EFI_PHYSICAL_ADDRESS ImageBase,
+ IN UINT64 ImageSize,
+ IN BOOLEAN IsFromSmm
+ )
+{
+ EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
+ VOID *ImageAddress;
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ UINT32 PeCoffHeaderOffset;
+ UINT32 SectionAlignment;
+ UINT16 ImageType;
+ EFI_IMAGE_SECTION_HEADER *Section;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ UINT16 Magic;
+ UINT8 *Name;
+ UINTN Index;
+ CHAR8 *PdbPointer;
+
+ ReturnStatus = EFI_SUCCESS;
+ //
+ // Check whole region
+ //
+ ImageAddress = (VOID *)(UINTN)ImageBase;
+
+ PdbPointer = PeCoffLoaderGetPdbPointer (ImageAddress);
+ if (PdbPointer != NULL) {
+ DEBUG ((EFI_D_INFO, " Image - %a\n", PdbPointer));
+ }
+
+ //
+ // Check PE/COFF image
+ //
+ DosHdr = (EFI_IMAGE_DOS_HEADER *) (UINTN) ImageAddress;
+ PeCoffHeaderOffset = 0;
+ if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ PeCoffHeaderOffset = DosHdr->e_lfanew;
+ }
+
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINT8 *) (UINTN) ImageAddress + PeCoffHeaderOffset);
+ if (Hdr.Pe32->Signature != EFI_IMAGE_NT_SIGNATURE) {
+ DEBUG ((EFI_D_INFO, "Hdr.Pe32->Signature invalid - 0x%x\n", Hdr.Pe32->Signature));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Measuring PE/COFF Image Header;
+ // But CheckSum field and SECURITY data directory (certificate) are excluded
+ //
+ if (Hdr.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value
+ // in the PE/COFF Header. If the MachineType is Itanium(IA64) and the
+ // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
+ // then override the magic value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ ImageType = Hdr.Pe32->OptionalHeader.Subsystem;
+ SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment;
+ } else {
+ //
+ // Get the magic value from the PE/COFF Optional Header
+ //
+ Magic = Hdr.Pe32->OptionalHeader.Magic;
+ ImageType = Hdr.Pe32Plus->OptionalHeader.Subsystem;
+ SectionAlignment = Hdr.Pe32Plus->OptionalHeader.SectionAlignment;
+ }
+
+ if ((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) {
+ DEBUG ((EFI_D_INFO, "!!!!!!!! RecordImageMemoryMap - Section Alignment(0x%x) is not %dK !!!!!!!!\n", SectionAlignment, RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));
+ PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress);
+ if (PdbPointer != NULL) {
+ DEBUG ((EFI_D_INFO, "!!!!!!!! Image - %a !!!!!!!!\n", PdbPointer));
+ }
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Section = (EFI_IMAGE_SECTION_HEADER *) (
+ (UINT8 *) (UINTN) ImageAddress +
+ PeCoffHeaderOffset +
+ sizeof(UINT32) +
+ sizeof(EFI_IMAGE_FILE_HEADER) +
+ Hdr.Pe32->FileHeader.SizeOfOptionalHeader
+ );
+
+ Status = TestPointCheckMemoryAttribute (
+ MemoryAttributesTable,
+ (UINTN)ImageAddress,
+ (UINTN)&Section[Hdr.Pe32->FileHeader.NumberOfSections] - (UINTN)ImageAddress,
+ FALSE,
+ IsFromSmm
+ );
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ }
+
+ for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) {
+ Name = Section[Index].Name;
+ DEBUG ((
+ EFI_D_INFO,
+ " Section - '%c%c%c%c%c%c%c%c'\n",
+ Name[0],
+ Name[1],
+ Name[2],
+ Name[3],
+ Name[4],
+ Name[5],
+ Name[6],
+ Name[7]
+ ));
+
+ DEBUG ((EFI_D_INFO, " VirtualSize - 0x%08x\n", Section[Index].Misc.VirtualSize));
+ DEBUG ((EFI_D_INFO, " VirtualAddress - 0x%08x\n", Section[Index].VirtualAddress));
+ DEBUG ((EFI_D_INFO, " SizeOfRawData - 0x%08x\n", Section[Index].SizeOfRawData));
+ DEBUG ((EFI_D_INFO, " PointerToRawData - 0x%08x\n", Section[Index].PointerToRawData));
+ DEBUG ((EFI_D_INFO, " PointerToRelocations - 0x%08x\n", Section[Index].PointerToRelocations));
+ DEBUG ((EFI_D_INFO, " PointerToLinenumbers - 0x%08x\n", Section[Index].PointerToLinenumbers));
+ DEBUG ((EFI_D_INFO, " NumberOfRelocations - 0x%08x\n", Section[Index].NumberOfRelocations));
+ DEBUG ((EFI_D_INFO, " NumberOfLinenumbers - 0x%08x\n", Section[Index].NumberOfLinenumbers));
+ DEBUG ((EFI_D_INFO, " Characteristics - 0x%08x\n", Section[Index].Characteristics));
+ if ((Section[Index].Characteristics & EFI_IMAGE_SCN_CNT_CODE) != 0) {
+ //
+ // Check code section
+ //
+ Status = TestPointCheckMemoryAttribute (
+ MemoryAttributesTable,
+ (UINTN)ImageAddress + Section[Index].VirtualAddress,
+ Section[Index].SizeOfRawData,
+ TRUE,
+ IsFromSmm
+ );
+ } else {
+ //
+ // Check data section
+ //
+ Status = TestPointCheckMemoryAttribute (
+ MemoryAttributesTable,
+ (UINTN)ImageAddress + Section[Index].VirtualAddress,
+ Section[Index].SizeOfRawData,
+ FALSE,
+ IsFromSmm
+ );
+ }
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ }
+ }
+
+ return ReturnStatus;
+}
+
+EFI_STATUS
+TestPointCheckUefiMemoryAttributesTable (
+ IN EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
+ EFI_RUNTIME_ARCH_PROTOCOL *RuntimeArch;
+ LIST_ENTRY *Link;
+ EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage;
+
+ Status = gBS->LocateProtocol (
+ &gEfiRuntimeArchProtocolGuid,
+ NULL,
+ &RuntimeArch
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+
+ ReturnStatus = EFI_SUCCESS;
+ for (Link = RuntimeArch->ImageHead.ForwardLink; Link != &(RuntimeArch->ImageHead); Link = Link->ForwardLink) {
+ RuntimeImage = BASE_CR (Link, EFI_RUNTIME_IMAGE_ENTRY, Link);
+ Status = TestPointCheckImageMemoryAttribute (
+ MemoryAttributesTable,
+ (EFI_PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase,
+ RuntimeImage->ImageSize,
+ FALSE
+ );
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ }
+ }
+
+ return ReturnStatus;
+}
+
+EFI_STATUS
+TestPointCheckUefiMemAttribute (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *MemoryAttributesTable;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckUefiMemAttribute - Enter\n"));
+ Status = EfiGetSystemConfigurationTable (&gEfiMemoryAttributesTableGuid, &MemoryAttributesTable);
+ if (!EFI_ERROR (Status)) {
+ TestPointDumpMemoryAttributesTable(MemoryAttributesTable);
+ Status = TestPointCheckUefiMemoryAttributesTable(MemoryAttributesTable);
+ }
+
+ if (EFI_ERROR (Status)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL_ERROR_STRING
+ );
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckUefiMemAttribute - Exit\n"));
+
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemMap.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckMemoryMap.c
index 6d59c7773c..ab4aa99b01 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemMap.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckMemoryMap.c
@@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/PrintLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
CHAR8 *mMemoryTypeShortName[] = {
"Reserved ",
@@ -64,7 +65,7 @@ ShortNameOfMemoryType(
@param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
**/
VOID
-DumpMemoryMap (
+TestPointDumpMemoryMap (
IN EFI_MEMORY_DESCRIPTOR *MemoryMap,
IN UINTN MemoryMapSize,
IN UINTN DescriptorSize
@@ -115,7 +116,7 @@ DumpMemoryMap (
}
BOOLEAN
-IsGoodMemoryMap (
+TestPointCheckUefiMemoryMapEntry (
IN EFI_MEMORY_DESCRIPTOR *MemoryMap,
IN UINTN MemoryMapSize,
IN UINTN DescriptorSize
@@ -136,6 +137,18 @@ IsGoodMemoryMap (
}
Entry = NEXT_MEMORY_DESCRIPTOR (Entry, DescriptorSize);
}
+ if (EntryCount[EfiRuntimeServicesCode] > 1) {
+ DEBUG ((DEBUG_ERROR, "EfiRuntimeServicesCode entry - %d\n", EntryCount[EfiRuntimeServicesCode]));
+ }
+ if (EntryCount[EfiRuntimeServicesData] > 1) {
+ DEBUG ((DEBUG_ERROR, "EfiRuntimeServicesData entry - %d\n", EntryCount[EfiRuntimeServicesCode]));
+ }
+ if (EntryCount[EfiACPIMemoryNVS] > 1) {
+ DEBUG ((DEBUG_ERROR, "EfiACPIMemoryNVS entry - %d\n", EntryCount[EfiACPIMemoryNVS]));
+ }
+ if (EntryCount[EfiACPIReclaimMemory] > 1) {
+ DEBUG ((DEBUG_ERROR, "EfiACPIReclaimMemory entry - %d\n", EntryCount[EfiACPIReclaimMemory]));
+ }
if ((EntryCount[EfiRuntimeServicesCode] > 1) ||
(EntryCount[EfiRuntimeServicesData] > 1) ||
(EntryCount[EfiACPIReclaimMemory] > 1) ||
@@ -146,8 +159,78 @@ IsGoodMemoryMap (
}
}
+VOID
+TestPointDumpUefiMemoryMap (
+ OUT EFI_MEMORY_DESCRIPTOR **UefiMemoryMap, OPTIONAL
+ OUT UINTN *UefiMemoryMapSize, OPTIONAL
+ OUT UINTN *UefiDescriptorSize OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ UINTN MapKey;
+ UINT32 DescriptorVersion;
+ EFI_MEMORY_DESCRIPTOR *MemoryMap;
+ UINTN MemoryMapSize;
+ UINTN DescriptorSize;
+
+ if (UefiMemoryMap != NULL) {
+ *UefiMemoryMap = NULL;
+ *UefiMemoryMapSize = 0;
+ *UefiDescriptorSize = 0;
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpUefiMemoryMap - Enter\n"));
+ MemoryMapSize = 0;
+ MemoryMap = NULL;
+ Status = gBS->GetMemoryMap (
+ &MemoryMapSize,
+ MemoryMap,
+ &MapKey,
+ &DescriptorSize,
+ &DescriptorVersion
+ );
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+
+ do {
+ Status = gBS->AllocatePool (EfiBootServicesData, MemoryMapSize, (VOID **)&MemoryMap);
+ ASSERT (MemoryMap != NULL);
+ if (MemoryMap == NULL) {
+ goto Done ;
+ }
+
+ Status = gBS->GetMemoryMap (
+ &MemoryMapSize,
+ MemoryMap,
+ &MapKey,
+ &DescriptorSize,
+ &DescriptorVersion
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (MemoryMap);
+ MemoryMap = NULL;
+ }
+ } while (Status == EFI_BUFFER_TOO_SMALL);
+
+ if (MemoryMap == NULL) {
+ goto Done ;
+ }
+
+ TestPointDumpMemoryMap (MemoryMap, MemoryMapSize, DescriptorSize);
+
+ if (UefiMemoryMap != NULL) {
+ *UefiMemoryMap = AllocateCopyPool (MemoryMapSize, MemoryMap);
+ *UefiMemoryMapSize = MemoryMapSize;
+ *UefiDescriptorSize = DescriptorSize;
+ }
+ gBS->FreePool (MemoryMap);
+
+Done:
+ DEBUG ((DEBUG_INFO, "==== TestPointDumpUefiMemoryMap - Exit\n"));
+ return ;
+}
+
EFI_STATUS
-TestPointDumpMemMap (
+TestPointCheckUefiMemoryMap (
VOID
)
{
@@ -159,7 +242,7 @@ TestPointDumpMemMap (
UINTN UefiDescriptorSize;
BOOLEAN Result;
- DEBUG ((DEBUG_INFO, "==== TestPointDumpMemMap - Enter\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckUefiMemoryMap - Enter\n"));
UefiMemoryMapSize = 0;
MemoryMap = NULL;
Status = gBS->GetMemoryMap (
@@ -196,15 +279,15 @@ TestPointDumpMemMap (
Status = EFI_OUT_OF_RESOURCES;
goto Done ;
}
-
- DumpMemoryMap (MemoryMap, UefiMemoryMapSize, UefiDescriptorSize);
- Result = IsGoodMemoryMap (MemoryMap, UefiMemoryMapSize, UefiDescriptorSize);
+ Result = TestPointCheckUefiMemoryMapEntry (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
+ TEST_POINT_BYTE3_READY_TO_BOOT_MEMORY_TYPE_INFORMATION_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE3_READY_TO_BOOT_MEMORY_TYPE_INFORMATION_FUNCTIONAL_ERROR_STRING
);
Status = EFI_INVALID_PARAMETER;
} else {
@@ -214,6 +297,6 @@ TestPointDumpMemMap (
gBS->FreePool (MemoryMap);
Done:
- DEBUG ((DEBUG_INFO, "==== TestPointDumpMemMap - Exit\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckUefiMemoryMap - Exit\n"));
return Status;
-}
+} \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemoryTypeInformation.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckMemoryTypeInformation.c
index b25404a564..e2f4792977 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemoryTypeInformation.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckMemoryTypeInformation.c
@@ -107,7 +107,7 @@ DumpMemoryTypeInfoSummary (
}
EFI_STATUS
-TestPointDumpMemoryTypeInformation (
+TestPointCheckMemoryTypeInformation (
VOID
)
{
@@ -117,7 +117,7 @@ TestPointDumpMemoryTypeInformation (
VOID *PreviousMemoryTypeInformation;
VOID *VariableMemoryTypeInformation;
- DEBUG ((DEBUG_INFO, "==== TestPointDumpMemoryTypeInformation - Enter\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckMemoryTypeInformation - Enter\n"));
CurrentMemoryTypeInformation = NULL;
PreviousMemoryTypeInformation = NULL;
@@ -144,14 +144,16 @@ TestPointDumpMemoryTypeInformation (
if ((CurrentMemoryTypeInformation != NULL) && (PreviousMemoryTypeInformation != NULL)) {
DumpMemoryTypeInfoSummary(CurrentMemoryTypeInformation, PreviousMemoryTypeInformation);
}
- DEBUG ((DEBUG_INFO, "==== TestPointDumpMemoryTypeInformation - Exit\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckMemoryTypeInformation - 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
+ TEST_POINT_BYTE3_READY_TO_BOOT_MEMORY_TYPE_INFORMATION_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE3_READY_TO_BOOT_MEMORY_TYPE_INFORMATION_FUNCTIONAL_ERROR_STRING
);
}
return Status;
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpPci.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPci.c
index b1d0ff331c..843b23c1ff 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpPci.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPci.c
@@ -20,6 +20,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/PciIo.h>
#include <Protocol/PciRootBridgeIo.h>
+#include <Library/PciSegmentLib.h>
+#include <Library/PciSegmentInfoLib.h>
#include <IndustryStandard/Pci.h>
#pragma pack(1)
@@ -242,7 +244,7 @@ PciGetNextBusRange (
}
EFI_STATUS
-TestPointDumpPci (
+TestPointCheckPciResource (
VOID
)
{
@@ -261,7 +263,7 @@ TestPointDumpPci (
UINT16 MaxBus;
BOOLEAN IsEnd;
- DEBUG ((DEBUG_INFO, "==== TestPointDumpPci - Enter\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckPciResource - Enter\n"));
HandleBuf = NULL;
Status = gBS->LocateHandleBuffer (
ByProtocol,
@@ -370,15 +372,83 @@ Done:
FreePool (HandleBuf);
}
- DEBUG ((DEBUG_INFO, "==== TestPointDumpPci - Exit\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckPciResource - 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
+ TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_PCI_RESOURCE_ALLOCATED_ERROR_CODE \
+ TEST_POINT_PCI_ENUMERATION_DONE \
+ TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_PCI_RESOURCE_ALLOCATED_ERROR_STRING
);
}
return Status;
}
+
+EFI_STATUS
+TestPointCheckPciBusMaster (
+ VOID
+ )
+{
+ UINTN Segment;
+ UINTN SegmentCount;
+ UINTN Bus;
+ UINTN Device;
+ UINTN Function;
+ UINT16 VendorId;
+ UINT16 Command;
+ UINT8 HeaderType;
+ EFI_STATUS Status;
+ PCI_SEGMENT_INFO *PciSegmentInfo;
+
+ PciSegmentInfo = GetPciSegmentInfo (&SegmentCount);
+
+ Status = EFI_SUCCESS;
+ for (Segment = 0; Segment < SegmentCount; Segment++) {
+ for (Bus = PciSegmentInfo[Segment].StartBusNumber; Bus <= PciSegmentInfo[Segment].EndBusNumber; Bus++) {
+ for (Device = 0; Device <= 0x1F; Device++) {
+ for (Function = 0; Function <= 0x7; Function++) {
+ VendorId = PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS(PciSegmentInfo[Segment].SegmentNumber, Bus, Device, Function, PCI_VENDOR_ID_OFFSET));
+ //
+ // 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 (VendorId == 0xffff && Function == 0) {
+ break;
+ }
+
+ if (VendorId != 0xffff) {
+ Command = PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, Function, PCI_COMMAND_OFFSET));
+ if ((Command & EFI_PCI_COMMAND_BUS_MASTER) != 0) {
+ DEBUG ((DEBUG_INFO, "PCI BME enabled (S%04x.B%02x.D%02x.F%x - %04x)\n", Segment, Bus, Device, Function, Command));
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_PCI_BUS_MASTER_DISABLED_ERROR_CODE \
+ TEST_POINT_PCI_ENUMERATION_DONE \
+ TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_PCI_BUS_MASTER_DISABLED_ERROR_STRING
+ );
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // If this is not a multi-function device, we can leave the loop
+ // to deal with the next device.
+ //
+ HeaderType = PciSegmentRead8 (PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, Function, PCI_HEADER_TYPE_OFFSET));
+ if (Function == 0 && ((HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00)) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPiSignedFvBoot.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPiSignedFvBoot.c
new file mode 100644
index 0000000000..377ca8f853
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPiSignedFvBoot.c
@@ -0,0 +1,33 @@
+/** @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>
+
+EFI_STATUS
+EFIAPI
+TestPointCheckPiSignedFvBoot (
+ VOID
+ )
+{
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckPiSignedFvBoot - Enter\n"));
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckPiSignedFvBoot - Exit\n"));
+ return EFI_UNSUPPORTED;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmiHandlerInstrument.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmiHandlerInstrument.c
new file mode 100644
index 0000000000..bf9bfa9615
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmiHandlerInstrument.c
@@ -0,0 +1,684 @@
+/** @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 <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DxeServicesLib.h>
+#include <Library/DevicePathLib.h>
+#include <Protocol/SmmCommunication.h>
+#include <Guid/PiSmmCommunicationRegionTable.h>
+#include <Guid/SmiHandlerProfile.h>
+
+#define PROFILE_NAME_STRING_LENGTH 64
+CHAR8 mNameString[PROFILE_NAME_STRING_LENGTH + 1];
+
+VOID *mSmiHandlerProfileDatabase;
+UINTN mSmiHandlerProfileDatabaseSize;
+
+/**
+ This function dump raw data.
+
+ @param Data raw data
+ @param Size raw data size
+**/
+VOID
+InternalDumpData (
+ IN UINT8 *Data,
+ IN UINTN Size
+ )
+{
+ UINTN Index;
+ for (Index = 0; Index < Size; Index++) {
+ DEBUG ((DEBUG_INFO, "%02x", (UINTN)Data[Index]));
+ if ((Index + 1) != Size) {
+ DEBUG ((DEBUG_INFO, " "));
+ }
+ }
+}
+
+/**
+ Get SMI handler profile database.
+**/
+VOID
+GetSmiHandlerProfileDatabase(
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINTN CommSize;
+ UINT8 *CommBuffer;
+ EFI_SMM_COMMUNICATE_HEADER *CommHeader;
+ SMI_HANDLER_PROFILE_PARAMETER_GET_INFO *CommGetInfo;
+ SMI_HANDLER_PROFILE_PARAMETER_GET_DATA_BY_OFFSET *CommGetData;
+ EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
+ UINTN MinimalSizeNeeded;
+ EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *PiSmmCommunicationRegionTable;
+ UINT32 Index;
+ EFI_MEMORY_DESCRIPTOR *Entry;
+ VOID *Buffer;
+ UINTN Size;
+ UINTN Offset;
+
+ Status = gBS->LocateProtocol(&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&SmmCommunication);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "SmiHandlerProfile: Locate SmmCommunication protocol - %r\n", Status));
+ return ;
+ }
+
+ MinimalSizeNeeded = EFI_PAGE_SIZE;
+
+ Status = EfiGetSystemConfigurationTable(
+ &gEdkiiPiSmmCommunicationRegionTableGuid,
+ (VOID **)&PiSmmCommunicationRegionTable
+ );
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "SmiHandlerProfile: Get PiSmmCommunicationRegionTable - %r\n", Status));
+ return ;
+ }
+ ASSERT(PiSmmCommunicationRegionTable != NULL);
+ Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
+ Size = 0;
+ for (Index = 0; Index < PiSmmCommunicationRegionTable->NumberOfEntries; Index++) {
+ if (Entry->Type == EfiConventionalMemory) {
+ Size = EFI_PAGES_TO_SIZE((UINTN)Entry->NumberOfPages);
+ if (Size >= MinimalSizeNeeded) {
+ break;
+ }
+ }
+ Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
+ }
+ ASSERT(Index < PiSmmCommunicationRegionTable->NumberOfEntries);
+ CommBuffer = (UINT8 *)(UINTN)Entry->PhysicalStart;
+
+ //
+ // Get Size
+ //
+ CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
+ CopyMem(&CommHeader->HeaderGuid, &gSmiHandlerProfileGuid, sizeof(gSmiHandlerProfileGuid));
+ CommHeader->MessageLength = sizeof(SMI_HANDLER_PROFILE_PARAMETER_GET_INFO);
+
+ CommGetInfo = (SMI_HANDLER_PROFILE_PARAMETER_GET_INFO *)&CommBuffer[OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data)];
+ CommGetInfo->Header.Command = SMI_HANDLER_PROFILE_COMMAND_GET_INFO;
+ CommGetInfo->Header.DataLength = sizeof(*CommGetInfo);
+ CommGetInfo->Header.ReturnStatus = (UINT64)-1;
+ CommGetInfo->DataSize = 0;
+
+ CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLength;
+ Status = SmmCommunication->Communicate(SmmCommunication, CommBuffer, &CommSize);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "SmiHandlerProfile: SmmCommunication - %r\n", Status));
+ return ;
+ }
+
+ if (CommGetInfo->Header.ReturnStatus != 0) {
+ DEBUG ((DEBUG_INFO, "SmiHandlerProfile: GetInfo - 0x%0x\n", CommGetInfo->Header.ReturnStatus));
+ return ;
+ }
+
+ mSmiHandlerProfileDatabaseSize = (UINTN)CommGetInfo->DataSize;
+
+ //
+ // Get Data
+ //
+ mSmiHandlerProfileDatabase = AllocateZeroPool(mSmiHandlerProfileDatabaseSize);
+ if (mSmiHandlerProfileDatabase == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_INFO, "SmiHandlerProfile: AllocateZeroPool (0x%x) for dump buffer - %r\n", mSmiHandlerProfileDatabaseSize, Status));
+ return ;
+ }
+
+ CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
+ CopyMem(&CommHeader->HeaderGuid, &gSmiHandlerProfileGuid, sizeof(gSmiHandlerProfileGuid));
+ CommHeader->MessageLength = sizeof(SMI_HANDLER_PROFILE_PARAMETER_GET_DATA_BY_OFFSET);
+
+ CommGetData = (SMI_HANDLER_PROFILE_PARAMETER_GET_DATA_BY_OFFSET *)&CommBuffer[OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data)];
+ CommGetData->Header.Command = SMI_HANDLER_PROFILE_COMMAND_GET_DATA_BY_OFFSET;
+ CommGetData->Header.DataLength = sizeof(*CommGetData);
+ CommGetData->Header.ReturnStatus = (UINT64)-1;
+
+ CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLength;
+ Buffer = (UINT8 *)CommHeader + CommSize;
+ Size -= CommSize;
+
+ CommGetData->DataBuffer = (PHYSICAL_ADDRESS)(UINTN)Buffer;
+ CommGetData->DataOffset = 0;
+ while (CommGetData->DataOffset < mSmiHandlerProfileDatabaseSize) {
+ Offset = (UINTN)CommGetData->DataOffset;
+ if (Size <= (mSmiHandlerProfileDatabaseSize - CommGetData->DataOffset)) {
+ CommGetData->DataSize = (UINT64)Size;
+ } else {
+ CommGetData->DataSize = (UINT64)(mSmiHandlerProfileDatabaseSize - CommGetData->DataOffset);
+ }
+ Status = SmmCommunication->Communicate(SmmCommunication, CommBuffer, &CommSize);
+ ASSERT_EFI_ERROR(Status);
+
+ if (CommGetData->Header.ReturnStatus != 0) {
+ FreePool(mSmiHandlerProfileDatabase);
+ mSmiHandlerProfileDatabase = NULL;
+ DEBUG ((DEBUG_INFO, "SmiHandlerProfile: GetData - 0x%x\n", CommGetData->Header.ReturnStatus));
+ return ;
+ }
+ CopyMem((UINT8 *)mSmiHandlerProfileDatabase + Offset, (VOID *)(UINTN)CommGetData->DataBuffer, (UINTN)CommGetData->DataSize);
+ }
+
+ DEBUG ((DEBUG_INFO, "SmiHandlerProfileSize - 0x%x\n", mSmiHandlerProfileDatabaseSize));
+
+ return ;
+}
+
+/**
+ Get the file name portion of the Pdb File Name.
+
+ The portion of the Pdb File Name between the last backslash and
+ either a following period or the end of the string is copied into
+ AsciiBuffer. The name is truncated, if necessary, to ensure that
+ AsciiBuffer is not overrun.
+
+ @param[in] PdbFileName Pdb file name.
+ @param[out] AsciiBuffer The resultant Ascii File Name.
+
+**/
+VOID
+GetShortPdbFileName (
+ IN CHAR8 *PdbFileName,
+ OUT CHAR8 *AsciiBuffer
+ )
+{
+ UINTN IndexPdb; // Current work location within a Pdb string.
+ UINTN IndexBuffer; // Current work location within a Buffer string.
+ UINTN StartIndex;
+ UINTN EndIndex;
+
+ ZeroMem (AsciiBuffer, PROFILE_NAME_STRING_LENGTH + 1);
+
+ if (PdbFileName == NULL) {
+ AsciiStrnCpyS (AsciiBuffer, PROFILE_NAME_STRING_LENGTH + 1, " ", 1);
+ } else {
+ StartIndex = 0;
+ for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++);
+ for (IndexPdb = 0; PdbFileName[IndexPdb] != 0; IndexPdb++) {
+ if ((PdbFileName[IndexPdb] == '\\') || (PdbFileName[IndexPdb] == '/')) {
+ StartIndex = IndexPdb + 1;
+ }
+
+ if (PdbFileName[IndexPdb] == '.') {
+ EndIndex = IndexPdb;
+ }
+ }
+
+ IndexBuffer = 0;
+ for (IndexPdb = StartIndex; IndexPdb < EndIndex; IndexPdb++) {
+ AsciiBuffer[IndexBuffer] = PdbFileName[IndexPdb];
+ IndexBuffer++;
+ if (IndexBuffer >= PROFILE_NAME_STRING_LENGTH) {
+ AsciiBuffer[PROFILE_NAME_STRING_LENGTH] = 0;
+ break;
+ }
+ }
+ }
+}
+
+/**
+ Get a human readable name for an image.
+ The following methods will be tried orderly:
+ 1. Image PDB
+ 2. FFS UI section
+ 3. Image GUID
+
+ @param[in] ImageStruct Point to the image structure.
+
+ @return The resulting Ascii name string is stored in the mNameString global array.
+
+**/
+CHAR8 *
+GetDriverNameString (
+ IN SMM_CORE_IMAGE_DATABASE_STRUCTURE *ImageStruct
+ )
+{
+ EFI_STATUS Status;
+ CHAR16 *NameString;
+ UINTN StringSize;
+
+ if (ImageStruct == NULL) {
+ return "???";
+ }
+
+ //
+ // Method 1: Get the name string from image PDB
+ //
+ if (ImageStruct->PdbStringOffset != 0) {
+ GetShortPdbFileName ((CHAR8 *) ((UINTN) ImageStruct + ImageStruct->PdbStringOffset), mNameString);
+ return mNameString;
+ }
+
+ if (!IsZeroGuid (&ImageStruct->FileGuid)) {
+ //
+ // Try to get the image's FFS UI section by image GUID
+ //
+ NameString = NULL;
+ StringSize = 0;
+ Status = GetSectionFromAnyFv (
+ &ImageStruct->FileGuid,
+ EFI_SECTION_USER_INTERFACE,
+ 0,
+ (VOID **) &NameString,
+ &StringSize
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Method 2: Get the name string from FFS UI section
+ //
+ if (StrLen (NameString) > PROFILE_NAME_STRING_LENGTH) {
+ NameString[PROFILE_NAME_STRING_LENGTH] = 0;
+ }
+ UnicodeStrToAsciiStrS (NameString, mNameString, sizeof (mNameString));
+ FreePool (NameString);
+ return mNameString;
+ }
+ }
+
+ //
+ // Method 3: Get the name string from image GUID
+ //
+ AsciiSPrint (mNameString, sizeof (mNameString), "%g", &ImageStruct->FileGuid);
+ return mNameString;
+}
+
+/**
+ Get image structure from reference index.
+
+ @param ImageRef the image reference index
+
+ @return image structure
+**/
+SMM_CORE_IMAGE_DATABASE_STRUCTURE *
+GetImageFromRef (
+ IN UINTN ImageRef
+ )
+{
+ SMM_CORE_IMAGE_DATABASE_STRUCTURE *ImageStruct;
+
+ ImageStruct = (VOID *)mSmiHandlerProfileDatabase;
+ while ((UINTN)ImageStruct < (UINTN)mSmiHandlerProfileDatabase + mSmiHandlerProfileDatabaseSize) {
+ if (ImageStruct->Header.Signature == SMM_CORE_IMAGE_DATABASE_SIGNATURE) {
+ if (ImageStruct->ImageRef == ImageRef) {
+ return ImageStruct;
+ }
+ }
+ ImageStruct = (VOID *)((UINTN)ImageStruct + ImageStruct->Header.Length);
+ }
+
+ return NULL;
+}
+
+/**
+ Dump SMM loaded image information.
+**/
+VOID
+DumpSmmLoadedImage(
+ VOID
+ )
+{
+ SMM_CORE_IMAGE_DATABASE_STRUCTURE *ImageStruct;
+ CHAR8 *PdbString;
+ CHAR8 *NameString;
+
+ ImageStruct = (VOID *)mSmiHandlerProfileDatabase;
+ while ((UINTN)ImageStruct < (UINTN)mSmiHandlerProfileDatabase + mSmiHandlerProfileDatabaseSize) {
+ if (ImageStruct->Header.Signature == SMM_CORE_IMAGE_DATABASE_SIGNATURE) {
+ NameString = GetDriverNameString (ImageStruct);
+ DEBUG ((DEBUG_INFO, " <Image Name=\"%a\"", NameString));
+ DEBUG ((DEBUG_INFO, " Base=\"0x%lx\" Size=\"0x%lx\"", ImageStruct->ImageBase, ImageStruct->ImageSize));
+ if (ImageStruct->EntryPoint != 0) {
+ DEBUG ((DEBUG_INFO, " EntryPoint=\"0x%lx\"", ImageStruct->EntryPoint));
+ }
+ DEBUG ((DEBUG_INFO, " FvFile=\"%g\"", &ImageStruct->FileGuid));
+ DEBUG ((DEBUG_INFO, " RefId=\"0x%x\"", ImageStruct->ImageRef));
+ DEBUG ((DEBUG_INFO, ">\n"));
+ if (ImageStruct->PdbStringOffset != 0) {
+ PdbString = (CHAR8 *)((UINTN)ImageStruct + ImageStruct->PdbStringOffset);
+ DEBUG ((DEBUG_INFO, " <Pdb>%a</Pdb>\n", PdbString));
+ }
+ DEBUG ((DEBUG_INFO, " </Image>\n"));
+ }
+
+ ImageStruct = (VOID *)((UINTN)ImageStruct + ImageStruct->Header.Length);
+ }
+
+ return;
+}
+
+CHAR8 *mSxTypeString[] = {
+ "SxS0",
+ "SxS1",
+ "SxS2",
+ "SxS3",
+ "SxS4",
+ "SxS5",
+};
+
+/**
+ Convert SxType to a string.
+
+ @param Type SxType
+
+ @return SxType string
+**/
+CHAR8 *
+SxTypeToString (
+ IN EFI_SLEEP_TYPE Type
+ )
+{
+ if (Type >= 0 && Type <= ARRAY_SIZE(mSxTypeString)) {
+ return mSxTypeString[Type];
+ } else {
+ AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);
+ return mNameString;
+ }
+}
+
+CHAR8 *mSxPhaseString[] = {
+ "SxEntry",
+ "SxExit",
+};
+
+/**
+ Convert SxPhase to a string.
+
+ @param Phase SxPhase
+
+ @return SxPhase string
+**/
+CHAR8 *
+SxPhaseToString (
+ IN EFI_SLEEP_PHASE Phase
+ )
+{
+ if (Phase >= 0 && Phase <= ARRAY_SIZE(mSxPhaseString)) {
+ return mSxPhaseString[Phase];
+ } else {
+ AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);
+ return mNameString;
+ }
+}
+
+CHAR8 *mPowerButtonPhaseString[] = {
+ "PowerButtonEntry",
+ "PowerButtonExit",
+};
+
+/**
+ Convert PowerButtonPhase to a string.
+
+ @param Phase PowerButtonPhase
+
+ @return PowerButtonPhase string
+**/
+CHAR8 *
+PowerButtonPhaseToString (
+ IN EFI_POWER_BUTTON_PHASE Phase
+ )
+{
+ if (Phase >= 0 && Phase <= ARRAY_SIZE(mPowerButtonPhaseString)) {
+ return mPowerButtonPhaseString[Phase];
+ } else {
+ AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);
+ return mNameString;
+ }
+}
+
+CHAR8 *mStandbyButtonPhaseString[] = {
+ "StandbyButtonEntry",
+ "StandbyButtonExit",
+};
+
+/**
+ Convert StandbyButtonPhase to a string.
+
+ @param Phase StandbyButtonPhase
+
+ @return StandbyButtonPhase string
+**/
+CHAR8 *
+StandbyButtonPhaseToString (
+ IN EFI_STANDBY_BUTTON_PHASE Phase
+ )
+{
+ if (Phase >= 0 && Phase <= ARRAY_SIZE(mStandbyButtonPhaseString)) {
+ return mStandbyButtonPhaseString[Phase];
+ } else {
+ AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);
+ return mNameString;
+ }
+}
+
+CHAR8 *mIoTrapTypeString[] = {
+ "WriteTrap",
+ "ReadTrap",
+ "ReadWriteTrap",
+};
+
+/**
+ Convert IoTrapType to a string.
+
+ @param Type IoTrapType
+
+ @return IoTrapType string
+**/
+CHAR8 *
+IoTrapTypeToString (
+ IN EFI_SMM_IO_TRAP_DISPATCH_TYPE Type
+ )
+{
+ if (Type >= 0 && Type <= ARRAY_SIZE(mIoTrapTypeString)) {
+ return mIoTrapTypeString[Type];
+ } else {
+ AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);
+ return mNameString;
+ }
+}
+
+CHAR8 *mUsbTypeString[] = {
+ "UsbLegacy",
+ "UsbWake",
+};
+
+/**
+ Convert UsbType to a string.
+
+ @param Type UsbType
+
+ @return UsbType string
+**/
+CHAR8 *
+UsbTypeToString (
+ IN EFI_USB_SMI_TYPE Type
+ )
+{
+ if (Type >= 0 && Type <= ARRAY_SIZE(mUsbTypeString)) {
+ return mUsbTypeString[Type];
+ } else {
+ AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);
+ return mNameString;
+ }
+}
+
+/**
+ Dump SMI child context.
+
+ @param HandlerType the handler type
+ @param Context the handler context
+ @param ContextSize the handler context size
+**/
+VOID
+DumpSmiChildContext (
+ IN EFI_GUID *HandlerType,
+ IN VOID *Context,
+ IN UINTN ContextSize
+ )
+{
+ CHAR16 *Str;
+
+ if (CompareGuid (HandlerType, &gEfiSmmSwDispatch2ProtocolGuid)) {
+ DEBUG ((DEBUG_INFO, " SwSmi=\"0x%lx\"", ((SMI_HANDLER_PROFILE_SW_REGISTER_CONTEXT *)Context)->SwSmiInputValue));
+ } else if (CompareGuid (HandlerType, &gEfiSmmSxDispatch2ProtocolGuid)) {
+ DEBUG ((DEBUG_INFO, " SxType=\"%a\"", SxTypeToString(((EFI_SMM_SX_REGISTER_CONTEXT *)Context)->Type)));
+ DEBUG ((DEBUG_INFO, " SxPhase=\"%a\"", SxPhaseToString(((EFI_SMM_SX_REGISTER_CONTEXT *)Context)->Phase)));
+ } else if (CompareGuid (HandlerType, &gEfiSmmPowerButtonDispatch2ProtocolGuid)) {
+ DEBUG ((DEBUG_INFO, " PowerButtonPhase=\"%a\"", PowerButtonPhaseToString(((EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT *)Context)->Phase)));
+ } else if (CompareGuid (HandlerType, &gEfiSmmStandbyButtonDispatch2ProtocolGuid)) {
+ DEBUG ((DEBUG_INFO, " StandbyButtonPhase=\"%a\"", StandbyButtonPhaseToString(((EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT *)Context)->Phase)));
+ } else if (CompareGuid (HandlerType, &gEfiSmmPeriodicTimerDispatch2ProtocolGuid)) {
+ DEBUG ((DEBUG_INFO, " PeriodicTimerPeriod=\"%ld\"", ((EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT *)Context)->Period));
+ DEBUG ((DEBUG_INFO, " PeriodicTimerSmiTickInterval=\"%ld\"", ((EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT *)Context)->SmiTickInterval));
+ } else if (CompareGuid (HandlerType, &gEfiSmmGpiDispatch2ProtocolGuid)) {
+ DEBUG ((DEBUG_INFO, " GpiNum=\"0x%lx\"", ((EFI_SMM_GPI_REGISTER_CONTEXT *)Context)->GpiNum));
+ } else if (CompareGuid (HandlerType, &gEfiSmmIoTrapDispatch2ProtocolGuid)) {
+ DEBUG ((DEBUG_INFO, " IoTrapAddress=\"0x%x\"", ((EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context)->Address));
+ DEBUG ((DEBUG_INFO, " IoTrapLength=\"0x%x\"", ((EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context)->Length));
+ DEBUG ((DEBUG_INFO, " IoTrapType=\"%a\"", IoTrapTypeToString(((EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context)->Type)));
+ } else if (CompareGuid (HandlerType, &gEfiSmmUsbDispatch2ProtocolGuid)) {
+ DEBUG ((DEBUG_INFO, " UsbType=\"0x%x\"", UsbTypeToString(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context)->Type)));
+ Str = ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE, TRUE);
+ DEBUG ((DEBUG_INFO, " UsbDevicePath=\"%s\"", Str));
+ if (Str != NULL) {
+ FreePool (Str);
+ }
+ } else {
+ DEBUG ((DEBUG_INFO, " Context=\""));
+ InternalDumpData (Context, ContextSize);
+ DEBUG ((DEBUG_INFO, "\""));
+ }
+}
+
+/**
+ Dump SMI handler in HandlerCategory.
+
+ @param HandlerCategory SMI handler category
+**/
+VOID
+DumpSmiHandler(
+ IN UINT32 HandlerCategory
+ )
+{
+ SMM_CORE_SMI_DATABASE_STRUCTURE *SmiStruct;
+ SMM_CORE_SMI_HANDLER_STRUCTURE *SmiHandlerStruct;
+ UINTN Index;
+ SMM_CORE_IMAGE_DATABASE_STRUCTURE *ImageStruct;
+ CHAR8 *NameString;
+
+ SmiStruct = (VOID *)mSmiHandlerProfileDatabase;
+ while ((UINTN)SmiStruct < (UINTN)mSmiHandlerProfileDatabase + mSmiHandlerProfileDatabaseSize) {
+ if ((SmiStruct->Header.Signature == SMM_CORE_SMI_DATABASE_SIGNATURE) && (SmiStruct->HandlerCategory == HandlerCategory)) {
+ SmiHandlerStruct = (VOID *)(SmiStruct + 1);
+ DEBUG ((DEBUG_INFO, " <SmiEntry"));
+ if (!IsZeroGuid (&SmiStruct->HandlerType)) {
+ DEBUG ((DEBUG_INFO, " HandlerType=\"%g\"", &SmiStruct->HandlerType));
+ }
+ DEBUG ((DEBUG_INFO, ">\n"));
+ for (Index = 0; Index < SmiStruct->HandlerCount; Index++) {
+ DEBUG ((DEBUG_INFO, " <SmiHandler"));
+ if (SmiHandlerStruct->ContextBufferSize != 0) {
+ DumpSmiChildContext (&SmiStruct->HandlerType, (UINT8 *)SmiHandlerStruct + SmiHandlerStruct->ContextBufferOffset, SmiHandlerStruct->ContextBufferSize);
+ }
+ DEBUG ((DEBUG_INFO, ">\n"));
+ ImageStruct = GetImageFromRef((UINTN)SmiHandlerStruct->ImageRef);
+ NameString = GetDriverNameString (ImageStruct);
+ DEBUG ((DEBUG_INFO, " <Module RefId=\"0x%x\" Name=\"%a\">\n", SmiHandlerStruct->ImageRef, NameString));
+ if ((ImageStruct != NULL) && (ImageStruct->PdbStringOffset != 0)) {
+ DEBUG ((DEBUG_INFO, " <Pdb>%a</Pdb>\n", (UINT8 *)ImageStruct + ImageStruct->PdbStringOffset));
+ }
+ DEBUG ((DEBUG_INFO, " </Module>\n"));
+ DEBUG ((DEBUG_INFO, " <Handler Address=\"0x%lx\">\n", SmiHandlerStruct->Handler));
+ if (ImageStruct != NULL) {
+ DEBUG ((DEBUG_INFO, " <RVA>0x%x</RVA>\n", (UINTN) (SmiHandlerStruct->Handler - ImageStruct->ImageBase)));
+ }
+ DEBUG ((DEBUG_INFO, " </Handler>\n", SmiHandlerStruct->Handler));
+ DEBUG ((DEBUG_INFO, " <Caller Address=\"0x%lx\">\n", SmiHandlerStruct->CallerAddr));
+ if (ImageStruct != NULL) {
+ DEBUG ((DEBUG_INFO, " <RVA>0x%x</RVA>\n", (UINTN) (SmiHandlerStruct->CallerAddr - ImageStruct->ImageBase)));
+ }
+ DEBUG ((DEBUG_INFO, " </Caller>\n", SmiHandlerStruct->Handler));
+ SmiHandlerStruct = (VOID *)((UINTN)SmiHandlerStruct + SmiHandlerStruct->Length);
+ DEBUG ((DEBUG_INFO, " </SmiHandler>\n"));
+ }
+ DEBUG ((DEBUG_INFO, " </SmiEntry>\n"));
+ }
+ SmiStruct = (VOID *)((UINTN)SmiStruct + SmiStruct->Header.Length);
+ }
+
+ return;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointCheckSmiHandlerInstrument (
+ VOID
+ )
+{
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmiHandlerInstrument - Enter\n"));
+
+ GetSmiHandlerProfileDatabase();
+
+ if (mSmiHandlerProfileDatabase == NULL) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Dump all image
+ //
+ DEBUG ((DEBUG_INFO, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"));
+ DEBUG ((DEBUG_INFO, "<SmiHandlerProfile>\n"));
+ DEBUG ((DEBUG_INFO, "<ImageDatabase>\n"));
+ DEBUG ((DEBUG_INFO, " <!-- SMM image loaded -->\n"));
+ DumpSmmLoadedImage();
+ DEBUG ((DEBUG_INFO, "</ImageDatabase>\n\n"));
+
+ //
+ // Dump SMI Handler
+ //
+ DEBUG ((DEBUG_INFO, "<SmiHandlerDatabase>\n"));
+ DEBUG ((DEBUG_INFO, " <!-- SMI Handler registered -->\n\n"));
+ DEBUG ((DEBUG_INFO, " <SmiHandlerCategory Name=\"RootSmi\">\n"));
+ DEBUG ((DEBUG_INFO, " <!-- The root SMI Handler registered by SmmCore -->\n"));
+ DumpSmiHandler(SmmCoreSmiHandlerCategoryRootHandler);
+ DEBUG ((DEBUG_INFO, " </SmiHandlerCategory>\n\n"));
+
+ DEBUG ((DEBUG_INFO, " <SmiHandlerCategory Name=\"GuidSmi\">\n"));
+ DEBUG ((DEBUG_INFO, " <!-- The GUID SMI Handler registered by SmmCore -->\n"));
+ DumpSmiHandler(SmmCoreSmiHandlerCategoryGuidHandler);
+ DEBUG ((DEBUG_INFO, " </SmiHandlerCategory>\n\n"));
+
+ DEBUG ((DEBUG_INFO, " <SmiHandlerCategory Name=\"HardwareSmi\">\n"));
+ DEBUG ((DEBUG_INFO, " <!-- The hardware SMI Handler registered by SmmChildDispatcher -->\n"));
+ DumpSmiHandler(SmmCoreSmiHandlerCategoryHardwareHandler);
+ DEBUG ((DEBUG_INFO, " </SmiHandlerCategory>\n\n"));
+
+ DEBUG ((DEBUG_INFO, "</SmiHandlerDatabase>\n"));
+ DEBUG ((DEBUG_INFO, "</SmiHandlerProfile>\n"));
+
+ if (mSmiHandlerProfileDatabase != NULL) {
+ FreePool(mSmiHandlerProfileDatabase);
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmiHandlerInstrument - Exit\n"));
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmmInfo.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmmInfo.c
new file mode 100644
index 0000000000..59a59921e4
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmmInfo.c
@@ -0,0 +1,149 @@
+/** @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>
+
+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
+CheckSmramDescriptor (
+ IN UINTN NumberOfSmmReservedRegions,
+ IN EFI_SMRAM_DESCRIPTOR *Descriptor
+ )
+{
+ UINTN Index;
+ UINT64 Base;
+ UINT64 Length;
+
+ Base = 0;
+ Length = 0;
+ for (Index = 0; Index < NumberOfSmmReservedRegions; Index++) {
+ if (Base == 0) {
+ Base = Descriptor[Index].PhysicalStart;
+ Length = Descriptor[Index].PhysicalSize;
+ } else {
+ if (Base + Length == Descriptor[Index].PhysicalStart) {
+ Length = Length + Descriptor[Index].PhysicalSize;
+ } else if (Descriptor[Index].PhysicalStart + Descriptor[Index].PhysicalSize == Base) {
+ Base = Descriptor[Index].PhysicalStart;
+ Length = Length + Descriptor[Index].PhysicalSize;
+ } else {
+ DEBUG ((DEBUG_ERROR, "Smram is not adjacent\n"));
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_SMRAM_ALIGNED_ERROR_CODE \
+ TEST_POINT_DXE_SMM_READY_TO_LOCK
+ TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_SMRAM_ALIGNED_ERROR_STRING
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ if (Length != GetPowerOfTwo64 (Length)) {
+ DEBUG ((DEBUG_ERROR, "Smram is not aligned\n"));
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_SMRAM_ALIGNED_ERROR_CODE \
+ TEST_POINT_DXE_SMM_READY_TO_LOCK
+ TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_SMRAM_ALIGNED_ERROR_STRING
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+TestPointCheckSmmInfo (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
+ UINTN Size;
+ EFI_SMRAM_DESCRIPTOR *SmramRanges;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmInfo - 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);
+
+ Status = CheckSmramDescriptor (Size / sizeof (EFI_SMRAM_DESCRIPTOR), SmramRanges);
+
+ FreePool (SmramRanges);
+
+Done:
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmInfo - Exit\n"));
+
+ return Status;
+} \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckTcgMor.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckTcgMor.c
new file mode 100644
index 0000000000..4570367d92
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckTcgMor.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/PrintLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Guid/MemoryOverwriteControl.h>
+#include <IndustryStandard/MemoryOverwriteRequestControlLock.h>
+
+typedef struct {
+ CHAR16 *Name;
+ EFI_GUID *Guid;
+} VARIABLE_LIST;
+
+VARIABLE_LIST mMorVariable[] = {
+ {MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, &gEfiMemoryOverwriteControlDataGuid},
+ {MEMORY_OVERWRITE_REQUEST_CONTROL_LOCK_NAME, &gEfiMemoryOverwriteRequestControlLockGuid},
+};
+
+EFI_STATUS
+EFIAPI
+TestPointCheckTcgMor (
+ VOID
+ )
+{
+ VOID *Variable;
+ UINTN Size;
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckTcgMor - Enter\n"));
+
+ ReturnStatus = EFI_SUCCESS;
+ for (Index = 0; Index < sizeof(mMorVariable)/sizeof(mMorVariable[0]); Index++) {
+ Status = GetVariable2 (mMorVariable[Index].Name, mMorVariable[Index].Guid, &Variable, &Size);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_ERROR, "Variable - %S not found\n", mMorVariable[Index].Name));
+ ReturnStatus = Status;
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE4_READY_TO_BOOT_TCG_MOR_ENABLED_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE4_READY_TO_BOOT_TCG_MOR_ENABLED_ERROR_STRING
+ );
+ } else {
+ FreePool (Variable);
+ }
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckTcgMor - Exit\n"));
+ return ReturnStatus;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckTcgTrustedBoot.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckTcgTrustedBoot.c
new file mode 100644
index 0000000000..d2fbc4ef36
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckTcgTrustedBoot.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/UefiLib.h>
+#include <Library/PrintLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/Tcg2Protocol.h>
+
+EFI_STATUS
+EFIAPI
+TestPointCheckTcgTrustedBoot (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *Tcg2;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY ProtocolCapability;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckTcgTrustedBoot - Enter\n"));
+
+ Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **)&Tcg2);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_ERROR, "Tcg2 Protocol - %r\n", Status));
+ goto Done;
+ }
+
+ Status = Tcg2->GetCapability (Tcg2, &ProtocolCapability);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_ERROR, "Tcg2->GetCapability - %r\n", Status));
+ goto Done;
+ }
+
+ DEBUG ((DEBUG_INFO, "Capability.Size - 0x%x\n", ProtocolCapability.Size));
+ DEBUG ((DEBUG_INFO, "StructureVersion - %x.%x\n", ProtocolCapability.StructureVersion.Major, ProtocolCapability.StructureVersion.Minor));
+ DEBUG ((DEBUG_INFO, "ProtocolVersion - %x.%x\n", ProtocolCapability.ProtocolVersion.Major, ProtocolCapability.ProtocolVersion.Minor));
+ DEBUG ((DEBUG_INFO, "HashAlgorithmBitmap - 0x%08x\n", ProtocolCapability.HashAlgorithmBitmap));
+ DEBUG ((DEBUG_INFO, "SupportedEventLogs - 0x%08x\n", ProtocolCapability.SupportedEventLogs));
+ DEBUG ((DEBUG_INFO, "TPMPresentFlag - %x\n", ProtocolCapability.TPMPresentFlag));
+ DEBUG ((DEBUG_INFO, "MaxCommandSize - 0x%04x\n", ProtocolCapability.MaxCommandSize));
+ DEBUG ((DEBUG_INFO, "MaxResponseSize - 0x%04x\n", ProtocolCapability.MaxResponseSize));
+ DEBUG ((DEBUG_INFO, "ManufacturerID - 0x%08x\n", ProtocolCapability.ManufacturerID));
+ if ((ProtocolCapability.StructureVersion.Major > 1) ||
+ (ProtocolCapability.StructureVersion.Minor > 0)) {
+ DEBUG ((DEBUG_INFO, "NumberOfPCRBanks - 0x%08x\n", ProtocolCapability.NumberOfPCRBanks));
+ DEBUG ((DEBUG_INFO, "ActivePcrBanks - 0x%08x\n", ProtocolCapability.ActivePcrBanks));
+ }
+
+ if (!ProtocolCapability.TPMPresentFlag) {
+ Status = EFI_NOT_FOUND;
+ }
+
+Done:
+ if (EFI_ERROR(Status)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE4_READY_TO_BOOT_TCG_TRUSTED_BOOT_ENABLED_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE4_READY_TO_BOOT_TCG_TRUSTED_BOOT_ENABLED_ERROR_STRING
+ );
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckTcgTrustedBoot - Exit\n"));
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckUefiSecureBoot.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckUefiSecureBoot.c
new file mode 100644
index 0000000000..af674ec925
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckUefiSecureBoot.c
@@ -0,0 +1,107 @@
+/** @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/GlobalVariable.h>
+#include <Guid/ImageAuthentication.h>
+
+typedef struct {
+ CHAR16 *Name;
+ EFI_GUID *Guid;
+ UINT8 ExpectedSize;
+ UINT8 ExpectedData;
+} VARIABLE_LIST;
+
+VARIABLE_LIST mUefiSecureBootVariable[] = {
+ {EFI_PLATFORM_KEY_NAME, &gEfiGlobalVariableGuid},
+ {EFI_KEY_EXCHANGE_KEY_NAME, &gEfiGlobalVariableGuid},
+ {EFI_IMAGE_SECURITY_DATABASE, &gEfiImageSecurityDatabaseGuid},
+ {EFI_IMAGE_SECURITY_DATABASE1, &gEfiImageSecurityDatabaseGuid},
+};
+
+VARIABLE_LIST mUefiSecureBootModeVariable[] = {
+ {EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid, sizeof(UINT8), 1},
+ {EFI_SETUP_MODE_NAME, &gEfiGlobalVariableGuid, sizeof(UINT8), 0},
+};
+
+EFI_STATUS
+EFIAPI
+TestPointCheckUefiSecureBoot (
+ VOID
+ )
+{
+ VOID *Variable;
+ UINTN Size;
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckUefiSecureBoot - Enter\n"));
+
+ ReturnStatus = EFI_SUCCESS;
+ for (Index = 0; Index < sizeof(mUefiSecureBootVariable)/sizeof(mUefiSecureBootVariable[0]); Index++) {
+ Status = GetVariable2 (mUefiSecureBootVariable[Index].Name, mUefiSecureBootVariable[Index].Guid, &Variable, &Size);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_ERROR, "Variable - %S not found\n", mUefiSecureBootVariable[Index].Name));
+ ReturnStatus = Status;
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED_ERROR_STRING
+ );
+ } else {
+ FreePool (Variable);
+ }
+ }
+
+ for (Index = 0; Index < sizeof(mUefiSecureBootModeVariable)/sizeof(mUefiSecureBootModeVariable[0]); Index++) {
+ Status = GetVariable2 (mUefiSecureBootModeVariable[Index].Name, mUefiSecureBootModeVariable[Index].Guid, &Variable, &Size);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_ERROR, "Variable - %S not found\n", mUefiSecureBootModeVariable[Index].Name));
+ ReturnStatus = Status;
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED_ERROR_STRING
+ );
+ } else {
+ if ((Size != mUefiSecureBootModeVariable[Index].ExpectedSize) ||
+ (*(UINT8 *)Variable != mUefiSecureBootModeVariable[Index].ExpectedData)) {
+ DEBUG ((DEBUG_ERROR, "Variable - %S is not expected (0x%x)\n", mUefiSecureBootModeVariable[Index].Name, *(UINT8 *)Variable));
+ ReturnStatus = EFI_SECURITY_VIOLATION;
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED_ERROR_CODE \
+ TEST_POINT_READY_TO_BOOT \
+ TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED_ERROR_STRING
+ );
+ }
+ FreePool (Variable);
+ }
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckUefiSecureBoot - Exit\n"));
+ return ReturnStatus;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpVariable.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckVariable.c
index 4512a2385d..68c25efc22 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpVariable.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckVariable.c
@@ -68,7 +68,7 @@ DumpVarProperty (
}
}
-EFI_STATUS
+VOID
TestPointDumpVariable (
VOID
)
@@ -168,6 +168,5 @@ TestPointDumpVariable (
Done:
DEBUG ((DEBUG_INFO, "==== TestPointDumpVariable - Exit\n"));
- // Check - TBD
- return EFI_SUCCESS;
+ return ;
} \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpDevicePath.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpDevicePath.c
deleted file mode 100644
index eff049591e..0000000000
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpDevicePath.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/** @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/DxeDumpMemAttribute.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemAttribute.c
deleted file mode 100644
index 57a86963f2..0000000000
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpMemAttribute.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/** @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/DxeDumpSmmInfo.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpSmmInfo.c
deleted file mode 100644
index 0934038208..0000000000
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeDumpSmmInfo.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/** @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/DxeTestPointCheckLib.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c
index f7801bf4b2..0465ef9f68 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c
@@ -18,90 +18,150 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/DmaRemappingReportingTable.h>
+#include <IndustryStandard/WindowsSmmSecurityMitigationTable.h>
-EFI_STATUS
+VOID
TestPointDumpGcd (
+ OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **GcdMemoryMap, OPTIONAL
+ OUT UINTN *GcdMemoryMapNumberOfDescriptors, OPTIONAL
+ OUT EFI_GCD_IO_SPACE_DESCRIPTOR **GcdIoMap, OPTIONAL
+ OUT UINTN *GcdIoMapNumberOfDescriptors OPTIONAL
+ );
+
+VOID
+TestPointDumpUefiMemoryMap (
+ OUT EFI_MEMORY_DESCRIPTOR **UefiMemoryMap, OPTIONAL
+ OUT UINTN *UefiMemoryMapSize, OPTIONAL
+ OUT UINTN *UefiDescriptorSize OPTIONAL
+ );
+
+EFI_STATUS
+TestPointCheckUefiMemoryMap (
VOID
);
EFI_STATUS
-TestPointDumpMemMap (
+TestPointCheckUefiMemAttribute (
VOID
);
EFI_STATUS
-TestPointDumpMemAttribute (
+TestPointCheckPciResource (
VOID
);
EFI_STATUS
-TestPointDumpPci (
+TestPointCheckConsoleVariable (
VOID
);
EFI_STATUS
-TestPointDumpConsoleVariable (
+TestPointCheckBootVariable (
+ VOID
+ );
+
+VOID
+TestPointDumpDevicePath (
VOID
);
EFI_STATUS
-TestPointDumpBootVariable (
+TestPointCheckMemoryTypeInformation (
VOID
);
EFI_STATUS
-TestPointDumpDevicePath (
+TestPointCheckAcpi (
+ IN UINT32 *Signature OPTIONAL
+ );
+
+EFI_STATUS
+TestPointCheckHsti (
+ VOID
+ );
+
+VOID
+TestPointDumpVariable (
VOID
);
EFI_STATUS
-TestPointDumpMemoryTypeInformation (
+TestPointCheckEsrt (
VOID
);
EFI_STATUS
-TestPointDumpAcpi (
+TestPointCheckSmmInfo (
VOID
);
EFI_STATUS
-TestPointDumpHsti (
+TestPointCheckPciBusMaster (
VOID
);
EFI_STATUS
-TestPointDumpVariable (
+TestPointCheckLoadedImage (
VOID
);
EFI_STATUS
-TestPointDumpEsrt (
+EFIAPI
+TestPointCheckSmiHandlerInstrument (
VOID
);
EFI_STATUS
-TestPointDumpSmmInfo (
+TestPointCheckUefiSecureBoot (
VOID
);
EFI_STATUS
-TestPointDumpLoadedImage (
+TestPointCheckPiSignedFvBoot (
VOID
);
EFI_STATUS
+TestPointCheckTcgTrustedBoot (
+ VOID
+ );
+
+EFI_STATUS
+TestPointCheckTcgMor (
+ VOID
+ );
+
+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_DXE},
+ TEST_POINT_FEATURE_SIZE,
+ {0}, // FeaturesImplemented
+ {0}, // FeaturesVerified
+ 0,
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED UINT8 mFeatureImplemented[TEST_POINT_FEATURE_SIZE];
+
+EFI_STATUS
EFIAPI
-TestPointPciEnumerationDone (
+TestPointPciEnumerationDonePciBusMasterDisabled (
VOID
)
{
EFI_STATUS Status;
BOOLEAN Result;
- DEBUG ((DEBUG_INFO, "======== TestPointPciEnumerationDone - Enter\n"));
+ if ((mFeatureImplemented[2] & TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_PCI_BUS_MASTER_DISABLED) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointPciEnumerationDonePciBusMasterDisabled - Enter\n"));
Result = TRUE;
- Status = TestPointDumpPci ();
+ Status = TestPointCheckPciBusMaster ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
@@ -111,43 +171,171 @@ TestPointPciEnumerationDone (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
2,
- TEST_POINT_BYTE2_PCI_ENUMERATION_DONE
+ TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_PCI_BUS_MASTER_DISABLED
);
}
- DEBUG ((DEBUG_INFO, "======== TestPointPciEnumerationDone - Exit\n"));
+ DEBUG ((DEBUG_INFO, "======== TestPointPciEnumerationDonePciBusMasterDisabled - Exit\n"));
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
-TestPointEndOfDxe (
+TestPointPciEnumerationDonePciResourceAllocated (
VOID
)
{
EFI_STATUS Status;
BOOLEAN Result;
-
- DEBUG ((DEBUG_INFO, "======== TestPointEndOfDxe - Enter\n"));
+ if ((mFeatureImplemented[2] & TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_RESOURCE_ALLOCATED) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointPciEnumerationDonePciResourceAllocated - Enter\n"));
+
Result = TRUE;
- Status = TestPointDumpLoadedImage ();
+ Status = TestPointCheckPciResource ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpMemMap ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 2,
+ TEST_POINT_BYTE2_PCI_ENUMERATION_DONE_RESOURCE_ALLOCATED
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointPciEnumerationDonePciResourceAllocated - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfDxeDmarTableFuntional (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+ UINT32 Signature;
+
+ if ((mFeatureImplemented[2] & TEST_POINT_BYTE2_END_OF_DXE_DMAT_TABLE_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfDxeDmarTableFuntional - Enter\n"));
+
+ Signature = EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE;
+ Result = TRUE;
+ Status = TestPointCheckAcpi (&Signature);
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpGcd ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 2,
+ TEST_POINT_BYTE2_END_OF_DXE_DMAT_TABLE_FUNCTIONAL
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfDxeDmarTableFuntional - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfDxeNoThirdPartyPciOptionRom (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[2] & TEST_POINT_BYTE2_END_OF_DXE_NO_THIRD_PARTY_PCI_OPTION_ROM) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfDxeNoThirdPartyPciOptionRom - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointCheckLoadedImage ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpConsoleVariable ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 2,
+ TEST_POINT_BYTE2_END_OF_DXE_NO_THIRD_PARTY_PCI_OPTION_ROM
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfDxeNoThirdPartyPciOptionRom - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointDxeSmmReadyToLockSmramAligned (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[2] & TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_SMRAM_ALIGNED) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointDxeSmmReadyToLockSmramAligned - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointCheckSmmInfo ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpBootVariable ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 2,
+ TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_SMRAM_ALIGNED
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointDxeSmmReadyToLockSmramAligned - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointDxeSmmReadyToLockWsmtTableFuntional (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+ UINT32 Signature;
+
+ if ((mFeatureImplemented[2] & TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_WSMT_TABLE_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointDxeSmmReadyToLockWsmtTableFuntional - Enter\n"));
+
+ Result = TRUE;
+ Signature = EFI_ACPI_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE;
+ Status = TestPointCheckAcpi (&Signature);
if (EFI_ERROR(Status)) {
Result = FALSE;
}
@@ -157,27 +345,31 @@ TestPointEndOfDxe (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
2,
- TEST_POINT_BYTE2_END_OF_DXE
+ TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK_WSMT_TABLE_FUNCTIONAL
);
}
- DEBUG ((DEBUG_INFO, "======== TestPointEndOfDxe - Exit\n"));
+ DEBUG ((DEBUG_INFO, "======== TestPointDxeSmmReadyToLockWsmtTableFuntional - Exit\n"));
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
-TestPointDxeSmmReadyToLock (
+TestPointReadyToBootSmiHandlerInstrument (
VOID
)
{
EFI_STATUS Status;
BOOLEAN Result;
+
+ if ((mFeatureImplemented[3] & TEST_POINT_BYTE3_READY_TO_BOOT_SMI_HANDLER_INSTRUMENT) == 0) {
+ return EFI_SUCCESS;
+ }
- DEBUG ((DEBUG_INFO, "======== TestPointDxeSmmReadyToLock - Enter\n"));
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootSmiHandlerInstrument - Enter\n"));
Result = TRUE;
- Status = TestPointDumpSmmInfo ();
+ Status = TestPointCheckSmiHandlerInstrument ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
@@ -186,73 +378,383 @@ TestPointDxeSmmReadyToLock (
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
- 2,
- TEST_POINT_BYTE2_DXE_SMM_READY_TO_LOCK
+ 3,
+ TEST_POINT_BYTE3_READY_TO_BOOT_SMI_HANDLER_INSTRUMENT
);
}
- DEBUG ((DEBUG_INFO, "======== TestPointDxeSmmReadyToLock - Exit\n"));
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootSmiHandlerInstrument - Exit\n"));
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
-TestPointReadyToBoot (
+TestPointReadyToBootAcpiTableFuntional (
VOID
)
{
EFI_STATUS Status;
BOOLEAN Result;
+
+ if ((mFeatureImplemented[3] & TEST_POINT_BYTE3_READY_TO_BOOT_ACPI_TABLE_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
- DEBUG ((DEBUG_INFO, "======== TestPointReadyToBoot - Enter\n"));
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootAcpiTableFuntional - Enter\n"));
Result = TRUE;
- Status = TestPointDumpLoadedImage ();
+ Status = TestPointCheckAcpi (NULL);
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpMemMap ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 3,
+ TEST_POINT_BYTE3_READY_TO_BOOT_ACPI_TABLE_FUNCTIONAL
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootAcpiTableFuntional - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootMemoryTypeInformationFunctional (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[3] & TEST_POINT_BYTE3_READY_TO_BOOT_MEMORY_TYPE_INFORMATION_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootMemoryTypeInformationFunctional - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointCheckMemoryTypeInformation ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpGcd ();
+ TestPointDumpUefiMemoryMap (NULL, NULL, NULL);
+ Status = TestPointCheckUefiMemoryMap ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpDevicePath ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 3,
+ TEST_POINT_BYTE3_READY_TO_BOOT_MEMORY_TYPE_INFORMATION_FUNCTIONAL
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootMemoryTypeInformationFunctional - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootUefiMemoryAttributeTableFunctional (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[3] & TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootUefiMemoryAttributeTableFunctional - Enter\n"));
+
+ Result = TRUE;
+ TestPointDumpUefiMemoryMap (NULL, NULL, NULL);
+ TestPointDumpGcd (NULL, NULL, NULL, NULL);
+ Status = TestPointCheckUefiMemAttribute ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpConsoleVariable ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 3,
+ TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootUefiMemoryAttributeTableFunctional - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootUefiBootVariableFunctional (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[3] & TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_BOOT_VARIABLE_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootUefiBootVariableFunctional - Enter\n"));
+
+ Result = TRUE;
+ TestPointDumpDevicePath ();
+ TestPointDumpVariable ();
+ Status = TestPointCheckBootVariable ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpBootVariable ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 3,
+ TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_BOOT_VARIABLE_FUNCTIONAL
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootUefiBootVariableFunctional - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootUefiConsoleVariableFunctional (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[3] & TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_CONSOLE_VARIABLE_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootUefiConsoleVariableFunctional - Enter\n"));
+
+ Result = TRUE;
+ TestPointDumpDevicePath ();
+ TestPointDumpVariable ();
+ Status = TestPointCheckConsoleVariable ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpMemoryTypeInformation ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 3,
+ TEST_POINT_BYTE3_READY_TO_BOOT_UEFI_CONSOLE_VARIABLE_FUNCTIONAL
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootUefiConsoleVariableFunctional - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootHstiTableFunctional (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[3] & TEST_POINT_BYTE3_READY_TO_BOOT_HSTI_TABLE_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootHstiTableFunctional - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointCheckHsti ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpVariable ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 3,
+ TEST_POINT_BYTE3_READY_TO_BOOT_HSTI_TABLE_FUNCTIONAL
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootHstiTableFunctional - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootEsrtTableFunctional (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[4] & TEST_POINT_BYTE4_READY_TO_BOOT_ESRT_TABLE_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootEsrtTableFunctional - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointCheckEsrt ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpMemAttribute ();
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 4,
+ TEST_POINT_BYTE4_READY_TO_BOOT_ESRT_TABLE_FUNCTIONAL
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootEsrtTableFunctional - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootUefiSecureBootEnabled (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[4] & TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootUefiSecureBootEnabled - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointCheckUefiSecureBoot ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpAcpi ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 4,
+ TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootUefiSecureBootEnabled - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootPiSignedFvBootEnabled (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[4] & TEST_POINT_BYTE4_READY_TO_BOOT_PI_SIGNED_FV_BOOT_ENABLED) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootPiSignedFvBootEnabled - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointCheckPiSignedFvBoot ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpEsrt ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 4,
+ TEST_POINT_BYTE4_READY_TO_BOOT_PI_SIGNED_FV_BOOT_ENABLED
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootPiSignedFvBootEnabled - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootTcgTrustedBootEnabled (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[4] & TEST_POINT_BYTE4_READY_TO_BOOT_TCG_TRUSTED_BOOT_ENABLED) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootTcgTrustedBootEnabled - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointCheckTcgTrustedBoot ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpHsti ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 4,
+ TEST_POINT_BYTE4_READY_TO_BOOT_TCG_TRUSTED_BOOT_ENABLED
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootTcgTrustedBootEnabled - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootTcgMorEnabled (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[4] & TEST_POINT_BYTE4_READY_TO_BOOT_TCG_MOR_ENABLED) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootTcgMorEnabled - Enter\n"));
+
+ Result = TRUE;
+ Status = TestPointCheckTcgMor ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
@@ -261,12 +763,12 @@ TestPointReadyToBoot (
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
- 2,
- TEST_POINT_BYTE2_READY_TO_BOOT
+ 4,
+ TEST_POINT_BYTE4_READY_TO_BOOT_TCG_MOR_ENABLED
);
}
- DEBUG ((DEBUG_INFO, "======== TestPointReadyToBoot - Exit\n"));
+ DEBUG ((DEBUG_INFO, "======== TestPointReadyToBootTcgMorEnabled - Exit\n"));
return EFI_SUCCESS;
}
@@ -283,19 +785,6 @@ TestPointExitBootServices (
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
**/
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf
index c5f6882340..609f6c34af 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf
@@ -31,10 +31,13 @@
UefiLib
PrintLib
DevicePathLib
+ DxeServicesLib
HobLib
PeCoffGetEntryPointLib
HstiLib
TestPointLib
+ PciSegmentLib
+ PciSegmentInfoLib
[Packages]
MinPlatformPkg/MinPlatformPkg.dec
@@ -43,26 +46,30 @@
[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
+ DxeCheckGcd.c
+ DxeCheckMemoryMap.c
+ DxeCheckMemoryAttribute.c
+ DxeCheckPci.c
+ DxeCheckConsoleVariable.c
+ DxeCheckBootVariable.c
+ DxeCheckVariable.c
+ DxeCheckDevicePath.c
+ DxeCheckMemoryTypeInformation.c
+ DxeCheckAcpi.c
+ DxeCheckAcpiMadt.c
+ DxeCheckAcpiMcfg.c
+ DxeCheckAcpiHpet.c
+ DxeCheckAcpiDmar.c
+ DxeCheckAcpiWsmt.c
+ DxeCheckHsti.c
+ DxeCheckEsrt.c
+ DxeCheckLoadedImage.c
+ DxeCheckSmmInfo.c
+ DxeCheckSmiHandlerInstrument.c
+ DxeCheckUefiSecureBoot.c
+ DxeCheckPiSignedFvBoot.c
+ DxeCheckTcgTrustedBoot.c
+ DxeCheckTcgMor.c
[Guids]
gEfiMemoryAttributesTableGuid
@@ -71,7 +78,12 @@
gEfiAcpi10TableGuid
gEfiMemoryTypeInformationGuid
gEfiSystemResourceTableGuid
- gEfiSmmPeiSmramMemoryReserveGuid
+ gEfiMemoryOverwriteControlDataGuid
+ gEfiMemoryOverwriteRequestControlLockGuid
+ gEfiGlobalVariableGuid
+ gEfiImageSecurityDatabaseGuid
+ gSmiHandlerProfileGuid
+ gEdkiiPiSmmCommunicationRegionTableGuid
[Protocols]
gEfiPciIoProtocolGuid
@@ -81,6 +93,17 @@
gEfiLoadedImageProtocolGuid
gEfiLoadedImageDevicePathProtocolGuid
gEfiDevicePathProtocolGuid
+ gEfiRuntimeArchProtocolGuid
+ gEfiTcg2ProtocolGuid
+ gEfiSmmCommunicationProtocolGuid
+ gEfiSmmSwDispatch2ProtocolGuid
+ gEfiSmmSxDispatch2ProtocolGuid
+ gEfiSmmPowerButtonDispatch2ProtocolGuid
+ gEfiSmmStandbyButtonDispatch2ProtocolGuid
+ gEfiSmmPeriodicTimerDispatch2ProtocolGuid
+ gEfiSmmGpiDispatch2ProtocolGuid
+ gEfiSmmIoTrapDispatch2ProtocolGuid
+ gEfiSmmUsbDispatch2ProtocolGuid
[Pcd]
gMinPlatformModuleTokenSpaceGuid.PcdTestPointIbvPlatformFeature
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpFvInfo.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckFvInfo.c
index c32c03b2c7..9adbe40fd6 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpFvInfo.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckFvInfo.c
@@ -16,12 +16,31 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/TestPointCheckLib.h>
#include <Library/TestPointLib.h>
#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/PeiServicesLib.h>
#include <Ppi/FirmwareVolumeInfo.h>
#include <Ppi/FirmwareVolumeInfo2.h>
EFI_STATUS
-TestPointDumpFvInfo (
+TestPointCheckFv (
+ IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader,
+ IN UINT64 Size,
+ IN GUID *FvFormat
+ )
+{
+ if (!CompareGuid (FvFormat, &FvHeader->FileSystemGuid)) {
+ DEBUG ((DEBUG_ERROR, "FvFormat error - 0x%lx\n", FvHeader));
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Size != FvHeader->FvLength) {
+ DEBUG ((DEBUG_ERROR, "FvLength error - 0x%lx\n", FvHeader));
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+TestPointCheckFvInfo (
VOID
)
{
@@ -32,7 +51,7 @@ TestPointDumpFvInfo (
UINTN Index;
UINTN Index2;
- DEBUG ((DEBUG_INFO, "==== TestPointDumpFvInfo - Enter\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckFvInfo - Enter\n"));
DEBUG ((DEBUG_INFO, "FV Info PPI\n"));
for (Index = 0; ; Index++) {
Status = PeiServicesLocatePpi (
@@ -104,15 +123,54 @@ TestPointDumpFvInfo (
FvInfo2->AuthenticationStatus
));
}
- DEBUG ((DEBUG_INFO, "==== TestPointDumpFvInfo - Exit\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckFvInfo - 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;
+ for (Index = 0; ; Index++) {
+ Status = PeiServicesLocatePpi (
+ &gEfiPeiFirmwareVolumeInfoPpiGuid,
+ Index,
+ &Descriptor,
+ (VOID **)&FvInfo
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ Status = TestPointCheckFv (FvInfo->FvInfo, FvInfo->FvInfoSize, &FvInfo->FvFormat);
+ if (EFI_ERROR(Status)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_FV_INFO_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_MEMORY_DISCOVERED \
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_FV_INFO_FUNCTIONAL_ERROR_STRING
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ for (Index2 = 0; ; Index2++) {
+ Status = PeiServicesLocatePpi (
+ &gEfiPeiFirmwareVolumeInfo2PpiGuid,
+ Index2,
+ &Descriptor,
+ (VOID **)&FvInfo2
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ Status = TestPointCheckFv (FvInfo2->FvInfo, FvInfo2->FvInfoSize, &FvInfo2->FvFormat);
+ if (EFI_ERROR(Status)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_FV_INFO_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_MEMORY_DISCOVERED \
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_FV_INFO_FUNCTIONAL_ERROR_STRING
+ );
+ 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/PeiCheckHob.c
index 9ef96936c0..dcb8dd7040 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpHob.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckHob.c
@@ -91,7 +91,7 @@ ShortNameOfResourceType (
}
}
-EFI_STATUS
+VOID
DumpPhitHob (
IN VOID *HobList
)
@@ -108,11 +108,9 @@ DumpPhitHob (
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
+VOID
DumpCpuHob (
IN VOID *HobList
)
@@ -131,11 +129,9 @@ DumpCpuHob (
));
}
}
-
- return EFI_SUCCESS;
}
-EFI_STATUS
+VOID
DumpResourceHob (
IN VOID *HobList
)
@@ -180,11 +176,9 @@ DumpResourceHob (
DEBUG ((DEBUG_INFO, "\n"));
}
}
-
- return EFI_SUCCESS;
}
-EFI_STATUS
+VOID
DumpFvHob (
IN VOID *HobList
)
@@ -192,9 +186,7 @@ DumpFvHob (
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) {
@@ -206,7 +198,6 @@ DumpFvHob (
FirmwareVolumeHob->BaseAddress,
FirmwareVolumeHob->Length
));
- Found = TRUE;
}
}
@@ -223,23 +214,11 @@ DumpFvHob (
&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
+VOID
DumpMemoryAllocationHob (
IN VOID *HobList
)
@@ -286,11 +265,9 @@ DumpMemoryAllocationHob (
DEBUG ((DEBUG_INFO, "\n"));
}
}
-
- return EFI_SUCCESS;
}
-EFI_STATUS
+VOID
DumpGuidHob (
IN VOID *HobList
)
@@ -311,67 +288,92 @@ DumpGuidHob (
));
}
}
-
- return EFI_SUCCESS;
}
-EFI_STATUS
+VOID
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;
- }
+ DumpPhitHob (HobList);
if (PhitHobOnly) {
goto Done ;
}
- Status = DumpCpuHob (HobList);
- if (EFI_ERROR(Status)) {
- Result = FALSE;
- }
+ DumpCpuHob (HobList);
- Status = DumpResourceHob (HobList);
- if (EFI_ERROR(Status)) {
- Result = FALSE;
- }
+ DumpResourceHob (HobList);
- Status = DumpFvHob (HobList);
- if (EFI_ERROR(Status)) {
- Result = FALSE;
- }
+ DumpFvHob (HobList);
- Status = DumpMemoryAllocationHob (HobList);
- if (EFI_ERROR(Status)) {
- Result = FALSE;
- }
+ DumpMemoryAllocationHob (HobList);
- Status = DumpGuidHob (HobList);
- if (EFI_ERROR(Status)) {
- Result = FALSE;
- }
+ DumpGuidHob (HobList);
Done:
DEBUG ((DEBUG_INFO, "==== TestPointDumpHob - Exit\n"));
- if (!Result) {
- return EFI_INVALID_PARAMETER;
+ return ;
+}
+
+EFI_STATUS
+TestPointCheckMemoryResource (
+ VOID
+ )
+{
+ VOID *HobList;
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
+ EFI_PEI_HOB_POINTERS Hob2;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob2;
+
+ HobList = GetHobList ();
+
+ //
+ // Check overlap
+ //
+ 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;
+ switch (ResourceHob->ResourceType) {
+ case EFI_RESOURCE_SYSTEM_MEMORY:
+ if (((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES) ||
+ ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == INITIALIZED_MEMORY_ATTRIBUTES)) {
+ DEBUG ((DEBUG_INFO, "Overlap Checking 0x%lx 0x%lx\n", ResourceHob->PhysicalStart, ResourceHob->ResourceLength));
+ for (Hob2.Raw = GET_NEXT_HOB (Hob); !END_OF_HOB_LIST (Hob2); Hob2.Raw = GET_NEXT_HOB (Hob2)) {
+ ResourceHob2 = Hob2.ResourceDescriptor;
+ switch (ResourceHob2->ResourceType) {
+ case EFI_RESOURCE_SYSTEM_MEMORY:
+ if (((ResourceHob2->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES) ||
+ ((ResourceHob2->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == INITIALIZED_MEMORY_ATTRIBUTES)) {
+ if ((ResourceHob->PhysicalStart >= ResourceHob2->PhysicalStart && ResourceHob->PhysicalStart < ResourceHob2->PhysicalStart + ResourceHob2->ResourceLength) ||
+ (ResourceHob2->PhysicalStart >= ResourceHob->PhysicalStart && ResourceHob2->PhysicalStart < ResourceHob->PhysicalStart + ResourceHob->ResourceLength)) {
+ DEBUG ((DEBUG_INFO, " Overlap 0x%lx 0x%lx\n", ResourceHob2->PhysicalStart, ResourceHob2->ResourceLength));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
}
+
return EFI_SUCCESS;
}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckMtrr.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckMtrr.c
new file mode 100644
index 0000000000..f4e666900c
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckMtrr.c
@@ -0,0 +1,442 @@
+/** @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/HobLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MtrrLib.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)
+
+MTRR_MEMORY_CACHE_TYPE
+SetCurrentCacheType (
+ IN MTRR_MEMORY_CACHE_TYPE CurrentCacheType,
+ IN MTRR_MEMORY_CACHE_TYPE NewCacheType
+ )
+{
+ switch (CurrentCacheType) {
+ case CacheUncacheable:
+ return CacheUncacheable;
+ break;
+ case CacheWriteBack:
+ if (NewCacheType == CacheWriteThrough) {
+ return CacheWriteThrough;
+ } else {
+ return CacheInvalid;
+ }
+ break;
+ case CacheWriteThrough:
+ if (NewCacheType == CacheWriteBack) {
+ return CacheWriteThrough;
+ } else {
+ return CacheInvalid;
+ }
+ break;
+ default:
+ if (NewCacheType == CacheUncacheable) {
+ return CacheUncacheable;
+ } else {
+ return CacheInvalid;
+ }
+ break;
+ }
+}
+
+EFI_STATUS
+TestPointCheckCacheType (
+ IN MTRR_SETTINGS *Mtrrs,
+ IN VARIABLE_MTRR *VariableMtrr,
+ IN UINT64 Base,
+ IN UINT64 Length,
+ IN MTRR_MEMORY_CACHE_TYPE ExpectedCacheType
+ )
+{
+ UINT64 TempBase;
+ UINT64 TempLength;
+ UINTN VariableMtrrIndex;
+ UINTN VariableMtrrCount;
+
+ if (Base < BASE_1MB) {
+ // Check Fixed MTRR
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Check
+ //
+ VariableMtrrCount = GetVariableMtrrCount ();
+ for (VariableMtrrIndex = 0; VariableMtrrIndex < VariableMtrrCount; VariableMtrrIndex++) {
+ if (!VariableMtrr[VariableMtrrIndex].Valid) {
+ continue;
+ }
+ if (((Base >= VariableMtrr[VariableMtrrIndex].BaseAddress) && (Base < VariableMtrr[VariableMtrrIndex].BaseAddress + VariableMtrr[VariableMtrrIndex].Length)) ||
+ ((VariableMtrr[VariableMtrrIndex].BaseAddress >= Base) && (VariableMtrr[VariableMtrrIndex].BaseAddress < Base + Length))) {
+ // Overlap check
+ if (VariableMtrr[VariableMtrrIndex].Type != ExpectedCacheType) {
+ DEBUG ((DEBUG_ERROR, "Cache [0x%lx, 0x%lx] is not expected\n", Base, Length));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ }
+ TempBase = Base;
+ TempLength = Length;
+ for (VariableMtrrIndex = 0; VariableMtrrIndex < VariableMtrrCount; VariableMtrrIndex++) {
+ if (!VariableMtrr[VariableMtrrIndex].Valid) {
+ continue;
+ }
+ if (((TempBase >= VariableMtrr[VariableMtrrIndex].BaseAddress) && (TempBase < VariableMtrr[VariableMtrrIndex].BaseAddress + VariableMtrr[VariableMtrrIndex].Length)) ||
+ ((VariableMtrr[VariableMtrrIndex].BaseAddress >= TempBase) && (VariableMtrr[VariableMtrrIndex].BaseAddress < TempBase + TempLength))) {
+ // Update checked region
+ if (TempBase >= VariableMtrr[VariableMtrrIndex].BaseAddress) {
+ if (TempBase + TempLength > VariableMtrr[VariableMtrrIndex].BaseAddress + VariableMtrr[VariableMtrrIndex].Length) {
+ TempLength = TempBase + TempLength - (VariableMtrr[VariableMtrrIndex].BaseAddress + VariableMtrr[VariableMtrrIndex].Length);
+ TempBase = VariableMtrr[VariableMtrrIndex].BaseAddress + VariableMtrr[VariableMtrrIndex].Length;
+ } else {
+ TempLength = 0;
+ }
+ } else {
+ TempLength = VariableMtrr[VariableMtrrIndex].BaseAddress - TempBase;
+ }
+ }
+ }
+
+ if (TempLength != 0) {
+ if ((Mtrrs->MtrrDefType & 0xFF) != ExpectedCacheType) {
+ DEBUG ((DEBUG_ERROR, "Cache [0x%lx, 0x%lx] is not expected in default\n", TempBase, TempLength));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+TestPointCheckMtrrMask (
+ IN MTRR_SETTINGS *Mtrrs
+ )
+{
+ UINTN Index;
+ UINT64 Length;
+ UINT32 RegEax;
+ UINT8 PhysicalAddressBits;
+ UINTN VariableMtrrCount;
+
+ AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
+ if (RegEax >= 0x80000008) {
+ AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
+ PhysicalAddressBits = (UINT8) RegEax;
+ } else {
+ PhysicalAddressBits = 36;
+ }
+
+ VariableMtrrCount = GetVariableMtrrCount ();
+ for (Index = 0; Index < VariableMtrrCount; Index++) {
+ if ((Mtrrs->Variables.Mtrr[Index].Mask & BIT11) == 0) {
+ continue;
+ }
+ Length = Mtrrs->Variables.Mtrr[Index].Mask & ~0xFFFull;
+ Length = ~Length + 1;
+ Length = Length & (LShiftU64 (1, PhysicalAddressBits) - 1);
+ if (Length != GetPowerOfTwo64 (Length)) {
+ DEBUG ((DEBUG_ERROR, "MTRR Mask (0x%016lx) is invalid\n", Mtrrs->Variables.Mtrr[Index].Mask));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ return EFI_SUCCESS;
+}
+
+VOID
+TestPointMtrrConvert (
+ IN MTRR_SETTINGS *Mtrrs,
+ OUT VARIABLE_MTRR *VariableMtrr
+ )
+{
+ UINT32 RegEax;
+ UINT8 PhysicalAddressBits;
+ VARIABLE_MTRR TempVariableMtrr;
+ UINTN Index;
+ UINTN VariableMtrrIndex;
+ UINTN VariableMtrrCount;
+
+ AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
+ if (RegEax >= 0x80000008) {
+ AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
+ PhysicalAddressBits = (UINT8) RegEax;
+ } else {
+ PhysicalAddressBits = 36;
+ }
+
+ //
+ // Calculate Length
+ //
+ VariableMtrrIndex = 0;
+ VariableMtrrCount = GetVariableMtrrCount ();
+ for (Index = 0; Index < VariableMtrrCount; Index++) {
+ if ((Mtrrs->Variables.Mtrr[Index].Mask & BIT11) == 0) {
+ continue;
+ }
+ VariableMtrr[VariableMtrrIndex].Length = Mtrrs->Variables.Mtrr[Index].Mask & ~0xFFFull;
+ VariableMtrr[VariableMtrrIndex].Length = ~VariableMtrr[VariableMtrrIndex].Length + 1;
+ VariableMtrr[VariableMtrrIndex].Length = VariableMtrr[VariableMtrrIndex].Length & (LShiftU64 (1, PhysicalAddressBits) - 1);
+ VariableMtrr[VariableMtrrIndex].BaseAddress = Mtrrs->Variables.Mtrr[Index].Base & ~0xFFFull;
+ VariableMtrr[VariableMtrrIndex].Type = Mtrrs->Variables.Mtrr[Index].Base & 0xFF;
+ VariableMtrr[VariableMtrrIndex].Valid = TRUE;
+ VariableMtrrIndex ++;
+ }
+ VariableMtrrCount = VariableMtrrIndex;
+
+ //
+ // Sort
+ //
+ if (VariableMtrrCount > 1) {
+ for (VariableMtrrIndex = 0; VariableMtrrIndex < VariableMtrrCount; VariableMtrrIndex++) {
+ Index = VariableMtrrIndex + 1;
+ for (Index = VariableMtrrIndex + 1; Index < VariableMtrrCount; Index++) {
+ if (VariableMtrr[VariableMtrrIndex].BaseAddress > VariableMtrr[Index].BaseAddress) {
+ CopyMem (&TempVariableMtrr, &VariableMtrr[VariableMtrrIndex], sizeof(VARIABLE_MTRR));
+ CopyMem (&VariableMtrr[VariableMtrrIndex], &VariableMtrr[Index], sizeof(VARIABLE_MTRR));
+ CopyMem (&VariableMtrr[Index], &TempVariableMtrr, sizeof(VARIABLE_MTRR));
+ }
+ }
+ }
+ }
+
+ //
+ // Dump
+ //
+ DEBUG ((DEBUG_INFO, "CACHE Result:\n"));
+ for (VariableMtrrIndex = 0; VariableMtrrIndex < VariableMtrrCount; VariableMtrrIndex++) {
+ if (VariableMtrr[VariableMtrrIndex].Valid) {
+ DEBUG ((DEBUG_INFO, "CACHE - 0x%016lx 0x%016lx %d\n",
+ VariableMtrr[VariableMtrrIndex].BaseAddress,
+ VariableMtrr[VariableMtrrIndex].Length,
+ VariableMtrr[VariableMtrrIndex].Type
+ ));
+ }
+ }
+
+ //
+ // Remove overlap
+ //
+ if (VariableMtrrCount > 1) {
+ for (VariableMtrrIndex = 0; VariableMtrrIndex < VariableMtrrCount; VariableMtrrIndex++) {
+ Index = VariableMtrrIndex + 1;
+ for (Index = VariableMtrrIndex + 1; Index < VariableMtrrCount - 1; Index++) {
+ if (VariableMtrr[VariableMtrrIndex].BaseAddress + VariableMtrr[VariableMtrrIndex].Length > VariableMtrr[Index].BaseAddress) {
+ VariableMtrr[VariableMtrrIndex].Length = VariableMtrr[Index].BaseAddress - VariableMtrr[VariableMtrrIndex].BaseAddress;
+ }
+ }
+ }
+ }
+
+ //
+ // Dump
+ //
+ DEBUG ((DEBUG_INFO, "CACHE Final:\n"));
+ for (VariableMtrrIndex = 0; VariableMtrrIndex < VariableMtrrCount; VariableMtrrIndex++) {
+ if (VariableMtrr[VariableMtrrIndex].Valid) {
+ DEBUG ((DEBUG_INFO, "CACHE - 0x%016lx 0x%016lx %d\n",
+ VariableMtrr[VariableMtrrIndex].BaseAddress,
+ VariableMtrr[VariableMtrrIndex].Length,
+ VariableMtrr[VariableMtrrIndex].Type
+ ));
+ }
+ }
+}
+
+EFI_STATUS
+TestPointCheckMtrrForPei (
+ IN MTRR_SETTINGS *Mtrrs,
+ IN VARIABLE_MTRR *VariableMtrr
+ )
+{
+ EFI_STATUS Status;
+ VOID *HobList;
+ EFI_HOB_HANDOFF_INFO_TABLE *PhitHob;
+
+ HobList = GetHobList ();
+ PhitHob = HobList;
+
+ //
+ // DRAM must be WB
+ //
+ DEBUG ((DEBUG_INFO, "MTRR Checking 0x%lx 0x%lx\n", PhitHob->EfiMemoryBottom, PhitHob->EfiMemoryTop - PhitHob->EfiMemoryBottom));
+ Status = TestPointCheckCacheType (
+ Mtrrs,
+ VariableMtrr,
+ PhitHob->EfiMemoryBottom,
+ PhitHob->EfiMemoryTop - PhitHob->EfiMemoryBottom,
+ CacheWriteBack
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // FV must be WB or WP
+ //
+
+ //
+ // MMIO must be UC
+ //
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+TestPointCheckMtrrForDxe (
+ IN MTRR_SETTINGS *Mtrrs,
+ IN VARIABLE_MTRR *VariableMtrr
+ )
+{
+ EFI_STATUS Status;
+ VOID *HobList;
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
+
+ HobList = GetHobList ();
+
+ //
+ // DRAM must be WB
+ //
+ 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;
+ switch (ResourceHob->ResourceType) {
+ case EFI_RESOURCE_SYSTEM_MEMORY:
+ if (((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES) ||
+ ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == INITIALIZED_MEMORY_ATTRIBUTES)) {
+ DEBUG ((DEBUG_INFO, "MTRR Checking 0x%lx 0x%lx\n", ResourceHob->PhysicalStart, ResourceHob->ResourceLength));
+ Status = TestPointCheckCacheType (
+ Mtrrs,
+ VariableMtrr,
+ ResourceHob->PhysicalStart,
+ ResourceHob->ResourceLength,
+ CacheWriteBack
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ //
+ // FV must be WB or WP
+ //
+
+ //
+ // MMIO must be UC
+ //
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+TestPointCheckMtrr (
+ IN BOOLEAN IsForDxe
+ )
+{
+ EFI_STATUS Status;
+ MTRR_SETTINGS LocalMtrrs;
+ MTRR_SETTINGS *Mtrrs;
+ UINTN Index;
+ UINTN VariableMtrrCount;
+ BOOLEAN Result;
+ VARIABLE_MTRR VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR];
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckMtrr - 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, "==== TestPointCheckMtrr - Exit\n"));
+
+ //
+ // Check Mask
+ //
+ Status = TestPointCheckMtrrMask (Mtrrs);
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ } else {
+
+ ZeroMem (VariableMtrr, sizeof(VariableMtrr));
+ TestPointMtrrConvert (Mtrrs, VariableMtrr);
+
+ if (IsForDxe) {
+ Status = TestPointCheckMtrrForDxe (Mtrrs, VariableMtrr);
+ } else {
+ Status = TestPointCheckMtrrForPei (Mtrrs, VariableMtrr);
+ }
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ } else {
+ Result = TRUE;
+ }
+ }
+
+ if (!Result) {
+ if (IsForDxe) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_END_OF_PEI_MTRR_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_END_OF_PEI \
+ TEST_POINT_BYTE1_END_OF_PEI_MTRR_FUNCTIONAL_ERROR_STRING
+ );
+ } else {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_MTRR_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_MEMORY_DISCOVERED \
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_MTRR_FUNCTIONAL_ERROR_STRING
+ );
+ }
+ }
+
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckPci.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckPci.c
new file mode 100644
index 0000000000..631f2bd122
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckPci.c
@@ -0,0 +1,87 @@
+/** @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/PciSegmentLib.h>
+#include <Library/PciSegmentInfoLib.h>
+#include <IndustryStandard/Pci.h>
+
+EFI_STATUS
+TestPointCheckPciBusMaster (
+ VOID
+ )
+{
+ UINTN Segment;
+ UINTN SegmentCount;
+ UINTN Bus;
+ UINTN Device;
+ UINTN Function;
+ UINT16 VendorId;
+ UINT16 Command;
+ UINT8 HeaderType;
+ EFI_STATUS Status;
+ PCI_SEGMENT_INFO *PciSegmentInfo;
+
+ PciSegmentInfo = GetPciSegmentInfo (&SegmentCount);
+
+ Status = EFI_SUCCESS;
+ for (Segment = 0; Segment < SegmentCount; Segment++) {
+ for (Bus = PciSegmentInfo[Segment].StartBusNumber; Bus <= PciSegmentInfo[Segment].EndBusNumber; Bus++) {
+ for (Device = 0; Device <= 0x1F; Device++) {
+ for (Function = 0; Function <= 0x7; Function++) {
+ VendorId = PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS(PciSegmentInfo[Segment].SegmentNumber, Bus, Device, Function, PCI_VENDOR_ID_OFFSET));
+ //
+ // 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 (VendorId == 0xffff && Function == 0) {
+ break;
+ }
+
+ if (VendorId != 0xffff) {
+ Command = PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, Function, PCI_COMMAND_OFFSET));
+ if ((Command & EFI_PCI_COMMAND_BUS_MASTER) != 0) {
+ DEBUG ((DEBUG_INFO, "PCI BME enabled (S%04x.B%02x.D%02x.F%x - %04x)\n", Segment, Bus, Device, Function, Command));
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_END_OF_PEI_PCI_BUS_MASTER_DISABLED_ERROR_CODE \
+ TEST_POINT_END_OF_PEI \
+ TEST_POINT_BYTE1_END_OF_PEI_PCI_BUS_MASTER_DISABLED_ERROR_STRING
+ );
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // If this is not a multi-function device, we can leave the loop
+ // to deal with the next device.
+ //
+ HeaderType = PciSegmentRead8 (PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, Function, PCI_HEADER_TYPE_OFFSET));
+ if (Function == 0 && ((HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00)) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckSmmInfo.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckSmmInfo.c
new file mode 100644
index 0000000000..a65a2555cd
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckSmmInfo.c
@@ -0,0 +1,232 @@
+/** @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/PeiServicesLib.h>
+#include <Library/PeiServicesTablePointerLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Guid/SmramMemoryReserve.h>
+#include <Ppi/SmmAccess.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
+CheckSmramDescriptor (
+ IN UINTN NumberOfSmmReservedRegions,
+ IN EFI_SMRAM_DESCRIPTOR *Descriptor
+ )
+{
+ UINTN Index;
+ UINT64 Base;
+ UINT64 Length;
+
+ Base = 0;
+ Length = 0;
+ for (Index = 0; Index < NumberOfSmmReservedRegions; Index++) {
+ if (Base == 0) {
+ Base = Descriptor[Index].PhysicalStart;
+ Length = Descriptor[Index].PhysicalSize;
+ } else {
+ if (Base + Length == Descriptor[Index].PhysicalStart) {
+ Length = Length + Descriptor[Index].PhysicalSize;
+ } else if (Descriptor[Index].PhysicalStart + Descriptor[Index].PhysicalSize == Base) {
+ Base = Descriptor[Index].PhysicalStart;
+ Length = Length + Descriptor[Index].PhysicalSize;
+ } else {
+ DEBUG ((DEBUG_ERROR, "Smram is not adjacent\n"));
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_END_OF_PEI \
+ TEST_POINT_BYTE1_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL_ERROR_STRING
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ if (Length != GetPowerOfTwo64 (Length)) {
+ DEBUG ((DEBUG_ERROR, "Smram is not aligned\n"));
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_MEMORY_DISCOVERED \
+ TEST_POINT_BYTE1_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL_ERROR_STRING
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
+
+#if 0
+EFI_STATUS
+TestPointCheckSmramHob (
+ VOID
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *SmramHobDescriptorBlock;
+ UINT64 Base;
+ UINT64 Length;
+ UINTN Index;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmramHob - 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);
+ break;
+ }
+ }
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmramHob - Exit\n"));
+
+ Base = 0;
+ Length = 0;
+ Hob.Raw = GetHobList ();
+ 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);
+ for (Index = 0; Index < SmramHobDescriptorBlock->NumberOfSmmReservedRegions; Index++) {
+ if (Base == 0) {
+ Base = SmramHobDescriptorBlock->Descriptor[Index].PhysicalStart;
+ Length = SmramHobDescriptorBlock->Descriptor[Index].PhysicalSize;
+ } else {
+ if (Base + Length == SmramHobDescriptorBlock->Descriptor[Index].PhysicalStart) {
+ Length = Length + SmramHobDescriptorBlock->Descriptor[Index].PhysicalSize;
+ } else if (SmramHobDescriptorBlock->Descriptor[Index].PhysicalStart + SmramHobDescriptorBlock->Descriptor[Index].PhysicalSize == Base) {
+ Base = SmramHobDescriptorBlock->Descriptor[Index].PhysicalStart;
+ Length = Length + SmramHobDescriptorBlock->Descriptor[Index].PhysicalSize;
+ } else {
+ DEBUG ((DEBUG_ERROR, "SmramHob is not adjacent\n"));
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_END_OF_PEI \
+ TEST_POINT_BYTE1_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL_ERROR_STRING
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ }
+ break;
+ }
+ }
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ }
+
+ if (Length != GetPowerOfTwo64 (Length)) {
+ DEBUG ((DEBUG_ERROR, "SmramHob is not aligned\n"));
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_MEMORY_RESOURCE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_MEMORY_DISCOVERED \
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_MEMORY_RESOURCE_FUNCTIONAL_ERROR_STRING
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
+#endif
+
+EFI_STATUS
+TestPointCheckSmmInfoPei (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ PEI_SMM_ACCESS_PPI *SmmAccess;
+ UINTN Size;
+ EFI_SMRAM_DESCRIPTOR *SmramRanges;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmInfoPei - Enter\n"));
+
+ Status = PeiServicesLocatePpi (&gPeiSmmAccessPpiGuid, 0, NULL, (VOID **)&SmmAccess);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_SUCCESS;
+ goto Done ;
+ }
+
+ Size = 0;
+ Status = SmmAccess->GetCapabilities ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, &Size, NULL);
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+
+ SmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateZeroPool (Size);
+ ASSERT (SmramRanges != NULL);
+
+ Status = SmmAccess->GetCapabilities ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, &Size, SmramRanges);
+ ASSERT_EFI_ERROR (Status);
+
+ DEBUG ((DEBUG_INFO, "SMRAM Info\n"));
+ DumpSmramDescriptor (Size / sizeof (EFI_SMRAM_DESCRIPTOR), SmramRanges);
+
+ Status = CheckSmramDescriptor (Size / sizeof (EFI_SMRAM_DESCRIPTOR), SmramRanges);
+
+ FreePool (SmramRanges);
+
+Done:
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmInfoPei - Exit\n"));
+
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpMtrr.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpMtrr.c
deleted file mode 100644
index e50e10b0d5..0000000000
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpMtrr.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/** @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
deleted file mode 100644
index a8e2f91679..0000000000
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiDumpSmramHob.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/** @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
index 754771eafd..ff1d250266 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.c
@@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/BaseMemoryLib.h>
EFI_STATUS
-TestPointDumpMtrr (
+TestPointCheckMtrr (
IN BOOLEAN IsForDxe
);
@@ -29,29 +29,119 @@ TestPointDumpHob (
);
EFI_STATUS
-TestPointDumpFvInfo (
+TestPointCheckFvInfo (
VOID
);
EFI_STATUS
-TestPointDumpSmramHob (
+TestPointCheckMemoryResource (
VOID
);
EFI_STATUS
+TestPointCheckSmramHob (
+ VOID
+ );
+
+EFI_STATUS
+TestPointCheckSmmInfoPei (
+ VOID
+ );
+
+EFI_STATUS
+TestPointCheckPciBusMaster (
+ VOID
+ );
+
+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_PEI},
+ TEST_POINT_FEATURE_SIZE,
+ {0}, // FeaturesImplemented
+ {0}, // FeaturesVerified
+ 0,
+};
+
+UINT8 *
+GetFeatureImplemented (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *TestPoint;
+ UINTN TestPointSize;
+
+ Status = TestPointLibGetTable (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ TEST_POINT_IMPLEMENTATION_ID_PLATFORM_PEI,
+ &TestPoint,
+ &TestPointSize
+ );
+ ASSERT_EFI_ERROR(Status);
+
+ return (UINT8 *)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT);
+}
+
+EFI_STATUS
EFIAPI
TestPointDebugInitDone (
VOID
)
{
- EFI_STATUS Status;
- BOOLEAN Result;
+ UINT8 *FeatureImplemented;
+
+ FeatureImplemented = GetFeatureImplemented ();
+
+ //
+ // If code can run here, always set TEMP INIT DONE here.
+ //
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 0,
+ TEST_POINT_BYTE0_TEMP_INIT_DONE
+ );
+
+ if ((FeatureImplemented[1] & TEST_POINT_BYTE1_DEBUG_INIT_DONE) == 0) {
+ return EFI_SUCCESS;
+ }
DEBUG ((DEBUG_INFO, "======== TestPointDebugInitDone - Enter\n"));
DEBUG ((DEBUG_INFO, "!!! DebugInitialized !!!\n"));
+ 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
+TestPointMemoryDiscoveredMtrrFunctional (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+ UINT8 *FeatureImplemented;
+
+ FeatureImplemented = GetFeatureImplemented ();
+
+ if ((FeatureImplemented[1] & TEST_POINT_BYTE1_MEMORY_DISCOVERED_MTRR_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointMemoryDiscoveredMtrrFunctional - Enter\n"));
+
+ TestPointDumpHob (FALSE);
+
Result = TRUE;
- Status = TestPointDumpHob (TRUE);
+ Status = TestPointCheckMtrr (FALSE);
if (EFI_ERROR(Status)) {
Result = FALSE;
}
@@ -61,38 +151,70 @@ TestPointDebugInitDone (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
1,
- TEST_POINT_BYTE1_DEBUG_INIT_DONE
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_MTRR_FUNCTIONAL
);
}
- DEBUG ((DEBUG_INFO, "======== TestPointDebugInitDone - Exit\n"));
+ DEBUG ((DEBUG_INFO, "======== TestPointMemoryDiscoveredMtrrFunctional - Exit\n"));
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
-TestPointMemoryDiscovered (
+TestPointMemoryDiscoveredMemoryResourceFunctional (
VOID
)
{
EFI_STATUS Status;
BOOLEAN Result;
+ UINT8 *FeatureImplemented;
- DEBUG ((DEBUG_INFO, "======== TestPointMemoryDiscovered - Enter\n"));
+ FeatureImplemented = GetFeatureImplemented ();
+
+ if ((FeatureImplemented[1] & TEST_POINT_BYTE1_MEMORY_DISCOVERED_MEMORY_RESOURCE_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointMemoryDiscoveredMemoryResourceFunctional - Enter\n"));
Result = TRUE;
- Status = TestPointDumpMtrr (FALSE);
+
+ Status = TestPointCheckMemoryResource ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpHob (FALSE);
- if (EFI_ERROR(Status)) {
- Result = FALSE;
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 1,
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_MEMORY_RESOURCE_FUNCTIONAL
+ );
}
- Status = TestPointDumpFvInfo ();
- if (EFI_ERROR(Status)) {
- Result = FALSE;
+
+ DEBUG ((DEBUG_INFO, "======== TestPointMemoryDiscoveredMemoryResourceFunctional - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointMemoryDiscoveredFvInfoFunctional (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+ UINT8 *FeatureImplemented;
+
+ FeatureImplemented = GetFeatureImplemented ();
+
+ if ((FeatureImplemented[1] & TEST_POINT_BYTE1_MEMORY_DISCOVERED_FV_INFO_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
}
- Status = TestPointDumpSmramHob ();
+
+ DEBUG ((DEBUG_INFO, "======== TestPointMemoryDiscoveredFvInfoFunctional - Enter\n"));
+ Result = TRUE;
+ Status = TestPointCheckFvInfo ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
@@ -102,38 +224,108 @@ TestPointMemoryDiscovered (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
1,
- TEST_POINT_BYTE1_MEMORY_DISCOVERED
+ TEST_POINT_BYTE1_MEMORY_DISCOVERED_FV_INFO_FUNCTIONAL
);
}
- DEBUG ((DEBUG_INFO, "======== TestPointMemoryDiscovered - Exit\n"));
+ DEBUG ((DEBUG_INFO, "======== TestPointMemoryDiscoveredFvInfoFunctional - Exit\n"));
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
-TestPointEndOfPei (
+TestPointEndOfPeiSystemResourceFunctional (
VOID
)
{
EFI_STATUS Status;
BOOLEAN Result;
+ UINT8 *FeatureImplemented;
+
+ FeatureImplemented = GetFeatureImplemented ();
+
+ if ((FeatureImplemented[1] & TEST_POINT_BYTE1_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfPeiSystemResourceFunctional - Enter\n"));
+
+ TestPointDumpHob (FALSE);
- DEBUG ((DEBUG_INFO, "======== TestPointEndOfPei - Enter\n"));
Result = TRUE;
- Status = TestPointDumpMtrr (TRUE);
+ Status = TestPointCheckSmmInfoPei ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpHob (FALSE);
- if (EFI_ERROR(Status)) {
- Result = FALSE;
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 1,
+ TEST_POINT_BYTE1_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfPeiSystemResourceFunctional - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfPeiMtrrFunctional (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+ UINT8 *FeatureImplemented;
+
+ FeatureImplemented = GetFeatureImplemented ();
+
+ if ((FeatureImplemented[1] & TEST_POINT_BYTE1_END_OF_PEI_MTRR_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
}
- Status = TestPointDumpFvInfo ();
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfPeiMtrrFunctional - Enter\n"));
+ Result = TRUE;
+ Status = TestPointCheckMtrr (TRUE);
if (EFI_ERROR(Status)) {
Result = FALSE;
}
- Status = TestPointDumpSmramHob ();
+
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 1,
+ TEST_POINT_BYTE1_END_OF_PEI_MTRR_FUNCTIONAL
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfPeiMtrrFunctional - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfPeiPciBusMasterDisabled (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+ UINT8 *FeatureImplemented;
+
+ FeatureImplemented = GetFeatureImplemented ();
+
+ if ((FeatureImplemented[1] & TEST_POINT_BYTE1_END_OF_PEI_PCI_BUS_MASTER_DISABLED) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfPeiPciBusMasterDisabled - Enter\n"));
+ Result = TRUE;
+ Status = TestPointCheckPciBusMaster ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
@@ -143,25 +335,14 @@ TestPointEndOfPei (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
1,
- TEST_POINT_BYTE1_END_OF_PEI
+ TEST_POINT_BYTE1_END_OF_PEI_PCI_BUS_MASTER_DISABLED
);
}
- DEBUG ((DEBUG_INFO, "======== TestPointEndOfPei - Exit\n"));
+ DEBUG ((DEBUG_INFO, "======== TestPointEndOfPeiPciBusMasterDisabled - 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
**/
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.inf
index 24056ca69e..9ef9471a2e 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.inf
@@ -30,19 +30,24 @@
HobLib
PrintLib
PeiServicesLib
+ PeiServicesTablePointerLib
TestPointLib
+ PciSegmentLib
+ PciSegmentInfoLib
[Packages]
MinPlatformPkg/MinPlatformPkg.dec
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[Sources]
PeiTestPointCheckLib.c
- PeiDumpMtrr.c
- PeiDumpHob.c
- PeiDumpFvInfo.c
- PeiDumpSmramHob.c
+ PeiCheckMtrr.c
+ PeiCheckHob.c
+ PeiCheckFvInfo.c
+ PeiCheckSmmInfo.c
+ PeiCheckPci.c
[Pcd]
gMinPlatformModuleTokenSpaceGuid.PcdTestPointIbvPlatformFeature
@@ -51,8 +56,8 @@
gEfiHobMemoryAllocStackGuid
gEfiHobMemoryAllocBspStoreGuid
gEfiHobMemoryAllocModuleGuid
- gEfiSmmPeiSmramMemoryReserveGuid
[Ppis]
gEfiPeiFirmwareVolumeInfoPpiGuid
- gEfiPeiFirmwareVolumeInfo2PpiGuid \ No newline at end of file
+ gEfiPeiFirmwareVolumeInfo2PpiGuid
+ gPeiSmmAccessPpiGuid \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecDumpCpuInfo.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecCheckCpuInfo.c
index 9ec3044353..a57ca2c05e 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecDumpCpuInfo.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecCheckCpuInfo.c
@@ -33,7 +33,6 @@ TestPointDumpCpuInfo (
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
index 8d10a255e1..6df3c43bb3 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.c
@@ -13,28 +13,64 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Uefi.h>
#include <Library/TestPointCheckLib.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
+#define TEST_PATTERN 0x5A
+
VOID
TestPointDumpCpuInfo (
VOID
);
EFI_STATUS
+TestTempRam (
+ IN VOID *TempRamTestStart,
+ IN VOID *TempRamTestEnd
+ )
+{
+ UINTN Index;
+ BOOLEAN Result;
+
+ Result = TRUE;
+
+ DEBUG ((DEBUG_INFO, "TempRamTestStart - 0x%08x\n", TempRamTestStart));
+ DEBUG ((DEBUG_INFO, "TempRamTestEnd - 0x%08x\n", TempRamTestEnd));
+
+ SetMem (TempRamTestStart, (UINTN)TempRamTestEnd - (UINTN)TempRamTestStart, TEST_PATTERN);
+ for (Index = 0; Index < (UINTN)TempRamTestEnd - (UINTN)TempRamTestStart; Index++) {
+ if (*((UINT8 *)TempRamTestStart + Index) != TEST_PATTERN) {
+ Result = FALSE;
+ }
+ }
+ if (Result) {
+ DEBUG ((DEBUG_INFO, "TempRam Test PASS\n"));
+ return EFI_SUCCESS;
+ } else {
+ DEBUG ((DEBUG_INFO, "TempRam Test FAIL\n"));
+ return EFI_DEVICE_ERROR;
+ }
+}
+
+EFI_STATUS
EFIAPI
-TestPointTempMemoryInitDone (
+TestPointTempMemoryFunction (
IN VOID *TempRamStart,
IN VOID *TempRamEnd
)
{
- DEBUG ((DEBUG_INFO, "======== TestPointTempMemoryInitDone - Enter\n"));
+ UINTN StackMark;
+ DEBUG ((DEBUG_INFO, "======== TestPointTempMemoryFunction - 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"));
+ StackMark = 0;
+ TestTempRam (TempRamStart, (VOID *)((UINTN)&StackMark & ~0xFFF));
+
+ DEBUG ((DEBUG_INFO, "======== TestPointTempMemoryFunction - 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
index c7445d9222..f1cae85cb1 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf
@@ -24,6 +24,7 @@
[LibraryClasses]
BaseLib
DebugLib
+ BaseMemoryLib
[Packages]
MinPlatformPkg/MinPlatformPkg.dec
@@ -32,6 +33,6 @@
[Sources]
SecTestPointCheckLib.c
- SecDumpCpuInfo.c
+ SecCheckCpuInfo.c
[Pcd]
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckCommunicationBuffer.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckCommunicationBuffer.c
new file mode 100644
index 0000000000..7625c60e61
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckCommunicationBuffer.c
@@ -0,0 +1,103 @@
+/** @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>
+
+#define NEXT_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
+ ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) + (Size)))
+
+extern EFI_MEMORY_DESCRIPTOR *mUefiMemoryMap;
+extern UINTN mUefiMemoryMapSize;
+extern UINTN mUefiDescriptorSize;
+
+extern EFI_GCD_MEMORY_SPACE_DESCRIPTOR *mGcdMemoryMap;
+extern EFI_GCD_IO_SPACE_DESCRIPTOR *mGcdIoMap;
+extern UINTN mGcdMemoryMapNumberOfDescriptors;
+extern UINTN mGcdIoMapNumberOfDescriptors;
+
+EFI_STATUS
+TestPointCheckPageTable (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINTN Length,
+ IN BOOLEAN IsCode,
+ IN BOOLEAN IsOutsideSmram
+ );
+
+BOOLEAN
+IsUefiPageNotPresent (
+ IN EFI_MEMORY_DESCRIPTOR *MemoryMap
+ )
+{
+ switch (MemoryMap->Type) {
+ case EfiLoaderCode:
+ case EfiLoaderData:
+ case EfiBootServicesCode:
+ case EfiBootServicesData:
+ case EfiConventionalMemory:
+ case EfiUnusableMemory:
+ case EfiACPIReclaimMemory:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+EFI_STATUS
+TestPointCheckSmmCommunicationBuffer (
+ VOID
+ )
+{
+ EFI_STATUS ReturnStatus;
+ EFI_STATUS Status;
+ EFI_MEMORY_DESCRIPTOR *MemoryMap;
+ UINTN MemoryMapEntryCount;
+ UINTN Index;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmCommunicationBuffer - Enter\n"));
+
+ ReturnStatus = EFI_SUCCESS;
+ MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize;
+ MemoryMap = mUefiMemoryMap;
+ for (Index = 0; Index < MemoryMapEntryCount; Index++) {
+ if (IsUefiPageNotPresent(MemoryMap)) {
+ DEBUG ((DEBUG_INFO, "UEFI MemoryMap Checking 0x%lx - 0x%x\n", MemoryMap->PhysicalStart, EFI_PAGES_TO_SIZE(MemoryMap->NumberOfPages)));
+ Status = TestPointCheckPageTable (
+ MemoryMap->PhysicalStart,
+ EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages),
+ FALSE,
+ TRUE
+ );
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ }
+ }
+ MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, mUefiDescriptorSize);
+ }
+
+ if (EFI_ERROR (ReturnStatus)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER_ERROR_CODE \
+ TEST_POINT_SMM_READY_TO_BOOT \
+ TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER_ERROR_STRING
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmCommunicationBuffer - Exit\n"));
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpLoadedImage.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckLoadedImage.c
index 63b20edc6a..a9f8c6b939 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpLoadedImage.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckLoadedImage.c
@@ -31,7 +31,7 @@ DumpLoadedImage (
IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath
);
-EFI_STATUS
+VOID
TestPointDumpSmmLoadedImage (
VOID
)
@@ -106,6 +106,5 @@ Done:
DEBUG ((DEBUG_INFO, "==== TestPointDumpSmmLoadedImage - Exit\n"));
- // Check - TBD
- return EFI_SUCCESS;
+ return ;
}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckMemoryAttribute.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckMemoryAttribute.c
new file mode 100644
index 0000000000..a30edb0bdd
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckMemoryAttribute.c
@@ -0,0 +1,174 @@
+/** @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 <Library/MemoryAllocationLib.h>
+#include <Guid/MemoryAttributesTable.h>
+#include <Guid/PiSmmMemoryAttributesTable.h>
+#include <Protocol/LoadedImage.h>
+
+VOID
+TestPointDumpMemoryAttributesTable (
+ IN EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable
+ );
+
+EFI_STATUS
+TestPointCheckImageMemoryAttribute (
+ IN EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable,
+ IN EFI_PHYSICAL_ADDRESS ImageBase,
+ IN UINT64 ImageSize,
+ IN BOOLEAN IsFromSmm
+ );
+
+EFI_STATUS
+TestPointCheckSmmMemoryAttributesTable (
+ IN EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ UINTN Index;
+ UINTN HandleBufSize;
+ EFI_HANDLE *HandleBuf;
+ UINTN HandleCount;
+ EFI_STATUS ReturnStatus;
+
+ ReturnStatus = EFI_SUCCESS;
+ 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 = TestPointCheckImageMemoryAttribute (
+ MemoryAttributesTable,
+ (EFI_PHYSICAL_ADDRESS)(UINTN)LoadedImage->ImageBase,
+ LoadedImage->ImageSize,
+ TRUE
+ );
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ }
+ }
+
+Done:
+
+ if (HandleBuf != NULL) {
+ FreePool (HandleBuf);
+ }
+
+ return ReturnStatus;
+}
+
+/**
+ 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
+TestPointCheckSmmMemAttribute (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *MemoryAttributesTable;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmMemAttribute - Enter\n"));
+ Status = SmmGetSystemConfigurationTable (&gEdkiiPiSmmMemoryAttributesTableGuid, (VOID **)&MemoryAttributesTable);
+ if (!EFI_ERROR (Status)) {
+ TestPointDumpMemoryAttributesTable(MemoryAttributesTable);
+ Status = TestPointCheckSmmMemoryAttributesTable(MemoryAttributesTable);
+ }
+
+ if (EFI_ERROR (Status)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SMM_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_SMM_READY_TO_LOCK \
+ TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SMM_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL_ERROR_STRING
+ );
+ }
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmMemAttribute - Exit\n"));
+
+ return Status;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckPaging.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckPaging.c
new file mode 100644
index 0000000000..d41e8f860f
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckPaging.c
@@ -0,0 +1,370 @@
+/** @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 <Library/SmmServicesTableLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Guid/MemoryAttributesTable.h>
+#include <Register/SmramSaveStateMap.h>
+#include <Register/StmApi.h>
+#include <Register/Msr.h>
+
+#define NEXT_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
+ ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) + (Size)))
+
+///
+/// Page Table Entry
+///
+#define IA32_PG_P BIT0
+#define IA32_PG_RW BIT1
+#define IA32_PG_U BIT2
+#define IA32_PG_WT BIT3
+#define IA32_PG_CD BIT4
+#define IA32_PG_A BIT5
+#define IA32_PG_D BIT6
+#define IA32_PG_PS BIT7
+#define IA32_PG_PAT_2M BIT12
+#define IA32_PG_PAT_4K IA32_PG_PS
+#define IA32_PG_PMNT BIT62
+#define IA32_PG_NX BIT63
+
+#define PAGING_4K_MASK 0xFFF
+#define PAGING_2M_MASK 0x1FFFFF
+#define PAGING_1G_MASK 0x3FFFFFFF
+
+#define PAGING_PAE_INDEX_MASK 0x1FF
+
+#define PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull
+#define PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull
+#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull
+
+typedef enum {
+ PageNone,
+ Page4K,
+ Page2M,
+ Page1G,
+} PAGE_ATTRIBUTE;
+
+typedef struct {
+ PAGE_ATTRIBUTE Attribute;
+ UINT64 Length;
+ UINT64 AddressMask;
+} PAGE_ATTRIBUTE_TABLE;
+
+PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] = {
+ {Page4K, SIZE_4KB, PAGING_4K_ADDRESS_MASK_64},
+ {Page2M, SIZE_2MB, PAGING_2M_ADDRESS_MASK_64},
+ {Page1G, SIZE_1GB, PAGING_1G_ADDRESS_MASK_64},
+};
+
+EFI_STATUS
+EFIAPI
+SmmGetSystemConfigurationTable (
+ IN EFI_GUID *TableGuid,
+ OUT VOID **Table
+ );
+
+/**
+ Return page table base.
+
+ @return page table base.
+**/
+UINTN
+GetPageTableBase (
+ VOID
+ )
+{
+ return (AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64);
+}
+
+/**
+ Return length according to page attributes.
+
+ @param[in] PageAttributes The page attribute of the page entry.
+
+ @return The length of page entry.
+**/
+UINTN
+PageAttributeToLength (
+ IN PAGE_ATTRIBUTE PageAttribute
+ )
+{
+ UINTN Index;
+ for (Index = 0; Index < sizeof(mPageAttributeTable)/sizeof(mPageAttributeTable[0]); Index++) {
+ if (PageAttribute == mPageAttributeTable[Index].Attribute) {
+ return (UINTN)mPageAttributeTable[Index].Length;
+ }
+ }
+ return 0;
+}
+
+/**
+ Return page table entry to match the address.
+
+ @param[in] Address The address to be checked.
+ @param[out] PageAttributes The page attribute of the page entry.
+
+ @return The page entry.
+**/
+VOID *
+GetPageTableEntry (
+ IN PHYSICAL_ADDRESS Address,
+ OUT PAGE_ATTRIBUTE *PageAttribute
+ )
+{
+ UINTN Index1;
+ UINTN Index2;
+ UINTN Index3;
+ UINTN Index4;
+ UINT64 *L1PageTable;
+ UINT64 *L2PageTable;
+ UINT64 *L3PageTable;
+ UINT64 *L4PageTable;
+
+ Index4 = ((UINTN)RShiftU64 (Address, 39)) & PAGING_PAE_INDEX_MASK;
+ Index3 = ((UINTN)Address >> 30) & PAGING_PAE_INDEX_MASK;
+ Index2 = ((UINTN)Address >> 21) & PAGING_PAE_INDEX_MASK;
+ Index1 = ((UINTN)Address >> 12) & PAGING_PAE_INDEX_MASK;
+
+ if (sizeof(UINTN) == sizeof(UINT64)) {
+ L4PageTable = (UINT64 *)GetPageTableBase ();
+ if (L4PageTable[Index4] == 0) {
+ *PageAttribute = Page1G;
+ return NULL;
+ }
+
+ L3PageTable = (UINT64 *)(UINTN)(L4PageTable[Index4] & PAGING_4K_ADDRESS_MASK_64);
+ } else {
+ L3PageTable = (UINT64 *)GetPageTableBase ();
+ }
+ if (L3PageTable[Index3] == 0) {
+ *PageAttribute = Page1G;
+ return NULL;
+ }
+ if ((L3PageTable[Index3] & IA32_PG_PS) != 0) {
+ // 1G
+ *PageAttribute = Page1G;
+ return &L3PageTable[Index3];
+ }
+
+ L2PageTable = (UINT64 *)(UINTN)(L3PageTable[Index3] & PAGING_4K_ADDRESS_MASK_64);
+ if (L2PageTable[Index2] == 0) {
+ *PageAttribute = Page2M;
+ return NULL;
+ }
+ if ((L2PageTable[Index2] & IA32_PG_PS) != 0) {
+ // 2M
+ *PageAttribute = Page2M;
+ return &L2PageTable[Index2];
+ }
+
+ // 4k
+ L1PageTable = (UINT64 *)(UINTN)(L2PageTable[Index2] & PAGING_4K_ADDRESS_MASK_64);
+ if ((L1PageTable[Index1] == 0) && (Address != 0)) {
+ *PageAttribute = Page4K;
+ return NULL;
+ }
+ *PageAttribute = Page4K;
+ return &L1PageTable[Index1];
+}
+
+typedef struct {
+ volatile BOOLEAN Valid;
+ volatile UINT64 SmBase;
+} SMBASE_SHARED_BUFFER;
+
+VOID
+EFIAPI
+GetSmBaseOnCurrentProcessor (
+ IN OUT VOID *Buffer
+ )
+{
+ SMBASE_SHARED_BUFFER *SmBaseBuffer;
+
+ SmBaseBuffer = Buffer;
+ SmBaseBuffer->SmBase = AsmReadMsr64 (MSR_IA32_SMBASE);
+ SmBaseBuffer->Valid = TRUE;
+}
+
+BOOLEAN
+IsSmmSaveState (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress
+ )
+{
+ volatile SMBASE_SHARED_BUFFER SmBaseBuffer;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN TileCodeSize;
+ UINTN TileDataSize;
+ UINTN TileSize;
+
+ TileCodeSize = SIZE_4KB; // BUGBUG: Assume 4KB
+ TileCodeSize = ALIGN_VALUE(TileCodeSize, SIZE_4KB);
+ TileDataSize = (SMRAM_SAVE_STATE_MAP_OFFSET - TXT_SMM_PSD_OFFSET) + sizeof (SMRAM_SAVE_STATE_MAP);
+ TileDataSize = ALIGN_VALUE(TileDataSize, SIZE_4KB);
+ TileSize = TileDataSize + TileCodeSize - 1;
+ TileSize = 2 * GetPowerOfTwo32 ((UINT32)TileSize);
+
+ for (Index = 0; Index < gSmst->NumberOfCpus; Index++) {
+ ZeroMem ((VOID *)&SmBaseBuffer, sizeof(SmBaseBuffer));
+ if (Index == gSmst->CurrentlyExecutingCpu) {
+ GetSmBaseOnCurrentProcessor ((VOID *)&SmBaseBuffer);
+ DEBUG ((DEBUG_INFO, "SmbaseBsp(%d) - 0x%x\n", Index, SmBaseBuffer.SmBase));
+ } else {
+ Status = gSmst->SmmStartupThisAp (GetSmBaseOnCurrentProcessor, Index, (VOID *)&SmBaseBuffer);
+ ASSERT_EFI_ERROR (Status);
+ while (!SmBaseBuffer.Valid) {
+ CpuPause ();
+ }
+ DEBUG ((DEBUG_INFO, "SmbaseAp(%d) - 0x%x\n", Index, SmBaseBuffer.SmBase));
+ }
+ if (Index == gSmst->NumberOfCpus - 1) {
+ TileSize = SIZE_32KB;
+ }
+ if ((BaseAddress >= SmBaseBuffer.SmBase + SMM_HANDLER_OFFSET + TileCodeSize) &&
+ (BaseAddress < SmBaseBuffer.SmBase + SMM_HANDLER_OFFSET + TileSize)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+EFI_STATUS
+TestPointCheckPageTable (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINTN Length,
+ IN BOOLEAN IsCode,
+ IN BOOLEAN IsOutsideSmram
+ )
+{
+ UINT64 *PageEntry;
+ PAGE_ATTRIBUTE PageAttribute;
+ UINTN PageEntryLength;
+ EFI_PHYSICAL_ADDRESS BaseAddressEnd;
+
+ ASSERT ((BaseAddress & (SIZE_4KB - 1)) == 0);
+ ASSERT ((Length & (SIZE_4KB - 1)) == 0);
+
+ BaseAddressEnd = BaseAddress + Length;
+
+ //
+ // Below logic is to check 2M/4K page to make sure we donot waist memory.
+ //
+ while (BaseAddress < BaseAddressEnd) {
+ PageEntry = GetPageTableEntry (BaseAddress, &PageAttribute);
+ ASSERT (PageAttribute != PageNone);
+
+ if (IsOutsideSmram) {
+ if ((PageEntry != NULL) && ((*PageEntry & IA32_PG_P) != 0)) {
+ DEBUG ((DEBUG_ERROR, "OutsideSmram present - 0x%x\n", BaseAddress));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ if (IsCode) {
+ if ((PageEntry == NULL) || ((*PageEntry & IA32_PG_P) == 0)) {
+ DEBUG ((DEBUG_ERROR, "Code Page not exist - 0x%x\n", BaseAddress));
+ return EFI_INVALID_PARAMETER;
+ } else if ((*PageEntry & IA32_PG_RW) != 0) {
+ //
+ // Check if it is SMM SaveState
+ //
+ if (!IsSmmSaveState (BaseAddress)) {
+ DEBUG ((DEBUG_ERROR, "Code Page read write - 0x%x\n", BaseAddress));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ } else {
+ if ((PageEntry == NULL) || ((*PageEntry & IA32_PG_P) == 0)) {
+ // Pass
+ } else if ((*PageEntry & IA32_PG_NX) == 0) {
+ DEBUG ((DEBUG_ERROR, "Data Page executable - 0x%x\n", BaseAddress));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ PageEntryLength = PageAttributeToLength (PageAttribute);
+ PageEntryLength = (UINTN)((BaseAddress & ~(PageEntryLength - 1)) + PageEntryLength - BaseAddress);
+
+ //
+ // move to next
+ //
+ BaseAddress += PageEntryLength;
+ Length -= PageEntryLength;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+EFI_STATUS
+TestPointCheckPagingWithMemoryAttributesTable (
+ IN EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable
+ )
+{
+ UINTN Index;
+ EFI_MEMORY_DESCRIPTOR *Entry;
+ EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
+
+ ReturnStatus = EFI_SUCCESS;
+ Entry = (EFI_MEMORY_DESCRIPTOR *)(MemoryAttributesTable + 1);
+ for (Index = 0; Index < MemoryAttributesTable->NumberOfEntries; Index++) {
+ DEBUG ((DEBUG_INFO, "SmmMemoryAttribute Checking 0x%lx - 0x%x\n", Entry->PhysicalStart, EFI_PAGES_TO_SIZE((UINTN)Entry->NumberOfPages)));
+ Status = TestPointCheckPageTable (
+ Entry->PhysicalStart,
+ EFI_PAGES_TO_SIZE((UINTN)Entry->NumberOfPages),
+ ((Entry->Attribute & EFI_MEMORY_RO) == 0) ? FALSE : TRUE,
+ FALSE
+ );
+ if (EFI_ERROR(Status)) {
+ ReturnStatus = Status;
+ }
+ Entry = NEXT_MEMORY_DESCRIPTOR (Entry, MemoryAttributesTable->DescriptorSize);
+ }
+
+ return ReturnStatus;
+}
+
+EFI_STATUS
+TestPointCheckSmmPaging (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *MemoryAttributesTable;
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmPaging - Enter\n"));
+
+ Status = SmmGetSystemConfigurationTable (&gEdkiiPiSmmMemoryAttributesTableGuid, (VOID **)&MemoryAttributesTable);
+ if (!EFI_ERROR (Status)) {
+ Status = TestPointCheckPagingWithMemoryAttributesTable(MemoryAttributesTable);
+ }
+
+ if (EFI_ERROR (Status)) {
+ TestPointLibAppendErrorString (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ TEST_POINT_BYTE5_SMM_READY_TO_BOOT_SMM_PAGE_LEVEL_PROTECTION_ERROR_CODE \
+ TEST_POINT_SMM_READY_TO_BOOT \
+ TEST_POINT_BYTE5_SMM_READY_TO_BOOT_SMM_PAGE_LEVEL_PROTECTION_ERROR_STRING
+ );
+ }
+
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmPaging - Exit\n"));
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpSmrr.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckSmrr.c
index f10db06574..5205472533 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpSmrr.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckSmrr.c
@@ -37,12 +37,13 @@ UINT32 mSmrrPhysBaseMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE;
UINT32 mSmrrPhysMaskMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK;
EFI_STATUS
-TestPointDumpSmrr (
+TestPointCheckSmrr (
VOID
)
{
UINT64 SmrrBase;
UINT64 SmrrMask;
+ UINT64 Length;
UINT32 RegEax;
UINT32 RegEdx;
@@ -50,7 +51,7 @@ TestPointDumpSmrr (
UINTN ModelId;
BOOLEAN Result;
- DEBUG ((DEBUG_INFO, "==== TestPointDumpSmrr - Enter\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmrr - Enter\n"));
//
// Retrieve CPU Family and Model
@@ -107,16 +108,29 @@ TestPointDumpSmrr (
DEBUG ((DEBUG_INFO, "SMRR : Base=%016lx Make=%016lx\n", SmrrBase, SmrrMask));
}
- DEBUG ((DEBUG_INFO, "==== TestPointDumpSmrr - Exit\n"));
+ DEBUG ((DEBUG_INFO, "==== TestPointCheckSmrr - Exit\n"));
- // Check - TBD
Result = TRUE;
+ if (!mSmrrSupported) {
+ Result = FALSE;
+ DEBUG ((DEBUG_ERROR, "Smrr is not supported\n"));
+ } else {
+ Length = SmrrMask & ~0xFFFull;
+ Length = ~Length + 1;
+ Length = Length & 0xFFFFF000;
+ if (Length != GetPowerOfTwo64 (Length)) {
+ Result = FALSE;
+ DEBUG ((DEBUG_ERROR, "Smrr is not aligned\n"));
+ }
+ }
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
+ TEST_POINT_BYTE5_SMM_END_OF_DXE_SMRR_FUNCTIONAL_ERROR_CODE \
+ TEST_POINT_SMM_END_OF_DXE \
+ TEST_POINT_BYTE5_SMM_END_OF_DXE_SMRR_FUNCTIONAL_ERROR_STRING
);
return EFI_INVALID_PARAMETER;
}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpMemAttribute.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpMemAttribute.c
deleted file mode 100644
index bf7008c160..0000000000
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmDumpMemAttribute.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/** @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/SmmTestPointCheckLib.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c
index e99fefa386..cbc21307ce 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c
@@ -18,7 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/BaseMemoryLib.h>
EFI_STATUS
-TestPointDumpSmrr (
+TestPointCheckSmrr (
VOID
);
@@ -28,23 +28,73 @@ TestPointDumpSmmLoadedImage (
);
EFI_STATUS
-TestPointDumpSmmMemAttribute (
+TestPointCheckSmmMemAttribute (
VOID
);
EFI_STATUS
+TestPointCheckSmmPaging (
+ VOID
+ );
+
+EFI_STATUS
+TestPointCheckSmmCommunicationBuffer (
+ VOID
+ );
+
+VOID
+TestPointDumpGcd (
+ OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **GcdMemoryMap, OPTIONAL
+ OUT UINTN *GcdMemoryMapNumberOfDescriptors, OPTIONAL
+ OUT EFI_GCD_IO_SPACE_DESCRIPTOR **GcdIoMap, OPTIONAL
+ OUT UINTN *GcdIoMapNumberOfDescriptors OPTIONAL
+ );
+
+VOID
+TestPointDumpUefiMemoryMap (
+ OUT EFI_MEMORY_DESCRIPTOR **UefiMemoryMap, OPTIONAL
+ OUT UINTN *UefiMemoryMapSize, OPTIONAL
+ OUT UINTN *UefiDescriptorSize OPTIONAL
+ );
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_MEMORY_DESCRIPTOR *mUefiMemoryMap;
+GLOBAL_REMOVE_IF_UNREFERENCED UINTN mUefiMemoryMapSize;
+GLOBAL_REMOVE_IF_UNREFERENCED UINTN mUefiDescriptorSize;
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GCD_MEMORY_SPACE_DESCRIPTOR *mGcdMemoryMap;
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GCD_IO_SPACE_DESCRIPTOR *mGcdIoMap;
+GLOBAL_REMOVE_IF_UNREFERENCED UINTN mGcdMemoryMapNumberOfDescriptors;
+GLOBAL_REMOVE_IF_UNREFERENCED UINTN mGcdIoMapNumberOfDescriptors;
+
+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_SMM},
+ TEST_POINT_FEATURE_SIZE,
+ {0}, // FeaturesImplemented
+ {0}, // FeaturesVerified
+ 0,
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED UINT8 mFeatureImplemented[TEST_POINT_FEATURE_SIZE];
+
+EFI_STATUS
EFIAPI
-TestPointSmmEndOfDxe (
+TestPointSmmEndOfDxeSmrrFunctional (
VOID
)
{
EFI_STATUS Status;
BOOLEAN Result;
-
- DEBUG ((DEBUG_INFO, "======== TestPointSmmEndOfDxe - Enter\n"));
+ if ((mFeatureImplemented[5] & TEST_POINT_BYTE5_SMM_END_OF_DXE_SMRR_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmEndOfDxeSmrrFunctional - Enter\n"));
+
Result = TRUE;
- Status = TestPointDumpSmmLoadedImage ();
+ Status = TestPointCheckSmrr ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
@@ -53,8 +103,8 @@ TestPointSmmEndOfDxe (
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
- 3,
- TEST_POINT_BYTE3_SMM_END_OF_DXE
+ 5,
+ TEST_POINT_BYTE5_SMM_END_OF_DXE_SMRR_FUNCTIONAL
);
}
@@ -64,21 +114,22 @@ TestPointSmmEndOfDxe (
EFI_STATUS
EFIAPI
-TestPointSmmReadyToLock (
+TestPointSmmReadyToLockSmmMemoryAttributeTableFunctional (
VOID
)
{
EFI_STATUS Status;
BOOLEAN Result;
+
+ if ((mFeatureImplemented[5] & TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SMM_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL) == 0) {
+ return EFI_SUCCESS;
+ }
DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToLock - Enter\n"));
-
+
Result = TRUE;
- Status = TestPointDumpSmrr ();
- if (EFI_ERROR(Status)) {
- Result = FALSE;
- }
- Status = TestPointDumpSmmMemAttribute ();
+ TestPointDumpSmmLoadedImage ();
+ Status = TestPointCheckSmmMemAttribute ();
if (EFI_ERROR(Status)) {
Result = FALSE;
}
@@ -87,8 +138,8 @@ TestPointSmmReadyToLock (
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
- 3,
- TEST_POINT_BYTE3_SMM_READY_TO_LOCK
+ 5,
+ TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SMM_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL
);
}
@@ -98,13 +149,77 @@ TestPointSmmReadyToLock (
EFI_STATUS
EFIAPI
-TestPointSmmReadyToBoot (
+TestPointSmmReadyToLockSecureSmmCommunicationBuffer (
VOID
)
{
- DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToBoot - Enter\n"));
+
+ if ((mFeatureImplemented[5] & TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToLockSecureSmmCommunicationBuffer - Enter\n"));
+
+ //
+ // Collect information here, because it is last chance to access outside SMRAM.
+ //
+ TestPointDumpUefiMemoryMap (&mUefiMemoryMap, &mUefiMemoryMapSize, &mUefiDescriptorSize);
+ TestPointDumpGcd (&mGcdMemoryMap, &mGcdMemoryMapNumberOfDescriptors, &mGcdIoMap, &mGcdIoMapNumberOfDescriptors);
+ //
+ // Defer the validation to TestPointSmmReadyToBootSecureSmmCommunicationBuffer, because page table setup later.
+ //
- DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToBoot - Exit\n"));
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToLockSecureSmmCommunicationBuffer - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointSmmReadyToBootSmmPageProtection (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+
+ if ((mFeatureImplemented[5] & TEST_POINT_BYTE5_SMM_READY_TO_BOOT_SMM_PAGE_LEVEL_PROTECTION) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToBootSmmPageProtection - Enter\n"));
+
+ Result = TRUE;
+
+ Status = TestPointCheckSmmPaging ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 5,
+ TEST_POINT_BYTE5_SMM_READY_TO_BOOT_SMM_PAGE_LEVEL_PROTECTION
+ );
+ }
+
+ if (mUefiMemoryMap != NULL) {
+ Result = TRUE;
+
+ Status = TestPointCheckSmmCommunicationBuffer ();
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 5,
+ TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER
+ );
+ }
+ }
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToBootSmmPageProtection - Exit\n"));
return EFI_SUCCESS;
}
@@ -120,19 +235,6 @@ TestPointSmmExitBootServices (
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
**/
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf
index bd3bce527e..ca24387a34 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf
@@ -39,12 +39,15 @@
[Sources]
SmmTestPointCheckLib.c
- SmmDumpMemAttribute.c
- DxeDumpMemAttribute.c
- DxeDumpMemMap.c
- SmmDumpLoadedImage.c
- DxeDumpLoadedImage.c
- SmmDumpSmrr.c
+ SmmCheckMemoryAttribute.c
+ SmmCheckLoadedImage.c
+ SmmCheckSmrr.c
+ SmmCheckPaging.c
+ SmmCheckCommunicationBuffer.c
+ DxeCheckMemoryAttribute.c
+ DxeCheckMemoryMap.c
+ DxeCheckLoadedImage.c
+ DxeCheckGcd.c
[Pcd]
gMinPlatformModuleTokenSpaceGuid.PcdTestPointIbvPlatformFeature
@@ -57,3 +60,4 @@
gEfiLoadedImageProtocolGuid
gEfiLoadedImageDevicePathProtocolGuid
gEfiDevicePathProtocolGuid
+ gEfiRuntimeArchProtocolGuid
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c
index a4d352fdec..d3f170554b 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c
@@ -16,7 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
EFI_STATUS
EFIAPI
-TestPointTempMemoryInitDone (
+TestPointTempMemoryFunction (
IN VOID *TempRamStart,
IN VOID *TempRamEnd
)
@@ -35,7 +35,7 @@ TestPointDebugInitDone (
EFI_STATUS
EFIAPI
-TestPointMemoryDiscovered (
+TestPointMemoryDiscoveredMtrrFunctional (
VOID
)
{
@@ -44,7 +44,7 @@ TestPointMemoryDiscovered (
EFI_STATUS
EFIAPI
-TestPointEndOfPei (
+TestPointMemoryDiscoveredMemoryResourceFunctional (
VOID
)
{
@@ -53,7 +53,7 @@ TestPointEndOfPei (
EFI_STATUS
EFIAPI
-TestPointPciEnumerationDone (
+TestPointMemoryDiscoveredFvInfoFunctional (
VOID
)
{
@@ -62,7 +62,7 @@ TestPointPciEnumerationDone (
EFI_STATUS
EFIAPI
-TestPointEndOfDxe (
+TestPointEndOfPeiSystemResourceFunctional (
VOID
)
{
@@ -71,7 +71,7 @@ TestPointEndOfDxe (
EFI_STATUS
EFIAPI
-TestPointDxeSmmReadyToLock (
+TestPointEndOfPeiMtrrFunctional (
VOID
)
{
@@ -80,7 +80,169 @@ TestPointDxeSmmReadyToLock (
EFI_STATUS
EFIAPI
-TestPointReadyToBoot (
+TestPointEndOfPeiPciBusMasterDisabled (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointPciEnumerationDonePciBusMasterDisabled (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointPciEnumerationDonePciResourceAllocated (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfDxeNoThirdPartyPciOptionRom (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointEndOfDxeDmarTableFuntional (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointDxeSmmReadyToLockSmramAligned (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointDxeSmmReadyToLockWsmtTableFuntional (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootSmiHandlerInstrument (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootAcpiTableFuntional (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootMemoryTypeInformationFunctional (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootUefiMemoryAttributeTableFunctional (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootUefiBootVariableFunctional (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootUefiConsoleVariableFunctional (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootHstiTableFunctional (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootEsrtTableFunctional (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootUefiSecureBootEnabled (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootPiSignedFvBootEnabled (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootTcgTrustedBootEnabled (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointReadyToBootTcgMorEnabled (
VOID
)
{
@@ -98,7 +260,16 @@ TestPointExitBootServices (
EFI_STATUS
EFIAPI
-TestPointSmmEndOfDxe (
+TestPointSmmEndOfDxeSmrrFunctional (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+TestPointSmmReadyToLockSmmMemoryAttributeTableFunctional (
VOID
)
{
@@ -107,7 +278,7 @@ TestPointSmmEndOfDxe (
EFI_STATUS
EFIAPI
-TestPointSmmReadyToLock (
+TestPointSmmReadyToLockSecureSmmCommunicationBuffer (
VOID
)
{
@@ -116,7 +287,7 @@ TestPointSmmReadyToLock (
EFI_STATUS
EFIAPI
-TestPointSmmReadyToBoot (
+TestPointSmmReadyToBootSmmPageProtection (
VOID
)
{
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.c
index 40474cd4f2..45b5b33bf7 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/DxeTestPoint.c
@@ -174,8 +174,8 @@ InternalTestPointIsValidTable (
DEBUG ((EFI_D_ERROR, "TestPointSize < sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)\n"));
return FALSE;
}
- if (((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < TestPoint->FeaturesSize) {
- DEBUG ((EFI_D_ERROR, "((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < FeaturesSize\n"));
+ if (((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / TEST_POINT_FEATURES_ITEM_NUMBER) < TestPoint->FeaturesSize) {
+ DEBUG ((EFI_D_ERROR, "((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / TEST_POINT_FEATURES_ITEM_NUMBER) < FeaturesSize\n"));
return FALSE;
}
@@ -210,8 +210,8 @@ InternalTestPointIsValidTable (
return FALSE;
}
- ErrorStringSize = TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3;
- ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3);
+ ErrorStringSize = TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * TEST_POINT_FEATURES_ITEM_NUMBER;
+ ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * TEST_POINT_FEATURES_ITEM_NUMBER);
//
// basic check for ErrorString
@@ -254,9 +254,6 @@ InternalTestPointIsValidTable (
One system should have only one PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE.
- If the Role is NOT PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE,
- FeaturesRequired field will be ignored.
-
@param TestPoint TestPoint data
@param TestPointSize TestPoint size
@@ -278,10 +275,11 @@ TestPointLibSetTable (
EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
UINT32 Role;
CHAR16 *ImplementationID;
- UINT32 FeaturesSize;
- UINT8 *FeaturesRequired;
+
+ DEBUG ((EFI_D_ERROR, "TestPointLibSetTable\n"));
if (!InternalTestPointIsValidTable (TestPoint, TestPointSize)) {
+ DEBUG ((EFI_D_ERROR, "InternalTestPointIsValidTable\n"));
return EFI_VOLUME_CORRUPTED;
}
@@ -289,6 +287,7 @@ TestPointLibSetTable (
ImplementationID = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->ImplementationID;
Aip = InternalTestPointFindAip (Role, ImplementationID, NULL, NULL);
if (Aip != NULL) {
+ DEBUG ((EFI_D_ERROR, "Aip (0x%x, %S) is found\n", Role, ImplementationID));
return EFI_ALREADY_STARTED;
}
@@ -301,11 +300,6 @@ TestPointLibSetTable (
FreePool (TestPointAip);
return EFI_OUT_OF_RESOURCES;
}
- if (Role != PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE) {
- FeaturesRequired = (UINT8 *)TestPointAip->TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT);
- FeaturesSize = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->FeaturesSize;
- ZeroMem (FeaturesRequired, FeaturesSize);
- }
TestPointAip->Signature = TEST_POINT_AIP_PRIVATE_SIGNATURE;
CopyMem (&TestPointAip->Aip, &mAdapterInformationProtocol, sizeof(EFI_ADAPTER_INFORMATION_PROTOCOL));
@@ -402,7 +396,7 @@ InternalTestPointRecordFeaturesVerified (
return EFI_UNSUPPORTED;
}
- FeaturesVerified = (UINT8 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 2);
+ FeaturesVerified = (UINT8 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 1);
if (Set) {
FeaturesVerified[ByteIndex] = (UINT8)(FeaturesVerified[ByteIndex] | (Bit));
@@ -443,6 +437,7 @@ TestPointLibSetFeaturesVerified (
IN UINT8 BitMask
)
{
+ DEBUG ((DEBUG_INFO, "TestPointLibSetFeaturesVerified - Index:0x%x Mask:0x%02x\n", ByteIndex, BitMask));
return InternalTestPointRecordFeaturesVerified (
Role,
ImplementationID,
@@ -476,6 +471,7 @@ TestPointLibClearFeaturesVerified (
IN UINT8 BitMask
)
{
+ DEBUG ((DEBUG_INFO, "TestPointLibClearFeaturesVerified - Index:0x%x Mask:0x%02x\n", ByteIndex, BitMask));
return InternalTestPointRecordFeaturesVerified (
Role,
ImplementationID,
@@ -526,7 +522,7 @@ InternalTestPointRecordErrorString (
if (Append) {
Offset = TestPointSize - sizeof(CHAR16);
} else {
- Offset = sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 3;
+ Offset = sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * TEST_POINT_FEATURES_ITEM_NUMBER;
}
StringSize = StrSize (ErrorString);
@@ -570,7 +566,7 @@ TestPointLibAppendErrorString (
IN CHAR16 *ErrorString
)
{
- DEBUG ((DEBUG_ERROR, "TestPointLibAppendErrorString - (0x%x) %s\n", Role, ErrorString));
+ DEBUG ((DEBUG_INFO, "TestPointLibAppendErrorString - (0x%x) %s\n", Role, ErrorString));
return InternalTestPointRecordErrorString (
Role,
ImplementationID,
@@ -601,7 +597,7 @@ TestPointLibSetErrorString (
IN CHAR16 *ErrorString
)
{
- DEBUG ((DEBUG_ERROR, "TestPointLibSetErrorString - %s\n", ErrorString));
+ DEBUG ((DEBUG_INFO, "TestPointLibSetErrorString - %s\n", ErrorString));
return InternalTestPointRecordErrorString (
Role,
ImplementationID,
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.c
index f648e589b7..fac07c52f5 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/PeiTestPoint.c
@@ -24,9 +24,9 @@ InternalGetTestPointInfoSize (
UINTN ErrorStringMaxSize;
CHAR16 ErrorChar;
- ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + 3 * TestPoint->FeaturesSize);
+ ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TEST_POINT_FEATURES_ITEM_NUMBER * TestPoint->FeaturesSize);
- ErrorStringMaxSize = MaxSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3;
+ ErrorStringMaxSize = MaxSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * TEST_POINT_FEATURES_ITEM_NUMBER;
//
// ErrorString might not be CHAR16 aligned.
//
@@ -36,7 +36,7 @@ InternalGetTestPointInfoSize (
CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
}
- return sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + 3 * TestPoint->FeaturesSize + (ErrorStringLength + 1) * sizeof(CHAR16);
+ return sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TEST_POINT_FEATURES_ITEM_NUMBER * TestPoint->FeaturesSize + (ErrorStringLength + 1) * sizeof(CHAR16);
}
/**
@@ -135,8 +135,8 @@ InternalTestPointIsValidTable (
DEBUG ((EFI_D_ERROR, "TestPointSize < sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)\n"));
return FALSE;
}
- if (((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < TestPoint->FeaturesSize) {
- DEBUG ((EFI_D_ERROR, "((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < FeaturesSize\n"));
+ if (((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / TEST_POINT_FEATURES_ITEM_NUMBER) < TestPoint->FeaturesSize) {
+ DEBUG ((EFI_D_ERROR, "((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / TEST_POINT_FEATURES_ITEM_NUMBER) < FeaturesSize\n"));
return FALSE;
}
@@ -171,8 +171,8 @@ InternalTestPointIsValidTable (
return FALSE;
}
- ErrorStringSize = TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3;
- ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3);
+ ErrorStringSize = TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * TEST_POINT_FEATURES_ITEM_NUMBER;
+ ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * TEST_POINT_FEATURES_ITEM_NUMBER);
//
// basic check for ErrorString
@@ -215,9 +215,6 @@ InternalTestPointIsValidTable (
One system should have only one PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE.
- If the Role is NOT PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE,
- FeaturesRequired field will be ignored.
-
@param TestPoint TestPoint data
@param TestPointSize TestPoint size
@@ -237,10 +234,11 @@ TestPointLibSetTable (
EFI_STATUS Status;
UINT32 Role;
CHAR16 *ImplementationID;
- UINT32 FeaturesSize;
- UINT8 *FeaturesRequired;
+
+ DEBUG ((EFI_D_ERROR, "TestPointLibSetTable\n"));
if (!InternalTestPointIsValidTable (TestPoint, TestPointSize)) {
+ DEBUG ((EFI_D_ERROR, "InternalTestPointIsValidTable\n"));
return EFI_VOLUME_CORRUPTED;
}
@@ -248,6 +246,7 @@ TestPointLibSetTable (
ImplementationID = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->ImplementationID;
Status = InternalTestPointFindAip (Role, ImplementationID, NULL, NULL, NULL);
if (!EFI_ERROR(Status)) {
+ DEBUG ((EFI_D_ERROR, "Aip (0x%x, %S) is found\n", Role, ImplementationID));
return EFI_ALREADY_STARTED;
}
@@ -255,11 +254,6 @@ TestPointLibSetTable (
if (NewTestPoint == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- if (Role != PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE) {
- FeaturesRequired = (UINT8 *)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT);
- FeaturesSize = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->FeaturesSize;
- ZeroMem (FeaturesRequired, FeaturesSize);
- }
CopyMem (NewTestPoint, TestPoint, TestPointSize);
@@ -335,7 +329,7 @@ InternalTestPointRecordFeaturesVerified (
return EFI_UNSUPPORTED;
}
- FeaturesVerified = (UINT8 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 2);
+ FeaturesVerified = (UINT8 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 1);
if (Set) {
FeaturesVerified[ByteIndex] = (UINT8)(FeaturesVerified[ByteIndex] | (Bit));
@@ -370,6 +364,7 @@ TestPointLibSetFeaturesVerified (
IN UINT8 BitMask
)
{
+ DEBUG ((DEBUG_INFO, "TestPointLibSetFeaturesVerified - Index:0x%x Mask:0x%02x\n", ByteIndex, BitMask));
return InternalTestPointRecordFeaturesVerified (
Role,
ImplementationID,
@@ -403,6 +398,7 @@ TestPointLibClearFeaturesVerified (
IN UINT8 BitMask
)
{
+ DEBUG ((DEBUG_INFO, "TestPointLibClearFeaturesVerified - Index:0x%x Mask:0x%02x\n", ByteIndex, BitMask));
return InternalTestPointRecordFeaturesVerified (
Role,
ImplementationID,
@@ -454,7 +450,7 @@ InternalTestPointRecordErrorString (
if (Append) {
Offset = TestPointSize - sizeof(CHAR16);
} else {
- Offset = sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 3;
+ Offset = sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * TEST_POINT_FEATURES_ITEM_NUMBER;
}
StringSize = StrSize (ErrorString);
@@ -500,7 +496,7 @@ TestPointLibAppendErrorString (
IN CHAR16 *ErrorString
)
{
- DEBUG ((DEBUG_ERROR, "TestPointLibAppendErrorString - (0x%x) %s\n", Role, ErrorString));
+ DEBUG ((DEBUG_INFO, "TestPointLibAppendErrorString - (0x%x) %s\n", Role, ErrorString));
return InternalTestPointRecordErrorString (
Role,
ImplementationID,
@@ -531,7 +527,7 @@ TestPointLibSetErrorString (
IN CHAR16 *ErrorString
)
{
- DEBUG ((DEBUG_ERROR, "TestPointLibSetErrorString - %s\n", ErrorString));
+ DEBUG ((DEBUG_INFO, "TestPointLibSetErrorString - %s\n", ErrorString));
return InternalTestPointRecordErrorString (
Role,
ImplementationID,
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.c
index 746d0308da..a55f6731b7 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointLib/SmmTestPoint.c
@@ -193,8 +193,8 @@ InternalTestPointIsValidTable (
DEBUG ((EFI_D_ERROR, "TestPointSize < sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)\n"));
return FALSE;
}
- if (((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < TestPoint->FeaturesSize) {
- DEBUG ((EFI_D_ERROR, "((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / 3) < FeaturesSize\n"));
+ if (((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / TEST_POINT_FEATURES_ITEM_NUMBER) < TestPoint->FeaturesSize) {
+ DEBUG ((EFI_D_ERROR, "((TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT)) / TEST_POINT_FEATURES_ITEM_NUMBER) < FeaturesSize\n"));
return FALSE;
}
@@ -229,8 +229,8 @@ InternalTestPointIsValidTable (
return FALSE;
}
- ErrorStringSize = TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3;
- ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3);
+ ErrorStringSize = TestPointSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * TEST_POINT_FEATURES_ITEM_NUMBER;
+ ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * TEST_POINT_FEATURES_ITEM_NUMBER);
//
// basic check for ErrorString
@@ -273,9 +273,6 @@ InternalTestPointIsValidTable (
One system should have only one PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE.
- If the Role is NOT PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE,
- FeaturesRequired field will be ignored.
-
@param TestPoint TestPoint data
@param TestPointSize TestPoint size
@@ -297,10 +294,11 @@ TestPointLibSetTable (
EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
UINT32 Role;
CHAR16 *ImplementationID;
- UINT32 FeaturesSize;
- UINT8 *FeaturesRequired;
+
+ DEBUG ((EFI_D_ERROR, "TestPointLibSetTable\n"));
if (!InternalTestPointIsValidTable (TestPoint, TestPointSize)) {
+ DEBUG ((EFI_D_ERROR, "InternalTestPointIsValidTable\n"));
return EFI_VOLUME_CORRUPTED;
}
@@ -308,6 +306,7 @@ TestPointLibSetTable (
ImplementationID = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->ImplementationID;
Aip = InternalTestPointFindAip (Role, ImplementationID, NULL, NULL);
if (Aip != NULL) {
+ DEBUG ((EFI_D_ERROR, "Aip (0x%x, %S) is found\n", Role, ImplementationID));
return EFI_ALREADY_STARTED;
}
@@ -320,11 +319,6 @@ TestPointLibSetTable (
FreePool (TestPointAip);
return EFI_OUT_OF_RESOURCES;
}
- if (Role != PLATFORM_TEST_POINT_ROLE_PLATFORM_REFERENCE) {
- FeaturesRequired = (UINT8 *)TestPointAip->TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT);
- FeaturesSize = ((ADAPTER_INFO_PLATFORM_TEST_POINT *)TestPoint)->FeaturesSize;
- ZeroMem (FeaturesRequired, FeaturesSize);
- }
TestPointAip->Signature = TEST_POINT_AIP_PRIVATE_SIGNATURE;
CopyMem (&TestPointAip->Aip, &mAdapterInformationProtocol, sizeof(EFI_ADAPTER_INFORMATION_PROTOCOL));
@@ -425,7 +419,7 @@ InternalTestPointRecordFeaturesVerified (
return EFI_UNSUPPORTED;
}
- FeaturesVerified = (UINT8 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 2);
+ FeaturesVerified = (UINT8 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 1);
if (Set) {
FeaturesVerified[ByteIndex] = (UINT8)(FeaturesVerified[ByteIndex] | (Bit));
@@ -466,6 +460,7 @@ TestPointLibSetFeaturesVerified (
IN UINT8 BitMask
)
{
+ DEBUG ((DEBUG_INFO, "TestPointLibSetFeaturesVerified - Index:0x%x Mask:0x%02x\n", ByteIndex, BitMask));
return InternalTestPointRecordFeaturesVerified (
Role,
ImplementationID,
@@ -499,6 +494,7 @@ TestPointLibClearFeaturesVerified (
IN UINT8 BitMask
)
{
+ DEBUG ((DEBUG_INFO, "TestPointLibClearFeaturesVerified - Index:0x%x Mask:0x%02x\n", ByteIndex, BitMask));
return InternalTestPointRecordFeaturesVerified (
Role,
ImplementationID,
@@ -549,7 +545,7 @@ InternalTestPointRecordErrorString (
if (Append) {
Offset = TestPointSize - sizeof(CHAR16);
} else {
- Offset = sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * 3;
+ Offset = sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TestPoint->FeaturesSize * TEST_POINT_FEATURES_ITEM_NUMBER;
}
StringSize = StrSize (ErrorString);
@@ -593,7 +589,7 @@ TestPointLibAppendErrorString (
IN CHAR16 *ErrorString
)
{
- DEBUG ((DEBUG_ERROR, "TestPointLibAppendErrorString - (0x%x) %s\n", Role, ErrorString));
+ DEBUG ((DEBUG_INFO, "TestPointLibAppendErrorString - (0x%x) %s\n", Role, ErrorString));
return InternalTestPointRecordErrorString (
Role,
ImplementationID,
@@ -624,7 +620,7 @@ TestPointLibSetErrorString (
IN CHAR16 *ErrorString
)
{
- DEBUG ((DEBUG_ERROR, "TestPointLibSetErrorString - %s\n", ErrorString));
+ DEBUG ((DEBUG_INFO, "TestPointLibSetErrorString - %s\n", ErrorString));
return InternalTestPointRecordErrorString (
Role,
ImplementationID,
diff --git a/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDump.c b/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDump.c
index e35ae95222..2dc03429e3 100644
--- a/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDump.c
+++ b/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDump.c
@@ -18,11 +18,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
-#include <Library/HobLib.h>
#include <Library/TestPointLib.h>
#include <Protocol/AdapterInformation.h>
-#include <Protocol/SmmCommunication.h>
-#include <Guid/PiSmmCommunicationRegionTable.h>
VOID
DumpTestPoint (
@@ -43,13 +40,6 @@ DumpTestPoint (
Print (L" FeaturesSize - 0x%08x\n", TestPoint->FeaturesSize);
Features = (UINT8 *)(TestPoint + 1);
- Print (L" FeaturesRequired - ");
- for (Index = 0; Index < TestPoint->FeaturesSize; Index++) {
- Print (L"%02x ", Features[Index]);
- }
- Print (L"\n");
-
- Features = (UINT8 *)(Features + TestPoint->FeaturesSize);
Print (L" FeaturesImplemented - ");
for (Index = 0; Index < TestPoint->FeaturesSize; Index++) {
Print (L"%02x ", Features[Index]);
@@ -81,35 +71,6 @@ DumpTestPoint (
}
VOID
-DumpTestPointDataPei (
- IN UINT32 Role OPTIONAL,
- IN CHAR16 *ImplementationID OPTIONAL
- )
-{
- EFI_PEI_HOB_POINTERS Hob;
- ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
-
- Hob.Raw = GetHobList ();
- while (TRUE) {
- Hob.Raw = GetNextGuidHob (&gAdapterInfoPlatformTestPointGuid, Hob.Raw);
- if (Hob.Raw == NULL) {
- return ;
- }
- TestPoint = GET_GUID_HOB_DATA (Hob);
-
- if ((Role == 0) ||
- ((TestPoint->Role == Role) &&
- ((ImplementationID == NULL) || (StrCmp (ImplementationID, TestPoint->ImplementationID) == 0)))) {
- DumpTestPoint (TestPoint);
- }
- Hob.Raw = GET_NEXT_HOB (Hob);
- if (Hob.Raw == NULL) {
- return ;
- }
- }
-}
-
-VOID
DumpTestPointDataDxe (
IN UINT32 Role OPTIONAL,
IN CHAR16 *ImplementationID OPTIONAL
@@ -204,196 +165,6 @@ DumpTestPointDataDxe (
FreePool (Handles);
}
-UINTN mSmmTestPointDatabaseSize;
-VOID *mSmmTestPointDatabase;
-
-VOID
-GetTestPointDataSmm (
- VOID
- )
-{
- EFI_STATUS Status;
- UINTN CommSize;
- UINT8 *CommBuffer;
- EFI_SMM_COMMUNICATE_HEADER *CommHeader;
- SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO *CommGetInfo;
- SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET *CommGetData;
- EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
- UINTN MinimalSizeNeeded;
- EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *PiSmmCommunicationRegionTable;
- UINT32 Index;
- EFI_MEMORY_DESCRIPTOR *Entry;
- VOID *Buffer;
- UINTN Size;
- UINTN Offset;
-
- Status = gBS->LocateProtocol(&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&SmmCommunication);
- if (EFI_ERROR(Status)) {
- Print(L"SmiHandlerTestPoint: Locate SmmCommunication protocol - %r\n", Status);
- return ;
- }
-
- MinimalSizeNeeded = EFI_PAGE_SIZE;
-
- Status = EfiGetSystemConfigurationTable(
- &gEdkiiPiSmmCommunicationRegionTableGuid,
- (VOID **)&PiSmmCommunicationRegionTable
- );
- if (EFI_ERROR(Status)) {
- Print(L"SmiHandlerTestPoint: Get PiSmmCommunicationRegionTable - %r\n", Status);
- return ;
- }
- ASSERT(PiSmmCommunicationRegionTable != NULL);
- Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
- Size = 0;
- for (Index = 0; Index < PiSmmCommunicationRegionTable->NumberOfEntries; Index++) {
- if (Entry->Type == EfiConventionalMemory) {
- Size = EFI_PAGES_TO_SIZE((UINTN)Entry->NumberOfPages);
- if (Size >= MinimalSizeNeeded) {
- break;
- }
- }
- Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
- }
- ASSERT(Index < PiSmmCommunicationRegionTable->NumberOfEntries);
- CommBuffer = (UINT8 *)(UINTN)Entry->PhysicalStart;
-
- //
- // Get Size
- //
- CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
- CopyMem(&CommHeader->HeaderGuid, &gAdapterInfoPlatformTestPointGuid, sizeof(gAdapterInfoPlatformTestPointGuid));
- CommHeader->MessageLength = sizeof(SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO);
-
- CommGetInfo = (SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO *)&CommBuffer[OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data)];
- CommGetInfo->Header.Command = SMI_HANDLER_TEST_POINT_COMMAND_GET_INFO;
- CommGetInfo->Header.DataLength = sizeof(*CommGetInfo);
- CommGetInfo->Header.ReturnStatus = (UINT64)-1;
- CommGetInfo->DataSize = 0;
-
- CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLength;
- Status = SmmCommunication->Communicate(SmmCommunication, CommBuffer, &CommSize);
- if (EFI_ERROR(Status)) {
- Print(L"SmiHandlerTestPoint: SmmCommunication - %r\n", Status);
- return ;
- }
-
- if (CommGetInfo->Header.ReturnStatus != 0) {
- Print(L"SmiHandlerTestPoint: GetInfo - 0x%0x\n", CommGetInfo->Header.ReturnStatus);
- return ;
- }
-
- mSmmTestPointDatabaseSize = (UINTN)CommGetInfo->DataSize;
-
- //
- // Get Data
- //
- mSmmTestPointDatabase = AllocateZeroPool(mSmmTestPointDatabaseSize);
- if (mSmmTestPointDatabase == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- Print(L"SmiHandlerTestPoint: AllocateZeroPool (0x%x) for dump buffer - %r\n", mSmmTestPointDatabaseSize, Status);
- return ;
- }
-
- CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
- CopyMem(&CommHeader->HeaderGuid, &gAdapterInfoPlatformTestPointGuid, sizeof(gAdapterInfoPlatformTestPointGuid));
- CommHeader->MessageLength = sizeof(SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET);
-
- CommGetData = (SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET *)&CommBuffer[OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data)];
- CommGetData->Header.Command = SMI_HANDLER_TEST_POINT_COMMAND_GET_DATA_BY_OFFSET;
- CommGetData->Header.DataLength = sizeof(*CommGetData);
- CommGetData->Header.ReturnStatus = (UINT64)-1;
-
- CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLength;
- Buffer = (UINT8 *)CommHeader + CommSize;
- Size -= CommSize;
-
- CommGetData->DataBuffer = (PHYSICAL_ADDRESS)(UINTN)Buffer;
- CommGetData->DataOffset = 0;
- while (CommGetData->DataOffset < mSmmTestPointDatabaseSize) {
- Offset = (UINTN)CommGetData->DataOffset;
- if (Size <= (mSmmTestPointDatabaseSize - CommGetData->DataOffset)) {
- CommGetData->DataSize = (UINT64)Size;
- } else {
- CommGetData->DataSize = (UINT64)(mSmmTestPointDatabaseSize - CommGetData->DataOffset);
- }
- Status = SmmCommunication->Communicate(SmmCommunication, CommBuffer, &CommSize);
- ASSERT_EFI_ERROR(Status);
-
- if (CommGetData->Header.ReturnStatus != 0) {
- FreePool(mSmmTestPointDatabase);
- mSmmTestPointDatabase = NULL;
- Print(L"SmiHandlerTestPoint: GetData - 0x%x\n", CommGetData->Header.ReturnStatus);
- return ;
- }
- CopyMem((UINT8 *)mSmmTestPointDatabase + Offset, (VOID *)(UINTN)CommGetData->DataBuffer, (UINTN)CommGetData->DataSize);
- }
-
- DEBUG ((DEBUG_INFO, "SmmTestPointDatabaseSize - 0x%x\n", mSmmTestPointDatabaseSize));
-
- return ;
-}
-
-UINTN
-GetTestPointInfoSize (
- IN ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint,
- IN UINTN MaxSize
- )
-{
- CHAR16 *ErrorString;
- UINTN ErrorStringLength;
- UINTN ErrorStringMaxSize;
- CHAR16 ErrorChar;
-
- ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + 3 * TestPoint->FeaturesSize);
-
- ErrorStringMaxSize = MaxSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * 3;
- //
- // ErrorString might not be CHAR16 aligned.
- //
- CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
- for (ErrorStringLength = 0; (ErrorChar != 0) && (ErrorStringLength < (ErrorStringMaxSize/2)); ErrorStringLength++) {
- ErrorString++;
- CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
- }
-
- return sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + 3 * TestPoint->FeaturesSize + (ErrorStringLength + 1) * sizeof(CHAR16);
-}
-
-VOID
-DumpTestPointDataSmm (
- IN UINT32 Role OPTIONAL,
- IN CHAR16 *ImplementationID OPTIONAL
- )
-{
- ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
- UINTN Size;
-
- GetTestPointDataSmm ();
-
- if (mSmmTestPointDatabaseSize == 0) {
- return ;
- }
- if (mSmmTestPointDatabase == NULL) {
- return ;
- }
-
- TestPoint = mSmmTestPointDatabase;
- while ((UINTN)TestPoint < (UINTN)mSmmTestPointDatabase + mSmmTestPointDatabaseSize) {
- if ((Role == 0) ||
- ((TestPoint->Role == Role) &&
- ((ImplementationID == NULL) || (StrCmp (ImplementationID, TestPoint->ImplementationID) == 0)))) {
- DumpTestPoint (TestPoint);
- }
-
- //
- // Next
- //
- Size = GetTestPointInfoSize (TestPoint, (UINTN)mSmmTestPointDatabase + mSmmTestPointDatabaseSize - (UINTN)TestPoint);
- TestPoint = (ADAPTER_INFO_PLATFORM_TEST_POINT *)((UINTN)TestPoint + Size);
- }
-}
-
EFI_STATUS
EFIAPI
TestPointDumpAppEntrypoint (
@@ -401,12 +172,7 @@ TestPointDumpAppEntrypoint (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- Print(L"TestPoint PEI:\n");
- DumpTestPointDataPei (0, NULL);
- Print(L"TestPoint DXE:\n");
DumpTestPointDataDxe (0, NULL);
- Print(L"TestPoint SMM:\n");
- DumpTestPointDataSmm (0, NULL);
return EFI_SUCCESS;
}
diff --git a/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDumpApp.inf b/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDumpApp.inf
index 73ca073fe2..c1e7cc8b22 100644
--- a/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDumpApp.inf
+++ b/Platform/Intel/MinPlatformPkg/Test/TestPointDumpApp/TestPointDumpApp.inf
@@ -35,15 +35,12 @@
DebugLib
UefiBootServicesTableLib
UefiLib
- HobLib
[Guids]
gAdapterInfoPlatformTestPointGuid
- gEdkiiPiSmmCommunicationRegionTableGuid
[Protocols]
gEfiAdapterInformationProtocolGuid
- gEfiSmmCommunicationProtocolGuid
[Depex]
TRUE \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c b/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c
new file mode 100644
index 0000000000..b80db2d547
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c
@@ -0,0 +1,417 @@
+/** @file
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiDxe.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/HobLib.h>
+#include <Library/TestPointLib.h>
+#include <Protocol/AdapterInformation.h>
+#include <Protocol/SmmCommunication.h>
+#include <Guid/PiSmmCommunicationRegionTable.h>
+#include <Protocol/ReportStatusCodeHandler.h>
+
+EFI_STATUS
+TestPointStubUnRegisterRscHandler (
+ VOID
+ );
+
+UINTN mSmmTestPointDatabaseSize;
+VOID *mSmmTestPointDatabase;
+
+EFI_EVENT mRscNotifyEvent = NULL;
+EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;
+
+VOID
+PublishPeiTestPoint (
+ VOID
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN TestPointSize;
+
+ DEBUG ((DEBUG_INFO, "PublishPeiTestPoint\n"));
+
+ Hob.Raw = GetHobList ();
+ while (TRUE) {
+ Hob.Raw = GetNextGuidHob (&gAdapterInfoPlatformTestPointGuid, Hob.Raw);
+ if (Hob.Raw == NULL) {
+ return ;
+ }
+ TestPoint = GET_GUID_HOB_DATA (Hob);
+ TestPointSize = GET_GUID_HOB_DATA_SIZE (Hob);
+
+ TestPointLibSetTable (TestPoint, TestPointSize);
+
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ if (Hob.Raw == NULL) {
+ return ;
+ }
+ }
+}
+
+VOID
+TestPointStubForPei (
+ VOID
+ )
+{
+ PublishPeiTestPoint ();
+}
+
+VOID
+GetTestPointDataSmm (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINTN CommSize;
+ UINT8 *CommBuffer;
+ EFI_SMM_COMMUNICATE_HEADER *CommHeader;
+ SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO *CommGetInfo;
+ SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET *CommGetData;
+ EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
+ UINTN MinimalSizeNeeded;
+ EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *PiSmmCommunicationRegionTable;
+ UINT32 Index;
+ EFI_MEMORY_DESCRIPTOR *Entry;
+ VOID *Buffer;
+ UINTN Size;
+ UINTN Offset;
+
+ Status = gBS->LocateProtocol(&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&SmmCommunication);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "SmiHandlerTestPoint: Locate SmmCommunication protocol - %r\n", Status));
+ return ;
+ }
+
+ MinimalSizeNeeded = EFI_PAGE_SIZE;
+
+ Status = EfiGetSystemConfigurationTable(
+ &gEdkiiPiSmmCommunicationRegionTableGuid,
+ (VOID **)&PiSmmCommunicationRegionTable
+ );
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "SmiHandlerTestPoint: Get PiSmmCommunicationRegionTable - %r\n", Status));
+ return ;
+ }
+ ASSERT(PiSmmCommunicationRegionTable != NULL);
+ Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
+ Size = 0;
+ for (Index = 0; Index < PiSmmCommunicationRegionTable->NumberOfEntries; Index++) {
+ if (Entry->Type == EfiConventionalMemory) {
+ Size = EFI_PAGES_TO_SIZE((UINTN)Entry->NumberOfPages);
+ if (Size >= MinimalSizeNeeded) {
+ break;
+ }
+ }
+ Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
+ }
+ ASSERT(Index < PiSmmCommunicationRegionTable->NumberOfEntries);
+ CommBuffer = (UINT8 *)(UINTN)Entry->PhysicalStart;
+
+ //
+ // Get Size
+ //
+ CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
+ CopyMem(&CommHeader->HeaderGuid, &gAdapterInfoPlatformTestPointGuid, sizeof(gAdapterInfoPlatformTestPointGuid));
+ CommHeader->MessageLength = sizeof(SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO);
+
+ CommGetInfo = (SMI_HANDLER_TEST_POINT_PARAMETER_GET_INFO *)&CommBuffer[OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data)];
+ CommGetInfo->Header.Command = SMI_HANDLER_TEST_POINT_COMMAND_GET_INFO;
+ CommGetInfo->Header.DataLength = sizeof(*CommGetInfo);
+ CommGetInfo->Header.ReturnStatus = (UINT64)-1;
+ CommGetInfo->DataSize = 0;
+
+ CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLength;
+ Status = SmmCommunication->Communicate(SmmCommunication, CommBuffer, &CommSize);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "SmiHandlerTestPoint: SmmCommunication - %r\n", Status));
+ return ;
+ }
+
+ if (CommGetInfo->Header.ReturnStatus != 0) {
+ DEBUG ((DEBUG_INFO, "SmiHandlerTestPoint: GetInfo - 0x%0x\n", CommGetInfo->Header.ReturnStatus));
+ return ;
+ }
+
+ mSmmTestPointDatabaseSize = (UINTN)CommGetInfo->DataSize;
+
+ //
+ // Get Data
+ //
+ mSmmTestPointDatabase = AllocateZeroPool(mSmmTestPointDatabaseSize);
+ if (mSmmTestPointDatabase == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_INFO, "SmiHandlerTestPoint: AllocateZeroPool (0x%x) for dump buffer - %r\n", mSmmTestPointDatabaseSize, Status));
+ return ;
+ }
+
+ CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
+ CopyMem(&CommHeader->HeaderGuid, &gAdapterInfoPlatformTestPointGuid, sizeof(gAdapterInfoPlatformTestPointGuid));
+ CommHeader->MessageLength = sizeof(SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET);
+
+ CommGetData = (SMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET *)&CommBuffer[OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data)];
+ CommGetData->Header.Command = SMI_HANDLER_TEST_POINT_COMMAND_GET_DATA_BY_OFFSET;
+ CommGetData->Header.DataLength = sizeof(*CommGetData);
+ CommGetData->Header.ReturnStatus = (UINT64)-1;
+
+ CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLength;
+ Buffer = (UINT8 *)CommHeader + CommSize;
+ Size -= CommSize;
+
+ CommGetData->DataBuffer = (PHYSICAL_ADDRESS)(UINTN)Buffer;
+ CommGetData->DataOffset = 0;
+ while (CommGetData->DataOffset < mSmmTestPointDatabaseSize) {
+ Offset = (UINTN)CommGetData->DataOffset;
+ if (Size <= (mSmmTestPointDatabaseSize - CommGetData->DataOffset)) {
+ CommGetData->DataSize = (UINT64)Size;
+ } else {
+ CommGetData->DataSize = (UINT64)(mSmmTestPointDatabaseSize - CommGetData->DataOffset);
+ }
+ Status = SmmCommunication->Communicate(SmmCommunication, CommBuffer, &CommSize);
+ ASSERT_EFI_ERROR(Status);
+
+ if (CommGetData->Header.ReturnStatus != 0) {
+ FreePool(mSmmTestPointDatabase);
+ mSmmTestPointDatabase = NULL;
+ DEBUG ((DEBUG_INFO, "SmiHandlerTestPoint: GetData - 0x%x\n", CommGetData->Header.ReturnStatus));
+ return ;
+ }
+ CopyMem((UINT8 *)mSmmTestPointDatabase + Offset, (VOID *)(UINTN)CommGetData->DataBuffer, (UINTN)CommGetData->DataSize);
+ }
+
+ DEBUG ((DEBUG_INFO, "SmmTestPointDatabaseSize - 0x%x\n", mSmmTestPointDatabaseSize));
+
+ return ;
+}
+
+UINTN
+GetTestPointInfoSize (
+ IN ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint,
+ IN UINTN MaxSize
+ )
+{
+ CHAR16 *ErrorString;
+ UINTN ErrorStringLength;
+ UINTN ErrorStringMaxSize;
+ CHAR16 ErrorChar;
+
+ ErrorString = (CHAR16 *)((UINTN)TestPoint + sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TEST_POINT_FEATURES_ITEM_NUMBER * TestPoint->FeaturesSize);
+
+ ErrorStringMaxSize = MaxSize - sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) - TestPoint->FeaturesSize * TEST_POINT_FEATURES_ITEM_NUMBER;
+ //
+ // ErrorString might not be CHAR16 aligned.
+ //
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ for (ErrorStringLength = 0; (ErrorChar != 0) && (ErrorStringLength < (ErrorStringMaxSize/2)); ErrorStringLength++) {
+ ErrorString++;
+ CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));
+ }
+
+ return sizeof(ADAPTER_INFO_PLATFORM_TEST_POINT) + TEST_POINT_FEATURES_ITEM_NUMBER * TestPoint->FeaturesSize + (ErrorStringLength + 1) * sizeof(CHAR16);
+}
+
+VOID
+PublishSmmTestPoint (
+ VOID
+ )
+{
+ ADAPTER_INFO_PLATFORM_TEST_POINT *TestPoint;
+ UINTN TestPointSize;
+
+ DEBUG ((DEBUG_INFO, "PublishSmmTestPoint\n"));
+
+ GetTestPointDataSmm ();
+
+ if (mSmmTestPointDatabaseSize == 0) {
+ return ;
+ }
+ if (mSmmTestPointDatabase == NULL) {
+ return ;
+ }
+
+ TestPoint = mSmmTestPointDatabase;
+ while ((UINTN)TestPoint < (UINTN)mSmmTestPointDatabase + mSmmTestPointDatabaseSize) {
+ TestPointSize = GetTestPointInfoSize (TestPoint, (UINTN)mSmmTestPointDatabase + mSmmTestPointDatabaseSize - (UINTN)TestPoint);
+
+ TestPointLibSetTable (TestPoint, TestPointSize);
+
+ TestPoint = (ADAPTER_INFO_PLATFORM_TEST_POINT *)((UINTN)TestPoint + TestPointSize);
+ }
+}
+
+/**
+ Report status code listener
+ for OsLoaderLoadImageStart and OsLoaderStartImageStart.
+
+ @param[in] CodeType Indicates the type of status code being reported.
+ @param[in] Value Describes the current status of a hardware or software entity.
+ This included information about the class and subclass that is used to
+ classify the entity as well as an operation.
+ @param[in] Instance The enumeration of a hardware or software entity within
+ the system. Valid instance numbers start with 1.
+ @param[in] CallerId This optional parameter may be used to identify the caller.
+ This parameter allows the status code driver to apply different rules to
+ different callers.
+ @param[in] Data This optional parameter may be used to pass additional data.
+
+ @retval EFI_SUCCESS Status code is what we expected.
+ @retval EFI_UNSUPPORTED Status code not supported.
+
+**/
+EFI_STATUS
+EFIAPI
+TestPointStubStatusCodeListener (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId,
+ IN EFI_STATUS_CODE_DATA *Data
+ )
+{
+ EFI_STATUS Status;
+ STATIC BOOLEAN Published = FALSE;
+
+ //
+ // Check whether status code is what we are interested in.
+ //
+ if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) {
+ return EFI_UNSUPPORTED;
+ }
+
+ Status = EFI_SUCCESS;
+ if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)) {
+ if (!Published) {
+ PublishSmmTestPoint ();
+ Published = TRUE;
+ }
+ } else if (Value == PcdGet32 (PcdProgressCodeOsLoaderLoad)) {
+ } else if (Value == PcdGet32 (PcdProgressCodeOsLoaderStart)) {
+ } else if (Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) {
+ TestPointStubUnRegisterRscHandler ();
+ } else if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT)) {
+ } else {
+ //
+ // Ignore else progress code.
+ //
+ Status = EFI_UNSUPPORTED;
+ }
+
+ return Status;
+}
+
+/**
+ RscHandler Protocol notification event handler.
+
+ @param[in] Event Event whose notification function is being invoked.
+ @param[in] Context Pointer to the notification function's context.
+**/
+VOID
+EFIAPI
+OnRscHandlerInstalled (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol (
+ &gEfiRscHandlerProtocolGuid,
+ NULL,
+ &mRscHandlerProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ //
+ // Register report status code listener for OS Loader load and start.
+ //
+ Status = mRscHandlerProtocol->Register (TestPointStubStatusCodeListener, TPL_HIGH_LEVEL);
+ ASSERT_EFI_ERROR (Status);
+
+ gBS->CloseEvent (mRscNotifyEvent);
+ mRscNotifyEvent = NULL;
+}
+
+EFI_STATUS
+TestPointStubRegisterRscHandler (
+ VOID
+ )
+{
+ VOID *Registration;
+
+ mRscNotifyEvent = EfiCreateProtocolNotifyEvent (
+ &gEfiRscHandlerProtocolGuid,
+ TPL_CALLBACK,
+ OnRscHandlerInstalled,
+ NULL,
+ &Registration
+ );
+ ASSERT (mRscNotifyEvent != NULL);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+TestPointStubUnRegisterRscHandler (
+ VOID
+ )
+{
+ if (mRscHandlerProtocol != NULL) {
+ mRscHandlerProtocol->Unregister (TestPointStubStatusCodeListener);
+ mRscHandlerProtocol = NULL;
+ }
+ if (mRscNotifyEvent != NULL) {
+ gBS->CloseEvent (mRscNotifyEvent);
+ mRscNotifyEvent = NULL;
+ }
+ return EFI_SUCCESS;
+}
+
+VOID
+TestPointStubForSmm (
+ VOID
+ )
+{
+ TestPointStubRegisterRscHandler ();
+}
+
+/**
+ Initialize TestPointStub.
+
+ @param[in] ImageHandle Image handle of this driver.
+ @param[in] SystemTable Global system service table.
+
+ @retval EFI_SUCCESS Initialization complete.
+ @exception EFI_UNSUPPORTED The chipset is unsupported by this driver.
+ @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
+ @retval EFI_DEVICE_ERROR Device error, driver exits abnormally.
+**/
+EFI_STATUS
+EFIAPI
+TestPointStubDxeEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ TestPointStubForPei ();
+ TestPointStubForSmm ();
+
+ return EFI_SUCCESS;
+} \ No newline at end of file
diff --git a/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.inf b/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.inf
new file mode 100644
index 0000000000..09d6f2a9f0
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.inf
@@ -0,0 +1,57 @@
+### @file
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials are licensed and made available under
+# the terms and conditions of the BSD License which accompanies this distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+###
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TestPointStubDxe
+ FILE_GUID = C034A2CB-1190-4638-9DDF-6F297824741E
+ VERSION_STRING = 1.0
+ MODULE_TYPE = DXE_DRIVER
+ ENTRY_POINT = TestPointStubDxeEntryPoint
+
+[Sources]
+ TestPointStubDxe.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ BaseLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ DebugLib
+ PcdLib
+ UefiBootServicesTableLib
+ UefiLib
+ HobLib
+ TestPointLib
+
+[Guids]
+ gAdapterInfoPlatformTestPointGuid
+ gEdkiiPiSmmCommunicationRegionTableGuid
+
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderLoad
+ gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderStart
+
+[Protocols]
+ gEfiAdapterInformationProtocolGuid
+ gEfiSmmCommunicationProtocolGuid
+ gEfiRscHandlerProtocolGuid
+
+[Depex]
+ TRUE