Skip to content

Commit

Permalink
OCMB changes to suit PPE compilation.
Browse files Browse the repository at this point in the history
Change-Id: If1146defe839abe50a35daa633d8bfc2e9aa1bdf
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/76637
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Christian R Geddes <crgeddes@us.ibm.com>
Reviewed-by: MURULIDHAR NATARAJU <murulidhar@in.ibm.com>
Reviewed-by: RAJA DAS <rajadas2@in.ibm.com>
Tested-by: HWSV CI <hwsv-ci+hostboot@us.ibm.com>
Reviewed-by: Jennifer A Stofer <stofer@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/77308
  • Loading branch information
skumar8j authored and RAJA DAS committed Jul 25, 2019
1 parent 4ece76d commit b141546
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 26 deletions.
Expand Up @@ -36,9 +36,14 @@
#ifndef _MSS_EXP_I2C_FIELDS_H_
#define _MSS_EXP_I2C_FIELDS_H_

#include <generic/memory/lib/utils/mss_field.H>
#include <lib/shared/exp_consts.H>
#include <functional>
#ifdef __PPE__
#include <mss_field.H>
#include <exp_consts.H>
#else
#include <generic/memory/lib/utils/mss_field.H>
#include <lib/shared/exp_consts.H>
#endif

namespace mss
{
Expand Down Expand Up @@ -241,6 +246,7 @@ inline fapi2::ReturnCode get_field(const fapi2::Target<fapi2::TARGET_TYPE_OCMB_C
return mss::get_field<endian::BIG, F, TT>(i_target, i_data, EXP_I2C_GET_FIELD, o_value);
}

#ifndef __PPE__
///
/// @brief Explorer I2C field setter
/// @tparam IT Input type
Expand Down Expand Up @@ -461,6 +467,8 @@ inline fapi2::ReturnCode set_fw_mode(const fapi2::Target<fapi2::TARGET_TYPE_OCMB

}// boot_cfg

#endif

namespace status
{

Expand All @@ -478,6 +486,7 @@ inline fapi2::ReturnCode get_boot_stage(const fapi2::Target<fapi2::TARGET_TYPE_O
return get_field<fields::BOOT_STAGE>(i_target, i_data, o_setting);
}


///
/// @brief STATUS_CODE getter
/// @param[in] i_target the OCMB target
Expand All @@ -492,6 +501,7 @@ inline fapi2::ReturnCode get_status_code(const fapi2::Target<fapi2::TARGET_TYPE_
return get_field<fields::STATUS_CODE>(i_target, i_data, o_setting);
}

#ifndef __PPE__
///
/// @brief CMD_ID getter
/// @param[in] i_target the OCMB target
Expand All @@ -505,6 +515,7 @@ inline fapi2::ReturnCode get_cmd_id(const fapi2::Target<fapi2::TARGET_TYPE_OCMB_
{
return get_field<fields::CMD_ID>(i_target, i_data, o_setting);
}
#endif

}// status
}// i2c
Expand Down
Expand Up @@ -36,7 +36,9 @@
#ifndef MSS_EXP_CONSTS_H
#define MSS_EXP_CONSTS_H

#include <generic/memory/lib/utils/shared/mss_generic_consts.H>
#ifndef __PPE__
#include <generic/memory/lib/utils/shared/mss_generic_consts.H>
#endif

namespace mss
{
Expand All @@ -46,6 +48,7 @@ namespace exp

constexpr uint32_t OCMB_ADDR_SHIFT = 3;

#ifndef __PPE__
///
/// @brief enum list of explorer eff attributes to set
///
Expand Down Expand Up @@ -83,6 +86,8 @@ enum sizes
MAX_MRANK_PER_PORT = MAX_DIMM_PER_PORT * MAX_RANK_PER_DIMM,
};

#endif

///
/// @brief explorer ffdc codes
///
Expand Down Expand Up @@ -197,6 +202,7 @@ enum status_codes
FW_BUSY = 0xFE,
};

#ifndef __PPE__
///
/// @brief status codes for FW_BOOT_CONFIG
///
Expand All @@ -214,6 +220,7 @@ enum fw_boot_cfg_status
FW_BOOT_CFG_UNSUPPORTED_SERDES_FREQ = 0x04,
};

#endif
///
/// @brief I2C boot stage options
/// @note certain cmds work in certain boot stages
Expand Down Expand Up @@ -261,9 +268,9 @@ enum addrSide
RHS = 0x01
};


}// i2c

