TianoCore EDK2 master
Loading...
Searching...
No Matches
Tpm2Ptp.c File Reference

Go to the source code of this file.

Macros

#define PTP_TIMEOUT_MAX   (90000 * 1000)
 
#define TPMCMDBUFLENGTH   0x500
 
#define RETRY_CNT_MAX   3
 

Functions

BOOLEAN Tpm2IsPtpPresence (IN VOID *Reg)
 
EFI_STATUS PtpCrbWaitRegisterBits (IN UINT32 *Register, IN UINT32 BitSet, IN UINT32 BitClear, IN UINT32 TimeOut)
 
EFI_STATUS PtpCrbRequestUseTpm (IN PTP_CRB_REGISTERS_PTR CrbReg)
 
EFI_STATUS PtpCrbTpmCommand (IN PTP_CRB_REGISTERS_PTR CrbReg, IN UINT8 *BufferIn, IN UINT32 SizeIn, IN OUT UINT8 *BufferOut, IN OUT UINT32 *SizeOut)
 
EFI_STATUS Tpm2TisTpmCommand (IN TIS_PC_REGISTERS_PTR TisReg, IN UINT8 *BufferIn, IN UINT32 SizeIn, IN OUT UINT8 *BufferOut, IN OUT UINT32 *SizeOut)
 
EFI_STATUS TisPcRequestUseTpm (IN TIS_PC_REGISTERS_PTR TisReg)
 
TPM2_PTP_INTERFACE_TYPE Tpm2GetPtpInterface (IN VOID *Register)
 
UINT8 Tpm2GetIdleByPass (IN VOID *Register)
 
VOID DumpPtpInfo (IN VOID *Register)
 
