/** @file\r
TIS (TPM Interface Specification) functions used by dTPM2.0 library.\r
\r
-Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2018, 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
TIS_TIMEOUT_MAX\r
);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_ERROR, "Wait for Tpm2 response data time out!!\n"));\r
- Status = EFI_DEVICE_ERROR;\r
- goto Exit;\r
+ //\r
+ // dataAvail check timeout. Cancel the currently executing command by writing commandCancel,\r
+ // Expect TPM_RC_CANCELLED or successfully completed response.\r
+ //\r
+ DEBUG ((DEBUG_ERROR, "Wait for Tpm2 response data time out. Trying to cancel the command!!\n"));\r
+\r
+ MmioWrite32((UINTN)&TisReg->Status, TIS_PC_STS_CANCEL);\r
+ Status = TisPcWaitRegisterBits (\r
+ &TisReg->Status,\r
+ (UINT8) (TIS_PC_VALID | TIS_PC_STS_DATA),\r
+ 0,\r
+ TIS_TIMEOUT_B\r
+ );\r
+ //\r
+ // Do not clear CANCEL bit here bicoz Writes of 0 to this bit are ignored\r
+ //\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Cancel executing command fail to get any response\r
+ // Try to abort the command with write of a 1 to commandReady in Command Execution state\r
+ //\r
+ Status = EFI_DEVICE_ERROR;\r
+ goto Exit;\r
+ }\r
}\r
+\r
//\r
// Get response data header\r
//\r