#ifndef __PPE__
namespace omi
{

Expand Down Expand Up @@ -327,6 +334,8 @@ enum response_arg
};

}// omi
#endif

}// exp
}// mss

Expand Down
Expand Up @@ -102,6 +102,7 @@
Explorer status code for command ID EXP_FW_STATUS
did not return SUCCESS
</description>
<ffdc>TARGET</ffdc>
<ffdc>STATUS_CODE</ffdc>
<ffdc>CMD_ID</ffdc>
<callout>
Expand All @@ -123,6 +124,7 @@
Received FW_BUSY status after polling timeout for
command ID EXP_FW_STATUS
</description>
<ffdc>TARGET</ffdc>
<ffdc>STATUS_CODE</ffdc>
<callout>
<procedure>CODE</procedure>
Expand All @@ -143,6 +145,7 @@
Received incorrect boot stage from
command ID EXP_FW_STATUS
</description>
<ffdc>TARGET</ffdc>
<ffdc>BOOT_STAGE</ffdc>
<ffdc>EXPECTED_BOOT_STAGE</ffdc>
<callout>
Expand Down
34 changes: 28 additions & 6 deletions src/import/generic/memory/lib/utils/endian_utils.H
Expand Up @@ -37,9 +37,14 @@
#ifndef _ENDIAN_UTILS_H_
#define _ENDIAN_UTILS_H_

#include <cstdint>
#include <vector>
#include <generic/memory/lib/utils/shared/mss_generic_consts.H>

#ifdef __PPE__
#include <mss_generic_consts.H>
#else
#include <cstdint>
#include <generic/memory/lib/utils/shared/mss_generic_consts.H>
#endif

namespace mss
{
Expand Down Expand Up @@ -67,6 +72,7 @@ void forceLE(const T& i_input, std::vector<uint8_t>& io_data)
}
}

#ifndef __PPE__
///
/// @brief Forces native data into LE order for an array
/// @tparam T the data type to process
Expand All @@ -82,7 +88,7 @@ inline void forceLEArray(const T* i_input, const uint64_t i_size, std::vector<ui
forceLE(i_input[i], io_data);
}
}

#endif
///
/// @brief Forces native data into BE order
/// @tparam T the data type to process
Expand All @@ -98,20 +104,31 @@ void forceBE(const T& i_input, std::vector<uint8_t>& io_data)
std::vector<uint8_t> l_tempBuffer;

// This loop will put i_input into l_tempBuffer in BE order
for(size_t i = 0; i < sizeof(i_input); i++)

for(size_t i = sizeof(i_input); i > 0; i--)
{
// Grab the lowest order byte and add it to the front of the vector
const uint8_t l_byte = l_temp & 0xFF;
l_tempBuffer.insert(l_tempBuffer.begin(), l_byte);
l_tempBuffer.push_back(l_byte);

// Shift higher byte value into lowest no matter existing endianness
l_temp >>= BITS_PER_BYTE;
}

// Put the new BE formatted data at the end of the input buffer
io_data.insert(io_data.end(), l_tempBuffer.begin(), l_tempBuffer.end());

std::vector<uint8_t>::iterator it = l_tempBuffer.end();
--it; //Move iterator to the last element.

for(uint8_t i = l_tempBuffer.size(); i > 0; --i)
{
io_data.push_back(*it);
--it;
}

}

#ifndef __PPE__
///
/// @brief Forces native data into BE order for an array
/// @tparam T the data type to process
Expand All @@ -127,6 +144,7 @@ inline void forceBEArray(const T* i_input, const uint64_t i_size, std::vector<ui
forceBE(i_input[i], io_data);
}
}
#endif

///
/// @brief Converts LE data into native order
Expand Down Expand Up @@ -165,6 +183,7 @@ bool readLE(const std::vector<uint8_t>& i_input, uint32_t& io_idx, T& o_data)
return true;
}

#ifndef __PPE__
///
/// @brief Converts LE data into native order
/// @tparam T the data type to output to
Expand All @@ -188,6 +207,7 @@ bool readLEArray(const std::vector<uint8_t>& i_input, const uint32_t i_size, uin

return l_passing;
}
#endif

///
/// @brief Converts BE data into native order
Expand Down Expand Up @@ -225,6 +245,7 @@ bool readBE(const std::vector<uint8_t>& i_input, uint32_t& io_idx, T& o_data)
return true;
}

#ifndef __PPE__
///
/// @brief Converts BE data into native order
/// @tparam T the data type to output to
Expand All @@ -248,6 +269,7 @@ bool readBEArray(const std::vector<uint8_t>& i_input, const uint32_t i_size, uin

return l_passing;
}
#endif

}

