]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg: Tcg2Smm: Enable TPM2.0 interrupt support
authorZhang, Chao B <chao.b.zhang@intel.com>
Mon, 8 Jan 2018 02:13:54 +0000 (10:13 +0800)
committerZhang, Chao B <chao.b.zhang@intel.com>
Mon, 29 Jan 2018 07:09:23 +0000 (15:09 +0800)
1. Expose _CRS, _SRS, _PRS control method to support TPM interrupt
2. Provide 2 PCDs to configure _CRS and _PRS returned data

Cc: Yao Jiewen <jiewen.yao@intel.com>
Cc: Ronald Aigner <Ronald.Aigner@microsoft.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
SecurityPkg/SecurityPkg.dec
SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.h
SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf
SecurityPkg/Tcg/Tcg2Smm/Tpm.asl

index ededb51c246fd6eb76521884f92a6a9c12095efa..6027544f8acab3ea80597ee74a2da284c88033b1 100644 (file)
   # @Prompt Initial setting of TCG2 Persistent Firmware Management Flags\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTcg2PhysicalPresenceFlags|0x300E2|UINT32|0x0001001B\r
 \r
   # @Prompt Initial setting of TCG2 Persistent Firmware Management Flags\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTcg2PhysicalPresenceFlags|0x300E2|UINT32|0x0001001B\r
 \r
+  ## Indicate current TPM2 Interrupt Number reported by _CRS control method.<BR><BR>\r
+  # TPM2 Interrupt feature is disabled If the pcd is set to 0.<BR>\r
+  # @Prompt Current TPM2 Interrupt Number\r
+  gEfiSecurityPkgTokenSpaceGuid.PcdTpm2CurrentIrqNum|0x0C|UINT32|0x0001001C\r
+\r
+  ## Indicate platform possible TPM2 Interrupt Number reported by _PRS control method.<BR><BR>\r
+  # Possible TPM2 Interrupt Number Buffer will not be reported if TPM2 Interrupt feature is disabled.<BR>\r
+  # @Prompt Possible TPM2 Interrupt Number buffer\r
+  gEfiSecurityPkgTokenSpaceGuid.PcdTpm2PossibleIrqNumBuf|{0x0C, 0x00, 0x00, 0x00}|VOID*|0x0001001D\r
+\r
 [PcdsDynamic, PcdsDynamicEx]\r
 \r
   ## This PCD indicates Hash mask for TPM 2.0. Bit definition strictly follows TCG Algorithm Registry.<BR><BR>\r
 [PcdsDynamic, PcdsDynamicEx]\r
 \r
   ## This PCD indicates Hash mask for TPM 2.0. Bit definition strictly follows TCG Algorithm Registry.<BR><BR>\r
index 5a1fd3e363c7202375b93c0feb389d4da1686ca1..e3938cb8ece02b9f2196e196da45f28c506e4980 100644 (file)
@@ -9,7 +9,7 @@
 \r
   PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted input and do some check.\r
 \r
 \r
   PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted input and do some check.\r
 \r
-Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\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
 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
@@ -303,6 +303,251 @@ UpdatePPVersion (
   return EFI_NOT_FOUND;\r
 }\r
 \r
   return EFI_NOT_FOUND;\r
 }\r
 \r
