diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/build/ifcompiler/initCompiler.y | 44 | ||||
-rw-r--r--[-rwxr-xr-x] | src/build/ifcompiler/initRpn.C | 14 | ||||
-rwxr-xr-x | src/build/ifcompiler/initRpn.H | 33 | ||||
-rwxr-xr-x | src/build/ifcompiler/initScom.C | 11 | ||||
-rw-r--r--[-rwxr-xr-x] | src/build/ifcompiler/initSymbols.C | 107 | ||||
-rwxr-xr-x | src/build/ifcompiler/initSymbols.H | 18 | ||||
-rwxr-xr-x | src/build/ifcompiler/makefile | 5 | ||||
-rw-r--r-- | src/include/usr/hwpf/hwp/fapiHwpExecInitFile.H | 56 | ||||
-rw-r--r-- | src/include/usr/hwpf/hwp/fapiHwpInitFileInclude.H | 117 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/fapiHwpExecInitFile.C | 110 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/initfiles/sample.initfile | 2 | ||||
-rw-r--r-- | src/usr/hwpf/test/hwpftest.H | 9 |
12 files changed, 271 insertions, 255 deletions
diff --git a/src/build/ifcompiler/initCompiler.y b/src/build/ifcompiler/initCompiler.y index 4c86575d0..4c8da2ca3 100755 --- a/src/build/ifcompiler/initCompiler.y +++ b/src/build/ifcompiler/initCompiler.y @@ -23,6 +23,7 @@ // 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 +// andrewg 11/09/11 Refactor to use common include with hwp framework. // End Change Log ********************************************************************************* /** * @file initCompiler.y @@ -232,10 +233,10 @@ idrows: id_col { init::dbg << $1->listing(NULL); current_scom->add_row_ // 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(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; } +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; } ; @@ -261,24 +262,23 @@ 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 INIT_LOGIC_OR expr { $$ = $1->push_merge($3,init::Rpn::OR); } - | expr INIT_LOGIC_AND expr { $$ = $1->push_merge($3,init::Rpn::AND); } - | expr INIT_EQ expr { $$ = $1->push_merge($3,init::Rpn::EQ); } - | expr INIT_NE expr { $$ = $1->push_merge($3,init::Rpn::NE); } - | expr INIT_LE expr { $$ = $1->push_merge($3,init::Rpn::LE); } - | expr INIT_GE expr { $$ = $1->push_merge($3,init::Rpn::GE); } - | expr '<' expr { $$ = $1->push_merge($3,init::Rpn::LT); } - | expr '>' expr { $$ = $1->push_merge($3,init::Rpn::GT); } - | expr INIT_SHIFT_RIGHT expr { $$ = $1->push_merge($3,init::Rpn::SHIFTRIGHT); } - | expr INIT_SHIFT_LEFT expr { $$ = $1->push_merge($3,init::Rpn::SHIFTLEFT); } - | expr '+' expr { $$ = $1->push_merge($3,init::Rpn::PLUS); } - | expr '-' expr { $$ = $1->push_merge($3,init::Rpn::MINUS); } - | expr '*' expr { $$ = $1->push_merge($3,init::Rpn::MULT); } - | expr '/' expr { $$ = $1->push_merge($3,init::Rpn::DIVIDE); } - | expr '%' expr { $$ = $1->push_merge($3,init::Rpn::MOD); } - | '!' expr { $$ = $2->push_op(init::Rpn::NOT); } - /* | '~' expr { $$ = $2->push_op("~"); } */ + | expr ATTRIBUTE_INDEX { $1->push_array_index(*($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); } + | expr INIT_NE expr { $$ = $1->push_merge($3,NE); } + | expr INIT_LE expr { $$ = $1->push_merge($3,LE); } + | expr INIT_GE expr { $$ = $1->push_merge($3,GE); } + | expr '<' expr { $$ = $1->push_merge($3,LT); } + | expr '>' expr { $$ = $1->push_merge($3,GT); } + | expr INIT_SHIFT_RIGHT expr { $$ = $1->push_merge($3,SHIFTRIGHT); } + | expr INIT_SHIFT_LEFT expr { $$ = $1->push_merge($3,SHIFTLEFT); } + | expr '+' expr { $$ = $1->push_merge($3,PLUS); } + | expr '-' expr { $$ = $1->push_merge($3,MINUS); } + | expr '*' expr { $$ = $1->push_merge($3,MULT); } + | expr '/' expr { $$ = $1->push_merge($3,DIVIDE); } + | expr '%' expr { $$ = $1->push_merge($3,MOD); } + | '!' expr { $$ = $2->push_op(NOT); } | '(' expr ')' { $$ = $2; } ; diff --git a/src/build/ifcompiler/initRpn.C b/src/build/ifcompiler/initRpn.C index bd1b8b1a1..39af931a1 100755..100644 --- a/src/build/ifcompiler/initRpn.C +++ b/src/build/ifcompiler/initRpn.C @@ -22,6 +22,7 @@ // 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 +// andrewg 11/09/11 Multi-dimensional array and move to common fapi include // End Change Log ********************************************************************************* /** @@ -207,7 +208,7 @@ void Rpn::push_array_index(std::string &i_array_idx) uint32_t 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_idx.c_str(),l_array_val,rpn_id); + // printf("Array Index: %s decimal:%u rpn_id:0x%8X\n",l_idx.c_str(),l_array_val,rpn_id); } @@ -240,10 +241,10 @@ bool Rpn::isFalse() const //dg003a //------------------------------------------------------------------------------------------------- -Rpn * Rpn::push_op(RPN_OP op) +Rpn * Rpn::push_op(IfRpnOp op) { uint32_t v = op; - if(op == Rpn::LIST) // calculate list size + if(op == LIST) // calculate list size { uint32_t count = 0; for(RPNSTACK::const_reverse_iterator r = iv_rpnstack.rbegin(); r != iv_rpnstack.rend(); ++r) @@ -261,7 +262,7 @@ Rpn * Rpn::push_op(RPN_OP op) //------------------------------------------------------------------------------------------------- // @post i_rpn is deleted -Rpn * Rpn::push_merge(Rpn * i_rpn, RPN_OP op) +Rpn * Rpn::push_merge(Rpn * i_rpn, IfRpnOp op) { //dg003a begin Rpn * result = this; @@ -628,10 +629,9 @@ std::string Rpn::listing(const char * i_desc, const std::string & spyname, bool if(i_final) { uint32_t val = iv_symbols->get_tag(*i); - uint32_t type = val & Symbols::TYPE_MASK; + uint32_t type = val & IF_TYPE_MASK; - if (type == Symbols::LIT_TYPE || - type == Symbols::VAR_TYPE) + if (type == IF_ATTR_TYPE) { rpn_byte_size += 2; oss << "0x" << std::setw(4) << val << "\t\t" << "PUSH " << name << std::endl; diff --git a/src/build/ifcompiler/initRpn.H b/src/build/ifcompiler/initRpn.H index 33a503842..5eba73c62 100755 --- a/src/build/ifcompiler/initRpn.H +++ b/src/build/ifcompiler/initRpn.H @@ -25,6 +25,7 @@ // 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 +// andrewg 11/09/11 Multi-dimensional array and move to common fapi include // End Change Log ********************************************************************************* /** @@ -36,6 +37,7 @@ #include <string> #include <vector> #include <map> +#include <fapiHwpInitFileInclude.H> namespace init @@ -59,36 +61,9 @@ namespace init ARRAY_INDEX = 0x40000000, OPERATION = 0x80000000, TYPE_MASK = 0xF8000000, - OP_MASK = 0x000000FF }; - // These RPN_OPs are defined in the ciniIfRpnCalculator.C The values must always match - enum RPN_OP - { - PUSH = 0x00000000, - AND = 0x00000001, - OR = 0x00000002, - NOT = 0x00000003, - EQ = 0x00000004, - NE = 0x00000005, - GT = 0x00000006, - GE = 0x00000007, - LT = 0x00000008, - LE = 0x00000009, - PLUS = 0x0000000A, - MINUS = 0x0000000B, - MULT = 0x0000000C, - DIVIDE = 0x0000000D, - MOD = 0x0000000E, - LIST = 0x0000000F, - SHIFTLEFT = 0x00000010, - SHIFTRIGHT = 0x00000011, - FALSE_OP = 0x00000012, // dg003a - TRUE_OP = 0x00000013, // dg003a - LAST_OP - }; - /** * @brief Create empty RPN * @@ -145,7 +120,7 @@ namespace init */ void push_attr_enum(std::string &i_attr_enum); - Rpn * push_op(RPN_OP op); //<<< Add an operation to the Rpn sequence + Rpn * push_op(IfRpnOp op); //<<< Add an operation to the Rpn sequence /** * @brief Merge an Rpn to this Rpn sequence with input operation @@ -155,7 +130,7 @@ namespace init * * @return Merged RPN */ - Rpn * push_merge(Rpn * io_rpn, RPN_OP i_op); + Rpn * push_merge(Rpn * io_rpn, IfRpnOp i_op); /** * Merge (append) Rpn with this Rpn sequence diff --git a/src/build/ifcompiler/initScom.C b/src/build/ifcompiler/initScom.C index 404a59b04..8a7d08cf1 100755 --- a/src/build/ifcompiler/initScom.C +++ b/src/build/ifcompiler/initScom.C @@ -23,6 +23,7 @@ // dg003 SW047506 dgilbert 12/09/10 More filtering enhancements // andrewg 05/24/11 Port over for VPL/PgP // andrewg 09/19/11 Updates based on review +// andrewg 11/09/11 Multi-dimensional array and move to common fapi include // End Change Log ********************************************************************************* /** @@ -221,11 +222,11 @@ void Scom::add_row_rpn(Rpn * i_rpn) // Replace the Rpn "ANY" EQ with TRUE dg003a Rpn any_rpn("ANY",iv_symbols); Rpn true_rpn(iv_symbols); - true_rpn.push_op(Rpn::TRUE_OP); + true_rpn.push_op(TRUE_OP); // The column EXPR can have an lone "ANY" rpn - so add EQ. - if(any_rpn == (*i_rpn)) i_rpn->push_op(Rpn::EQ); - any_rpn.push_op(Rpn::EQ); + if(any_rpn == (*i_rpn)) i_rpn->push_op(EQ); + any_rpn.push_op(EQ); if(any_rpn == (*i_rpn)) iv_row_rpn.push_back(true_rpn); // Replace col == ANY with TRUE else @@ -279,8 +280,8 @@ void Scom::make_target(const char * i_symbol) r.push_int(v); } } - if(rsize > 1) r.push_op(Rpn::LIST); // if more than one target - r.push_op(Rpn::EQ); + if(rsize > 1) r.push_op(LIST); // if more than one target + r.push_op(EQ); } iv_row_rpn.push_back(r); diff --git a/src/build/ifcompiler/initSymbols.C b/src/build/ifcompiler/initSymbols.C index 018e82f0d..77f55258b 100755..100644 --- a/src/build/ifcompiler/initSymbols.C +++ b/src/build/ifcompiler/initSymbols.C @@ -20,6 +20,7 @@ // 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 +// andrewg 11/09/11 Multi-dimensional array and move to common fapi include // End Change Log ********************************************************************************* /** @@ -179,7 +180,7 @@ Symbols::Symbols(FILELIST & i_filenames) string attribute_name; string find_type = "_Type"; string find_array = "["; - bool array = false; + uint32_t array = 0; iss >> type; iss >> attribute_name; if(attribute_name == "*") @@ -190,11 +191,12 @@ Symbols::Symbols(FILELIST & i_filenames) } //printf("typedef: type:%s attribute_name:%s\n",type.c_str(),attribute_name.c_str()); - // Check if there's a "[" in the string, which would indicate it's an array + // Determine how many (if any) dimensions this array has size_t pos = attribute_name.find(find_array); - if(pos != string::npos) + while(pos != string::npos) { - array = true; + array++; + pos = attribute_name.find(find_array,pos+1); } // Now strip off the _type in the name @@ -210,7 +212,8 @@ Symbols::Symbols(FILELIST & i_filenames) } iv_attr_type[attribute_name] = get_attr_type(type,array); - //printf("Attribute %s Type for %s is %u\n",attribute_name.c_str(),type.c_str(),get_attr_type(type,array)); + //printf("Attribute %s Type with array dimension %u for %s is %u\n",attribute_name.c_str(),array, + // type.c_str(),get_attr_type(type,array)); } } infs.close(); @@ -219,51 +222,38 @@ Symbols::Symbols(FILELIST & i_filenames) iv_rpn_map[Rpn::SYMBOL | INIT_ANY_LIT] = RPN_DATA("ANY",CINI_LIT_MASK); } -uint32_t Symbols::get_attr_type(const string &i_type, bool i_array) +uint32_t Symbols::get_attr_type(const string &i_type, const uint32_t i_array) { + uint32_t l_type = 0; if (i_type == "uint8_t") { - if(i_array == true) - { - return(SYM_ATTR_UINT8_ARRAY_TYPE); - } - else - { - return(SYM_ATTR_UINT8_TYPE); - } + l_type = SYM_ATTR_UINT8_TYPE; } else if(i_type == "uint32_t") { - if(i_array == true) - { - return(SYM_ATTR_UINT32_ARRAY_TYPE); - } - else - { - return(SYM_ATTR_UINT32_TYPE); - } + l_type = SYM_ATTR_UINT32_TYPE; } else if(i_type == "uint64_t") { - if(i_array == true) - { - return(SYM_ATTR_UINT64_ARRAY_TYPE); - } - else - { - return(SYM_ATTR_UINT64_TYPE); - } + l_type = SYM_ATTR_UINT64_TYPE; } - //else if(i_type == "uint64_t") - // TODO - Add attribute array support else { - // TODO - Need to ensure all attributes have data type at the end of processing printf("Unknown data type: %s\n",i_type.c_str()); - return(0); + exit(-1); + } + + if(i_array > MAX_ATTRIBUTE_ARRAY_DIMENSION) + { + printf("Array dimension size for %s %u exceeded maximum dimension of %u\n", + i_type.c_str(),i_array,MAX_ATTRIBUTE_ARRAY_DIMENSION); + exit(-1); } + // See enum definition on why this works + l_type += (i_array*ATTR_DIMENSION_SIZE_MULT)+i_array; + return(l_type); } // ------------------------------------------------------------------------------------------------ @@ -429,31 +419,16 @@ uint16_t Symbols::get_tag(uint32_t i_rpn_id) break; } - - if((cini_id & CINI_LIT_MASK) == CINI_LIT_MASK) + uint32_t offset = 0; + for(SYMBOL_USED::iterator i = iv_used_var.begin(); i != iv_used_var.end(); ++i,++offset) { - uint32_t offset = 0; - for(SYMBOL_USED::iterator i = iv_used_lit.begin(); i != iv_used_lit.end(); ++i,++offset) + if(cini_id == *i) { - if(cini_id == *i) - { - tag = (uint16_t) (offset | LIT_TYPE); - break; - } - } - } - else // vars - { - uint32_t offset = 0; - for(SYMBOL_USED::iterator i = iv_used_var.begin(); i != iv_used_var.end(); ++i,++offset) - { - if(cini_id == *i) - { - tag = (uint16_t) (offset | VAR_TYPE); - break; - } + tag = (uint16_t) (offset | IF_ATTR_TYPE); + break; } } + } while(0); return tag; @@ -525,7 +500,7 @@ uint16_t Symbols::get_numeric_tag(uint32_t i_rpn_id) if(offset < iv_lits.size()) { // numeric lits are numbered after enum lits, but with different TYPE - tag = (iv_used_lit.size() + offset) | NUM_TYPE; + tag = (iv_used_lit.size() + offset) | IF_NUM_TYPE; } else { @@ -548,7 +523,7 @@ uint16_t Symbols::get_numeric_array_tag(uint32_t i_rpn_id) if(offset < iv_lits.size()) { // numeric lits are numbered after enum lits, but with different TYPE - tag = (iv_used_lit.size() + offset) | NUM_TYPE; + tag = (iv_used_lit.size() + offset) | IF_NUM_TYPE; } else { @@ -768,7 +743,7 @@ string Symbols::listing() for(SYMBOL_USED::iterator i = iv_used_var.begin() + 1; i != iv_used_var.end(); ++i) { ++count; - oss << "Type:" << setw(2) << iv_attr_type[find_text(*i)] << " Value:0x" << setw(8) << (*i) << '\t' << "ID 0X" << setw(4) << (count | VAR_TYPE) + oss << "Type:" << setw(2) << iv_attr_type[find_text(*i)] << " Value:0x" << setw(8) << (*i) << '\t' << "ID 0X" << setw(4) << (count | IF_ATTR_TYPE) << '\t' << '[' << find_text(*i) << ']' << endl; //printf("ATTRIBUTE: %s Value:0x%02X\n",(find_text(*i)).c_str(),iv_attr_type[find_text(*i)]); @@ -960,26 +935,19 @@ string Symbols::get_enumname(uint32_t spy_id) uint32_t Symbols::get_rpn_id(uint32_t bin_tag) { uint32_t rpn_id = NOT_FOUND; - uint32_t type = bin_tag & TYPE_MASK; - uint32_t offset = bin_tag & ~TYPE_MASK; + uint32_t type = bin_tag & IF_TYPE_MASK; + uint32_t offset = bin_tag & ~IF_TYPE_MASK; uint32_t cini_id = 0; switch(type) { - case LIT_TYPE: { - cini_id = iv_used_lit[offset]; - string name = find_text(cini_id); - rpn_id = use_symbol(name); - } - break; - - case VAR_TYPE: { + case IF_ATTR_TYPE: { cini_id = iv_used_var[offset]; string name = find_text(cini_id); rpn_id = use_symbol(name); } break; - case NUM_TYPE: { + case IF_NUM_TYPE: { offset -= iv_used_lit.size(); if(offset >= iv_lits.size()) { @@ -993,6 +961,7 @@ uint32_t Symbols::get_rpn_id(uint32_t bin_tag) rpn_id = find_numeric_lit(d.first,d.second); } break; + default: { ostringstream erros; diff --git a/src/build/ifcompiler/initSymbols.H b/src/build/ifcompiler/initSymbols.H index 93613e059..80a3fbb31 100755 --- a/src/build/ifcompiler/initSymbols.H +++ b/src/build/ifcompiler/initSymbols.H @@ -22,6 +22,7 @@ // D754106 dgilbert 06/14/10 Create // andrewg 09/19/11 Updates based on review // camvanng 11/08/11 Added support for attribute enums +// andrewg 11/09/11 Multi-dimensional array and move to common fapi include // End Change Log ********************************************************************************* /** @@ -41,6 +42,7 @@ #include <map> #include <set> #include <initRpn.H> +#include <fapiHwpInitFileInclude.H> // Requires file from hwpf using namespace std; @@ -55,24 +57,12 @@ namespace init enum { - LIT_TYPE = 0x4000, - VAR_TYPE = 0x8000, - NUM_TYPE = 0xC000, - TYPE_MASK = 0xFFFFC000, CINI_LIT_MASK = 0xA0000000, INIT_ANY_LIT = 0x07FFFFFE, INIT_EXPR_VAR = 0x07FFFFFF, }; - enum - { - SYM_ATTR_UINT8_TYPE = 0x00, - SYM_ATTR_UINT32_TYPE = 0x01, - SYM_ATTR_UINT64_TYPE = 0x02, - SYM_ATTR_UINT8_ARRAY_TYPE = 0x03, - SYM_ATTR_UINT32_ARRAY_TYPE = 0x04, - SYM_ATTR_UINT64_ARRAY_TYPE = 0x05, - }; + enum { @@ -230,7 +220,7 @@ namespace init string find_text(uint32_t i_cini_id); uint32_t add_undefined(const string & s); - uint32_t get_attr_type(const string &i_type, bool i_array); + uint32_t get_attr_type(const string &i_type, const uint32_t i_array); private: //data diff --git a/src/build/ifcompiler/makefile b/src/build/ifcompiler/makefile index 04bea5213..737c8004d 100755 --- a/src/build/ifcompiler/makefile +++ b/src/build/ifcompiler/makefile @@ -21,6 +21,9 @@ # # IBM_PROLOG_END # add a -d to flex for debug output +# ./bin/initCompiler -init ./sample.initfile -outdir . --debug -attr ./fapiAttributeIds.H + +ROOTPATH = ../../.. y.tab.%: initCompiler.y yacc -d initCompiler.y @@ -29,7 +32,7 @@ lex.yy.c: initCompiler.lex flex initCompiler.lex bin/initCompiler: y.tab.c y.tab.h lex.yy.c initCompiler.C initCompiler.H initRpn.C initRpn.H initScom.C initScom.H initSymbols.C initSymbols.H - mkdir -p bin; g++ initCompiler.C lex.yy.c y.tab.c initRpn.C initScom.C initSymbols.C -I./ -o ./bin/initCompiler + mkdir -p bin; g++ initCompiler.C lex.yy.c y.tab.c initRpn.C initScom.C initSymbols.C -I ./ -I ${ROOTPATH}/src/include/usr/hwpf/hwp/ -o ./bin/initCompiler ifcompiler: bin/initCompiler diff --git a/src/include/usr/hwpf/hwp/fapiHwpExecInitFile.H b/src/include/usr/hwpf/hwp/fapiHwpExecInitFile.H index 7954f15cf..7018e6280 100644 --- a/src/include/usr/hwpf/hwp/fapiHwpExecInitFile.H +++ b/src/include/usr/hwpf/hwp/fapiHwpExecInitFile.H @@ -31,6 +31,7 @@ * Flag Defect/Feature User Date Description * ------ -------------- ---------- ----------- ---------------------------- * camvanng 09/29/2011 Created. + * andrewg 11/16/2011 Refactor includes with initfile compiler * */ @@ -38,6 +39,7 @@ #define FAPIHWPEXECINITFILE_H_ #include <fapi.H> +#include <fapiHwpInitFileInclude.H> // HWPs are defined as C functions because platforms may wish to package them // in linux shared libraries which are DL-Opened @@ -45,60 +47,6 @@ extern "C" { /** - * @brief Enumeration of RPN ops - */ -enum IfRpnOp -{ - AND = 0x00000001, - OR = 0x00000002, - NOT = 0x00000003, - EQ = 0x00000004, - NE = 0x00000005, - GT = 0x00000006, - GE = 0x00000007, - LT = 0x00000008, - LE = 0x00000009, - PLUS = 0x0000000A, - MINUS = 0x0000000B, - MULT = 0x0000000C, - DIVIDE = 0x0000000D, - MOD = 0x0000000E, - LIST = 0x0000000F, - SHIFTLEFT = 0x00000010, - SHIFTRIGHT = 0x00000011, - FALSE_OP = 0x00000012, - TRUE_OP = 0x00000013, - PUSH_MASK = 0x000000C0, - OP_MASK = 0x000000FF -}; - -/** - * @brief Enumeration of Type Mask - */ -enum IfTypeMask -{ - IF_LIT_TYPE = 0x4000, - IF_VAR_TYPE = 0x8000, - IF_NUM_TYPE = 0xC000, - IF_TYPE_MASK = 0xC000, -}; - -/** - * @brief Enumeration of Attribute types - */ -enum IfAttrType -{ - SYM_ATTR_UINT8_TYPE = 0x00, - SYM_ATTR_UINT32_TYPE = 0x01, - SYM_ATTR_UINT64_TYPE = 0x02, - SYM_ATTR_UINT8_ARRAY_TYPE = 0x03, - SYM_ATTR_UINT32_ARRAY_TYPE = 0x04, - SYM_ATTR_UINT64_ARRAY_TYPE = 0x05, -}; - - - -/** * @brief HWP to execute an initfile. * * @param[in] i_chip Reference to target chip diff --git a/src/include/usr/hwpf/hwp/fapiHwpInitFileInclude.H b/src/include/usr/hwpf/hwp/fapiHwpInitFileInclude.H new file mode 100644 index 000000000..38d763152 --- /dev/null +++ b/src/include/usr/hwpf/hwp/fapiHwpInitFileInclude.H @@ -0,0 +1,117 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/hwpf/hwp/fapiHwpInitFileInclude.H $ +// +// 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 +/** + * @file fapiHwpInitFileInclude.H + * + * @brief Common defines for Hardware Procedure initfile execution + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * andrewg 11/09/2011 Created. + * + */ + +#ifndef FAPIHWPINITFILEINCLUDE_H_ +#define FAPIHWPINITFILEINCLUDE_H_ + +/** + * @brief Enumeration of RPN ops + */ +enum IfRpnOp +{ + AND = 0x00000001, + OR = 0x00000002, + NOT = 0x00000003, + EQ = 0x00000004, + NE = 0x00000005, + GT = 0x00000006, + GE = 0x00000007, + LT = 0x00000008, + LE = 0x00000009, + PLUS = 0x0000000A, + MINUS = 0x0000000B, + MULT = 0x0000000C, + DIVIDE = 0x0000000D, + MOD = 0x0000000E, + LIST = 0x0000000F, + SHIFTLEFT = 0x00000010, + SHIFTRIGHT = 0x00000011, + FALSE_OP = 0x00000012, + TRUE_OP = 0x00000013, + LAST_OP = 0x00000014, + PUSH_MASK = 0x000000C0, + OP_MASK = 0x000000FF +}; + +/** + * @brief Enumeration of Type Mask + */ +enum IfTypeMask +{ + IF_ATTR_TYPE = 0x8000, + IF_NUM_TYPE = 0xC000, + IF_TYPE_MASK = 0xC000, +}; + +// Only support up to 4 dimensions for an array +const uint8_t MAX_ATTRIBUTE_ARRAY_DIMENSION = 4; + +// Used for array size parsing +const uint8_t ATTR_DIMENSION_MASK = 0xF0; + +// Most significant nibble in 1 byte attribute type will indicate array dimension +const uint8_t ATTR_DIMENSION_SIZE_MULT = 0x10; + +/** + * @brief Enumeration of Attribute types + * + * Note that the most significant nibble is used to determine dimension size + * by the procedure executing the initfile. + */ +enum IfAttrType +{ + SYM_ATTR_UINT8_TYPE = 0x00, + SYM_ATTR_UINT8_ARRAY1_TYPE = 0x11, + SYM_ATTR_UINT8_ARRAY2_TYPE = 0x22, + SYM_ATTR_UINT8_ARRAY3_TYPE = 0x33, + SYM_ATTR_UINT8_ARRAY4_TYPE = 0x44, + SYM_ATTR_UINT32_TYPE = 0x05, + SYM_ATTR_UINT32_ARRAY1_TYPE = 0x16, + SYM_ATTR_UINT32_ARRAY2_TYPE = 0x27, + SYM_ATTR_UINT32_ARRAY3_TYPE = 0x38, + SYM_ATTR_UINT32_ARRAY4_TYPE = 0x49, + SYM_ATTR_UINT64_TYPE = 0x0A, + SYM_ATTR_UINT64_ARRAY1_TYPE = 0x1B, + SYM_ATTR_UINT64_ARRAY2_TYPE = 0x2C, + SYM_ATTR_UINT64_ARRAY3_TYPE = 0x3D, + SYM_ATTR_UINT64_ARRAY4_TYPE = 0x4E, +}; + + + + +#endif /* FAPIHWPINITFILEINCLUDE_H_ */ + diff --git a/src/usr/hwpf/hwp/fapiHwpExecInitFile.C b/src/usr/hwpf/hwp/fapiHwpExecInitFile.C index 7df1dbed3..4382e34ab 100644 --- a/src/usr/hwpf/hwp/fapiHwpExecInitFile.C +++ b/src/usr/hwpf/hwp/fapiHwpExecInitFile.C @@ -31,6 +31,7 @@ * Flag Defect/Feature User Date Description * ------ -------------- ---------- ----------- ---------------------------- * camvanng 09/29/2011 Created. + * andrewg 11/09/2011 Multi-dimension array support */ #include <fapiHwpExecInitFile.H> @@ -153,10 +154,7 @@ void unloadAttrSymbolTable(attrTableEntry_t *& io_attrs); fapi::ReturnCode getAttr(const ifData_t & i_ifData, const uint16_t i_id, uint64_t & o_val, - const uint32_t i_arrayIndex1 = 0, - const uint32_t i_arrayIndex2 = 0, - const uint32_t i_arrayIndex3 = 0, - const uint32_t i_arrayIndex4 = 0); + const uint16_t i_arrayIndexIds[MAX_ATTRIBUTE_ARRAY_DIMENSION]); uint64_t * loadLitSymbolTable(ifInfo_t & io_ifInfo, uint16_t & o_numLits); @@ -189,7 +187,7 @@ uint64_t rpnBinaryOp(IfRpnOp i_op, uint64_t i_val1, uint64_t i_val2, uint32_t i_any); fapi::ReturnCode rpnDoPush(ifData_t & io_ifData, const uint16_t i_id, - uint32_t & io_any, const uint16_t i_arrayIndex1 = 0); + uint32_t & io_any, const uint16_t i_arrayIndexIds[MAX_ATTRIBUTE_ARRAY_DIMENSION]); fapi::ReturnCode rpnDoOp(rpnStack_t * io_rpnStack, IfRpnOp i_op, uint32_t i_any); @@ -494,13 +492,10 @@ void unloadAttrSymbolTable(attrTableEntry_t *& io_attrs) * If there are ever attributes with more than 4 dimensions then this function * will need to be updated. * - * @param[in] i_ifData Reference to ifData_t which contains initfile data - * @param[in] i_id AttributeID - * @param[out] o_val Reference to uint64_t where attribute value is set - * @param[in] i_arrayIndex1 If array attribute then index1 - * @param[in] i_arrayIndex2 If at least 2D array attribute then index2 - * @param[in] i_arrayIndex3 If at least 3D array attribute then index3 - * @param[in] i_arrayIndex4 If at least 4D array attribute then index4 + * @param[in] i_ifData Reference to ifData_t which contains initfile data + * @param[in] i_id AttributeID + * @param[out] o_val Reference to uint64_t where attribute value is set + * @param[in] i_arrayIndexIds Array of attribute array index's (when needed) * * @return ReturnCode. Zero if success. */ @@ -508,13 +503,10 @@ void unloadAttrSymbolTable(attrTableEntry_t *& io_attrs) fapi::ReturnCode getAttr(const ifData_t & i_ifData, const uint16_t i_id, uint64_t & o_val, - const uint32_t i_arrayIndex1, - const uint32_t i_arrayIndex2, - const uint32_t i_arrayIndex3, - const uint32_t i_arrayIndex4) + const uint16_t i_arrayIndexIds[MAX_ATTRIBUTE_ARRAY_DIMENSION]) { - FAPI_DBG(">> hwpExecInitFile: getAttr: id 0x%x index %d", - i_id, i_arrayIndex1); + FAPI_DBG(">> hwpExecInitFile: getAttr: id 0x%x", + i_id); fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS; @@ -539,8 +531,8 @@ fapi::ReturnCode getAttr(const ifData_t & i_ifData, FAPI_DBG("hwpExecInitFile: getAttr: attrId %u", l_attrId); l_rc = fapi::fapiGetInitFileAttr(l_attrId, l_pTarget, o_val, - i_arrayIndex1, i_arrayIndex2, - i_arrayIndex3, i_arrayIndex4); + i_arrayIndexIds[0], i_arrayIndexIds[1], + i_arrayIndexIds[2], i_arrayIndexIds[3]); if (l_rc) { @@ -1559,46 +1551,34 @@ uint64_t rpnBinaryOp(IfRpnOp i_op, uint64_t i_val1, uint64_t i_val2, * Pushes the attribute or literal value specified by i_id onto the RPN stack. * It uses the appropriate symbol table to resolve the value first. * - * @param[in,out] io_ifData Reference to ifData_t which contains initfile data - * @param[in] i_id Id of element to push - * @param[in,out] io_any Set if ANY op - * @param[in] i_arrayIndexId Set to array index if this is an array attribute, - * support for 1-dimensional array only - * @return fapi::ReturnCode Zero on success + * @param[in,out] io_ifData Reference to ifData_t which contains initfile data + * @param[in] i_id Id of element to push + * @param[in,out] io_any Set if ANY op + * @param[in] i_arrayIndexIds Array of attribute array index's + (when attribute is array type) + * @return fapi::ReturnCode Zero on success */ fapi::ReturnCode rpnDoPush(ifData_t & io_ifData, const uint16_t i_id, - uint32_t & io_any, const uint16_t i_arrayIndexId) + uint32_t & io_any, const uint16_t i_arrayIndexIds[MAX_ATTRIBUTE_ARRAY_DIMENSION]) { FAPI_DBG(">> HwpInitFile: rpnDoPush: id 0x%X", i_id); fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS; uint64_t l_val = 0; - uint64_t l_idx = 0; do { - if ((i_id & IF_TYPE_MASK) == IF_VAR_TYPE) //It's an attribute + if ((i_id & IF_TYPE_MASK) == IF_ATTR_TYPE) //It's an attribute { - if (i_arrayIndexId) - { - l_rc = getLit(io_ifData, i_arrayIndexId, l_idx); - - if (l_rc) - { - break; - } - } - - l_rc = getAttr(io_ifData, i_id, l_val, l_idx); - + l_rc = getAttr(io_ifData, i_id, l_val, i_arrayIndexIds); if (l_rc) { break; } FAPI_DBG("hwpExecInitFile: rpnDoPush: getAttr: id = 0x%X, " - "value = 0x%llX idx = %u", i_id, l_val, l_idx); + "value = 0x%llX", i_id, l_val); rpnPush(io_ifData.rpnStack, l_val); } @@ -1747,7 +1727,7 @@ fapi::ReturnCode rpnDoOp(rpnStack_t * io_rpnStack, IfRpnOp i_op, uint32_t i_any) * * @return fapi::ReturnCode Zero on success */ -fapi::ReturnCode evalRpn(ifData_t & io_ifData, char * i_expr, +fapi::ReturnCode evalRpn(ifData_t & io_ifData, char *i_expr, uint32_t i_len, const bool i_hasExpr) { FAPI_DBG(">> hwpExecInitFile: evalRpn"); @@ -1780,24 +1760,50 @@ fapi::ReturnCode evalRpn(ifData_t & io_ifData, char * i_expr, FAPI_DBG("hwpExecInitFile: evalRpn: id 0x%.2X", l_id); //Check for attribute of array type - //1 dimensional support only - uint16_t l_arrayIndexId = 0; - if ((l_id & IF_TYPE_MASK) == IF_VAR_TYPE) + uint16_t l_arrayIndexs[MAX_ATTRIBUTE_ARRAY_DIMENSION] = {0}; + + if ((l_id & IF_TYPE_MASK) == IF_ATTR_TYPE) { //Mask out the type bits and zero-based uint16_t i = (l_id & ~IF_TYPE_MASK) - 1; - if (SYM_ATTR_UINT8_ARRAY_TYPE <= io_ifData.attrs[i].type) + // Get the attribute dimension + uint8_t l_attrDimension = io_ifData.attrs[i].type & ATTR_DIMENSION_MASK; + + // Now shift it to the LS nibble + l_attrDimension = l_attrDimension >> 4; + + //FAPI_DBG("hwpExecInitFile: evalRpn: Attribute ID:0x%.4X has dimension %u of type 0x%.4X", + // l_id,l_attrDimension,io_ifData.attrs[i].type); + + // Read out all dimensions for the attribute + for(uint8_t j=0; j<l_attrDimension; j++) { - l_arrayIndexId = *(const uint16_t *)i_expr; + // Read out array index id + uint16_t l_arrayIdxId = 0; + memcpy(&l_arrayIdxId,i_expr,2); + + uint64_t l_tmpIdx = 0; + + // Retrieve the actual value for the array index (using it's id) + l_rc = getLit(io_ifData,l_arrayIdxId,l_tmpIdx); + if (l_rc) + { + break; + } + l_arrayIndexs[j] = l_tmpIdx; i_expr += 2; i_len -= 2; - FAPI_DBG("hwpExecInitFile: evalRpn: array index id 0x%.2X", - l_arrayIndexId); } } - l_rc = rpnDoPush(io_ifData, l_id, l_any, l_arrayIndexId); + // Handle error from above for loop + if(l_rc) + { + break; + } + + l_rc = rpnDoPush(io_ifData, l_id, l_any, l_arrayIndexs); } else { @@ -1814,6 +1820,4 @@ fapi::ReturnCode evalRpn(ifData_t & io_ifData, char * i_expr, return l_rc; } - - } // extern "C" diff --git a/src/usr/hwpf/hwp/initfiles/sample.initfile b/src/usr/hwpf/hwp/initfiles/sample.initfile index e4a537878..998b5335c 100755 --- a/src/usr/hwpf/hwp/initfiles/sample.initfile +++ b/src/usr/hwpf/hwp/initfiles/sample.initfile @@ -143,7 +143,7 @@ scom 0x000000000006800c { #--****************************************************************************** #scom 0x0000000013013288 { # scom_data, ATTR_SCRATCH_UINT32_1 expr; -# 0x0000000000000192, 3, ATTR_SCRATCH_UINT8_ARRAY_1[2] == ATTR_SCRATCH_UINT8_1; +# 0x0000000000000192, 3, ATTR_SCRATCH_UINT8_ARRAY_2[1][2][3] == 0x00000000000000BE; #} #--****************************************************************************** diff --git a/src/usr/hwpf/test/hwpftest.H b/src/usr/hwpf/test/hwpftest.H index 42fdbccbf..9ee01f465 100644 --- a/src/usr/hwpf/test/hwpftest.H +++ b/src/usr/hwpf/test/hwpftest.H @@ -245,6 +245,15 @@ public: break; } + uint8_t l_uint8array2[2][3][4]; + l_uint8array2[1][2][3] = 0xBE; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_2, NULL, l_uint8array2); + if (l_rc != fapi::FAPI_RC_SUCCESS) + { + FAPI_IMP("testHwpf5: ATTR_SCRATCH_UINT8_ARRAY_2. Error from SET"); + break; + } + // Get the master processor chip TARGETING::Target* l_pTarget = NULL; TARGETING::targetService().masterProcChipTargetHandle(l_pTarget); |