Skip to content

Commit

Permalink
Initial mss_field endian modification
Browse files Browse the repository at this point in the history
Change-Id: Ia64288c78b36dc77cd0440a83e859650631e3c06
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/65722
Reviewed-by: Louis Stermole <stermole@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: HWSV CI <hwsv-ci+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/66552
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
  • Loading branch information
aamarin authored and crgeddes committed Sep 27, 2018
1 parent f43f978 commit 0fb82ef
Show file tree
Hide file tree
Showing 9 changed files with 294 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,28 @@
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
#include <lib/i2c/exp_i2c_fields.H>

namespace mss
{
namespace exp
{
namespace i2c
{

// If a constexpr static data member (since C++11) is odr-used,
// a definition at namespace scope is still required, but it cannot have an initializer.
constexpr mss::field_t<mss::endian::BIG> fields::BOOT_MODE;
constexpr mss::field_t<mss::endian::BIG> fields::LANE_MODE;
constexpr mss::field_t<mss::endian::BIG> fields::SERDES_FREQ;
constexpr mss::field_t<mss::endian::BIG> fields::FW_MODE;
constexpr mss::field_t<mss::endian::BIG> fields::LOOPBACK_TEST;
constexpr mss::field_t<mss::endian::BIG> fields::TRANSPORT_LAYER;
constexpr mss::field_t<mss::endian::BIG> fields::DL_LAYER_BOOT_MODE;
constexpr mss::field_t<mss::endian::BIG> fields::CMD_ID;
constexpr mss::field_t<mss::endian::BIG> fields::STATUS_CODE;
constexpr mss::field_t<mss::endian::BIG> fields::BOOT_STAGE;

}// i2c
}// exp
}// mss
3 changes: 2 additions & 1 deletion src/import/generic/memory/lib/spd/spd_factory_pattern.C
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ factories::factories(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target,
"Failed to read DEVICE_TYPE field for %s", spd::c_str(i_target) );
FAPI_TRY( (reader<init_fields::HYBRID, spd::rev::GEN_SEC_MAX>(i_target, i_spd_data, iv_hybrid)),
"Failed to read HYBRID field for %s", spd::c_str(i_target) );
FAPI_TRY( (reader<init_fields::HYBRID_MEDIA, spd::rev::GEN_SEC_MAX>(i_target, i_spd_data, iv_hybrid_media)),
FAPI_TRY( (reader<init_fields::HYBRID_MEDIA, spd::rev::GEN_SEC_MAX>(i_target, i_spd_data,
iv_hybrid_media)),
"Failed to read HYBRID_MEDIA field for %s", spd::c_str(i_target) );

o_rc = fapi2::FAPI2_RC_SUCCESS;
Expand Down
18 changes: 18 additions & 0 deletions src/import/generic/memory/lib/spd/spd_field.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,21 @@
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
#include <generic/memory/lib/spd/spd_field.H>

namespace mss
{
namespace spd
{

// If a constexpr static data member (since C++11) is odr-used,
// a definition at namespace scope is still required, but it cannot have an initializer.
constexpr mss::field_t<mss::endian::LITTLE> init_fields::REVISION;
constexpr mss::field_t<mss::endian::LITTLE> init_fields::DEVICE_TYPE;
constexpr mss::field_t<mss::endian::LITTLE> init_fields::BASE_MODULE;
constexpr mss::field_t<mss::endian::LITTLE> init_fields::HYBRID;
constexpr mss::field_t<mss::endian::LITTLE> init_fields::HYBRID_MEDIA;
constexpr mss::field_t<mss::endian::LITTLE> init_fields::REF_RAW_CARD;

}// spd
}// mss
12 changes: 6 additions & 6 deletions src/import/generic/memory/lib/spd/spd_field.H
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ class init_fields
// 1st field: Byte number
// 2nd field: Start bit
// 3rd field: Bit length
static constexpr mss::field_t REVISION{1, REVISION_START, REVISION_LEN};
static constexpr mss::field_t DEVICE_TYPE{2, DEVICE_TYPE_START, DEVICE_TYPE_LEN};
static constexpr mss::field_t BASE_MODULE{3, BASE_MODULE_START, BASE_MODULE_LEN};
static constexpr mss::field_t HYBRID{3, HYBRID_START, HYBRID_LEN};
static constexpr mss::field_t HYBRID_MEDIA{3, HYBRID_MEDIA_START, HYBRID_MEDIA_LEN};
static constexpr mss::field_t REF_RAW_CARD{130, REF_RAW_CARD_START, REF_RAW_CARD_LEN};
static constexpr mss::field_t<mss::endian::LITTLE> REVISION{1, REVISION_START, REVISION_LEN};
static constexpr mss::field_t<mss::endian::LITTLE> DEVICE_TYPE{2, DEVICE_TYPE_START, DEVICE_TYPE_LEN};
static constexpr mss::field_t<mss::endian::LITTLE> BASE_MODULE{3, BASE_MODULE_START, BASE_MODULE_LEN};
static constexpr mss::field_t<mss::endian::LITTLE> HYBRID{3, HYBRID_START, HYBRID_LEN};
static constexpr mss::field_t<mss::endian::LITTLE> HYBRID_MEDIA{3, HYBRID_MEDIA_START, HYBRID_MEDIA_LEN};
static constexpr mss::field_t<mss::endian::LITTLE> REF_RAW_CARD{130, REF_RAW_CARD_START, REF_RAW_CARD_LEN};
};

