mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 12:45:26 -05:00
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>
This commit is contained in:
parent
7749c4d0e9
commit
6cb861137d
1 changed files with 23 additions and 1 deletions
|
|
@ -46,7 +46,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SOCDESC_VERSION_MAJOR 1
|
#define SOCDESC_VERSION_MAJOR 1
|
||||||
#define SOCDESC_VERSION_MINOR 1
|
#define SOCDESC_VERSION_MINOR 4
|
||||||
#define SOCDESC_VERSION_REV 1
|
#define SOCDESC_VERSION_REV 1
|
||||||
|
|
||||||
#define SOCDESC_VERSION__(maj,min,rev) #maj"."#min"."#rev
|
#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) {}
|
soc_reg_field_t():first_bit(0), last_bit(31) {}
|
||||||
|
|
||||||
|
/** Return field bitmask in register */
|
||||||
soc_word_t bitmask() const
|
soc_word_t bitmask() const
|
||||||
{
|
{
|
||||||
// WARNING beware of the case where first_bit=0 and last_bit=31
|
// 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;
|
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
|
bool is_reserved() const
|
||||||
{
|
{
|
||||||
return name.substr(0, 4) == "RSVD" || name.substr(0, 5) == "RSRVD";
|
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_reg_field_value_t > value;
|
||||||
|
|
||||||
std::vector< soc_error_t > errors(bool recursive);
|
std::vector< soc_error_t > errors(bool recursive);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue