summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf
diff options
context:
space:
mode:
authorCamVan Nguyen <ctnguyen@us.ibm.com>2012-01-31 23:26:38 -0600
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-02-07 11:40:32 -0600
commit7839259660f10f1b31db833fce37aa323e749f41 (patch)
tree522dcdc39a32916cffe62134e9ae63b5213f5084 /src/usr/hwpf
parent29f47aee84ded4c6e59da561c2e9b6257590b31d (diff)
downloadblackbird-hostboot-7839259660f10f1b31db833fce37aa323e749f41.tar.gz
blackbird-hostboot-7839259660f10f1b31db833fce37aa323e749f41.zip
SCOM Initfile - Support for using a range of index's for an array attribute
Change-Id: I87a23905c877281037b8610b6400b828f0578bec Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/636 Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com> Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf')
-rw-r--r--src/usr/hwpf/hwp/fapiHwpExecInitFile.C82
-rwxr-xr-xsrc/usr/hwpf/hwp/initfiles/sample.initfile105
-rwxr-xr-xsrc/usr/hwpf/ifcompiler/initCompiler.lex11
-rwxr-xr-xsrc/usr/hwpf/ifcompiler/initCompiler.y10
-rwxr-xr-xsrc/usr/hwpf/ifcompiler/initRpn.C146
-rwxr-xr-xsrc/usr/hwpf/ifcompiler/initRpn.H10
-rwxr-xr-xsrc/usr/hwpf/ifcompiler/initScom.C25
-rwxr-xr-xsrc/usr/hwpf/ifcompiler/initScom.H3
-rwxr-xr-xsrc/usr/hwpf/ifcompiler/initSymbols.C2
-rw-r--r--src/usr/hwpf/test/hwpftest.H49
10 files changed, 328 insertions, 115 deletions
diff --git a/src/usr/hwpf/hwp/fapiHwpExecInitFile.C b/src/usr/hwpf/hwp/fapiHwpExecInitFile.C
index 67b91a24a..4f10de175 100644
--- a/src/usr/hwpf/hwp/fapiHwpExecInitFile.C
+++ b/src/usr/hwpf/hwp/fapiHwpExecInitFile.C
@@ -40,6 +40,8 @@
* camvanng 01/06/2012 Support for writing an
* attribute to a SCOM register
* mjjones 01/13/2012 Use new ReturnCode interfaces
+ * camvanng 01/20/2012 Support for using a range
+ * indexes for array attributes
*/
#include <fapiHwpExecInitFile.H>
@@ -189,6 +191,9 @@ fapi::ReturnCode executeScoms(ifData_t & io_ifData);
fapi::ReturnCode writeScom(const ifData_t & i_ifData, const uint32_t i_scomNum,
const uint16_t i_row);
+void deleteDataArrayIdx(const ifData_t & ifData, const uint32_t i_scomNum,
+ const uint16_t i_row);
+
void rpnPush(rpnStack_t * io_rpnStack, uint64_t i_val);
uint64_t rpnPop(rpnStack_t * io_rpnStack);
@@ -321,6 +326,13 @@ fapi::ReturnCode fapiHwpExecInitFile(const fapi::Target & i_Target,
FAPI_DBG("fapiHwpExecInitFile: Addr of scom struct %p, "
"num scoms %u", l_ifData.scoms, l_ifData.numScoms);
+ #ifdef HWPEXECINITFILE_DEBUG
+ for (size_t i = 0; i < l_dataArrayIdxId.size(); i++)
+ {
+ FAPI_DBG ("dataArrayIdxId[%u] 0x%02x", i, l_dataArrayIdxId.at(i));
+ }
+ #endif
+
//--------------------------------
// Execute SCOMs
//--------------------------------
@@ -853,7 +865,7 @@ void loadScomSection(ifInfo_t & io_ifInfo,
uint16_t l_idxId = 0;
ifRead(io_ifInfo, &l_idxId, sizeof(uint16_t));
io_ifData.dataArrayIdxId->push_back(static_cast<uint64_t>(l_idxId));
- FAPI_DBG("loadScomSection: array index id %u",
+ FAPI_DBG("loadScomSection: array index id 0x%02x",
io_ifData.dataArrayIdxId->back());
}
}
@@ -1188,6 +1200,10 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData)
if (l_goToNextRow)
{
FAPI_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;
}
@@ -1221,6 +1237,11 @@ fapi::ReturnCode executeScoms(ifData_t & i_ifData)
FAPI_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
{
@@ -1335,6 +1356,13 @@ fapi::ReturnCode writeScom(const ifData_t & i_ifData, const uint32_t i_scomNum,
// Remove the array index id(s)
i_ifData.dataArrayIdxId->erase(i_ifData.dataArrayIdxId->begin(),
i_ifData.dataArrayIdxId->begin() + l_attrDimension);
+
+ #ifdef HWPEXECINITFILE_DEBUG
+ for (size_t i = 0; i < i_ifData.dataArrayIdxId->size(); i++)
+ {
+ FAPI_DBG ("dataArrayIdxId[%u] 0x%02x", i, i_ifData.dataArrayIdxId->at(i));
+ }
+ #endif
}
}
else
@@ -1489,6 +1517,52 @@ fapi::ReturnCode writeScom(const ifData_t & i_ifData, const uint32_t i_scomNum,
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_TYPE_MASK) == 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;
+ 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)
+ {
+ FAPI_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_DEBUG
+ for (size_t i = 0; i < i_ifData.dataArrayIdxId->size(); i++)
+ {
+ FAPI_DBG ("dataArrayIdxId[%u] 0x%02x", i, i_ifData.dataArrayIdxId->at(i));
+ }
+ #endif
+
+ return;
+}
+
//******************************************************************************
// RPN Calculator functions
//******************************************************************************
@@ -1500,7 +1574,7 @@ fapi::ReturnCode writeScom(const ifData_t & i_ifData, const uint32_t i_scomNum,
*/
void rpnPush(rpnStack_t * io_rpnStack, uint64_t i_val)
{
- FAPI_DBG("fapiHwpExecInitFile: rpnPush");
+ FAPI_DBG("fapiHwpExecInitFile: rpnPush 0x%llX", i_val);
io_rpnStack->push_back(i_val);
}
@@ -1706,7 +1780,7 @@ uint64_t rpnBinaryOp(IfRpnOp i_op, uint64_t i_val1, uint64_t i_val2,
fapi::ReturnCode rpnDoPush(ifData_t & io_ifData, const uint16_t i_id,
uint32_t & io_any, const uint16_t i_arrayIndexIds[MAX_ATTRIBUTE_ARRAY_DIMENSION])
{
- FAPI_DBG(">> HwpInitFile: rpnDoPush: id 0x%X", i_id);
+ FAPI_DBG(">> fapiHwpExecInitFile: rpnDoPush: id 0x%X", i_id);
fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS;
uint64_t l_val = 0;
@@ -1769,7 +1843,7 @@ fapi::ReturnCode rpnDoPush(ifData_t & io_ifData, const uint16_t i_id,
} while(0);
- FAPI_DBG("<< HwpInitFile: rpnDoPush");
+ FAPI_DBG("<< fapiHwpExecInitFile: rpnDoPush");
return l_rc;
}
diff --git a/src/usr/hwpf/hwp/initfiles/sample.initfile b/src/usr/hwpf/hwp/initfiles/sample.initfile
index e5f51585b..36733aa50 100755
--- a/src/usr/hwpf/hwp/initfiles/sample.initfile
+++ b/src/usr/hwpf/hwp/initfiles/sample.initfile
@@ -46,12 +46,14 @@ scom 0x0000000013030007 {
}
#--******************************************************************************
-#-- Basic SCOM with Array In Middle & Scom Data of Array Attribute Type
+#-- SCOM with Address and Data of Array Type, Range of Index, Bit Support
#--******************************************************************************
scom 0x000000000006002(B,C) {
- scom_data ;
- SYS.ATTR_SCRATCH_UINT8_ARRAY_1[2] ;
+ bits, scom_data , expr;
+ 0:7, SYS.ATTR_SCRATCH_UINT8_ARRAY_1[2], SYS.ATTR_SCRATCH_UINT8_ARRAY_1[2,31] > SYS.ATTR_SCRATCH_UINT8_1;
+ 24:31, SYS.ATTR_SCRATCH_UINT8_ARRAY_1[2,31], SYS.ATTR_SCRATCH_UINT8_1 == SYS.ATTR_SCRATCH_UINT8_ARRAY_1[3,7];
+ 32:39, SYS.ATTR_SCRATCH_UINT8_ARRAY_2[0..1][1,2][2,3], SYS.ATTR_SCRATCH_UINT8_ARRAY_1[0,17] < SYS.ATTR_SCRATCH_UINT8_ARRAY_1[1,18];
}
#--******************************************************************************
@@ -85,85 +87,78 @@ scom 0x000000000006800c {
#--******************************************************************************
#-- Basic SCOM with bits
#--******************************************************************************
-#@todo
-#@VBU workaround - Disable sample addresses
-#All SCR reg addresses below are only supported from chip release 052 and beyond.
-#Release 051, which is used by current VBU model, contain different addresses for
-#these registers.
-#Disable them for now, needs to re-enable them when VBU upgrade to use chip release 052
-
-#scom 0x0000000013013283 {
-# bits , scom_data ;
-# 0:11 , 0b001111001001 ;
-# 12 , 0b1 ;
-# 13 , 0b1 ;
-# 14:59, 0b0000001100000110010000000000010000010010000000 ;
-#}
+scom 0x0000000013013283 {
+ bits , scom_data ;
+ 0:11 , 0b001111001001 ;
+ 12 , 0b1 ;
+ 13 , 0b1 ;
+ 14:59, 0b0000001100000110010000000000010000010010000000 ;
+}
#--******************************************************************************
#-- Complext SCOM with Bit Support, define, and attributes
#--******************************************************************************
-#scom 0x0000000013013284 {
-# bits , scom_data, expr ;
-# 0:11 , 0b001111001001, any ;
-# 12 , 0b1, def_equal_test ;
-# 12 , 0b0, def_not_equal_test ;
-# 13 , 0b1, SYS.ATTR_SCRATCH_UINT8_1 > SYS.ATTR_SCRATCH_UINT8_2 ;
-# 14:59, 0b0000001100000110010000000000010000010010000000, SYS.ATTR_SCRATCH_UINT64_2 == ENUM_ATTR_SCRATCH_UINT64_2_VAL_C;
-#}
+scom 0x0000000013013284 {
+ bits , scom_data, expr ;
+ 0:11 , 0b001111001001, any ;
+ 12 , 0b1, def_equal_test ;
+ 12 , 0b0, def_not_equal_test ;
+ 13 , 0b1, SYS.ATTR_SCRATCH_UINT8_1 > SYS.ATTR_SCRATCH_UINT8_2 ;
+ 14:59, 0b0000001100000110010000000000010000010010000000, SYS.ATTR_SCRATCH_UINT64_2 == ENUM_ATTR_SCRATCH_UINT64_2_VAL_C;
+}
#--******************************************************************************
#-- Complex SCOM with Bit Support, and logical operators
#--******************************************************************************
-#scom 0x0000000013013285 {
-# bits , scom_data, expr ;
-# 12 , 0b1, def_equal_test && def_not_equal_test ;
-# 12 , 0b0, def_equal_test || def_not_equal_test ;
-# 14 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 < SYS.ATTR_SCRATCH_UINT32_2 ;
-# 15 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 > SYS.ATTR_SCRATCH_UINT32_2 ;
-# 16 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 >= SYS.ATTR_SCRATCH_UINT32_2 ;
-# 17 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 <= SYS.ATTR_SCRATCH_UINT32_2 ;
-# 18 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 == SYS.ATTR_SCRATCH_UINT32_2 ;
-# 19 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 != SYS.ATTR_SCRATCH_UINT32_2 ;
-# 20 , 0b1, (SYS.ATTR_SCRATCH_UINT32_1 + SYS.ATTR_SCRATCH_UINT32_2) == 4 ;
-# 21:59, 0b000000110000011001000000000001000001001, SYS.ATTR_SCRATCH_UINT8_1 == SYS.ATTR_SCRATCH_UINT8_2 ;
-#}
+scom 0x0000000013013285 {
+ bits , scom_data, expr ;
+ 12 , 0b1, def_equal_test && def_not_equal_test ;
+ 12 , 0b0, def_equal_test || def_not_equal_test ;
+ 14 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 < SYS.ATTR_SCRATCH_UINT32_2 ;
+ 15 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 > SYS.ATTR_SCRATCH_UINT32_2 ;
+ 16 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 >= SYS.ATTR_SCRATCH_UINT32_2 ;
+ 17 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 <= SYS.ATTR_SCRATCH_UINT32_2 ;
+ 18 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 == SYS.ATTR_SCRATCH_UINT32_2 ;
+ 19 , 0b1, SYS.ATTR_SCRATCH_UINT32_1 != SYS.ATTR_SCRATCH_UINT32_2 ;
+ 20 , 0b1, (SYS.ATTR_SCRATCH_UINT32_1 + SYS.ATTR_SCRATCH_UINT32_2) == 4 ;
+ 21:59, 0b000000110000011001000000000001000001001, SYS.ATTR_SCRATCH_UINT8_1 == SYS.ATTR_SCRATCH_UINT8_2 ;
+}
#--******************************************************************************
#-- SCOM with 'ec' column - Use scratch for now since all attributes work
#--******************************************************************************
-#scom 0x0000000013013286 {
-# scom_data, SYS.ATTR_SCRATCH_UINT32_1, SYS.ATTR_SCRATCH_UINT32_2 ;
-# 0x0000000000000192, 1, ENUM_ATTR_SCRATCH_UINT64_ARRAY_2_VAL_B ;
-#}
+scom 0x0000000013013286 {
+ scom_data, SYS.ATTR_SCRATCH_UINT32_1, SYS.ATTR_SCRATCH_UINT32_2 ;
+ 0x0000000000000192, 1, ENUM_ATTR_SCRATCH_UINT64_ARRAY_2_VAL_B ;
+}
#--******************************************************************************
#-- Basic SCOM with an array
#--******************************************************************************
-#scom 0x0000000013013287 {
-# scom_data, expr ;
-# 0x0000000000000182, SYS.ATTR_SCRATCH_UINT8_ARRAY_1[2] == SYS.ATTR_SCRATCH_UINT8_1 ;
-#}
+scom 0x0000000013013287 {
+ scom_data, expr ;
+ 0x0000000000000182, SYS.ATTR_SCRATCH_UINT8_ARRAY_1[2] == SYS.ATTR_SCRATCH_UINT8_1 ;
+}
#--******************************************************************************
#-- SCOM with 'ec' & expr column - Use scratch for now since all attributes work
#--******************************************************************************
-#scom 0x0000000013013288 {
-# scom_data, SYS.ATTR_SCRATCH_UINT32_1 expr;
-# 0x0000000000000192, 3, SYS.ATTR_SCRATCH_UINT8_ARRAY_2[1][2][3] == 0x00000000000000BE;
-#}
+scom 0x0000000013013288 {
+ 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
#--******************************************************************************
-#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;
-#}
+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;
+}
#--******************************************************************************
#-- Basic SCOM with Multiple Arrays/Address Ranges
diff --git a/src/usr/hwpf/ifcompiler/initCompiler.lex b/src/usr/hwpf/ifcompiler/initCompiler.lex
index be59d834d..e1c2116ec 100755
--- a/src/usr/hwpf/ifcompiler/initCompiler.lex
+++ b/src/usr/hwpf/ifcompiler/initCompiler.lex
@@ -26,6 +26,7 @@
// camvanng 11/08/11 Added support for attribute enums
// camvanng 11/16/11 Support system & target attributes
// camvanng 12/12/11 Support multiple address ranges within a SCOM address
+// camvanng 01/20/12 Support for using a range of indexes for array attributes
// End Change Log *********************************************************************************/
/**
* @file initCompiler.lex
@@ -75,8 +76,8 @@ extern int yyline;
NEWLINE \n
FILENAME [A-Za-z][A-Za-z0-9_\.]*
-ID [A-Za-z][A-Za-z0-9_]*
-ID2 [A-Za-z][A-Za-z0-9_]*
+ID [A-Za-z][A-Za-z0-9_]*
+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
@@ -186,7 +187,7 @@ scom { BEGIN(scomop); oss.str(""); return INIT_SCOM; }
<scomcolname>{COMMENT} ++yyline;
<scomcolname>\n ++yyline;
-<scomcolname>{ID} {
+<scomcolname>{ID2} {
g_colstream.push_back(new std::ostringstream());
*(g_colstream.back()) << yytext;
}
@@ -195,7 +196,7 @@ scom { BEGIN(scomop); oss.str(""); return INIT_SCOM; }
<scomrow>{COMMENT} ++yyline;
<scomrow>{NEWLINE} ++yyline;
-<scomrow>[^,;\n#\{\}]+ push_col(yytext);
+<scomrow>([^,;\n#\{\}]+{ID2}*)+ push_col(yytext);
<scomrow>[,] ++g_scomcol;
<scomrow>[;] g_scomcol = 0;
<scomrow>[\}] {
@@ -255,7 +256,7 @@ END_INITFILE return INIT_ENDINITFILE;
<*>[\(] { ++g_paren_level; return yytext[0]; }
<*>[\)] { --g_paren_level; return yytext[0]; }
-<*>\[{MULTI_DIGIT}\] { yylval.str_ptr = new std::string(yytext); return ATTRIBUTE_INDEX; }
+<*>\[({MULTI_DIGIT}[,.]*)+\] { yylval.str_ptr = new std::string(yytext); return ATTRIBUTE_INDEX; }
<*>[\[\]\{\},:] {g_equation = false; return yytext[0]; }
diff --git a/src/usr/hwpf/ifcompiler/initCompiler.y b/src/usr/hwpf/ifcompiler/initCompiler.y
index 1bbc43220..168ec5628 100755
--- a/src/usr/hwpf/ifcompiler/initCompiler.y
+++ b/src/usr/hwpf/ifcompiler/initCompiler.y
@@ -24,7 +24,8 @@
// andrewg 09/19/11 Updates based on review
// camvanng 11/08/11 Added support for attribute enums
// andrewg 11/09/11 Refactor to use common include with hwp framework.
-// camvanng 12/12/11 Support multiple address ranges within a SCOM address
+// camvanng 12/12/11 Support multiple address ranges within a SCOM address
+// camvanng 01/20/12 Support for using a range indexes for array attributes
// End Change Log *********************************************************************************
/**
* @file initCompiler.y
@@ -110,7 +111,6 @@ int scom;
/* top is lowest precedent - done last */
-%left ATTRIBUTE_INDEX /* irrelevant precedence, but needed for clean compile */
%left INIT_LOGIC_OR
%left INIT_LOGIC_AND
%left '|' /* bitwise OR */
@@ -122,6 +122,7 @@ int scom;
%left '-' '+'
%left '*' '/' '%'
%right '!' '~' /* logic negation bitwise complement*/
+%left ATTRIBUTE_INDEX /* highest precedence */
/* bottom is highest precedent - done first */
@@ -191,12 +192,11 @@ scombody: scombodyline ';' {}
scombodyline: INIT_SCOMD ',' scomdrows {}
| INIT_BITS ',' bitsrows {}
| INIT_EXPR ',' exprrows { init::dbg << "Add col EXPR" << endl; current_scom->add_col("EXPR"); }
- | INIT_ID ',' idrows {
+ | INIT_ID ',' idrows {
current_scom->add_col(*($1));
init::dbg << "Add col " << *($1) << endl;
delete $1;
}
-
;
@@ -264,7 +264,7 @@ expr: INIT_INTEGER { $$= new init::Rpn($1,yyscomlist->get_s
| 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()); }
- | expr ATTRIBUTE_INDEX { $1->push_array_index(*($2));}
+ | expr ATTRIBUTE_INDEX { $1->push_array_index(*($2)); delete $2; }
| expr INIT_LOGIC_OR expr { $$ = $1->push_merge($3,OR); }
| expr INIT_LOGIC_AND expr { $$ = $1->push_merge($3,AND); }
| expr INIT_EQ expr { $$ = $1->push_merge($3,EQ); }
diff --git a/src/usr/hwpf/ifcompiler/initRpn.C b/src/usr/hwpf/ifcompiler/initRpn.C
index 2c8c0dc90..50b197e7d 100755
--- a/src/usr/hwpf/ifcompiler/initRpn.C
+++ b/src/usr/hwpf/ifcompiler/initRpn.C
@@ -24,6 +24,7 @@
// camvanng 11/08/11 Added support for attribute enums
// andrewg 11/09/11 Multi-dimensional array and move to common fapi include
// camvanng 01/06/12 Support for writing an attribute to a SCOM register
+// camvanng 01/20/12 Support for using a range of indexes for array attributes
// End Change Log *********************************************************************************
/**
@@ -40,6 +41,8 @@
#include <stdexcept>
#include <fapiHwpInitFileInclude.H> // Requires file from hwpf
+extern void yyerror(const char * s);
+
using namespace init;
const char * OP_TXT[] =
@@ -71,7 +74,7 @@ std::string Rpn::cv_empty_str;
//-------------------------------------------------------------------------------------------------
Rpn::Rpn(uint32_t i_uint,Symbols * symbols) : iv_symbols(symbols)
-{ push_int(i_uint);}
+{ push_int(i_uint); }
//-------------------------------------------------------------------------------------------------
@@ -205,13 +208,77 @@ void Rpn::push_array_index(std::string &i_array_idx)
string l_idx = i_array_idx;
// strip of leading "[" and last "]"
l_idx = l_idx.substr(1,(l_idx.length() - 2));
- uint32_t l_array_val = atoi(l_idx.c_str());
+ uint32_t l_num_idx = 0;
+ std::vector<string> l_idxstr;
- uint32_t rpn_id = iv_symbols->find_numeric_array_lit(l_array_val,4);
- iv_rpnstack.push_back(rpn_id);
+ // find index strings in comma separated list and save in vector
+ size_t l_pos = 0;
+ l_pos = l_idx.find(',');
+ while(l_pos != string::npos)
+ {
+ l_idxstr.push_back(l_idx.substr(0, l_pos));
+ l_idx = l_idx.substr(l_pos+1);
+ l_pos = l_idx.find(',');
+ }
+
+ // Push back the original idx string or the last string in the list
+ l_idxstr.push_back(l_idx);
+
+ uint32_t l_array_val = 0, l_array_val2 = 0;
+ uint32_t rpn_id = 0;
+ for (size_t i = 0; i < l_idxstr.size(); i++)
+ {
+ //Is it a range?
+ l_pos = l_idxstr.at(i).find("..");
+ if (l_pos != string::npos)
+ {
+ l_array_val = atoi(l_idxstr.at(i).substr(0,l_pos).c_str());
+ l_array_val2 = atoi(l_idxstr.at(i).substr(l_pos + 2).c_str());
+ //printf("I>Rpn::push_array_index: %u..%u\n", l_array_val, l_array_val2);
+ if (l_array_val >= l_array_val2)
+ {
+ std::ostringstream oss;
+ oss << "Invalid attribute array index range: " << l_idxstr.at(i);
+ yyerror(oss.str().c_str());
+ }
- // printf("Array Index: %s decimal:%u rpn_id:0x%8X\n",l_idx.c_str(),l_array_val,rpn_id);
+ for (uint32_t val = l_array_val; val <= l_array_val2; val++)
+ {
+ l_num_idx++;
+ rpn_id = iv_symbols->find_numeric_array_lit(val,4);
+ iv_rpnstack.push_back(rpn_id);
+ //printf("Array Index: %u rpn_id:0x%8X\n", val, rpn_id);
+ }
+ }
+ else
+ {
+ l_num_idx++;
+ l_array_val = atoi(l_idxstr.at(i).c_str());
+ rpn_id = iv_symbols->find_numeric_array_lit(l_array_val,4);
+ iv_rpnstack.push_back(rpn_id);
+
+ //printf("Array Index: %s decimal:%u rpn_id:0x%8X\n",l_idxstr.at(i).c_str(),l_array_val,rpn_id);
+ }
+ }
+
+ // Save the index range for this rpn
+ if (iv_array_idx_range.size())
+ {
+ if (iv_array_idx_range.back() != l_num_idx)
+ {
+ std::ostringstream oss;
+ oss << "Array attribute has different range of index for each dimension: "
+ << i_array_idx << " iv_array_idx_range: " << iv_array_idx_range.back()
+ << " l_num_idx: " << l_num_idx;
+ yyerror(oss.str().c_str());
+ }
+ }
+ else
+ {
+ iv_array_idx_range.push_back(l_num_idx);
+ }
+ //printf("Rpn::push_array_index: %s, iv_array_idx_range.size %u\n", i_array_idx.c_str(), iv_array_idx_range.size());
}
//-------------------------------------------------------------------------------------------------
@@ -284,11 +351,13 @@ Rpn * Rpn::push_merge(Rpn * i_rpn, IfRpnOp op)
if(this->isTrue())
{
iv_rpnstack.clear();
+ iv_array_idx_range.clear();
return merge(i_rpn); // merge deletes i_rpn
}
if(i_rpn->isFalse() || this->isFalse())
{
iv_rpnstack.clear();
+ iv_array_idx_range.clear();
delete i_rpn;
push_op(FALSE_OP);
return result;
@@ -304,11 +373,13 @@ Rpn * Rpn::push_merge(Rpn * i_rpn, IfRpnOp op)
if(this->isFalse())
{
iv_rpnstack.clear();
+ iv_array_idx_range.clear();
return merge(i_rpn); // merge deletes i_rpn
}
if(i_rpn->isTrue() || this->isTrue())
{
iv_rpnstack.clear();
+ iv_array_idx_range.clear();
delete i_rpn;
push_op(TRUE_OP);
return result;
@@ -327,6 +398,7 @@ Rpn * Rpn::push_merge(Rpn * i_rpn, IfRpnOp op)
if((op == EQ && *i_rpn == r2) || (op == NE && *i_rpn == r3))
{
iv_rpnstack.clear();
+ iv_array_idx_range.clear();
push_op(TRUE_OP);
delete i_rpn;
return result;
@@ -334,6 +406,7 @@ Rpn * Rpn::push_merge(Rpn * i_rpn, IfRpnOp op)
if((op == EQ && *i_rpn == r3) || (op == NE && *i_rpn == r2))
{
iv_rpnstack.clear();
+ iv_array_idx_range.clear();
push_op(FALSE_OP);
delete i_rpn;
return result;
@@ -467,6 +540,10 @@ Rpn * Rpn::push_merge(Rpn * i_rpn, IfRpnOp op)
//dg003a end
iv_rpnstack.insert(iv_rpnstack.end(), i_rpn->iv_rpnstack.begin(), i_rpn->iv_rpnstack.end());
+ for (size_t i = 0; i < i_rpn->iv_array_idx_range.size(); i++)
+ {
+ iv_array_idx_range.push_back(i_rpn->iv_array_idx_range.at(i));
+ }
result = push_op(op);
delete i_rpn;
@@ -479,6 +556,10 @@ Rpn * Rpn::push_merge(Rpn * i_rpn, IfRpnOp op)
Rpn * Rpn::merge(Rpn * i_rpn)
{
iv_rpnstack.insert(iv_rpnstack.end(), i_rpn->iv_rpnstack.begin(), i_rpn->iv_rpnstack.end());
+ for (size_t i = 0; i < i_rpn->iv_array_idx_range.size(); i++)
+ {
+ iv_array_idx_range.push_back(i_rpn->iv_array_idx_range.at(i));
+ }
delete i_rpn;
return this;
}
@@ -492,6 +573,7 @@ void Rpn::bin_read(BINSEQ::const_iterator & bli, Symbols * symbols)
if(symbols) iv_symbols = symbols;
iv_rpnstack.clear();
+ iv_array_idx_range.clear();
while(size)
{
@@ -568,6 +650,10 @@ BINSEQ::const_iterator Rpn::bin_read_one_op(BINSEQ::const_iterator & bli, Symbol
void Rpn::append(const Rpn & i_rpn)
{
iv_rpnstack.insert(iv_rpnstack.end(), i_rpn.iv_rpnstack.begin(), i_rpn.iv_rpnstack.end());
+ for (size_t i = 0; i < i_rpn.iv_array_idx_range.size(); i++)
+ {
+ iv_array_idx_range.push_back(i_rpn.iv_array_idx_range.at(i));
+ }
}
//-------------------------------------------------------------------------------------------------
@@ -692,11 +778,13 @@ std::string Rpn::listing(const char * i_desc, const std::string & spyname, bool
//-------------------------------------------------------------------------------------------------
-void Rpn::bin_str(BINSEQ & o_blist, bool i_prepend_count) // binary version to write to file
+// binary version to write to file
+void Rpn::bin_str(BINSEQ & o_blist, uint32_t i_num_addrs, uint32_t i_addr_num, bool i_prepend_count)
{
BINSEQ blist;
uint32_t count = 0;
-
+ uint32_t l_num_idx = 0; //number of array index in the range
+ uint32_t l_num_array_attrs = 0;
for(RPNSTACK::iterator i = iv_rpnstack.begin(); i != iv_rpnstack.end(); ++i)
{
@@ -713,24 +801,68 @@ void Rpn::bin_str(BINSEQ & o_blist, bool i_prepend_count) // binary version to
++count;
blist.push_back((uint8_t)(v >> 8));
}
+ l_num_idx = 0; //reset
break;
case SYMBOL: tag = iv_symbols->get_tag(v);
blist.push_back((uint8_t)(tag >> 8));
blist.push_back((uint8_t) tag);
count += 2;
+ l_num_idx = 0; //reset
break;
case NUMBER: tag = iv_symbols->get_numeric_tag(v);
blist.push_back((uint8_t)(tag >> 8));
blist.push_back((uint8_t) tag);
count += 2;
+ l_num_idx = 0; //reset
break;
case ARRAY_INDEX:
+ //Check if this rpn has any array attribute with a range of index specified
+ if ((0 == l_num_idx) && iv_array_idx_range.size())
+ {
+ if (iv_array_idx_range.size() > l_num_array_attrs)
+ {
+ l_num_idx = iv_array_idx_range.at(l_num_array_attrs);
+ l_num_array_attrs++;
+
+ //Error if index range is not equal to address range
+ if ((1 < l_num_idx) && (l_num_idx != i_num_addrs))
+ {
+ std::ostringstream errss;
+ errss << "Rpn::bin_str: Index range " << l_num_idx
+ << " != Address range " << i_num_addrs << endl;
+ throw std::invalid_argument(errss.str());
+ }
+ }
+ }
+
+ if (0 == l_num_idx)
+ {
+ //Error if no index range specified
+ std::ostringstream errss;
+ errss << "Rpn::bin_str: No index range specified for array attribute\n";
+ throw std::invalid_argument(errss.str());
+ }
+
+ if (1 < l_num_idx)
+ {
+ v = *(i + i_addr_num);
+ if ((v & TYPE_MASK) != ARRAY_INDEX)
+ {
+ std::ostringstream errss;
+ errss << "Rpn::bin_str: Rpn is not array index " << endl;
+ throw std::invalid_argument(errss.str());
+ }
+ }
tag = iv_symbols->get_numeric_array_tag(v);
blist.push_back((uint8_t)(tag >> 8));
blist.push_back((uint8_t) tag);
count += 2;
+ if (1 < l_num_idx) //Skip the other indexes in the range
+ {
+ i += l_num_idx - 1;
+ }
break;
default:
diff --git a/src/usr/hwpf/ifcompiler/initRpn.H b/src/usr/hwpf/ifcompiler/initRpn.H
index 5eba73c62..1965603b2 100755
--- a/src/usr/hwpf/ifcompiler/initRpn.H
+++ b/src/usr/hwpf/ifcompiler/initRpn.H
@@ -24,8 +24,9 @@
// dg002 SW039868 dgilbert 10/15/10 Add support to filter unneeded inits by EC
// dg003 SW047506 dgilbert 12/09/10 SERIES filtering
// andrewg 09/19/11 Updates based on review
-// camvanng 11/08/11 Added support for attribute enums
+// 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
// End Change Log *********************************************************************************
/**
@@ -178,12 +179,15 @@ namespace init
* @brief Push all RPN stack entries of object as numerical values onto input blist
*
* @param blist Binary string of RPN to write to file
+ * @param i_num_addrs number of Scom addresses for this Scom
+ * @param i_addr_num the nth addr with the range of Scom addresses
* @param i_prepend_count Flag to indicate prepend rpn count to binary string
* @PRE should never be called until all symbols in the initfile have been
* "looked up" or the binary tags for Symbols and Numbers may not be accurate
* @return void
*/
- void bin_str(BINSEQ & blist, bool i_prepend_count = false);
+ void bin_str(BINSEQ & blist, uint32_t i_num_addrs, uint32_t i_addr_num,
+ bool i_prepend_count = false);
/**
* Read binary sequence to recreate this Rpn sequence
@@ -262,9 +266,11 @@ namespace init
private: // types and data
typedef std::vector<uint32_t> RPNSTACK;
+ typedef std::vector<uint32_t> INDEXRANGE;
RPNSTACK iv_rpnstack; ///< Rpn sequence
Symbols * iv_symbols; ///< Symbol table to use
+ INDEXRANGE iv_array_idx_range; ///< indicates range of indexes for an array attribute
diff --git a/src/usr/hwpf/ifcompiler/initScom.C b/src/usr/hwpf/ifcompiler/initScom.C
index 583c082e1..a8cf2dd9d 100755
--- a/src/usr/hwpf/ifcompiler/initScom.C
+++ b/src/usr/hwpf/ifcompiler/initScom.C
@@ -28,6 +28,7 @@
// camvanng 12/12/11 Support multiple address ranges within a SCOM address
// Use strtoull vs strtoul for 32-bit platforms
// camvanng 12/15/11 Support for multiple duplicate addresses setting different bits
+// camvanng 01/20/12 Support for using a range of indexes for array attributes
// End Change Log *********************************************************************************
/**
@@ -440,6 +441,7 @@ uint32_t Scom::bin_listing(BINSEQ & blist)
{
set<RANGE> ranges;
uint32_t scom_count = 0;
+ uint32_t addr_num = 0;
row_optimize(); // delete any rows that are unconditionally false. + merge rows
@@ -447,7 +449,7 @@ uint32_t Scom::bin_listing(BINSEQ & blist)
SCOM_ADDR::iterator i = iv_scom_addr.begin();
- for(; i != iv_scom_addr.end(); ++i)
+ for(; i != iv_scom_addr.end(); ++i, ++addr_num)
{
//printf("scom address:%s\n",(*i).c_str());
if(ranges.size())
@@ -461,16 +463,16 @@ uint32_t Scom::bin_listing(BINSEQ & blist)
// - Recreate the spy from the bytecode
// - Compile the recreated spy back into bytecode.
BINSEQ temp;
- bin_list_one(temp,strtoull((*i).c_str(),NULL,16), *r);
+ bin_list_one(temp,strtoull((*i).c_str(),NULL,16), addr_num, *r);
BINSEQ::const_iterator bi = temp.begin();
Scom s(bi,iv_symbols);
- s.bin_list_one(blist,strtoull((*i).c_str(),NULL,16), RANGE(1,0));
+ s.bin_list_one(blist,strtoull((*i).c_str(),NULL,16), addr_num, RANGE(1,0));
}
}
else
{
++scom_count;
- bin_list_one(blist,strtoull((*i).c_str(),NULL,16), RANGE(1,0));
+ bin_list_one(blist,strtoull((*i).c_str(),NULL,16), addr_num, RANGE(1,0));
}
}
@@ -479,9 +481,10 @@ uint32_t Scom::bin_listing(BINSEQ & blist)
//-------------------------------------------------------------------------------------------------
-void Scom::bin_list_one(BINSEQ & blist,uint64_t i_addr, RANGE range)
+void Scom::bin_list_one(BINSEQ & blist,uint64_t i_addr, uint32_t i_addr_num, RANGE range)
{
+ uint32_t numaddrs = iv_scom_addr.size(); //Number of Scom addresses for this Scom
uint32_t numcols = iv_col_vars.size() | (iv_when & SUBTYPE_MASK); // WHEN subtype goes in numcols
// No range support
@@ -553,7 +556,7 @@ void Scom::bin_list_one(BINSEQ & blist,uint64_t i_addr, RANGE range)
//Rpn::set32(blist,(uint32_t)iv_address);
Rpn *l_scom_addr = new init::Rpn(i_addr,yyscomlist->get_symbols());
- l_scom_addr->bin_str(blist,false);
+ l_scom_addr->bin_str(blist,numaddrs,i_addr_num,false);
delete l_scom_addr;
@@ -568,7 +571,7 @@ void Scom::bin_list_one(BINSEQ & blist,uint64_t i_addr, RANGE range)
{
if ((*r) == range)
{
- i->bin_str(blist,false);
+ i->bin_str(blist,numaddrs,i_addr_num,false);
}
}
}
@@ -576,14 +579,14 @@ void Scom::bin_list_one(BINSEQ & blist,uint64_t i_addr, RANGE range)
{
for(RPN_LIST::iterator i = iv_scom_rpn.begin(); i != iv_scom_rpn.end(); ++i)
{
- i->bin_str(blist,false);
+ i->bin_str(blist,numaddrs,i_addr_num,false);
}
}
// list the column names that are really CINI VARS
for(RPN_LIST::iterator i = iv_col_vars.begin(); i != iv_col_vars.end(); ++i)
{
- i->bin_str(blist,false); // false means don't prepend an RPN byte count to the binary rpn appended.
+ i->bin_str(blist,numaddrs,i_addr_num,false); // false means don't prepend an RPN byte count to the binary rpn appended.
//uint16_t tag = iv_symbols->get_tag(*i);
//blist.push_back((uint8_t)(tag >> 8));
//blist.push_back((uint8_t) tag);
@@ -605,7 +608,7 @@ void Scom::bin_list_one(BINSEQ & blist,uint64_t i_addr, RANGE range)
{
rpn.append(i->at(n));
}
- rpn.bin_str(blist,true);
+ rpn.bin_str(blist,numaddrs,i_addr_num,true);
}
}
}
@@ -1050,7 +1053,7 @@ void ScomList::compile(BINSEQ & bin_seq)
}
else // syntax version already validated to be 1 or 2 - so if we get here it was never set.
{
- throw range_error("ERROR: No sytax version specified!");
+ throw range_error("ERROR: No syntax version specified!");
}
stats << '*' << setw(20) << "Syntax Version:" << setw(6) << iv_syntax_version << endl;
diff --git a/src/usr/hwpf/ifcompiler/initScom.H b/src/usr/hwpf/ifcompiler/initScom.H
index eebbb2513..efdd0d235 100755
--- a/src/usr/hwpf/ifcompiler/initScom.H
+++ b/src/usr/hwpf/ifcompiler/initScom.H
@@ -28,6 +28,7 @@
// camvanng 12/12/11 Support multiple address ranges within a SCOM address
// Use strtoull vs strtoul for 32-bit platforms
// camvanng 12/15/11 Support for multiple duplicate addresses setting different bits
+// camvanng 01/20/12 Support for using a range of indexes for array attributes
// End Change Log *********************************************************************************
/**
@@ -179,7 +180,7 @@ namespace init
private: // functions
string list_one(RANGE range);
- void bin_list_one(BINSEQ & blist,uint64_t i_addr, RANGE range);
+ void bin_list_one(BINSEQ & blist,uint64_t i_addr, uint32_t i_addr_num, RANGE range);
/**
* Optimize the row RPNs
diff --git a/src/usr/hwpf/ifcompiler/initSymbols.C b/src/usr/hwpf/ifcompiler/initSymbols.C
index 156d021dc..68e18f01c 100755
--- a/src/usr/hwpf/ifcompiler/initSymbols.C
+++ b/src/usr/hwpf/ifcompiler/initSymbols.C
@@ -177,7 +177,7 @@ Symbols::Symbols(FILELIST & i_filenames)
else
{
attr_enum_stream >> tmp;
- value = strtoll(tmp.c_str(), NULL, 0);
+ value = strtoull(tmp.c_str(), NULL, 0);
}
}
}
diff --git a/src/usr/hwpf/test/hwpftest.H b/src/usr/hwpf/test/hwpftest.H
index c087ed0ca..24b24db28 100644
--- a/src/usr/hwpf/test/hwpftest.H
+++ b/src/usr/hwpf/test/hwpftest.H
@@ -286,36 +286,29 @@ public:
//If the initfile changes, this data will also need to be changed.
ifScom_t l_ifScomData[] =
{
- {0x000000000006002b, 0, 0x0000000000000001},
- {0x000000000006002c, 0, 0x0000000000000001},
+ {0x000000000006002b, 0, 0x0000000000000000 |
+ (0x00000000000000C4ll << (64 - (32 + 8)))},
+ {0x000000000006002c, 0, (0x0000000000000001ll << (64 - 8)) |
+ (0x0000000000000008ll << (64 - (24 + 8)))},
{0x000000000006800b, 0, 0},
{0x000000000006800c, 0, (0x8000000000000000 >> 0x17) |
(0x00000000000000BEll << (64 - (24 + 8))) |
0x0000000000000003},
{0x0000000013010002, 0, 0xAABBC00000000000},
{0x0000000013030007, 0, 0x00000CDE00000000},
- /*
- * @todo
- * @VBU workaround
- * All SCR reg addresses below are only supported from chip release
- * 052 and beyond. Release 051, which is used by current VBU model,
- * contain different addresses for these registers.
- * Disable them for now, needs to re-enable them when VBU upgrade
- * to use chip release 052
- {0x0000000013013283, 0, 0x3c90000000000000 |
- (0x8000000000000000 >> 0x0c) |
- (0x8000000000000000 >> 0x0d) |
- (0x0306400412000000 >> 0x0e)},
- {0x0000000013013284, 0, 0x3c90000000000000},
- {0x0000000013013285, 0, (0x8000000000000000 >> 0x0f) |
- (0x8000000000000000 >> 0x10) |
- (0x8000000000000000 >> 0x13) |
- (0x0306400412000000 >> 0x15) },
- {0x0000000013013286, 0, 0},
- {0x0000000013013287, 0, 0x0000000000000182},
- {0x0000000013013288, 0, 0x0000000000000192},
- {0x0000000013013289, 0, 0x8000000000000000 >> 0x17}
- */
+ {0x0000000013013283, 0, 0x3c90000000000000 |
+ (0x8000000000000000 >> 0x0c) |
+ (0x8000000000000000 >> 0x0d) |
+ (0x0306400412000000 >> 0x0e)},
+ {0x0000000013013284, 0, 0x3c90000000000000},
+ {0x0000000013013285, 0, (0x8000000000000000 >> 0x0f) |
+ (0x8000000000000000 >> 0x10) |
+ (0x8000000000000000 >> 0x13) |
+ (0x0306400412000000 >> 0x15) },
+ {0x0000000013013286, 0, 0},
+ {0x0000000013013287, 0, 0x0000000000000182},
+ {0x0000000013013288, 0, 0x0000000000000192},
+ {0x0000000013013289, 0, 0x8000000000000000 >> 0x17}
};
fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS;
@@ -355,7 +348,14 @@ public:
}
uint8_t l_uint8array1[32];
+ l_uint8array1[0] = 1;
+ l_uint8array1[1] = 4;
l_uint8array1[2] = 1;
+ l_uint8array1[3] = 2;
+ l_uint8array1[7] = 1;
+ l_uint8array1[17] = 6;
+ l_uint8array1[18] = 6;
+ l_uint8array1[31] = 8;
l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_1,
NULL, l_uint8array1);
if (l_rc != fapi::FAPI_RC_SUCCESS)
@@ -366,6 +366,7 @@ public:
}
uint8_t l_uint8array2[2][3][4];
+ l_uint8array2[0][1][2] = 0xC4;
l_uint8array2[1][2][3] = 0xBE;
l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_2,
NULL, l_uint8array2);
OpenPOWER on IntegriCloud