From 7b99c2041cfe126bb85325a3d18ca69d279f54ad Mon Sep 17 00:00:00 2001 From: CamVan Nguyen Date: Tue, 22 May 2012 08:44:39 -0500 Subject: 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 Reviewed-by: A. Patrick Williams III --- src/include/usr/hwpf/hwp/fapiHwpExecInitFile.H | 7 +- src/include/usr/hwpf/hwp/fapiHwpInitFileInclude.H | 17 +- src/include/usr/hwpf/hwp/fapiTestHwp.H | 9 +- src/usr/hwas/testHWP.C | 59 ++++- src/usr/hwpf/hwp/fapiHwpErrorInfo.xml | 24 ++ src/usr/hwpf/hwp/fapiHwpExecInitFile.C | 266 +++++++++++++++------- src/usr/hwpf/hwp/fapiTestHwp.C | 37 +-- src/usr/hwpf/hwp/initfiles/sample.initfile | 32 ++- src/usr/hwpf/ifcompiler/initCompiler.lex | 35 ++- src/usr/hwpf/ifcompiler/initRpn.C | 40 +++- src/usr/hwpf/ifcompiler/initScom.C | 29 ++- src/usr/hwpf/ifcompiler/initSymbols.C | 95 ++++++-- src/usr/hwpf/ifcompiler/initSymbols.H | 27 ++- src/usr/hwpf/test/hwpftest.H | 81 ++++++- 14 files changed, 593 insertions(+), 165 deletions(-) diff --git a/src/include/usr/hwpf/hwp/fapiHwpExecInitFile.H b/src/include/usr/hwpf/hwp/fapiHwpExecInitFile.H index 63b1dc218..8ffba1cc8 100644 --- a/src/include/usr/hwpf/hwp/fapiHwpExecInitFile.H +++ b/src/include/usr/hwpf/hwp/fapiHwpExecInitFile.H @@ -33,6 +33,7 @@ * camvanng 09/29/2011 Created. * andrewg 11/16/2011 Refactor includes with initfile compiler * camvanng 11/16/2011 Define function pointer to HWP + * camvanng 05/07/2012 Support for associated target attributes * */ @@ -49,17 +50,17 @@ extern "C" //Provided for platforms that need to cast a generic function pointer into a //function pointer of the correct type to call the HWP. -typedef fapi::ReturnCode (*fapiHwpExecInitFile_FP_t)(const fapi::Target & i_Target, +typedef fapi::ReturnCode (*fapiHwpExecInitFile_FP_t)(const std::vector & i_target, const char * i_file); /** * @brief HWP to execute an initfile. * -* @param[in] i_chip Reference to target chip +* @param[in] i_target Reference to std::vector of targets * @param[in] i_file filename of binary initfile * * @return ReturnCode */ -fapi::ReturnCode fapiHwpExecInitFile(const fapi::Target & i_Target, +fapi::ReturnCode fapiHwpExecInitFile(const std::vector & i_target, const char * i_file); } // extern "C" diff --git a/src/include/usr/hwpf/hwp/fapiHwpInitFileInclude.H b/src/include/usr/hwpf/hwp/fapiHwpInitFileInclude.H index 50f2bd222..e726c59bb 100644 --- a/src/include/usr/hwpf/hwp/fapiHwpInitFileInclude.H +++ b/src/include/usr/hwpf/hwp/fapiHwpInitFileInclude.H @@ -33,6 +33,8 @@ * andrewg 11/09/2011 Created. * camvanng 11/16/2011 Support for system & target * attributes + * camvanng 05/07/2012 Support for associated + * target attributes * */ @@ -73,16 +75,15 @@ enum IfRpnOp */ enum IfTypeMask { - IF_ATTR_TYPE = 0x8000, - IF_NUM_TYPE = 0xC000, - IF_TYPE_MASK = 0xC000, + IF_NUM_TYPE = 0x4000, + IF_ATTR_TYPE = 0x8000, + IF_SYS_ATTR_TYPE = 0xA000, + IF_ASSOC_TGT_ATTR_TYPE = 0xC000, + IF_TYPE_MASK = 0xE000, }; -// System or Target attribute -const uint16_t IF_SYS_ATTR_MASK = 0x2000; - -// Attribute Id mask -const uint16_t IF_ATTR_ID_MASK = 0x1FFF; +// Id mask +const uint16_t IF_ID_MASK = static_cast(~IF_TYPE_MASK); // Only support up to 4 dimensions for an array const uint8_t MAX_ATTRIBUTE_ARRAY_DIMENSION = 4; diff --git a/src/include/usr/hwpf/hwp/fapiTestHwp.H b/src/include/usr/hwpf/hwp/fapiTestHwp.H index 12349e737..d1451d493 100644 --- a/src/include/usr/hwpf/hwp/fapiTestHwp.H +++ b/src/include/usr/hwpf/hwp/fapiTestHwp.H @@ -34,14 +34,17 @@ * mjjones 06/28/2011 Updated comment * mjjones 08/11/2011 Removed Clock HWP * mjjones 10/17/2011 Added func pointer + * camvanng 05/07/2012 Support for associated + * attributes */ #ifndef FAPITESTHW_H_ #define FAPITESTHW_H_ #include +#include -typedef fapi::ReturnCode (*hwpInitialTest_FP_t)(const fapi::Target &); +typedef fapi::ReturnCode (*hwpInitialTest_FP_t)(const std::vector &); extern "C" { @@ -49,11 +52,11 @@ extern "C" /** * @brief A simple HWP. Can easily be modified by HW dev team for test * - * @param[in] i_chip Reference to target chip + * @param[in] i_target Reference to std::vector of targets * * @return ReturnCode */ -fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip); +fapi::ReturnCode hwpInitialTest(const std::vector & i_target); } diff --git a/src/usr/hwas/testHWP.C b/src/usr/hwas/testHWP.C index d852295f5..a3895d388 100644 --- a/src/usr/hwas/testHWP.C +++ b/src/usr/hwas/testHWP.C @@ -55,6 +55,7 @@ #include #include #include +#include using namespace fapi; @@ -69,16 +70,70 @@ namespace HWAS void testHWP( void * io_pArgs ) { errlHndl_t l_err = NULL; + std::vector l_target; // Get the master processor chip TARGETING::Target* l_pTarget = NULL; TARGETING::targetService().masterProcChipTargetHandle(l_pTarget); - // Create a FAPI Target and invoke the hwpInitialTest HWP + // Create the FAPI Targets and invoke the hwpInitialTest HWP fapi::Target l_fapiTarget(TARGET_TYPE_PROC_CHIP, reinterpret_cast (l_pTarget)); - FAPI_INVOKE_HWP(l_err, hwpInitialTest, l_fapiTarget); + l_target.push_back(l_fapiTarget); + + // Get the target for the MBA chiplets of the first MEMBUF chip + TARGETING::PredicateCTM l_membufChip(TARGETING::CLASS_CHIP, + TARGETING::TYPE_MEMBUF); + + TARGETING::TargetRangeFilter l_filter( + TARGETING::targetService().begin(), + TARGETING::targetService().end(), + &l_membufChip); + + PredicateCTM l_mba(CLASS_UNIT,TYPE_MBA); + + // Just look at the first MEMBUF chip + if (l_filter) + { + TargetHandleList l_list; + (void) targetService().getAssociated( + l_list, + *l_filter, + TARGETING::TargetService::CHILD, + TARGETING::TargetService::ALL, + &l_mba); + + if (2 == l_list.size()) + { + for (size_t i = 0; i < l_list.size(); i++) + { + //Set the associated targets + fapi::Target l_fapiTargetAssoc(fapi::TARGET_TYPE_MBA_CHIPLET, + reinterpret_cast(l_list.at(i))); + l_target.push_back(l_fapiTargetAssoc); + } + + FAPI_INVOKE_HWP(l_err, hwpInitialTest, l_target); + } + else + { + HWAS_ERR("testHWP: Incorrect # of MBAs found: %u", + l_list.size()); + + size_t l_ffdc = l_list.size(); + size_t & FFDC_IF_TEST_NUM_MBAS_FOUND = l_ffdc; + FAPI_SET_HWP_ERROR(l_rc, + RC_HWP_EXEC_INITFILE_TEST_INCORRECT_NUM_MBAS_FOUND); + l_err = fapiRcToErrl(l_rc); + } + } + else + { + HWAS_ERR("testHWP: No MEMBUFs found"); + FAPI_SET_HWP_ERROR(l_rc, RC_HWP_EXEC_INITFILE_TEST_NO_MEMBUF_FOUND); + l_err = fapiRcToErrl(l_rc); + } if (l_err) { 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 @@ FFDC_IF_ATTR_ID_OUT_OF_RANGE + RC_INITFILE_LIT_ID_OUT_OF_RANGE InitFile's literal id is out of range FFDC_IF_LIT_ID_OUT_OF_RANGE + + + RC_INITFILE_TGT_NUM_OUT_OF_RANGE + InitFile's target number is out of range + + FFDC_IF_TGT_NUM + FFDC_IF_NUM_TGTS_PASSED_IN + + RC_HWP_EXEC_INITFILE_TEST_FAILED HWP Exec InitFile test case failed + + + RC_HWP_EXEC_INITFILE_TEST_INCORRECT_NUM_MBAS_FOUND + HWP Exec InitFile test incorrect number of MBA chiplets found + + FFDC_IF_TEST_NUM_MBAS_FOUND + + + + RC_HWP_EXEC_INITFILE_TEST_NO_MEMBUF_FOUND + HWP Exec Initfile test no MEMBUF chips found + + RC_HWP_ATTR_UNIT_TEST_FAIL HWP Attribute Unit Test failed + 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 @@ -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 * 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 * @param[in] i_file The binary if filename: .if * * @return ReturnCode. Zero on success. */ -fapi::ReturnCode fapiHwpExecInitFile(const fapi::Target & i_Target, +fapi::ReturnCode fapiHwpExecInitFile(const std::vector & 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(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(l_rc)); + if (l_pTarget) + { + IF_DBG("fapiHwpExecInitFile: target: %s", l_pTarget->toEcmdString()); + } + + fapi::AttributeId l_attrId = + static_cast(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(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(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(malloc(l_scoms[i].numCols * sizeof(uint16_t))); + reinterpret_cast(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(*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(*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 @@ -50,20 +52,19 @@ 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 & 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 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; } #--****************************************************************************** diff --git a/src/usr/hwpf/ifcompiler/initCompiler.lex b/src/usr/hwpf/ifcompiler/initCompiler.lex index 66183f776..beed2195a 100755 --- a/src/usr/hwpf/ifcompiler/initCompiler.lex +++ b/src/usr/hwpf/ifcompiler/initCompiler.lex @@ -34,6 +34,8 @@ // Ability to specify search paths for include files // camvanng 04/16/12 Support defines for SCOM address // Support defines for bits, scom_data and attribute columns +// camvanng 05/07/12 Support for associated target attributes +// Save and restore line numbers for each include file // End Change Log *********************************************************************************/ /** * @file initCompiler.lex @@ -79,11 +81,16 @@ std::string g_scomdef_name; std::map g_defines; //container for all the defines //i.e. define def_A = (attrA > 1) => key = "DEF_A", value = "(attr_A > 1)" +std::string g_target; //storage for current target + extern int yyline; extern std::vector yyincludepath; +extern std::map yytarget; //container for all defined targets + //i.e. define MBA0 = TGT1 => key = "TGT1", value = "MBA0" #define MAX_INCLUDE_DEPTH 10 YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; +int yyline_stack[MAX_INCLUDE_DEPTH]; int include_stack_num = 0; %} @@ -148,6 +155,7 @@ MULTI_DIGIT [0-9]+ yy_delete_buffer(YY_CURRENT_BUFFER); fclose(yyin); yy_switch_to_buffer(include_stack[include_stack_num]); + yyline = yyline_stack[include_stack_num]; } } @@ -177,6 +185,10 @@ include { BEGIN(incl); } exit( 1 ); } + /* Save current line number */ + yyline_stack[include_stack_num] = + yyline; + /* Save current input buffer */ include_stack[include_stack_num++] = YY_CURRENT_BUFFER; @@ -197,6 +209,7 @@ include { BEGIN(incl); } exit(1); } printf("Include file %s\n", filename.c_str()); + yyline = 1; //set line number for new buffer yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); BEGIN(INITIAL); @@ -363,7 +376,19 @@ scom_data { g_coltype = INIT_SCOMD; return INIT_SCOMD;} END_INITFILE return INIT_ENDINITFILE; -<*>SYS\. yymore(); +<*>SYS\. yymore(); //System attribute + +<*>TGT{MULTI_DIGIT}\. { + if (g_target.length()) + { + std::string tgt(yytext); + tgt = tgt.substr(0, tgt.length() -1); + yytarget[tgt] = g_target; + g_target.clear(); + } + + yymore(); //Associated target attribute + } /* All attribute enums start with "ENUM_ATTR_" */ <*>ENUM_ATTR_{ID} { @@ -377,6 +402,14 @@ END_INITFILE return INIT_ENDINITFILE; /* Anything else is a define. * Removing any requirements that defines has to start with "def_" or "DEF_" */ +<*>{ID}\. { // push back the define value for scanning + g_target = yytext; + g_target = g_target.substr(0, g_target.length() - 1); + //printf("%s\n", g_target.c_str()); + unput('.'); + pushBackDefine(g_target.c_str()); + } + <*>{ID} { // push back the define value for scanning pushBackDefine(yytext); } diff --git a/src/usr/hwpf/ifcompiler/initRpn.C b/src/usr/hwpf/ifcompiler/initRpn.C index 9d8de774a..10b8254e5 100755 --- a/src/usr/hwpf/ifcompiler/initRpn.C +++ b/src/usr/hwpf/ifcompiler/initRpn.C @@ -28,6 +28,7 @@ // camvanng 04/16/12 Support defines for SCOM address // Support defines for bits, scom_data and attribute columns // Delete obsolete code for defines support +// camvanng 05/07/12 Support for associated target attributes // End Change Log ********************************************************************************* /** @@ -42,6 +43,7 @@ #include #include #include +#include #include // Requires file from hwpf extern void yyerror(const char * s); @@ -187,6 +189,27 @@ void Rpn::push_id(std::string & i_id, TYPE i_type) rpn_id = iv_symbols->use_symbol(s); iv_rpnstack.push_back(rpn_id); + + //If this is an associated target's attribute, + //Add the target number as a numerical literal + size_t pos = s.find(ASSOC_TGT_ATTR); + if (pos != string::npos) + { + size_t len = ASSOC_TGT_ATTR.length(); + pos = s.find('.'); + if ((pos != string::npos) && (pos > len)) + { + uint32_t targetNum = strtoul(s.substr(len, pos-len).c_str(), NULL, 0); + //printf("Rpn::push_id: Target# %u\n", targetNum); + push_int(targetNum); + } + else + { + std::ostringstream oss; + oss << "Invalid associated target attribute " << i_id.c_str(); + yyerror(oss.str().c_str()); + } + } } //------------------------------------------------------------------------------------------------- @@ -591,8 +614,17 @@ void Rpn::bin_read(BINSEQ::const_iterator & bli, Symbols * symbols) iv_rpnstack.push_back(l_rpn_id); //Check for attribute of array type - if ((v & IF_TYPE_MASK) == IF_ATTR_TYPE) + if (v & IF_ATTR_TYPE) { + //Check for associated target attribute + if ((v & IF_TYPE_MASK) == IF_ASSOC_TGT_ATTR_TYPE) + { + v = *bli++; + v = (v << 8) + (*bli++); + iv_rpnstack.push_back(iv_symbols->get_rpn_id(v)); + //printf("Rpn::bin_read: Assoc target attribute id 0x%x\n", v); + } + //Get the attribute dimension & shift it to the LS nibble uint32_t l_type = iv_symbols->get_attr_type(l_rpn_id); uint8_t l_attrDimension = (static_cast(l_type) & ATTR_DIMENSION_MASK) >> 4; @@ -720,9 +752,8 @@ std::string Rpn::listing(const char * i_desc, const std::string & spyname, bool if(i_final) { uint32_t val = iv_symbols->get_tag(*i); - uint32_t type = val & IF_TYPE_MASK; - if (type == IF_ATTR_TYPE) + if (val & IF_ATTR_TYPE) { rpn_byte_size += 2; oss << "0x" << std::setw(4) << val << "\t\t" << "PUSH " << name << std::endl; @@ -747,7 +778,8 @@ std::string Rpn::listing(const char * i_desc, const std::string & spyname, bool } } - if((iv_rpnstack.size() == 1) && (iv_rpnstack.front() & SYMBOL)) // skip size and desc + //Skip size and desc for empty desc string and SYMBOL literal + if(i_desc && (0 == strlen(i_desc)) && (iv_rpnstack.front() & SYMBOL)) { odesc << oss.str(); } diff --git a/src/usr/hwpf/ifcompiler/initScom.C b/src/usr/hwpf/ifcompiler/initScom.C index bfd686832..edd030e56 100755 --- a/src/usr/hwpf/ifcompiler/initScom.C +++ b/src/usr/hwpf/ifcompiler/initScom.C @@ -32,6 +32,7 @@ // camvanng 02/14/12 Support binary and hex scom addresses // Support for array at beginning of scom address // Fix bug in string size when converting decimal to hex string +// camvanng 05/07/12 Support for associated target attributes // End Change Log ********************************************************************************* /** @@ -53,6 +54,7 @@ extern void yyerror(const char * s); extern init::ScomList * yyscomlist; // only use this during parsing +std::map yytarget; //generic target name & corresponding real name namespace init { extern ostringstream dbg; // debug output @@ -114,9 +116,7 @@ Scom::Scom(BINSEQ::const_iterator & bli, Symbols * i_symbols): // Read col heads for(size_t i = 0; i < numcols; ++i) { - uint32_t var_tag = Rpn::extract16(bli); - Rpn col_name_rpn(iv_symbols); - col_name_rpn.append(iv_symbols->get_rpn_id(var_tag)); + Rpn col_name_rpn(bli,iv_symbols); iv_col_vars.push_back(col_name_rpn); iv_cols_rpn.push_back(iv_row_rpn); // copy in blank row RPNs for this column } @@ -203,12 +203,19 @@ void Scom::add_col(const string & i_colname) Rpn col_rpn(s,iv_symbols); // = iv_symbols->use_symbol(s); // add check - Can't add any more cols after EXPR column dg001a - if(iv_col_vars.size() && s != "EXPR") + if(iv_col_vars.size()) { Rpn exp_rpn("EXPR",iv_symbols); if(exp_rpn == iv_col_vars.back()) // expr col already added - can't add any more cols { - yyerror("EXPR must be the last column"); + if (s == "EXPR") + { + yyerror("Multiple EXPR columns specified."); + } + else + { + yyerror("EXPR must be the last column"); + } } } @@ -1216,6 +1223,18 @@ void ScomList::listing(BINSEQ & bin_seq,ostream & olist) olist << endl; } + if (yytarget.size()) + { + olist << "------------------- TARGET MAPPING ------------------------\n\n" + << endl; + std::map::iterator i; + for (i = yytarget.begin(); i != yytarget.end(); i++) + { + olist << i->first << setfill(' ') << setw(30 - i->first.length()) + << " = " << i->second << endl; + } + } + olist << iv_symbols->listing() << endl; olist << "------------------- SCOM TABLES ------------------------\n\n" << endl; diff --git a/src/usr/hwpf/ifcompiler/initSymbols.C b/src/usr/hwpf/ifcompiler/initSymbols.C index a3003abc5..3a14f0fe0 100755 --- a/src/usr/hwpf/ifcompiler/initSymbols.C +++ b/src/usr/hwpf/ifcompiler/initSymbols.C @@ -28,6 +28,7 @@ // camvanng 04/16/12 Support defines for SCOM address // Support defines for bits, scom_data and attribute columns // Delete obsolete code for defines support +// camvanng 05/07/12 Support for associated target attributes // End Change Log ********************************************************************************* /** @@ -109,7 +110,6 @@ Symbols::Symbols(FILELIST & i_filenames) // Store the value iv_symbols[attr] = MAP_DATA(attrId,NOT_USED); - iv_symbols[SYS_ATTR + attr] = MAP_DATA(attrId,NOT_USED); getline(infs,fileline); } @@ -219,7 +219,6 @@ Symbols::Symbols(FILELIST & i_filenames) } iv_attr_type[attribute_name] = get_attr_type(type,array); - iv_attr_type[SYS_ATTR + attribute_name] = iv_attr_type[attribute_name]; //printf("Attribute %s Type with array dimension %u for %s is %u\n",attribute_name.c_str(),array, // type.c_str(),get_attr_type(type,array)); } @@ -275,6 +274,8 @@ uint32_t Symbols::get_attr_type(const uint32_t i_rpn_id) uint32_t Symbols::use_symbol(string & i_symbol) { uint32_t rpn_id = Rpn::SYMBOL | NOT_FOUND; + string l_symbol = i_symbol; + if(i_symbol == "ANY") rpn_id = INIT_ANY_LIT | Rpn::SYMBOL; else if(i_symbol == "EXPR") rpn_id = INIT_EXPR_VAR | Rpn::SYMBOL; else @@ -300,7 +301,39 @@ uint32_t Symbols::use_symbol(string & i_symbol) } else { - rpn_id = add_undefined(i_symbol); + //Strip off any prefix (i.e. "SYS." or "TGT<#>.") + size_t pos = i_symbol.find('.'); + if(pos != string::npos) + { + //Find the attribute without the prefix. + //If found, then add this system or assoc target attribute + //to our containers. + l_symbol = i_symbol.substr(pos+1); + SYMBOL_MAP::iterator i = iv_symbols.find(l_symbol); + if(i != iv_symbols.end()) + { + //Add the new attribute + + rpn_id = Rpn::SYMBOL | iv_rpn_id++; + uint32_t attrId = iv_symbols[l_symbol].first; + + iv_rpn_map[rpn_id] = RPN_DATA(i_symbol,attrId); + iv_symbols[i_symbol] = MAP_DATA(attrId, rpn_id); + iv_attr_type[i_symbol] = iv_attr_type[l_symbol]; + + ++iv_used_var_count; + + //printf ("Symbols::use_symbol: Just added %s symbol, rpn_id:0x%8X\n",i_symbol.c_str(),rpn_id); + } + else + { + rpn_id = add_undefined(i_symbol); + } + } + else + { + rpn_id = add_undefined(i_symbol); + } } } @@ -339,8 +372,8 @@ uint16_t Symbols::get_tag(uint32_t i_rpn_id) iv_used_var.reserve(iv_used_var_count); // makes if faster iv_used_lit.reserve(iv_used_lit_count); - //To differentiate between system and target attributes which have the same attribute id, - //save the attribute name also. + //To differentiate between system, target, and associated target attributes + //which have the same attribute id, save the attribute name also. iv_used_var.push_back(RPN_DATA("EXPR",SYM_EXPR)); // EXPR var always first iv_used_lit.push_back(iv_rpn_map[Rpn::SYMBOL|INIT_ANY_LIT].second); // ANY lit always first @@ -394,14 +427,20 @@ uint16_t Symbols::get_tag(uint32_t i_rpn_id) { if (name == (*i).first) { - tag = (uint16_t) (offset | IF_ATTR_TYPE); - - if (name.compare(0, 4, SYS_ATTR) == 0) + if (name.compare(0, ASSOC_TGT_ATTR.length(), ASSOC_TGT_ATTR) == 0) { - tag |= IF_SYS_ATTR_MASK; - //printf ("get tag: %s tag 0x%x\n", name.c_str(), tag); + tag = (uint16_t) (offset | IF_ASSOC_TGT_ATTR_TYPE); + } + else if (name.compare(0, SYS_ATTR.length(), SYS_ATTR) == 0) + { + tag = (uint16_t) (offset | IF_SYS_ATTR_TYPE); + } + else + { + tag = (uint16_t) (offset | IF_ATTR_TYPE); } + //printf ("get tag: %s tag 0x%x\n", name.c_str(), tag); break; } } @@ -722,14 +761,21 @@ string Symbols::listing() for(VAR_SYMBOL_USED::iterator i = iv_used_var.begin() + 1; i != iv_used_var.end(); ++i) { ++count; - uint32_t id = count | IF_ATTR_TYPE; + uint32_t id = count; string name = (*i).first; uint32_t attrId = (*i).second; - if(name.compare(0, 4, SYS_ATTR) == 0) + if(name.compare(0, ASSOC_TGT_ATTR.length(), ASSOC_TGT_ATTR) == 0) + { + id |= IF_ASSOC_TGT_ATTR_TYPE; + } + else if(name.compare(0, SYS_ATTR.length(), SYS_ATTR) == 0) + { + id |= IF_SYS_ATTR_TYPE; + } + else { - id |= IF_SYS_ATTR_MASK; - attrId = iv_symbols[name.substr(4)].first; + id |= IF_ATTR_TYPE; } oss << "Type:" << setw(2) << iv_attr_type[name] << " Value:0x" << setw(8) << attrId << '\t' << "ID 0X" << setw(4) << id @@ -738,8 +784,6 @@ string Symbols::listing() //printf("ATTRIBUTE: %s Value:0x%02X\n",name,iv_attr_type[name]); } - count = 0; - oss << "\n--------------- Literal Symbol Table -----------------\n\n"; oss << "\n0x" << setw(4) << iv_lits.size() << '\t' << "Number of numeric literals\n"; @@ -772,9 +816,12 @@ string Symbols::attr_listing() for(VAR_SYMBOL_USED::iterator i = iv_used_var.begin() + 1; i != iv_used_var.end(); ++i) { string name = (*i).first; - if (name.compare(0, 4, SYS_ATTR) == 0) + + //Strip off any prefix (i.e. "SYS." or "TGT<#>.") + size_t pos = name.find('.'); + if(pos != string::npos) { - name = name.substr(4); + name = name.substr(pos+1); } oss << name << endl; @@ -871,12 +918,14 @@ uint32_t Symbols::restore_var_bseq(BINSEQ::const_iterator & bli) string name = find_text(attrId); string used_var_name = iv_used_var.at(i+1).first; - // Account for system attributes + // Account for system & associated target attributes if (name != used_var_name) { - if (name == used_var_name.substr(4)) + size_t pos = used_var_name.find(name); + if(pos != string::npos) { attrId = iv_symbols[used_var_name].first; + } else { @@ -976,8 +1025,10 @@ uint32_t Symbols::get_rpn_id(uint32_t bin_tag) uint32_t offset = bin_tag & ~IF_TYPE_MASK; switch(type) { - case IF_ATTR_TYPE: { - offset &= ~IF_SYS_ATTR_MASK; + case IF_ATTR_TYPE: + case IF_SYS_ATTR_TYPE: + case IF_ASSOC_TGT_ATTR_TYPE: + { string name = iv_used_var[offset].first; rpn_id = use_symbol(name); } diff --git a/src/usr/hwpf/ifcompiler/initSymbols.H b/src/usr/hwpf/ifcompiler/initSymbols.H index 67872f1cd..92bd518ee 100755 --- a/src/usr/hwpf/ifcompiler/initSymbols.H +++ b/src/usr/hwpf/ifcompiler/initSymbols.H @@ -29,6 +29,7 @@ // camvanng 04/16/12 Support defines for SCOM address // Support defines for bits, scom_data and attribute columns // Delete obsolete code for defines support +// camvanng 05/07/12 Support for associated target attributes // End Change Log ********************************************************************************* /** @@ -56,6 +57,7 @@ using namespace std; namespace init { typedef set FILELIST; + const string ASSOC_TGT_ATTR = "TGT"; class Symbols { @@ -98,11 +100,12 @@ namespace init * @param rpn_id * @pre all the symbols have been marked used (no new symbols) * @post tag table built if not already built. - * @note tag bits 0bttxxxxxx xxxxxxxx - * tt == 0b01 -> enumerated literal - * tt == 0b10 -> Variable name - * tt == 0b11 -> Numeric constant - * xxxxxx xxxxxxxx assigned tag offset + * @note tag bits 0btttxxxxx xxxxxxxx + * ttt == 0b010 -> Numeric constant + * ttt == 0b100 -> Target attribute + * ttt == 0b101 -> System attribute + * ttt == 0b110 -> Associated target attribute + * xxxxx xxxxxxxx assigned tag offset */ uint16_t get_tag(uint32_t i_rpn_id); @@ -238,21 +241,21 @@ namespace init typedef pair MAP_DATA; //cini_id & corresponding rpn_id/NOT_USED typedef map SYMBOL_MAP; //attr name & corresponding cini_id, rpn_id/NOT_USED pair typedef map SPY_MAP; - typedef map SYMBOL_ATTR_TYPE; - typedef map SYMBOL_ATTR_ENUM; + typedef map SYMBOL_ATTR_TYPE; //attr name & corresponding type + typedef map SYMBOL_ATTR_ENUM; //enum name & corresponding value typedef pair RPN_DATA; //attribute name & corresponding cini_id - typedef map RPN_MAP; //attr name & corresponding attr name, cini_id pair + typedef map RPN_MAP; //rpn_id & corresponding attr name, cini_id pair typedef vector VAR_SYMBOL_USED; typedef vector SYMBOL_USED; - typedef pair LIT_DATA; - typedef vector LIT_LIST; + typedef pair LIT_DATA; //numeric literal & corresponding size + typedef vector LIT_LIST; ///< List of numeric literals and their size SYMBOL_MAP iv_symbols; ///< From ciniIfSymbols.H all vars and enumerated lits - SYMBOL_ATTR_TYPE iv_attr_type; - SYMBOL_ATTR_ENUM iv_attr_enum; + SYMBOL_ATTR_TYPE iv_attr_type; ///< List of attributes and their type + SYMBOL_ATTR_ENUM iv_attr_enum; ///< List of attribute enums and their value SYMBOL_MAP iv_not_found; ///< List of symbols not found RPN_MAP iv_rpn_map; ///< Map rpn_id to symbol name/cini_id of used Symbols VAR_SYMBOL_USED iv_used_var; ///< List of used attributes and their ids ordered by name diff --git a/src/usr/hwpf/test/hwpftest.H b/src/usr/hwpf/test/hwpftest.H index a74f357ef..24f3c769e 100644 --- a/src/usr/hwpf/test/hwpftest.H +++ b/src/usr/hwpf/test/hwpftest.H @@ -306,10 +306,11 @@ public: (0x8000000000000000 >> 0x10) | (0x8000000000000000 >> 0x13) | (0x0306400412000000 >> 0x15) }, - {0x0000000013013286, 0, 0}, + {0x0000000013013286, 0, 0x0000000000000192}, {0x0000000013013287, 0, 0x0000000000000182}, {0x0000000013013288, 0, 0x0000000000000192}, - {0x0000000013013289, 0, 0x8000000000000000 >> 0x17} + {0x0000000013013289, 0, (0x8000000000000000 >> 0x17) | + (0x4000000000000000 >> 0x18)} }; fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS; @@ -340,6 +341,14 @@ public: break; } + l_uint32 = 0; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_2, NULL, l_uint32); + if (l_rc != fapi::FAPI_RC_SUCCESS) + { + TS_FAIL("testHwpf5: ATTR_SCRATCH_UINT32_2. Error from SET"); + break; + } + uint64_t l_uint64 = 2; l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_uint64); if (l_rc != fapi::FAPI_RC_SUCCESS) @@ -348,6 +357,14 @@ public: break; } + l_uint64 = 0; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); + if (l_rc != fapi::FAPI_RC_SUCCESS) + { + TS_FAIL("testHwpf5: ATTR_SCRATCH_UINT64_2. Error from SET"); + break; + } + uint8_t l_uint8array1[32]; l_uint8array1[0] = 1; l_uint8array1[1] = 4; @@ -391,12 +408,68 @@ public: //printk("ATTR_IS_SIMULATION = %d\n", l_flag); } - // Get the master processor chip + //Set the targets + + std::vector l_target; + + // Get the master processor chip & set it as the main target for Scom ops TARGETING::Target* l_pTarget = NULL; TARGETING::targetService().masterProcChipTargetHandle(l_pTarget); fapi::Target l_fapiTarget(TARGET_TYPE_PROC_CHIP, reinterpret_cast (l_pTarget)); + l_target.push_back(l_fapiTarget); + + // Get the target for the MBA chiplets of the first MEMBUF chip + TARGETING::PredicateCTM l_membufChip(TARGETING::CLASS_CHIP, + TARGETING::TYPE_MEMBUF); + + TARGETING::TargetRangeFilter l_filter( + TARGETING::targetService().begin(), + TARGETING::targetService().end(), + &l_membufChip); + + PredicateCTM l_mba(CLASS_UNIT,TYPE_MBA); + + // Just look at the first MEMBUF chip + if (l_filter) + { + TargetHandleList l_list; + (void) targetService().getAssociated( + l_list, + *l_filter, + TARGETING::TargetService::CHILD, + TARGETING::TargetService::ALL, + &l_mba); + + if (2 == l_list.size()) + { + for (size_t i = 0; i < l_list.size(); i++) + { + //Set the associated targets + fapi::Target l_fapiTargetAssoc(fapi::TARGET_TYPE_MBA_CHIPLET, + reinterpret_cast(l_list.at(i))); + l_target.push_back(l_fapiTargetAssoc); + } + } + else + { + TS_FAIL("testHwpf5: Incorrect # of MBAs found: %u", + l_list.size()); + + size_t l_ffdc = l_list.size(); + size_t & FFDC_IF_TEST_NUM_MBAS_FOUND = l_ffdc; + FAPI_SET_HWP_ERROR(l_rc, + RC_HWP_EXEC_INITFILE_TEST_INCORRECT_NUM_MBAS_FOUND); + break; + } + } + else + { + TS_FAIL("testHwpf5: No MEMBUFs found"); + FAPI_SET_HWP_ERROR(l_rc, RC_HWP_EXEC_INITFILE_TEST_NO_MEMBUF_FOUND); + break; + } // Test ATTR_EC attribute access through FAPI uint8_t l_EC_R = 0xFF; @@ -450,7 +523,7 @@ public: } //Call Hwp to execute the initfile - FAPI_EXEC_HWP(l_rc, fapiHwpExecInitFile, l_fapiTarget, "sample.if"); + FAPI_EXEC_HWP(l_rc, fapiHwpExecInitFile, l_target, "sample.if"); if (l_rc != fapi::FAPI_RC_SUCCESS) { -- cgit v1.2.1