diff options
author | CamVan Nguyen <ctnguyen@us.ibm.com> | 2012-06-15 13:51:40 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-06-18 16:24:33 -0500 |
commit | 0cf879912d04e5c81ec49502fa792c70f6c3f7d3 (patch) | |
tree | a4e27b3bb80bfe1e08667029d345e596c3f69929 /src/usr/hwpf/ifcompiler | |
parent | d2b63c0d6e57e5c3676b312c25298aaed637fa07 (diff) | |
download | talos-hostboot-0cf879912d04e5c81ec49502fa792c70f6c3f7d3.tar.gz talos-hostboot-0cf879912d04e5c81ec49502fa792c70f6c3f7d3.zip |
SCOM Initfile: Ability to use logical operations with attribute columns
Change-Id: I13b4c68ca419d26835d9648d9ccac5be69919be7
RTC: 35655
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1209
Tested-by: Jenkins Server
Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com>
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/ifcompiler')
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initCompiler.lex | 24 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initCompiler.y | 39 |
2 files changed, 42 insertions, 21 deletions
diff --git a/src/usr/hwpf/ifcompiler/initCompiler.lex b/src/usr/hwpf/ifcompiler/initCompiler.lex index eb6e4720f..26574b632 100755 --- a/src/usr/hwpf/ifcompiler/initCompiler.lex +++ b/src/usr/hwpf/ifcompiler/initCompiler.lex @@ -43,6 +43,7 @@ // 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 +// camvanng 06/11/12 Fix shift/reduce warnings from yacc // End Change Log *********************************************************************************/ /** * @file initCompiler.lex @@ -185,7 +186,7 @@ Versions BEGIN(fnames); include { BEGIN(incl); } <incl>[ \t]* /* Eat up whitespace */ <incl>[^ \t\n]+ { /* Got the include file name */ - /*printf("include file %s\n", yytext);*/ + /*printf("lex: include file %s\n", yytext);*/ if ( include_stack_num >= MAX_INCLUDE_DEPTH ) { lex_err("Includes nested too deeply"); @@ -277,7 +278,7 @@ scom { BEGIN(scomop); oss.str(""); return INIT_SCOM; } return INIT_SCOM_SUFFIX; } -<scomop_hex,scomop_hex_suffix>\.0[bB] { BEGIN(scomop_bin); } +<scomop_hex,scomop_hex_suffix>\.0[bB] { BEGIN(scomop_bin); return yytext[0]; } <scomop_bin>{SINGLE_BIN}+ { /*printf("lex: bin string %s\n", yytext);*/ @@ -314,7 +315,7 @@ scom { BEGIN(scomop); oss.str(""); return INIT_SCOM; } <scomop_bin,scomop_bin_suffix>\.(0[xX])? { /*printf("lex: bin string %s\n", yytext);*/ - BEGIN(scomop_hex); + BEGIN(scomop_hex); return yytext[0]; } <scomop_bin,scomop_bin_suffix>\.0[bB] { @@ -412,7 +413,7 @@ END_INITFILE return INIT_ENDINITFILE; <*>{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()); + //printf("lex: %s\n", g_target.c_str()); unput('.'); pushBackDefine(g_target.c_str()); } @@ -459,7 +460,7 @@ int yywrap() { return 1; } void lex_err(const char *s ) { - std::cerr << "\nERROR: " << s << " -line " << yyline << std::endl; + std::cerr << "\nERROR: lex: " << s << " -line " << yyline << std::endl; } // Convert left justified bitstring to right-justified 64 bit integer @@ -576,7 +577,16 @@ void add_define(const char * s) exit(1); } + //remove trailing white spaces std::string str(s); + std::string whitespaces(" \t\r"); + size_t pos; + pos=str.find_last_not_of(whitespaces); + if (pos != std::string::npos) + { + str.erase(pos+1); + } + g_defines[g_scomdef_name] = str; //std::cout << "g_defines[" << g_scomdef_name << "] = " << g_defines[g_scomdef_name] << std::endl; } @@ -602,7 +612,7 @@ void pushBackDefine(const char *s) if (g_defines.end() == g_defines.find(key)) { oss.str(""); - oss << "lex: Cannot find define " << key; + oss << "Cannot find define " << key; lex_err(oss.str().c_str()); exit(1); } @@ -615,7 +625,7 @@ void pushBackDefine(const char *s) if (g_defines.end() == g_defines.find(key2)) { oss.str(""); - oss << "lex: Cannot find define " << key; + oss << "Cannot find define " << key; lex_err(oss.str().c_str()); exit(1); } diff --git a/src/usr/hwpf/ifcompiler/initCompiler.y b/src/usr/hwpf/ifcompiler/initCompiler.y index 6079febb7..62f534016 100755 --- a/src/usr/hwpf/ifcompiler/initCompiler.y +++ b/src/usr/hwpf/ifcompiler/initCompiler.y @@ -39,6 +39,8 @@ // Delete obsolete code for defines support // camvanng 05/22/12 Ability to do simple operations on attributes // in the scom_data column +// camvanng 06/11/12 Ability to do logical operations with attribute columns +// Fix shift/reduce warnings from yacc // End Change Log ********************************************************************************* /** * @file initCompiler.y @@ -119,7 +121,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 scomdexpr +%type <rpn_ptr> expr id_colexpr id_col num_list scomdexpr @@ -182,18 +184,21 @@ scomaddr: scomaddr_hex { /*printf("Found a hex scom address\n");*/ } | scomaddr_bin { /*printf("Found a binary scom address\n");*/ current_scom->append_scom_address_bin(); } - | scomaddr scomaddr_hex { /*printf("Found a hex scom address 2\n");*/ } - | scomaddr scomaddr_bin { /*printf("Append binary scom address 2\n");*/ + | scomaddr '.' scomaddr_hex { /*printf("Found a hex scom address 2\n");*/ } + | scomaddr '.' scomaddr_bin { /*printf("Append binary scom address 2\n");*/ current_scom->append_scom_address_bin(); } ; -scomaddr_hex: - | INIT_SCOM_ADDR { /*printf("Found an INIT_SCOM_ADDR %s\n", (*($1)).c_str());*/ - current_scom->set_scom_address(*($1)); delete $1; } +scomaddr_hex: INIT_SCOM_ADDR { /*printf("Found an INIT_SCOM_ADDR %s\n", (*($1)).c_str());*/ + current_scom->set_scom_address(*($1)); delete $1; } | scom_list { current_scom->copy_dup_scom_address(); } | INIT_SCOM_SUFFIX { current_scom->set_scom_suffix(*($1)); delete $1; } + | scomaddr_hex scom_list { /*printf("Found a scom_list 2\n");*/ + current_scom->copy_dup_scom_address(); } + | scomaddr_hex INIT_SCOM_SUFFIX { /*printf("Found a scom suffix %s\n", (*($2)).c_str());*/ + current_scom->set_scom_suffix(*($2)); delete $2;} ; @@ -276,20 +281,26 @@ exprrows: expr { init::dbg << $1->listing(NULL); current_scom->add_row_rpn { init::dbg << $3->listing(NULL); current_scom->add_row_rpn($3); } ; -idrows: id_col { init::dbg << $1->listing(NULL); current_scom->add_row_rpn($1); } - | idrows ',' id_col { init::dbg << $3->listing(NULL); current_scom->add_row_rpn($3); } +idrows: id_colexpr { init::dbg << $1->listing(NULL); current_scom->add_row_rpn($1); } + | idrows ',' id_colexpr { init::dbg << $3->listing(NULL); current_scom->add_row_rpn($3); } ; - // TODO num_list could be VARs,LITs, or even ranges eg {1,2..5,7} -id_col: INIT_ID { $$ = new init::Rpn(*($1),yyscomlist->get_symbols()); $$->push_op(EQ); delete $1; } - | INIT_INTEGER { $$ = new init::Rpn($1,yyscomlist->get_symbols()); $$->push_op(EQ); } - | '{' num_list '}' { $$ = $2; $2->push_op(LIST); $2->push_op(EQ); } - | ATTRIBUTE_ENUM { $$ = new init::Rpn((yyscomlist->get_symbols())->get_attr_enum_val(*($1)),yyscomlist->get_symbols()); $$->push_op(EQ); delete $1; } +id_colexpr: id_col { $1->push_op(EQ); } + | INIT_EQ id_col { $$ = $2; $2->push_op(EQ); } + | INIT_NE id_col { $$ = $2; $2->push_op(NE); } + | INIT_LE id_col { $$ = $2; $2->push_op(LE); } + | INIT_GE id_col { $$ = $2; $2->push_op(GE); } + | '<' id_col { $$ = $2; $2->push_op(LT); } + | '>' id_col { $$ = $2; $2->push_op(GT); } ; - +id_col: INIT_ID { $$ = new init::Rpn(*($1),yyscomlist->get_symbols()); delete $1; } + | INIT_INTEGER { $$ = new init::Rpn($1,yyscomlist->get_symbols()); } + | '{' num_list '}' { $$ = $2; $2->push_op(LIST); } + | ATTRIBUTE_ENUM { $$ = new init::Rpn((yyscomlist->get_symbols())->get_attr_enum_val(*($1)),yyscomlist->get_symbols()); delete $1; } +; num_list: INIT_INTEGER { $$ = new init::Rpn($1,yyscomlist->get_symbols()); } | INIT_ID { $$ = new init::Rpn(*($1),yyscomlist->get_symbols()); } |