summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/ifcompiler/initSymbols.H
diff options
context:
space:
mode:
authorMike Jones <mjjones@us.ibm.com>2011-11-17 19:38:31 -0600
committerMIKE J. JONES <mjjones@us.ibm.com>2011-11-21 12:07:50 -0600
commit11c80c5abcf203e5a65098ea047fd6d2a6e607cc (patch)
tree1e1a5246e8ed0b25b66e6e1e34bba7622f63bbea /src/usr/hwpf/ifcompiler/initSymbols.H
parentb9d93e82a069b6650f3bd7b43abe6aecc0bf2e4e (diff)
downloadblackbird-hostboot-11c80c5abcf203e5a65098ea047fd6d2a6e607cc.tar.gz
blackbird-hostboot-11c80c5abcf203e5a65098ea047fd6d2a6e607cc.zip
HWPF: Only support initfile attributes in fapiGetInitFileAttr()
Change-Id: Ia1ffa854d55b68f0e32595080bba323cd52e23a3 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/503 Tested-by: Jenkins Server Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com> Reviewed-by: CAMVAN T. NGUYEN <ctnguyen@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/ifcompiler/initSymbols.H')
-rwxr-xr-xsrc/usr/hwpf/ifcompiler/initSymbols.H269
1 files changed, 269 insertions, 0 deletions
diff --git a/src/usr/hwpf/ifcompiler/initSymbols.H b/src/usr/hwpf/ifcompiler/initSymbols.H
new file mode 100755
index 000000000..efef0dcbe
--- /dev/null
+++ b/src/usr/hwpf/ifcompiler/initSymbols.H
@@ -0,0 +1,269 @@
+// IBM_PROLOG_BEGIN_TAG
+// This is an automatically generated prolog.
+//
+// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/ifcompiler/initSymbols.H,v $
+//
+// IBM CONFIDENTIAL
+//
+// COPYRIGHT International Business Machines Corp. 2010,2010
+//
+//UNDEFINED
+//
+// Origin: UNDEFINED
+//
+// IBM_PROLOG_END_TAG
+#if !defined(INITSYMBOLS_H)
+#define INITSYMBOLS_H
+
+// Change Log *************************************************************************************
+//
+// Flag Track Userid Date Description
+// ---- -------- -------- -------- -------------------------------------------------------------
+// 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
+// mjjones 11/17/11 Output attribute listing
+// End Change Log *********************************************************************************
+
+/**
+ * @file initSymbols.H
+ * @brief Definition of the initSymbols class. Handles all symbols for initfiles
+ */
+
+// Definitions:
+// cini_id is the 32 bit symbol tag value of a CINI initfile literal or variable as defined in ciniIfSymbols.H
+// rpn_id is an internal representation used by the Rpn class for all numbers, symbols, Spy enums, etc. that is not an operator
+// bin_id is the 16 bit tag used to represet number, symbols, enums, etc. in the compiled initfile.
+
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+#include <map>
+#include <set>
+#include <initRpn.H>
+#include <fapiHwpInitFileInclude.H> // Requires file from hwpf
+
+using namespace std;
+
+
+namespace init
+{
+ typedef set<string> FILELIST;
+
+ class Symbols
+ {
+ public:
+
+ enum
+ {
+ CINI_LIT_MASK = 0xA0000000,
+ INIT_ANY_LIT = 0x07FFFFFE,
+ INIT_EXPR_VAR = 0x07FFFFFF,
+ };
+
+
+
+ enum
+ {
+ NOT_FOUND = 0x00000000,
+ NOT_USED = 0x00000000,
+ CINI_ID_NOT_FOUND = 0x80000000,
+ };
+
+ /**
+ * Build symbol map for list of files
+ * @param List of files to open to build Symbols
+ */
+ Symbols(FILELIST & i_filenames);
+
+ /**
+ * Add a Symbol to the "used" symbol table if not already there
+ * @param string Symbols name
+ * @returns Symbols Rpn id
+ * @post marks the id as 'USED'
+ *
+ */
+ uint32_t use_symbol(string & i_symbol);
+
+ /**
+ * Lookup the tag id from the rpn_id provided by use_symbol()
+ * @returns tag 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
+ * tt == 0b01 -> enumerated literal
+ * tt == 0b10 -> Variable name
+ * tt == 0b11 -> Numeric constant
+ * xxxxxx xxxxxxxx assigned tag offset
+ */
+ uint16_t get_tag(uint32_t i_rpn_id);
+
+ /**
+ * Find the symbol name associated with an rpn_id
+ * @param uint32_t rpn_id
+ * @returns string Symbol name | "" if not found
+ */
+ string find_name(uint32_t i_rpn_id);
+
+ /**
+ * Find the tag for the numeric lit
+ * @param data
+ * @param number of significant bytes in the data [1-8]
+ * @returns Rpn id
+ */
+ uint32_t find_numeric_lit(uint64_t i_data, int32_t byte_size);
+
+ /**
+ * Find the tag for the numeric array lit
+ * @param data
+ * @param number of significant bytes in the data [1-8]
+ * @returns Rpn id
+ */
+ uint32_t find_numeric_array_lit(uint64_t i_data, int32_t byte_size);
+
+ /**
+ * Convert a numeric literal Rpn tag to an initfile tag
+ * @param Rpn id returned by find_numeric_lit
+ * @return tag
+ * @pre Must not be called until find_numeric_lit() has been called for all numbers
+ * in the initfile.
+ */
+ uint16_t get_numeric_tag(uint32_t i_rpn_id);
+
+ /**
+ * Convert a numeric array literal Rpn tag to an initfile tag
+ * @param Rpn id returned by find_numeric_lit
+ * @return tag
+ * @pre Must not be called until find_numeric_array_lit() has been called for all numbers
+ * in the initfile.
+ */
+ uint16_t get_numeric_array_tag(uint32_t i_rpn_id);
+
+ /**
+ * Get the literal data value from the Rpn id returned by find_numeric_lit()
+ * @param uint32_t Rpn id
+ * @param uint32_t for returned byte size
+ * @returns uint64_t data
+ */
+ 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
+ */
+ uint32_t use_enum(const string & enumname);
+ uint32_t get_spy_enum_id(uint32_t i_rpn_id, const string & spyname);
+ string get_enum_name(uint32_t i_rpn_id);
+
+ string get_enumname(uint32_t spy_id);
+ string get_spyname(uint32_t spy_id);
+
+ /**
+ * Return spy id
+ */
+ uint32_t get_spy_id(const string & spyname);
+
+ void add_define(const string * name, const Rpn * rpn);
+ Rpn get_define_rpn(uint32_t rpn_id);
+ void clear_defines() { iv_defines.clear(); }
+
+
+ string listing(); ///< listing of used vars & lits
+ string attr_listing(); ///< listing of used HWPF attributes
+ uint32_t bin_vars(BINSEQ & blist); ///< binary byte output of used vars. ret # vars
+ uint32_t bin_lits(BINSEQ & blist); ///< binary byte sequence of used lits ret # lits
+
+ string full_listing(); ///< listing of all vars & lits (debug)
+ string not_found_listing(); ///< listing of all vars searched for, but not found
+
+ /**
+ * Get the rpn_id from an initfile binary tag
+ */
+ uint32_t get_rpn_id(uint32_t bin_tag);
+
+
+ /**
+ * Restore used symbol lists from binary sequence
+ * @returns number of symbols
+ */
+ uint32_t restore_var_bseq(BINSEQ::const_iterator & bli);
+ uint32_t restore_lit_bseq(BINSEQ::const_iterator & bli);
+
+ /**
+ * Test that all spies in this object are a subset of the object provided
+ * @param Symbols object to compare against
+ * @return string will all error messages. Empty string indicates success.
+ */
+ string spies_are_in(Symbols & i_full_list, const set<string> & i_ignore_spies);
+
+ static void translate_spyname(string & s)
+ {
+ for(string::iterator i = s.begin(); i != s.end(); ++i)
+ if((*i) == '.' || (*i) == '#' ||
+ (*i) == '=' || (*i) == '&' ||
+ (*i) == '<' || (*i) == '>' ||
+ (*i) == '!' || (*i) == '*' ||
+ (*i) == '/' || (*i) == '%' ||
+ (*i) == '$') *i = '_';
+ else *i = toupper(*i);
+ }
+
+ private: // functions
+
+ string find_text(uint32_t i_cini_id);
+ uint32_t add_undefined(const string & s);
+ uint32_t get_attr_type(const string &i_type, const uint32_t i_array);
+
+ private: //data
+
+ // map | symbol name | (cini_id, usage flags) |
+ typedef pair<uint32_t,uint32_t> MAP_DATA;
+ 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;
+
+ typedef pair<string,uint32_t> RPN_DATA;
+ typedef map<uint32_t,RPN_DATA> RPN_MAP;
+
+ typedef vector<uint32_t> SYMBOL_USED;
+
+ typedef pair<uint64_t,uint32_t> LIT_DATA;
+ typedef vector<LIT_DATA> LIT_LIST;
+
+ 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
+ SYMBOL_USED iv_used_lit; ///< List of cini_ids of used enum lits ordered by name
+
+ LIT_LIST iv_lits; ///< Numeric literals
+
+ SPY_MAP iv_spymap; ///< Spies & arrays & enum spies
+ SPY_MAP iv_enums; ///< Spy enums
+
+ DEF_MAP iv_defines; ///< defines
+
+ uint32_t iv_used_var_count;
+ uint32_t iv_used_lit_count;
+ uint32_t iv_rpn_id; ///< Current rpn offset assignment
+ };
+};
+
+
+#endif
OpenPOWER on IntegriCloud