diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2014-10-22 17:51:09 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2014-12-15 22:53:57 +0100 |
commit | 6cb861137d40c91782042764c591ceb995f345fa (patch) | |
tree | d41edb2a7d49a3f32c5c9d8eb0ec272be4974e8d | |
parent | 7749c4d0e960b3e4f92194bd8f63ed70cc9bcb31 (diff) | |
download | rockbox-6cb8611.tar.gz rockbox-6cb8611.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>
-rw-r--r-- | utils/regtools/lib/soc_desc.hpp | 24 |
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 @@ */ #define SOCDESC_VERSION_MAJOR 1 -#define SOCDESC_VERSION_MINOR 1 +#define SOCDESC_VERSION_MINOR 4 #define SOCDESC_VERSION_REV 1 #define SOCDESC_VERSION__(maj,min,rev) #maj"."#min"."#rev @@ -103,6 +103,7 @@ struct soc_reg_field_t soc_reg_field_t():first_bit(0), last_bit(31) {} + /** Return field bitmask in register */ soc_word_t bitmask() const { // WARNING beware of the case where first_bit=0 and last_bit=31 @@ -112,11 +113,32 @@ struct soc_reg_field_t return ((1 << (last_bit - first_bit + 1)) - 1) << first_bit; } + /** Extract field value from register value */ + soc_word_t extract(soc_word_t reg_val) const + { + return (reg_val & bitmask()) >> first_bit; + } + + /** Replace the field value in a register value */ + soc_word_t replace(soc_word_t reg_val, soc_word_t field_val) const + { + return (reg_val & ~bitmask()) | ((field_val << first_bit) & bitmask()); + } + bool is_reserved() const { return name.substr(0, 4) == "RSVD" || name.substr(0, 5) == "RSRVD"; } + /** Return field value index, or -1 if none */ + int find_value(soc_word_t v) const + { + for(size_t i = 0; i < value.size(); i++) + if(value[i].value == v) + return i; + return -1; + } + std::vector< soc_reg_field_value_t > value; std::vector< soc_error_t > errors(bool recursive); |