blob: 28e6f4a53dbd79aa31b39e89ace0bece6a67f887 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#!/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
hw_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);
}
$k = "GC_$k";
printf("#define %-40s %s\n", $k, $v);
if ( $k =~ m/0_BASE_ADDR$/ ) {
$k =~ s/0_BASE_ADDR/_BASE_ADDR/;
printf("#define %-40s %s\n", $k, $v);
}
next;
}
next if m!//!;
next if m!/\*! .. m!\*/!;
print;
}
|