/** @file\r
The header file for Tcg2 SMM driver.\r
- \r
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php\r
\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) Microsoft Corporation.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#ifndef __TCG2_SMM_H__\r
#define __TCG2_SMM_H__\r
\r
-#include <PiDxe.h>\r
-#include <IndustryStandard/Acpi.h>\r
-#include <IndustryStandard/Tpm2Acpi.h>\r
+#include <PiMm.h>\r
\r
#include <Guid/MemoryOverwriteControl.h>\r
#include <Guid/TpmInstance.h>\r
+#include <Guid/TpmNvsMm.h>\r
\r
+#include <Protocol/MmReadyToLock.h>\r
#include <Protocol/SmmSwDispatch2.h>\r
#include <Protocol/AcpiTable.h>\r
#include <Protocol/SmmVariable.h>\r
#include <Library/BaseLib.h>\r
#include <Library/BaseMemoryLib.h>\r
#include <Library/DebugLib.h>\r
-#include <Library/SmmServicesTableLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DxeServicesLib.h>\r
-#include <Library/TpmMeasurementLib.h>\r
+#include <Library/MmServicesTableLib.h>\r
#include <Library/Tpm2CommandLib.h>\r
#include <Library/Tcg2PhysicalPresenceLib.h>\r
#include <Library/IoLib.h>\r
-#include <Library/PrintLib.h>\r
#include <Library/PcdLib.h>\r
+#include <Library/Tpm2DeviceLib.h>\r
\r
#include <IndustryStandard/TpmPtp.h>\r
\r
-#pragma pack(1)\r
-typedef struct {\r
- UINT8 SoftwareSmi;\r
- UINT32 Parameter;\r
- UINT32 Response;\r
- UINT32 Request;\r
- UINT32 RequestParameter;\r
- UINT32 LastRequest;\r
- UINT32 ReturnCode;\r
-} PHYSICAL_PRESENCE_NVS;\r
-\r
-typedef struct {\r
- UINT8 SoftwareSmi;\r
- UINT32 Parameter;\r
- UINT32 Request;\r
- UINT32 ReturnCode;\r
-} MEMORY_CLEAR_NVS;\r
-\r
-typedef struct {\r
- PHYSICAL_PRESENCE_NVS PhysicalPresence;\r
- MEMORY_CLEAR_NVS MemoryClear;\r
- UINT32 PPRequestUserConfirm;\r
- UINT32 TpmIrqNum;\r
- BOOLEAN IsShortFormPkgLength;\r
-} TCG_NVS;\r
-\r
-typedef struct {\r
- UINT8 OpRegionOp;\r
- UINT32 NameString;\r
- UINT8 RegionSpace;\r
- UINT8 DWordPrefix;\r
- UINT32 RegionOffset;\r
- UINT8 BytePrefix;\r
- UINT8 RegionLen;\r
-} AML_OP_REGION_32_8;\r
-#pragma pack()\r
-\r
//\r
// The definition for TCG MOR\r
//\r
-#define ACPI_FUNCTION_DSM_MEMORY_CLEAR_INTERFACE 1\r
-#define ACPI_FUNCTION_PTS_CLEAR_MOR_BIT 2\r
+#define ACPI_FUNCTION_DSM_MEMORY_CLEAR_INTERFACE 1\r
+#define ACPI_FUNCTION_PTS_CLEAR_MOR_BIT 2\r
\r
//\r
// The return code for Memory Clear Interface Functions\r
//\r
-#define MOR_REQUEST_SUCCESS 0\r
-#define MOR_REQUEST_GENERAL_FAILURE 1\r
+#define MOR_REQUEST_SUCCESS 0\r
+#define MOR_REQUEST_GENERAL_FAILURE 1\r
\r
-//\r
-// Physical Presence Interface Version supported by Platform\r
-//\r
-#define PHYSICAL_PRESENCE_VERSION_TAG "$PV"\r
-#define PHYSICAL_PRESENCE_VERSION_SIZE 4\r
+/**\r
+ Notify the system that the SMM variable driver is ready.\r
+**/\r
+VOID\r
+Tcg2NotifyMmReady (\r
+ VOID\r
+ );\r
\r
-//\r
-// PNP _HID for TPM2 device\r
-//\r
-#define TPM_HID_TAG "NNNN0000"\r
-#define TPM_HID_PNP_SIZE 8\r
-#define TPM_HID_ACPI_SIZE 9\r
+/**\r
+ This function is an abstraction layer for implementation specific Mm buffer validation routine.\r
\r
-#define TPM_PRS_RESL "RESL"\r
-#define TPM_PRS_RESS "RESS"\r
-#define TPM_PRS_RES_NAME_SIZE 4\r
-//\r
-// Minimum PRS resource template size\r
-// 1 byte for BufferOp\r
-// 1 byte for PkgLength\r
-// 2 bytes for BufferSize\r
-// 12 bytes for Memory32Fixed descriptor\r
-// 5 bytes for Interrupt descriptor\r
-// 2 bytes for END Tag\r
-//\r
-#define TPM_POS_RES_TEMPLATE_MIN_SIZE (1 + 1 + 2 + 12 + 5 + 2)\r
+ @param Buffer The buffer start address to be checked.\r
+ @param Length The buffer length to be checked.\r
\r
-//\r
-// Max Interrupt buffer size for PRS interrupt resource\r
-// Now support 15 interrupts in maxmum\r
-//\r
-#define MAX_PRS_INT_BUF_SIZE (15*4)\r
-#endif // __TCG_SMM_H__\r
+ @retval TRUE This buffer is valid per processor architecture and not overlap with SMRAM.\r
+ @retval FALSE This buffer is not valid per processor architecture or overlap with SMRAM.\r
+**/\r
+BOOLEAN\r
+IsBufferOutsideMmValid (\r
+ IN EFI_PHYSICAL_ADDRESS Buffer,\r
+ IN UINT64 Length\r
+ );\r
+\r
+/**\r
+ The driver's common initialization routine.\r
+\r
+ It install callbacks for TPM physical presence and MemoryClear, and locate\r
+ SMM variable to be used in the callback function.\r
+\r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval Others Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+InitializeTcgCommon (\r
+ VOID\r
+ );\r
+\r
+#endif // __TCG_SMM_H__\r