EFI_STATUS EFIAPI DTpm2SubmitCommand (IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
 
EFI_STATUS EFIAPI DTpm2RequestUseTpm (VOID)
 

Detailed Description

PTP (Platform TPM Profile) CRB (Command Response Buffer) interface used by dTPM2.0 library.

Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
Copyright (c), Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Tpm2Ptp.c.

Macro Definition Documentation

◆ PTP_TIMEOUT_MAX

#define PTP_TIMEOUT_MAX   (90000 * 1000)

Definition at line 29 of file Tpm2Ptp.c.

◆ RETRY_CNT_MAX

#define RETRY_CNT_MAX   3

Definition at line 40 of file Tpm2Ptp.c.

◆ TPMCMDBUFLENGTH

#define TPMCMDBUFLENGTH   0x500

Definition at line 34 of file Tpm2Ptp.c.

Function Documentation

◆ DTpm2RequestUseTpm()

EFI_STATUS EFIAPI DTpm2RequestUseTpm ( VOID  )

This service requests use TPM2.

Return values
EFI_SUCCESSGet the control of TPM2 chip.
EFI_NOT_FOUNDTPM2 not found.
EFI_DEVICE_ERRORUnexpected device behavior.

Definition at line 633 of file Tpm2Ptp.c.

◆ DTpm2SubmitCommand()

EFI_STATUS EFIAPI DTpm2SubmitCommand ( IN UINT32  InputParameterBlockSize,
IN UINT8 *  InputParameterBlock,
IN OUT UINT32 *  OutputParameterBlockSize,
IN UINT8 *  OutputParameterBlock 
)

This service enables the sending of commands to the TPM2.

Parameters
[in]InputParameterBlockSizeSize of the TPM2 input parameter block.
[in]InputParameterBlockPointer to the TPM2 input parameter block.
[in,out]OutputParameterBlockSizeSize of the TPM2 output parameter block.
[in]OutputParameterBlockPointer to the TPM2 output parameter block.
Return values
EFI_SUCCESSThe command byte stream was successfully sent to the device and a response was successfully received.
EFI_DEVICE_ERRORThe command was not successfully sent to the device or a response was not successfully received from the device.
EFI_BUFFER_TOO_SMALLThe output parameter block is too small.

Definition at line 591 of file Tpm2Ptp.c.

◆ DumpPtpInfo()

VOID DumpPtpInfo ( IN VOID *  Register)

Dump PTP register information.

Parameters
[in]RegisterPointer to PTP register.

Definition at line 502 of file Tpm2Ptp.c.

◆ PtpCrbRequestUseTpm()

EFI_STATUS PtpCrbRequestUseTpm ( IN PTP_CRB_REGISTERS_PTR  CrbReg)

Get the control of TPM chip.

Parameters
[in]CrbRegPointer to CRB register.
Return values
EFI_SUCCESSGet the control of TPM chip.
EFI_INVALID_PARAMETERCrbReg is NULL.
EFI_NOT_FOUNDTPM chip doesn't exit.
EFI_TIMEOUTCan't get the TPM control in time.

Definition at line 113 of file Tpm2Ptp.c.

◆ PtpCrbTpmCommand()

EFI_STATUS PtpCrbTpmCommand ( IN PTP_CRB_REGISTERS_PTR  CrbReg,
IN UINT8 *  BufferIn,
IN UINT32  SizeIn,
IN OUT UINT8 *  BufferOut,
IN OUT UINT32 *  SizeOut 
)

Send a command to TPM for execution and return response data.

Parameters
[in]CrbRegTPM register space base address.
[in]BufferInBuffer for command data.
[in]SizeInSize of command data.
[in,out]BufferOutBuffer for response data.
[in,out]SizeOutSize of response data.
Return values
EFI_SUCCESSOperation completed successfully.
EFI_BUFFER_TOO_SMALLResponse data buffer is too small.
EFI_DEVICE_ERRORUnexpected device behavior.
EFI_UNSUPPORTEDUnsupported TPM version

Definition at line 149 of file Tpm2Ptp.c.

◆ PtpCrbWaitRegisterBits()

EFI_STATUS PtpCrbWaitRegisterBits ( IN UINT32 *  Register,
IN UINT32  BitSet,
IN UINT32  BitClear,
IN UINT32  TimeOut 
)

Check whether the value of a TPM chip register satisfies the input BIT setting.

Parameters
[in]RegisterAddress port of register to be checked.
[in]BitSetCheck these data bits are set.
[in]BitClearCheck these data bits are clear.
[in]TimeOutThe max wait time (unit MicroSecond) when checking register.
Return values
EFI_SUCCESSThe register satisfies the check bit.
EFI_TIMEOUTThe register can't run into the expected status in time.

Definition at line 80 of file Tpm2Ptp.c.

◆ TisPcRequestUseTpm()

EFI_STATUS TisPcRequestUseTpm ( IN TIS_PC_REGISTERS_PTR  TisReg)

Get the control of TPM chip by sending requestUse command TIS_PC_ACC_RQUUSE to ACCESS Register in the time of default TIS_TIMEOUT_A.

Parameters
[in]TisRegPointer to TIS register.
Return values
EFI_SUCCESSGet the control of TPM chip.
EFI_INVALID_PARAMETERTisReg is NULL.
EFI_NOT_FOUNDTPM chip doesn't exit.
EFI_TIMEOUTCan't get the TPM control in time.

Definition at line 170 of file Tpm2Tis.c.

◆ Tpm2GetIdleByPass()

UINT8 Tpm2GetIdleByPass ( IN VOID *  Register)

Return PTP CRB interface IdleByPass state.

Parameters
[in]RegisterPointer to PTP register.
Returns
PTP CRB interface IdleByPass state.

Definition at line 482 of file Tpm2Ptp.c.

◆ Tpm2GetPtpInterface()

TPM2_PTP_INTERFACE_TYPE Tpm2GetPtpInterface ( IN VOID *  Register)

Return PTP interface type.

Parameters
[in]RegisterPointer to PTP register.
Returns
PTP interface type.

Definition at line 435 of file Tpm2Ptp.c.

◆ Tpm2IsPtpPresence()

BOOLEAN Tpm2IsPtpPresence ( IN VOID *  Reg)

Check whether TPM PTP register exist.

Parameters
[in]RegPointer to PTP register.
Return values
TRUETPM PTP exists.
FALSETPM PTP is not found.

Definition at line 51 of file Tpm2Ptp.c.

◆ Tpm2TisTpmCommand()

EFI_STATUS Tpm2TisTpmCommand ( IN TIS_PC_REGISTERS_PTR  TisReg,
IN UINT8 *  BufferIn,
IN UINT32  SizeIn,
IN OUT UINT8 *  BufferOut,
IN OUT UINT32 *  SizeOut 
)

Send a command to TPM for execution and return response data.

Parameters
[in]TisRegTPM register space base address.
[in]BufferInBuffer for command data.
[in]SizeInSize of command data.
[in,out]BufferOutBuffer for response data.
[in,out]SizeOutSize of response data.
Return values
EFI_SUCCESSOperation completed successfully.
EFI_BUFFER_TOO_SMALLResponse data buffer is too small.
EFI_DEVICE_ERRORUnexpected device behavior.
EFI_UNSUPPORTEDUnsupported TPM version

Definition at line 210 of file Tpm2Tis.c.