diff options
author | Yao, Jiewen <jiewen.yao@intel.com> | 2016-01-27 12:15:59 +0000 |
---|---|---|
committer | jyao1 <jyao1@Edk2> | 2016-01-27 12:15:59 +0000 |
commit | e4780913e5a2c0699f368a79ca3ff1c951053e88 (patch) | |
tree | bd7ed14711c4cd1381dc27f0c08b6a19a3d9c349 /SecurityPkg/Library | |
parent | 1a4acc11360a89ada7cda08d4b4757855bbc4f16 (diff) | |
download | edk2-e4780913e5a2c0699f368a79ca3ff1c951053e88.tar.gz edk2-e4780913e5a2c0699f368a79ca3ff1c951053e88.tar.bz2 edk2-e4780913e5a2c0699f368a79ca3ff1c951053e88.zip |
SecurityPkg: Add TPM PTP detection in Tpm12SubmitCommand.
Previously, we only add PTP detection in Tpm12RequestUseTpm,
because RequestUseTpm does not check TPM command.
This patch also adds similar check in Tpm12SubmitCommand.
PTP device does not accept TPM12 command, so that it can
return error on PTP device, instead of wait till timeout.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <jiewen.yao@intel.com>
Reviewed-by: "Zhang, Chao B" <chao.b.zhang@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19755 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SecurityPkg/Library')
-rw-r--r-- | SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c | 99 |
1 files changed, 58 insertions, 41 deletions
diff --git a/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c b/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c index eaaf065245..4e04299f23 100644 --- a/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c +++ b/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c @@ -58,6 +58,44 @@ Tpm12TisPcPresenceCheck ( }
/**
+ Return PTP interface type.
+
+ @param[in] Register Pointer to PTP register.
+
+ @return PTP interface type.
+**/
+PTP_INTERFACE_TYPE
+Tpm12GetPtpInterface (
+ IN VOID *Register
+ )
+{
+ PTP_CRB_INTERFACE_IDENTIFIER InterfaceId;
+ PTP_FIFO_INTERFACE_CAPABILITY InterfaceCapability;
+
+ if (!Tpm12TisPcPresenceCheck (Register)) {
+ return PtpInterfaceMax;
+ }
+ //
+ // Check interface id
+ //
+ InterfaceId.Uint32 = MmioRead32 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->InterfaceId);
+ InterfaceCapability.Uint32 = MmioRead32 ((UINTN)&((PTP_FIFO_REGISTERS *)Register)->InterfaceCapability);
+
+ if ((InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_CRB) &&
+ (InterfaceId.Bits.InterfaceVersion == PTP_INTERFACE_IDENTIFIER_INTERFACE_VERSION_CRB) &&
+ (InterfaceId.Bits.CapCRB != 0)) {
+ return PtpInterfaceCrb;
+ }
+ if ((InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_FIFO) &&
+ (InterfaceId.Bits.InterfaceVersion == PTP_INTERFACE_IDENTIFIER_INTERFACE_VERSION_FIFO) &&
+ (InterfaceId.Bits.CapFIFO != 0) &&
+ (InterfaceCapability.Bits.InterfaceVersion == INTERFACE_CAPABILITY_INTERFACE_VERSION_PTP)) {
+ return PtpInterfaceFifo;
+ }
+ return PtpInterfaceTis;
+}
+
+/**
Check whether the value of a TPM chip register satisfies the input BIT setting.
@param[in] Register Address port of register to be checked.
@@ -393,51 +431,30 @@ Tpm12SubmitCommand ( IN UINT8 *OutputParameterBlock
)
{
- return Tpm12TisTpmCommand (
- (TIS_PC_REGISTERS_PTR) (UINTN) PcdGet64 (PcdTpmBaseAddress),
- InputParameterBlock,
- InputParameterBlockSize,
- OutputParameterBlock,
- OutputParameterBlockSize
- );
-}
-
-/**
- Return PTP interface type.
-
- @param[in] Register Pointer to PTP register.
-
- @return PTP interface type.
-**/
-PTP_INTERFACE_TYPE
-Tpm12GetPtpInterface (
- IN VOID *Register
- )
-{
- PTP_CRB_INTERFACE_IDENTIFIER InterfaceId;
- PTP_FIFO_INTERFACE_CAPABILITY InterfaceCapability;
+ PTP_INTERFACE_TYPE PtpInterface;
- if (!Tpm12TisPcPresenceCheck (Register)) {
- return PtpInterfaceMax;
- }
//
- // Check interface id
+ // Special handle for TPM1.2 to check PTP too, because PTP/TIS share same register address.
//
- InterfaceId.Uint32 = MmioRead32 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->InterfaceId);
- InterfaceCapability.Uint32 = MmioRead32 ((UINTN)&((PTP_FIFO_REGISTERS *)Register)->InterfaceCapability);
-
- if ((InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_CRB) &&
- (InterfaceId.Bits.InterfaceVersion == PTP_INTERFACE_IDENTIFIER_INTERFACE_VERSION_CRB) &&
- (InterfaceId.Bits.CapCRB != 0)) {
- return PtpInterfaceCrb;
- }
- if ((InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_FIFO) &&
- (InterfaceId.Bits.InterfaceVersion == PTP_INTERFACE_IDENTIFIER_INTERFACE_VERSION_FIFO) &&
- (InterfaceId.Bits.CapFIFO != 0) &&
- (InterfaceCapability.Bits.InterfaceVersion == INTERFACE_CAPABILITY_INTERFACE_VERSION_PTP)) {
- return PtpInterfaceFifo;
+ PtpInterface = Tpm12GetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));
+ switch (PtpInterface) {
+ case PtpInterfaceFifo:
+ case PtpInterfaceTis:
+ return Tpm12TisTpmCommand (
+ (TIS_PC_REGISTERS_PTR) (UINTN) PcdGet64 (PcdTpmBaseAddress),
+ InputParameterBlock,
+ InputParameterBlockSize,
+ OutputParameterBlock,
+ OutputParameterBlockSize
+ );
+ case PtpInterfaceCrb:
+ //
+ // No need to support CRB because it is only accept TPM2 command.
+ //
+ default:
+ return EFI_DEVICE_ERROR;
}
- return PtpInterfaceTis;
+
}
/**
|