spips
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Groups Pages
Xspips_tpm_polled_example

Macros

#define TPM_SPI_SELECT   0x00
 TPM slave select. More...
 
#define XSPIPS_TPM_ACCESS   0x0000
 TPM access register. More...
 
#define XSPIPS_TPM_STS   0x0018
 TPM status register. More...
 
#define XSPIPS_TPM_DATA_FIFO   0x0024
 TPM data FIFO register. More...
 
#define XSPIPS_TPM_DID_VID   0x0F00
 TPM DID/VID register. More...
 
#define XSPIPS_TPM_RID   0x0F04
 TPM revision ID register. More...
 
#define XSPIPS_TPM_ACCESS_VALID   0x80
 Access valid bit. More...
 
#define XSPIPS_TPM_ACCESS_ACT_LOCAL   0x20
 Active locality bit. More...
 
#define XSPIPS_TPM_ACCESS_REQ_PEND   0x04
 Pending request bit. More...
 
#define XSPIPS_TPM_ACCESS_REQ_USE   0x02
 Request use bit. More...
 
#define XSPIPS_TPM_STS_VALID   0x80
 Status valid bit. More...
 
#define XSPIPS_TPM_STS_CMD_READY   0x40
 Command ready bit. More...
 
#define XSPIPS_TPM_STS_GO   0x20
 TPM go bit. More...
 
#define XSPIPS_TPM_STS_DATA_AVAIL   0x10
 Data available bit. More...
 
#define XSPIPS_TPM_STS_DATA_EXPECT   0x08
 Data expected bit. More...
 
#define XSPIPS_TPM_TX_HEAD_SIZE   4
 SPI request header size. More...
 
#define XSPIPS_TPM_RX_HEAD_SIZE   10
 TPM response header size. More...
 
#define XSPIPS_TPM_SPI_MAX_SIZE   64
 Max bytes per SPI transfer. More...
 
#define XSPIPS_TPM2_CMD_SELFTEST   0x01
 Selftest menu option. More...
 
#define XSPIPS_TPM2_CMD_STARTUP   0x02
 Startup menu option. More...
 
#define XSPIPS_TPM2_CMD_PCR_READ   0x03
 PCR read menu option. More...
 
#define XSPIPS_TPM2_CMD_PCR_RESET   0x04
 PCR reset menu option. More...
 
#define XSPIPS_TPM2_CMD_PCR_EXTEND   0x05
 PCR extend menu option. More...
 
#define XSPIPS_EXIT_CMD_LOOP   0x06
 Exit menu option. More...
 
#define XSPIPS_TPM_PCR_EXT_CMD_SIZE   33
 Size of the PCR extend command without the digest. More...
 
#define XSPIPS_TPM_SHA1_DIGEST_SIZE   20
 SHA1 digest size. More...
 
#define XSPIPS_TPM_SHA256_DIGEST_SIZE   32
 SHA256 digest size. More...
 
#define XSPIPS_TPM_RESP_MAX_SIZE   4096
 Maximum possible TPM response size in bytes. More...
 
#define XSPIPS_TPM_REQ_MAX_SIZE   1024
 Maximum possible TPM request size in bytes. More...
 

Functions

int SpiPsReadID (XSpiPs *SpiPtr)
 Reads vendor identification information. More...
 
int SpiPsTpmStatusGet (XSpiPs *SpiPtr, u8 *StatusPtr)
 Gets TPM status. More...
 
int SpiPsTpmStatusSet (XSpiPs *SpiPtr, u8 StatusVal)
 Sets the TPM status. More...
 
int SpiPsTpmAccessGet (XSpiPs *SpiPtr, u8 *AccessPtr)
 Gets TPM access configuration. More...
 
int SpiPsTpmAccessSet (XSpiPs *SpiPtr, u8 Access)
 Sets TPM access configuration. More...
 
int SpiPsTpmFifoRead (XSpiPs *SpiPtr, u8 *DataPtr, u8 ByteCount)
 Reads data from TPM FIFO. More...
 
int SpiPsTpmFifoWrite (XSpiPs *SpiPtr, u8 *DataPtr, u8 ByteCount)
 Writes the data to the TPM FIFO. More...
 