Expand Down
40 changes: 29 additions & 11 deletions src/import/generic/memory/lib/utils/mss_field.H
Expand Up @@ -37,8 +37,21 @@
#ifndef _MSS_FIELD_H_
#define _MSS_FIELD_H_

#include <generic/memory/lib/utils/shared/mss_generic_consts.H>
#include <generic/memory/lib/utils/mss_generic_check.H>
#ifdef __PPE__
#include <mss_generic_check.H>
#else
#include <generic/memory/lib/utils/shared/mss_generic_consts.H>
#include <generic/memory/lib/utils/mss_generic_check.H>
#endif

//Macro
#ifdef __PPE__
#define TARGIDFORMAT "0x%08X"
#define TARGTID i_target.get()
#else
#define TARGIDFORMAT "%s"
#define TARGTID spd::c_str(i_target)
#endif

namespace mss
{
Expand Down Expand Up @@ -190,18 +203,18 @@ inline fapi2::ReturnCode get_field(const fapi2::Target<T>& i_target,
.set_LIST_SIZE(i_data.size())
.set_FUNCTION(i_ffdc_codes)
.set_TARGET(i_target),
"Out of bounds indexing (with %d) on a list of size %d for %s",
"Out of bounds indexing (with %d) on a list of size %d for " TARGIDFORMAT,
BYTE,
i_data.size(),
spd::c_str(i_target));
TARGTID);

{
// Extracting desired bits
const fapi2::buffer<OT> l_buffer(i_data[BYTE]);
l_buffer.template extractToRight<F.get_start(), F.get_length()>(o_value);

FAPI_DBG("%s data[%d] = 0x%02x. Field with start bit %d, bit len %d, has data 0x%02x.",
spd::c_str(i_target),
FAPI_DBG(TARGIDFORMAT " data[%d] = 0x%02x. Field with start bit %d, bit len %d, has data 0x%02x.",
TARGTID,
BYTE,
i_data[BYTE],
F.get_start(),
Expand All @@ -214,6 +227,7 @@ inline fapi2::ReturnCode get_field(const fapi2::Target<T>& i_target,
fapi_try_exit:
return fapi2::current_err;
}
#ifndef __PPE__

///
/// @brief Helper function to set byte field information
Expand Down Expand Up @@ -274,6 +288,7 @@ inline fapi2::ReturnCode set_field(const fapi2::Target<T>& i_target,
fapi_try_exit:
return fapi2::current_err;
}
#endif

///
/// @brief byte field reader
Expand Down Expand Up @@ -303,7 +318,7 @@ inline fapi2::ReturnCode get_field( const fapi2::Target<T>& i_target,
{
IT l_temp = 0;
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) );
"Failed get_field() for " TARGIDFORMAT, TARGTID );

// Test if retrieved data seems valid
FAPI_TRY( check::invalid_value(i_target,
Expand All @@ -313,29 +328,31 @@ inline fapi2::ReturnCode get_field( const fapi2::Target<T>& i_target,
F.get_byte(i_data),
l_temp,
i_ffdc_codes),
"Failed fail_for_invalid_value() for %s", spd::c_str(i_target) );
"Failed fail_for_invalid_value() for " TARGIDFORMAT, TARGTID );


// Output should only change if data check passes
o_value = static_cast<OT>(l_temp);

FAPI_ASSERT( o_value == l_temp,
fapi2::MSS_CONVERSION_ERROR()
.set_ORIGINAL_VAL(l_temp)
.set_CONVERTED_VAL(o_value)
.set_TARGET(i_target)
.set_FUNCTION(i_ffdc_codes),
"Conversion error between original %d to converted %d value for %s",
l_temp, o_value, spd::c_str(i_target) );
"Conversion error between original %d to converted %d value for " TARGIDFORMAT,
l_temp, o_value, TARGTID);

FAPI_DBG("%s: 0x%02x for %s",
TT::FIELD_STR,
o_value,
spd::c_str(i_target));


fapi_try_exit:
return fapi2::current_err;
}

#ifndef __PPE__
///
/// @brief byte field writer
/// @tparam E endian type
Expand Down Expand Up @@ -388,6 +405,7 @@ inline fapi2::ReturnCode set_field( const fapi2::Target<T>& i_target,
fapi_try_exit:
return fapi2::current_err;
}
#endif

}// mss

Expand Down

0 comments on commit b141546

Please sign in to comment.