summaryrefslogtreecommitdiffstats
path: root/hwpf/include/plat
diff options
context:
space:
mode:
Diffstat (limited to 'hwpf/include/plat')
-rw-r--r--hwpf/include/plat/hw_access.H96
-rw-r--r--hwpf/include/plat/multicast.H55
-rw-r--r--hwpf/include/plat/plat_target.H132
-rw-r--r--hwpf/include/plat/plat_target_utils.H13
-rw-r--r--hwpf/include/plat/target.H280
5 files changed, 291 insertions, 285 deletions
diff --git a/hwpf/include/plat/hw_access.H b/hwpf/include/plat/hw_access.H
index 047176a7..8104081a 100644
--- a/hwpf/include/plat/hw_access.H
+++ b/hwpf/include/plat/hw_access.H
@@ -1,11 +1,11 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
-/* $Source: $ */
+/* $Source: hwpf/include/plat/hw_access.H $ */
/* */
-/* OpenPOWER HostBoot Project */
+/* OpenPOWER sbe Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2012,2014 */
+/* Contributors Listed Below - COPYRIGHT 2012,2016 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -52,7 +52,7 @@ namespace fapi2
/// @brief Sets the PIB error mask - platform dependant
/// @param[in] i_mask The new error mask
void setPIBErrorMask(uint8_t i_mask)
- {
+ {
PLAT_SET_PIB_ERROR_MASK(i_mask);
}
@@ -99,8 +99,8 @@ namespace fapi2
/// @param[in] i_address SCOM register address to read from.
/// @param[out] o_data Buffer that holds data read from HW target.
/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
- template< TargetType K >
- inline void getScom(const Target<K>& i_target, const uint64_t i_address,
+ template< TargetType K, typename V >
+ inline void getScom(const Target<K, V>& i_target, const uint64_t i_address,
buffer<uint64_t>& o_data)
{
@@ -117,8 +117,8 @@ namespace fapi2
/// @param[in] i_address SCOM register address to write to.
/// @param[in] i_data Buffer that holds data to write into address.
/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
- template< TargetType K >
- inline void putScom(const Target<K>& i_target, const uint64_t i_address,
+ template< TargetType K, typename V >
+ inline void putScom(const Target<K, V>& i_target, const uint64_t i_address,
buffer<uint64_t> i_data)
{
@@ -135,14 +135,14 @@ namespace fapi2
/// @param[in] i_data Buffer that holds data to be modified.
/// @param[in] i_modifyMode The modify mode (or/and/xor).
/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
- template< TargetType K >
- inline void modifyScom( const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline void modifyScom( const Target<K, V>& i_target,
const uint64_t i_address,
const buffer<uint64_t> i_data,
const ChipOpModifyMode i_modifyMode)
{
fapi2::buffer<uint64_t> l_modifyDataBuffer;
-
+
PLAT_GETSCOM(current_err,
i_target,
(uint32_t)(i_address ),
@@ -166,7 +166,7 @@ namespace fapi2
PLAT_PUTSCOM(current_err,
i_target,
(uint32_t)(i_address ),
- l_modifyDataBuffer());
+ l_modifyDataBuffer());
return;
}
@@ -177,8 +177,8 @@ namespace fapi2
/// @param[in] i_data Buffer that holds data to write into address.
/// @param[in] i_mask Buffer that holds the mask value.
/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
- template< TargetType K >
- inline void putScomUnderMask(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline void putScomUnderMask(const Target<K, V>& i_target,
const uint64_t i_address,
buffer<uint64_t> i_data,
buffer<uint64_t> i_mask)
@@ -186,14 +186,14 @@ namespace fapi2
fapi2::buffer<uint64_t> l_modifyDataBuffer = i_data;
l_modifyDataBuffer &= i_mask;
-
+
PLAT_PUTSCOM(current_err,
i_target,
(uint32_t)(i_address ),
l_modifyDataBuffer());
return;
}
-
+
/// @brief Reads a CFAM register from a chip.
/// CFAM register is 32-bit wide.
@@ -202,8 +202,8 @@ namespace fapi2
/// @param[in] i_address CFAM register address to read from.
/// @param[out] o_data Buffer that holds data read from HW target.
/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
- template< TargetType K >
- inline ReturnCode getCfamRegister(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode getCfamRegister(const Target<K, V>& i_target,
const uint32_t i_address,
buffer<uint32_t>& o_data)
{
@@ -221,8 +221,8 @@ namespace fapi2
/// @param[in] i_address CFAM register address to write to.
/// @param[in] i_data Buffer that holds data to write into address.
/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
- template< TargetType K >
- inline ReturnCode putCfamRegister(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode putCfamRegister(const Target<K, V>& i_target,
const uint32_t i_address,
buffer<uint32_t>& i_data)
{
@@ -241,8 +241,8 @@ namespace fapi2
/// @param[in] i_data Buffer that holds data to be modified.
/// @param[in] i_modifyMode The modify mode (or/and/xor).
/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
- template< TargetType K >
- inline ReturnCode modifyCfamRegister(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode modifyCfamRegister(const Target<K, V>& i_target,
const uint32_t i_address,
const buffer<uint32_t>& i_data,
const ChipOpModifyMode i_modifyMode)
@@ -264,8 +264,8 @@ namespace fapi2
/// @param[out] o_data Buffer that holds data read from HW target.
/// @param[in] i_ringMode Ring operation mode.
/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
- template< TargetType K >
- inline ReturnCode getRing(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode getRing(const Target<K, V>& i_target,
const scanRingId_t i_address,
variable_buffer& o_data,
const RingMode i_ringMode = 0)
@@ -293,8 +293,8 @@ namespace fapi2
/// to write into address
/// @param[in] i_ringMode Ring operation mode.
/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
- template< TargetType K >
- inline ReturnCode putRing(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode putRing(const Target<K, V>& i_target,
const scanRingId_t i_address,
variable_buffer& i_data,
const RingMode i_ringMode = 0)
@@ -312,8 +312,8 @@ namespace fapi2
// ring data to write into address
/// @param[in] i_ringMode Ring operation mode.
/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
- template< TargetType K >
- inline ReturnCode putRing(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode putRing(const Target<K, V>& i_target,
const scanRingId_t i_address,
const void* i_data,
const RingMode i_ringMode = 0)
@@ -332,8 +332,8 @@ namespace fapi2
/// @param[in] i_modifyMode The modify mode (or/and/xor)
/// @param[in] i_ringMode Ring operation mode.
/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
- template< TargetType K >
- inline ReturnCode modifyRing(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode modifyRing(const Target<K, V>& i_target,
const scanRingId_t i_address,
variable_buffer& i_data,
const ChipOpModifyMode i_modifyMode,
@@ -385,8 +385,8 @@ namespace fapi2
/// SCOM_BULK_WRITE_MODE operations are not supported due to
/// hardware limitations.
///
- template< TargetType K >
- fapi2::ReturnCode multiScom (const Target<K>& i_target,
+ template< TargetType K, typename V >
+ fapi2::ReturnCode multiScom (const Target<K, V>& i_target,
MultiScom& io_multiScomObj)
{
}
@@ -439,8 +439,8 @@ namespace fapi2
/// the quotes for the cronus environment
///
#ifdef FAPI_SUPPORT_SPY_AS_ENUM
- template< TargetType K >
- inline ReturnCode getSpy(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode getSpy(const Target<K, V>& i_target,
const spyId_t i_spyId,
variable_buffer& o_data)
{
@@ -449,8 +449,8 @@ namespace fapi2
}
#endif
#ifdef FAPI_SUPPORT_SPY_AS_STRING
- template< TargetType K >
- inline ReturnCode getSpy(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode getSpy(const Target<K, V>& i_target,
const char * const i_spyId,
variable_buffer& o_data)
{
@@ -498,8 +498,8 @@ namespace fapi2
/// the quotes for the cronus environment
///
#ifdef FAPI_SUPPORT_SPY_AS_ENUM
- template< TargetType K >
- inline ReturnCode putSpy(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode putSpy(const Target<K, V>& i_target,
const spyId_t i_spyId,
variable_buffer& i_data)
{
@@ -508,8 +508,8 @@ namespace fapi2
}
#endif
#ifdef FAPI_SUPPORT_SPY_AS_STRING
- template< TargetType K >
- inline ReturnCode putSpy(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode putSpy(const Target<K, V>& i_target,
const char* const i_spyId,
variable_buffer& i_data)
{
@@ -538,8 +538,8 @@ namespace fapi2
/// See fapiPutSpy for details on spy id specifics.
///
#ifdef FAPI_SUPPORT_SPY_AS_ENUM
- template< TargetType K >
- inline ReturnCode putSpyImage(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode putSpyImage(const Target<K, V>& i_target,
const spyId_t i_spyId,
const variable_buffer& i_data,
variable_buffer& o_imageData)
@@ -549,8 +549,8 @@ namespace fapi2
}
#endif
#ifdef FAPI_SUPPORT_SPY_AS_STRING
- template< TargetType K >
- inline ReturnCode putSpyImage(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode putSpyImage(const Target<K, V>& i_target,
const char* const i_spyId,
const variable_buffer& i_data,
variable_buffer& o_imageData)
@@ -577,8 +577,8 @@ namespace fapi2
/// See fapiPutSpy for details on spy id specifics.
///
#ifdef FAPI_SUPPORT_SPY_AS_ENUM
- template< TargetType K >
- inline ReturnCode getSpyImage(const Target<K>& i_target,
+ template< TargetType K, typename V>
+ inline ReturnCode getSpyImage(const Target<K, V>& i_target,
const spyId_t i_spyId,
variable_buffer& o_data,
const variable_buffer& i_imageData)
@@ -588,8 +588,8 @@ namespace fapi2
}
#endif
#ifdef FAPI_SUPPORT_SPY_AS_STRING
- template< TargetType K >
- inline ReturnCode getSpyImage(const Target<K>& i_target,
+ template< TargetType K, typename V >
+ inline ReturnCode getSpyImage(const Target<K, V>& i_target,
const char * const i_spyId,
variable_buffer& o_data,
const variable_buffer& i_imageData)
diff --git a/hwpf/include/plat/multicast.H b/hwpf/include/plat/multicast.H
new file mode 100644
index 00000000..0e23ff2b
--- /dev/null
+++ b/hwpf/include/plat/multicast.H
@@ -0,0 +1,55 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: hwpf/include/plat/multicast.H $ */
+/* */
+/* OpenPOWER sbe Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+#ifndef __FAPI2_MULTICAST__
+#define __FAPI2_MULTICAST__
+
+#include <fapi2_multicast.H>
+
+namespace fapi2
+{
+
+template<MulticastType M, MulticastGroup G, typename V>
+template<MulticastType O, MulticastGroup N>
+inline void Multicast<M, G, V>::updateHandle(V& i_value)
+{
+ // Update handle only if multicast bit is set in handle, else we leave the
+ // handle unchanged. This enables the same procedure to work with both
+ // multicast and unicast targets
+ if(i_value.fields.is_multicast)
+ {
+ // Update the handle to reflect the new multicast type and group
+ i_value.fields.chiplet_num = (0x40) | (O << 3) | N;
+ }
+}
+
+template<MulticastType M, MulticastGroup G, typename V>
+inline bool Multicast<M, G, V>::isMulticast() const
+{
+ return iv_handle.fields.is_multicast;
+}
+
+}
+
+#endif
diff --git a/hwpf/include/plat/plat_target.H b/hwpf/include/plat/plat_target.H
index 95a2282b..094803cb 100644
--- a/hwpf/include/plat/plat_target.H
+++ b/hwpf/include/plat/plat_target.H
@@ -32,7 +32,16 @@
#include <stdint.h>
#include <target_types.H>
+#include <target_states.H>
#include <assert.h>
+#include <plat_target_parms.H>
+#include <vector>
+
+static const uint8_t CORES_PER_QUAD = 4;
+static const uint8_t EX_PER_QUAD = 2;
+static const uint8_t CORES_PER_EX = 2;
+static const uint8_t N3_CHIPLET = 5;
+static const uint8_t MCS_PER_MCBIST = 2;
//
// Define what a platform handle looks like. For Hostboot,
@@ -63,30 +72,145 @@ namespace fapi2
uint32_t type_target_num : 8;
uint32_t present : 1;
uint32_t functional : 1;
- uint32_t _reserved_b1 : 1;
+ uint32_t is_multicast : 1;
uint32_t valid : 1;
uint32_t type : 12;
#else
uint32_t type : 12;
uint32_t valid : 1;
- uint32_t _reserved_b1 : 1;
+ uint32_t is_multicast : 1;
uint32_t functional : 1;
uint32_t present : 1;
uint32_t type_target_num : 8;
uint32_t chiplet_num : 8;
#endif
} fields;
- // Union Constructor
+ ///
+ /// @brief Plat target handle constructor
+ ///
+ /// @param i_value Value to instantiate handle with
+ ///
plat_target_handle(uint32_t i_value = 0):value(i_value) {}
-
+ ///
+ /// @brief Get the fapi2::TargetType for this target
+ ///
+ /// @par Converts the internal PPE type for this target to fapi2 enum
+ ///
+ /// @return The fapi2::TargetType for this target
+ ///
TargetType getFapiTargetType() const;
+ ///
+ /// @brief Get the instance number for this target
+ ///
+ /// @return The instance number for this target
+ ///
inline uint32_t getTargetInstance() const
{
return fields.type_target_num;
}
+
+ ///
+ /// @brief Get this target's children
+ ///
+ /// @param [in] i_parentType fapi2 type of the parent
+ /// @param [in] i_childType fapi2 type of the child
+ /// @param [in] i_platType Plat type of the parent
+ /// @param [in] i_state Required state of the children
+ /// @param [out] o_children A vector of child target handles
+ ///
+ void getChildren(const TargetType i_parentType,
+ const TargetType i_childType,
+ const plat_target_type_t i_platType,
+ const TargetState i_state,
+ std::vector<plat_target_handle> &o_children) const;
+
+ ///
+ /// @brief Get proc chip target's children - filtered
+ ///
+ /// @param [in] i_filter Target filter
+ /// @param [in] i_state Required state of the children
+ /// @param [out] o_children A vector of child target handles
+ ///
+ void getChildren(const TargetFilter i_filter,
+ const TargetState i_state,
+ std::vector<plat_target_handle>& o_children) const;
+
+ ///
+ /// @brief Gets the plat target handle as a uint32
+ ///
+ /// @return Plat target handle as a uint32_t
+ ///
+ operator uint32_t() const {return value;}
} plat_target_handle_t;
+
+ typedef plat_target_handle_t plat_target_argument_t;
+
+ template<TargetType K, bool MULTICAST = false>
+ plat_target_handle_t createPlatTargetHandle(const uint32_t i_plat_argument)
+ {
+ static_assert((MULTICAST != true) || (K == TARGET_TYPE_PROC_CHIP),
+ "Only PROC_CHIP types can be multicast");
+ plat_target_handle_t l_handle = 0;
+
+ if(MULTICAST == true)
+ {
+ // Simply set the is multicast flag
+ l_handle.fields.is_multicast = 1;
+ }
+ else if(K & TARGET_TYPE_PROC_CHIP)
+ {
+ l_handle.fields.chiplet_num = 0;
+ l_handle.fields.type = PPE_TARGET_TYPE_PROC_CHIP;
+ l_handle.fields.type_target_num = 0;
+ }
+ else if(K & TARGET_TYPE_PERV)
+ {
+ l_handle.fields.chiplet_num = i_plat_argument + NEST_GROUP1_CHIPLET_OFFSET;
+ l_handle.fields.type = PPE_TARGET_TYPE_PERV;
+ l_handle.fields.type_target_num = i_plat_argument;
+ }
+ else if(K & TARGET_TYPE_CORE)
+ {
+ l_handle.fields.chiplet_num = i_plat_argument + CORE_CHIPLET_OFFSET;
+ l_handle.fields.type = PPE_TARGET_TYPE_CORE | PPE_TARGET_TYPE_PERV;
+ l_handle.fields.type_target_num = i_plat_argument;
+ }
+ else if(K & TARGET_TYPE_EQ)
+ {
+ l_handle.fields.chiplet_num = i_plat_argument + EQ_CHIPLET_OFFSET;
+ l_handle.fields.type = PPE_TARGET_TYPE_EQ | PPE_TARGET_TYPE_PERV;
+ l_handle.fields.type_target_num = i_plat_argument;
+ }
+ else if(K & TARGET_TYPE_EX)
+ {
+ l_handle.fields.chiplet_num = (i_plat_argument / 2) + EX_CHIPLET_OFFSET;
+ l_handle.fields.type = PPE_TARGET_TYPE_EX;
+ l_handle.fields.type_target_num = i_plat_argument;
+ }
+ else if(K & TARGET_TYPE_MCBIST)
+ {
+ l_handle.fields.chiplet_num = i_plat_argument + MCBIST_CHIPLET_OFFSET;
+ l_handle.fields.type = PPE_TARGET_TYPE_MCBIST | PPE_TARGET_TYPE_PERV;
+ l_handle.fields.type_target_num = i_plat_argument;
+ }
+ else if(K & TARGET_TYPE_MCS)
+ {
+ l_handle.fields.chiplet_num = N3_CHIPLET - (MCS_PER_MCBIST * (i_plat_argument / MCS_PER_MCBIST));
+ l_handle.fields.type = PPE_TARGET_TYPE_MCS;
+ l_handle.fields.type_target_num = i_plat_argument;
+ }
+ else if(K == TARGET_TYPE_ALL)
+ {
+ l_handle.fields.chiplet_num = i_plat_argument;
+ l_handle.fields.type = PPE_TARGET_TYPE_ALL;
+ }
+
+ l_handle.fields.valid = 1;
+ return l_handle;
+ }
+
};
#endif
diff --git a/hwpf/include/plat/plat_target_utils.H b/hwpf/include/plat/plat_target_utils.H
index 33dc7740..2f602349 100644
--- a/hwpf/include/plat/plat_target_utils.H
+++ b/hwpf/include/plat/plat_target_utils.H
@@ -70,5 +70,18 @@ namespace fapi2
template <TargetType K>
plat_target_handle_t plat_getTargetHandleByChipletNumber(
const uint8_t i_chipletNumber);
+
+ /// @brief Function to return a platform target handle, given the target
+ /// instance number and the fapi2 Target type
+ // @tparam K The fapi2 TargetType
+ // @param i_targetNum The instance number for the target
+ // @return Platform handle
+ // @note The caller can use the platform handle to construct a Target of
+ // it's choice. Ex:
+ // fapi2::Target<fapi2::TARGET_TYPE_EX>
+ // l_ex(plat_getTargetHandleByInstance<fapi2::TARGET_TYPE_EX>(0);
+ template <TargetType K>
+ plat_target_handle_t plat_getTargetHandleByInstance(
+ const uint8_t i_targetNum);
}
#endif
diff --git a/hwpf/include/plat/target.H b/hwpf/include/plat/target.H
index f61e40dd..9ed8de29 100644
--- a/hwpf/include/plat/target.H
+++ b/hwpf/include/plat/target.H
@@ -33,6 +33,7 @@
#include <plat_target.H>
#include <plat_target_parms.H>
#include <fapi2_target.H>
+#include <multicast.H>
#include <plat_trace.H>
#include <utils.H>
#include <stdint.h>
@@ -43,12 +44,6 @@ extern "C"
extern std::vector<fapi2::plat_target_handle_t> G_vec_targets;
}
-static const uint8_t CORES_PER_QUAD = 4;
-static const uint8_t EX_PER_QUAD = 2;
-static const uint8_t CORES_PER_EX = 2;
-static const uint8_t N3_CHIPLET = 5;
-static const uint8_t MCS_PER_MCBIST = 2;
-
struct ScomAddr
{
ScomAddr(uint32_t i_addr) : iv_addr(i_addr)
@@ -130,78 +125,6 @@ namespace fapi2
return PPE_TARGET_TYPE_PERV;
}
- /// @brief Create a Target, with a value
- /// @param[in] Value the value (i.e., specific element this
- /// target represents, or pointer)
- /// @note Platforms can mangle the value and K to get a
- /// single uint64_t in value which represents all the information
- /// they might need. value( K | V ), for example
- ///
- template<TargetType K, typename V>
- Target<K, V>::Target(V Value)
- {
- uint32_t l_plat_argument = Value.value;
- // Already formed target handle?
- if(Value.fields.valid == 1)
- {
- this->iv_handle = Value;
- return;
- }
-
- this->iv_handle.value = 0;
- if(K & TARGET_TYPE_PROC_CHIP)
- {
- this->iv_handle.fields.chiplet_num = 0;
- this->iv_handle.fields.type = PPE_TARGET_TYPE_PROC_CHIP;
- this->iv_handle.fields.type_target_num = 0;
- }
- else if(K & TARGET_TYPE_PERV)
- {
- this->iv_handle.fields.chiplet_num = l_plat_argument + NEST_GROUP1_CHIPLET_OFFSET;
- this->iv_handle.fields.type = PPE_TARGET_TYPE_PERV;
- this->iv_handle.fields.type_target_num = l_plat_argument;
- }
- else if(K & TARGET_TYPE_CORE)
- {
- this->iv_handle.fields.chiplet_num = l_plat_argument + CORE_CHIPLET_OFFSET;
- this->iv_handle.fields.type = PPE_TARGET_TYPE_CORE | PPE_TARGET_TYPE_PERV;
- this->iv_handle.fields.type_target_num = l_plat_argument;
- }
- else if(K & TARGET_TYPE_EQ)
- {
- this->iv_handle.fields.chiplet_num = l_plat_argument + EQ_CHIPLET_OFFSET;
- this->iv_handle.fields.type = PPE_TARGET_TYPE_EQ | PPE_TARGET_TYPE_PERV;
- this->iv_handle.fields.type_target_num = l_plat_argument;
- }
- else if(K & TARGET_TYPE_EX)
- {
- this->iv_handle.fields.chiplet_num = (l_plat_argument / 2) + EX_CHIPLET_OFFSET;
- this->iv_handle.fields.type = PPE_TARGET_TYPE_EX;
- this->iv_handle.fields.type_target_num = l_plat_argument;
- }
- else if(K & TARGET_TYPE_MCBIST)
- {
-
- this->iv_handle.fields.chiplet_num = l_plat_argument + MCBIST_CHIPLET_OFFSET;
- this->iv_handle.fields.type = PPE_TARGET_TYPE_MCBIST | PPE_TARGET_TYPE_PERV;
- this->iv_handle.fields.type_target_num = l_plat_argument;
- }
- else if(K & TARGET_TYPE_MCS)
- {
- this->iv_handle.fields.chiplet_num = N3_CHIPLET - (MCS_PER_MCBIST * (l_plat_argument / MCS_PER_MCBIST));
- this->iv_handle.fields.type = PPE_TARGET_TYPE_MCS;
- this->iv_handle.fields.type_target_num = l_plat_argument;
- }
- else if(K == TARGET_TYPE_ALL)
- {
- this->iv_handle.fields.chiplet_num = l_plat_argument;
- this->iv_handle.fields.type = PPE_TARGET_TYPE_ALL;
- }
-
- this->iv_handle.fields.valid = 1;
-
- }
-
///
/// @brief Assignment Operator.
/// @param[in] i_right Reference to Target to assign from.
@@ -248,17 +171,20 @@ namespace fapi2
///
/// @brief Get this target's immediate parent
/// @tparam T The type of the parent
- /// @return Target<T> a target representing the parent
+ /// @return Target<T, V> a target representing the parent
///
template<TargetType K, typename V>
template<TargetType T>
- inline Target<T> Target<K, V>::getParent(void) const
+ inline Target<T, V> Target<K, V>::getParent(void) const
{
static_assert(((K == TARGET_TYPE_EQ) ||
(K == TARGET_TYPE_CORE) ||
(K == TARGET_TYPE_MCBIST) ||
(K == TARGET_TYPE_PERV) ||
- (K == TARGET_TYPE_EX)) &&
+ (K == TARGET_TYPE_EX) ||
+ (K == TARGET_TYPE_PROC_CHIP) ||
+ (K == (TARGET_TYPE_PROC_CHIP | TARGET_TYPE_EQ)) ||
+ (K == (TARGET_TYPE_PROC_CHIP | TARGET_TYPE_CORE))) &&
((T == TARGET_TYPE_EQ) ||
(T == TARGET_TYPE_EX) ||
(T == TARGET_TYPE_PROC_CHIP) ||
@@ -299,23 +225,23 @@ namespace fapi2
if(TARGET_TYPE_PERV == T) // EQ/EC/MCBIST/PERV ===> PERV
{
- return this->iv_handle;
+ return static_cast<V>(this->iv_handle);
}
if(TARGET_TYPE_PROC_CHIP == T) // EQ/EC/EX/MCBIST/PERV ===> PROC
{
- return G_vec_targets[CHIP_TARGET_OFFSET];
+ return static_cast<V>(G_vec_targets[CHIP_TARGET_OFFSET]);
}
if((TARGET_TYPE_EQ == T) && (TARGET_TYPE_CORE == K)) // EC ===> EQ
{
- return G_vec_targets[(getTargetNumber() / CORES_PER_QUAD) + EQ_TARGET_OFFSET];
+ return static_cast<V>(G_vec_targets[(getTargetNumber() / CORES_PER_QUAD) + EQ_TARGET_OFFSET]);
}
if((TARGET_TYPE_EQ == T) && (TARGET_TYPE_EX == K)) // EX ===> EQ
{
- return G_vec_targets[(getTargetNumber() / EX_PER_QUAD) + EQ_TARGET_OFFSET];
+ return static_cast<V>(G_vec_targets[(getTargetNumber() / EX_PER_QUAD) + EQ_TARGET_OFFSET]);
}
if(TARGET_TYPE_EX == T) // EC ===> EX
{
- return G_vec_targets[(getTargetNumber() / CORES_PER_EX) + EX_TARGET_OFFSET];
+ return static_cast<V>(G_vec_targets[(getTargetNumber() / CORES_PER_EX) + EX_TARGET_OFFSET]);
}
}
@@ -324,187 +250,75 @@ namespace fapi2
/// @tparam V The plat target handle type
/// @tparam T The type of child
/// @param[in] i_state The desired TargetState of the children
- /// @return std::vector<Target<T> > a vector of present/functional
+ /// @return std::vector<Target<T, V> > a vector of present/functional
/// children
/// @warning The children are returned in order, ex child[0] is
/// std::vector[0]
template<TargetType K, typename V>
template<TargetType T>
- std::vector<Target<T>>
+ std::vector<Target<T, V>>
Target<K, V>::getChildren(const TargetState i_state) const
{
- static_assert(((K == TARGET_TYPE_EQ) || (K == TARGET_TYPE_EX)) &&
- ((T == TARGET_TYPE_EX) || (T == TARGET_TYPE_CORE)),
- "Invalid parent/child passed to getChildren");
+ constexpr TargetType L = static_cast<TargetType>(K & ~(TARGET_TYPE_PROC_CHIP));
+ constexpr plat_target_type_t P = fapiTargetTypeToPlatTargetType<T>();
+
+ static_assert(sizeof(Target<T, V>) == sizeof(plat_target_handle_t),
+ "Sizes of plat target and FAPI target must match");
+
+ static_assert(((L == TARGET_TYPE_EQ) || (L == TARGET_TYPE_EX) || (K == TARGET_TYPE_PROC_CHIP)),
+ "Invalid parent passed to getChildren");
// valid children for EQ
// EQ -> CORE
// EQ -> EX
- static_assert(!((K == fapi2::TARGET_TYPE_EQ) &&
+ static_assert(!((L == fapi2::TARGET_TYPE_EQ) &&
(T != fapi2::TARGET_TYPE_CORE) &&
(T != fapi2::TARGET_TYPE_EX)),
"improper child of fapi2::TARGET_TYPE_EQ");
// valid children for EX
// EX -> CORE
- static_assert(!((K == fapi2::TARGET_TYPE_EX) &&
+ static_assert(!((L == fapi2::TARGET_TYPE_EX) &&
(T != fapi2::TARGET_TYPE_CORE)),
"improper child of fapi2::TARGET_TYPE_EX");
- std::vector<Target<T> > l_children;
- uint32_t l_childPerChiplet = 0;
- uint32_t l_childTargetOffset = 0;
-
- // EQ ==> EX
- if((K == TARGET_TYPE_EQ) && (T == TARGET_TYPE_EX))
- {
- l_childPerChiplet = EX_PER_QUAD;
- l_childTargetOffset = EX_TARGET_OFFSET;
- }
-
- // EQ ==> EC
- if((K == TARGET_TYPE_EQ) && (T == TARGET_TYPE_CORE))
- {
- l_childPerChiplet = CORES_PER_QUAD;
- l_childTargetOffset = CORE_TARGET_OFFSET;
- }
-
- // EX ==> EC
- if((K == TARGET_TYPE_EX) && (T == TARGET_TYPE_CORE))
- {
- l_childPerChiplet = CORES_PER_EX;
- l_childTargetOffset = CORE_TARGET_OFFSET;
- }
-
- for(uint32_t i = 0; i < l_childPerChiplet; ++i)
- {
- Target<T> *l_temp = reinterpret_cast< Target<T>* >(&G_vec_targets.at((getTargetNumber() * l_childPerChiplet) + l_childTargetOffset + i));
- switch (i_state)
- {
- case TARGET_STATE_PRESENT:
- if ((*l_temp).getPresent())
- {
- l_children.push_back((*l_temp));
- }
- break;
- case TARGET_STATE_FUNCTIONAL:
- if ((*l_temp).getFunctional())
- {
- l_children.push_back((*l_temp));
- }
- break;
- default:
- assert(false);
- }
- }
-
- return l_children;
- }
-
- ///
- /// @brief Get this target's children - specialization for PROC_CHIP
- /// @tparam T The type of child
- /// @param[in] i_state The desired TargetState of the children
- /// @return std::vector<Target<T> > a vector of present/functional
- /// children
- ///
- template<>
- template< TargetType T>
- std::vector<Target<T> >
- Target<TARGET_TYPE_PROC_CHIP>::getChildren(const TargetState i_state) const
- {
- std::vector<fapi2::plat_target_handle_t>::iterator l_iter;
- std::vector<Target<T> > l_children;
- constexpr plat_target_type_t P = fapiTargetTypeToPlatTargetType<T>();
-
- for (l_iter = G_vec_targets.begin(); l_iter != G_vec_targets.end(); ++l_iter)
- {
- Target<T> * l_temp = reinterpret_cast< Target<T>* >(l_iter);
- if (((*l_temp).getTargetType() & P) == P)
- {
- switch (i_state)
- {
- case TARGET_STATE_PRESENT:
- if ((*l_temp).getPresent())
- {
- l_children.push_back((*l_temp));
- }
- break;
- case TARGET_STATE_FUNCTIONAL:
- if ((*l_temp).getFunctional())
- {
- l_children.push_back((*l_temp));
- }
- break;
- default:
- assert(false);
- }
- }
- }
+ std::vector<Target<T, V> > l_children;
+ static_cast<plat_target_handle_t>(get()).getChildren(K, T, P, i_state, reinterpret_cast<std::vector<plat_target_handle>&>(l_children));
return l_children;
}
// Specialization of getChildren, filtered for the chip target
template<TargetType K, typename V>
template<TargetType T>
- std::vector<Target<T> >
+ std::vector<Target<T, V> >
Target<K, V>::getChildren(const TargetFilter i_filter,
const TargetState i_state) const
{
+ static_assert(sizeof(Target<T, V>) == sizeof(plat_target_handle_t),
+ "Sizes of plat target and FAPI target must match");
+
static_assert((K == TARGET_TYPE_PROC_CHIP), "Parent target must be the proc chip");
static_assert((T == TARGET_TYPE_EQ) || (T == TARGET_TYPE_CORE)
|| (T == TARGET_TYPE_PERV) || (T == TARGET_TYPE_MCBIST),
"Child target type must be a pervasive chiplet");
std::vector<Target<T> > l_children;
- static const uint64_t mask = 1;
-
- // Walk the bits in the input target filter. For every bit, at
- // position x, that is set, x can be used as an index into our global
- // target vector (indexed by chiplet number)
- for (uint32_t l_idx = 0;
- l_idx < sizeof(TargetFilter) * 8;
- ++l_idx)
- {
- if (i_filter & (mask << (((sizeof(TargetFilter)*8)-1) - l_idx)))
- {
- plat_target_handle_t l_targetHandle = G_vec_targets.at(l_idx + NEST_GROUP1_CHIPLET_OFFSET);
-
- if(l_targetHandle.fields.type & PPE_TARGET_TYPE_PERV) // Can be an assertion?
- {
- switch (i_state)
- {
- case TARGET_STATE_PRESENT:
- if(l_targetHandle.fields.present)
- {
- l_children.push_back(l_targetHandle);
- }
- break;
- case TARGET_STATE_FUNCTIONAL:
- if(l_targetHandle.fields.functional)
- {
- l_children.push_back(l_targetHandle);
- }
- break;
- default:
- break;
- }
- }
- }
- }
- return l_children;
+
+ (static_cast<plat_target_handle_t>(get())).getChildren(i_filter, i_state, reinterpret_cast<std::vector<plat_target_handle_t>&>(l_children));
+
+ return l_children;
}
///
/// @brief Get the target at the other end of a bus - dimm included
/// @tparam T The type of the parent
/// @param[in] i_state The desired TargetState of the children
- /// @return Target<T> a target representing the thing on the other end
+ /// @return Target<T, V> a target representing the thing on the other end
/// @note Can be easily changed to a vector if needed
///
template<TargetType K, typename V>
template<TargetType T>
- inline Target<T>
+ inline Target<T, V>
Target<K, V>::getOtherEnd(const TargetState i_state) const
{
// static_assert( false, "getOtherEnd() is not supported on PPE platforms");
@@ -533,15 +347,15 @@ namespace fapi2
/// @post The contents of the buffer is replaced with the string
/// representation of the target
///
- template< TargetType T >
- inline void toString(const Target<T>& i_target, char* i_buffer, size_t i_bsize)
+ template< TargetType T, typename V >
+ inline void toString(const Target<T, V>& i_target, char* i_buffer, size_t i_bsize)
{
snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target.get(), T);
}
- template<TargetType T>
+ template<TargetType T, typename V>
__attribute__((always_inline))
- inline uint32_t getEffectiveAddress(const Target<T> &i_target,
+ inline uint32_t getEffectiveAddress(const Target<T, V> &i_target,
const uint32_t i_addr)
{
ScomAddr l_addr = i_addr;
@@ -590,15 +404,15 @@ namespace fapi2
/// @brief Return the string interpretation of this target
/// @tparam T The type of the target
/// @tparam B The type of the buffer
- /// @param[in] A pointer to the Target<T>
+ /// @param[in] A pointer to the Target<T, V>
/// @param[in] i_buffer buffer to write in to
/// @param[in] i_bsize size of the buffer
/// @return void
/// @post The contents of the buffer is replaced with the string
/// representation of the target
///
- template< TargetType T >
- inline void toString(const Target<T>* i_target, char* i_buffer, size_t i_bsize)
+ template< TargetType T, typename V >
+ inline void toString(const Target<T, V>* i_target, char* i_buffer, size_t i_bsize)
{
snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target->get(), T);
}
@@ -608,13 +422,13 @@ namespace fapi2
/// @tparam T The type of the target
/// @param[in] Ordinal representing the ordinal number of
/// the desired target
- /// @return Target<T> the target requested
+ /// @return Target<T, V> the target requested
///
- template<TargetType T>
- inline Target<T> getTarget(uint64_t Ordinal)
+ template<TargetType T, typename V>
+ inline Target<T, V> getTarget(uint64_t Ordinal)
{
// For testing
- return Target<T>(Ordinal);
+ return Target<T, V>(Ordinal);
}
}
OpenPOWER on IntegriCloud