TianoCore EDK2 master
Loading...
Searching...
No Matches
TpmCommLib.h File Reference

Go to the source code of this file.

Data Structures

struct  TIS_PC_REGISTERS
 

Macros

#define TPM_BASE_ADDRESS   0xfed40000
 
#define TCG_PLATFORM_TYPE_CLIENT   0
 
#define TCG_PLATFORM_TYPE_SERVER   1
 
#define TIS_PC_VALID   BIT7
 
#define TIS_PC_ACC_ACTIVE   BIT5
 
#define TIS_PC_ACC_SEIZED   BIT4
 
#define TIS_PC_ACC_SEIZE   BIT3
 
#define TIS_PC_ACC_PENDIND   BIT2
 
#define TIS_PC_ACC_RQUUSE   BIT1
 
#define TIS_PC_ACC_ESTABLISH   BIT0
 
#define TIS_PC_STS_READY   BIT6
 
#define TIS_PC_STS_GO   BIT5
 
#define TIS_PC_STS_DATA   BIT4
 
#define TIS_PC_STS_EXPECT   BIT3
 
#define TIS_PC_STS_RETRY   BIT1
 
#define TIS_TIMEOUT_A   750 * 1000
 
#define TIS_TIMEOUT_B   2000 * 1000
 
#define TIS_TIMEOUT_C   750 * 1000
 
#define TIS_TIMEOUT_D   750 * 1000
 
#define TPMCMDBUFLENGTH   1024
 

Typedefs

typedef EFI_HANDLE TIS_TPM_HANDLE
 
typedef TIS_PC_REGISTERSTIS_PC_REGISTERS_PTR
 

Functions

EFI_STATUS EFIAPI TisPcWaitRegisterBits (IN UINT8 *Register, IN UINT8 BitSet, IN UINT8 BitClear, IN UINT32 TimeOut)
 
EFI_STATUS EFIAPI TisPcReadBurstCount (IN TIS_PC_REGISTERS_PTR TisReg, OUT UINT16 *BurstCount)
 
EFI_STATUS EFIAPI TisPcPrepareCommand (IN TIS_PC_REGISTERS_PTR TisReg)
 
EFI_STATUS EFIAPI TisPcRequestUseTpm (IN TIS_PC_REGISTERS_PTR TisReg)
 
EFI_STATUS EFIAPI TpmCommHashAll (IN CONST UINT8 *Data, IN UINTN DataLen, OUT TPM_DIGEST *Digest)
 

Detailed Description

This library is only intended to be used by TPM modules. It provides basic TPM Interface Specification (TIS) and Command functions.

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

Definition in file TpmCommLib.h.

Macro Definition Documentation

◆ TCG_PLATFORM_TYPE_CLIENT

#define TCG_PLATFORM_TYPE_CLIENT   0

Definition at line 118 of file TpmCommLib.h.

◆ TCG_PLATFORM_TYPE_SERVER

#define TCG_PLATFORM_TYPE_SERVER   1

Definition at line 119 of file TpmCommLib.h.

◆ TIS_PC_ACC_ACTIVE

#define TIS_PC_ACC_ACTIVE   BIT5

Indicate that this locality is active.

Definition at line 132 of file TpmCommLib.h.

◆ TIS_PC_ACC_ESTABLISH

#define TIS_PC_ACC_ESTABLISH   BIT0

A value of 1 indicates that a T/OS has not been established on the platform

Definition at line 155 of file TpmCommLib.h.

◆ TIS_PC_ACC_PENDIND

#define TIS_PC_ACC_PENDIND   BIT2

When this bit is 1, another locality is requesting usage of the TPM.

Definition at line 147 of file TpmCommLib.h.

◆ TIS_PC_ACC_RQUUSE

#define TIS_PC_ACC_RQUUSE   BIT1

Set to 1 to indicate that this locality is requesting to use TPM.

Definition at line 151 of file TpmCommLib.h.

◆ TIS_PC_ACC_SEIZE

#define TIS_PC_ACC_SEIZE   BIT3

Set to 1 to indicate that TPM MUST reset the TIS_PC_ACC_ACTIVE bit and remove ownership for localities less than the locality that is writing this bit.

Definition at line 143 of file TpmCommLib.h.

◆ TIS_PC_ACC_SEIZED

#define TIS_PC_ACC_SEIZED   BIT4

Set to 1 to indicate that this locality had the TPM taken away while this locality had the TIS_PC_ACC_ACTIVE bit set.

Definition at line 137 of file TpmCommLib.h.

◆ TIS_PC_STS_DATA

#define TIS_PC_STS_DATA   BIT4

This bit indicates that the TPM has data available as a response.

