forked from ParaStation/pscom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.pl
executable file
·130 lines (113 loc) · 2.64 KB
/
convert.pl
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/perl
{
$type = shift(@ARGV) || die "Bad args to convert.pl\n";
if ($type == 7) {
$lanai = "LANai7.x";
}
elsif ($type == 4) {
$lanai = "LANai4.x";
}
elsif ($type == 2) {
$lanai = "LANai2.3";
$type = "";
}
else {
die "Bad args to convert.pl type = '$type' \n"
}
$width = shift(@ARGV) || "short";
if ($width eq "short") {
$w = 2;
}
elsif ($width eq "char") {
$w = 1;
}
else {
die "Bad width arg '$width'\n";
exit;
}
$count = 0;
$doing_symbols = 0;
print "/* This is the Myrinet MCP code for $lanai */ \n";
print "/* Generated by cat \$MYRI_HOME/lib/lanai/mcp$type.dat > myri_code$type.h */\n";
print "\n";
while (<STDIN>) {
if ($doing_symbols) {
if ($_ =~ /(\w\w\w\w) (\S+)/) {
if (!($2 =~ /\_\_/)) {
$offset = $1;
$name = $2;
if (($name =~ /\*\S+/) ||
($name =~ /\.\S+/) ||
($name eq "fake") ||
($name =~ /^K\d+/) ||
($name =~ /gcc_compil/) ||
($name =~ /gcc2_compil/) ) {
# do nothing
}
else {
$mname = "MYRI" . $name;
printf("#define %-28s 0x$offset\n",$mname);
}
}
else {
# print "1:$_";
}
}
else {
# print "2:$_";
}
}
elsif ($_ =~ /\@T (\w\w\w\w) (\w\w\w\w)/) {
if ($width eq "short") {
$size = hex($2) * 1;
}
else {
$size = hex($2) * 2;
}
printf("static unsigned int lanai%s_code_off = 0x%s; /* half-word offset */ \n", $type, $1);
printf("static unsigned int lanai%s_code_size = $size;\n",$type);
printf("static unsigned $width lanai%s_code[$size] = {\n",$type);
}
elsif ($_ =~ /\@D (\w\w\w\w) (\w\w\w\w)/) {
if ($count) {
print "} ;\n";
$count = 0;
}
if ($width eq "short") {
$size = hex($2) * 1;
}
else {
$size = hex($2) * 2;
}
printf("\n\n");
printf("/* This is the LANai data */ \n\n");
printf("static unsigned int lanai%s_data_off = 0x%s; /* half-word offset */\n", $type, $1);
printf("static unsigned int lanai%s_data_size = $size;\n",$type);
printf("static unsigned $width lanai%s_data[$size] = {\n",$type);
}
elsif ($_ =~ /\@S/) {
print "} ;\n";
$doing_symbols = 1;
print "\n\n#ifdef SYMBOL_DEFINES_COMPILED\n";
print "/* These are half-word addresses - NOT byte offsets */\n";
}
elsif (!($_ =~ /^@/)) {
if ($_ =~ /^(\w\w)(\w\w)/) {
if ($w == 2) {
printf("0x%s%s, ", $1,$2);
if (!($count % 8)) {
print "\n";
}
}
else {
printf("0x%s,0x%s, ", $1,$2);
if (!($count % 8)) {
print "\n";
}
}
$count++;
}
}
}
print "\n#endif SYMBOL_DEFINES_COMPILED\n";
}