]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c
SecurityPkg: Clean up source files
[mirror_edk2.git] / SecurityPkg / Library / Tpm2DeviceLibDTpm / Tpm2DeviceLibDTpm.c
index 3feb64df7edfde5f1c0ac987f7e69018980818e6..815a149c3dc36976cd1e722bd9269edb1659d4d1 100644 (file)
@@ -31,6 +31,18 @@ Tpm2GetPtpInterface (
   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
+\r
 /**\r
   This service enables the sending of commands to the TPM2.\r
 \r
@@ -41,7 +53,7 @@ Tpm2GetPtpInterface (
 \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
@@ -75,7 +87,7 @@ DTpm2RequestUseTpm (
 \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
@@ -130,7 +142,7 @@ Tpm2RegisterTpm2DeviceLib (
 \r
 /**\r
   The function caches current active TPM interface type.\r
-  \r
+\r
   @retval EFI_SUCCESS   DTPM2.0 instance is registered, or system dose not surpport registr DTPM2.0 instance\r
 **/\r
 EFI_STATUS\r
@@ -140,6 +152,7 @@ Tpm2DeviceLibConstructor (
   )\r
 {\r
   TPM2_PTP_INTERFACE_TYPE  PtpInterface;\r
+  UINT8                    IdleByPass;\r
 \r
   //\r
   // Cache current active TpmInterfaceType only when needed\r
@@ -148,5 +161,11 @@ Tpm2DeviceLibConstructor (
     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
 }\r