summaryrefslogtreecommitdiffstats
path: root/src/build/ifcompiler
diff options
context:
space:
mode:
authorCamVan Nguyen <ctnguyen@us.ibm.com>2011-11-10 13:22:16 -0600
committerA. Patrick Williams III <iawillia@us.ibm.com>2011-11-15 18:13:18 -0600
commit4d9344f1025ee77e24e88249dd3e32f3d4c9a3ba (patch)
treed3d41ed886b43bf0a0f955702d207b31c3050510 /src/build/ifcompiler
parent22b8b1dc178665eb32f923e47211f549b4d1913f (diff)
downloadtalos-hostboot-4d9344f1025ee77e24e88249dd3e32f3d4c9a3ba.tar.gz
talos-hostboot-4d9344f1025ee77e24e88249dd3e32f3d4c9a3ba.zip
Added initfile compiler support for attribute enums
Change-Id: I78a2a85831b545e7213e08a272fec482bd69cdf1 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/493 Tested-by: Jenkins Server Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com> Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/build/ifcompiler')
-rwxr-xr-xsrc/build/ifcompiler/initCompiler.lex8
-rwxr-xr-xsrc/build/ifcompiler/initCompiler.y5
-rwxr-xr-xsrc/build/ifcompiler/initRpn.C12
-rwxr-xr-xsrc/build/ifcompiler/initRpn.H10
-rwxr-xr-xsrc/build/ifcompiler/initSymbols.C77
-rwxr-xr-xsrc/build/ifcompiler/initSymbols.H12
6 files changed, 119 insertions, 5 deletions
diff --git a/src/build/ifcompiler/initCompiler.lex b/src/build/ifcompiler/initCompiler.lex
index 2361272f2..9abdaded3 100755
--- a/src/build/ifcompiler/initCompiler.lex
+++ b/src/build/ifcompiler/initCompiler.lex
@@ -23,6 +23,7 @@
// dg01 D766229 dgilbert 08/03/10 add check for hex/bin data > 64 bits
// dg02 SW058986 dgilbert 02/28/11 More noticeable fail for missing col headers
// andrewg 09/19/11 Updates based on review
+// camvanng 11/08/11 Added support for attribute enums
// End Change Log *********************************************************************************/
/**
* @file initCompiler.lex
@@ -202,16 +203,19 @@ bits { g_coltype = INIT_BITS; return INIT_BITS;}
expr { g_coltype = INIT_EXPR; return INIT_EXPR;}
scom_data { g_coltype = INIT_SCOMD; return INIT_SCOMD;}
- /*HEX and Binary nubers in the scombody can be up to 64bit,
+ /*HEX and Binary numbers in the scombody can be up to 64bit,
* decimal numbers will always fit in 32bit int */
{BINARY} { yylval.uint64 = bits2int(yytext); return INIT_INT64; }
-
<*>; { g_coltype = 0; return ';'; }
END_INITFILE return INIT_ENDINITFILE;
+<*>ENUM_{ID} {
+ yylval.str_ptr = new std::string(yytext); return ATTRIBUTE_ENUM;
+ }
+
<*>{ID} {
yylval.str_ptr = new std::string(yytext); return INIT_ID;
}
diff --git a/src/build/ifcompiler/initCompiler.y b/src/build/ifcompiler/initCompiler.y
index 672a2039e..4c86575d0 100755
--- a/src/build/ifcompiler/initCompiler.y
+++ b/src/build/ifcompiler/initCompiler.y
@@ -22,6 +22,7 @@
// D754106 dgilbert 06/14/10 Create
// D774126 dgilbert 09/30/10 Add ERROR: to yyerror message
// andrewg 09/19/11 Updates based on review
+// camvanng 11/08/11 Added support for attribute enums
// End Change Log *********************************************************************************
/**
* @file initCompiler.y
@@ -76,6 +77,7 @@ int scom;
%token <str_ptr> INIT_ID
%token <str_ptr> INIT_VERSIONS
%token <str_ptr> ATTRIBUTE_INDEX
+%token <str_ptr> ATTRIBUTE_ENUM
/* Define terminal symbols that don't have any associated data */
@@ -233,6 +235,7 @@ idrows: id_col { init::dbg << $1->listing(NULL); current_scom->add_row_
id_col: INIT_ID { $$ = new init::Rpn(*($1),yyscomlist->get_symbols()); $$->push_op(init::Rpn::EQ); delete $1; }
| INIT_INTEGER { $$ = new init::Rpn($1,yyscomlist->get_symbols()); $$->push_op(init::Rpn::EQ); }
| '{' num_list '}' { $$ = $2; $2->push_op(init::Rpn::LIST); $2->push_op(init::Rpn::EQ); }
+ | ATTRIBUTE_ENUM { $$ = new init::Rpn((yyscomlist->get_symbols())->get_attr_enum_val(*($1)),yyscomlist->get_symbols()); $$->push_op(init::Rpn::EQ); delete $1; }
;
@@ -241,6 +244,7 @@ num_list: INIT_INTEGER { $$ = new init::Rpn($1,yyscomlist->get_symbols());
| INIT_ID { $$ = new init::Rpn(*($1),yyscomlist->get_symbols()); }
| num_list ',' INIT_INTEGER { $$ = $1; $1->merge(new init::Rpn($3,yyscomlist->get_symbols())); }
| num_list ',' INIT_ID { $$ = $1; $1->merge(new init::Rpn(*($3),yyscomlist->get_symbols())); }
+ | ATTRIBUTE_ENUM { $$ = new init::Rpn((yyscomlist->get_symbols())->get_attr_enum_val(*($1)),yyscomlist->get_symbols()); }
;
@@ -255,6 +259,7 @@ define: INIT_DEFINE INIT_ID '=' expr ';'
/* expr should return an RPN string of some kind */
expr: 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()); }
| expr ATTRIBUTE_INDEX { $1->push_array_index(*($2)); }
| expr INIT_LOGIC_OR expr { $$ = $1->push_merge($3,init::Rpn::OR); }
diff --git a/src/build/ifcompiler/initRpn.C b/src/build/ifcompiler/initRpn.C
index bb0fcca1a..bd1b8b1a1 100755
--- a/src/build/ifcompiler/initRpn.C
+++ b/src/build/ifcompiler/initRpn.C
@@ -21,6 +21,7 @@
// dg003 SW047506 dgilbert 12/09/10 SERIES filtering
// andrewg 05/24/11 Port over for VPL/PgP
// andrewg 09/19/11 Updates based on review
+// camvanng 11/08/11 Added support for attribute enums
// End Change Log *********************************************************************************
/**
@@ -211,6 +212,17 @@ void Rpn::push_array_index(std::string &i_array_idx)
}
//-------------------------------------------------------------------------------------------------
+void Rpn::push_attr_enum(std::string &i_attr_enum)
+{
+ uint64_t l_attr_enum_val = iv_symbols->get_attr_enum_val(i_attr_enum);
+
+ uint32_t rpn_id = iv_symbols->find_numeric_lit(l_attr_enum_val,8);
+ iv_rpnstack.push_back(rpn_id);
+
+ //printf("Attribute Enum name: %s Value:%u rpn_id:0x%8X\n",i_attr_enum.c_str(),l_attr_enum_val,rpn_id);
+}
+
+//-------------------------------------------------------------------------------------------------
bool Rpn::isTrue() const //dg003a
{
diff --git a/src/build/ifcompiler/initRpn.H b/src/build/ifcompiler/initRpn.H
index 5bd98a3fa..33a503842 100755
--- a/src/build/ifcompiler/initRpn.H
+++ b/src/build/ifcompiler/initRpn.H
@@ -24,6 +24,7 @@
// 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
// End Change Log *********************************************************************************
/**
@@ -135,6 +136,15 @@ namespace init
*/
void push_array_index(std::string &i_array_idx);
+ /**
+ * @brief Add an attribute enum
+ *
+ * @param[in] i_attr_enum attribute enum name
+ *
+ * @return Void
+ */
+ void push_attr_enum(std::string &i_attr_enum);
+
Rpn * push_op(RPN_OP op); //<<< Add an operation to the Rpn sequence
/**
diff --git a/src/build/ifcompiler/initSymbols.C b/src/build/ifcompiler/initSymbols.C
index a09421be8..018e82f0d 100755
--- a/src/build/ifcompiler/initSymbols.C
+++ b/src/build/ifcompiler/initSymbols.C
@@ -19,6 +19,7 @@
// D754106 dgilbert 06/14/10 Create
// dgilbert 10/22/10 Add spies_are_in()
// andrewg 09/19/11 Updates based on review
+// camvanng 11/08/11 Added support for attribute enums
// End Change Log *********************************************************************************
/**
@@ -75,7 +76,7 @@ Symbols::Symbols(FILELIST & i_filenames)
if(def == "AttributeId")
{
// We've now found the beginning of the attribute enum definition
- // Read and skip the { on the next line
+ // Read and skip the '{' on the next line
getline(infs,fileline);
getline(infs,fileline);
@@ -105,6 +106,72 @@ Symbols::Symbols(FILELIST & i_filenames)
getline(infs,fileline);
}
}
+ else
+ {
+ // Make sure it's an attribute enum
+
+ string attribute_enum_name;
+ string find_enum = "_Enum";
+
+ // Check for _Enum in the name
+ size_t pos = def.find(find_enum);
+ if(pos != string::npos)
+ {
+ // We've now found the beginning of the attribute enum definition
+ // Read and skip the '{' on the next line
+ getline(infs,fileline);
+ getline(infs,fileline);
+
+ // We're just parsing the enum in order so values start
+ // at 0 and increment by 1 after that unless they are
+ // explicitly assigned.
+ uint64_t value = 0;
+
+ while(fileline[0] != '}')
+ {
+ istringstream attr_enum_stream(fileline);
+ string attr_enum;
+ string tmp;
+
+ // Get the attribute enum name
+ attr_enum_stream >> attr_enum;
+
+ // Strip off the "," at the end.
+ pos = attr_enum.find(',');
+ if(pos != string::npos)
+ {
+ attr_enum = attr_enum.substr(0,attr_enum.length()-1);
+ }
+ else
+ {
+ // Is a value for the enum specified?
+ attr_enum_stream >> tmp;
+
+ if (!attr_enum_stream.eof())
+ {
+ //Make sure it's an '='
+ if ("=" != tmp)
+ {
+ printf ("ERROR: Unknown attribute enum! %s\n",attr_enum.c_str());
+ exit(1);
+ }
+ else
+ {
+ attr_enum_stream >> tmp;
+ value = strtoll(tmp.c_str(), NULL, 0);
+ }
+ }
+ }
+
+ //printf("Attribute Enum String:%s Value %u\n",attr_enum.c_str(), value);
+
+ // Get a value for the string
+ iv_attr_enum[attr_enum] = value;
+ value++;
+ getline(infs,fileline);
+ }
+ }
+ }
}
else if(def == "typedef")
{
@@ -517,6 +584,12 @@ uint64_t Symbols::get_numeric_data(uint32_t i_rpn_id, uint32_t & o_size)
}
// ------------------------------------------------------------------------------------------------
+uint64_t Symbols::get_attr_enum_val(string & i_attr_enum)
+{
+ return iv_attr_enum[i_attr_enum];
+}
+
+// ------------------------------------------------------------------------------------------------
string Symbols::find_text(uint32_t i_cini_id)
{
@@ -729,7 +802,7 @@ string Symbols::not_found_listing()
ostringstream oss;
if(iv_not_found.size())
{
- oss << "\n------------- Symbols reqested that were NOT FOUND ---------------\n\n";
+ oss << "\n------------- Symbols requested that were NOT FOUND ---------------\n\n";
for(SYMBOL_MAP::iterator i = iv_not_found.begin(); i != iv_not_found.end(); ++i)
{
//if(i->first == "SPY_NOTFOUND" || (i->first).compare(0,13,"ENUM_NOTFOUND") == 0) continue;
diff --git a/src/build/ifcompiler/initSymbols.H b/src/build/ifcompiler/initSymbols.H
index 68ba70718..93613e059 100755
--- a/src/build/ifcompiler/initSymbols.H
+++ b/src/build/ifcompiler/initSymbols.H
@@ -21,6 +21,7 @@
// ---- -------- -------- -------- -------------------------------------------------------------
// D754106 dgilbert 06/14/10 Create
// andrewg 09/19/11 Updates based on review
+// camvanng 11/08/11 Added support for attribute enums
// End Change Log *********************************************************************************
/**
@@ -98,7 +99,7 @@ namespace init
/**
* Lookup the tag id from the rpn_id provided by use_symbol()
* @returns tag id
- * @param prn_id
+ * @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
@@ -158,6 +159,13 @@ namespace init
*/
uint64_t get_numeric_data(uint32_t i_rpn_id, uint32_t & o_size);
+ /**
+ * Get the attribute enum value for the attr enum
+ * @param string attribute enum name
+ * @returns uint64_t value
+ */
+ uint64_t get_attr_enum_val(string & i_attr_enum);
+
/**
* Store enum name & return rpn_id
@@ -231,6 +239,7 @@ namespace init
typedef map<string,MAP_DATA > SYMBOL_MAP;
typedef map<string,uint32_t> SPY_MAP;
typedef map<string,uint32_t> SYMBOL_ATTR_TYPE;
+ typedef map<string,uint64_t> SYMBOL_ATTR_ENUM;
typedef pair<Rpn,uint32_t> DEF_DATA;
typedef map<string,DEF_DATA> DEF_MAP;
@@ -245,6 +254,7 @@ namespace init
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_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
SYMBOL_USED iv_used_var; ///< List of cini_ids of used vars ordered by name
OpenPOWER on IntegriCloud