From 4356666101e0e7985e65a19f86bc4a74519e93f9 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Mon, 7 Apr 2014 11:28:04 +0200 Subject: regtools: completely rework qeditor, improve soc desc library and tools The graphical editor can now display and editor description files. The library has been improved to provide more useful function. The XML format has been slightly changed: only one soc is allowed per file (this is was already de facto the case since was the root tag). Also introduce a DTD to validate the files. Change-Id: If70ba35b6dc0242bdb87411cf4baee9597798aac --- utils/regtools/lib/soc_desc.hpp | 49 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'utils/regtools/lib/soc_desc.hpp') diff --git a/utils/regtools/lib/soc_desc.hpp b/utils/regtools/lib/soc_desc.hpp index efaf813eb2..d9dbf0cc20 100644 --- a/utils/regtools/lib/soc_desc.hpp +++ b/utils/regtools/lib/soc_desc.hpp @@ -25,6 +25,7 @@ #include #include #include +#include /** * These data structures represent the SoC register in a convenient way. @@ -50,6 +51,21 @@ typedef uint32_t soc_addr_t; typedef uint32_t soc_word_t; typedef uint32_t soc_reg_flags_t; +/** SoC error gravity level */ +enum soc_error_level_t +{ + SOC_ERROR_WARNING, + SOC_ERROR_FATAL, +}; + +/** SoC description error */ +struct soc_error_t +{ + soc_error_level_t level; /// level (warning, fatal, ...) + std::string location; /// human description of the location + std::string message; /// message +}; + /** SoC register generic formula */ enum soc_reg_formula_type_t { @@ -66,6 +82,8 @@ struct soc_reg_field_value_t std::string name; /// name of the value soc_word_t value; /// numeric value std::string desc; /// human description + + std::vector< soc_error_t > errors(bool recursive); }; /** SoC register field */ @@ -90,6 +108,8 @@ struct soc_reg_field_t } std::vector< soc_reg_field_value_t > value; + + std::vector< soc_error_t > errors(bool recursive); }; /** SoC register address */ @@ -97,6 +117,8 @@ struct soc_reg_addr_t { std::string name; /// actual register name soc_addr_t addr; /// actual register address (relative to device) + + std::vector< soc_error_t > errors(bool recursive); }; /** SoC register formula */ @@ -104,6 +126,8 @@ struct soc_reg_formula_t { enum soc_reg_formula_type_t type; std::string string; /// for STRING + + std::vector< soc_error_t > errors(bool recursive); }; /** SoC register */ @@ -116,6 +140,8 @@ struct soc_reg_t soc_reg_flags_t flags; /// ORed value std::vector< soc_reg_field_t > field; + + std::vector< soc_error_t > errors(bool recursive); }; /** Soc device address */ @@ -123,6 +149,8 @@ struct soc_dev_addr_t { std::string name; /// actual device name soc_addr_t addr; + + std::vector< soc_error_t > errors(bool recursive); }; /** SoC device */ @@ -135,6 +163,8 @@ struct soc_dev_t std::vector< soc_dev_addr_t > addr; std::vector< soc_reg_t > reg; + + std::vector< soc_error_t > errors(bool recursive); }; /** SoC */ @@ -144,10 +174,23 @@ struct soc_t std::string desc; /// SoC name std::vector< soc_dev_t > dev; + + std::vector< soc_error_t > errors(bool recursive); }; -/** Parse a SoC description from a XML file, append it to . A file - * can contain multiple SoC descriptions */ -bool soc_desc_parse_xml(const std::string& filename, std::vector< soc_t >& soc); +/** Parse a SoC description from a XML file, append it to . */ +bool soc_desc_parse_xml(const std::string& filename, soc_t& soc); +/** Write a SoC description to a XML file, overwriting it. A file can contain + * multiple Soc descriptions */ +bool soc_desc_produce_xml(const std::string& filename, const soc_t& soc); +/** Normalise a soc description by reordering elemnts so that: + * - devices are sorted by first name + * - registers are sorted by first address + * - fields are sorted by last bit + * - values are sorted by value */ +void soc_desc_normalize(soc_t& soc); +/** Formula parser: try to parse and evaluate a formula to a specific value of 'n' */ +bool soc_desc_evaluate_formula(const std::string& formula, + const std::map< std::string, soc_word_t>& var, soc_word_t& result, std::string& error); #endif /* __SOC_DESC__ */ \ No newline at end of file -- cgit v1.2.3