1 /** @file 2 The header file for Tcg2 SMM driver. 3 4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR> 5 SPDX-License-Identifier: BSD-2-Clause-Patent 6 7 **/ 8 9 #ifndef __TCG2_SMM_H__ 10 #define __TCG2_SMM_H__ 11 12 #include <PiDxe.h> 13 #include <IndustryStandard/Acpi.h> 14 #include <IndustryStandard/Tpm2Acpi.h> 15 16 #include <Guid/MemoryOverwriteControl.h> 17 #include <Guid/TpmInstance.h> 18 19 #include <Protocol/SmmSwDispatch2.h> 20 #include <Protocol/AcpiTable.h> 21 #include <Protocol/SmmVariable.h> 22 #include <Protocol/Tcg2Protocol.h> 23 24 #include <Library/BaseLib.h> 25 #include <Library/BaseMemoryLib.h> 26 #include <Library/DebugLib.h> 27 #include <Library/SmmServicesTableLib.h> 28 #include <Library/UefiDriverEntryPoint.h> 29 #include <Library/UefiBootServicesTableLib.h> 30 #include <Library/DxeServicesLib.h> 31 #include <Library/TpmMeasurementLib.h> 32 #include <Library/Tpm2CommandLib.h> 33 #include <Library/Tcg2PhysicalPresenceLib.h> 34 #include <Library/IoLib.h> 35 #include <Library/PrintLib.h> 36 #include <Library/PcdLib.h> 37 #include <Library/Tpm2DeviceLib.h> 38 39 #include <IndustryStandard/TpmPtp.h> 40 41 #pragma pack(1) 42 typedef struct { 43 UINT8 SoftwareSmi; 44 UINT32 Parameter; 45 UINT32 Response; 46 UINT32 Request; 47 UINT32 RequestParameter; 48 UINT32 LastRequest; 49 UINT32 ReturnCode; 50 } PHYSICAL_PRESENCE_NVS; 51 52 typedef struct { 53 UINT8 SoftwareSmi; 54 UINT32 Parameter; 55 UINT32 Request; 56 UINT32 ReturnCode; 57 } MEMORY_CLEAR_NVS; 58 59 typedef struct { 60 PHYSICAL_PRESENCE_NVS PhysicalPresence; 61 MEMORY_CLEAR_NVS MemoryClear; 62 UINT32 PPRequestUserConfirm; 63 UINT32 TpmIrqNum; 64 BOOLEAN IsShortFormPkgLength; 65 } TCG_NVS; 66 67 typedef struct { 68 UINT8 OpRegionOp; 69 UINT32 NameString; 70 UINT8 RegionSpace; 71 UINT8 DWordPrefix; 72 UINT32 RegionOffset; 73 UINT8 BytePrefix; 74 UINT8 RegionLen; 75 } AML_OP_REGION_32_8; 76 #pragma pack() 77 78 // 79 // The definition for TCG MOR 80 // 81 #define ACPI_FUNCTION_DSM_MEMORY_CLEAR_INTERFACE 1 82 #define ACPI_FUNCTION_PTS_CLEAR_MOR_BIT 2 83 84 // 85 // The return code for Memory Clear Interface Functions 86 // 87 #define MOR_REQUEST_SUCCESS 0 88 #define MOR_REQUEST_GENERAL_FAILURE 1 89 90 // 91 // Physical Presence Interface Version supported by Platform 92 // 93 #define PHYSICAL_PRESENCE_VERSION_TAG "$PV" 94 #define PHYSICAL_PRESENCE_VERSION_SIZE 4 95 96 // 97 // PNP _HID for TPM2 device 98 // 99 #define TPM_HID_TAG "NNNN0000" 100 #define TPM_HID_PNP_SIZE 8 101 #define TPM_HID_ACPI_SIZE 9 102 103 #define TPM_PRS_RESL "RESL" 104 #define TPM_PRS_RESS "RESS" 105 #define TPM_PRS_RES_NAME_SIZE 4 106 // 107 // Minimum PRS resource template size 108 // 1 byte for BufferOp 109 // 1 byte for PkgLength 110 // 2 bytes for BufferSize 111 // 12 bytes for Memory32Fixed descriptor 112 // 5 bytes for Interrupt descriptor 113 // 2 bytes for END Tag 114 // 115 #define TPM_POS_RES_TEMPLATE_MIN_SIZE (1 + 1 + 2 + 12 + 5 + 2) 116 117 // 118 // Max Interrupt buffer size for PRS interrupt resource 119 // Now support 15 interrupts in maxmum 120 // 121 #define MAX_PRS_INT_BUF_SIZE (15*4) 122 #endif // __TCG_SMM_H__ 123