diff --git a/src/import/generic/memory/lib/utils/mss_generic_check.H b/src/import/generic/memory/lib/utils/mss_generic_check.H index 7ad6b484c..5e007110c 100644 --- a/src/import/generic/memory/lib/utils/mss_generic_check.H +++ b/src/import/generic/memory/lib/utils/mss_generic_check.H @@ -59,6 +59,13 @@ namespace mss namespace check { #ifndef __PPE__ + +/// +/// @brief Making an enum for switch/case in bad_fir_bits. Both will need +/// to be updated if additional FIR checklists are needed +/// +enum firChecklist {GENERIC, OMI, DRAMINIT, CCS}; + /// /// @brief Helper function to log an error as related if needed /// @tparam T the target type on which to log the error @@ -82,14 +89,34 @@ inline void log_fir_helper( const fapi2::Target& i_target, /// /// @brief Checks whether any FIRs have lit up on a target /// @tparam MC MC type for which to check FIR's +/// @tparam F the FIR reg checklist to be checked /// @tparam T the fapi2::TargetType which hold the FIR bits /// @param[in] i_target - the target on which to operate /// @param[in,out] io_rc - the return code for the function /// @param[out] o_fir_error - true iff a FIR was hit /// @return fapi2::ReturnCode FAPI2_RC_SUCCESS iff ok /// -template< mss::mc_type MC, fapi2::TargetType T > -fapi2::ReturnCode bad_fir_bits( const fapi2::Target& i_target, fapi2::ReturnCode& io_rc, bool& o_fir_error ); +template< mss::mc_type MC, firChecklist F, fapi2::TargetType T > +fapi2::ReturnCode bad_fir_bits( const fapi2::Target& i_target, fapi2::ReturnCode& io_rc, bool& o_fir_error); + +/// +/// @brief Checks whether the passed in FIRs have any un-masked errors set +/// @param[in] i_fir - the contents of the fir register to be checked +/// @param[in] i_mask - the contents of the fir mask to be checked +/// @return bool return true iff an unmasked fir bit is found +/// +inline bool fir_with_mask_helper( const fapi2::buffer& i_fir, + const fapi2::buffer& i_mask) +{ + fapi2::buffer l_fir_mask(i_mask); + + // The mask register will need to be inverted as a 0 in the mask register means the FIR is legit + // A bitwise and works the opposite way + l_fir_mask.invert(); + + // Return true if any fir is set and unmasked to indicate this is a "new" FIR + return ((i_fir & l_fir_mask) != 0); +} /// /// @brief Checks whether the passed in FIRs have any un-masked errors set @@ -116,14 +143,9 @@ inline fapi2::ReturnCode fir_with_mask( const fapi2::Target& i_target, FAPI_TRY(mss::getScom(i_target, FIR_REG, l_fir)); FAPI_TRY(mss::getScom(i_target, FIR_MASK, l_fir_mask)); - - // The mask register will need to be inverted as a 0 in the mask register means the FIR is legit - // A bitwise and works the opposite way - l_fir_mask.invert(); - - // If we have any unmasked bit, set that we have a FIR error and exit out with success - // Note: we want to set success here as PRD will find the FIR as "new" and retrigger the procedure this way - o_fir_error = ((l_fir & l_fir_mask) != 0); + // If we have any unmasked bit, set that we have a FIR error and exit out with TRUE + // Note: we want to set TRUE here as PRD will find the FIR as "new" and retrigger the procedure this way + o_fir_error = fir_with_mask_helper(l_fir, l_fir_mask); // And print the information for debuggability FAPI_INF("%s %s on reg 0x%016lx value 0x%016lx and mask 0x%016lx value 0x%016lx", mss::c_str(i_target), @@ -136,14 +158,15 @@ fapi_try_exit: /// /// @brief Checks whether a FIR or unlocked PLL could be the root cause of another failure /// @tparam MC MC type for which to check FIR's +/// @tparam F the FIR reg checklist to be checked /// @tparam T the fapi2::TargetType which hold the FIR bits /// @param[in] i_target - the target on which to operate /// @param[in,out] io_rc - the return code for the function /// @return fapi2::ReturnCode FAPI2_RC_SUCCESS iff ok /// @note This is a helper function to enable unit testing /// -template< mss::mc_type MC, fapi2::TargetType T > -fapi2::ReturnCode hostboot_fir_or_pll_fail( const fapi2::Target& i_target, fapi2::ReturnCode& io_rc) +template< mss::mc_type MC, firChecklist F, fapi2::TargetType T > +fapi2::ReturnCode hostboot_fir_or_pll_fail( const fapi2::Target& i_target, fapi2::ReturnCode& io_rc ) { // We didn't have an error, so return success if(io_rc == fapi2::FAPI2_RC_SUCCESS) @@ -157,7 +180,8 @@ fapi2::ReturnCode hostboot_fir_or_pll_fail( const fapi2::Target& i_target, fa FAPI_ERR("%s has a bad return code, time to check some firs!", mss::c_str(i_target)); - l_fircheck_scom_err = bad_fir_bits(i_target, io_rc, l_fir_error); + // Check the fir bits against the mask and return fir status thru fapi2 RC + l_fircheck_scom_err = bad_fir_bits(i_target, io_rc, l_fir_error); FAPI_ERR("%s took a fail. FIR was %s", mss::c_str(i_target), l_fir_error ? "set - returning FIR RC" : "unset - returning inputted RC"); @@ -179,16 +203,17 @@ fapi2::ReturnCode hostboot_fir_or_pll_fail( const fapi2::Target& i_target, fa /// /// @brief Checks whether a FIR or unlocked PLL could be the root cause of another failure, if a check fir boolean is passed in /// @tparam MC MC type for which to check FIR's +/// @tparam F the FIR reg checklist to be checked /// @tparam T the fapi2::TargetType which hold the FIR bits /// @param[in] i_target - the target on which to operate /// @param[in,out] io_rc - the return code for the function /// @param[in] i_check_fir - true IFF the FIR needs to be checked - defaults to true /// @return fapi2::ReturnCode FAPI2_RC_SUCCESS iff ok /// -template< mss::mc_type MC, fapi2::TargetType T > +template< mss::mc_type MC, firChecklist F, fapi2::TargetType T > fapi2::ReturnCode fir_or_pll_fail( const fapi2::Target& i_target, fapi2::ReturnCode& io_rc, - const bool i_check_fir = true) + const bool i_check_fir = true ) { #ifdef __HOSTBOOT_MODULE @@ -198,7 +223,7 @@ fapi2::ReturnCode fir_or_pll_fail( const fapi2::Target& i_target, if(i_check_fir) { // Handle any issues according to PRD FIR scheme, as a FIR could have caused this issue - l_rc = hostboot_fir_or_pll_fail(i_target, l_rc); + l_rc = hostboot_fir_or_pll_fail(i_target, l_rc); } return l_rc;