Esempio n. 1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--chip',
        dest='chips',
        type=str,
        nargs='*',
        help='Chip for which to generate the header (all chips if unspecified)'
    )
    parser.add_argument('--sort',
                        choices=['name', 'address'],
                        default='address',
                        help='Sort key for registers, fields, and enum values')
    parser.add_argument('--guard', type=str, help='Name of the #include guard')
    parser.add_argument('files',
                        metavar='FILE',
                        type=str,
                        nargs='+',
                        help='Register database file')
    args = parser.parse_args()

    regdb = None
    for filename in args.files:
        with open(filename, 'r') as filp:
            db = RegisterDatabase.from_json(json.load(filp))
            if regdb is None:
                regdb = db
            else:
                regdb.update(db)

    deduplicate_enums(regdb)
    deduplicate_register_types(regdb)

    w = HeaderWriter(regdb, guard=args.guard)
    w.print(sys.stdout, sort=args.sort)
Esempio n. 2
0
def main():
    map_to = sys.argv[1]

    parser = HeaderParser(map_to)
    parser.parse_header(sys.stdin)

    deduplicate_enums(parser.regdb)
    deduplicate_register_types(parser.regdb)

    print(parser.regdb.encode_json_pretty())
Esempio n. 3
0
def main():
    regdb = RegisterDatabase()
    for filename in sys.argv[1:]:
        with open(filename, 'r') as filp:
            regdb.update(RegisterDatabase.from_json(json.load(filp)))

    deduplicate_enums(regdb)
    deduplicate_register_types(regdb)

    print(regdb.encode_json_pretty())
Esempio n. 4
0
def json_canonicalize(filp, chips = None):
    regdb = RegisterDatabase.from_json(json.load(filp))

    if chips is not None:
        for regmap in regdb.register_mappings():
            assert not hasattr(regmap, 'chips')
            regmap.chips = [chips]

    deduplicate_enums(regdb)
    deduplicate_register_types(regdb)
    deduce_missing_register_types(regdb)
    regdb.garbage_collect()

    return regdb.encode_json_pretty()
Esempio n. 5
0
def main():
    regdb_filename = sys.argv[1]
    with open(regdb_filename, 'r') as filp:
        regdb = RegisterDatabase.from_json(json.load(filp))

    if len(sys.argv) > 2:
        for regmap in regdb.register_mappings():
            assert not hasattr(regmap, 'chips')
            regmap.chips = [sys.argv[2]]

    deduplicate_enums(regdb)
    deduplicate_register_types(regdb)
    deduce_missing_register_types(regdb)
    regdb.garbage_collect()

    print(regdb.encode_json_pretty())