diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-11-25 23:22:28 +0000 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-11-26 00:29:48 +0100 |
commit | f04d3c518a3c26def9a003a108bec254499c7c90 (patch) | |
tree | a32a8022ad9c7d6de94bc031dcbd0e12278a1e57 /utils/regtools | |
parent | ef2b6db066dc1b25863887eec0b65dadc8e54bb3 (diff) | |
download | rockbox-f04d3c518a3c26def9a003a108bec254499c7c90.tar.gz rockbox-f04d3c518a3c26def9a003a108bec254499c7c90.zip |
regtools: add shortcut notation for simple register in the desc files
Change-Id: I2745287844ad0a47dd41ba4dae5e1f7218ae5814
Reviewed-on: http://gerrit.rockbox.org/679
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'utils/regtools')
-rw-r--r-- | utils/regtools/desc/XML.txt | 13 | ||||
-rw-r--r-- | utils/regtools/lib/soc_desc.cpp | 15 |
2 files changed, 26 insertions, 2 deletions
diff --git a/utils/regtools/desc/XML.txt b/utils/regtools/desc/XML.txt index d4dc73cc64..15164a43b9 100644 --- a/utils/regtools/desc/XML.txt +++ b/utils/regtools/desc/XML.txt | |||
@@ -61,12 +61,25 @@ The following properties are defined: | |||
61 | - "name" (mandatory,string): the mnemonic of the register. | 61 | - "name" (mandatory,string): the mnemonic of the register. |
62 | - "sct" (optional,"yes" or "no"): STMP specific attribute to specify the existence | 62 | - "sct" (optional,"yes" or "no"): STMP specific attribute to specify the existence |
63 | of the SCT variants of this register. | 63 | of the SCT variants of this register. |
64 | As a shortcut, in the case the register has a single address, one can add one more | ||
65 | property: | ||
66 | - "addr" (optional,integer): base address of this instance of the register. | ||
64 | 67 | ||
65 | Example: | 68 | Example: |
66 | <reg name="TIMCTRLn" sct="yes"> | 69 | <reg name="TIMCTRLn" sct="yes"> |
67 | <!-- reg desc --> | 70 | <!-- reg desc --> |
68 | </reg> | 71 | </reg> |
69 | 72 | ||
73 | The address shortcut has the following standard translation: | ||
74 | <reg name="GPIO_PADR" addr="0x00"> | ||
75 | <!-- bla --> | ||
76 | </reg> | ||
77 | is equivalent to: | ||
78 | <reg name="GPIO_PADR"> | ||
79 | <addr name="GPIO_PADR" addr="0x00"> | ||
80 | <!-- bla --> | ||
81 | </reg> | ||
82 | |||
70 | Element: soc.dev.reg.addr | 83 | Element: soc.dev.reg.addr |
71 | ------------------------- | 84 | ------------------------- |
72 | Each device can have one or more addresses associated with it. Each address | 85 | Each device can have one or more addresses associated with it. Each address |
diff --git a/utils/regtools/lib/soc_desc.cpp b/utils/regtools/lib/soc_desc.cpp index 413c30936f..4b9f51b9ae 100644 --- a/utils/regtools/lib/soc_desc.cpp +++ b/utils/regtools/lib/soc_desc.cpp | |||
@@ -102,8 +102,8 @@ bool validate_uint32_hook(const std::string& str, uint32_t& s) | |||
102 | { | 102 | { |
103 | unsigned long u; | 103 | unsigned long u; |
104 | if(!validate_unsigned_long_hook(str, u)) return false; | 104 | if(!validate_unsigned_long_hook(str, u)) return false; |
105 | #if ULONG_MAX > UINT32_MAX | 105 | #if ULONG_MAX > 0xffffffff |
106 | if(u > UINT32_MAX) return false; | 106 | if(u > 0xffffffff) return false; |
107 | #endif | 107 | #endif |
108 | s = u; | 108 | s = u; |
109 | return true; | 109 | return true; |
@@ -177,12 +177,23 @@ bool parse_reg_formula_elem(xmlNode *node, soc_reg_formula_t& formula) | |||
177 | return true; | 177 | return true; |
178 | } | 178 | } |
179 | 179 | ||
180 | bool parse_add_trivial_addr(const std::string& str, soc_reg_t& reg) | ||
181 | { | ||
182 | soc_reg_addr_t a; | ||
183 | a.name = reg.name; | ||
184 | if(!validate_uint32_hook(str, a.addr)) | ||
185 | return false; | ||
186 | reg.addr.push_back(a); | ||
187 | return true; | ||
188 | } | ||
189 | |||
180 | bool parse_reg_elem(xmlNode *node, soc_reg_t& reg) | 190 | bool parse_reg_elem(xmlNode *node, soc_reg_t& reg) |
181 | { | 191 | { |
182 | std::vector< soc_reg_formula_t > formulas; | 192 | std::vector< soc_reg_formula_t > formulas; |
183 | BEGIN_ATTR_MATCH(node->properties) | 193 | BEGIN_ATTR_MATCH(node->properties) |
184 | MATCH_TEXT_ATTR("name", reg.name) | 194 | MATCH_TEXT_ATTR("name", reg.name) |
185 | SOFT_MATCH_SCT_ATTR("sct", reg.flags) | 195 | SOFT_MATCH_SCT_ATTR("sct", reg.flags) |
196 | SOFT_MATCH_X_ATTR("addr", parse_add_trivial_addr, reg) | ||
186 | END_ATTR_MATCH() | 197 | END_ATTR_MATCH() |
187 | 198 | ||
188 | BEGIN_NODE_MATCH(node->children) | 199 | BEGIN_NODE_MATCH(node->children) |