summaryrefslogtreecommitdiff
path: root/utils/regtools/lib/soc_desc.hpp
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-04-07 11:28:04 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-05-01 19:34:18 +0200
commit4356666101e0e7985e65a19f86bc4a74519e93f9 (patch)
treebf8de8057d93d0fab0a30cae92a90f5a4edc79dc /utils/regtools/lib/soc_desc.hpp
parent3754624edc48539c5cc5acbf426ce909477e87d8 (diff)
downloadrockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.tar.gz
rockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.zip
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 <soc> was the root tag). Also introduce a DTD to validate the files. Change-Id: If70ba35b6dc0242bdb87411cf4baee9597798aac
Diffstat (limited to 'utils/regtools/lib/soc_desc.hpp')
-rw-r--r--utils/regtools/lib/soc_desc.hpp49
1 files changed, 46 insertions, 3 deletions
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 @@
25#include <vector> 25#include <vector>
26#include <list> 26#include <list>
27#include <string> 27#include <string>
28#include <map>
28 29
29/** 30/**
30 * These data structures represent the SoC register in a convenient way. 31 * These data structures represent the SoC register in a convenient way.
@@ -50,6 +51,21 @@ typedef uint32_t soc_addr_t;
50typedef uint32_t soc_word_t; 51typedef uint32_t soc_word_t;
51typedef uint32_t soc_reg_flags_t; 52typedef uint32_t soc_reg_flags_t;
52 53
54/** SoC error gravity level */
55enum soc_error_level_t
56{
57 SOC_ERROR_WARNING,
58 SOC_ERROR_FATAL,
59};
60
61/** SoC description error */
62struct soc_error_t
63{
64 soc_error_level_t level; /// level (warning, fatal, ...)
65 std::string location; /// human description of the location
66 std::string message; /// message
67};
68
53/** SoC register generic formula */ 69/** SoC register generic formula */
54enum soc_reg_formula_type_t 70enum soc_reg_formula_type_t
55{ 71{
@@ -66,6 +82,8 @@ struct soc_reg_field_value_t
66 std::string name; /// name of the value 82 std::string name; /// name of the value
67 soc_word_t value; /// numeric value 83 soc_word_t value; /// numeric value
68 std::string desc; /// human description 84 std::string desc; /// human description
85
86 std::vector< soc_error_t > errors(bool recursive);
69}; 87};
70 88
71/** SoC register field */ 89/** SoC register field */
@@ -90,6 +108,8 @@ struct soc_reg_field_t
90 } 108 }
91 109
92 std::vector< soc_reg_field_value_t > value; 110 std::vector< soc_reg_field_value_t > value;
111
112 std::vector< soc_error_t > errors(bool recursive);
93}; 113};
94 114
95/** SoC register address */ 115/** SoC register address */
@@ -97,6 +117,8 @@ struct soc_reg_addr_t
97{ 117{
98 std::string name; /// actual register name 118 std::string name; /// actual register name
99 soc_addr_t addr; /// actual register address (relative to device) 119 soc_addr_t addr; /// actual register address (relative to device)
120
121 std::vector< soc_error_t > errors(bool recursive);
100}; 122};
101 123
102/** SoC register formula */ 124/** SoC register formula */
@@ -104,6 +126,8 @@ struct soc_reg_formula_t
104{ 126{
105 enum soc_reg_formula_type_t type; 127 enum soc_reg_formula_type_t type;
106 std::string string; /// for STRING 128 std::string string; /// for STRING
129
130 std::vector< soc_error_t > errors(bool recursive);
107}; 131};
108 132
109/** SoC register */ 133/** SoC register */
@@ -116,6 +140,8 @@ struct soc_reg_t
116 soc_reg_flags_t flags; /// ORed value 140 soc_reg_flags_t flags; /// ORed value
117 141
118 std::vector< soc_reg_field_t > field; 142 std::vector< soc_reg_field_t > field;
143
144 std::vector< soc_error_t > errors(bool recursive);
119}; 145};
120 146
121/** Soc device address */ 147/** Soc device address */
@@ -123,6 +149,8 @@ struct soc_dev_addr_t
123{ 149{
124 std::string name; /// actual device name 150 std::string name; /// actual device name
125 soc_addr_t addr; 151 soc_addr_t addr;
152
153 std::vector< soc_error_t > errors(bool recursive);
126}; 154};
127 155
128/** SoC device */ 156/** SoC device */
@@ -135,6 +163,8 @@ struct soc_dev_t
135 std::vector< soc_dev_addr_t > addr; 163 std::vector< soc_dev_addr_t > addr;
136 164
137 std::vector< soc_reg_t > reg; 165 std::vector< soc_reg_t > reg;
166
167 std::vector< soc_error_t > errors(bool recursive);
138}; 168};
139 169
140/** SoC */ 170/** SoC */
@@ -144,10 +174,23 @@ struct soc_t
144 std::string desc; /// SoC name 174 std::string desc; /// SoC name
145 175
146 std::vector< soc_dev_t > dev; 176 std::vector< soc_dev_t > dev;
177
178 std::vector< soc_error_t > errors(bool recursive);
147}; 179};
148 180
149/** Parse a SoC description from a XML file, append it to <soc>. A file 181/** Parse a SoC description from a XML file, append it to <soc>. */
150 * can contain multiple SoC descriptions */ 182bool soc_desc_parse_xml(const std::string& filename, soc_t& soc);
151bool soc_desc_parse_xml(const std::string& filename, std::vector< soc_t >& soc); 183/** Write a SoC description to a XML file, overwriting it. A file can contain
184 * multiple Soc descriptions */
185bool soc_desc_produce_xml(const std::string& filename, const soc_t& soc);
186/** Normalise a soc description by reordering elemnts so that:
187 * - devices are sorted by first name
188 * - registers are sorted by first address
189 * - fields are sorted by last bit
190 * - values are sorted by value */
191void soc_desc_normalize(soc_t& soc);
192/** Formula parser: try to parse and evaluate a formula to a specific value of 'n' */
193bool soc_desc_evaluate_formula(const std::string& formula,
194 const std::map< std::string, soc_word_t>& var, soc_word_t& result, std::string& error);
152 195
153#endif /* __SOC_DESC__ */ \ No newline at end of file 196#endif /* __SOC_DESC__ */ \ No newline at end of file