summaryrefslogtreecommitdiffstats
path: root/src/usr/i2c
diff options
context:
space:
mode:
authorChris Engel <cjengel@us.ibm.com>2015-08-03 16:01:14 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2015-12-11 11:17:32 -0600
commite914974751a5125cff6fa7078399db6f3aac5641 (patch)
tree4f50b6677a2a0111f98884813ff7e028459bcca2 /src/usr/i2c
parent0cbd52585b9013430efeaeed6b4c38f6122eea98 (diff)
downloadblackbird-hostboot-e914974751a5125cff6fa7078399db6f3aac5641.tar.gz
blackbird-hostboot-e914974751a5125cff6fa7078399db6f3aac5641.zip
Trustedboot: Additional commands in trusted boot init sequence
- getCap FW Version - TPM Command marshal/unmarshal code Change-Id: Ia9a90b1160c9c3b5d818318771bff21eb013bdf4 RTC: 125287 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/20056 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Reviewed-by: STEPHEN M. CPREK <smcprek@us.ibm.com> Reviewed-by: Timothy R. Block <block@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/i2c')
-rwxr-xr-xsrc/usr/i2c/test/tpmddtest.H98
-rwxr-xr-xsrc/usr/i2c/tpmdd.C46
-rwxr-xr-xsrc/usr/i2c/tpmdd.H44
3 files changed, 24 insertions, 164 deletions
diff --git a/src/usr/i2c/test/tpmddtest.H b/src/usr/i2c/test/tpmddtest.H
index 74f71b28e..4053245a6 100755
--- a/src/usr/i2c/test/tpmddtest.H
+++ b/src/usr/i2c/test/tpmddtest.H
@@ -38,9 +38,10 @@
#include <devicefw/driverif.H>
#include <i2c/tpmddreasoncodes.H>
#include <targeting/common/commontargeting.H>
+#include "secureboot/trustedbootif.H"
#include "i2ctest.H"
#include "../tpmdd.H"
-#include "../../secureboot/trusted/trustedboot.H"
+#include "../../secureboot/trusted/trustedTypes.H"
extern trace_desc_t* g_trac_tpmdd;
@@ -541,16 +542,16 @@ class TPMDDTest: public CxxTest::TestSuite
memset(data, 0xFE, sizeof(data));
TRUSTEDBOOT::TPM2_GetCapabilityIn* cmd =
- (TRUSTEDBOOT::TPM2_GetCapabilityIn*)data;
+ reinterpret_cast<TRUSTEDBOOT::TPM2_GetCapabilityIn*>
+ (data);
- cmd->base.tag = TRUSTEDBOOT::TPM_ST_NO_SESSIONS;
cmd->base.commandSize =
sizeof (TRUSTEDBOOT::TPM2_GetCapabilityIn);
+ cmd->base.tag = TRUSTEDBOOT::TPM_ST_NO_SESSIONS;
cmd->base.commandCode = TRUSTEDBOOT::TPM_CC_GetCapability;
cmd->capability = TRUSTEDBOOT::TPM_CAP_TPM_PROPERTIES;
cmd->property = TRUSTEDBOOT::TPM_PT_MANUFACTURER;
cmd->propertyCount = 1;
-
cmdSize = cmd->base.commandSize;
num_ops++;
@@ -623,97 +624,12 @@ class TPMDDTest: public CxxTest::TestSuite
continue;
}
- // Build our command block for a startup
- memset(data, 0xFE, sizeof(data));
-
- // Test a TPM command underflow
- TRUSTEDBOOT::TPM2_GetCapabilityIn* cmd =
- (TRUSTEDBOOT::TPM2_GetCapabilityIn*)data;
-
- cmd->base.tag = TRUSTEDBOOT::TPM_ST_NO_SESSIONS;
- cmd->base.commandSize =
- sizeof (TRUSTEDBOOT::TPM2_GetCapabilityIn);
- cmd->base.commandCode = TRUSTEDBOOT::TPM_CC_GetCapability;
- cmd->capability = TRUSTEDBOOT::TPM_CAP_TPM_PROPERTIES;
- cmd->property = TRUSTEDBOOT::TPM_PT_MANUFACTURER;
- cmd->propertyCount = 1;
-
- cmdSize = cmd->base.commandSize;
-
- num_ops++;
- err = deviceRead(testTarget,
- &data,
- dataSize,
- DEVICE_TPM_ADDRESS( TPM_PRIMARY,
- TPM_OP_TRANSMIT,
- cmdSize - 1) );
-
- if( NULL == err ||
- err->reasonCode() != TPM_UNDERFLOW_ERROR)
- {
- fails++;
- TS_FAIL( "testTPMTransmitOverUnder - Error "
- "command underflow not detected" );
- errlCommit( err,
- TPMDD_COMP_ID );
- delete err;
- err = NULL;
- }
- else
- {
- TRACUCOMP(g_trac_tpmdd, "testTPMTransmitOverUnder - "
- "CmdUnder Transmit returned as expected. len=%d",
- dataSize);
- }
-
-
- // Build our command block for a startup
- dataSize = sizeof(data);
- memset(data, 0xFE, sizeof(data));
-
- // Test a TPM command overflow
-
- cmd->base.tag = TRUSTEDBOOT::TPM_ST_NO_SESSIONS;
- cmd->base.commandSize =
- sizeof (TRUSTEDBOOT::TPM2_GetCapabilityIn);
- cmd->base.commandCode = TRUSTEDBOOT::TPM_CC_GetCapability;
- cmd->capability = TRUSTEDBOOT::TPM_CAP_TPM_PROPERTIES;
- cmd->property = TRUSTEDBOOT::TPM_PT_MANUFACTURER;
- cmd->propertyCount = 1;
-
- cmdSize = cmd->base.commandSize;
-
- num_ops++;
- err = deviceRead(testTarget,
- &data,
- dataSize,
- DEVICE_TPM_ADDRESS( TPM_PRIMARY,
- TPM_OP_TRANSMIT,
- cmdSize + 1) );
-
- if( NULL == err ||
- err->reasonCode() != TPM_OVERFLOW_ERROR)
- {
- fails++;
- TS_FAIL( "testTPMTransmitOverUnder - Error "
- "command overflow not detected" );
- errlCommit( err,
- TPMDD_COMP_ID );
- delete err;
- err = NULL;
- }
- else
- {
- TRACUCOMP(g_trac_tpmdd, "testTPMTransmitOverUnder - "
- "CmdOver Transmit returned as expected. len=%d",
- dataSize);
- }
-
- // Build our command block for a startup
dataSize = sizeof(data);
memset(data, 0xFE, sizeof(data));
// Test a TPM data overflow
+ TRUSTEDBOOT::TPM2_GetCapabilityIn* cmd =
+ reinterpret_cast<TRUSTEDBOOT::TPM2_GetCapabilityIn*>(data);
cmd->base.tag = TRUSTEDBOOT::TPM_ST_NO_SESSIONS;
cmd->base.commandSize =
diff --git a/src/usr/i2c/tpmdd.C b/src/usr/i2c/tpmdd.C
index 16748c4b3..ef34ba2b7 100755
--- a/src/usr/i2c/tpmdd.C
+++ b/src/usr/i2c/tpmdd.C
@@ -154,16 +154,6 @@ errlHndl_t tpmPerformOp( DeviceFW::OperationType i_opType,
- // Get i2c master target
- err = tpmGetI2CMasterTarget( i_target,
- tpmInfo );
-
- if( err )
- {
- break;
- }
-
-
// Lock to sequence operations
mutex_lock( &g_tpmMutex );
unlock = true;
@@ -326,21 +316,6 @@ bool tpmPresence ( TARGETING::Target * i_target,
break;
}
- // Get i2c master target
- err = tpmGetI2CMasterTarget( i_target,
- tpmInfo );
-
- if( err )
- {
- TRACFCOMP(g_trac_tpmdd,
- ERR_MRK"Error in tpmPresence::tpmGetI2Cmaster() "
- "RC 0x%X", err->reasonCode());
- l_present = false;
- delete err;
- err = NULL;
- break;
- }
-
// Ensure the TPM is enabled
if (!tpmInfo.tpmEnabled)
{
@@ -1267,6 +1242,19 @@ errlHndl_t tpmReadAttributes ( TARGETING::Target * i_target,
}
+ // Get i2c master target
+ err = tpmGetI2CMasterTarget( i_target,
+ io_tpmInfo );
+
+ if( err )
+ {
+ TRACFCOMP(g_trac_tpmdd,
+ ERR_MRK"Error in tpmReadAttributes::tpmGetI2Cmaster() "
+ "RC 0x%X", err->reasonCode());
+ break;
+ }
+
+
} while( 0 );
TRACUCOMP(g_trac_tpmdd,"tpmReadAttributes() tgt=0x%X, %d/%d/0x%X "
@@ -1320,9 +1308,9 @@ errlHndl_t tpmGetI2CMasterTarget ( TARGETING::Target * i_target,
{
// Path element: type:8 instance:8
l_epCompressed |=
- io_tpmInfo.i2cMasterPath[i].type << (16*(3-i));
+ io_tpmInfo.i2cMasterPath[i].type << ((16*(3-i))+8);
l_epCompressed |=
- io_tpmInfo.i2cMasterPath[i].instance << ((16*(3-i))-8);
+ io_tpmInfo.i2cMasterPath[i].instance << (16*(3-i));
// Can only fit 4 path elements into 64 bits
if ( i == 3 )
@@ -1374,9 +1362,9 @@ errlHndl_t tpmGetI2CMasterTarget ( TARGETING::Target * i_target,
{
// Path element: type:8 instance:8
l_epCompressed |=
- io_tpmInfo.i2cMasterPath[i].type << (16*(3-i));
+ io_tpmInfo.i2cMasterPath[i].type << ((16*(3-i))+8);
l_epCompressed |=
- io_tpmInfo.i2cMasterPath[i].instance << ((16*(3-i))-8);
+ io_tpmInfo.i2cMasterPath[i].instance << (16*(3-i));
// Can only fit 4 path elements into 64 bits
if ( i == 3 )
diff --git a/src/usr/i2c/tpmdd.H b/src/usr/i2c/tpmdd.H
index c81e436d4..ad531d67d 100755
--- a/src/usr/i2c/tpmdd.H
+++ b/src/usr/i2c/tpmdd.H
@@ -41,15 +41,6 @@
namespace TPMDD
{
-/**
-* @brief Enumerations to describe the type of devices to be accessed.
-*/
-enum tpm_addr_size_t
-{
- ONE_BYTE_ADDR = 1,
- TWO_BYTE_ADDR = 2,
- LAST_DEVICE_TYPE
-};
/// TPM Timeouts listed in ms
/// Timeout names and durations are as described in the TCG specification
@@ -67,24 +58,6 @@ enum
MAX_STSVALID_POLLS = 5, ///< Max poll of 50ms (5*10ms)
};
-/**
- * @brief Structure of common parameters needed by different parts of
- * the code.
- */
-struct tpm_info_t
-{
- tpm_op_types_t operation; ///< TPM operation to perform
- uint64_t port; ///< I2C Master port
- uint64_t engine; ///< I2C Master engin
- tpm_addr_size_t addrSize; ///< I2C Addr size
- TARGETING::EntityPath i2cMasterPath; ///< I2C Master path
- TARGETING::Target * i2cTarget; ///< I2C Target
-
- uint8_t chip; ///< Chip target, primary/backup
- uint8_t tpmEnabled; ///< Is this TPM available and functional?
- uint8_t devAddr; ///< I2C Address
- size_t offset; ///< TPM Device register offset
-};
@@ -257,23 +230,6 @@ errlHndl_t tpmPrepareAddress ( void * io_buffer,
tpm_info_t i_tpmInfo );
/**
- * @brief this function will read all of the associated attributes needed
- * to access the intended TPM. These attributes will be used to
- * determine the type of I2C device as well as how to address it via
- * the I2C device driver.
- *
- * @param[in] i_target target node.
- *
- * @param[in/out] io_tpmInfo The structure that will contain the attribute data
- * read from the target device.
- *
- * @return errlHndl_t NULL if successful, otherwise a pointer to the
- * error log.
- */
-errlHndl_t tpmReadAttributes ( TARGETING::Target * i_target,
- tpm_info_t & io_tpmInfo );
-
-/**
* @brief This function decides whether or not the target passed into the
* TPM device driver actually contains the I2C Master engines. If
* not, it will then read the attribute of the target to get the path
OpenPOWER on IntegriCloud