///
Expand Down
336 changes: 171 additions & 165 deletions src/import/generic/memory/lib/spd/spd_fields_ddr4.H

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/import/generic/memory/lib/spd/spd_reader.H
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ namespace spd
/// @param[out] o_value raw value for this SPD field
/// @return FAPI2_RC_SUCCESS iff okay
///
template< const field_t& F,
template< const field_t<endian::LITTLE>& F,
rev R,
typename IT,
typename OT,
typename TT = readerTraits<F, R> >
fapi2::ReturnCode reader( const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target,
const std::vector<IT>& i_spd_data,
OT& o_value)
inline fapi2::ReturnCode reader( const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target,
const std::vector<IT>& i_spd_data,
OT& o_value)
{

FAPI_TRY( (mss::get_field<F, TT>(i_target, i_spd_data, mss::READ_SPD_FIELD, o_value)),
FAPI_TRY( (mss::get_field<endian::LITTLE, F, TT>(i_target, i_spd_data, mss::READ_SPD_FIELD, o_value)),
"Failed read_field() for %s", spd::c_str(i_target) );

fapi_try_exit:
Expand Down
2 changes: 1 addition & 1 deletion src/import/generic/memory/lib/spd/spd_traits.H
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace spd
/// @tparam F holds SPD field info
/// @tparam R the revision of the SPD field
///
template< const field_t& F, rev R >
template< const field_t<endian::LITTLE>& F, rev R >
class readerTraits;

///
Expand Down
2 changes: 1 addition & 1 deletion src/import/generic/memory/lib/spd/spd_traits_ddr4.H
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace spd
/// @note valid for all revisions
///
template<rev R>
class readerTraits < fields<DDR4, BASE_CNFG>::BYTES_USED, R>
class readerTraits < fields<DDR4, BASE_CNFG>::BYTES_USED, R >
{
public:

Expand Down
94 changes: 65 additions & 29 deletions src/import/generic/memory/lib/utils/mss_field.H
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,22 @@
namespace mss
{

///
/// @brief endian fields for use as a template selecor
///
enum class endian
{
BIG,
LITTLE,
};

///
/// @class field_t
/// @brief data structure for byte fields
/// @tparam E endian type for this field
/// @note holds byte index, start bit, and bit length of a decoded field
///
template< endian E >
class field_t
{
private:
Expand Down Expand Up @@ -84,10 +95,7 @@ class field_t
/// @brief Byte index getter
/// @return the byte index for this field
///
constexpr size_t get_byte() const
{
return iv_byte;
}
const size_t get_byte(const std::vector<uint8_t>& i_data) const;

///
/// @brief Starting bit getter
Expand All @@ -109,6 +117,26 @@ class field_t

};// field_t

///
/// @brief Byte index getter - big endian specialization
/// @return the byte index for this field
///
template<>
inline const size_t field_t<mss::endian::BIG>::get_byte(const std::vector<uint8_t>& i_data) const
{
return ( i_data.size() - 1 ) - iv_byte;
}

///
/// @brief Byte index getter - big endian specialization
/// @return the byte index for this field
///
template<>
inline const size_t field_t<mss::endian::LITTLE>::get_byte(const std::vector<uint8_t>& i_data) const
{
return iv_byte;
}

///
/// @brief Checks input field against a custom conditional
/// @tparam T field input type
Expand All @@ -119,15 +147,16 @@ class field_t
/// @return boolean true or false
///
template < typename T, typename F >
bool conditional(const T i_field,
const size_t i_comparison_val,
const F i_op)
inline bool conditional(const T i_field,
const size_t i_comparison_val,
const F i_op)
{
return i_op(i_field, i_comparison_val);
}

///
/// @brief Helper function to extract byte information
/// @tparam E endian type
/// @tparam F the field to extract
/// @tparam T the fapi2 target type
/// @tparam IT data input type
Expand All @@ -139,17 +168,18 @@ bool conditional(const T i_field,
/// @param[out] o_value raw value for this field
/// @return FAPI2_RC_SUCCESS iff okay
///
template< const field_t& F,
template< mss::endian E,
const mss::field_t<E>& F,
fapi2::TargetType T,
typename IT,
typename OT,
typename FFDC >
fapi2::ReturnCode get_field(const fapi2::Target<T>& i_target,
const std::vector<IT>& i_data,
const FFDC i_ffdc_codes,
OT& o_value)
inline fapi2::ReturnCode get_field(const fapi2::Target<T>& i_target,
const std::vector<IT>& i_data,
const FFDC i_ffdc_codes,
OT& o_value)
{
constexpr size_t BYTE = F.get_byte();
const size_t BYTE = F.get_byte(i_data);

FAPI_ASSERT( BYTE < i_data.size(),
fapi2::MSS_OUT_OF_BOUNDS_INDEXING()
Expand Down Expand Up @@ -184,6 +214,7 @@ fapi_try_exit:

///
/// @brief Helper function to set byte field information
/// @tparam E endian type
/// @tparam F the field to extract
/// @tparam T the fapi2 target type
/// @tparam IT data input type
Expand All @@ -195,17 +226,18 @@ fapi_try_exit:
/// @param[in,out] io_data the data to modify
/// @return FAPI2_RC_SUCCESS iff okay
///
template< const field_t& F,
template< mss::endian E,
const mss::field_t<E>& F,
fapi2::TargetType T,
typename IT,
typename OT,
typename FFDC >
fapi2::ReturnCode set_field(const fapi2::Target<T>& i_target,
const IT i_setting,
const FFDC i_ffdc_codes,
std::vector<OT>& io_data)
inline fapi2::ReturnCode set_field(const fapi2::Target<T>& i_target,
const IT i_setting,
const FFDC i_ffdc_codes,
std::vector<OT>& io_data)
{
constexpr size_t BYTE = F.get_byte();
const size_t BYTE = F.get_byte(io_data);

FAPI_ASSERT( BYTE < io_data.size(),
fapi2::MSS_OUT_OF_BOUNDS_INDEXING()
Expand Down Expand Up @@ -242,6 +274,7 @@ fapi_try_exit:

///
/// @brief byte field reader
/// @tparam E endian type
/// @tparam F the byte field to read
/// @tparam TT traits associated with F - required
/// @tparam T the fapi2 target type
Expand All @@ -253,7 +286,8 @@ fapi_try_exit:
/// @param[out] o_value raw value for this field
/// @return FAPI2_RC_SUCCESS iff okay
///
template< const field_t& F,
template< mss::endian E,
const mss::field_t<E>& F,
typename TT,
fapi2::TargetType T,
typename IT,
Expand All @@ -265,15 +299,15 @@ inline fapi2::ReturnCode get_field( const fapi2::Target<T>& i_target,
OT& o_value )
{
IT l_temp = 0;
FAPI_TRY( get_field<F>(i_target, i_data, i_ffdc_codes, l_temp),
FAPI_TRY( (get_field<E, F>(i_target, i_data, i_ffdc_codes, l_temp)),
"Failed get_field() for %s", spd::c_str(i_target) );

// Test if retrieved data seems valid
FAPI_TRY( check::invalid_value(i_target,
conditional( l_temp,
TT::COMPARISON_VAL,
typename TT::template COMPARISON_OP<IT>() ),
F.get_byte(),
F.get_byte(i_data),
l_temp,
i_ffdc_codes),
"Failed fail_for_invalid_value() for %s", spd::c_str(i_target) );
Expand Down Expand Up @@ -301,6 +335,7 @@ fapi_try_exit:

///
/// @brief byte field writer
/// @tparam E endian type
/// @tparam F the byte field to read
/// @tparam TT traits associated with writer
/// @tparam T the fapi2 target type
Expand All @@ -313,18 +348,19 @@ fapi_try_exit:
/// @param[in,out] io_data the data to modify
/// @return FAPI2_RC_SUCCESS iff okay
///
template< const field_t& F,
template< mss::endian E,
const mss::field_t<E>& F,
typename TT,
fapi2::TargetType T,
typename IT,
typename OT,
typename FFDC >
fapi2::ReturnCode set_field( const fapi2::Target<T>& i_target,
const IT i_setting,
const FFDC i_ffdc_codes,
std::vector<OT>& io_data )
inline fapi2::ReturnCode set_field( const fapi2::Target<T>& i_target,
const IT i_setting,
const FFDC i_ffdc_codes,
std::vector<OT>& io_data )
{
constexpr size_t BYTE = F.get_byte();
const size_t BYTE = F.get_byte(io_data);

// Test if the data we want to set is valid for this field
FAPI_TRY( check::invalid_value(i_target,
Expand All @@ -336,7 +372,7 @@ fapi2::ReturnCode set_field( const fapi2::Target<T>& i_target,
i_ffdc_codes),
"Failed fail_for_invalid_value() for %s", spd::c_str(i_target) );

FAPI_TRY( set_field<F>(i_target, i_setting, i_ffdc_codes, io_data),
FAPI_TRY( (set_field<E, F>(i_target, i_setting, i_ffdc_codes, io_data)),
"Failed set_field() for %s", spd::c_str(i_target) );

FAPI_INF("%s: Set value of 0x%02x. Data for buffer at byte %d, is now 0x%02x for %s",
Expand Down

0 comments on commit 0fb82ef

Please sign in to comment.