]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c
SecurityPkg: Apply uncrustify changes
[mirror_edk2.git] / SecurityPkg / Library / Tpm2DeviceLibDTpm / Tpm2InstanceLibDTpm.c
index 5f6e163c0f2ecddc4b4b81a2f2b35c03c7f81641..7d3e4bef86052a6d79363a50bff8ddc2b4e115f6 100644 (file)
@@ -4,13 +4,7 @@
   based on platform setting.\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
@@ -22,29 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Guid/TpmInstance.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
   Dump PTP register information.\r
@@ -53,7 +25,7 @@ Tpm2GetIdleByPass (
 **/\r
 VOID\r
 DumpPtpInfo (\r
-  IN VOID *Register\r
+  IN VOID  *Register\r
   );\r
 \r
 /**\r
@@ -66,15 +38,15 @@ DumpPtpInfo (
 \r
   @retval EFI_SUCCESS            The command byte stream was successfully sent to the device and a response was successfully received.\r
   @retval EFI_DEVICE_ERROR       The command was not successfully sent to the device or a response was not successfully received from the device.\r
-  @retval EFI_BUFFER_TOO_SMALL   The output parameter block is too small. \r
+  @retval EFI_BUFFER_TOO_SMALL   The output parameter block is too small.\r
 **/\r
 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
@@ -98,8 +70,8 @@ TPM2_DEVICE_INTERFACE  mDTpm2InternalTpm2Device = {
 \r
 /**\r
   The function register DTPM2.0 instance and 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
+\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
@@ -107,9 +79,7 @@ Tpm2InstanceLibDTpmConstructor (
   VOID\r
   )\r
 {\r
-  EFI_STATUS               Status;\r
-  TPM2_PTP_INTERFACE_TYPE  PtpInterface;\r
-  UINT8                    IdleByPass;\r
+  EFI_STATUS  Status;\r
 \r
   Status = Tpm2RegisterTpm2DeviceLib (&mDTpm2InternalTpm2Device);\r
   if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {\r
@@ -117,22 +87,12 @@ Tpm2InstanceLibDTpmConstructor (
     // Unsupported means platform policy does not need this instance enabled.\r
     //\r
     if (Status == EFI_SUCCESS) {\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
-      DumpPtpInfo ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));\r
+      Status = InternalTpm2DeviceLibDTpmCommonConstructor ();\r
+      DumpPtpInfo ((VOID *)(UINTN)PcdGet64 (PcdTpmBaseAddress));\r
     }\r
+\r
     return EFI_SUCCESS;\r
   }\r
+\r
   return Status;\r
 }\r