]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c
Handle TPM device error and avoid deadloop in BDS.
[mirror_edk2.git] / SecurityPkg / Library / Tpm12DeviceLibDTpm / Tpm12Tis.c
index 2ad5345927661d1d343e044140f4ac9d21f526fb..2fb360fa12c918d7d8772c3bf5e02d9fc8816cfd 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   TIS (TPM Interface Specification) functions used by TPM1.2.\r
   \r
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2015, 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
@@ -217,7 +217,6 @@ Tpm12TisPcPresenceCheck (
   @retval     EFI_TIMEOUT  The register can't run into the expected status in time.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 Tpm12TisPcWaitRegisterBits (\r
   IN      UINT8                     *Register,\r
   IN      UINT8                     BitSet,\r
@@ -249,7 +248,6 @@ Tpm12TisPcWaitRegisterBits (
   @retval     EFI_TIMEOUT           BurstCount can't be got in time.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 Tpm12TisPcReadBurstCount (\r
   IN      TIS_PC_REGISTERS_PTR      TisReg,\r
      OUT  UINT16                    *BurstCount\r
@@ -293,7 +291,6 @@ Tpm12TisPcReadBurstCount (
   @retval    EFI_TIMEOUT           TPM chip can't be set to ready state in time.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 Tpm12TisPcPrepareCommand (\r
   IN      TIS_PC_REGISTERS_PTR      TisReg\r
   )\r
@@ -326,7 +323,6 @@ Tpm12TisPcPrepareCommand (
   @retval    EFI_TIMEOUT           Can't get the TPM control in time.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 Tpm12TisPcRequestUseTpm (\r
   IN      TIS_PC_REGISTERS_PTR      TisReg\r
   )\r
@@ -361,7 +357,6 @@ Tpm12TisPcRequestUseTpm (
   @param[in, out] SizeOut       Size of response data.  \r
  \r
   @retval EFI_SUCCESS           Operation completed successfully.\r
-  @retval EFI_TIMEOUT           The register can't run into the expected status in time.\r
   @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.\r
   @retval EFI_DEVICE_ERROR      Unexpected device behavior.\r
   @retval EFI_UNSUPPORTED       Unsupported TPM version\r
@@ -408,7 +403,7 @@ Tpm12TisTpmCommand (
   Status = Tpm12TisPcPrepareCommand (TisReg);\r
   if (EFI_ERROR (Status)){\r
     DEBUG ((DEBUG_ERROR, "Tpm12 is not ready for command!\n"));\r
-    return Status;\r
+    return EFI_DEVICE_ERROR;\r
   }\r
   //\r
   // Send the command data to Tpm\r
@@ -417,7 +412,7 @@ Tpm12TisTpmCommand (
   while (Index < SizeIn) {\r
     Status = Tpm12TisPcReadBurstCount (TisReg, &BurstCount);\r
     if (EFI_ERROR (Status)) {\r
-      Status = EFI_TIMEOUT;\r
+      Status = EFI_DEVICE_ERROR;\r
       goto Exit;\r
     }\r
     for (; BurstCount > 0 && Index < SizeIn; BurstCount--) {\r
@@ -451,7 +446,7 @@ Tpm12TisTpmCommand (
              );\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "Wait for Tpm12 response data time out!!\n"));\r
-    Status = EFI_TIMEOUT;\r
+    Status = EFI_DEVICE_ERROR;\r
     goto Exit;\r
   }\r
   //\r
@@ -462,7 +457,7 @@ Tpm12TisTpmCommand (
   while (Index < sizeof (TPM_RSP_COMMAND_HDR)) {\r
     Status = Tpm12TisPcReadBurstCount (TisReg, &BurstCount);\r
     if (EFI_ERROR (Status)) {\r
-      Status = EFI_TIMEOUT;\r
+      Status = EFI_DEVICE_ERROR;\r
       goto Exit;\r
     }\r
     for (; BurstCount > 0; BurstCount--) {\r
@@ -509,7 +504,7 @@ Tpm12TisTpmCommand (
     }\r
     Status = Tpm12TisPcReadBurstCount (TisReg, &BurstCount);\r
     if (EFI_ERROR (Status)) {\r
-      Status = EFI_TIMEOUT;\r
+      Status = EFI_DEVICE_ERROR;\r
       goto Exit;\r
     }\r
   }\r