/** @file
TIS (TPM Interface Specification) functions used by TPM PEI driver.
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <IndustryStandard/Tpm12.h>
#include <IndustryStandard/UefiTcgPlatform.h>
#include <Library/TpmCommLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
/**
Send a command to TPM for execution and return response data.
@param[in] PeiServices Describes the list of possible PEI Services.
@param[in] TisReg TPM register space base address.
@param[in] BufferIn Buffer for command data.
@param[in] SizeIn Size of command data.
@param[in, out] BufferOut Buffer for response data.
@param[in, out] SizeOut Size of response data.
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_TIMEOUT The register can't run into the expected status in time.
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
@retval EFI_DEVICE_ERROR Unexpected device behavior.
**/
)
{
return Status;
}
//
// Send the command data to Tpm
//
Index = 0;
goto Exit;
}
Index++;
}
}
//
// Check the Tpm status STS_EXPECT change from 1 to 0
//
);
goto Exit;
}
//
// Executed the TPM command and waiting for the response data ready
//
0,
);
goto Exit;
}
//
// Get response data header
//
Index = 0;
BurstCount = 0;
while (Index < sizeof (TPM_RSP_COMMAND_HDR)) {
goto Exit;
}
for (; BurstCount > 0; BurstCount--) {
Index++;
if (Index == sizeof (TPM_RSP_COMMAND_HDR)) break;
}
}
//
// Check the reponse data header (tag,parasize and returncode )
//
goto Exit;
}
if (*SizeOut < TpmOutSize) {
goto Exit;
}
*SizeOut = TpmOutSize;
//
// Continue reading the remaining data
//
while ( Index < TpmOutSize ) {
for (; BurstCount > 0; BurstCount--) {
Index++;
if (Index == TpmOutSize) {
goto Exit;
}
}
goto Exit;
}
}
Exit:
return Status;
}