Skip to content

Commit

Permalink
Clean up PPE character format and target
Browse files Browse the repository at this point in the history
Removed duplicated code and abstracted out the
character target and format specifier into
reusable MACROS instead of a hacked redefine.

Change-Id: Id4b318b4a040aa5e366d0bdafdcaf55ceb73feef
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/92714
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com>
Dev-Ready: ANDRE A MARIN <aamarin@us.ibm.com>
Reviewed-by: Louis Stermole <stermole@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: Jennifer A Stofer <stofer@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/92724
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
  • Loading branch information
aamarin authored and dcrowell77 committed Mar 9, 2020
1 parent 9c2a95e commit a76d697
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 50 deletions.
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2018,2019 */
/* Contributors Listed Below - COPYRIGHT 2018,2020 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -40,24 +40,19 @@
#include <i2c_access.H>
#include <vector>

// reused TARGTIDFORMAT defined in generic/memory/lib/utils/mss_generic_check.H
#ifdef __PPE__
#include <exp_i2c_fields.H>
#include <endian_utils.H>
//Macro
#define MSSTARGID i_target.get
#else
#include <generic/memory/lib/utils/poll.H>
#include <lib/i2c/exp_i2c_fields.H>
#include <generic/memory/lib/utils/pos.H>
#include <generic/memory/lib/utils/endian_utils.H>
#endif


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

namespace mss
Expand Down Expand Up @@ -104,8 +99,8 @@ inline fapi2::ReturnCode status_code( const fapi2::Target<fapi2::TARGET_TYPE_OCM
set_TARGET(i_target).
set_STATUS_CODE(l_status).
set_CMD_ID(i_cmd_id),
"Status code did not return SUCCESS (%d), received (%d) for " TARGIDFORMAT ,
status_codes::SUCCESS, l_status, TARGID );
"Status code did not return SUCCESS (%d), received (%d) for " TARGTIDFORMAT ,
status_codes::SUCCESS, l_status, MSSTARGID );

return fapi2::FAPI2_RC_SUCCESS;

Expand Down Expand Up @@ -229,22 +224,22 @@ inline fapi2::ReturnCode fw_status(const fapi2::Target<fapi2::TARGET_TYPE_OCMB_C
FAPI_TRY( fapi2::delay( i_delay, 200) );
}

FAPI_DBG(TARGIDFORMAT " stopped on loop %u/%u", TARGID , l_loop, i_loops);
FAPI_DBG(TARGTIDFORMAT " stopped on loop %u/%u", MSSTARGID , l_loop, i_loops);
// Check that Explorer is not still in FW_BUSY state

FAPI_ASSERT( !l_busy,
fapi2::MSS_EXP_I2C_FW_STATUS_BUSY().
set_TARGET(i_target),
"Polling timeout on FW_STATUS command (still FW_BUSY) for " TARGIDFORMAT,
TARGID );
"Polling timeout on FW_STATUS command (still FW_BUSY) for " TARGTIDFORMAT,
MSSTARGID );
// Check that Explorer is in RUNTIME_FW boot stage
FAPI_ASSERT( (l_boot_stage == EXPECTED_BOOT_STAGE),
fapi2::MSS_EXP_I2C_WRONG_BOOT_STAGE().
set_TARGET(i_target).
set_BOOT_STAGE(l_boot_stage).
set_EXPECTED_BOOT_STAGE(EXPECTED_BOOT_STAGE),
"Polling timeout on FW_STATUS command (wrong boot stage: 0x%01x, expected 0x%01x) for " TARGIDFORMAT,
l_boot_stage, EXPECTED_BOOT_STAGE, TARGID );
"Polling timeout on FW_STATUS command (wrong boot stage: 0x%01x, expected 0x%01x) for " TARGTIDFORMAT,
l_boot_stage, EXPECTED_BOOT_STAGE, MSSTARGID );

fapi_try_exit:
return fapi2::current_err;
Expand Down Expand Up @@ -324,8 +319,8 @@ inline fapi2::ReturnCode check_fw_status_busy(const fapi2::Target<fapi2::TARGET_
set_TARGET(i_target).
set_STATUS_CODE(l_status).
set_CMD_ID(FW_STATUS),
"Status code did not return BUSY (%d) as expected post BOOT_CONFIG1, received (%d) for " TARGIDFORMAT ,
status_codes::FW_BUSY, l_status, TARGID );
"Status code did not return BUSY (%d) as expected post BOOT_CONFIG1, received (%d) for " TARGTIDFORMAT ,
status_codes::FW_BUSY, l_status, MSSTARGID );

return fapi2::FAPI2_RC_SUCCESS;

Expand Down
19 changes: 6 additions & 13 deletions src/import/generic/memory/lib/utils/mss_field.H
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2018,2019 */
/* Contributors Listed Below - COPYRIGHT 2018,2020 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -44,14 +44,7 @@
#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
// reused TARGTID & TARGTIDFORMAT macro defined in generic/memory/lib/utils/mss_generic_check.H

namespace mss
{
Expand Down Expand Up @@ -203,7 +196,7 @@ 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 " TARGIDFORMAT,
"Out of bounds indexing (with %d) on a list of size %d for " TARGTIDFORMAT,
BYTE,
i_data.size(),
TARGTID);
Expand All @@ -213,7 +206,7 @@ inline fapi2::ReturnCode get_field(const fapi2::Target<T>& i_target,
const fapi2::buffer<OT> l_buffer(i_data[BYTE]);
l_buffer.template extractToRight<F.get_start(), F.get_length()>(o_value);

FAPI_DBG(TARGIDFORMAT " data[%d] = 0x%02x. Field with start bit %d, bit len %d, has data 0x%02x.",
FAPI_DBG(TARGTIDFORMAT " data[%d] = 0x%02x. Field with start bit %d, bit len %d, has data 0x%02x.",
TARGTID,
BYTE,
i_data[BYTE],
Expand Down Expand Up @@ -318,7 +311,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 " TARGIDFORMAT, TARGTID );
"Failed get_field() for " TARGTIDFORMAT, TARGTID );

// Test if retrieved data seems valid
FAPI_TRY( check::invalid_value(i_target,
Expand All @@ -340,7 +333,7 @@ inline fapi2::ReturnCode get_field( const fapi2::Target<T>& i_target,
.set_CONVERTED_VAL(o_value)
.set_TARGET(i_target)
.set_FUNCTION(i_ffdc_codes),
"Conversion error between original %d to converted %d value for " TARGIDFORMAT,
"Conversion error between original %d to converted %d value for " TARGTIDFORMAT,
l_temp, o_value, TARGTID);

FAPI_DBG("%s: 0x%02x for %s",
Expand Down
31 changes: 14 additions & 17 deletions src/import/generic/memory/lib/utils/mss_generic_check.H
Expand Up @@ -38,10 +38,20 @@

#include <fapi2.H>

#ifndef __PPE__
#ifdef __PPE__
//Macro -- PPE doesn't want to include generic_consts.H
// so we'll define it here directly
#define TARGTIDFORMAT "0x%08X"
#define TARGTID i_target.get()

#else
#include <generic/memory/lib/utils/shared/mss_generic_consts.H>
#include <generic/memory/lib/utils/scom.H>
#include <generic/memory/lib/utils/c_str.H>
//Macro -- PPE doesn't want to include generic_consts.H
// so we'll define it here directly
#define TARGTIDFORMAT "%s"
#define TARGTID spd::c_str(i_target)
#endif

namespace mss
Expand Down Expand Up @@ -220,31 +230,18 @@ inline fapi2::ReturnCode invalid_value(const fapi2::Target<T>& i_target,
const FFDC i_ffdc_codes,
const char* i_err_str = "")
{
#ifdef __PPE__
FAPI_ASSERT(i_conditional,
fapi2::MSS_FAILED_DATA_INTEGRITY_CHECK().
set_VALUE(i_data).
set_BYTE(i_byte_index).
set_TARGET(i_target).
set_FFDC_CODE(i_ffdc_codes),
"%s Byte %d, Data returned: %d.",
"%s Byte %d, Data returned: %d for " TARGTIDFORMAT,
i_err_str,
i_byte_index,
i_data);
#else
FAPI_ASSERT(i_conditional,
fapi2::MSS_FAILED_DATA_INTEGRITY_CHECK().
set_VALUE(i_data).
set_BYTE(i_byte_index).
set_TARGET(i_target).
set_FFDC_CODE(i_ffdc_codes),
"%s %s Byte %d, Data returned: %d.",
spd::c_str(i_target),
i_err_str,
i_byte_index,
i_data);
i_data,
TARGTID);

#endif
return fapi2::FAPI2_RC_SUCCESS;

fapi_try_exit:
Expand Down

0 comments on commit a76d697

Please sign in to comment.