diff options
author | CamVan Nguyen <ctnguyen@us.ibm.com> | 2012-05-22 08:44:39 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-05-30 10:26:38 -0500 |
commit | 7b99c2041cfe126bb85325a3d18ca69d279f54ad (patch) | |
tree | b249b0bf4773e2677ec8620eab3074e8e1acb310 /src/usr/hwpf/hwp | |
parent | 99d1dab56d4e067cb4ee4b089cd3456acba6a89c (diff) | |
download | talos-hostboot-7b99c2041cfe126bb85325a3d18ca69d279f54ad.tar.gz talos-hostboot-7b99c2041cfe126bb85325a3d18ca69d279f54ad.zip |
SCOM Initfile: Support for associated attributes.
Change-Id: Ie86bce0abaa12b986a7858723625c8e305a899d9
RTC: 41742
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1093
Tested-by: Jenkins Server
Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/hwp')
-rw-r--r-- | src/usr/hwpf/hwp/fapiHwpErrorInfo.xml | 24 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/fapiHwpExecInitFile.C | 266 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/fapiTestHwp.C | 37 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/initfiles/sample.initfile | 32 |
4 files changed, 258 insertions, 101 deletions
diff --git a/src/usr/hwpf/hwp/fapiHwpErrorInfo.xml b/src/usr/hwpf/hwp/fapiHwpErrorInfo.xml index 880af55e6..4293afaf4 100644 --- a/src/usr/hwpf/hwp/fapiHwpErrorInfo.xml +++ b/src/usr/hwpf/hwp/fapiHwpErrorInfo.xml @@ -92,18 +92,42 @@ <!-- Collect local FFDC FFDC_IF_ATTR_ID_OUT_OF_RANGE --> <ffdc>FFDC_IF_ATTR_ID_OUT_OF_RANGE</ffdc> </hwpError> + <!-- *********************************************************************** --> <hwpError> <rc>RC_INITFILE_LIT_ID_OUT_OF_RANGE</rc> <description>InitFile's literal id is out of range </description> <!-- Collect local FFDC FFDC_IF_LIT_ID_OUT_OF_RANGE --> <ffdc>FFDC_IF_LIT_ID_OUT_OF_RANGE</ffdc> </hwpError> + <!-- *********************************************************************** --> + <hwpError> + <rc>RC_INITFILE_TGT_NUM_OUT_OF_RANGE</rc> + <description>InitFile's target number is out of range </description> + <!-- Collect local FFDC --> + <ffdc>FFDC_IF_TGT_NUM</ffdc> + <ffdc>FFDC_IF_NUM_TGTS_PASSED_IN</ffdc> + </hwpError> + <!-- *********************************************************************** --> <hwpError> <rc>RC_HWP_EXEC_INITFILE_TEST_FAILED</rc> <description>HWP Exec InitFile test case failed </description> </hwpError> + <!-- *********************************************************************** --> + <hwpError> + <rc>RC_HWP_EXEC_INITFILE_TEST_INCORRECT_NUM_MBAS_FOUND</rc> + <description>HWP Exec InitFile test incorrect number of MBA chiplets found</description> + <!-- Collect local FFDC --> + <ffdc>FFDC_IF_TEST_NUM_MBAS_FOUND</ffdc> + </hwpError> + <!-- *********************************************************************** --> + <hwpError> + <rc>RC_HWP_EXEC_INITFILE_TEST_NO_MEMBUF_FOUND</rc> + <description>HWP Exec Initfile test no MEMBUF chips found</description> + </hwpError> + <!-- *********************************************************************** --> <hwpError> <rc>RC_HWP_ATTR_UNIT_TEST_FAIL</rc> <description>HWP Attribute Unit Test failed</description> </hwpError> + <!-- *********************************************************************** --> </hwpErrors> diff --git a/src/usr/hwpf/hwp/fapiHwpExecInitFile.C b/src/usr/hwpf/hwp/fapiHwpExecInitFile.C index 2bba470a5..3fc6cff24 100644 --- a/src/usr/hwpf/hwp/fapiHwpExecInitFile.C +++ b/src/usr/hwpf/hwp/fapiHwpExecInitFile.C @@ -49,6 +49,8 @@ * PutScomUnderMask ops to same * Scom register * Turn off most debug traces + * camvanng 05/07/2012 Support for associated target + * attributes */ #include <fapiHwpExecInitFile.H> @@ -149,15 +151,16 @@ typedef struct scomData uint16_t numCols; uint16_t numRows; uint16_t * dataId; //attribute or numeric literal + uint16_t * dataTgtId; //target number of the dataId bool hasExpr; - char * colId; //expr or an attribute + char * colId; //an attribute plus it's target# char ** rowData; }scomData_t; //Init File Data typedef struct ifData { - const fapi::Target * pTarget; + const std::vector<fapi::Target> * pTarget; uint16_t numAttrs; uint16_t numLits; uint32_t numScoms; @@ -196,6 +199,7 @@ void unloadAttrSymbolTable(ifData_t & io_ifData); fapi::ReturnCode getAttr(const ifData_t & i_ifData, const uint16_t i_id, uint64_t & o_val, + const uint32_t i_targetNum, const uint16_t i_arrayIndex[MAX_ATTRIBUTE_ARRAY_DIMENSION]); void loadLitSymbolTable(ifInfo_t & io_ifInfo, @@ -237,13 +241,14 @@ uint64_t rpnBinaryOp(IfRpnOp i_op, uint64_t i_val1, uint64_t i_val2, uint32_t i_any); fapi::ReturnCode rpnDoPush(ifData_t & io_ifData, const uint16_t i_id, - uint32_t & io_any, const uint16_t i_arrayIndex[MAX_ATTRIBUTE_ARRAY_DIMENSION]); + uint32_t & io_any, const uint32_t i_targetNum, + const uint16_t i_arrayIndex[MAX_ATTRIBUTE_ARRAY_DIMENSION]); fapi::ReturnCode rpnDoOp(rpnStack_t * io_rpnStack, IfRpnOp i_op, uint32_t i_any); fapi::ReturnCode evalRpn(ifData_t & i_ifData, char * i_expr, uint32_t i_len, - bool i_hasExpr = false); + bool i_isColExpr = false, bool i_hasExpr = false); //****************************************************************************** // fapiHwpExecInitFile function @@ -253,18 +258,22 @@ fapi::ReturnCode evalRpn(ifData_t & i_ifData, char * i_expr, uint32_t i_len, * * This HWP can be called to execute a binary initfile. * - * @param[in] i_Target Reference to fapi::Target + * @param[in] i_target Reference to std::vector<fapi::Target> * @param[in] i_file The binary if filename: <initfile>.if * * @return ReturnCode. Zero on success. */ -fapi::ReturnCode fapiHwpExecInitFile(const fapi::Target & i_Target, +fapi::ReturnCode fapiHwpExecInitFile(const std::vector<fapi::Target> & i_target, const char * i_file) { FAPI_INF(">> fapiHwpExecInitFile: Performing HWP for %s", i_file); - // Print the ecmd string of the chip - FAPI_INF("fapiHwpExecInitFile: Target: %s", i_Target.toEcmdString()); + // Print the ecmd string of the targets + FAPI_INF("fapiHwpExecInitFile: SCOM target: %s", i_target.front().toEcmdString()); + for (size_t i = 1; i < i_target.size(); i++) + { + FAPI_INF("fapiHwpExecInitFile: Associated target: %s", i_target.at(i).toEcmdString()); + } fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS; fapi::ReturnCode l_tmpRc = fapi::FAPI_RC_SUCCESS; @@ -272,7 +281,7 @@ fapi::ReturnCode fapiHwpExecInitFile(const fapi::Target & i_Target, const char * l_ifAddr = NULL; // Load the binary initfile - l_rc = fapiLoadInitFile(i_Target, i_file, l_ifAddr, l_ifSize); + l_rc = fapiLoadInitFile(i_target.front(), i_file, l_ifAddr, l_ifSize); if (l_rc.ok()) { @@ -364,7 +373,7 @@ fapi::ReturnCode fapiHwpExecInitFile(const fapi::Target & i_Target, //-------------------------------- // Execute SCOMs //-------------------------------- - l_ifData.pTarget = &i_Target; + l_ifData.pTarget = &i_target; l_rc = executeScoms(l_ifData); @@ -578,52 +587,83 @@ void unloadAttrSymbolTable(ifData_t & io_ifData) fapi::ReturnCode getAttr(const ifData_t & i_ifData, const uint16_t i_id, uint64_t & o_val, + const uint32_t i_targetNum, const uint16_t i_arrayIndex[MAX_ATTRIBUTE_ARRAY_DIMENSION]) { - IF_DBG(">> fapiHwpExecInitFile: getAttr: id 0x%x", - i_id); + IF_DBG(">> fapiHwpExecInitFile: getAttr: id 0x%x target# %u", + i_id, i_targetNum); fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS; - //Mask out the type & system bits and zero-base - uint16_t l_id = (i_id & IF_ATTR_ID_MASK) - 1; - IF_DBG("fapiHwpExecInitFile: getAttr: id 0x%x", l_id); + do { - if (l_id < i_ifData.numAttrs) - { - const fapi::Target * l_pTarget = i_ifData.pTarget; + //Mask out the type bits and zero-base + uint16_t l_id = (i_id & IF_ID_MASK) - 1; + IF_DBG("fapiHwpExecInitFile: getAttr: id 0x%x", l_id); - if (i_id & IF_SYS_ATTR_MASK) + if (l_id < i_ifData.numAttrs) { - l_pTarget = NULL; - } + const fapi::Target * l_pTarget = &(i_ifData.pTarget->front()); - fapi::AttributeId l_attrId = - static_cast<fapi::AttributeId>(i_ifData.attrs[l_id].attrId); - IF_DBG("fapiHwpExecInitFile: getAttr: attrId 0x%x", l_attrId); + if ((i_id & IF_TYPE_MASK) == IF_SYS_ATTR_TYPE) + { + l_pTarget = NULL; + } + else if ((i_id & IF_TYPE_MASK) == IF_ASSOC_TGT_ATTR_TYPE) + { + if (0 == i_targetNum) + { + //Expect nonzero targetNum + fapiAssert(false); + } + else if (i_ifData.pTarget->size() <= i_targetNum) + { + FAPI_ERR("fapiHwpExecInitFile: getAttr: target# %u is greater " + "then number of targets %u passed in", i_targetNum, + i_ifData.pTarget->size()); + + const uint32_t & FFDC_IF_TGT_NUM = i_targetNum; + size_t l_ffdc = i_ifData.pTarget->size(); + size_t & FFDC_IF_NUM_TGTS_PASSED_IN = l_ffdc; + FAPI_SET_HWP_ERROR(l_rc, RC_INITFILE_TGT_NUM_OUT_OF_RANGE); + break; + } - l_rc = fapi::fapiGetInitFileAttr(l_attrId, l_pTarget, o_val, - i_arrayIndex[0], i_arrayIndex[1], - i_arrayIndex[2], i_arrayIndex[3]); + l_pTarget = &(i_ifData.pTarget->at(i_targetNum)); + } - if (l_rc) - { - FAPI_ERR("fapiHwpExecInitFile: getAttr: GetInitFileAttr failed rc 0x%x", - static_cast<uint32_t>(l_rc)); + if (l_pTarget) + { + IF_DBG("fapiHwpExecInitFile: target: %s", l_pTarget->toEcmdString()); + } + + fapi::AttributeId l_attrId = + static_cast<fapi::AttributeId>(i_ifData.attrs[l_id].attrId); + IF_DBG("fapiHwpExecInitFile: getAttr: attrId 0x%x", l_attrId); + + l_rc = fapi::fapiGetInitFileAttr(l_attrId, l_pTarget, o_val, + i_arrayIndex[0], i_arrayIndex[1], + i_arrayIndex[2], i_arrayIndex[3]); + + if (l_rc) + { + FAPI_ERR("fapiHwpExecInitFile: getAttr: GetInitFileAttr failed rc 0x%x", + static_cast<uint32_t>(l_rc)); + break; + } + + IF_DBG("fapiHwpExecInitFile: getAttr: val 0x%.16llx", o_val); } else { - IF_DBG("fapiHwpExecInitFile: getAttr: val 0x%.16llx", o_val); - } - } - else - { - FAPI_ERR("fapiHwpExecInitFile: getAttr: id out of range"); + FAPI_ERR("fapiHwpExecInitFile: getAttr: id out of range"); - uint32_t l_ffdc = i_id; - uint32_t & FFDC_IF_ATTR_ID_OUT_OF_RANGE = l_ffdc; // GENERIC IDENTIFIER - FAPI_SET_HWP_ERROR(l_rc, RC_INITFILE_ATTR_ID_OUT_OF_RANGE); + const uint16_t & FFDC_IF_ATTR_ID_OUT_OF_RANGE = i_id; // GENERIC IDENTIFIER + FAPI_SET_HWP_ERROR(l_rc, RC_INITFILE_ATTR_ID_OUT_OF_RANGE); + break; + } } + while (0); IF_DBG("<< fapiHwpExecInitFile: getAttr"); return l_rc; @@ -747,7 +787,7 @@ fapi::ReturnCode getLit(const ifData_t & i_ifData, fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS; //Mask out the type bits and zero-base - uint16_t l_id = (i_id & (~IF_TYPE_MASK)) - 1; + uint16_t l_id = (i_id & IF_ID_MASK) - 1; if (l_id < i_ifData.numLits) { @@ -758,8 +798,7 @@ fapi::ReturnCode getLit(const ifData_t & i_ifData, { FAPI_ERR("fapiHwpExecInitFile: getLit: id out of range"); - uint32_t l_ffdc = i_id; - uint32_t & FFDC_IF_LIT_ID_OUT_OF_RANGE = l_ffdc; // GENERIC IDENTIFIER + const uint16_t & FFDC_IF_LIT_ID_OUT_OF_RANGE = i_id; // GENERIC IDENTIFIER FAPI_SET_HWP_ERROR(l_rc, RC_INITFILE_LIT_ID_OUT_OF_RANGE); } @@ -862,6 +901,11 @@ void loadScomSection(ifInfo_t & io_ifInfo, memset(l_scoms[i].dataId, 0, l_scoms[i].numRows * sizeof(uint16_t*)); + //Allocate memory to hold the data's target id + l_scoms[i].dataTgtId = + reinterpret_cast<uint16_t*>(malloc(l_scoms[i].numRows * sizeof(uint16_t*))); + memset(l_scoms[i].dataTgtId, 0, l_scoms[i].numRows * sizeof(uint16_t*)); + //Read the data ids for (uint16_t j = 0; j < l_scoms[i].numRows; j++) { @@ -871,11 +915,22 @@ void loadScomSection(ifInfo_t & io_ifInfo, IF_DBG("loadScomSection: scom[%u]: dataId[%u] 0x%02x", i, j, l_scoms[i].dataId[j]); - //Check for attribute of array type - if ((l_scoms[i].dataId[j] & IF_TYPE_MASK) == IF_ATTR_TYPE) + //Is this an attribute + if (l_scoms[i].dataId[j] & IF_ATTR_TYPE) { - //Mask out the type & system bits and zero-based - uint16_t l_id = (l_scoms[i].dataId[j] & IF_ATTR_ID_MASK) - 1; + //Is this an associated target attribute + if ((l_scoms[i].dataId[j] & IF_TYPE_MASK) == IF_ASSOC_TGT_ATTR_TYPE) + { + //Read the target number + ifRead(io_ifInfo, &l_scoms[i].dataTgtId[j], + sizeof(l_scoms[i].dataTgtId[j])); + IF_DBG("loadScomSection: dataTgtId[%u] 0x%02x", + j, l_scoms[i].dataTgtId[j]); + } + + //Check for attribute of array type + //Mask out the type bits and zero-based + uint16_t l_id = (l_scoms[i].dataId[j] & IF_ID_MASK) - 1; if (l_id < io_ifData.numAttrs) { // Get the attribute dimension & shift it to the LS nibble @@ -915,11 +970,11 @@ void loadScomSection(ifInfo_t & io_ifInfo, //----------------------------------- if (0 < l_scoms[i].numCols) { - //Allocate memory to hold the column data + //Allocate memory to hold the column data plus it's target id l_scoms[i].colId = - reinterpret_cast<char *>(malloc(l_scoms[i].numCols * sizeof(uint16_t))); + reinterpret_cast<char *>(malloc(l_scoms[i].numCols * 2 * sizeof(uint16_t))); memset(l_scoms[i].colId, 0, - l_scoms[i].numCols * sizeof(uint16_t)); + l_scoms[i].numCols * 2 * sizeof(uint16_t)); //Read Column Id uint16_t l_colId = 0; @@ -933,6 +988,18 @@ void loadScomSection(ifInfo_t & io_ifInfo, IF_DBG("loadScomSection: scom[%u]: colId[%u] " "0x%02x", i, j, l_colId); + + //Is this an associated target attribute + if ((l_colId & IF_TYPE_MASK) == IF_ASSOC_TGT_ATTR_TYPE) + { + uint16_t l_colTgtId = 0; + //Read the target Id + //Don't swap the bytes - it is parsed by bytes later in code. + ifRead(io_ifInfo, l_pCol, sizeof(uint16_t), false); + l_colTgtId = (*l_pCol << 8) | (*(l_pCol+1)); + IF_DBG("loadScomSection: colTgtId[%u] 0x%02x", j, l_colTgtId); + } + l_pCol += 2; //advance past the target Id } //Is the last column an EXPR column @@ -1071,6 +1138,9 @@ void unloadScomSection(ifData_t & io_ifData) free(io_ifData.scoms[i].dataId); io_ifData.scoms[i].dataId = NULL; + free(io_ifData.scoms[i].dataTgtId); + io_ifData.scoms[i].dataTgtId = NULL; + free(io_ifData.scoms[i].colId); io_ifData.scoms[i].colId = NULL; @@ -1155,8 +1225,8 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData) //Evaluate the simple columns (not the 'expr' column) for (uint16_t col= 0; col < l_numSimpleCols; col++) { - //This will always be a push - l_rc = evalRpn(i_ifData, l_colExpr, 2); + //Evaluate the col id & target number + l_rc = evalRpn(i_ifData, l_colExpr, 4, true); if (l_rc) { @@ -1164,15 +1234,24 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData) break; } - l_colExpr++; //advance past calculation + l_colExpr += 4; //advance past calculation //This might be several pushes or just a push and an operator, //so loop to read in the pushes //An OP marks the end of a simple column RPN while (static_cast<uint32_t>(*l_rowExpr) & PUSH_MASK) { - // PUSH (SYMBOL) always 2 bytes - l_rc = evalRpn(i_ifData, l_rowExpr, 2); + uint32_t l_byteCount = 2; + if((static_cast<uint16_t>(*l_rowExpr << 8) & IF_TYPE_MASK) + == IF_ASSOC_TGT_ATTR_TYPE) + { + //Read the target# also + l_byteCount += 2; + } + + // PUSH (SYMBOL) + l_rc = evalRpn(i_ifData, l_rowExpr, l_byteCount); + l_rowExpr += l_byteCount; //advance past the calculation if (l_rc) { @@ -1180,8 +1259,6 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData) " on scom 0x%X", i_ifData.scoms[i].addrId); break; } - - l_rowExpr += 2; //advance past the calculation } if (l_rc) @@ -1247,7 +1324,7 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData) l_rowExpr++; //l_len--; //remove the length value from the length left - l_rc = evalRpn(i_ifData, l_rowExpr, l_len, true); + l_rc = evalRpn(i_ifData, l_rowExpr, l_len, false, true); if (l_rc) { @@ -1303,7 +1380,7 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData) //If the scom data for this row is an attribute of array type, //then save it's array indexes uint16_t l_dataId = i_ifData.scoms[i].dataId[l_row]; - if ((l_dataId & IF_TYPE_MASK) == IF_ATTR_TYPE) //It's an attribute + if (l_dataId & IF_ATTR_TYPE) //It's an attribute { uint8_t l_attrDimension = getAttrArrayDimension(i_ifData, l_dataId); if (l_attrDimension) @@ -1314,7 +1391,7 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData) #ifdef HWPEXECINITFILE_DEBUG2 IF_DBG("fapiHwpExecInitFile: executeScoms: scom data array" " indexes are"); - for (uint8_t j = 0; j < l_attrDimension; j++) + for (uint8_t j = 0; j < l_attrDimension; j++) { IF_DBG(" [%u]", l_scom.dataArrayIdx[j]); } @@ -1375,8 +1452,8 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData) } } // end looping for all scoms - // Clear the scom list; the only time the scom list should not be empty - // is we have pending scoms to write but we broke out of the above for + // Clear the scom list; the only time the scom list is not empty + // is if we have pending scoms to write but we broke out of the above for // loop early due to an error (l_rc != 0). if (l_scomList.size()) { @@ -1407,7 +1484,7 @@ fapi::ReturnCode writeScom(const ifData_t & i_ifData, fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS; uint32_t l_ecmdRc = ECMD_DBUF_SUCCESS; - const fapi::Target l_target = *(i_ifData.pTarget); + const fapi::Target l_target = i_ifData.pTarget->front(); uint64_t l_data = 0; // aggregate scom data to write uint64_t l_mask = 0; // aggregate mask for PutScomUnderMask op @@ -1445,10 +1522,22 @@ fapi::ReturnCode writeScom(const ifData_t & i_ifData, uint16_t l_row = i_scomList.at(l_entry).row; uint16_t l_dataId = i_ifData.scoms[l_scomNum].dataId[l_row]; - if ((l_dataId & IF_TYPE_MASK) == IF_ATTR_TYPE) //It's an attribute + if (l_dataId & IF_ATTR_TYPE) //It's an attribute { + // Get the target number + uint64_t l_dataTgtNum = 0; + uint16_t l_dataTgtId = i_ifData.scoms[l_scomNum].dataTgtId[l_row]; + if (l_dataTgtId) + { + l_rc = getLit(i_ifData, l_dataTgtId, l_dataTgtNum); + if (l_rc) + { + break; + } + } + l_rc = getAttr(i_ifData, l_dataId, l_tmpData, - i_scomList.at(l_entry).dataArrayIdx); + l_dataTgtNum, i_scomList.at(l_entry).dataArrayIdx); } else // It's a numeric literal { @@ -1601,10 +1690,10 @@ void deleteDataArrayIdx(const ifData_t & i_ifData, { //Get the scom data uint16_t l_id = i_ifData.scoms[i_scomNum].dataId[i_row]; - if ((l_id & IF_TYPE_MASK) == IF_ATTR_TYPE) //It's an attribute + if (l_id & IF_ATTR_TYPE) //It's an attribute { - //Mask out the type & system bits and zero-based - uint16_t l_tmpId = (l_id & IF_ATTR_ID_MASK) - 1; + //Mask out the type bits and zero-based + uint16_t l_tmpId = (l_id & IF_ID_MASK) - 1; if (l_tmpId < i_ifData.numAttrs) { // Get the attribute dimension & shift it to the LS nibble @@ -1644,8 +1733,8 @@ uint8_t getAttrArrayDimension(const ifData_t & i_ifData, uint16_t i_id) { uint8_t l_attrDimension = 0; - //Mask out the type & system bits and zero-based - uint16_t l_id = (i_id & IF_ATTR_ID_MASK) - 1; + //Mask out the type bits and zero-based + uint16_t l_id = (i_id & IF_ID_MASK) - 1; if (l_id < i_ifData.numAttrs) { // Get the attribute dimension & shift it to the LS nibble @@ -1930,7 +2019,8 @@ uint64_t rpnBinaryOp(IfRpnOp i_op, uint64_t i_val1, uint64_t i_val2, * @return fapi::ReturnCode Zero on success */ fapi::ReturnCode rpnDoPush(ifData_t & io_ifData, const uint16_t i_id, - uint32_t & io_any, const uint16_t i_arrayIndex[MAX_ATTRIBUTE_ARRAY_DIMENSION]) + uint32_t & io_any, const uint32_t i_targetNum, + const uint16_t i_arrayIndex[MAX_ATTRIBUTE_ARRAY_DIMENSION]) { IF_DBG(">> fapiHwpExecInitFile: rpnDoPush: id 0x%X", i_id); @@ -1940,16 +2030,16 @@ fapi::ReturnCode rpnDoPush(ifData_t & io_ifData, const uint16_t i_id, do { - if ((i_id & IF_TYPE_MASK) == IF_ATTR_TYPE) //It's an attribute + if (i_id & IF_ATTR_TYPE) //It's an attribute { - l_rc = getAttr(io_ifData, i_id, l_val, i_arrayIndex); + l_rc = getAttr(io_ifData, i_id, l_val, i_targetNum, i_arrayIndex); if (l_rc) { break; } IF_DBG("fapiHwpExecInitFile: rpnDoPush: getAttr: id = 0x%X, " - "value = 0x%llX", i_id, l_val); + "target# = %u, value = 0x%llX", i_id, i_targetNum, l_val); rpnPush(io_ifData.rpnStack, l_val); } @@ -2099,13 +2189,14 @@ fapi::ReturnCode rpnDoOp(rpnStack_t * io_rpnStack, IfRpnOp i_op, uint32_t i_any) * @return fapi::ReturnCode Zero on success */ fapi::ReturnCode evalRpn(ifData_t & io_ifData, char *i_expr, - uint32_t i_len, const bool i_hasExpr) + uint32_t i_len, const bool i_isColExpr, const bool i_hasExpr) { IF_DBG(">> fapiHwpExecInitFile: evalRpn"); fapi::ReturnCode l_rc; IfRpnOp l_op; uint16_t l_id; + uint64_t l_targetNum = 0; uint32_t l_any = IF_NOT_ANY; IF_DBG("fapiHwpExecInitFile: evalRpn: len %u", i_len); @@ -2133,8 +2224,29 @@ fapi::ReturnCode evalRpn(ifData_t & io_ifData, char *i_expr, //Check for attribute of array type uint16_t l_arrayIndexs[MAX_ATTRIBUTE_ARRAY_DIMENSION] = {0}; - if ((l_id & IF_TYPE_MASK) == IF_ATTR_TYPE) + if (l_id & IF_ATTR_TYPE) { + // If it's a column Id or an associated target attribute + if (i_isColExpr || + (l_id & IF_TYPE_MASK) == IF_ASSOC_TGT_ATTR_TYPE) + { + // Read the target# id + uint16_t l_targetId = *i_expr++ << 8; + l_targetId = *i_expr++; + IF_DBG("target Id 0x%x", l_targetId); + + if (l_targetId) + { + // Retrieve the actual value for the target number (using it's id) + l_rc = getLit(io_ifData,l_targetId,l_targetNum); + if (l_rc) + { + break; + } + } + i_len -= 2; + } + // Get the attribute dimension uint8_t l_attrDimension = getAttrArrayDimension(io_ifData, l_id); @@ -2165,7 +2277,7 @@ fapi::ReturnCode evalRpn(ifData_t & io_ifData, char *i_expr, break; } - l_rc = rpnDoPush(io_ifData, l_id, l_any, l_arrayIndexs); + l_rc = rpnDoPush(io_ifData, l_id, l_any, l_targetNum, l_arrayIndexs); } else { diff --git a/src/usr/hwpf/hwp/fapiTestHwp.C b/src/usr/hwpf/hwp/fapiTestHwp.C index af622ccd8..a9534e783 100644 --- a/src/usr/hwpf/hwp/fapiTestHwp.C +++ b/src/usr/hwpf/hwp/fapiTestHwp.C @@ -42,6 +42,8 @@ * fapiHwpExecInitFile() * mjjones 01/13/2012 Use new ReturnCode interfaces * mjjones 02/21/2012 Use new Target toEcmdString + * camvanng 05/07/2012 Suppport for associated + * target attributes */ #include <fapiTestHwp.H> @@ -51,19 +53,18 @@ extern "C" { //****************************************************************************** -// Forward Declaration -//****************************************************************************** -fapi::ReturnCode testExecInitFile(const fapi::Target & i_chip); - -//****************************************************************************** // hwpInitialTest function - Override with whatever you want here //****************************************************************************** -fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) +fapi::ReturnCode hwpInitialTest(const std::vector<fapi::Target> & i_target) { FAPI_INF("Performing HWP: hwpInitialTest"); - // Print the ecmd string of the chip - FAPI_INF("hwpInitialTest: Chip: %s", i_chip.toEcmdString()); + // Print the ecmd string of the target(s) + for (size_t i = 0; i < i_target.size(); i++) + { + FAPI_INF("hwpInitialTest: target[%u]: %s", i, i_target.at(i).toEcmdString()); + } + fapi::ReturnCode l_rc; uint32_t l_ecmdRc = ECMD_DBUF_SUCCESS; @@ -77,7 +78,7 @@ fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) // -------------------------------------------------------- // 1. fapiGetScom test // -------------------------------------------------------- - l_rc = fapiGetScom(i_chip, l_addr, l_ScomData); + l_rc = fapiGetScom(i_target.front(), l_addr, l_ScomData); if (l_rc != fapi::FAPI_RC_SUCCESS) { FAPI_ERR("hwpInitialTest: Error from fapiGetScom"); @@ -103,7 +104,7 @@ fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) break; } - l_rc = fapiPutScom(i_chip, l_addr, l_ScomData); + l_rc = fapiPutScom(i_target.front(), l_addr, l_ScomData); if (l_rc != fapi::FAPI_RC_SUCCESS) { FAPI_ERR("hwpInitialTest: Error from fapiPutScom"); @@ -131,7 +132,7 @@ fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) } - l_rc = fapiPutScomUnderMask(i_chip, l_addr, l_ScomData, l_maskData); + l_rc = fapiPutScomUnderMask(i_target.front(), l_addr, l_ScomData, l_maskData); if (l_rc != fapi::FAPI_RC_SUCCESS) { FAPI_ERR("hwpInitialTest: Error from fapiPutScomUnderMask"); @@ -154,7 +155,7 @@ fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) break; } - l_rc = fapiPutScom(i_chip, l_addr, l_ScomData); + l_rc = fapiPutScom(i_target.front(), l_addr, l_ScomData); if (l_rc != fapi::FAPI_RC_SUCCESS) { FAPI_ERR("hwpInitialTest: Error from fapiPutScom"); @@ -174,7 +175,7 @@ fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) // These functions, therefore, can only be called on the Centaur, which is not available // at this time. // When Centaur is supported: -// - Don't use i_chip (a processor) as a target. Set the target as one of the Centaurs. +// - Don't use i_target.front() (a processor) as a target. Set the target as one of the Centaurs. // - Enable this block of code and test the cfam access functions on the Centaur. // -------------------------------------------------------- @@ -183,7 +184,7 @@ fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) ecmdDataBufferBase l_cfamData(32); // 32-bit cfam data holder uint32_t l_originalCfamData = 0; const uint32_t l_cfamAddr = 0x100A; // ChipID register - l_rc = fapiGetCfamRegister(i_chip, l_cfamAddr, l_cfamData); + l_rc = fapiGetCfamRegister(i_target.front(), l_cfamAddr, l_cfamData); if (l_rc != fapi::FAPI_RC_SUCCESS) { FAPI_ERR("hwpInitialTest: Error from fapiGetCfamRegister"); @@ -209,7 +210,7 @@ fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) } - l_rc = fapiPutCfamRegister(i_chip, l_cfamAddr, l_cfamData); + l_rc = fapiPutCfamRegister(i_target.front(), l_cfamAddr, l_cfamData); if (l_rc != fapi::FAPI_RC_SUCCESS) { FAPI_ERR("hwpInitialTest: Error from fapiPutCfamRegister"); @@ -233,7 +234,7 @@ fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) break; } - l_rc = fapiModifyCfamRegister(i_chip, l_cfamAddr, + l_rc = fapiModifyCfamRegister(i_target.front(), l_cfamAddr, l_cfamData, fapi::CHIP_OP_MODIFY_MODE_AND); if (l_rc != fapi::FAPI_RC_SUCCESS) { @@ -257,7 +258,7 @@ fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) break; } - l_rc = fapiPutCfamRegister(i_chip, l_cfamAddr, l_cfamData); + l_rc = fapiPutCfamRegister(i_target.front(), l_cfamAddr, l_cfamData); if (l_rc != fapi::FAPI_RC_SUCCESS) { FAPI_ERR("hwpInitialTest: Error from fapiPutCfamRegister to restore"); @@ -276,7 +277,7 @@ fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) // -------------------------------------------------------- //Call Hwp to execute the sample initfile - FAPI_EXEC_HWP(l_rc, fapiHwpExecInitFile, i_chip, "sample.if"); + FAPI_EXEC_HWP(l_rc, fapiHwpExecInitFile, i_target, "sample.if"); if (l_rc != fapi::FAPI_RC_SUCCESS) { FAPI_ERR("hwpInitialTest: Error from fapiHwpExecInitFile"); diff --git a/src/usr/hwpf/hwp/initfiles/sample.initfile b/src/usr/hwpf/hwp/initfiles/sample.initfile index 325313f5c..1841c9fb0 100755 --- a/src/usr/hwpf/hwp/initfiles/sample.initfile +++ b/src/usr/hwpf/hwp/initfiles/sample.initfile @@ -45,6 +45,24 @@ include sample.define define def_equal_test = (SYS.ATTR_SCRATCH_UINT32_1 == SYS.ATTR_SCRATCH_UINT32_2); define def_not_equal_test = (SYS.ATTR_SCRATCH_UINT64_1 != SYS.ATTR_SCRATCH_UINT64_2); +#-- ----------------------------------------------------------------------------- +#--****************************************************************************** +#-- ----------------------------------------------------------------------------- +#-- +#-- Defines for associated targets +#-- User can either use the generic target name TGTn within the initfile or +#-- define a more informative name to use here. +#-- By default attributes without the associated target name prefix or the "SYS." +#-- prefix is the primary target's attribute. The targets must be passed to +#-- fapiHwpExecInitFile() as a std::vector<fapi::Target> with the elements in the +#-- same order as defined in the initfile; i.e. the primary target is the first +#-- element followed by TGT1, 2, 3... +#-- +#-- ----------------------------------------------------------------------------- +#--****************************************************************************** +define MBA0 = TGT1; +define MBA1 = TGT2; + #--****************************************************************************** #-- Basic SCOM @@ -164,7 +182,7 @@ scom 0x0000000013013285 { scom 0x0000000013013286 { scom_data, SYS.ATTR_SCRATCH_UINT32_1, SYS.ATTR_SCRATCH_UINT32_2 ; - 0x0000000000000192, 1, ENUM_ATTR_SCRATCH_UINT64_ARRAY_2_VAL_B ; + 0x0000000000000192, 3, ENUM_ATTR_SCRATCH_UINT64_ARRAY_2_VAL_B ; } #--****************************************************************************** @@ -179,17 +197,19 @@ scom 0x0000000013013287 { #-- SCOM with 'ec' & expr column - Use scratch for now since all attributes work #--****************************************************************************** scom 0x0000000013013288 { - scom_data, SYS.ATTR_SCRATCH_UINT32_1 expr; + scom_data, SYS.ATTR_SCRATCH_UINT32_1, expr; 0x0000000000000192, 3, SYS.ATTR_SCRATCH_UINT8_ARRAY_2[1][2][3] == 0x00000000000000BE; } #--****************************************************************************** -#-- Complex SCOM with Bit Support, logical operators and 'ec' column +#-- Complex SCOM with Bit Support, associated attributes and logical operators #--****************************************************************************** scom 0x0000000013013289 { - bits , scom_data SYS.ATTR_SCRATCH_UINT32_1 expr; - 23 , 0b1, any, SYS.ATTR_SCRATCH_UINT8_ARRAY_1[2] == SYS.ATTR_SCRATCH_UINT8_1; - 23 , 0b0, 1, any; + bits, scom_data, MBA1.ATTR_CHIP_UNIT_POS, expr; + 23, 0b0, 1, MBA0.ATTR_CHIP_UNIT_POS == 1; + 23, MBA1.ATTR_CHIP_UNIT_POS, 1, MBA0.ATTR_CHIP_UNIT_POS == 0; + 24:25, 0b10, 0, any; + 24:25, 0b01, 1, SYS.ATTR_SCRATCH_UINT8_ARRAY_1[2] == SYS.ATTR_SCRATCH_UINT8_1; } #--****************************************************************************** |