summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaymes Wilks <mjwilks@us.ibm.com>2017-02-23 12:57:30 -0600
committerDaniel M. Crowell <dcrowell@us.ibm.com>2017-04-02 17:34:10 -0400
commit91ada9424dd95a58c4a998f0d51b36cb0c31dbfe (patch)
tree2df6b692836626c89bceb67c6c540c1b42483500
parentd6aaf2fe4f15c5360bb67fde5fc96f437ba3d271 (diff)
downloadtalos-hostboot-91ada9424dd95a58c4a998f0d51b36cb0c31dbfe.tar.gz
talos-hostboot-91ada9424dd95a58c4a998f0d51b36cb0c31dbfe.zip
Initialize HDAT TPM Info
Add code to initialize TPM Info on OpenPower systems to the correct length and to all zeros. Change-Id: Ica2cd689cdc32e93746f68fa613c8dfbca1740bc RTC:166834 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36967 Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com> Reviewed-by: Stephen M. Cprek <smcprek@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
-rwxr-xr-xsrc/include/usr/hdat/hdat.H25
-rwxr-xr-xsrc/usr/hdat/hdathdif.C26
-rwxr-xr-xsrc/usr/hdat/hdatspiraS.C4
-rw-r--r--src/usr/hdat/hdattpmdata.C86
-rw-r--r--src/usr/hdat/hdattpmdata.H43
5 files changed, 166 insertions, 18 deletions
diff --git a/src/include/usr/hdat/hdat.H b/src/include/usr/hdat/hdat.H
index 6e052d7db..5c95ce792 100755
--- a/src/include/usr/hdat/hdat.H
+++ b/src/include/usr/hdat/hdat.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -129,25 +129,28 @@ struct hdatFruId_t
/*----------------------------------------------------------------------------*/
/* Constants */
/*----------------------------------------------------------------------------*/
-const int32_t HDAT_SUCCESS = 0;
-const int32_t HDAT_FAILURE = -1;
+extern const int32_t HDAT_SUCCESS;
+extern const int32_t HDAT_FAILURE;
/** @brief No children for a data structure*/
-const uint32_t HDAT_NO_CHILD = 0;
+extern const uint32_t HDAT_NO_CHILD;
/** @brief Structure id for an HDIF structure*/
-const uint16_t HDAT_HDIF_STRUCT_ID = 0xD1F0;
+extern const uint16_t HDAT_HDIF_STRUCT_ID;
/** @brief FFDC Version to classify data in error log */
-const uint8_t HDAT_VERSION1 = 1;
+extern const uint8_t HDAT_VERSION1;
/** @brief FFDC Sub Version to classify data in error log */
-const uint8_t HDAT_PCIA_FFDC_SUBSEC = 1;
-const uint8_t HDAT_NACA_FFDC_SUBSEC1 = 2;
-const uint8_t HDAT_NACA_FFDC_SUBSEC2 = 3;
+extern const uint8_t HDAT_PCIA_FFDC_SUBSEC;
+extern const uint8_t HDAT_NACA_FFDC_SUBSEC1;
+extern const uint8_t HDAT_NACA_FFDC_SUBSEC2;
-const uint32_t HDAT_REAL_ADDRESS_MASK = 0x80000000;
-const uint64_t HDAT_REAL_ADDRESS_MASK64 = 0x8000000000000000ull;
+extern const uint32_t HDAT_REAL_ADDRESS_MASK;
+extern const uint64_t HDAT_REAL_ADDRESS_MASK64;
+
+/** @brief Align value for HDAT instances */
+extern const uint8_t HDAT_HDIF_ALIGN;
// (this goes up to 8 threads on P8)
#define HDAT_MAX_THREADS_SUPPORTED 8
diff --git a/src/usr/hdat/hdathdif.C b/src/usr/hdat/hdathdif.C
index 1533ddbe2..7ce7d1bfb 100755
--- a/src/usr/hdat/hdathdif.C
+++ b/src/usr/hdat/hdathdif.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2016 */
+/* Contributors Listed Below - COPYRIGHT 2016,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -36,7 +36,6 @@
#include "hdathdif.H"
#include "hdatutil.H"
-
namespace HDAT
{
@@ -53,6 +52,29 @@ const uint32_t HDAT_BOUNDARY = 16; // Pad structures to a 16 byte boundary
const char HDAT_PAD[15] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0'};
+const int32_t HDAT_SUCCESS = 0;
+const int32_t HDAT_FAILURE = -1;
+
+/** @brief No children for a data structure*/
+const uint32_t HDAT_NO_CHILD = 0;
+
+/** @brief Structure id for an HDIF structure*/
+const uint16_t HDAT_HDIF_STRUCT_ID = 0xD1F0;
+
+/** @brief FFDC Version to classify data in error log */
+const uint8_t HDAT_VERSION1 = 1;
+
+/** @brief FFDC Sub Version to classify data in error log */
+const uint8_t HDAT_PCIA_FFDC_SUBSEC = 1;
+const uint8_t HDAT_NACA_FFDC_SUBSEC1 = 2;
+const uint8_t HDAT_NACA_FFDC_SUBSEC2 = 3;
+
+const uint32_t HDAT_REAL_ADDRESS_MASK = 0x80000000;
+const uint64_t HDAT_REAL_ADDRESS_MASK64 = 0x8000000000000000ull;
+
+/** @brief Align value for HDAT instances */
+const uint8_t HDAT_HDIF_ALIGN = 128;
+
/** @brief See the prologue in hdathdif.H
*/
diff --git a/src/usr/hdat/hdatspiraS.C b/src/usr/hdat/hdatspiraS.C
index df36a0ae5..db23584ac 100755
--- a/src/usr/hdat/hdatspiraS.C
+++ b/src/usr/hdat/hdatspiraS.C
@@ -646,8 +646,8 @@ errlHndl_t HdatSpiraS::loadDataArea( const hdat5Tuple_t& i_spirasHostEntry,
l_spirasEntry.hdatAllocCnt = l_count;
l_spirasEntry.hdatActualCnt = l_count;
- uint32_t l_rem = l_size % 128;
- uint32_t l_pad = l_rem ? (128 - l_rem) : 0;
+ uint32_t l_rem = l_size % HDAT_HDIF_ALIGN;
+ uint32_t l_pad = l_rem ? (HDAT_HDIF_ALIGN - l_rem) : 0;
l_spirasEntry.hdatAllocSize = l_size + l_pad;
l_spirasEntry.hdatActualSize = l_size;
diff --git a/src/usr/hdat/hdattpmdata.C b/src/usr/hdat/hdattpmdata.C
index b714ba1df..8b13fe4e8 100644
--- a/src/usr/hdat/hdattpmdata.C
+++ b/src/usr/hdat/hdattpmdata.C
@@ -28,18 +28,26 @@
#include "hdatutil.H"
#include <sys/mm.h>
#include <sys/mmio.h>
+#include <sys/internode.h>
#include <vpd/mvpdenums.H>
#include <pnor/pnorif.H>
#include <util/align.H>
+#include <algorithm>
#include <devicefw/userif.H>
#include <targeting/common/util.H>
+#include <targeting/common/target.H>
+#include <targeting/common/targetservice.H>
+#include <targeting/common/utilFilter.H>
+#include <targeting/common/entitypath.H>
namespace HDAT
{
extern trace_desc_t *g_trac_hdat;
+const uint8_t g_hdatTpmDataEyeCatch[] = {'T', 'P', 'M', 'R', 'E', 'L'};
+
HdatTpmData::HdatTpmData(errlHndl_t &o_errlHndl,
const HDAT::hdatMsAddr_t &i_msAddr):
iv_msAddr(i_msAddr),
@@ -135,11 +143,87 @@ HdatTpmData::~HdatTpmData()
}
}
-errlHndl_t HdatTpmData::hdatLoadTpmData(uint32_t &o_size,uint32_t &o_count)
+errlHndl_t HdatTpmData::hdatLoadTpmData(uint32_t &o_size, uint32_t &o_count)
{
errlHndl_t l_errl = nullptr;
+ o_size = 0;
+ o_count = 0;
+
+ // TODO RTC 167290 - In order to support multiple nodes, this calculation
+ // needs to be #nodes * [ the entire 18.x set of structures ] and the
+ // initialization needs to be done on each instance. The reported size
+ // (in variable o_size) needs to be the size of a single instance and the
+ // reported count (via o_count) needs to be the number of nodes. For now,
+ // we assume one node.
+
+ // account for the size of the TPM data header
+ o_size += sizeof(hdatTpmData_t);
+
+ // account for the size of the TPM Info array header
+ o_size += sizeof(hdatSbTpmInfo_t);
+
+ // account for each element of the TPM Info array
+ o_size += ((sizeof(hdatSbTpmInstInfo_t) +
+ TPM_SRTM_EVENT_LOG_MAX +
+ TPM_DRTM_EVENT_LOG_MAX)
+ * hdatCalcMaxTpmsPerNode());
+
+ // account for User physical interaction mechanism info struct
+ // and Host I2C device information pointers
+ o_size += (sizeof(hdatPhysInterMechInfo_t) + sizeof(hdatI2cDevInfoPtrs_t) *
+ NUM_I2C_PHYS_PRESENCE_DEVICES);
+
+ // Align size value to match actual allocated size, because we also want to
+ // zero the padded part, and thus simplify multinode support going forward.
+ o_size = ALIGN_X(o_size, HDAT_HDIF_ALIGN);
+
+ // zero all of it
+ memset(iv_hdatTpmData,0,o_size);
+
+ // We add the first two fields for a reference to aid in debugging,
+ // but the rest will be populated in FSP/OpenPower common code. Any
+ // work here would just be duplicated later during the runtime istep.
+
+ // add the format magic number
+ iv_hdatTpmData->hdatHdr.hdatStructId = HDAT::HDAT_HDIF_STRUCT_ID;
+
+ // add the eyecatcher
+ memcpy(iv_hdatTpmData->hdatHdr.hdatStructName,
+ g_hdatTpmDataEyeCatch,
+ sizeof(g_hdatTpmDataEyeCatch));
+
+ // account for this one instance of Node TPM Related Data
+ ++o_count;
+
return l_errl;
}
+uint16_t hdatCalcMaxTpmsPerNode()
+{
+ size_t l_maxTpms = 0;
+
+ // calculate max # of TPMs per node
+
+ // look for class ENC type NODE and class chip TPM to find TPMs
+ TARGETING::TargetHandleList l_nodeEncList;
+
+ getEncResources(l_nodeEncList, TARGETING::TYPE_NODE,
+ TARGETING::UTIL_FILTER_ALL);
+
+ // loop thru the nodes and check number of TPMs
+ std::for_each(l_nodeEncList.begin(), l_nodeEncList.end(),
+ [&l_maxTpms](const TARGETING::Target* const i_pNode)
+ {
+ // for this Node, get a list of tpms
+ TARGETING::TargetHandleList l_tpmChipList;
+
+ getChildAffinityTargets ( l_tpmChipList, i_pNode,
+ TARGETING::CLASS_CHIP, TARGETING::TYPE_TPM, false );
+
+ l_maxTpms = std::max(l_maxTpms, l_tpmChipList.size());
+ } );
+ return l_maxTpms;
+}
+
}
diff --git a/src/usr/hdat/hdattpmdata.H b/src/usr/hdat/hdattpmdata.H
index ce92b46a7..d17172366 100644
--- a/src/usr/hdat/hdattpmdata.H
+++ b/src/usr/hdat/hdattpmdata.H
@@ -38,12 +38,19 @@
#include <hdat/hdat_reasoncodes.H>
#include "hdatutil.H"
#include <hdat/hdat.H>
+#include <sys/misc.h>
+
+#define TPM_SRTM_EVENT_LOG_MAX (64 * KILOBYTE)
+
+#define TPM_DRTM_EVENT_LOG_MAX (64 * KILOBYTE)
+
+#define NUM_I2C_PHYS_PRESENCE_DEVICES 2
namespace HDAT
{
/**
- * @brief Structure definition for HDAT Tpm Node Related Data header
+ * @brief Structure definition for HDAT Tpm Node Data Header
*/
struct hdatTpmData_t
{
@@ -61,7 +68,7 @@ struct hdatSbTpmInfo_t
{
uint32_t hdatSbTpmArrayOffset;
uint32_t hdatSbTpmArrayNumEntries;
- uint32_t hdatsbTpmArraySize;
+ uint32_t hdatSbTpmArraySize;
} __attribute__ ((packed));
@@ -85,6 +92,28 @@ struct hdatSbTpmInstInfo_t
} __attribute__ ((packed));
+/**
+ * @brief Structure definition for HDAT physical interaction mechanism info
+ */
+struct hdatPhysInterMechInfo_t
+{
+ uint32_t hdatOffsetI2cDevInfoPtrs;
+ uint32_t hdatNumEntries;
+ uint32_t hdatSizeOfI2cDevInfoPtrs;
+} __attribute__ ((packed));
+
+
+/**
+ * @brief Structure definition for HDAT Host I2c Device Information pointers
+ */
+struct hdatI2cDevInfoPtrs_t
+{
+ uint32_t hdatChipId;
+ uint32_t hdatDbobId; // Drawer/Book/Octant/Blade ID
+ uint32_t hdatHostI2cLinkId;
+} __attribute__ ((packed));
+
+
/** Begin Class Description
*
* @brief The HdatTpmData class is used to construct the Node TPM Related Data
@@ -186,6 +215,16 @@ class HdatTpmData
}; // end of HdatTpmData class
+/**
+ * @brief Calculate the maximum number of TPMs per node for this system.
+ *
+ * @pre None
+ *
+ * @post None
+ *
+ * @retval uint16_t Returns the maximum number of TPMs per node for this system
+ */
+uint16_t hdatCalcMaxTpmsPerNode();
}
#endif // HDATTPMDATA_H
OpenPOWER on IntegriCloud