summaryrefslogtreecommitdiffstats
path: root/src/usr/expscom/i2cscomdd.C
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/expscom/i2cscomdd.C')
-rw-r--r--src/usr/expscom/i2cscomdd.C220
1 files changed, 11 insertions, 209 deletions
diff --git a/src/usr/expscom/i2cscomdd.C b/src/usr/expscom/i2cscomdd.C
index 1cbff6083..596e293ec 100644
--- a/src/usr/expscom/i2cscomdd.C
+++ b/src/usr/expscom/i2cscomdd.C
@@ -37,33 +37,16 @@
#include <hwpf/fapi2/include/fapi2_hwp_executor.H> // FAPI_EXEC_HWP
#include <expscom/expscom_reasoncodes.H> // EXPSCOM::MOD_I2CSCOM_PERFORM_OP
#include "i2cscomdd.H" //i2cScomPerformOp
-#include "expscomtrace.H" //g_trac_expscom
+#include "expscom_trace.H" //g_trac_expscom
+#include "expscom_utils.H" //validateInputs
namespace I2CSCOMDD
{
-constexpr uint64_t FIRST_4_BYTES = 0xFFFFFFFF00000000;
-
-/**
- * @brief Performs validation of params passed into i2cScomPerformOp function
- * This function checks that the target type, the address format, the buffer length
- * and the op type are all valid. A unique error will be created for each violation.
- * If multiple error are found the last error will be returned and all previous errors
- * found will be committed as new errors are found (see function).
- *
- * @param[in] i_opType Operation type, see DeviceFW::OperationType
- * in driverif.H
- * @param[in] i_target TARGETING::Target passed to i2cScomPerformOp
- * @param[in] i_buflen size of buffer passed to i2cScomPerformOp
- * (i_buflen is expected to be 8 bytes)
- * @param[in] i_scomAddr Scom address operation will be performed on
-
- * @return errlHndl_t nullptr on success, non-null ptr on error
- */
-errlHndl_t validateInputs(DeviceFW::OperationType i_opType,
- const TARGETING::Target* i_target,
- size_t i_buflen,
- uint64_t i_scomAddr);
+DEVICE_REGISTER_ROUTE(DeviceFW::WILDCARD,
+ DeviceFW::I2CSCOM,
+ TARGETING::TYPE_OCMB_CHIP,
+ i2cScomPerformOp);
///////////////////////////////////////////////////////////////////////////////
// See header for doxygen documentation
@@ -89,10 +72,14 @@ errlHndl_t i2cScomPerformOp(DeviceFW::OperationType i_opType,
do
{
// First make sure the inputs are valid
- l_err = validateInputs ( i_opType, i_target, l_scomAddr, io_buflen);
+ l_err = EXPSCOM::validateInputs ( i_opType, i_target, l_scomAddr, io_buflen);
if(l_err)
{
+ // Write a trace out to the buffer and then collect it on the log
+ // this way we can know if the fail was in i2cScomPerformOp or mmioScomPerformOp
+ TRACFCOMP( g_trac_expscom, ERR_MRK "i2cScomPerformOp> Validation of inputs failed see error logs for details ");
+ l_err->collectTrace(EXPSCOM_COMP_NAME);
break;
}
@@ -181,189 +168,4 @@ errlHndl_t i2cScomPerformOp(DeviceFW::OperationType i_opType,
} while (0);
return l_err;
}
-
-///////////////////////////////////////////////////////////////////////////////
-// See above for doxygen documentation
-///////////////////////////////////////////////////////////////////////////////
-errlHndl_t validateInputs(DeviceFW::OperationType i_opType,
- const TARGETING::Target* i_target,
- size_t i_buflen,
- uint64_t i_scomAddr)
-{
- errlHndl_t l_err = nullptr;
- uint32_t l_commonPlid = 0; // If there are multiple issues found link logs with first
-
- TARGETING::ATTR_MODEL_type l_targetModel =
- i_target->getAttr<TARGETING::ATTR_MODEL>();
-
- // Only target we can perform i2c scoms on like this are explorer OCMB chip targets
- if( l_targetModel != TARGETING::MODEL_EXPLORER )
- {
- TRACFCOMP( g_trac_expscom, ERR_MRK "i2cScomPerformOp> Invalid model type : l_targetModel=%d", l_targetModel );
- /*@
- * @errortype
- * @moduleid EXPSCOM::MOD_I2CSCOM_PERFORM_OP
- * @reasoncode EXPSCOM::RC_INVALID_MODEL_TYPE
- * @userdata1 SCOM Address
- * @userdata2[0:31] Model Type
- * @userdata2[32:63] Target Huid
- * @devdesc i2cScomPerformOp> Invalid target type (!= OCMB_CHP)
- * @custdesc A problem occurred during the IPL of the system:
- * Invalid target type for a SCOM operation.
- */
- l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- EXPSCOM::MOD_I2CSCOM_PERFORM_OP,
- EXPSCOM::RC_INVALID_MODEL_TYPE,
- i_scomAddr,
- TWO_UINT32_TO_UINT64(l_targetModel,
- TARGETING::get_huid(i_target)),
- ERRORLOG::ErrlEntry::ADD_SW_CALLOUT);
-
- l_err->collectTrace(EXPSCOM_COMP_NAME);
- ERRORLOG::ErrlUserDetailsTarget(i_target,"SCOM Target").
- addToLog(l_err);
- l_commonPlid = l_err->plid();
- }
- // The address is really only 32 bits, we will cast it to 32 bits before passing to
- // the fapi2 i2c_get_scom function but just to be safe make sure that first 4 bytes are 0s
- if( i_scomAddr & FIRST_4_BYTES )
- {
- TRACFCOMP( g_trac_expscom,
- ERR_MRK "i2cScomPerformOp> Invalid address : i_scomAddr=0x%lx , first 32 bits should be 0's",
- i_scomAddr );
-
- // If there is already an error from prev checks, then commit it
- if(l_err)
- {
- errlCommit(l_err, EXPSCOM_COMP_ID);
- }
-
- /*@
- * @errortype
- * @moduleid EXPSCOM::MOD_I2CSCOM_PERFORM_OP
- * @reasoncode EXPSCOM::RC_INVALID_ADDRESS
- * @userdata1 SCOM Address
- * @userdata2 Target HUID
- * @devdesc i2cScomPerformOp> Invalid scom address, first 4
- * bytes should be 0's
- * @custdesc A problem occurred during the IPL of the system:
- * Invalid address for a SCOM operation.
- */
- l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- EXPSCOM::MOD_I2CSCOM_PERFORM_OP,
- EXPSCOM::RC_INVALID_ADDRESS,
- i_scomAddr,
- TARGETING::get_huid(i_target),
- ERRORLOG::ErrlEntry::ADD_SW_CALLOUT);
-
- l_err->collectTrace(EXPSCOM_COMP_NAME);
- ERRORLOG::ErrlUserDetailsTarget(i_target,"SCOM Target").
- addToLog(l_err);
-
- if(l_commonPlid == 0)
- {
- l_commonPlid = l_err->plid();
- }
- else
- {
- l_err->plid(l_commonPlid);
- }
- }
-
- // The buffer passed into i2cScomPerformOp should ALWAYS be 8 bytes.
- // If it is an IBM scom then all 8 bytes are used. If its microchip scom
- // then only the last 4 bytes are used.
- if (i_buflen != sizeof(uint64_t))
- {
- TRACFCOMP( g_trac_expscom, ERR_MRK "i2cScomPerformOp> Invalid data length : io_buflen=%d ,"
- " expected sizeof(uint64_t)", i_buflen );
-
- // If there is already an error from prev checks, then commit it
- if(l_err)
- {
- errlCommit(l_err, EXPSCOM_COMP_ID);
- }
-
- /*@
- * @errortype
- * @moduleid EXPSCOM::MOD_I2CSCOM_PERFORM_OP
- * @reasoncode EXPSCOM::RC_INVALID_LENGTH
- * @userdata1 SCOM Address
- * @userdata2 Data Length
- * @devdesc i2cScomPerformOp> Invalid data length (!= 8 bytes)
- * @custdesc A problem occurred during the IPL of the system:
- * Invalid data length for a SCOM operation.
- */
- l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- EXPSCOM::MOD_I2CSCOM_PERFORM_OP,
- EXPSCOM::RC_INVALID_LENGTH,
- i_scomAddr,
- TO_UINT64(i_buflen),
- ERRORLOG::ErrlEntry::ADD_SW_CALLOUT);
-
- l_err->collectTrace(EXPSCOM_COMP_NAME);
- ERRORLOG::ErrlUserDetailsTarget(i_target,"SCOM Target").
- addToLog(l_err);
-
- if(l_commonPlid == 0)
- {
- l_commonPlid = l_err->plid();
- }
- else
- {
- l_err->plid(l_commonPlid);
- }
- }
-
- // The only valid operations are READ and WRITE if anything else comes in we need to error out
- if (i_opType != DeviceFW::READ && i_opType != DeviceFW::WRITE )
- {
- TRACFCOMP( g_trac_expscom, ERR_MRK "i2cScomPerformOp> Invalid operation type : i_opType=%d", i_opType );
-
- if(l_err)
- {
- errlCommit(l_err, EXPSCOM_COMP_ID);
- }
-
- /*@
- * @errortype
- * @moduleid EXPSCOM::MOD_I2CSCOM_PERFORM_OP
- * @reasoncode EXPSCOM::RC_INVALID_OPTYPE
- * @userdata1 SCOM Address
- * @userdata2 Op Type
- * @devdesc i2cScomPerformOp> Invalid operation type (!= READ or WRITE)
- * @custdesc A problem occurred during the IPL of the system:
- * Invalid SCOM operation.
- */
- l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- EXPSCOM::MOD_I2CSCOM_PERFORM_OP,
- EXPSCOM::RC_INVALID_OPTYPE,
- i_scomAddr,
- i_opType,
- ERRORLOG::ErrlEntry::ADD_SW_CALLOUT);
-
- l_err->collectTrace(EXPSCOM_COMP_NAME);
- ERRORLOG::ErrlUserDetailsTarget(i_target,"SCOM Target").
- addToLog(l_err);
-
- if(l_commonPlid == 0)
- {
- l_commonPlid = l_err->plid();
- }
- else
- {
- l_err->plid(l_commonPlid);
- }
- }
-
- return l_err;
-}
-
-
-DEVICE_REGISTER_ROUTE(DeviceFW::WILDCARD,
- DeviceFW::I2CSCOM,
- TARGETING::TYPE_OCMB_CHIP,
- i2cScomPerformOp);
-
-
} \ No newline at end of file
OpenPOWER on IntegriCloud