int SpiPsTpmTransfer (XSpiPs *SpiPtr, u32 Address, u8 *TxBuf, u8 *RxBuf, u16 Length)
 Transfers data to or from a TPM register. More...
 
int SpiPsTpmDataTransfer (XSpiPs *SpiPtr, u8 *TxBuf, u8 *RxBuf, u16 Txlen)
 Sends a TPM command and reads the TPM response. More...
 
int SpiPsTpmPolledExample (XSpiPs *SpiInstancePtr, UINTPTR BaseAddress)
 Illustrates how to use the XSpiPs device driver in polled mode with a TPM device. More...
 
int main (void)
 Calls the SPI TPM example. More...
 

Variables

u8 TpmTxBuffer [XSPIPS_TPM_REQ_MAX_SIZE+XSPIPS_TPM_TX_HEAD_SIZE]
 Buffer for the data sent on the SPI bus. More...
 
u8 TpmRxBuffer [XSPIPS_TPM_RESP_MAX_SIZE+XSPIPS_TPM_TX_HEAD_SIZE]
 Buffer for the data received on the SPI bus. More...
 
u8 TpmRespBuffer [XSPIPS_TPM_RESP_MAX_SIZE]
 Buffer for the TPM command response. More...
 

Macro Definition Documentation

#define TPM_SPI_SELECT   0x00

TPM slave select.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_EXIT_CMD_LOOP   0x06

Exit menu option.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM2_CMD_PCR_EXTEND   0x05

PCR extend menu option.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM2_CMD_PCR_READ   0x03

PCR read menu option.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM2_CMD_PCR_RESET   0x04

PCR reset menu option.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM2_CMD_SELFTEST   0x01

Selftest menu option.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM2_CMD_STARTUP   0x02

Startup menu option.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM_ACCESS   0x0000

TPM access register.

Referenced by SpiPsTpmAccessGet(), and SpiPsTpmAccessSet().

#define XSPIPS_TPM_ACCESS_ACT_LOCAL   0x20

Active locality bit.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM_ACCESS_REQ_PEND   0x04

Pending request bit.

#define XSPIPS_TPM_ACCESS_REQ_USE   0x02

Request use bit.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM_ACCESS_VALID   0x80

Access valid bit.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM_DATA_FIFO   0x0024

TPM data FIFO register.

Referenced by SpiPsTpmFifoRead(), and SpiPsTpmFifoWrite().

#define XSPIPS_TPM_DID_VID   0x0F00

TPM DID/VID register.

Referenced by SpiPsReadID().

#define XSPIPS_TPM_PCR_EXT_CMD_SIZE   33

Size of the PCR extend command without the digest.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM_REQ_MAX_SIZE   1024

Maximum possible TPM request size in bytes.

#define XSPIPS_TPM_RESP_MAX_SIZE   4096

Maximum possible TPM response size in bytes.

Referenced by SpiPsTpmDataTransfer().

#define XSPIPS_TPM_RID   0x0F04

TPM revision ID register.

Referenced by SpiPsReadID().

#define XSPIPS_TPM_RX_HEAD_SIZE   10

TPM response header size.

Referenced by SpiPsTpmDataTransfer().

#define XSPIPS_TPM_SHA1_DIGEST_SIZE   20

SHA1 digest size.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM_SHA256_DIGEST_SIZE   32

SHA256 digest size.

Referenced by SpiPsTpmPolledExample().

#define XSPIPS_TPM_SPI_MAX_SIZE   64

Max bytes per SPI transfer.

Referenced by SpiPsTpmTransfer().

#define XSPIPS_TPM_STS   0x0018

TPM status register.

Referenced by SpiPsTpmStatusGet(), and SpiPsTpmStatusSet().

#define XSPIPS_TPM_STS_CMD_READY   0x40

Command ready bit.

Referenced by SpiPsTpmDataTransfer().

#define XSPIPS_TPM_STS_DATA_AVAIL   0x10

Data available bit.

Referenced by SpiPsTpmDataTransfer().

#define XSPIPS_TPM_STS_DATA_EXPECT   0x08

Data expected bit.

#define XSPIPS_TPM_STS_GO   0x20

TPM go bit.

Referenced by SpiPsTpmDataTransfer().

#define XSPIPS_TPM_STS_VALID   0x80

Status valid bit.

