summaryrefslogtreecommitdiff
path: root/utils/regtools/lib/soc_desc.hpp
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-10-22 17:51:09 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-12-15 22:53:57 +0100
commit6cb861137d40c91782042764c591ceb995f345fa (patch)
treed41edb2a7d49a3f32c5c9d8eb0ec272be4974e8d /utils/regtools/lib/soc_desc.hpp
parent7749c4d0e960b3e4f92194bd8f63ed70cc9bcb31 (diff)
downloadrockbox-6cb861137d40c91782042764c591ceb995f345fa.tar.gz
rockbox-6cb861137d40c91782042764c591ceb995f345fa.zip
regtools/socdesc: update library with a field useful functions
Change-Id: Ib2891fe36b0594e8554bb354a29bc8b3485de20d Reviewed-on: http://gerrit.rockbox.org/1018 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'utils/regtools/lib/soc_desc.hpp')
-rw-r--r--utils/regtools/lib/soc_desc.hpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/utils/regtools/lib/soc_desc.hpp b/utils/regtools/lib/soc_desc.hpp
index 1b4985529c..bb8eb4ba8d 100644
--- a/utils/regtools/lib/soc_desc.hpp
+++ b/utils/regtools/lib/soc_desc.hpp
@@ -46,7 +46,7 @@
46 */ 46 */
47 47
48#define SOCDESC_VERSION_MAJOR 1 48#define SOCDESC_VERSION_MAJOR 1
49#define SOCDESC_VERSION_MINOR 1 49#define SOCDESC_VERSION_MINOR 4
50#define SOCDESC_VERSION_REV 1 50#define SOCDESC_VERSION_REV 1
51 51
52#define SOCDESC_VERSION__(maj,min,rev) #maj"."#min"."#rev 52#define SOCDESC_VERSION__(maj,min,rev) #maj"."#min"."#rev
@@ -103,6 +103,7 @@ struct soc_reg_field_t
103 103
104 soc_reg_field_t():first_bit(0), last_bit(31) {} 104 soc_reg_field_t():first_bit(0), last_bit(31) {}
105 105
106 /** Return field bitmask in register */
106 soc_word_t bitmask() const 107 soc_word_t bitmask() const
107 { 108 {
108 // WARNING beware of the case where first_bit=0 and last_bit=31 109 // WARNING beware of the case where first_bit=0 and last_bit=31
@@ -112,11 +113,32 @@ struct soc_reg_field_t
112 return ((1 << (last_bit - first_bit + 1)) - 1) << first_bit; 113 return ((1 << (last_bit - first_bit + 1)) - 1) << first_bit;
113 } 114 }
114 115
116 /** Extract field value from register value */
117 soc_word_t extract(soc_word_t reg_val) const
118 {
119 return (reg_val & bitmask()) >> first_bit;
120 }
121
122 /** Replace the field value in a register value */
123 soc_word_t replace(soc_word_t reg_val, soc_word_t field_val) const
124 {
125 return (reg_val & ~bitmask()) | ((field_val << first_bit) & bitmask());
126 }
127
115 bool is_reserved() const 128 bool is_reserved() const
116 { 129 {
117 return name.substr(0, 4) == "RSVD" || name.substr(0, 5) == "RSRVD"; 130 return name.substr(0, 4) == "RSVD" || name.substr(0, 5) == "RSRVD";
118 } 131 }
119 132
133 /** Return field value index, or -1 if none */
134 int find_value(soc_word_t v) const
135 {
136 for(size_t i = 0; i < value.size(); i++)
137 if(value[i].value == v)
138 return i;
139 return -1;
140 }
141
120 std::vector< soc_reg_field_value_t > value; 142 std::vector< soc_reg_field_value_t > value;
121 143
122 std::vector< soc_error_t > errors(bool recursive); 144 std::vector< soc_error_t > errors(bool recursive);