/** @file
Ihis library is only intended to be used by TPM modules.
It provides basic TPM Interface Specification (TIS) and Command functions.
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.
**/
#ifndef _TPM_COMM_LIB_H_
#define _TPM_COMM_LIB_H_
#include <IndustryStandard/Tpm12.h>
///
/// TPM register base address.
///
//
// Set structure alignment to 1-byte
//
#pragma pack (1)
//
// Register set map as specified in TIS specification Chapter 10
//
typedef struct {
///
/// Used to gain ownership for this particular port.
///
///
/// Controls interrupts.
///
///
/// SIRQ vector to be used by the TPM.
///
///
/// What caused interrupt.
///
///
/// Shows which interrupts are supported by that particular TPM.
///
///
/// Status Register. Provides status of the TPM.
///
///
/// Number of consecutive writes that can be done to the TPM.
///
///
/// Read or write FIFO, depending on transaction.
///
///
/// Vendor ID
///
///
/// Device ID
///
///
/// Revision ID
///
///
/// TCG defined configuration registers.
///
///
/// Alias to I/O legacy space.
///
///
/// Additional 8 bits for I/O legacy space extension.
///
///
/// Alias to second I/O legacy space.
///
///
/// Additional 8 bits for second I/O legacy space extension.
///
///
/// Vendor-defined configuration registers.
///
//
// Restore original structure alignment
//
#pragma pack ()
//
// Define pointer types used to access TIS registers on PC
//
//
// TCG Platform Type based on TCG ACPI Specification Version 1.00
//
#define TCG_PLATFORM_TYPE_CLIENT 0
//
// Define bits of ACCESS and STATUS registers
//
///
/// This bit is a 1 to indicate that the other bits in this register are valid.
///
///
/// Indicate that this locality is active.
///
///
/// Set to 1 to indicate that this locality had the TPM taken away while
/// this locality had the TIS_PC_ACC_ACTIVE bit set.
///
///
/// 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.
///
///
/// When this bit is 1, another locality is requesting usage of the TPM.
///
///
/// Set to 1 to indicate that this locality is requesting to use TPM.
///
///
///
///
/// When this bit is 1, TPM is in the Ready state,
/// indicating it is ready to receive a new command.
///
///
/// Write a 1 to this bit to cause the TPM to execute that command.
///
///
/// This bit indicates that the TPM has data available as a response.
///
///
/// The TPM sets this bit to a value of 1 when it expects another byte of data for a command.
///
///
/// Writes a 1 to this bit to force the TPM to re-send the response.
///
//
// Default TimeOut value
//
//
//
/**
Check whether the value of a TPM chip register satisfies the input BIT setting.
@param[in] Register Address port of register to be checked.
@param[in] BitSet Check these data bits are set.
@param[in] BitClear Check these data bits are clear.
@param[in] TimeOut The max wait time (unit MicroSecond) when checking register.
@retval EFI_SUCCESS The register satisfies the check bit.
@retval EFI_TIMEOUT The register can't run into the expected status in time.
**/
);
/**
Get BurstCount by reading the burstCount field of a TIS regiger
in the time of default TIS_TIMEOUT_D.
@param[in] TisReg Pointer to TIS register.
@param[out] BurstCount Pointer to a buffer to store the got BurstConut.
@retval EFI_SUCCESS Get BurstCount.
@retval EFI_INVALID_PARAMETER TisReg is NULL or BurstCount is NULL.
@retval EFI_TIMEOUT BurstCount can't be got in time.
**/
);
/**
Set TPM chip to ready state by sending ready command TIS_PC_STS_READY
to Status Register in time.
@param[in] TisReg Pointer to TIS register.
@retval EFI_SUCCESS TPM chip enters into ready state.
@retval EFI_INVALID_PARAMETER TisReg is NULL.
@retval EFI_TIMEOUT TPM chip can't be set to ready state 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_D.
@param[in] TisReg Pointer to TIS register.
@retval EFI_SUCCESS Get the control of TPM chip.
@retval EFI_INVALID_PARAMETER TisReg is NULL.
@retval EFI_NOT_FOUND TPM chip doesn't exit.
@retval EFI_TIMEOUT Can't get the TPM control in time.
**/
);
/**
Single function calculates SHA1 digest value for all raw data. It
combines Sha1Init(), Sha1Update() and Sha1Final().
@param[in] Data Raw data to be digested.
@param[in] DataLen Size of the raw data.
@param[out] Digest Pointer to a buffer that stores the final digest.
@retval EFI_SUCCESS Always successfully calculate the final digest.
**/
);
#endif