diff options
author | CamVan Nguyen <ctnguyen@us.ibm.com> | 2012-06-01 15:42:19 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-06-11 11:38:15 -0500 |
commit | 43705c216502430ed9beb464a991c8e63a60bedb (patch) | |
tree | 5fb9d099e148ef5ff94e4280e4ed1d916f6c813e /src | |
parent | 3a295ce2d7f731a0c8ce226871d4949ceaefddbb (diff) | |
download | talos-hostboot-43705c216502430ed9beb464a991c8e63a60bedb.tar.gz talos-hostboot-43705c216502430ed9beb464a991c8e63a60bedb.zip |
SCOM Initfile: Ability to do simple operations in the scom_data column.
RTC: 40445
Change-Id: I00717b3b2fdd560264bef14b7c63ed847bafbcca
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1179
Tested-by: Jenkins Server
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/usr/hwpf/hwp/fapiHwpExecInitFile.C | 420 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/initfiles/sample.initfile | 8 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initCompiler.lex | 43 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initCompiler.y | 68 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initRpn.C | 106 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initRpn.H | 62 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initScom.C | 53 | ||||
-rw-r--r-- | src/usr/hwpf/test/hwpftest.H | 4 |
8 files changed, 358 insertions, 406 deletions
diff --git a/src/usr/hwpf/hwp/fapiHwpExecInitFile.C b/src/usr/hwpf/hwp/fapiHwpExecInitFile.C index 3fc6cff24..b23ce5133 100644 --- a/src/usr/hwpf/hwp/fapiHwpExecInitFile.C +++ b/src/usr/hwpf/hwp/fapiHwpExecInitFile.C @@ -1,25 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/hwpf/hwp/fapiTestHwp.C $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2011 -// -// p1 -// -// Object Code Only (OCO) source materials -// Licensed Internal Code Source Materials -// IBM HostBoot Licensed Internal Code -// -// The source code for this program is not published or other- -// wise divested of its trade secrets, irrespective of what has -// been deposited with the U.S. Copyright Office. -// -// Origin: 30 -// -// IBM_PROLOG_END +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/hwp/fapiHwpExecInitFile.C $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2011-2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ /** * @file fapiHwpExecInitFile.C * @@ -51,6 +52,9 @@ * Turn off most debug traces * camvanng 05/07/2012 Support for associated target * attributes + * camvanng 05/22/2012 Ability to do simple operations + * on attributes in the scom + * data column */ #include <fapiHwpExecInitFile.H> @@ -150,9 +154,8 @@ typedef struct scomData uint16_t addrId; //numeric literal uint16_t numCols; uint16_t numRows; - uint16_t * dataId; //attribute or numeric literal - uint16_t * dataTgtId; //target number of the dataId - bool hasExpr; + char ** data; //scom data to write + bool hasExpr; //has "expr" column char * colId; //an attribute plus it's target# char ** rowData; }scomData_t; @@ -167,7 +170,6 @@ typedef struct ifData attrTableEntry_t * attrs; uint64_t * numericLits; scomData_t * scoms; - dataArrayIdxId_t * dataArrayIdxId; rpnStack_t * rpnStack; }ifData_t; @@ -176,8 +178,6 @@ typedef struct scomToWrite { uint16_t scomNum; //the scom entry number uint16_t row; //the row within the scom entry - uint16_t dataArrayIdx[MAX_ATTRIBUTE_ARRAY_DIMENSION]; //for scom data of - //array attribute type, save the array indexes }scomToWrite_t; //A list of the scoms to write @@ -218,16 +218,11 @@ void unloadScomSection(ifData_t & io_ifData); fapi::ReturnCode executeScoms(ifData_t & io_ifData); -fapi::ReturnCode writeScom(const ifData_t & i_ifData, const scomList_t & i_scomList); - -void deleteDataArrayIdx(const ifData_t & ifData, const uint32_t i_scomNum, - const uint16_t i_row); +fapi::ReturnCode writeScom(ifData_t & i_ifData, const scomList_t & i_scomList); -uint8_t getAttrArrayDimension(const ifData_t & i_ifData, uint16_t i_id); - -fapi::ReturnCode getDataArrayIdx(const ifData_t & i_ifData, - const uint8_t i_attrDimension, - uint16_t o_arrayIndex[MAX_ATTRIBUTE_ARRAY_DIMENSION]); +fapi::ReturnCode getAttrArrayDimension(const ifData_t & i_ifData, + const uint16_t i_id, + uint8_t & o_attrDimension); void rpnPush(rpnStack_t * io_rpnStack, uint64_t i_val); @@ -339,9 +334,6 @@ fapi::ReturnCode fapiHwpExecInitFile(const std::vector<fapi::Target> & i_target, ifData_t l_ifData; memset(&l_ifData, 0, sizeof(ifData_t)); - dataArrayIdxId_t l_dataArrayIdxId; - l_ifData.dataArrayIdxId = &l_dataArrayIdxId; - //-------------------------------- // Load the Attribute Symbol Table //-------------------------------- @@ -363,13 +355,6 @@ fapi::ReturnCode fapiHwpExecInitFile(const std::vector<fapi::Target> & i_target, IF_DBG("fapiHwpExecInitFile: Addr of scom struct %p, " "num scoms %u", l_ifData.scoms, l_ifData.numScoms); - #ifdef HWPEXECINITFILE_DEBUG2 - for (size_t i = 0; i < l_dataArrayIdxId.size(); i++) - { - IF_DBG ("dataArrayIdxId[%u] 0x%02x", i, l_dataArrayIdxId.at(i)); - } - #endif - //-------------------------------- // Execute SCOMs //-------------------------------- @@ -381,10 +366,6 @@ fapi::ReturnCode fapiHwpExecInitFile(const std::vector<fapi::Target> & i_target, // Unload //-------------------------------- - // Unload the data array index id container - l_dataArrayIdxId.clear(); - l_ifData.dataArrayIdxId = NULL; - // Unload the Attribute Symbol Table unloadAttrSymbolTable(l_ifData); @@ -447,12 +428,13 @@ void ifSeek(ifInfo_t & io_ifInfo, size_t i_offset) * @param[in,out] io_ifInfo Reference to ifInfo_t which contains addr, size, * and current offset of the initfile * @param[out] o_data Ptr to buffer where data read will be stored - * @param[in] i_size number of bytes to read (1, 2, 4 or 8 bytes) + * @param[in] i_size number of bytes to read * @param[in] i_swap If true, will swap bytes to account for endianness if needed. */ void ifRead(ifInfo_t & io_ifInfo, void * o_data, uint32_t i_size, bool i_swap) { - if (!((1 == i_size) || (2 == i_size) || (4 == i_size) || (8 == i_size))) + if ((true == i_swap) && + !((1 == i_size) || (2 == i_size) || (4 == i_size) || (8 == i_size))) { FAPI_ERR("fapiHwpExecInitFile: ifRead: invalid number of bytes %d", i_size); fapiAssert(false); @@ -614,6 +596,8 @@ fapi::ReturnCode getAttr(const ifData_t & i_ifData, if (0 == i_targetNum) { //Expect nonzero targetNum + FAPI_ERR("fapiHwpExecInitFile: getAttr: Expect nonzero " + "targetNum"); fapiAssert(false); } else if (i_ifData.pTarget->size() <= i_targetNum) @@ -656,7 +640,7 @@ fapi::ReturnCode getAttr(const ifData_t & i_ifData, } else { - FAPI_ERR("fapiHwpExecInitFile: getAttr: id out of range"); + FAPI_ERR("fapiHwpExecInitFile: getAttr: id 0x%x out of range", i_id); 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); @@ -796,7 +780,7 @@ fapi::ReturnCode getLit(const ifData_t & i_ifData, } else { - FAPI_ERR("fapiHwpExecInitFile: getLit: id out of range"); + FAPI_ERR("fapiHwpExecInitFile: getLit: id 0x%x out of range", i_id); 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); @@ -892,74 +876,49 @@ void loadScomSection(ifInfo_t & io_ifInfo, } //----------------------------------- - //Read the scom data ids + //Read the scom data //----------------------------------- - //Allocate memory to hold the data ids; i.e. attribute or numeric literal ids - l_scoms[i].dataId = - reinterpret_cast<uint16_t*>(malloc(l_scoms[i].numRows * sizeof(uint16_t*))); - memset(l_scoms[i].dataId, 0, - l_scoms[i].numRows * sizeof(uint16_t*)); + uint8_t l_rowSize = 0; + char * l_rowPtr = NULL; - //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*)); + //Allocate memory to hold the scom data + l_scoms[i].data = + reinterpret_cast<char**>(malloc(l_scoms[i].numRows * sizeof(char**))); + memset(l_scoms[i].data, 0, l_scoms[i].numRows * sizeof(char**)); - //Read the data ids + //Read the scom data for each row for (uint16_t j = 0; j < l_scoms[i].numRows; j++) { - ifRead(io_ifInfo, &(l_scoms[i].dataId[j]), - sizeof(l_scoms[i].dataId[j])); - - IF_DBG("loadScomSection: scom[%u]: dataId[%u] 0x%02x", - i, j, l_scoms[i].dataId[j]); + //Read the row size; i.e. # of bytes + ifRead(io_ifInfo, &l_rowSize, sizeof(l_rowSize)); - //Is this an attribute - if (l_scoms[i].dataId[j] & IF_ATTR_TYPE) + //Expect non-zero row size + if (0 >= l_rowSize) { - //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]); - } + FAPI_ERR("loadScomSection: scom[%u]: scom data row size %u", + i, l_rowSize); + fapiAssert(false); + } - //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 - uint8_t l_attrDimension = - io_ifData.attrs[l_id].type & ATTR_DIMENSION_MASK; - l_attrDimension = l_attrDimension >> 4; + //Allocate the space for the scom data and its size + l_scoms[i].data[j] = reinterpret_cast<char *>(malloc(l_rowSize + 1)); + memset(l_scoms[i].data[j], 0, l_rowSize + 1); + l_rowPtr = l_scoms[i].data[j]; - IF_DBG("loadScomSection: data is an attribute of " - "dimension %u", l_attrDimension); + //Save the size of the scom data + *l_rowPtr++ = l_rowSize; - // Read out all dimensions for the attribute - for(uint8_t k = 0; k < l_attrDimension; k++) - { - // Save the array index id - uint16_t l_idxId = 0; - ifRead(io_ifInfo, &l_idxId, sizeof(uint16_t)); - io_ifData.dataArrayIdxId->push_back(static_cast<uint64_t>(l_idxId)); - IF_DBG("loadScomSection: array index id 0x%02x", - io_ifData.dataArrayIdxId->back()); - } - } - else - { - FAPI_ERR("loadScomSection: scom[%u]: dataId[%u] 0x%02x:" - " index id 0x%02x out of range", i, j, - l_scoms[i].dataId[j], l_id); - fapiAssert(false); - } + //Read in the scom data + //Don't swap the bytes, scom data will parsed by byte later in code + ifRead(io_ifInfo, l_rowPtr, l_rowSize, false); + #if defined(HOSTBOOT_DEBUG) && defined(HWPEXECINITFILE_DEBUG) + for (k = 0; k < l_rowSize; k++) + { + IF_DBG("loadScomSection: scom[%u]: data[%u] " + "0x%02x", i, j, *l_rowPtr++); } + #endif } // Set to default @@ -1035,8 +994,8 @@ void loadScomSection(ifInfo_t & io_ifInfo, } //Read the row data for each row - uint8_t l_rowSize = 0; - char * l_rowPtr = NULL; + l_rowSize = 0; + l_rowPtr = NULL; uint32_t c; for (uint16_t j = 0; j < l_scoms[i].numRows; j++) @@ -1135,11 +1094,17 @@ void unloadScomSection(ifData_t & io_ifData) //Deallocate memory for (uint32_t i = 0; i < io_ifData.numScoms; i++) { - free(io_ifData.scoms[i].dataId); - io_ifData.scoms[i].dataId = NULL; + if (NULL != io_ifData.scoms[i].data) + { + for (uint16_t j = 0; j < io_ifData.scoms[i].numRows; j++) + { + free(io_ifData.scoms[i].data[j]); + io_ifData.scoms[i].data[j] = NULL; + } - free(io_ifData.scoms[i].dataTgtId); - io_ifData.scoms[i].dataTgtId = NULL; + free(io_ifData.scoms[i].data); + io_ifData.scoms[i].data = NULL; + } free(io_ifData.scoms[i].colId); io_ifData.scoms[i].colId = NULL; @@ -1308,9 +1273,6 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData) { IF_DBG("fapiHwpExecInitFile: executeScoms: check next row"); - //Delete any data array indices stored for this row - deleteDataArrayIdx(i_ifData, i, l_row); - l_goToNextRow = false; continue; } @@ -1344,11 +1306,6 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData) IF_DBG("fapiHwpExecInitFile: executeScoms: Expr: found valid row"); break; } - else - { - //Delete any data array indices stored for this row - deleteDataArrayIdx(i_ifData, i, l_row); - } } else { @@ -1374,38 +1331,6 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData) //Set the scom entry number and it's row l_scom.scomNum = i; l_scom.row = l_row; - memset(l_scom.dataArrayIdx, 0, - sizeof(uint16_t)*MAX_ATTRIBUTE_ARRAY_DIMENSION); - - //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_ATTR_TYPE) //It's an attribute - { - uint8_t l_attrDimension = getAttrArrayDimension(i_ifData, l_dataId); - if (l_attrDimension) - { - l_rc = getDataArrayIdx(i_ifData, l_attrDimension, - l_scom.dataArrayIdx); - - #ifdef HWPEXECINITFILE_DEBUG2 - IF_DBG("fapiHwpExecInitFile: executeScoms: scom data array" - " indexes are"); - for (uint8_t j = 0; j < l_attrDimension; j++) - { - IF_DBG(" [%u]", l_scom.dataArrayIdx[j]); - } - #endif - - if (l_rc) - { - FAPI_ERR("fapiHwpExecInitFile: executeScoms: Failed to get" - "data array index for scom# %u row %u", - l_scom.scomNum, l_scom.row); - break; - } - } - } //push the scom entry and it's row into the list to write l_scomList.push_back(l_scom); @@ -1476,7 +1401,7 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData) * * @return ReturnCode. Zero if success. */ -fapi::ReturnCode writeScom(const ifData_t & i_ifData, +fapi::ReturnCode writeScom(ifData_t & i_ifData, const scomList_t & i_scomList) { FAPI_DBG(">> fapiHwpExecInitFile: writeScom"); @@ -1490,14 +1415,20 @@ fapi::ReturnCode writeScom(const ifData_t & i_ifData, uint64_t l_mask = 0; // aggregate mask for PutScomUnderMask op uint16_t l_scomNum = 0; + uint16_t l_row = 0; + uint64_t l_tmpData = 0; uint16_t l_addrId = 0; uint64_t l_addr = 0; + char * l_rowExpr = NULL; // pointer to scom data expression + uint8_t l_rowSize = 0; // size of scom data do { for (size_t l_entry = 0; l_entry < i_scomList.size(); l_entry++) { l_scomNum = i_scomList.at(l_entry).scomNum; + l_row = i_scomList.at(l_entry).row; + l_tmpData = 0; if (0 == l_entry) { @@ -1518,37 +1449,25 @@ fapi::ReturnCode writeScom(const ifData_t & i_ifData, } //Get the scom data - uint64_t l_tmpData = 0; - uint16_t l_row = i_scomList.at(l_entry).row; - uint16_t l_dataId = i_ifData.scoms[l_scomNum].dataId[l_row]; + IF_DBG("fapiHwpExecInitFile: writeScom: Evaluate scom data"); - 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_rowExpr = i_ifData.scoms[l_scomNum].data[l_row]; + l_rowSize = *((uint8_t*)l_rowExpr); //size of the scom data + l_rowExpr++; - l_rc = getAttr(i_ifData, l_dataId, l_tmpData, - l_dataTgtNum, i_scomList.at(l_entry).dataArrayIdx); - } - else // It's a numeric literal - { - l_rc = getLit(i_ifData, l_dataId, l_tmpData); - } + l_rc = evalRpn(i_ifData, l_rowExpr, l_rowSize, false, false); if (l_rc) { + FAPI_ERR("fapiHwpExecInitFile: writeScom: scom data expression " + "evalRpn failed on scom 0x%X", i_ifData.scoms[l_scomNum].addrId); break; } + l_tmpData = rpnPop(i_ifData.rpnStack); + IF_DBG("fapiHwpExecInitFile: writeScom: Scom data 0x%llX", + l_tmpData); + IF_DBG("fapiHwpExecInitFile: writeScom: addr 0x%.16llX, " "data 0x%.16llX", l_addr, l_tmpData); @@ -1676,51 +1595,6 @@ fapi::ReturnCode writeScom(const ifData_t & i_ifData, return l_rc; } -/** @brief Delete any data array indices for specified Scom and row - * - * @param[in] i_ifData Reference to ifData_t which contains initfile data - * @param[in] i_scomNum Scom entry number - * @param[in] i_row Scom entry row number - * - * @return void - */ -void deleteDataArrayIdx(const ifData_t & i_ifData, - const uint32_t i_scomNum, - const uint16_t i_row) -{ - //Get the scom data - uint16_t l_id = i_ifData.scoms[i_scomNum].dataId[i_row]; - if (l_id & IF_ATTR_TYPE) //It's an attribute - { - //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 - uint8_t l_attrDimension = - (i_ifData.attrs[l_tmpId].type & ATTR_DIMENSION_MASK) >> 4; - if (l_attrDimension) - { - IF_DBG("fapiHwpExecInitFile: deleteDataArrayIdx: " - "Delete data array indices for scom[%u] row[%u]", - i_scomNum, i_row); - - // Remove the array index id(s) - i_ifData.dataArrayIdxId->erase(i_ifData.dataArrayIdxId->begin(), - i_ifData.dataArrayIdxId->begin() + l_attrDimension); - } - } - } - - #ifdef HWPEXECINITFILE_DEBUG2 - for (size_t i = 0; i < i_ifData.dataArrayIdxId->size(); i++) - { - IF_DBG ("dataArrayIdxId[%u] 0x%02x", i, i_ifData.dataArrayIdxId->at(i)); - } - #endif - - return; -} /** @brief Get the attribute array dimension. * @@ -1729,76 +1603,34 @@ void deleteDataArrayIdx(const ifData_t & i_ifData, * * @return the attribute dimension */ -uint8_t getAttrArrayDimension(const ifData_t & i_ifData, uint16_t i_id) +fapi::ReturnCode getAttrArrayDimension(const ifData_t & i_ifData, + const uint16_t i_id, + uint8_t & o_attrDimension) { - uint8_t l_attrDimension = 0; + fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS; + + o_attrDimension = 0; //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 - l_attrDimension = + o_attrDimension = (i_ifData.attrs[l_id].type & ATTR_DIMENSION_MASK) >> 4; - } - - IF_DBG("fapiHwpExecInitFile: getAttrArrayDimension: Attr ID:0x%.4X " - "has dimension %u of type 0x%.4X", - i_id, l_attrDimension, i_ifData.attrs[l_id].type); - - return l_attrDimension; -} - -/** @brief Get the array indexes of this attribute - * the dimension. - * - * @param[in] i_ifData Reference to ifData_t which contains initfile data - * @param[in] i_attrDimension The attribute array dimension - * @param[out] o_arrayIndex[] The attribute array indexes - * - * @return ReturnCode. Zero if success. - */ -fapi::ReturnCode getDataArrayIdx(const ifData_t & i_ifData, - const uint8_t i_attrDimension, - uint16_t o_arrayIndex[MAX_ATTRIBUTE_ARRAY_DIMENSION]) -{ - fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS; - do + IF_DBG("fapiHwpExecInitFile: getAttrArrayDimension: Attr ID:0x%.4X " + "has dimension %u of type 0x%.4X", + i_id, l_attrDimension, i_ifData.attrs[l_id].type); + } + else { - // Read out all dimensions for the attribute - for(uint8_t i = 0; i < i_attrDimension; i++) - { - // Get the array index id - uint64_t l_idxId = i_ifData.dataArrayIdxId->at(i); - - // Retrieve the actual value for the array index (using it's id) - uint64_t l_idx = 0; - l_rc = getLit(i_ifData,l_idxId,l_idx); - if (l_rc) - { - break; - } - o_arrayIndex[i] = l_idx; - } + FAPI_ERR("fapiHwpExecInitFile: getAttrArrayDimension: " + "id 0x%x out of range", i_id); - if (l_rc) - { - break; - } - - // Remove the array index id(s) - i_ifData.dataArrayIdxId->erase(i_ifData.dataArrayIdxId->begin(), - i_ifData.dataArrayIdxId->begin() + i_attrDimension); - - #ifdef HWPEXECINITFILE_DEBUG2 - for (size_t i = 0; i < i_ifData.dataArrayIdxId->size(); i++) - { - IF_DBG ("dataArrayIdxId[%u] 0x%02x", - i, i_ifData.dataArrayIdxId->at(i)); - } - #endif - } while (0); + 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); + } return l_rc; } @@ -1829,14 +1661,15 @@ uint64_t rpnPop(rpnStack_t * io_rpnStack) { IF_DBG("fapiHwpExecInitFile: rpnPop"); - uint64_t l_val = 0; - - if (io_rpnStack->size() != 0) + if (0 == io_rpnStack->size()) { - l_val = io_rpnStack->back(); - io_rpnStack->pop_back(); + FAPI_ERR("fapiHwpExecInitFile: rpnPop: rpn stack is empty"); + fapiAssert(false); } + uint64_t l_val = io_rpnStack->back(); + io_rpnStack->pop_back(); + return l_val; } @@ -2248,7 +2081,12 @@ fapi::ReturnCode evalRpn(ifData_t & io_ifData, char *i_expr, } // Get the attribute dimension - uint8_t l_attrDimension = getAttrArrayDimension(io_ifData, l_id); + uint8_t l_attrDimension = 0; + l_rc = getAttrArrayDimension(io_ifData, l_id, l_attrDimension); + if (l_rc) + { + break; + } // Read out all dimensions for the attribute for(uint8_t j=0; j<l_attrDimension; j++) diff --git a/src/usr/hwpf/hwp/initfiles/sample.initfile b/src/usr/hwpf/hwp/initfiles/sample.initfile index 1841c9fb0..60012acc0 100755 --- a/src/usr/hwpf/hwp/initfiles/sample.initfile +++ b/src/usr/hwpf/hwp/initfiles/sample.initfile @@ -126,12 +126,14 @@ scom 0x000000000006800c { #--****************************************************************************** #-- Basic SCOM with same address but different bits set & Scom data of Attr type +#-- Simple operations on Scom data #--****************************************************************************** scom 0x000000000006800c { - bits , scom_data ; - 24:31 , SYS.ATTR_SCRATCH_UINT8_ARRAY_2[1][2][3] ; - 32:63 , SYS.ATTR_SCRATCH_UINT32_1; + bits , scom_data , expr ; + 24:31, (MBA1.ATTR_CHIP_UNIT_POS + SYS.ATTR_SCRATCH_UINT8_ARRAY_2[1][2][3]) , SYS.ATTR_SCRATCH_UINT8_1 != 1; + 24:31, (MBA1.ATTR_CHIP_UNIT_POS + SYS.ATTR_SCRATCH_UINT8_ARRAY_2[1][2][3] + 1) / 2, !(SYS.ATTR_SCRATCH_UINT8_1 == 3); + 32:63, (SYS.ATTR_SCRATCH_UINT32_1 * 20) << 8 , SYS.ATTR_SCRATCH_UINT32_1 == 3; } #--****************************************************************************** diff --git a/src/usr/hwpf/ifcompiler/initCompiler.lex b/src/usr/hwpf/ifcompiler/initCompiler.lex index beed2195a..eb6e4720f 100755 --- a/src/usr/hwpf/ifcompiler/initCompiler.lex +++ b/src/usr/hwpf/ifcompiler/initCompiler.lex @@ -1,20 +1,26 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* fips740 src/engd/initfiles/ifcompiler/initCompiler.lex 1.2 */ -/* */ -/* IBM CONFIDENTIAL */ -/* */ -/* OBJECT CODE ONLY SOURCE MATERIALS */ -/* */ -/* COPYRIGHT International Business Machines Corp. 2010 */ -/* All Rights Reserved */ -/* */ -/* The source code for this program is not published or otherwise */ -/* divested of its trade secrets, irrespective of what has been */ -/* deposited with the U.S. Copyright Office. */ -/* */ -/* IBM_PROLOG_END_TAG */ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/ifcompiler/initCompiler.lex $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2010-2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ /* Change Log ************************************************************************************* // // Flag Track Userid Date Description @@ -36,6 +42,7 @@ // 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 +// camvanng 05/22/12 Fix "OP" definition // End Change Log *********************************************************************************/ /** * @file initCompiler.lex @@ -105,7 +112,7 @@ ID2 [A-Za-z][A-Za-z0-9_]*(\[[0-9]+(..[0-9]+)?(,[0-9]+(..[0-9]+)?)*\]){0,4} ID3 [0-9]+[A-Za-z_]+[0-9]* DIGIT [0-9] COMMENT #.*\n -OP "="|"+"|"-"|"|"|"<"|">"|"*"|"/"|"%" +OP "="|"+"|"-"|"!"|"<"|">"|"*"|"/"|"%" FLOAT [0-9]+"."[0-9]* BINARY 0[bB][0-1]+ SINGLE_BIN [0-1] diff --git a/src/usr/hwpf/ifcompiler/initCompiler.y b/src/usr/hwpf/ifcompiler/initCompiler.y index 3398919ac..6079febb7 100755 --- a/src/usr/hwpf/ifcompiler/initCompiler.y +++ b/src/usr/hwpf/ifcompiler/initCompiler.y @@ -1,20 +1,26 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* fips730 src/engd/initfiles/ifcompiler/initCompiler.y 1.1 */ -/* */ -/* IBM CONFIDENTIAL */ -/* */ -/* OBJECT CODE ONLY SOURCE MATERIALS */ -/* */ -/* COPYRIGHT International Business Machines Corp. 2010 */ -/* All Rights Reserved */ -/* */ -/* The source code for this program is not published or otherwise */ -/* divested of its trade secrets, irrespective of what has been */ -/* deposited with the U.S. Copyright Office. */ -/* */ -/* IBM_PROLOG_END_TAG */ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/ifcompiler/initCompiler.y $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2010-2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ // Change Log ************************************************************************************* // // Flag Track Userid Date Description @@ -31,6 +37,8 @@ // 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/22/12 Ability to do simple operations on attributes +// in the scom_data column // End Change Log ********************************************************************************* /** * @file initCompiler.y @@ -111,7 +119,7 @@ int scom; /* non-terminal tokens and the union data-type associated with them */ %type <str_ptr> bitsrows -%type <rpn_ptr> expr id_col num_list +%type <rpn_ptr> expr id_col num_list scomdexpr @@ -230,19 +238,29 @@ scombodyline: INIT_SCOMD ',' scomdrows {} ; -scomdrows: expr { - /*printf("scomdrows - RPN Address:0x%X\n",$1);*/ +scomdrows: scomdexpr { + /* printf("\n\nscomdrows - RPN Address:0x%X\n\n\n",$1); */ init::dbg << $1->listing("Length scom RPN"); current_scom->add_scom_rpn($1); } - | scomdrows ',' expr { init::dbg << $3->listing("Length scom RPN"); current_scom->add_scom_rpn($3); } + | scomdrows ',' scomdexpr { init::dbg << $3->listing("Length scom RPN"); current_scom->add_scom_rpn($3); } ; - -/* -scomdrows: id_col { printf("scomdrows\n"); } +scomdexpr: INIT_INTEGER { $$= new init::Rpn($1,yyscomlist->get_symbols());} + | INIT_ID { $$= new init::Rpn(*($1),yyscomlist->get_symbols()); delete $1;} + | ATTRIBUTE_ENUM { $$= new init::Rpn((yyscomlist->get_symbols())->get_attr_enum_val(*($1)),yyscomlist->get_symbols()); delete $1; } + | INIT_INT64 { $$=new init::Rpn($1,yyscomlist->get_symbols()); } + | scomdexpr ATTRIBUTE_INDEX { $1->push_array_index(*($2)); delete $2; } + | scomdexpr INIT_SHIFT_RIGHT scomdexpr { $$ = $1->push_merge($3,SHIFTRIGHT); } + | scomdexpr INIT_SHIFT_LEFT scomdexpr { $$ = $1->push_merge($3,SHIFTLEFT); } + | scomdexpr '+' scomdexpr { $$ = $1->push_merge($3,PLUS); } + | scomdexpr '-' scomdexpr { $$ = $1->push_merge($3,MINUS); } + | scomdexpr '*' scomdexpr { $$ = $1->push_merge($3,MULT); } + | scomdexpr '/' scomdexpr { $$ = $1->push_merge($3,DIVIDE); } + | scomdexpr '%' scomdexpr { $$ = $1->push_merge($3,MOD); } + | '!' scomdexpr { $$ = $2->push_op(NOT); } + | '(' scomdexpr ')' { $$ = $2; } ; -*/ bitsrows: bitrange {} | bitsrows ',' bitrange {} diff --git a/src/usr/hwpf/ifcompiler/initRpn.C b/src/usr/hwpf/ifcompiler/initRpn.C index 10b8254e5..d926e62f1 100755 --- a/src/usr/hwpf/ifcompiler/initRpn.C +++ b/src/usr/hwpf/ifcompiler/initRpn.C @@ -1,17 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/ifcompiler/initRpn.C,v $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2010,2010 -// -//UNDEFINED -// -// Origin: UNDEFINED -// -// IBM_PROLOG_END_TAG +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/ifcompiler/initRpn.C $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2010-2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ // Change Log ************************************************************************************* // // Flag Reason Userid Date Description @@ -29,6 +38,8 @@ // Support defines for bits, scom_data and attribute columns // Delete obsolete code for defines support // camvanng 05/07/12 Support for associated target attributes +// camvanng 05/22/12 Ability to do simple operations on attributes +// in the scom_data column // End Change Log ********************************************************************************* /** @@ -577,39 +588,31 @@ Rpn * Rpn::merge(Rpn * i_rpn) //------------------------------------------------------------------------------------------------- // See header file for contract -void Rpn::bin_read(BINSEQ::const_iterator & bli, Symbols * symbols) +void Rpn::bin_read(BINSEQ::const_iterator & bli, uint8_t i_size, Symbols * symbols) { - uint32_t size = 2; // Size is always 2 for symbols - if(symbols) iv_symbols = symbols; iv_rpnstack.clear(); iv_array_idx_range.clear(); - while(size) + while(i_size) { uint32_t v = *bli++; + --i_size; if(v < LAST_OP) // operator { if(v == LIST) { - --size; + --i_size; v |= (*bli++) << 8; } iv_rpnstack.push_back(v | OPERATION); - --size; } else // tag { v = (v << 8) + (*bli++); - --size; - if(size == 0) - { - std::ostringstream errss; - errss << "Rpn::bin_read Invalid RPN binary sequence\n"; - throw std::invalid_argument(errss.str()); - } - --size; + --i_size; + uint32_t l_rpn_id = iv_symbols->get_rpn_id(v); iv_rpnstack.push_back(l_rpn_id); @@ -621,6 +624,7 @@ void Rpn::bin_read(BINSEQ::const_iterator & bli, Symbols * symbols) { v = *bli++; v = (v << 8) + (*bli++); + i_size -= 2; iv_rpnstack.push_back(iv_symbols->get_rpn_id(v)); //printf("Rpn::bin_read: Assoc target attribute id 0x%x\n", v); } @@ -633,6 +637,7 @@ void Rpn::bin_read(BINSEQ::const_iterator & bli, Symbols * symbols) v = *bli++; v = (v << 8) + (*bli++); iv_rpnstack.push_back(iv_symbols->get_rpn_id(v)); + i_size -= 2; } } } @@ -666,6 +671,49 @@ BINSEQ::const_iterator Rpn::bin_read_one_op(BINSEQ::const_iterator & bli, Symbol } //------------------------------------------------------------------------------------------------- +void Rpn::bin_read_one_id(BINSEQ::const_iterator & io_bli, Symbols * i_symbols) +{ + if(i_symbols) iv_symbols = i_symbols; + + uint32_t v = *io_bli++; + if(v < LAST_OP) // operator + { + std::ostringstream errss; + errss << "Rpn::bin_read_one_id: This is an op\n"; + throw std::invalid_argument(errss.str()); + } + + // not op - always two bytes + v = (v << 8) + (*io_bli++); + + uint32_t l_rpn_id = iv_symbols->get_rpn_id(v); + iv_rpnstack.push_back(l_rpn_id); + + //Check for attribute of array type + if (v & IF_ATTR_TYPE) + { + //Check for associated target attribute + if ((v & IF_TYPE_MASK) == IF_ASSOC_TGT_ATTR_TYPE) + { + v = *io_bli++; + v = (v << 8) + (*io_bli++); + iv_rpnstack.push_back(iv_symbols->get_rpn_id(v)); + //printf("Rpn::bin_read_one_id: 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<uint8_t>(l_type) & ATTR_DIMENSION_MASK) >> 4; + for(uint8_t i=0; i < l_attrDimension; i++) + { + v = *io_bli++; + v = (v << 8) + (*io_bli++); + iv_rpnstack.push_back(iv_symbols->get_rpn_id(v)); + } + } +} + +//------------------------------------------------------------------------------------------------- void Rpn::append(const Rpn & i_rpn) { @@ -742,7 +790,7 @@ std::string Rpn::listing(const char * i_desc, const std::string & spyname, bool else { rpn_byte_size += size; - oss << "0x" << std::setw(size * 2) << data << '\t' << "Numerica Literal" << std::endl; + oss << "0x" << std::setw(size * 2) << data << '\t' << "Numerical Literal" << std::endl; } } else if((*i) & SYMBOL) diff --git a/src/usr/hwpf/ifcompiler/initRpn.H b/src/usr/hwpf/ifcompiler/initRpn.H index 1965603b2..7e87554c8 100755 --- a/src/usr/hwpf/ifcompiler/initRpn.H +++ b/src/usr/hwpf/ifcompiler/initRpn.H @@ -1,17 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/ifcompiler/initRpn.H,v $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2010,2010 -// -//UNDEFINED -// -// Origin: UNDEFINED -// -// IBM_PROLOG_END_TAG +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/ifcompiler/initRpn.H $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2010-2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ #if !defined(INITRPN_H) #define INITRPN_H @@ -27,6 +36,8 @@ // camvanng 11/08/11 Added support for attribute enums // andrewg 11/09/11 Multi-dimensional array and move to common fapi include // camvanng 01/20/12 Support for using a range of indexes for array attributes +// camvanng 05/22/12 Ability to do simple operations on attributes +// in the scom_data column // End Change Log ********************************************************************************* /** @@ -191,13 +202,15 @@ namespace init /** * Read binary sequence to recreate this Rpn sequence - * @param bineary sequence interator + * @param binary sequence interator + * @param number of bytes to read * @param symbol table to use - * @pre first byte in binary sequence is the size of the rpn sequence in bytes - * @post if symbols != NULL then iv_rpnstack is replaced - * @post iv_symbols is replace with symbols + * @post this rpn sequence is appended + * @post if symbols != NULL then iv_symbols is replaced with symbols */ - void bin_read(BINSEQ::const_iterator & bli, Symbols * symbols = NULL); // read binary sequence to recreate RPN + void bin_read(BINSEQ::const_iterator & bli, + uint8_t i_size = 2, + Symbols * symbols = NULL); // read binary sequence to recreate RPN /** * Copy one rpn operation from bli and add to this Rpn sequence @@ -212,6 +225,17 @@ namespace init */ BINSEQ::const_iterator bin_read_one_op(BINSEQ::const_iterator & bli, Symbols * symbols = NULL); // read one rpn operation from bli to create Rpn + /** + * Copy one numeric literal or attribute from io_bli and add to this Rpn sequence + * @param[in,out] io_bli iterator of a binary rpn sequence + * @param[in] i_symbols table to use. + * @pre io_bli points to a valid rpn sequence + * @post this Rpn sequence is appended + * @post Internal symbol table ptr is replaced with given symbol table ptr if not NULL + * @post iterator of binary sequence is one past the last byte used. + */ + void bin_read_one_id(BINSEQ::const_iterator & io_bli, Symbols * i_symbols = NULL); + //dg002a /** * Resolve the RPN and returns false if the given EC level causes the RPN expression to be false. diff --git a/src/usr/hwpf/ifcompiler/initScom.C b/src/usr/hwpf/ifcompiler/initScom.C index edd030e56..7fc527693 100755 --- a/src/usr/hwpf/ifcompiler/initScom.C +++ b/src/usr/hwpf/ifcompiler/initScom.C @@ -1,18 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/ifcompiler/initScom.C,v $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2010,2010 -// -//UNDEFINED -// -// Origin: UNDEFINED -// -// IBM_PROLOG_END_TAG - +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/ifcompiler/initScom.C $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2010-2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ // Change Log ************************************************************************************* // // Flag Track Userid Date Description @@ -33,6 +41,8 @@ // 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 +// camvanng 05/22/12 Ability to do simple operations on attributes +// in the scom_data column // End Change Log ********************************************************************************* /** @@ -105,7 +115,11 @@ Scom::Scom(BINSEQ::const_iterator & bli, Symbols * i_symbols): for(size_t i = 0; i < numrows; ++i) { - Rpn rpn(bli,iv_symbols); + uint8_t length = *bli++; // first byte is length of rpn sequence + //printf("Creating scom data rpn, length %u\n", length); + + Rpn rpn(iv_symbols); // blank RPNs + rpn.bin_read(bli, length); // read rpn sequence iv_scom_rpn.push_back(rpn); } @@ -116,7 +130,8 @@ Scom::Scom(BINSEQ::const_iterator & bli, Symbols * i_symbols): // Read col heads for(size_t i = 0; i < numcols; ++i) { - Rpn col_name_rpn(bli,iv_symbols); + Rpn col_name_rpn(iv_symbols); // blank RPNs + col_name_rpn.bin_read_one_id(bli); iv_col_vars.push_back(col_name_rpn); iv_cols_rpn.push_back(iv_row_rpn); // copy in blank row RPNs for this column } @@ -581,7 +596,7 @@ void Scom::bin_list_one(BINSEQ & blist,uint64_t i_addr, uint32_t i_addr_num, RAN { if ((*r) == range) { - i->bin_str(blist,numaddrs,i_addr_num,false); + i->bin_str(blist,numaddrs,i_addr_num,true); //Add length to blist } } } @@ -589,7 +604,7 @@ void Scom::bin_list_one(BINSEQ & blist,uint64_t i_addr, uint32_t i_addr_num, RAN { for(RPN_LIST::iterator i = iv_scom_rpn.begin(); i != iv_scom_rpn.end(); ++i) { - i->bin_str(blist,numaddrs,i_addr_num,false); + i->bin_str(blist,numaddrs,i_addr_num,true); //Add length to blist } } diff --git a/src/usr/hwpf/test/hwpftest.H b/src/usr/hwpf/test/hwpftest.H index 24f3c769e..772ad53eb 100644 --- a/src/usr/hwpf/test/hwpftest.H +++ b/src/usr/hwpf/test/hwpftest.H @@ -293,8 +293,8 @@ public: (0x0000000000000008ll << (64 - (24 + 8)))}, {0x000000000006800b, 0, 0}, {0x000000000006800c, 0, (0x8000000000000000 >> 0x17) | - (0x00000000000000BEll << (64 - (24 + 8))) | - 0x0000000000000003}, + (0x0000000000000060ll << (64 - (24 + 8))) | + 0x0000000000003C00}, {0x0000000013010002, 0, 0xAABBC00000000000}, {0x0000000013030007, 0, 0x00000CDE00000000}, {0x0000000013013283, 0, 0x3c90000000000000 | |