+/**\r
+  Patch interrupt resources returned by TPM _PRS. ResourceTemplate to patch is determined by input\r
+  interrupt buffer size. BufferSize, PkgLength and interrupt descirptor in ByteList need to be patched\r
+\r
+  @param[in, out] Table            The TPM item in ACPI table.\r
+  @param[in]      IrqBuffer        Input new IRQ buffer.\r
+  @param[in]      IrqBuffserSize   Input new IRQ buffer size.\r
+\r
+  @return                          patch status.\r
+\r
+**/\r
+EFI_STATUS\r
+UpdatePossibleResource (\r
+  EFI_ACPI_DESCRIPTION_HEADER    *Table,\r
+  UINT32                         *IrqBuffer,\r
+  UINT32                         IrqBuffserSize\r
+  )\r
+{\r
+  UINT8       *DataPtr;\r
+  UINT8       *DataEndPtr;\r
+  UINT32      NewPkgLength;\r
+  UINT32      OrignalPkgLength;\r
+\r
+  NewPkgLength     = 0;\r
+  OrignalPkgLength = 0;\r
+  DataEndPtr       = NULL;\r
+\r
+  //\r
+  // Follow ACPI spec\r
+  //           6.4.3   Extend Interrupt Descriptor.\r
+  //           19.3.3 ASL Resource Template\r
+  //           20      AML specification\r
+  // to patch TPM ACPI object _PRS returned ResourceTemplate() containing 2 resource descriptors and an auto appended End Tag\r
+  //\r
+  //  AML data is organized by following rule.\r
+  //  Code need to patch BufferSize and PkgLength and interrupt descirptor in ByteList\r
+  //\r
+  // =============  Buffer ====================\r
+  //           DefBuffer := BufferOp PkgLength BufferSize ByteList\r
+  //            BufferOp := 0x11\r
+  //\r
+  // ==============PkgLength==================\r
+  //          PkgLength := PkgLeadByte |\r
+  //                              <PkgLeadByte ByteData> |\r
+  //                              <PkgLeadByte ByteData ByteData> |\r
+  //                              <PkgLeadByte ByteData ByteData ByteData>\r
+  //\r
+  //       PkgLeadByte := <bit 7-6: ByteData count that follows (0-3)>\r
+  //                               <bit 5-4: Only used if PkgLength <= 63 >\r
+  //                               <bit 3-0: Least significant package length nybble>\r
+  //\r
+  //==============BufferSize==================\r
+  //        BufferSize := Integar\r
+  //           Integar := ByteConst|WordConst|DwordConst....\r
+  //\r
+  //           ByteConst := BytePrefix ByteData\r
+  //\r
+  //==============ByteList===================\r
+  //          ByteList := ByteData ByteList\r
+  //\r
+  //=========================================\r
+\r
+  //\r
+  // 1. Check TPM_PRS_RESS with PkgLength <=63 can hold the input interrupt number buffer for patching\r
+  //\r
+  for (DataPtr  = (UINT8 *)(Table + 1);\r
+       DataPtr < (UINT8 *) ((UINT8 *) Table + Table->Length - (TPM_PRS_RES_NAME_SIZE + TPM_POS_RES_TEMPLATE_MIN_SIZE));\r
+       DataPtr += 1) {\r
+    if (CompareMem(DataPtr, TPM_PRS_RESS, TPM_PRS_RES_NAME_SIZE) == 0) {\r
+      //\r
+      // Jump over object name & BufferOp\r
+      //\r
+      DataPtr += TPM_PRS_RES_NAME_SIZE + 1;\r
+\r
+      if ((*DataPtr & (BIT7|BIT6)) == 0) {\r
+        OrignalPkgLength = (UINT32)*DataPtr;\r
+        DataEndPtr       = DataPtr + OrignalPkgLength;\r
+\r
+        //\r
+        // Jump over PkgLength = PkgLeadByte only\r
+        //\r
+        NewPkgLength++;\r
+\r
+        //\r
+        // Jump over BufferSize\r
+        //\r
+        if (*(DataPtr + 1) == AML_BYTE_PREFIX) {\r
+          NewPkgLength += 2;\r
+        } else if (*(DataPtr + 1) == AML_WORD_PREFIX) {\r
+          NewPkgLength += 3;\r
+        } else if (*(DataPtr + 1) == AML_DWORD_PREFIX) {\r
+          NewPkgLength += 5;\r
+        } else {\r
+          ASSERT(FALSE);\r
+          return EFI_UNSUPPORTED;\r
+        }\r
+      } else {\r
+        ASSERT(FALSE);\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+\r
+      //\r
+      // Include Memory32Fixed Descritor (12 Bytes) + Interrupt Descriptor header(5 Bytes) + End Tag(2 Bytes)\r
+      //\r
+      NewPkgLength += 19 + IrqBuffserSize;\r
+      if (NewPkgLength > 63) {\r
+        break;\r
+      }\r
+\r
+      if (NewPkgLength > OrignalPkgLength) {\r
+        ASSERT(FALSE);\r
+        return EFI_INVALID_PARAMETER;\r
+      }\r
+\r
+      //\r
+      // 1.1 Patch PkgLength\r
+      //\r
+      *DataPtr = (UINT8)NewPkgLength;\r
+\r
+      //\r
+      // 1.2 Patch BufferSize = sizeof(Memory32Fixed Descritor + Interrupt Descriptor + End Tag).\r
+      //      It is Little endian. So only patch lowest byte of BufferSize due to current interrupt number limit.\r
+      //\r
+      *(DataPtr + 2) = (UINT8)(IrqBuffserSize + 19);\r
+\r
+      //\r
+      // Notify _PRS to report short formed ResourceTemplate\r
+      //\r
+      mTcgNvs->IsShortFormPkgLength = TRUE;\r
+\r
+      break;\r
+    }\r
+  }\r
+\r
+  //\r
+  // 2. Use TPM_PRS_RESL with PkgLength > 63 to hold longer input interrupt number buffer for patching\r
+  //\r
+  if (NewPkgLength > 63) {\r
+    NewPkgLength     = 0;\r
+    OrignalPkgLength = 0;\r
+    for (DataPtr  = (UINT8 *)(Table + 1);\r
+         DataPtr < (UINT8 *) ((UINT8 *) Table + Table->Length - (TPM_PRS_RES_NAME_SIZE + TPM_POS_RES_TEMPLATE_MIN_SIZE));\r
+         DataPtr += 1) {\r
+      if (CompareMem(DataPtr, TPM_PRS_RESL, TPM_PRS_RES_NAME_SIZE) == 0) {\r
+        //\r
+        // Jump over object name & BufferOp\r
+        //\r
+        DataPtr += TPM_PRS_RES_NAME_SIZE + 1;\r
+\r
+        if ((*DataPtr & (BIT7|BIT6)) != 0) {\r
+          OrignalPkgLength = (UINT32)(*(DataPtr + 1) << 4) + (*DataPtr & 0x0F);\r
+          DataEndPtr       = DataPtr + OrignalPkgLength;\r
+          //\r
+          // Jump over PkgLength = PkgLeadByte + ByteData length\r
+          //\r
+          NewPkgLength += 1 + ((*DataPtr & (BIT7|BIT6)) >> 6);\r
+\r
+          //\r
+          // Jump over BufferSize\r
+          //\r
+          if (*(DataPtr + NewPkgLength) == AML_BYTE_PREFIX) {\r
+            NewPkgLength += 2;\r
+          } else if (*(DataPtr + NewPkgLength) == AML_WORD_PREFIX) {\r
+            NewPkgLength += 3;\r
+          } else if (*(DataPtr + NewPkgLength) == AML_DWORD_PREFIX) {\r
+            NewPkgLength += 5;\r
+          } else {\r
+            ASSERT(FALSE);\r
+            return EFI_UNSUPPORTED;\r
+          }\r
+        } else {\r
+          ASSERT(FALSE);\r
+          return EFI_UNSUPPORTED;\r
+        }\r
+\r
+        //\r
+        // Include Memory32Fixed Descritor (12 Bytes) + Interrupt Descriptor header(5 Bytes) + End Tag(2  Bytes)\r
+        //\r
+        NewPkgLength += 19 + IrqBuffserSize;\r
+\r
+        if (NewPkgLength > OrignalPkgLength) {\r
+          ASSERT(FALSE);\r
+          return EFI_INVALID_PARAMETER;\r
+        }\r
+\r
+        //\r
+        // 2.1 Patch PkgLength. Only patch PkgLeadByte and first ByteData\r
+        //\r
+        *DataPtr = (UINT8)((*DataPtr) & 0xF0) | (NewPkgLength & 0x0F);\r
+        *(DataPtr + 1) = (UINT8)((NewPkgLength & 0xFF0) >> 4);\r
+\r
+        //\r
+        // 2.2 Patch BufferSize = sizeof(Memory32Fixed Descritor + Interrupt Descriptor + End Tag).\r
+        //     It is Little endian. Only patch lowest byte of BufferSize due to current interrupt number limit.\r
+        //\r
+        *(DataPtr + 2 + ((*DataPtr & (BIT7|BIT6)) >> 6)) = (UINT8)(IrqBuffserSize + 19);\r
+\r
+        //\r
+        // Notify _PRS to report long formed ResourceTemplate\r
+        //\r
+        mTcgNvs->IsShortFormPkgLength = FALSE;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+\r
+  if (DataPtr >= (UINT8 *) ((UINT8 *) Table + Table->Length - (TPM_PRS_RES_NAME_SIZE + TPM_POS_RES_TEMPLATE_MIN_SIZE))) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  //\r
+  // 3. Move DataPtr to Interrupt descriptor header and patch interrupt descriptor.\r
+  //     5 bytes for interrupt descriptor header, 2 bytes for End Tag\r
+  //\r
+  DataPtr += NewPkgLength - (5 + IrqBuffserSize + 2);\r
+  //\r
+  //   3.1 Patch Length bit[7:0] of Interrupt descirptor patch interrupt descriptor\r
+  //\r
+  *(DataPtr + 1) = (UINT8)(2 + IrqBuffserSize);\r
+  //\r
+  //   3.2 Patch Interrupt Table Length\r
+  //\r
+  *(DataPtr + 4) = (UINT8)(IrqBuffserSize / sizeof(UINT32));\r
+  //\r
+  //   3.3 Copy patched InterruptNumBuffer\r
+  //\r
+  CopyMem(DataPtr + 5, IrqBuffer, IrqBuffserSize);\r
+\r
+  //\r
+  // 4. Jump over Interrupt descirptor and Patch END Tag, set Checksum field to 0\r
+  //\r
+  DataPtr       += 5 + IrqBuffserSize;\r
+  *DataPtr       = ACPI_END_TAG_DESCRIPTOR;\r
+  *(DataPtr + 1) = 0;\r
+\r
+  //\r
+  // 5. Jump over whole ResourceTemplate. Stuff rest bytes to NOOP\r
+  //\r
+  for (DataPtr += 2; DataPtr < DataEndPtr; DataPtr++) {\r
+    *DataPtr = AML_NOOP_OP;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   Patch TPM2 device HID string.  The initial string tag in TPM2 ACPI table is "NNN0000".\r
 \r
 /**\r
   Patch TPM2 device HID string.  The initial string tag in TPM2 ACPI table is "NNN0000".\r
 \r
@@ -424,6 +669,8 @@ PublishAcpiTable (
   UINTN                          TableKey;\r
   EFI_ACPI_DESCRIPTION_HEADER    *Table;\r
   UINTN                          TableSize;\r
   UINTN                          TableKey;\r
   EFI_ACPI_DESCRIPTION_HEADER    *Table;\r
   UINTN                          TableSize;\r
+  UINT32                         *PossibleIrqNumBuf;\r
+  UINT32                         PossibleIrqNumBufSize;\r
 \r
   Status = GetSectionFromFv (\r
              &gEfiCallerIdGuid,\r
 \r
   Status = GetSectionFromFv (\r
              &gEfiCallerIdGuid,\r
@@ -454,6 +701,29 @@ PublishAcpiTable (
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
+  if (PcdGet32(PcdTpm2CurrentIrqNum) != 0) {\r
+    //\r
+    // Patch _PRS interrupt resource only when TPM interrupt is supported\r
+    //\r
+    PossibleIrqNumBuf     = (UINT32 *)PcdGetPtr(PcdTpm2PossibleIrqNumBuf);\r
+    PossibleIrqNumBufSize = (UINT32)PcdGetSize(PcdTpm2PossibleIrqNumBuf);\r
+\r
+    if (PossibleIrqNumBufSize <= MAX_PRS_INT_BUF_SIZE && (PossibleIrqNumBufSize % sizeof(UINT32)) == 0) {\r
+      Status = UpdatePossibleResource(Table, PossibleIrqNumBuf, PossibleIrqNumBufSize);\r
+      DEBUG ((\r
+        DEBUG_INFO,\r
+        "UpdatePossibleResource status - %x. TPM2 service may not ready in OS.\n",\r
+        Status\r
+        ));\r
+    } else {\r
+      DEBUG ((\r
+        DEBUG_INFO,\r
+        "PcdTpm2PossibleIrqNumBuf size %x is not correct. TPM2 service may not ready in OS.\n",\r
+        PossibleIrqNumBufSize\r
+      ));\r
+    }\r
+  }\r
+\r
   //\r
   // Measure to PCR[0] with event EV_POST_CODE ACPI DATA\r
   //\r
   //\r
   // Measure to PCR[0] with event EV_POST_CODE ACPI DATA\r
   //\r
@@ -471,6 +741,8 @@ PublishAcpiTable (
   CopyMem (Table->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Table->OemId) );\r
   mTcgNvs = AssignOpRegion (Table, SIGNATURE_32 ('T', 'N', 'V', 'S'), (UINT16) sizeof (TCG_NVS));\r
   ASSERT (mTcgNvs != NULL);\r
   CopyMem (Table->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Table->OemId) );\r
   mTcgNvs = AssignOpRegion (Table, SIGNATURE_32 ('T', 'N', 'V', 'S'), (UINT16) sizeof (TCG_NVS));\r
   ASSERT (mTcgNvs != NULL);\r
+  mTcgNvs->TpmIrqNum            = PcdGet32(PcdTpm2CurrentIrqNum);\r
+  mTcgNvs->IsShortFormPkgLength = FALSE;\r
 \r
   //\r
   // Publish the TPM ACPI table. Table is re-checksumed.\r
 \r
   //\r
   // Publish the TPM ACPI table. Table is re-checksumed.\r
index 100804cf2abd3a0ec0e62696116205715c75b0fb..732452cb35de80e6e2a7d6ef2f2b332d867e9a98 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The header file for Tcg2 SMM driver.\r
   \r
 /** @file\r
   The header file for Tcg2 SMM driver.\r
   \r
-Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\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
 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
@@ -39,6 +39,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/Tcg2PhysicalPresenceLib.h>\r
 #include <Library/IoLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/Tcg2PhysicalPresenceLib.h>\r
 #include <Library/IoLib.h>\r
 #include <Library/PrintLib.h>\r
+#include <Library/PcdLib.h>\r
 \r
 #include <IndustryStandard/TpmPtp.h>\r
 \r
 \r
 #include <IndustryStandard/TpmPtp.h>\r
 \r
@@ -64,6 +65,8 @@ typedef struct {
   PHYSICAL_PRESENCE_NVS  PhysicalPresence;\r
   MEMORY_CLEAR_NVS       MemoryClear;\r
   UINT32                 PPRequestUserConfirm;\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
 } TCG_NVS;\r
 \r
 typedef struct {\r
@@ -102,4 +105,23 @@ typedef struct {
 #define TPM_HID_PNP_SIZE                                           8\r
 #define TPM_HID_ACPI_SIZE                                          9\r
 \r
 #define TPM_HID_PNP_SIZE                                           8\r
 #define TPM_HID_ACPI_SIZE                                          9\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
+\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
 #endif  // __TCG_SMM_H__\r
index c709743b4772884f7ce80db74b72f5f7ab9b6818..81f74959a420ffe60c2ae5f4ba998d208ade5577 100644 (file)
@@ -16,7 +16,7 @@
 #  This driver will have external input - variable and ACPINvs data in SMM mode.\r
 #  This external input must be validated carefully to avoid security issue.\r
 #\r
 #  This driver will have external input - variable and ACPINvs data in SMM mode.\r
 #  This external input must be validated carefully to avoid security issue.\r
 #\r
-# Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\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
 # 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
@@ -58,6 +58,7 @@
   Tpm2CommandLib\r
   Tcg2PhysicalPresenceLib\r
   IoLib\r
   Tpm2CommandLib\r
   Tcg2PhysicalPresenceLib\r
   IoLib\r
+  PcdLib\r
 \r
 [Guids]\r
   ## SOMETIMES_PRODUCES ## Variable:L"MemoryOverwriteRequestControl"\r
 \r
 [Guids]\r
   ## SOMETIMES_PRODUCES ## Variable:L"MemoryOverwriteRequestControl"\r
@@ -82,6 +83,8 @@
   gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer  ## CONSUMES\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev                 ## CONSUMES\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTpmPlatformClass                 ## SOMETIMES_CONSUMES\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer  ## CONSUMES\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev                 ## CONSUMES\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTpmPlatformClass                 ## SOMETIMES_CONSUMES\r
+  gEfiSecurityPkgTokenSpaceGuid.PcdTpm2CurrentIrqNum            ## CONSUMES\r
+  gEfiSecurityPkgTokenSpaceGuid.PcdTpm2PossibleIrqNumBuf        ## CONSUMES\r
 \r
 [Depex]\r
   gEfiAcpiTableProtocolGuid AND\r
 \r
 [Depex]\r
   gEfiAcpiTableProtocolGuid AND\r
index f52830545eda709baf7c7d1e4303d1e8d402eb5d..f58efca1443de177d451849b29ccf5535fa5c139 100644 (file)
@@ -2,7 +2,7 @@
   The TPM2 definition block in ACPI table for TCG2 physical presence  \r
   and MemoryClear.\r
 \r
   The TPM2 definition block in ACPI table for TCG2 physical presence  \r
   and MemoryClear.\r
 \r
-Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
 (c)Copyright 2016 HP Development Company, L.P.<BR>\r
 Copyright (c) 2017, Microsoft Corporation.  All rights reserved. <BR>\r
 This program and the accompanying materials \r
 (c)Copyright 2016 HP Development Company, L.P.<BR>\r
 Copyright (c) 2017, Microsoft Corporation.  All rights reserved. <BR>\r
 This program and the accompanying materials \r
@@ -92,20 +92,59 @@ DefinitionBlock (
         MCIP,   32, //   Used for save the Mor paramter\r
         MORD,   32, //   Memory Overwrite Request Data\r
         MRET,   32, //   Memory Overwrite function return code\r
         MCIP,   32, //   Used for save the Mor paramter\r
         MORD,   32, //   Memory Overwrite Request Data\r
         MRET,   32, //   Memory Overwrite function return code\r
-        UCRQ,   32  //   Phyical Presence request operation to Get User Confirmation Status \r
+        UCRQ,   32, //   Phyical Presence request operation to Get User Confirmation Status\r
+        IRQN,   32, //   IRQ Number for _CRS\r
+        SFRB,   8   //   Is shortformed Pkglength for resource buffer\r
       }\r
 \r
       }\r
 \r
-      Name(RESO, ResourceTemplate () {\r
-        Memory32Fixed (ReadWrite, 0xfed40000, 0x5000, REGS)\r
+      //\r
+      // Possible resource settings returned by  _PRS method\r
+      //   RESS : ResourceTemplate with PkgLength <=63\r
+      //   RESL : ResourceTemplate with PkgLength > 63\r
+      //\r
+      // The format of the data has to follow the same format as\r
+      // _CRS (according to ACPI spec).\r
+      //\r
+      Name (RESS, ResourceTemplate() {\r
+        Memory32Fixed (ReadWrite, 0xfed40000, 0x5000)\r
+        Interrupt(ResourceConsumer, Level, ActiveLow, Shared, , , ) {1,2,3,4,5,6,7,8,9,10}\r
+      })\r
+\r
+      Name (RESL, ResourceTemplate() {\r
+        Memory32Fixed (ReadWrite, 0xfed40000, 0x5000)\r
+        Interrupt(ResourceConsumer, Level, ActiveLow, Shared, , , ) {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}\r
+      })\r
+\r
+      //\r
+      // Current resource settings for _CRS method\r
+      //\r
+      Name(RES0, ResourceTemplate () {\r
+        Memory32Fixed (ReadWrite, 0xfed40000, 0x5000, REG0)\r
         Interrupt(ResourceConsumer, Level, ActiveLow, Shared, , , INTR) {12}\r
       })\r
 \r
         Interrupt(ResourceConsumer, Level, ActiveLow, Shared, , , INTR) {12}\r
       })\r
 \r
+      Name(RES1, ResourceTemplate () {\r
+        Memory32Fixed (ReadWrite, 0xfed40000, 0x5000, REG1)\r
+      })\r
+\r
+\r
       //\r
       // Return the resource consumed by TPM device.\r
       //\r
       Method(_CRS,0,Serialized)\r
       {\r
       //\r
       // Return the resource consumed by TPM device.\r
       //\r
       Method(_CRS,0,Serialized)\r
       {\r
-        Return(RESO)\r
+        //\r
+        // IRQNum = 0 means disable IRQ support\r
+        //\r
+        If (LEqual(IRQN, 0)) {\r
+          Return (RES1)\r
+        }\r
+        Else\r
+        {\r
+          CreateDWordField(RES0, ^INTR._INT, LIRQ)\r
+          Store(IRQN, LIRQ)\r
+          Return (RES0)\r
+        }\r
       }\r
 \r
       //\r
       }\r
 \r
       //\r
@@ -113,23 +152,34 @@ DefinitionBlock (
       // assign an interrupt number to the device. The input byte stream\r
       // has to be the same as returned by _CRS (according to ACPI spec).\r
       //\r
       // assign an interrupt number to the device. The input byte stream\r
       // has to be the same as returned by _CRS (according to ACPI spec).\r
       //\r
+      // Platform may choose to override this function with specific interrupt\r
+      // programing logic to replace FIFO/TIS SIRQ registers programing\r
+      //\r
       Method(_SRS,1,Serialized)\r
       {\r
       Method(_SRS,1,Serialized)\r
       {\r
+        //\r
+        // Do not configure Interrupt if IRQ Num is configured 0 by default\r
+        //\r
+        If (LEqual(IRQN, 0)) {\r
+          Return (0)\r
+        }\r
+\r
         //\r
         // Update resource descriptor\r
         // Use the field name to identify the offsets in the argument\r
         //\r
         // Update resource descriptor\r
         // Use the field name to identify the offsets in the argument\r
-        // buffer and RESO buffer.\r
+        // buffer and RES0 buffer.\r
         //\r
         CreateDWordField(Arg0, ^INTR._INT, IRQ0)\r
         //\r
         CreateDWordField(Arg0, ^INTR._INT, IRQ0)\r
-        CreateDWordField(RESO, ^INTR._INT, LIRQ)\r
+        CreateDWordField(RES0, ^INTR._INT, LIRQ)\r
         Store(IRQ0, LIRQ)\r
         Store(IRQ0, LIRQ)\r
+        Store(IRQ0, IRQN)\r
 \r
         CreateBitField(Arg0, ^INTR._HE, ITRG)\r
 \r
         CreateBitField(Arg0, ^INTR._HE, ITRG)\r
-        CreateBitField(RESO, ^INTR._HE, LTRG)\r
+        CreateBitField(RES0, ^INTR._HE, LTRG)\r
         Store(ITRG, LTRG)\r
 \r
         CreateBitField(Arg0, ^INTR._LL, ILVL)\r
         Store(ITRG, LTRG)\r
 \r
         CreateBitField(Arg0, ^INTR._LL, ILVL)\r
-        CreateBitField(RESO, ^INTR._LL, LLVL)\r
+        CreateBitField(RES0, ^INTR._LL, LLVL)\r
         Store(ILVL, LLVL)\r
 \r
         //\r
         Store(ILVL, LLVL)\r
 \r
         //\r
@@ -176,15 +226,25 @@ DefinitionBlock (
         }\r
       }\r
 \r
         }\r
       }\r
 \r
-      //\r
-      // Possible resource settings.\r
-      // The format of the data has to follow the same format as\r
-      // _CRS (according to ACPI spec).\r
-      //\r
-      Name (_PRS, ResourceTemplate() {\r
-        Memory32Fixed (ReadWrite, 0xfed40000, 0x5000)\r
-        Interrupt(ResourceConsumer, Level, ActiveLow, Shared, , , SIRQ) {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}\r
-      })\r
+      Method(_PRS,0,Serialized)\r
+      {\r
+        //\r
+        // IRQNum = 0 means disable IRQ support\r
+        //\r
+        If (LEqual(IRQN, 0)) {\r
+          Return (RES1)\r
+        } ElseIf(LEqual(SFRB, 0)) {\r
+          //\r
+          // Long format. Possible resources PkgLength > 63\r
+          //\r
+          Return (RESL)\r
+        } Else {\r
+          //\r
+          // Short format. Possible resources PkgLength <=63\r
+          //\r
+          Return (RESS)\r
+        }\r
+      }\r
 \r
       Method (PTS, 1, Serialized)\r
       {  \r
 \r
       Method (PTS, 1, Serialized)\r
       {  \r