Referenced by SpiPsTpmDataTransfer().

#define XSPIPS_TPM_TX_HEAD_SIZE   4

SPI request header size.

Referenced by SpiPsTpmTransfer().

Function Documentation

int main ( void  )

Calls the SPI TPM example.

Returns
XST_SUCCESS if successful, otherwise XST_FAILURE.

References SpiPsTpmPolledExample().

int SpiPsReadID ( XSpiPs *  SpiPtr)

Reads vendor identification information.

Parameters
[in,out]SpiPtrPointer to the SPIPS driver component to use.
Returns
XST_SUCCESS if successful, else XST_FAILURE.

References SpiPsTpmTransfer(), XSPIPS_TPM_DID_VID, and XSPIPS_TPM_RID.

Referenced by SpiPsTpmPolledExample().

int SpiPsTpmAccessGet ( XSpiPs *  SpiPtr,
u8 *  AccessPtr 
)

Gets TPM access configuration.

Parameters
[in,out]SpiPtrPointer to the SPIPS driver component to use.
[out]AccessPtrPointer to get access configuration.
Returns
XST_SUCCESS if successful, else XST_FAILURE.

References SpiPsTpmTransfer(), and XSPIPS_TPM_ACCESS.

Referenced by SpiPsTpmPolledExample().

int SpiPsTpmAccessSet ( XSpiPs *  SpiPtr,
u8  Access 
)

Sets TPM access configuration.

Parameters
[in,out]SpiPtrPointer to the SPIPS driver component to use.
[in]AccessAccess configuration value to set.
Returns
XST_SUCCESS if successful, else XST_FAILURE.

References SpiPsTpmTransfer(), and XSPIPS_TPM_ACCESS.

Referenced by SpiPsTpmPolledExample().

int SpiPsTpmDataTransfer ( XSpiPs *  SpiPtr,
u8 *  TxBuf,
u8 *  RxBuf,
u16  Txlen 
)

Sends a TPM command and reads the TPM response.

The command is written to the TPM data FIFO and the response is read back once the TPM reports that data is available.

Parameters
[in,out]SpiPtrPointer to the SPIPS driver component to use.
[in]TxBufPointer to transmit buffer.
[in,out]RxBufPointer to receive buffer.
[in]TxlenData transfer length.
Returns
XST_SUCCESS if successful, else XST_FAILURE.

References SpiPsTpmFifoRead(), SpiPsTpmFifoWrite(), SpiPsTpmStatusGet(), SpiPsTpmStatusSet(), XSPIPS_TPM_RESP_MAX_SIZE, XSPIPS_TPM_RX_HEAD_SIZE, XSPIPS_TPM_STS_CMD_READY, XSPIPS_TPM_STS_DATA_AVAIL, XSPIPS_TPM_STS_GO, and XSPIPS_TPM_STS_VALID.

Referenced by SpiPsTpmPolledExample().

int SpiPsTpmFifoRead ( XSpiPs *  SpiPtr,
u8 *  DataPtr,
u8  ByteCount 
)

Reads data from TPM FIFO.

Parameters
[in,out]SpiPtrPointer to the SPIPS driver component to use.
[out]DataPtrPointer to the buffer for the data read from the FIFO.
[in]ByteCountThe number of bytes to read.
Returns
XST_SUCCESS if successful, else XST_FAILURE.

References SpiPsTpmTransfer(), and XSPIPS_TPM_DATA_FIFO.

Referenced by SpiPsTpmDataTransfer().

int SpiPsTpmFifoWrite ( XSpiPs *  SpiPtr,
u8 *  DataPtr,
u8  ByteCount 
)

Writes the data to the TPM FIFO.

Parameters
[in,out]SpiPtrPointer to the SPIPS driver component to use.
[in]DataPtrData pointer to be written to FIFO.
[in]ByteCountThe number of bytes to write.
Returns
XST_SUCCESS if successful, else XST_FAILURE.

References SpiPsTpmTransfer(), and XSPIPS_TPM_DATA_FIFO.

Referenced by SpiPsTpmDataTransfer().

int SpiPsTpmPolledExample ( XSpiPs *  SpiInstancePtr,
UINTPTR  BaseAddress 
)

Illustrates how to use the XSpiPs device driver in polled mode with a TPM device.

