diff options
author | Bill Richardson <wfrichar@chromium.org> | 2015-10-15 13:45:34 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-10-15 18:08:37 -0700 |
commit | fb0eca2ba6652a4cdc4a478db44420d0fea71916 (patch) | |
tree | 442084b495df3c40d8d3300470dc6444b77ee218 /util | |
parent | 50b1a9de02ab8149a43099abd0c68bcac0a420eb (diff) | |
download | chrome-ec-fb0eca2ba6652a4cdc4a478db44420d0fea71916.tar.gz |
Cr50: Check in the script for cr50_fpga_regdefs.h
We've been converting the FPGA headers to our headers using a
script that we've passed around via email. Let's check it in so
we don't diverge.
BUG=none
BRANCH=none
TEST=manual
Run ./util/cr50_regs on the latest FPGA header, compare the
output with chip/g/cr50_fpga_regdefs.h. They match.
Change-Id: I6b435755a047265ea91d1af4e3e753e7555d149d
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/306290
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'util')
-rwxr-xr-x | util/cr50_regs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/util/cr50_regs b/util/cr50_regs new file mode 100755 index 0000000000..2ac117f4a6 --- /dev/null +++ b/util/cr50_regs @@ -0,0 +1,72 @@ +#!/usr/bin/perl +# Copyright 2015 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +use strict; +our $opt_D; + +use File::Basename; +my $progdir = dirname($0); +my $prog = basename($0); + +use Getopt::Std; +my $usage = " +Usage: $prog [HEADER] + +This converts the FPGA release's generated C header file into the +cr50_fpga_regdefs.h file that is included by chip/g/registers.h. +Mostly it just prefaces the macros with GC_ to avoid name collision. + +"; +getopts('D') or die $usage; + + +print "/* + * Copyright 2015 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* This file is autogenerated by the $prog utility. Do not edit. */ + +"; + +while(<>) +{ + if ( s/\b\w+_REGDEFS_H/__EC_CHIP_G_CR50_FPGA_REGDEFS_H/g ) + { + print; + next; + } + + if ( s/__ENABLE_FLASH_DFT_DEFINITIONS__/GC__ENABLE_FLASH_DFT_DEFINITIONS__/g ) + { + print; + next; + } + + if ( s/\bFLASH_DFT/GC_FLASH_DFT/g ) + { + print; + next; + } + + if ( m/^#define\s+(\S+)\s+(\S+)\s*$/ ) + { + my ($k,$v) = ($1,$2); + + if ($k =~ m/^IRQNUM/) { + # irqnums must be decimal + $v = 0 + hex($v); + } + printf("#define %-40s %s\n", "GC_$k", $v); + next; + } + + next if m!//!; + next if m!/\*! .. m!\*/!; + + print; +} + |