Definition at line 169 of file TpmCommLib.h.

◆ TIS_PC_STS_EXPECT

#define TIS_PC_STS_EXPECT   BIT3

The TPM sets this bit to a value of 1 when it expects another byte of data for a command.

Definition at line 173 of file TpmCommLib.h.

◆ TIS_PC_STS_GO

#define TIS_PC_STS_GO   BIT5

Write a 1 to this bit to cause the TPM to execute that command.

Definition at line 165 of file TpmCommLib.h.

◆ TIS_PC_STS_READY

#define TIS_PC_STS_READY   BIT6

When this bit is 1, TPM is in the Ready state, indicating it is ready to receive a new command.

Definition at line 161 of file TpmCommLib.h.

◆ TIS_PC_STS_RETRY

#define TIS_PC_STS_RETRY   BIT1

Writes a 1 to this bit to force the TPM to re-send the response.

Definition at line 177 of file TpmCommLib.h.

◆ TIS_PC_VALID

#define TIS_PC_VALID   BIT7

This bit is a 1 to indicate that the other bits in this register are valid.

Definition at line 128 of file TpmCommLib.h.

◆ TIS_TIMEOUT_A

#define TIS_TIMEOUT_A   750 * 1000

Definition at line 182 of file TpmCommLib.h.

◆ TIS_TIMEOUT_B

#define TIS_TIMEOUT_B   2000 * 1000

Definition at line 183 of file TpmCommLib.h.

◆ TIS_TIMEOUT_C

#define TIS_TIMEOUT_C   750 * 1000

Definition at line 184 of file TpmCommLib.h.

◆ TIS_TIMEOUT_D

#define TIS_TIMEOUT_D   750 * 1000

Definition at line 185 of file TpmCommLib.h.

◆ TPM_BASE_ADDRESS

#define TPM_BASE_ADDRESS   0xfed40000

TPM register base address.

Definition at line 20 of file TpmCommLib.h.

◆ TPMCMDBUFLENGTH

#define TPMCMDBUFLENGTH   1024

Definition at line 190 of file TpmCommLib.h.

Typedef Documentation

◆ TIS_PC_REGISTERS_PTR

Definition at line 113 of file TpmCommLib.h.

◆ TIS_TPM_HANDLE

typedef EFI_HANDLE TIS_TPM_HANDLE

Definition at line 15 of file TpmCommLib.h.

Function Documentation

◆ TisPcPrepareCommand()

EFI_STATUS EFIAPI TisPcPrepareCommand ( IN TIS_PC_REGISTERS_PTR  TisReg)

Set TPM chip to ready state by sending ready command TIS_PC_STS_READY to Status Register in time.

Parameters
[in]TisRegPointer to TIS register.
Return values
EFI_SUCCESSTPM chip enters into ready state.
EFI_INVALID_PARAMETERTisReg is NULL.
EFI_TIMEOUTTPM chip can't be set to ready state in time.

Definition at line 138 of file Tpm2Tis.c.

◆ TisPcReadBurstCount()

EFI_STATUS EFIAPI TisPcReadBurstCount ( IN TIS_PC_REGISTERS_PTR  TisReg,
OUT UINT16 *  BurstCount 
)

Get BurstCount by reading the burstCount field of a TIS register in the time of default TIS_TIMEOUT_D.

Parameters
[in]TisRegPointer to TIS register.
[out]BurstCountPointer to a buffer to store the got BurstCount.
Return values
EFI_SUCCESSGet BurstCount.
EFI_INVALID_PARAMETERTisReg is NULL or BurstCount is NULL.
EFI_TIMEOUTBurstCount can't be got in time.

Definition at line 94 of file Tpm2Tis.c.

◆ TisPcRequestUseTpm()

EFI_STATUS EFIAPI 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_D.

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.

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.

◆ TisPcWaitRegisterBits()

EFI_STATUS EFIAPI TisPcWaitRegisterBits ( IN UINT8 *  Register,
IN UINT8  BitSet,
IN UINT8  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 60 of file Tpm2Tis.c.

◆ TpmCommHashAll()

EFI_STATUS EFIAPI TpmCommHashAll ( IN CONST UINT8 *  Data,
IN UINTN  DataLen,
OUT TPM_DIGEST Digest 
)

Single function calculates SHA1 digest value for all raw data. It combines Sha1Init(), Sha1Update() and Sha1Final().

Parameters
[in]DataRaw data to be digested.
[in]DataLenSize of the raw data.
[out]DigestPointer to a buffer that stores the final digest.
Return values
EFI_SUCCESSAlways successfully calculate the final digest.

Definition at line 23 of file TpmComm.c.