Add support for aliased definitions.
authorJeremy Kerr <jk@ozlabs.org>
Tue, 21 Nov 2006 04:33:35 +0000 (15:33 +1100)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 12 Nov 2009 23:58:44 +0000 (10:58 +1100)
Allows defintions to be linked with the 'alias:' conf syntax. For example:

[MSR]
alias: MSR_64

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
bitfield

index 27605d33bf3a7cdcb52e3f3f686f8b0c71b43a89..71e495813fb2bc788f1460e08959e00fdf761e49 100644 (file)
--- a/bitfield
+++ b/bitfield
@@ -130,6 +130,7 @@ def parse_config(bnf, regs, file):
                # default to 64 bit registers
                width = 64
                name = None
                # default to 64 bit registers
                width = 64
                name = None
+               alias_id = None
                fields = []
 
                for t in ts:
                fields = []
 
                for t in ts:
@@ -154,6 +155,22 @@ def parse_config(bnf, regs, file):
                                                "Invalid value in %s" % id)
 
                                fields[-1].add_value(v[0], v[1])
                                                "Invalid value in %s" % id)
 
                                fields[-1].add_value(v[0], v[1])
+                       elif t[0] == 'alias':
+                               alias_id = t[1].strip()
+
+               if alias_id is not None:
+                       if name is not None or fields != []:
+                               raise ConfigurationError(file, ("Definiton " \
+                                       + "for %s is an alias, but has other " \
+                                       + "attributes") % id)
+
+                       if not regs.has_key(alias_id):
+                               raise ConfigurationError(file, "Aliasing "
+                                       "non-existent register %s (from %s)" \
+                                       % (alias_id, id))
+
+                       regs[id] = regs[alias_id]
+                       continue
 
                if name is None or name == '':
                        raise ConfigurationError(file,
 
                if name is None or name == '':
                        raise ConfigurationError(file,