The function sends TPM commands to the device based on user inputs and displays the response.

Parameters
[in]SpiInstancePtrPointer to the Spi Instance.
[in]BaseAddressThe base address of the device.
Returns
XST_SUCCESS if successful else XST_FAILURE.
Note
In XSCT/classic flow, the device configuration is looked up based on DeviceId.

References XSpiPs_Config::BaseAddress, SpiPsReadID(), SpiPsTpmAccessGet(), SpiPsTpmAccessSet(), SpiPsTpmDataTransfer(), TPM_SPI_SELECT, TpmRespBuffer, XSpiPs_CfgInitialize(), XSPIPS_CLK_PRESCALE_16, XSPIPS_EXIT_CMD_LOOP, XSPIPS_FORCE_SSELECT_OPTION, XSpiPs_LookupConfig(), XSPIPS_MANUAL_START_OPTION, XSPIPS_MASTER_OPTION, XSpiPs_SelfTest(), XSpiPs_SetClkPrescaler(), XSpiPs_SetOptions(), XSpiPs_SetSlaveSelect(), XSPIPS_TPM2_CMD_PCR_EXTEND, XSPIPS_TPM2_CMD_PCR_READ, XSPIPS_TPM2_CMD_PCR_RESET, XSPIPS_TPM2_CMD_SELFTEST, XSPIPS_TPM2_CMD_STARTUP, XSPIPS_TPM_ACCESS_ACT_LOCAL, XSPIPS_TPM_ACCESS_REQ_USE, XSPIPS_TPM_ACCESS_VALID, XSPIPS_TPM_PCR_EXT_CMD_SIZE, XSPIPS_TPM_SHA1_DIGEST_SIZE, and XSPIPS_TPM_SHA256_DIGEST_SIZE.

Referenced by main().

int SpiPsTpmStatusGet ( XSpiPs *  SpiPtr,
u8 *  StatusPtr 
)

Gets TPM status.

Parameters
[in,out]SpiPtrPointer to the SPIPS driver component to use.
[out]StatusPtrPointer to read status.
Returns
XST_SUCCESS if successful, else XST_FAILURE.

References SpiPsTpmTransfer(), and XSPIPS_TPM_STS.

Referenced by SpiPsTpmDataTransfer().

int SpiPsTpmStatusSet ( XSpiPs *  SpiPtr,
u8  StatusVal 
)

Sets the TPM status.

Parameters
[in,out]SpiPtrPointer to the SPIPS driver component to use.
[in]StatusValValue to be written to status register.
Returns
XST_SUCCESS if successful, else XST_FAILURE.

References SpiPsTpmTransfer(), and XSPIPS_TPM_STS.

Referenced by SpiPsTpmDataTransfer().

int SpiPsTpmTransfer ( XSpiPs *  SpiPtr,
u32  Address,
u8 *  TxBuf,
u8 *  RxBuf,
u16  Length 
)

Transfers data to or from a TPM register.

The transfer is split into SPI transfers of up to XSPIPS_TPM_SPI_MAX_SIZE bytes.

Parameters
[in,out]SpiPtrPointer to the SPIPS driver component to use.
[in]AddressRegister address.
[in]TxBufPointer to transmit buffer.
[in,out]RxBufPointer to receive buffer.
[in]LengthTransfer length.
Returns
XST_SUCCESS if successful, else XST_FAILURE.

References TpmRxBuffer, TpmTxBuffer, XSpiPs_PolledTransfer(), XSPIPS_TPM_SPI_MAX_SIZE, and XSPIPS_TPM_TX_HEAD_SIZE.

Referenced by SpiPsReadID(), SpiPsTpmAccessGet(), SpiPsTpmAccessSet(), SpiPsTpmFifoRead(), SpiPsTpmFifoWrite(), SpiPsTpmStatusGet(), and SpiPsTpmStatusSet().

Variable Documentation

u8 TpmRespBuffer[XSPIPS_TPM_RESP_MAX_SIZE]

Buffer for the TPM command response.

Referenced by SpiPsTpmPolledExample().

Buffer for the data received on the SPI bus.

Referenced by SpiPsTpmTransfer().

Buffer for the data sent on the SPI bus.

Referenced by SpiPsTpmTransfer().