]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / SecurityPkg / Library / Tpm2DeviceLibDTpm / Tpm2DeviceLibDTpm.c
index 815a149c3dc36976cd1e722bd9269edb1659d4d1..7cc55df4365b57242d66358e03d57a9f1cd28b96 100644 (file)
@@ -3,13 +3,7 @@
   Choosing this library means platform uses and only uses DTPM device as TPM2 engine.\r
 \r
 Copyright (c) 2013 - 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
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -19,29 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/Tpm2DeviceLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
-/**\r
-  Return PTP interface type.\r
-\r
-  @param[in] Register                Pointer to PTP register.\r
-\r
-  @return PTP interface type.\r
-**/\r
-TPM2_PTP_INTERFACE_TYPE\r
-Tpm2GetPtpInterface (\r
-  IN VOID *Register\r
-  );\r
-\r
-/**\r
-  Return PTP CRB interface IdleByPass state.\r
-\r
-  @param[in] Register                Pointer to PTP register.\r
-\r
-  @return PTP CRB interface IdleByPass state.\r
-**/\r
-UINT8\r
-Tpm2GetIdleByPass (\r
-  IN VOID *Register\r
-  );\r
+#include "Tpm2DeviceLibDTpm.h"\r
 \r
 /**\r
   This service enables the sending of commands to the TPM2.\r
@@ -58,10 +30,10 @@ Tpm2GetIdleByPass (
 EFI_STATUS\r
 EFIAPI\r
 DTpm2SubmitCommand (\r
-  IN UINT32            InputParameterBlockSize,\r
-  IN UINT8             *InputParameterBlock,\r
-  IN OUT UINT32        *OutputParameterBlockSize,\r
-  IN UINT8             *OutputParameterBlock\r
+  IN UINT32      InputParameterBlockSize,\r
+  IN UINT8       *InputParameterBlock,\r
+  IN OUT UINT32  *OutputParameterBlockSize,\r
+  IN UINT8       *OutputParameterBlock\r
   );\r
 \r
 /**\r
@@ -92,10 +64,10 @@ DTpm2RequestUseTpm (
 EFI_STATUS\r
 EFIAPI\r
 Tpm2SubmitCommand (\r
-  IN UINT32            InputParameterBlockSize,\r
-  IN UINT8             *InputParameterBlock,\r
-  IN OUT UINT32        *OutputParameterBlockSize,\r
-  IN UINT8             *OutputParameterBlock\r
+  IN UINT32      InputParameterBlockSize,\r
+  IN UINT8       *InputParameterBlock,\r
+  IN OUT UINT32  *OutputParameterBlockSize,\r
+  IN UINT8       *OutputParameterBlock\r
   )\r
 {\r
   return DTpm2SubmitCommand (\r
@@ -134,7 +106,7 @@ Tpm2RequestUseTpm (
 EFI_STATUS\r
 EFIAPI\r
 Tpm2RegisterTpm2DeviceLib (\r
-  IN TPM2_DEVICE_INTERFACE   *Tpm2Device\r
+  IN TPM2_DEVICE_INTERFACE  *Tpm2Device\r
   )\r
 {\r
   return EFI_UNSUPPORTED;\r
@@ -143,7 +115,7 @@ Tpm2RegisterTpm2DeviceLib (
 /**\r
   The function caches current active TPM interface type.\r
 \r
-  @retval EFI_SUCCESS   DTPM2.0 instance is registered, or system dose not surpport registr DTPM2.0 instance\r
+  @retval EFI_SUCCESS   DTPM2.0 instance is registered, or system does not support register DTPM2.0 instance\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -151,21 +123,5 @@ Tpm2DeviceLibConstructor (
   VOID\r
   )\r
 {\r
-  TPM2_PTP_INTERFACE_TYPE  PtpInterface;\r
-  UINT8                    IdleByPass;\r
-\r
-  //\r
-  // Cache current active TpmInterfaceType only when needed\r
-  //\r
-  if (PcdGet8(PcdActiveTpmInterfaceType) == 0xFF) {\r
-    PtpInterface = Tpm2GetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));\r
-    PcdSet8S(PcdActiveTpmInterfaceType, PtpInterface);\r
-  }\r
-\r
-  if (PcdGet8(PcdActiveTpmInterfaceType) == Tpm2PtpInterfaceCrb && PcdGet8(PcdCRBIdleByPass) == 0xFF) {\r
-    IdleByPass = Tpm2GetIdleByPass((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));\r
-    PcdSet8S(PcdCRBIdleByPass, IdleByPass);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
+  return InternalTpm2DeviceLibDTpmCommonConstructor ();\r
 }\r