]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c
SecurityPkg: SecureBootConfigDxe: Remove useless code in VFR
[mirror_edk2.git] / SecurityPkg / Library / Tpm2DeviceLibDTpm / Tpm2Tis.c
index cf85d4c7eeab818bfcaaa7a24ce135b448e6b089..b7dd57df8dd0ca121755c34ec73711c907e0bf17 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   TIS (TPM Interface Specification) functions used by dTPM2.0 library.\r
   \r
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<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
@@ -223,7 +224,6 @@ TisPcPresenceCheck (
   @retval     EFI_TIMEOUT  The register can't run into the expected status in time.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 TisPcWaitRegisterBits (\r
   IN      UINT8                     *Register,\r
   IN      UINT8                     BitSet,\r
@@ -255,7 +255,6 @@ TisPcWaitRegisterBits (
   @retval     EFI_TIMEOUT           BurstCount can't be got in time.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 TisPcReadBurstCount (\r
   IN      TIS_PC_REGISTERS_PTR      TisReg,\r
      OUT  UINT16                    *BurstCount\r
@@ -299,7 +298,6 @@ TisPcReadBurstCount (
   @retval    EFI_TIMEOUT           TPM chip can't be set to ready state in time.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 TisPcPrepareCommand (\r
   IN      TIS_PC_REGISTERS_PTR      TisReg\r
   )\r
@@ -332,7 +330,6 @@ TisPcPrepareCommand (
   @retval    EFI_TIMEOUT           Can't get the TPM control in time.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 TisPcRequestUseTpm (\r
   IN      TIS_PC_REGISTERS_PTR      TisReg\r
   )\r
@@ -367,7 +364,6 @@ TisPcRequestUseTpm (
   @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
@@ -392,29 +388,29 @@ TisTpmCommand (
   DEBUG_CODE (\r
     UINTN  DebugSize;\r
 \r
-    DEBUG ((EFI_D_INFO, "TisTpmCommand Send - "));\r
+    DEBUG ((EFI_D_VERBOSE, "Tpm2TisTpmCommand Send - "));\r
     if (SizeIn > 0x100) {\r
       DebugSize = 0x40;\r
     } else {\r
       DebugSize = SizeIn;\r
     }\r
     for (Index = 0; Index < DebugSize; Index++) {\r
-      DEBUG ((EFI_D_INFO, "%02x ", BufferIn[Index]));\r
+      DEBUG ((EFI_D_VERBOSE, "%02x ", BufferIn[Index]));\r
     }\r
     if (DebugSize != SizeIn) {\r
-      DEBUG ((EFI_D_INFO, "...... "));\r
+      DEBUG ((EFI_D_VERBOSE, "...... "));\r
       for (Index = SizeIn - 0x20; Index < SizeIn; Index++) {\r
-        DEBUG ((EFI_D_INFO, "%02x ", BufferIn[Index]));\r
+        DEBUG ((EFI_D_VERBOSE, "%02x ", BufferIn[Index]));\r
       }\r
     }\r
-    DEBUG ((EFI_D_INFO, "\n"));\r
+    DEBUG ((EFI_D_VERBOSE, "\n"));\r
   );\r
   TpmOutSize = 0;\r
 \r
   Status = TisPcPrepareCommand (TisReg);\r
   if (EFI_ERROR (Status)){\r
-    DEBUG ((DEBUG_ERROR, "Tpm is not ready for command!\n"));\r
-    return Status;\r
+    DEBUG ((DEBUG_ERROR, "Tpm2 is not ready for command!\n"));\r
+    return EFI_DEVICE_ERROR;\r
   }\r
   //\r
   // Send the command data to Tpm\r
@@ -423,7 +419,7 @@ TisTpmCommand (
   while (Index < SizeIn) {\r
     Status = TisPcReadBurstCount (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
@@ -441,7 +437,7 @@ TisTpmCommand (
              TIS_TIMEOUT_C\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "The send buffer too small!\n"));\r
+    DEBUG ((DEBUG_ERROR, "Tpm2 The send buffer too small!\n"));\r
     Status = EFI_BUFFER_TOO_SMALL;\r
     goto Exit;\r
   }\r
@@ -460,8 +456,8 @@ TisTpmCommand (
              TIS_TIMEOUT_MAX\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "Wait for Tpm response data time out!!\n"));\r
-    Status = EFI_TIMEOUT;\r
+    DEBUG ((DEBUG_ERROR, "Wait for Tpm2 response data time out!!\n"));\r
+    Status = EFI_DEVICE_ERROR;\r
     goto Exit;\r
   }\r
   //\r
@@ -472,7 +468,7 @@ TisTpmCommand (
   while (Index < sizeof (TPM2_RESPONSE_HEADER)) {\r
     Status = TisPcReadBurstCount (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
@@ -482,11 +478,11 @@ TisTpmCommand (
     }\r
   }\r
   DEBUG_CODE (\r
-    DEBUG ((EFI_D_INFO, "TisTpmCommand ReceiveHeader - "));\r
+    DEBUG ((EFI_D_VERBOSE, "TisTpmCommand ReceiveHeader - "));\r
     for (Index = 0; Index < sizeof (TPM2_RESPONSE_HEADER); Index++) {\r
-      DEBUG ((EFI_D_INFO, "%02x ", BufferOut[Index]));\r
+      DEBUG ((EFI_D_VERBOSE, "%02x ", BufferOut[Index]));\r
     }\r
-    DEBUG ((EFI_D_INFO, "\n"));\r
+    DEBUG ((EFI_D_VERBOSE, "\n"));\r
   );\r
   //\r
   // Check the reponse data header (tag,parasize and returncode )\r
@@ -494,7 +490,7 @@ TisTpmCommand (
   CopyMem (&Data16, BufferOut, sizeof (UINT16));\r
   // TPM2 should not use this RSP_COMMAND\r
   if (SwapBytes16 (Data16) == TPM_ST_RSP_COMMAND) {\r
-    DEBUG ((EFI_D_ERROR, "TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMAND));\r
+    DEBUG ((EFI_D_ERROR, "TPM2: TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMAND));\r
     Status = EFI_UNSUPPORTED;\r
     goto Exit;\r
   }\r
@@ -520,17 +516,17 @@ TisTpmCommand (
     }\r
     Status = TisPcReadBurstCount (TisReg, &BurstCount);\r
     if (EFI_ERROR (Status)) {\r
-      Status = EFI_TIMEOUT;\r
+      Status = EFI_DEVICE_ERROR;\r
       goto Exit;\r
     }\r
   }\r
 Exit:\r
   DEBUG_CODE (\r
-    DEBUG ((EFI_D_INFO, "TisTpmCommand Receive - "));\r
+    DEBUG ((EFI_D_VERBOSE, "Tpm2TisTpmCommand Receive - "));\r
     for (Index = 0; Index < TpmOutSize; Index++) {\r
-      DEBUG ((EFI_D_INFO, "%02x ", BufferOut[Index]));\r
+      DEBUG ((EFI_D_VERBOSE, "%02x ", BufferOut[Index]));\r
     }\r
-    DEBUG ((EFI_D_INFO, "\n"));\r
+    DEBUG ((EFI_D_VERBOSE, "\n"));\r
   );\r
   MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_READY);\r
   return Status;\r