diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-01-15 12:27:20 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-01-15 12:27:20 -0500 |
commit | c0106d72b8d71696dbe9dc80e2c77d4ac63f7531 (patch) | |
tree | ca96d2baecb0555e36219ed6968dc8e306e530ca /scripts | |
parent | 5852973c129cf7c7e6c229abb7250673fc2a50c9 (diff) | |
parent | eff317d0834ad1ff03f747f6bc2d76b9a9c95160 (diff) |
Merge branch 'topic/asoc' into next/asoc
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/.gitignore | 1 | ||||
-rw-r--r-- | scripts/Makefile | 3 | ||||
-rw-r--r-- | scripts/bootgraph.pl | 56 | ||||
-rwxr-xr-x | scripts/checkpatch.pl | 172 | ||||
-rwxr-xr-x | scripts/config | 150 | ||||
-rw-r--r-- | scripts/headers_check.pl | 70 | ||||
-rw-r--r-- | scripts/headers_install.pl | 3 | ||||
-rw-r--r-- | scripts/ihex2fw.c | 268 | ||||
-rw-r--r-- | scripts/kconfig/expr.h | 82 | ||||
-rw-r--r-- | scripts/kconfig/lex.zconf.c_shipped | 7 | ||||
-rw-r--r-- | scripts/kconfig/zconf.l | 7 | ||||
-rw-r--r-- | scripts/markup_oops.pl | 203 | ||||
-rwxr-xr-x | scripts/tags.sh | 19 |
13 files changed, 951 insertions, 90 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore index b939fbd01195..09e2406f3b78 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore | |||
@@ -1,6 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Generated files | 2 | # Generated files |
3 | # | 3 | # |
4 | ihex2fw | ||
4 | conmakehash | 5 | conmakehash |
5 | kallsyms | 6 | kallsyms |
6 | pnmtologo | 7 | pnmtologo |
diff --git a/scripts/Makefile b/scripts/Makefile index aafdf064feef..035182e16afb 100644 --- a/scripts/Makefile +++ b/scripts/Makefile | |||
@@ -2,11 +2,12 @@ | |||
2 | # scripts contains sources for various helper programs used throughout | 2 | # scripts contains sources for various helper programs used throughout |
3 | # the kernel for the build process. | 3 | # the kernel for the build process. |
4 | # --------------------------------------------------------------------------- | 4 | # --------------------------------------------------------------------------- |
5 | # ihex2fw: Parser/loader for IHEX formatted data | ||
5 | # kallsyms: Find all symbols in vmlinux | 6 | # kallsyms: Find all symbols in vmlinux |
6 | # pnmttologo: Convert pnm files to logo files | 7 | # pnmttologo: Convert pnm files to logo files |
7 | # conmakehash: Create chartable | ||
8 | # conmakehash: Create arrays for initializing the kernel console tables | 8 | # conmakehash: Create arrays for initializing the kernel console tables |
9 | 9 | ||
10 | hostprogs-y := ihex2fw | ||
10 | hostprogs-$(CONFIG_KALLSYMS) += kallsyms | 11 | hostprogs-$(CONFIG_KALLSYMS) += kallsyms |
11 | hostprogs-$(CONFIG_LOGO) += pnmtologo | 12 | hostprogs-$(CONFIG_LOGO) += pnmtologo |
12 | hostprogs-$(CONFIG_VT) += conmakehash | 13 | hostprogs-$(CONFIG_VT) += conmakehash |
diff --git a/scripts/bootgraph.pl b/scripts/bootgraph.pl index f0af9aa9b243..b0246307aac4 100644 --- a/scripts/bootgraph.pl +++ b/scripts/bootgraph.pl | |||
@@ -41,11 +41,13 @@ use strict; | |||
41 | 41 | ||
42 | my %start; | 42 | my %start; |
43 | my %end; | 43 | my %end; |
44 | my %type; | ||
44 | my $done = 0; | 45 | my $done = 0; |
45 | my $maxtime = 0; | 46 | my $maxtime = 0; |
46 | my $firsttime = 100; | 47 | my $firsttime = 100; |
47 | my $count = 0; | 48 | my $count = 0; |
48 | my %pids; | 49 | my %pids; |
50 | my %pidctr; | ||
49 | 51 | ||
50 | while (<>) { | 52 | while (<>) { |
51 | my $line = $_; | 53 | my $line = $_; |
@@ -53,6 +55,7 @@ while (<>) { | |||
53 | my $func = $2; | 55 | my $func = $2; |
54 | if ($done == 0) { | 56 | if ($done == 0) { |
55 | $start{$func} = $1; | 57 | $start{$func} = $1; |
58 | $type{$func} = 0; | ||
56 | if ($1 < $firsttime) { | 59 | if ($1 < $firsttime) { |
57 | $firsttime = $1; | 60 | $firsttime = $1; |
58 | } | 61 | } |
@@ -63,12 +66,40 @@ while (<>) { | |||
63 | $count = $count + 1; | 66 | $count = $count + 1; |
64 | } | 67 | } |
65 | 68 | ||
69 | if ($line =~ /([0-9\.]+)\] async_waiting @ ([0-9]+)/) { | ||
70 | my $pid = $2; | ||
71 | my $func; | ||
72 | if (!defined($pidctr{$pid})) { | ||
73 | $func = "wait_" . $pid . "_1"; | ||
74 | $pidctr{$pid} = 1; | ||
75 | } else { | ||
76 | $pidctr{$pid} = $pidctr{$pid} + 1; | ||
77 | $func = "wait_" . $pid . "_" . $pidctr{$pid}; | ||
78 | } | ||
79 | if ($done == 0) { | ||
80 | $start{$func} = $1; | ||
81 | $type{$func} = 1; | ||
82 | if ($1 < $firsttime) { | ||
83 | $firsttime = $1; | ||
84 | } | ||
85 | } | ||
86 | $pids{$func} = $pid; | ||
87 | $count = $count + 1; | ||
88 | } | ||
89 | |||
66 | if ($line =~ /([0-9\.]+)\] initcall ([a-zA-Z0-9\_]+)\+.*returned/) { | 90 | if ($line =~ /([0-9\.]+)\] initcall ([a-zA-Z0-9\_]+)\+.*returned/) { |
67 | if ($done == 0) { | 91 | if ($done == 0) { |
68 | $end{$2} = $1; | 92 | $end{$2} = $1; |
69 | $maxtime = $1; | 93 | $maxtime = $1; |
70 | } | 94 | } |
71 | } | 95 | } |
96 | |||
97 | if ($line =~ /([0-9\.]+)\] async_continuing @ ([0-9]+)/) { | ||
98 | my $pid = $2; | ||
99 | my $func = "wait_" . $pid . "_" . $pidctr{$pid}; | ||
100 | $end{$func} = $1; | ||
101 | $maxtime = $1; | ||
102 | } | ||
72 | if ($line =~ /Write protecting the/) { | 103 | if ($line =~ /Write protecting the/) { |
73 | $done = 1; | 104 | $done = 1; |
74 | } | 105 | } |
@@ -88,7 +119,7 @@ END | |||
88 | } | 119 | } |
89 | 120 | ||
90 | print "<?xml version=\"1.0\" standalone=\"no\"?> \n"; | 121 | print "<?xml version=\"1.0\" standalone=\"no\"?> \n"; |
91 | print "<svg width=\"1000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n"; | 122 | print "<svg width=\"2000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n"; |
92 | 123 | ||
93 | my @styles; | 124 | my @styles; |
94 | 125 | ||
@@ -105,8 +136,11 @@ $styles[9] = "fill:rgb(255,255,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0 | |||
105 | $styles[10] = "fill:rgb(255,128,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; | 136 | $styles[10] = "fill:rgb(255,128,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; |
106 | $styles[11] = "fill:rgb(128,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; | 137 | $styles[11] = "fill:rgb(128,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; |
107 | 138 | ||
108 | my $mult = 950.0 / ($maxtime - $firsttime); | 139 | my $style_wait = "fill:rgb(128,128,128);fill-opacity:0.5;stroke-width:0;stroke:rgb(0,0,0)"; |
109 | my $threshold = ($maxtime - $firsttime) / 60.0; | 140 | |
141 | my $mult = 1950.0 / ($maxtime - $firsttime); | ||
142 | my $threshold2 = ($maxtime - $firsttime) / 120.0; | ||
143 | my $threshold = $threshold2/10; | ||
110 | my $stylecounter = 0; | 144 | my $stylecounter = 0; |
111 | my %rows; | 145 | my %rows; |
112 | my $rowscount = 1; | 146 | my $rowscount = 1; |
@@ -116,7 +150,7 @@ foreach my $key (@initcalls) { | |||
116 | my $duration = $end{$key} - $start{$key}; | 150 | my $duration = $end{$key} - $start{$key}; |
117 | 151 | ||
118 | if ($duration >= $threshold) { | 152 | if ($duration >= $threshold) { |
119 | my ($s, $s2, $e, $w, $y, $y2, $style); | 153 | my ($s, $s2, $s3, $e, $w, $y, $y2, $style); |
120 | my $pid = $pids{$key}; | 154 | my $pid = $pids{$key}; |
121 | 155 | ||
122 | if (!defined($rows{$pid})) { | 156 | if (!defined($rows{$pid})) { |
@@ -125,6 +159,7 @@ foreach my $key (@initcalls) { | |||
125 | } | 159 | } |
126 | $s = ($start{$key} - $firsttime) * $mult; | 160 | $s = ($start{$key} - $firsttime) * $mult; |
127 | $s2 = $s + 6; | 161 | $s2 = $s + 6; |
162 | $s3 = $s + 1; | ||
128 | $e = ($end{$key} - $firsttime) * $mult; | 163 | $e = ($end{$key} - $firsttime) * $mult; |
129 | $w = $e - $s; | 164 | $w = $e - $s; |
130 | 165 | ||
@@ -137,8 +172,17 @@ foreach my $key (@initcalls) { | |||
137 | $stylecounter = 0; | 172 | $stylecounter = 0; |
138 | }; | 173 | }; |
139 | 174 | ||
140 | print "<rect x=\"$s\" width=\"$w\" y=\"$y\" height=\"145\" style=\"$style\"/>\n"; | 175 | if ($type{$key} == 1) { |
141 | print "<text transform=\"translate($s2,$y2) rotate(90)\">$key</text>\n"; | 176 | $y = $y + 15; |
177 | print "<rect x=\"$s\" width=\"$w\" y=\"$y\" height=\"115\" style=\"$style_wait\"/>\n"; | ||
178 | } else { | ||
179 | print "<rect x=\"$s\" width=\"$w\" y=\"$y\" height=\"145\" style=\"$style\"/>\n"; | ||
180 | if ($duration >= $threshold2) { | ||
181 | print "<text transform=\"translate($s2,$y2) rotate(90)\">$key</text>\n"; | ||
182 | } else { | ||
183 | print "<text transform=\"translate($s3,$y2) rotate(90)\" font-size=\"3pt\">$key</text>\n"; | ||
184 | } | ||
185 | } | ||
142 | } | 186 | } |
143 | } | 187 | } |
144 | 188 | ||
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index f88bb3e21cda..7bed4ed2c519 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -1,7 +1,8 @@ | |||
1 | #!/usr/bin/perl -w | 1 | #!/usr/bin/perl -w |
2 | # (c) 2001, Dave Jones. <davej@redhat.com> (the file handling bit) | 2 | # (c) 2001, Dave Jones. <davej@redhat.com> (the file handling bit) |
3 | # (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit) | 3 | # (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit) |
4 | # (c) 2007, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite, etc) | 4 | # (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite) |
5 | # (c) 2008, Andy Whitcroft <apw@canonical.com> | ||
5 | # Licensed under the terms of the GNU GPL License version 2 | 6 | # Licensed under the terms of the GNU GPL License version 2 |
6 | 7 | ||
7 | use strict; | 8 | use strict; |
@@ -9,7 +10,7 @@ use strict; | |||
9 | my $P = $0; | 10 | my $P = $0; |
10 | $P =~ s@.*/@@g; | 11 | $P =~ s@.*/@@g; |
11 | 12 | ||
12 | my $V = '0.24'; | 13 | my $V = '0.26'; |
13 | 14 | ||
14 | use Getopt::Long qw(:config no_auto_abbrev); | 15 | use Getopt::Long qw(:config no_auto_abbrev); |
15 | 16 | ||
@@ -68,7 +69,9 @@ my $dbg_possible = 0; | |||
68 | my $dbg_type = 0; | 69 | my $dbg_type = 0; |
69 | my $dbg_attr = 0; | 70 | my $dbg_attr = 0; |
70 | for my $key (keys %debug) { | 71 | for my $key (keys %debug) { |
71 | eval "\${dbg_$key} = '$debug{$key}';" | 72 | ## no critic |
73 | eval "\${dbg_$key} = '$debug{$key}';"; | ||
74 | die "$@" if ($@); | ||
72 | } | 75 | } |
73 | 76 | ||
74 | if ($terse) { | 77 | if ($terse) { |
@@ -116,7 +119,8 @@ our $Attribute = qr{ | |||
116 | __(?:mem|cpu|dev|)(?:initdata|init)| | 119 | __(?:mem|cpu|dev|)(?:initdata|init)| |
117 | ____cacheline_aligned| | 120 | ____cacheline_aligned| |
118 | ____cacheline_aligned_in_smp| | 121 | ____cacheline_aligned_in_smp| |
119 | ____cacheline_internodealigned_in_smp | 122 | ____cacheline_internodealigned_in_smp| |
123 | __weak | ||
120 | }x; | 124 | }x; |
121 | our $Modifier; | 125 | our $Modifier; |
122 | our $Inline = qr{inline|__always_inline|noinline}; | 126 | our $Inline = qr{inline|__always_inline|noinline}; |
@@ -125,6 +129,7 @@ our $Lval = qr{$Ident(?:$Member)*}; | |||
125 | 129 | ||
126 | our $Constant = qr{(?:[0-9]+|0x[0-9a-fA-F]+)[UL]*}; | 130 | our $Constant = qr{(?:[0-9]+|0x[0-9a-fA-F]+)[UL]*}; |
127 | our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)}; | 131 | our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)}; |
132 | our $Compare = qr{<=|>=|==|!=|<|>}; | ||
128 | our $Operators = qr{ | 133 | our $Operators = qr{ |
129 | <=|>=|==|!=| | 134 | <=|>=|==|!=| |
130 | =>|->|<<|>>|<|>|!|~| | 135 | =>|->|<<|>>|<|>|!|~| |
@@ -190,7 +195,7 @@ sub build_types { | |||
190 | }x; | 195 | }x; |
191 | $Type = qr{ | 196 | $Type = qr{ |
192 | $NonptrType | 197 | $NonptrType |
193 | (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)? | 198 | (?:[\s\*]+\s*const|[\s\*]+|(?:\s*\[\s*\])+)? |
194 | (?:\s+$Inline|\s+$Modifier)* | 199 | (?:\s+$Inline|\s+$Modifier)* |
195 | }x; | 200 | }x; |
196 | $Declare = qr{(?:$Storage\s+)?$Type}; | 201 | $Declare = qr{(?:$Storage\s+)?$Type}; |
@@ -203,9 +208,9 @@ my @dep_includes = (); | |||
203 | my @dep_functions = (); | 208 | my @dep_functions = (); |
204 | my $removal = "Documentation/feature-removal-schedule.txt"; | 209 | my $removal = "Documentation/feature-removal-schedule.txt"; |
205 | if ($tree && -f "$root/$removal") { | 210 | if ($tree && -f "$root/$removal") { |
206 | open(REMOVE, "<$root/$removal") || | 211 | open(my $REMOVE, '<', "$root/$removal") || |
207 | die "$P: $removal: open failed - $!\n"; | 212 | die "$P: $removal: open failed - $!\n"; |
208 | while (<REMOVE>) { | 213 | while (<$REMOVE>) { |
209 | if (/^Check:\s+(.*\S)/) { | 214 | if (/^Check:\s+(.*\S)/) { |
210 | for my $entry (split(/[, ]+/, $1)) { | 215 | for my $entry (split(/[, ]+/, $1)) { |
211 | if ($entry =~ m@include/(.*)@) { | 216 | if ($entry =~ m@include/(.*)@) { |
@@ -217,17 +222,21 @@ if ($tree && -f "$root/$removal") { | |||
217 | } | 222 | } |
218 | } | 223 | } |
219 | } | 224 | } |
225 | close($REMOVE); | ||
220 | } | 226 | } |
221 | 227 | ||
222 | my @rawlines = (); | 228 | my @rawlines = (); |
223 | my @lines = (); | 229 | my @lines = (); |
224 | my $vname; | 230 | my $vname; |
225 | for my $filename (@ARGV) { | 231 | for my $filename (@ARGV) { |
232 | my $FILE; | ||
226 | if ($file) { | 233 | if ($file) { |
227 | open(FILE, "diff -u /dev/null $filename|") || | 234 | open($FILE, '-|', "diff -u /dev/null $filename") || |
228 | die "$P: $filename: diff failed - $!\n"; | 235 | die "$P: $filename: diff failed - $!\n"; |
236 | } elsif ($filename eq '-') { | ||
237 | open($FILE, '<&STDIN'); | ||
229 | } else { | 238 | } else { |
230 | open(FILE, "<$filename") || | 239 | open($FILE, '<', "$filename") || |
231 | die "$P: $filename: open failed - $!\n"; | 240 | die "$P: $filename: open failed - $!\n"; |
232 | } | 241 | } |
233 | if ($filename eq '-') { | 242 | if ($filename eq '-') { |
@@ -235,11 +244,11 @@ for my $filename (@ARGV) { | |||
235 | } else { | 244 | } else { |
236 | $vname = $filename; | 245 | $vname = $filename; |
237 | } | 246 | } |
238 | while (<FILE>) { | 247 | while (<$FILE>) { |
239 | chomp; | 248 | chomp; |
240 | push(@rawlines, $_); | 249 | push(@rawlines, $_); |
241 | } | 250 | } |
242 | close(FILE); | 251 | close($FILE); |
243 | if (!process($filename)) { | 252 | if (!process($filename)) { |
244 | $exit = 1; | 253 | $exit = 1; |
245 | } | 254 | } |
@@ -366,7 +375,7 @@ sub sanitise_line { | |||
366 | } | 375 | } |
367 | } | 376 | } |
368 | 377 | ||
369 | #print "SQ:$sanitise_quote\n"; | 378 | #print "c<$c> SQ<$sanitise_quote>\n"; |
370 | if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") { | 379 | if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") { |
371 | substr($res, $off, 1, $;); | 380 | substr($res, $off, 1, $;); |
372 | } elsif ($off != 0 && $sanitise_quote && $c ne "\t") { | 381 | } elsif ($off != 0 && $sanitise_quote && $c ne "\t") { |
@@ -402,6 +411,7 @@ sub ctx_statement_block { | |||
402 | 411 | ||
403 | my $type = ''; | 412 | my $type = ''; |
404 | my $level = 0; | 413 | my $level = 0; |
414 | my @stack = ([$type, $level]); | ||
405 | my $p; | 415 | my $p; |
406 | my $c; | 416 | my $c; |
407 | my $len = 0; | 417 | my $len = 0; |
@@ -433,6 +443,16 @@ sub ctx_statement_block { | |||
433 | $remainder = substr($blk, $off); | 443 | $remainder = substr($blk, $off); |
434 | 444 | ||
435 | #warn "CSB: c<$c> type<$type> level<$level> remainder<$remainder> coff_set<$coff_set>\n"; | 445 | #warn "CSB: c<$c> type<$type> level<$level> remainder<$remainder> coff_set<$coff_set>\n"; |
446 | |||
447 | # Handle nested #if/#else. | ||
448 | if ($remainder =~ /^#\s*(?:ifndef|ifdef|if)\s/) { | ||
449 | push(@stack, [ $type, $level ]); | ||
450 | } elsif ($remainder =~ /^#\s*(?:else|elif)\b/) { | ||
451 | ($type, $level) = @{$stack[$#stack - 1]}; | ||
452 | } elsif ($remainder =~ /^#\s*endif\b/) { | ||
453 | ($type, $level) = @{pop(@stack)}; | ||
454 | } | ||
455 | |||
436 | # Statement ends at the ';' or a close '}' at the | 456 | # Statement ends at the ';' or a close '}' at the |
437 | # outermost level. | 457 | # outermost level. |
438 | if ($level == 0 && $c eq ';') { | 458 | if ($level == 0 && $c eq ';') { |
@@ -579,11 +599,22 @@ sub ctx_block_get { | |||
579 | my @res = (); | 599 | my @res = (); |
580 | 600 | ||
581 | my $level = 0; | 601 | my $level = 0; |
602 | my @stack = ($level); | ||
582 | for ($line = $start; $remain > 0; $line++) { | 603 | for ($line = $start; $remain > 0; $line++) { |
583 | next if ($rawlines[$line] =~ /^-/); | 604 | next if ($rawlines[$line] =~ /^-/); |
584 | $remain--; | 605 | $remain--; |
585 | 606 | ||
586 | $blk .= $rawlines[$line]; | 607 | $blk .= $rawlines[$line]; |
608 | |||
609 | # Handle nested #if/#else. | ||
610 | if ($rawlines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) { | ||
611 | push(@stack, $level); | ||
612 | } elsif ($rawlines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) { | ||
613 | $level = $stack[$#stack - 1]; | ||
614 | } elsif ($rawlines[$line] =~ /^.\s*#\s*endif\b/) { | ||
615 | $level = pop(@stack); | ||
616 | } | ||
617 | |||
587 | foreach my $c (split(//, $rawlines[$line])) { | 618 | foreach my $c (split(//, $rawlines[$line])) { |
588 | ##print "C<$c>L<$level><$open$close>O<$off>\n"; | 619 | ##print "C<$c>L<$level><$open$close>O<$off>\n"; |
589 | if ($off > 0) { | 620 | if ($off > 0) { |
@@ -843,11 +874,11 @@ sub annotate_values { | |||
843 | $type = 'V'; | 874 | $type = 'V'; |
844 | $av_pending = 'V'; | 875 | $av_pending = 'V'; |
845 | 876 | ||
846 | } elsif ($cur =~ /^($Ident\s*):/) { | 877 | } elsif ($cur =~ /^($Ident\s*):(?:\s*\d+\s*(,|=|;))?/) { |
847 | if ($type eq 'E') { | 878 | if (defined $2 && $type eq 'C' || $type eq 'T') { |
848 | $av_pend_colon = 'L'; | ||
849 | } elsif ($type eq 'T') { | ||
850 | $av_pend_colon = 'B'; | 879 | $av_pend_colon = 'B'; |
880 | } elsif ($type eq 'E') { | ||
881 | $av_pend_colon = 'L'; | ||
851 | } | 882 | } |
852 | print "IDENT_COLON($1,$type>$av_pend_colon)\n" if ($dbg_values > 1); | 883 | print "IDENT_COLON($1,$type>$av_pend_colon)\n" if ($dbg_values > 1); |
853 | $type = 'V'; | 884 | $type = 'V'; |
@@ -865,6 +896,10 @@ sub annotate_values { | |||
865 | $type = 'E'; | 896 | $type = 'E'; |
866 | $av_pend_colon = 'O'; | 897 | $av_pend_colon = 'O'; |
867 | 898 | ||
899 | } elsif ($cur =~/^(,)/) { | ||
900 | print "COMMA($1)\n" if ($dbg_values > 1); | ||
901 | $type = 'C'; | ||
902 | |||
868 | } elsif ($cur =~ /^(\?)/o) { | 903 | } elsif ($cur =~ /^(\?)/o) { |
869 | print "QUESTION($1)\n" if ($dbg_values > 1); | 904 | print "QUESTION($1)\n" if ($dbg_values > 1); |
870 | $type = 'N'; | 905 | $type = 'N'; |
@@ -880,7 +915,7 @@ sub annotate_values { | |||
880 | } | 915 | } |
881 | $av_pend_colon = 'O'; | 916 | $av_pend_colon = 'O'; |
882 | 917 | ||
883 | } elsif ($cur =~ /^(;|\[)/o) { | 918 | } elsif ($cur =~ /^(\[)/o) { |
884 | print "CLOSE($1)\n" if ($dbg_values > 1); | 919 | print "CLOSE($1)\n" if ($dbg_values > 1); |
885 | $type = 'N'; | 920 | $type = 'N'; |
886 | 921 | ||
@@ -1051,6 +1086,7 @@ sub process { | |||
1051 | my $in_comment = 0; | 1086 | my $in_comment = 0; |
1052 | my $comment_edge = 0; | 1087 | my $comment_edge = 0; |
1053 | my $first_line = 0; | 1088 | my $first_line = 0; |
1089 | my $p1_prefix = ''; | ||
1054 | 1090 | ||
1055 | my $prev_values = 'E'; | 1091 | my $prev_values = 'E'; |
1056 | 1092 | ||
@@ -1097,9 +1133,12 @@ sub process { | |||
1097 | $rawlines[$ln - 1] =~ /^-/); | 1133 | $rawlines[$ln - 1] =~ /^-/); |
1098 | $cnt--; | 1134 | $cnt--; |
1099 | #print "RAW<$rawlines[$ln - 1]>\n"; | 1135 | #print "RAW<$rawlines[$ln - 1]>\n"; |
1100 | ($edge) = (defined $rawlines[$ln - 1] && | 1136 | last if (!defined $rawlines[$ln - 1]); |
1101 | $rawlines[$ln - 1] =~ m@(/\*|\*/)@); | 1137 | if ($rawlines[$ln - 1] =~ m@(/\*|\*/)@ && |
1102 | last if (defined $edge); | 1138 | $rawlines[$ln - 1] !~ m@"[^"]*(?:/\*|\*/)[^"]*"@) { |
1139 | ($edge) = $1; | ||
1140 | last; | ||
1141 | } | ||
1103 | } | 1142 | } |
1104 | if (defined $edge && $edge eq '*/') { | 1143 | if (defined $edge && $edge eq '*/') { |
1105 | $in_comment = 1; | 1144 | $in_comment = 1; |
@@ -1109,7 +1148,7 @@ sub process { | |||
1109 | # is the start of a diff block and this line starts | 1148 | # is the start of a diff block and this line starts |
1110 | # ' *' then it is very likely a comment. | 1149 | # ' *' then it is very likely a comment. |
1111 | if (!defined $edge && | 1150 | if (!defined $edge && |
1112 | $rawlines[$linenr] =~ m@^.\s* \*(?:\s|$)@) | 1151 | $rawlines[$linenr] =~ m@^.\s*(?:\*\*+| \*)(?:\s|$)@) |
1113 | { | 1152 | { |
1114 | $in_comment = 1; | 1153 | $in_comment = 1; |
1115 | } | 1154 | } |
@@ -1196,7 +1235,12 @@ sub process { | |||
1196 | # extract the filename as it passes | 1235 | # extract the filename as it passes |
1197 | if ($line=~/^\+\+\+\s+(\S+)/) { | 1236 | if ($line=~/^\+\+\+\s+(\S+)/) { |
1198 | $realfile = $1; | 1237 | $realfile = $1; |
1199 | $realfile =~ s@^[^/]*/@@; | 1238 | $realfile =~ s@^([^/]*)/@@; |
1239 | |||
1240 | $p1_prefix = $1; | ||
1241 | if ($tree && $p1_prefix ne '' && -e "$root/$p1_prefix") { | ||
1242 | WARN("patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n"); | ||
1243 | } | ||
1200 | 1244 | ||
1201 | if ($realfile =~ m@^include/asm/@) { | 1245 | if ($realfile =~ m@^include/asm/@) { |
1202 | ERROR("do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n"); | 1246 | ERROR("do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n"); |
@@ -1336,7 +1380,7 @@ sub process { | |||
1336 | } | 1380 | } |
1337 | 1381 | ||
1338 | # any (foo ... *) is a pointer cast, and foo is a type | 1382 | # any (foo ... *) is a pointer cast, and foo is a type |
1339 | while ($s =~ /\(($Ident)(?:\s+$Sparse)*\s*\*+\s*\)/sg) { | 1383 | while ($s =~ /\(($Ident)(?:\s+$Sparse)*[\s\*]+\s*\)/sg) { |
1340 | possible($1, "C:" . $s); | 1384 | possible($1, "C:" . $s); |
1341 | } | 1385 | } |
1342 | 1386 | ||
@@ -1594,7 +1638,7 @@ sub process { | |||
1594 | $herecurr); | 1638 | $herecurr); |
1595 | } | 1639 | } |
1596 | # check for static initialisers. | 1640 | # check for static initialisers. |
1597 | if ($line =~ /\s*static\s.*=\s*(0|NULL|false)\s*;/) { | 1641 | if ($line =~ /\bstatic\s.*=\s*(0|NULL|false)\s*;/) { |
1598 | ERROR("do not initialise statics to 0 or NULL\n" . | 1642 | ERROR("do not initialise statics to 0 or NULL\n" . |
1599 | $herecurr); | 1643 | $herecurr); |
1600 | } | 1644 | } |
@@ -1602,7 +1646,7 @@ sub process { | |||
1602 | # check for new typedefs, only function parameters and sparse annotations | 1646 | # check for new typedefs, only function parameters and sparse annotations |
1603 | # make sense. | 1647 | # make sense. |
1604 | if ($line =~ /\btypedef\s/ && | 1648 | if ($line =~ /\btypedef\s/ && |
1605 | $line !~ /\btypedef\s+$Type\s+\(\s*\*?$Ident\s*\)\s*\(/ && | 1649 | $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ && |
1606 | $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && | 1650 | $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && |
1607 | $line !~ /\b$typeTypedefs\b/ && | 1651 | $line !~ /\b$typeTypedefs\b/ && |
1608 | $line !~ /\b__bitwise(?:__|)\b/) { | 1652 | $line !~ /\b__bitwise(?:__|)\b/) { |
@@ -1610,21 +1654,39 @@ sub process { | |||
1610 | } | 1654 | } |
1611 | 1655 | ||
1612 | # * goes on variable not on type | 1656 | # * goes on variable not on type |
1613 | if ($line =~ m{\($NonptrType(\*+)(?:\s+const)?\)}) { | 1657 | # (char*[ const]) |
1614 | ERROR("\"(foo$1)\" should be \"(foo $1)\"\n" . | 1658 | if ($line =~ m{\($NonptrType(\s*\*[\s\*]*(?:$Modifier\s*)*)\)}) { |
1615 | $herecurr); | 1659 | my ($from, $to) = ($1, $1); |
1616 | 1660 | ||
1617 | } elsif ($line =~ m{\($NonptrType\s+(\*+)(?!\s+const)\s+\)}) { | 1661 | # Should start with a space. |
1618 | ERROR("\"(foo $1 )\" should be \"(foo $1)\"\n" . | 1662 | $to =~ s/^(\S)/ $1/; |
1619 | $herecurr); | 1663 | # Should not end with a space. |
1664 | $to =~ s/\s+$//; | ||
1665 | # '*'s should not have spaces between. | ||
1666 | while ($to =~ s/(.)\s\*/$1\*/) { | ||
1667 | } | ||
1620 | 1668 | ||
1621 | } elsif ($line =~ m{\b$NonptrType(\*+)(?:\s+(?:$Attribute|$Sparse))?\s+[A-Za-z\d_]+}) { | 1669 | #print "from<$from> to<$to>\n"; |
1622 | ERROR("\"foo$1 bar\" should be \"foo $1bar\"\n" . | 1670 | if ($from ne $to) { |
1623 | $herecurr); | 1671 | ERROR("\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr); |
1672 | } | ||
1673 | } elsif ($line =~ m{\b$NonptrType(\s*\*[\s\*]*(?:$Modifier\s*)?)($Ident)}) { | ||
1674 | my ($from, $to, $ident) = ($1, $1, $2); | ||
1624 | 1675 | ||
1625 | } elsif ($line =~ m{\b$NonptrType\s+(\*+)(?!\s+(?:$Attribute|$Sparse))\s+[A-Za-z\d_]+}) { | 1676 | # Should start with a space. |
1626 | ERROR("\"foo $1 bar\" should be \"foo $1bar\"\n" . | 1677 | $to =~ s/^(\S)/ $1/; |
1627 | $herecurr); | 1678 | # Should not end with a space. |
1679 | $to =~ s/\s+$//; | ||
1680 | # '*'s should not have spaces between. | ||
1681 | while ($to =~ s/(.)\s\*/$1\*/) { | ||
1682 | } | ||
1683 | # Modifiers should have spaces. | ||
1684 | $to =~ s/(\b$Modifier$)/$1 /; | ||
1685 | |||
1686 | #print "from<$from> to<$to>\n"; | ||
1687 | if ($from ne $to) { | ||
1688 | ERROR("\"foo${from}bar\" should be \"foo${to}bar\"\n" . $herecurr); | ||
1689 | } | ||
1628 | } | 1690 | } |
1629 | 1691 | ||
1630 | # # no BUG() or BUG_ON() | 1692 | # # no BUG() or BUG_ON() |
@@ -1759,7 +1821,7 @@ sub process { | |||
1759 | $c = 'C' if ($elements[$n + 2] =~ /^$;/); | 1821 | $c = 'C' if ($elements[$n + 2] =~ /^$;/); |
1760 | $c = 'B' if ($elements[$n + 2] =~ /^(\)|\]|;)/); | 1822 | $c = 'B' if ($elements[$n + 2] =~ /^(\)|\]|;)/); |
1761 | $c = 'O' if ($elements[$n + 2] eq ''); | 1823 | $c = 'O' if ($elements[$n + 2] eq ''); |
1762 | $c = 'E' if ($elements[$n + 2] =~ /\s*\\$/); | 1824 | $c = 'E' if ($elements[$n + 2] =~ /^\s*\\$/); |
1763 | } else { | 1825 | } else { |
1764 | $c = 'E'; | 1826 | $c = 'E'; |
1765 | } | 1827 | } |
@@ -1950,9 +2012,9 @@ sub process { | |||
1950 | my $spacing = $1; | 2012 | my $spacing = $1; |
1951 | my $value = $2; | 2013 | my $value = $2; |
1952 | 2014 | ||
1953 | # Flatten any parentheses and braces | 2015 | # Flatten any parentheses |
1954 | $value =~ s/\)\(/\) \(/g; | 2016 | $value =~ s/\)\(/\) \(/g; |
1955 | while ($value =~ s/\([^\(\)]*\)/1/) { | 2017 | while ($value !~ /(?:$Ident|-?$Constant)\s*$Compare\s*(?:$Ident|-?$Constant)/ && $value =~ s/\([^\(\)]*\)/1/) { |
1956 | } | 2018 | } |
1957 | 2019 | ||
1958 | if ($value =~ /^(?:$Ident|-?$Constant)$/) { | 2020 | if ($value =~ /^(?:$Ident|-?$Constant)$/) { |
@@ -1992,7 +2054,7 @@ sub process { | |||
1992 | $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) { | 2054 | $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) { |
1993 | my ($s, $c) = ($stat, $cond); | 2055 | my ($s, $c) = ($stat, $cond); |
1994 | 2056 | ||
1995 | if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/) { | 2057 | if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/s) { |
1996 | ERROR("do not use assignment in if condition\n" . $herecurr); | 2058 | ERROR("do not use assignment in if condition\n" . $herecurr); |
1997 | } | 2059 | } |
1998 | 2060 | ||
@@ -2167,9 +2229,10 @@ sub process { | |||
2167 | MODULE_PARAM_DESC| | 2229 | MODULE_PARAM_DESC| |
2168 | DECLARE_PER_CPU| | 2230 | DECLARE_PER_CPU| |
2169 | DEFINE_PER_CPU| | 2231 | DEFINE_PER_CPU| |
2170 | __typeof__\( | 2232 | __typeof__\(| |
2233 | \.$Ident\s*=\s* | ||
2171 | }x; | 2234 | }x; |
2172 | #print "REST<$rest>\n"; | 2235 | #print "REST<$rest> dstat<$dstat>\n"; |
2173 | if ($rest ne '') { | 2236 | if ($rest ne '') { |
2174 | if ($rest !~ /while\s*\(/ && | 2237 | if ($rest !~ /while\s*\(/ && |
2175 | $dstat !~ /$exceptions/) | 2238 | $dstat !~ /$exceptions/) |
@@ -2189,6 +2252,15 @@ sub process { | |||
2189 | } | 2252 | } |
2190 | } | 2253 | } |
2191 | 2254 | ||
2255 | # make sure symbols are always wrapped with VMLINUX_SYMBOL() ... | ||
2256 | # all assignments may have only one of the following with an assignment: | ||
2257 | # . | ||
2258 | # ALIGN(...) | ||
2259 | # VMLINUX_SYMBOL(...) | ||
2260 | if ($realfile eq 'vmlinux.lds.h' && $line =~ /(?:(?:^|\s)$Ident\s*=|=\s*$Ident(?:\s|$))/) { | ||
2261 | WARN("vmlinux.lds.h needs VMLINUX_SYMBOL() around C-visible symbols\n" . $herecurr); | ||
2262 | } | ||
2263 | |||
2192 | # check for redundant bracing round if etc | 2264 | # check for redundant bracing round if etc |
2193 | if ($line =~ /(^.*)\bif\b/ && $1 !~ /else\s*$/) { | 2265 | if ($line =~ /(^.*)\bif\b/ && $1 !~ /else\s*$/) { |
2194 | my ($level, $endln, @chunks) = | 2266 | my ($level, $endln, @chunks) = |
@@ -2443,6 +2515,11 @@ sub process { | |||
2443 | if ($line =~ /^.\s*__initcall\s*\(/) { | 2515 | if ($line =~ /^.\s*__initcall\s*\(/) { |
2444 | WARN("please use device_initcall() instead of __initcall()\n" . $herecurr); | 2516 | WARN("please use device_initcall() instead of __initcall()\n" . $herecurr); |
2445 | } | 2517 | } |
2518 | # check for struct file_operations, ensure they are const. | ||
2519 | if ($line =~ /\bstruct\s+file_operations\b/ && | ||
2520 | $line !~ /\bconst\b/) { | ||
2521 | WARN("struct file_operations should normally be const\n" . $herecurr); | ||
2522 | } | ||
2446 | 2523 | ||
2447 | # use of NR_CPUS is usually wrong | 2524 | # use of NR_CPUS is usually wrong |
2448 | # ignore definitions of NR_CPUS and usage to define arrays as likely right | 2525 | # ignore definitions of NR_CPUS and usage to define arrays as likely right |
@@ -2466,6 +2543,15 @@ sub process { | |||
2466 | last; | 2543 | last; |
2467 | } | 2544 | } |
2468 | } | 2545 | } |
2546 | |||
2547 | # whine mightly about in_atomic | ||
2548 | if ($line =~ /\bin_atomic\s*\(/) { | ||
2549 | if ($realfile =~ m@^drivers/@) { | ||
2550 | ERROR("do not use in_atomic in drivers\n" . $herecurr); | ||
2551 | } else { | ||
2552 | WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr); | ||
2553 | } | ||
2554 | } | ||
2469 | } | 2555 | } |
2470 | 2556 | ||
2471 | # If we have no input at all, then there is nothing to report on | 2557 | # If we have no input at all, then there is nothing to report on |
diff --git a/scripts/config b/scripts/config new file mode 100755 index 000000000000..68b9761cdc38 --- /dev/null +++ b/scripts/config | |||
@@ -0,0 +1,150 @@ | |||
1 | #!/bin/bash | ||
2 | # Manipulate options in a .config file from the command line | ||
3 | |||
4 | usage() { | ||
5 | cat >&2 <<EOL | ||
6 | Manipulate options in a .config file from the command line. | ||
7 | Usage: | ||
8 | config options command ... | ||
9 | commands: | ||
10 | --enable|-e option Enable option | ||
11 | --disable|-d option Disable option | ||
12 | --module|-m option Turn option into a module | ||
13 | --state|-s option Print state of option (n,y,m,undef) | ||
14 | |||
15 | --enable-after|-E beforeopt option | ||
16 | Enable option directly after other option | ||
17 | --disable-after|-D beforeopt option | ||
18 | Disable option directly after other option | ||
19 | --module-after|-M beforeopt option | ||
20 | Turn option into module directly after other option | ||
21 | |||
22 | commands can be repeated multiple times | ||
23 | |||
24 | options: | ||
25 | --file .config file to change (default .config) | ||
26 | |||
27 | config doesn't check the validity of the .config file. This is done at next | ||
28 | make time. | ||
29 | The options need to be already in the file before they can be changed, | ||
30 | but sometimes you can cheat with the --*-after options. | ||
31 | EOL | ||
32 | exit 1 | ||
33 | } | ||
34 | |||
35 | checkarg() { | ||
36 | ARG="$1" | ||
37 | if [ "$ARG" = "" ] ; then | ||
38 | usage | ||
39 | fi | ||
40 | case "$ARG" in | ||
41 | CONFIG_*) | ||
42 | ARG="${ARG/CONFIG_/}" | ||
43 | ;; | ||
44 | esac | ||
45 | ARG="`echo $ARG | tr a-z A-Z`" | ||
46 | } | ||
47 | |||
48 | replace() { | ||
49 | sed -i -e "$@" $FN | ||
50 | } | ||
51 | |||
52 | if [ "$1" = "--file" ]; then | ||
53 | FN="$2" | ||
54 | if [ "$FN" = "" ] ; then | ||
55 | usage | ||
56 | fi | ||
57 | shift | ||
58 | shift | ||
59 | else | ||
60 | FN=.config | ||
61 | fi | ||
62 | |||
63 | while [ "$1" != "" ] ; do | ||
64 | CMD="$1" | ||
65 | shift | ||
66 | case "$CMD" in | ||
67 | --enable|-e) | ||
68 | checkarg "$1" | ||
69 | replace "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/" | ||
70 | shift | ||
71 | ;; | ||
72 | |||
73 | --disable|-d) | ||
74 | checkarg "$1" | ||
75 | replace "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/" | ||
76 | shift | ||
77 | ;; | ||
78 | |||
79 | --module|-m) | ||
80 | checkarg "$1" | ||
81 | replace "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \ | ||
82 | -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/" | ||
83 | shift | ||
84 | ;; | ||
85 | |||
86 | --state|-s) | ||
87 | checkarg "$1" | ||
88 | if grep -q "# CONFIG_$ARG is not set" $FN ; then | ||
89 | echo n | ||
90 | else | ||
91 | V="$(grep "^CONFIG_$ARG=" $FN)" | ||
92 | if [ $? != 0 ] ; then | ||
93 | echo undef | ||
94 | else | ||
95 | V="${V/CONFIG_$ARG=/}" | ||
96 | V="${V/\"/}" | ||
97 | echo "$V" | ||
98 | fi | ||
99 | fi | ||
100 | shift | ||
101 | ;; | ||
102 | |||
103 | --enable-after|-E) | ||
104 | checkarg "$1" | ||
105 | A=$ARG | ||
106 | checkarg "$2" | ||
107 | B=$ARG | ||
108 | replace "/CONFIG_$A=[my]/aCONFIG_$B=y" \ | ||
109 | -e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=y" \ | ||
110 | -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/" | ||
111 | shift | ||
112 | shift | ||
113 | ;; | ||
114 | |||
115 | --disable-after|-D) | ||
116 | checkarg "$1" | ||
117 | A=$ARG | ||
118 | checkarg "$2" | ||
119 | B=$ARG | ||
120 | replace "/CONFIG_$A=[my]/a# CONFIG_$B is not set" \ | ||
121 | -e "/# CONFIG_$ARG is not set/a/# CONFIG_$ARG is not set" \ | ||
122 | -e "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/" | ||
123 | shift | ||
124 | shift | ||
125 | ;; | ||
126 | |||
127 | --module-after|-M) | ||
128 | checkarg "$1" | ||
129 | A=$ARG | ||
130 | checkarg "$2" | ||
131 | B=$ARG | ||
132 | replace "/CONFIG_$A=[my]/aCONFIG_$B=m" \ | ||
133 | -e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=m" \ | ||
134 | -e "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \ | ||
135 | -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/" | ||
136 | shift | ||
137 | shift | ||
138 | ;; | ||
139 | |||
140 | # undocumented because it ignores --file (fixme) | ||
141 | --refresh) | ||
142 | yes "" | make oldconfig | ||
143 | ;; | ||
144 | |||
145 | *) | ||
146 | usage | ||
147 | ;; | ||
148 | esac | ||
149 | done | ||
150 | |||
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl index 488a3b1f760f..db30fac3083e 100644 --- a/scripts/headers_check.pl +++ b/scripts/headers_check.pl | |||
@@ -14,7 +14,9 @@ | |||
14 | # Only include files located in asm* and linux* are checked. | 14 | # Only include files located in asm* and linux* are checked. |
15 | # The rest are assumed to be system include files. | 15 | # The rest are assumed to be system include files. |
16 | # | 16 | # |
17 | # 2) TODO: check for leaked CONFIG_ symbols | 17 | # 2) It is checked that prototypes does not use "extern" |
18 | # | ||
19 | # 3) Check for leaked CONFIG_ symbols | ||
18 | 20 | ||
19 | use strict; | 21 | use strict; |
20 | 22 | ||
@@ -32,7 +34,11 @@ foreach my $file (@files) { | |||
32 | $lineno = 0; | 34 | $lineno = 0; |
33 | while ($line = <FH>) { | 35 | while ($line = <FH>) { |
34 | $lineno++; | 36 | $lineno++; |
35 | check_include(); | 37 | &check_include(); |
38 | &check_asm_types(); | ||
39 | &check_sizetypes(); | ||
40 | &check_prototypes(); | ||
41 | &check_config(); | ||
36 | } | 42 | } |
37 | close FH; | 43 | close FH; |
38 | } | 44 | } |
@@ -54,3 +60,63 @@ sub check_include | |||
54 | } | 60 | } |
55 | } | 61 | } |
56 | } | 62 | } |
63 | |||
64 | sub check_prototypes | ||
65 | { | ||
66 | if ($line =~ m/^\s*extern\b/) { | ||
67 | printf STDERR "$filename:$lineno: extern's make no sense in userspace\n"; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | sub check_config | ||
72 | { | ||
73 | if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9]+)[^a-zA-Z0-9]/) { | ||
74 | printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n"; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | my $linux_asm_types; | ||
79 | sub check_asm_types() | ||
80 | { | ||
81 | if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) { | ||
82 | return; | ||
83 | } | ||
84 | if ($lineno == 1) { | ||
85 | $linux_asm_types = 0; | ||
86 | } elsif ($linux_asm_types >= 1) { | ||
87 | return; | ||
88 | } | ||
89 | if ($line =~ m/^\s*#\s*include\s+<asm\/types.h>/) { | ||
90 | $linux_asm_types = 1; | ||
91 | printf STDERR "$filename:$lineno: " . | ||
92 | "include of <linux/types.h> is preferred over <asm/types.h>\n" | ||
93 | # Warn until headers are all fixed | ||
94 | #$ret = 1; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | my $linux_types; | ||
99 | sub check_sizetypes | ||
100 | { | ||
101 | if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) { | ||
102 | return; | ||
103 | } | ||
104 | if ($lineno == 1) { | ||
105 | $linux_types = 0; | ||
106 | } elsif ($linux_types >= 1) { | ||
107 | return; | ||
108 | } | ||
109 | if ($line =~ m/^\s*#\s*include\s+<linux\/types.h>/) { | ||
110 | $linux_types = 1; | ||
111 | return; | ||
112 | } | ||
113 | if ($line =~ m/__[us](8|16|32|64)\b/) { | ||
114 | printf STDERR "$filename:$lineno: " . | ||
115 | "found __[us]{8,16,32,64} type " . | ||
116 | "without #include <linux/types.h>\n"; | ||
117 | $linux_types = 2; | ||
118 | # Warn until headers are all fixed | ||
119 | #$ret = 1; | ||
120 | } | ||
121 | } | ||
122 | |||
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl index 7d2b4146e02f..c6ae4052ab43 100644 --- a/scripts/headers_install.pl +++ b/scripts/headers_install.pl | |||
@@ -36,6 +36,9 @@ foreach my $file (@files) { | |||
36 | $line =~ s/\s__attribute_const__\s/ /g; | 36 | $line =~ s/\s__attribute_const__\s/ /g; |
37 | $line =~ s/\s__attribute_const__$//g; | 37 | $line =~ s/\s__attribute_const__$//g; |
38 | $line =~ s/^#include <linux\/compiler.h>//; | 38 | $line =~ s/^#include <linux\/compiler.h>//; |
39 | $line =~ s/(^|\s)(inline)\b/$1__$2__/g; | ||
40 | $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; | ||
41 | $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; | ||
39 | printf OUTFILE "%s", $line; | 42 | printf OUTFILE "%s", $line; |
40 | } | 43 | } |
41 | close OUTFILE; | 44 | close OUTFILE; |
diff --git a/scripts/ihex2fw.c b/scripts/ihex2fw.c new file mode 100644 index 000000000000..8f7fdaa9e010 --- /dev/null +++ b/scripts/ihex2fw.c | |||
@@ -0,0 +1,268 @@ | |||
1 | /* | ||
2 | * Parser/loader for IHEX formatted data. | ||
3 | * | ||
4 | * Copyright © 2008 David Woodhouse <dwmw2@infradead.org> | ||
5 | * Copyright © 2005 Jan Harkes <jaharkes@cs.cmu.edu> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <stdint.h> | ||
13 | #include <arpa/inet.h> | ||
14 | #include <stdio.h> | ||
15 | #include <errno.h> | ||
16 | #include <sys/types.h> | ||
17 | #include <sys/stat.h> | ||
18 | #include <sys/mman.h> | ||
19 | #include <fcntl.h> | ||
20 | #include <string.h> | ||
21 | #include <unistd.h> | ||
22 | #include <stdlib.h> | ||
23 | #define _GNU_SOURCE | ||
24 | #include <getopt.h> | ||
25 | |||
26 | |||
27 | struct ihex_binrec { | ||
28 | struct ihex_binrec *next; /* not part of the real data structure */ | ||
29 | uint32_t addr; | ||
30 | uint16_t len; | ||
31 | uint8_t data[]; | ||
32 | }; | ||
33 | |||
34 | /** | ||
35 | * nybble/hex are little helpers to parse hexadecimal numbers to a byte value | ||
36 | **/ | ||
37 | static uint8_t nybble(const uint8_t n) | ||
38 | { | ||
39 | if (n >= '0' && n <= '9') return n - '0'; | ||
40 | else if (n >= 'A' && n <= 'F') return n - ('A' - 10); | ||
41 | else if (n >= 'a' && n <= 'f') return n - ('a' - 10); | ||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | static uint8_t hex(const uint8_t *data, uint8_t *crc) | ||
46 | { | ||
47 | uint8_t val = (nybble(data[0]) << 4) | nybble(data[1]); | ||
48 | *crc += val; | ||
49 | return val; | ||
50 | } | ||
51 | |||
52 | static int process_ihex(uint8_t *data, ssize_t size); | ||
53 | static void file_record(struct ihex_binrec *record); | ||
54 | static int output_records(int outfd); | ||
55 | |||
56 | static int sort_records = 0; | ||
57 | static int wide_records = 0; | ||
58 | |||
59 | int usage(void) | ||
60 | { | ||
61 | fprintf(stderr, "ihex2fw: Convert ihex files into binary " | ||
62 | "representation for use by Linux kernel\n"); | ||
63 | fprintf(stderr, "usage: ihex2fw [<options>] <src.HEX> <dst.fw>\n"); | ||
64 | fprintf(stderr, " -w: wide records (16-bit length)\n"); | ||
65 | fprintf(stderr, " -s: sort records by address\n"); | ||
66 | return 1; | ||
67 | } | ||
68 | |||
69 | int main(int argc, char **argv) | ||
70 | { | ||
71 | int infd, outfd; | ||
72 | struct stat st; | ||
73 | uint8_t *data; | ||
74 | int opt; | ||
75 | |||
76 | while ((opt = getopt(argc, argv, "ws")) != -1) { | ||
77 | switch (opt) { | ||
78 | case 'w': | ||
79 | wide_records = 1; | ||
80 | break; | ||
81 | case 's': | ||
82 | sort_records = 1; | ||
83 | break; | ||
84 | default: | ||
85 | return usage(); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | if (optind + 2 != argc) | ||
90 | return usage(); | ||
91 | |||
92 | if (!strcmp(argv[optind], "-")) | ||
93 | infd = 0; | ||
94 | else | ||
95 | infd = open(argv[optind], O_RDONLY); | ||
96 | if (infd == -1) { | ||
97 | fprintf(stderr, "Failed to open source file: %s", | ||
98 | strerror(errno)); | ||
99 | return usage(); | ||
100 | } | ||
101 | if (fstat(infd, &st)) { | ||
102 | perror("stat"); | ||
103 | return 1; | ||
104 | } | ||
105 | data = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, infd, 0); | ||
106 | if (data == MAP_FAILED) { | ||
107 | perror("mmap"); | ||
108 | return 1; | ||
109 | } | ||
110 | |||
111 | if (!strcmp(argv[optind+1], "-")) | ||
112 | outfd = 1; | ||
113 | else | ||
114 | outfd = open(argv[optind+1], O_TRUNC|O_CREAT|O_WRONLY, 0644); | ||
115 | if (outfd == -1) { | ||
116 | fprintf(stderr, "Failed to open destination file: %s", | ||
117 | strerror(errno)); | ||
118 | return usage(); | ||
119 | } | ||
120 | if (process_ihex(data, st.st_size)) | ||
121 | return 1; | ||
122 | |||
123 | output_records(outfd); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static int process_ihex(uint8_t *data, ssize_t size) | ||
128 | { | ||
129 | struct ihex_binrec *record; | ||
130 | uint32_t offset = 0; | ||
131 | uint8_t type, crc = 0, crcbyte = 0; | ||
132 | int i, j; | ||
133 | int line = 1; | ||
134 | int len; | ||
135 | |||
136 | i = 0; | ||
137 | next_record: | ||
138 | /* search for the start of record character */ | ||
139 | while (i < size) { | ||
140 | if (data[i] == '\n') line++; | ||
141 | if (data[i++] == ':') break; | ||
142 | } | ||
143 | |||
144 | /* Minimum record length would be about 10 characters */ | ||
145 | if (i + 10 > size) { | ||
146 | fprintf(stderr, "Can't find valid record at line %d\n", line); | ||
147 | return -EINVAL; | ||
148 | } | ||
149 | |||
150 | len = hex(data + i, &crc); i += 2; | ||
151 | if (wide_records) { | ||
152 | len <<= 8; | ||
153 | len += hex(data + i, &crc); i += 2; | ||
154 | } | ||
155 | record = malloc((sizeof (*record) + len + 3) & ~3); | ||
156 | if (!record) { | ||
157 | fprintf(stderr, "out of memory for records\n"); | ||
158 | return -ENOMEM; | ||
159 | } | ||
160 | memset(record, 0, (sizeof(*record) + len + 3) & ~3); | ||
161 | record->len = len; | ||
162 | |||
163 | /* now check if we have enough data to read everything */ | ||
164 | if (i + 8 + (record->len * 2) > size) { | ||
165 | fprintf(stderr, "Not enough data to read complete record at line %d\n", | ||
166 | line); | ||
167 | return -EINVAL; | ||
168 | } | ||
169 | |||
170 | record->addr = hex(data + i, &crc) << 8; i += 2; | ||
171 | record->addr |= hex(data + i, &crc); i += 2; | ||
172 | type = hex(data + i, &crc); i += 2; | ||
173 | |||
174 | for (j = 0; j < record->len; j++, i += 2) | ||
175 | record->data[j] = hex(data + i, &crc); | ||
176 | |||
177 | /* check CRC */ | ||
178 | crcbyte = hex(data + i, &crc); i += 2; | ||
179 | if (crc != 0) { | ||
180 | fprintf(stderr, "CRC failure at line %d: got 0x%X, expected 0x%X\n", | ||
181 | line, crcbyte, (unsigned char)(crcbyte-crc)); | ||
182 | return -EINVAL; | ||
183 | } | ||
184 | |||
185 | /* Done reading the record */ | ||
186 | switch (type) { | ||
187 | case 0: | ||
188 | /* old style EOF record? */ | ||
189 | if (!record->len) | ||
190 | break; | ||
191 | |||
192 | record->addr += offset; | ||
193 | file_record(record); | ||
194 | goto next_record; | ||
195 | |||
196 | case 1: /* End-Of-File Record */ | ||
197 | if (record->addr || record->len) { | ||
198 | fprintf(stderr, "Bad EOF record (type 01) format at line %d", | ||
199 | line); | ||
200 | return -EINVAL; | ||
201 | } | ||
202 | break; | ||
203 | |||
204 | case 2: /* Extended Segment Address Record (HEX86) */ | ||
205 | case 4: /* Extended Linear Address Record (HEX386) */ | ||
206 | if (record->addr || record->len != 2) { | ||
207 | fprintf(stderr, "Bad HEX86/HEX386 record (type %02X) at line %d\n", | ||
208 | type, line); | ||
209 | return -EINVAL; | ||
210 | } | ||
211 | |||
212 | /* We shouldn't really be using the offset for HEX86 because | ||
213 | * the wraparound case is specified quite differently. */ | ||
214 | offset = record->data[0] << 8 | record->data[1]; | ||
215 | offset <<= (type == 2 ? 4 : 16); | ||
216 | goto next_record; | ||
217 | |||
218 | case 3: /* Start Segment Address Record */ | ||
219 | case 5: /* Start Linear Address Record */ | ||
220 | if (record->addr || record->len != 4) { | ||
221 | fprintf(stderr, "Bad Start Address record (type %02X) at line %d\n", | ||
222 | type, line); | ||
223 | return -EINVAL; | ||
224 | } | ||
225 | |||
226 | /* These records contain the CS/IP or EIP where execution | ||
227 | * starts. Don't really know what to do with them. */ | ||
228 | goto next_record; | ||
229 | |||
230 | default: | ||
231 | fprintf(stderr, "Unknown record (type %02X)\n", type); | ||
232 | return -EINVAL; | ||
233 | } | ||
234 | |||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | static struct ihex_binrec *records; | ||
239 | |||
240 | static void file_record(struct ihex_binrec *record) | ||
241 | { | ||
242 | struct ihex_binrec **p = &records; | ||
243 | |||
244 | while ((*p) && (!sort_records || (*p)->addr < record->addr)) | ||
245 | p = &((*p)->next); | ||
246 | |||
247 | record->next = *p; | ||
248 | *p = record; | ||
249 | } | ||
250 | |||
251 | static int output_records(int outfd) | ||
252 | { | ||
253 | unsigned char zeroes[6] = {0, 0, 0, 0, 0, 0}; | ||
254 | struct ihex_binrec *p = records; | ||
255 | |||
256 | while (p) { | ||
257 | uint16_t writelen = (p->len + 9) & ~3; | ||
258 | |||
259 | p->addr = htonl(p->addr); | ||
260 | p->len = htons(p->len); | ||
261 | write(outfd, &p->addr, writelen); | ||
262 | p = p->next; | ||
263 | } | ||
264 | /* EOF record is zero length, since we don't bother to represent | ||
265 | the type field in the binary version */ | ||
266 | write(outfd, zeroes, 6); | ||
267 | return 0; | ||
268 | } | ||
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 9d4cba1c001d..6408fefae083 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
@@ -65,9 +65,13 @@ enum symbol_type { | |||
65 | S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER | 65 | S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER |
66 | }; | 66 | }; |
67 | 67 | ||
68 | /* enum values are used as index to symbol.def[] */ | ||
68 | enum { | 69 | enum { |
69 | S_DEF_USER, /* main user value */ | 70 | S_DEF_USER, /* main user value */ |
70 | S_DEF_AUTO, | 71 | S_DEF_AUTO, /* values read from auto.conf */ |
72 | S_DEF_DEF3, /* Reserved for UI usage */ | ||
73 | S_DEF_DEF4, /* Reserved for UI usage */ | ||
74 | S_DEF_COUNT | ||
71 | }; | 75 | }; |
72 | 76 | ||
73 | struct symbol { | 77 | struct symbol { |
@@ -75,7 +79,7 @@ struct symbol { | |||
75 | char *name; | 79 | char *name; |
76 | enum symbol_type type; | 80 | enum symbol_type type; |
77 | struct symbol_value curr; | 81 | struct symbol_value curr; |
78 | struct symbol_value def[4]; | 82 | struct symbol_value def[S_DEF_COUNT]; |
79 | tristate visible; | 83 | tristate visible; |
80 | int flags; | 84 | int flags; |
81 | struct property *prop; | 85 | struct property *prop; |
@@ -84,42 +88,64 @@ struct symbol { | |||
84 | 88 | ||
85 | #define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) | 89 | #define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) |
86 | 90 | ||
87 | #define SYMBOL_CONST 0x0001 | 91 | #define SYMBOL_CONST 0x0001 /* symbol is const */ |
88 | #define SYMBOL_CHECK 0x0008 | 92 | #define SYMBOL_CHECK 0x0008 /* used during dependency checking */ |
89 | #define SYMBOL_CHOICE 0x0010 | 93 | #define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */ |
90 | #define SYMBOL_CHOICEVAL 0x0020 | 94 | #define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */ |
91 | #define SYMBOL_VALID 0x0080 | 95 | #define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */ |
92 | #define SYMBOL_OPTIONAL 0x0100 | 96 | #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ |
93 | #define SYMBOL_WRITE 0x0200 | 97 | #define SYMBOL_WRITE 0x0200 /* ? */ |
94 | #define SYMBOL_CHANGED 0x0400 | 98 | #define SYMBOL_CHANGED 0x0400 /* ? */ |
95 | #define SYMBOL_AUTO 0x1000 | 99 | #define SYMBOL_AUTO 0x1000 /* value from environment variable */ |
96 | #define SYMBOL_CHECKED 0x2000 | 100 | #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ |
97 | #define SYMBOL_WARNED 0x8000 | 101 | #define SYMBOL_WARNED 0x8000 /* warning has been issued */ |
98 | #define SYMBOL_DEF 0x10000 | 102 | |
99 | #define SYMBOL_DEF_USER 0x10000 | 103 | /* Set when symbol.def[] is used */ |
100 | #define SYMBOL_DEF_AUTO 0x20000 | 104 | #define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */ |
101 | #define SYMBOL_DEF3 0x40000 | 105 | #define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */ |
102 | #define SYMBOL_DEF4 0x80000 | 106 | #define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */ |
107 | #define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */ | ||
108 | #define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ | ||
103 | 109 | ||
104 | #define SYMBOL_MAXLENGTH 256 | 110 | #define SYMBOL_MAXLENGTH 256 |
105 | #define SYMBOL_HASHSIZE 257 | 111 | #define SYMBOL_HASHSIZE 257 |
106 | #define SYMBOL_HASHMASK 0xff | 112 | #define SYMBOL_HASHMASK 0xff |
107 | 113 | ||
114 | /* A property represent the config options that can be associated | ||
115 | * with a config "symbol". | ||
116 | * Sample: | ||
117 | * config FOO | ||
118 | * default y | ||
119 | * prompt "foo prompt" | ||
120 | * select BAR | ||
121 | * config BAZ | ||
122 | * int "BAZ Value" | ||
123 | * range 1..255 | ||
124 | */ | ||
108 | enum prop_type { | 125 | enum prop_type { |
109 | P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, | 126 | P_UNKNOWN, |
110 | P_SELECT, P_RANGE, P_ENV | 127 | P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */ |
128 | P_COMMENT, /* text associated with a comment */ | ||
129 | P_MENU, /* prompt associated with a menuconfig option */ | ||
130 | P_DEFAULT, /* default y */ | ||
131 | P_CHOICE, /* choice value */ | ||
132 | P_SELECT, /* select BAR */ | ||
133 | P_RANGE, /* range 7..100 (for a symbol) */ | ||
134 | P_ENV, /* value from environment variable */ | ||
111 | }; | 135 | }; |
112 | 136 | ||
113 | struct property { | 137 | struct property { |
114 | struct property *next; | 138 | struct property *next; /* next property - null if last */ |
115 | struct symbol *sym; | 139 | struct symbol *sym; /* the symbol for which the property is associated */ |
116 | enum prop_type type; | 140 | enum prop_type type; /* type of property */ |
117 | const char *text; | 141 | const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */ |
118 | struct expr_value visible; | 142 | struct expr_value visible; |
119 | struct expr *expr; | 143 | struct expr *expr; /* the optional conditional part of the property */ |
120 | struct menu *menu; | 144 | struct menu *menu; /* the menu the property are associated with |
121 | struct file *file; | 145 | * valid for: P_SELECT, P_RANGE, P_CHOICE, |
122 | int lineno; | 146 | * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */ |
147 | struct file *file; /* what file was this property defined */ | ||
148 | int lineno; /* what lineno was this property defined */ | ||
123 | }; | 149 | }; |
124 | 150 | ||
125 | #define for_all_properties(sym, st, tok) \ | 151 | #define for_all_properties(sym, st, tok) \ |
diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped index 7342ce0a7780..dc3e81807d13 100644 --- a/scripts/kconfig/lex.zconf.c_shipped +++ b/scripts/kconfig/lex.zconf.c_shipped | |||
@@ -2370,11 +2370,14 @@ void zconf_nextfile(const char *name) | |||
2370 | current_buf = buf; | 2370 | current_buf = buf; |
2371 | 2371 | ||
2372 | if (file->flags & FILE_BUSY) { | 2372 | if (file->flags & FILE_BUSY) { |
2373 | printf("recursive scan (%s)?\n", name); | 2373 | printf("%s:%d: do not source '%s' from itself\n", |
2374 | zconf_curname(), zconf_lineno(), name); | ||
2374 | exit(1); | 2375 | exit(1); |
2375 | } | 2376 | } |
2376 | if (file->flags & FILE_SCANNED) { | 2377 | if (file->flags & FILE_SCANNED) { |
2377 | printf("file %s already scanned?\n", name); | 2378 | printf("%s:%d: file '%s' is already sourced from '%s'\n", |
2379 | zconf_curname(), zconf_lineno(), name, | ||
2380 | file->parent->name); | ||
2378 | exit(1); | 2381 | exit(1); |
2379 | } | 2382 | } |
2380 | file->flags |= FILE_BUSY; | 2383 | file->flags |= FILE_BUSY; |
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 5164ef7ce499..21ff69c9ad4e 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -314,11 +314,14 @@ void zconf_nextfile(const char *name) | |||
314 | current_buf = buf; | 314 | current_buf = buf; |
315 | 315 | ||
316 | if (file->flags & FILE_BUSY) { | 316 | if (file->flags & FILE_BUSY) { |
317 | printf("recursive scan (%s)?\n", name); | 317 | printf("%s:%d: do not source '%s' from itself\n", |
318 | zconf_curname(), zconf_lineno(), name); | ||
318 | exit(1); | 319 | exit(1); |
319 | } | 320 | } |
320 | if (file->flags & FILE_SCANNED) { | 321 | if (file->flags & FILE_SCANNED) { |
321 | printf("file %s already scanned?\n", name); | 322 | printf("%s:%d: file '%s' is already sourced from '%s'\n", |
323 | zconf_curname(), zconf_lineno(), name, | ||
324 | file->parent->name); | ||
322 | exit(1); | 325 | exit(1); |
323 | } | 326 | } |
324 | file->flags |= FILE_BUSY; | 327 | file->flags |= FILE_BUSY; |
diff --git a/scripts/markup_oops.pl b/scripts/markup_oops.pl new file mode 100644 index 000000000000..d40449cafa84 --- /dev/null +++ b/scripts/markup_oops.pl | |||
@@ -0,0 +1,203 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | |||
3 | use File::Basename; | ||
4 | |||
5 | # Copyright 2008, Intel Corporation | ||
6 | # | ||
7 | # This file is part of the Linux kernel | ||
8 | # | ||
9 | # This program file is free software; you can redistribute it and/or modify it | ||
10 | # under the terms of the GNU General Public License as published by the | ||
11 | # Free Software Foundation; version 2 of the License. | ||
12 | # | ||
13 | # Authors: | ||
14 | # Arjan van de Ven <arjan@linux.intel.com> | ||
15 | |||
16 | |||
17 | my $vmlinux_name = $ARGV[0]; | ||
18 | if (!defined($vmlinux_name)) { | ||
19 | my $kerver = `uname -r`; | ||
20 | chomp($kerver); | ||
21 | $vmlinux_name = "/lib/modules/$kerver/build/vmlinux"; | ||
22 | print "No vmlinux specified, assuming $vmlinux_name\n"; | ||
23 | } | ||
24 | my $filename = $vmlinux_name; | ||
25 | # | ||
26 | # Step 1: Parse the oops to find the EIP value | ||
27 | # | ||
28 | |||
29 | my $target = "0"; | ||
30 | my $function; | ||
31 | my $module = ""; | ||
32 | my $func_offset; | ||
33 | my $vmaoffset = 0; | ||
34 | |||
35 | while (<STDIN>) { | ||
36 | my $line = $_; | ||
37 | if ($line =~ /EIP: 0060:\[\<([a-z0-9]+)\>\]/) { | ||
38 | $target = $1; | ||
39 | } | ||
40 | if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) { | ||
41 | $function = $1; | ||
42 | $func_offset = $2; | ||
43 | } | ||
44 | |||
45 | # check if it's a module | ||
46 | if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]+\W\[([a-zA-Z0-9\_\-]+)\]/) { | ||
47 | $module = $3; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | my $decodestart = hex($target) - hex($func_offset); | ||
52 | my $decodestop = $decodestart + 8192; | ||
53 | if ($target eq "0") { | ||
54 | print "No oops found!\n"; | ||
55 | print "Usage: \n"; | ||
56 | print " dmesg | perl scripts/markup_oops.pl vmlinux\n"; | ||
57 | exit; | ||
58 | } | ||
59 | |||
60 | # if it's a module, we need to find the .ko file and calculate a load offset | ||
61 | if ($module ne "") { | ||
62 | my $dir = dirname($filename); | ||
63 | $dir = $dir . "/"; | ||
64 | my $mod = $module . ".ko"; | ||
65 | my $modulefile = `find $dir -name $mod | head -1`; | ||
66 | chomp($modulefile); | ||
67 | $filename = $modulefile; | ||
68 | if ($filename eq "") { | ||
69 | print "Module .ko file for $module not found. Aborting\n"; | ||
70 | exit; | ||
71 | } | ||
72 | # ok so we found the module, now we need to calculate the vma offset | ||
73 | open(FILE, "objdump -dS $filename |") || die "Cannot start objdump"; | ||
74 | while (<FILE>) { | ||
75 | if ($_ =~ /^([0-9a-f]+) \<$function\>\:/) { | ||
76 | my $fu = $1; | ||
77 | $vmaoffset = hex($target) - hex($fu) - hex($func_offset); | ||
78 | } | ||
79 | } | ||
80 | close(FILE); | ||
81 | } | ||
82 | |||
83 | my $counter = 0; | ||
84 | my $state = 0; | ||
85 | my $center = 0; | ||
86 | my @lines; | ||
87 | |||
88 | sub InRange { | ||
89 | my ($address, $target) = @_; | ||
90 | my $ad = "0x".$address; | ||
91 | my $ta = "0x".$target; | ||
92 | my $delta = hex($ad) - hex($ta); | ||
93 | |||
94 | if (($delta > -4096) && ($delta < 4096)) { | ||
95 | return 1; | ||
96 | } | ||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | |||
101 | |||
102 | # first, parse the input into the lines array, but to keep size down, | ||
103 | # we only do this for 4Kb around the sweet spot | ||
104 | |||
105 | open(FILE, "objdump -dS --adjust-vma=$vmaoffset --start-address=$decodestart --stop-address=$decodestop $filename |") || die "Cannot start objdump"; | ||
106 | |||
107 | while (<FILE>) { | ||
108 | my $line = $_; | ||
109 | chomp($line); | ||
110 | if ($state == 0) { | ||
111 | if ($line =~ /^([a-f0-9]+)\:/) { | ||
112 | if (InRange($1, $target)) { | ||
113 | $state = 1; | ||
114 | } | ||
115 | } | ||
116 | } else { | ||
117 | if ($line =~ /^([a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]+)\:/) { | ||
118 | my $val = $1; | ||
119 | if (!InRange($val, $target)) { | ||
120 | last; | ||
121 | } | ||
122 | if ($val eq $target) { | ||
123 | $center = $counter; | ||
124 | } | ||
125 | } | ||
126 | $lines[$counter] = $line; | ||
127 | |||
128 | $counter = $counter + 1; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | close(FILE); | ||
133 | |||
134 | if ($counter == 0) { | ||
135 | print "No matching code found \n"; | ||
136 | exit; | ||
137 | } | ||
138 | |||
139 | if ($center == 0) { | ||
140 | print "No matching code found \n"; | ||
141 | exit; | ||
142 | } | ||
143 | |||
144 | my $start; | ||
145 | my $finish; | ||
146 | my $codelines = 0; | ||
147 | my $binarylines = 0; | ||
148 | # now we go up and down in the array to find how much we want to print | ||
149 | |||
150 | $start = $center; | ||
151 | |||
152 | while ($start > 1) { | ||
153 | $start = $start - 1; | ||
154 | my $line = $lines[$start]; | ||
155 | if ($line =~ /^([a-f0-9]+)\:/) { | ||
156 | $binarylines = $binarylines + 1; | ||
157 | } else { | ||
158 | $codelines = $codelines + 1; | ||
159 | } | ||
160 | if ($codelines > 10) { | ||
161 | last; | ||
162 | } | ||
163 | if ($binarylines > 20) { | ||
164 | last; | ||
165 | } | ||
166 | } | ||
167 | |||
168 | |||
169 | $finish = $center; | ||
170 | $codelines = 0; | ||
171 | $binarylines = 0; | ||
172 | while ($finish < $counter) { | ||
173 | $finish = $finish + 1; | ||
174 | my $line = $lines[$finish]; | ||
175 | if ($line =~ /^([a-f0-9]+)\:/) { | ||
176 | $binarylines = $binarylines + 1; | ||
177 | } else { | ||
178 | $codelines = $codelines + 1; | ||
179 | } | ||
180 | if ($codelines > 10) { | ||
181 | last; | ||
182 | } | ||
183 | if ($binarylines > 20) { | ||
184 | last; | ||
185 | } | ||
186 | } | ||
187 | |||
188 | |||
189 | my $i; | ||
190 | |||
191 | my $fulltext = ""; | ||
192 | $i = $start; | ||
193 | while ($i < $finish) { | ||
194 | if ($i == $center) { | ||
195 | $fulltext = $fulltext . "*$lines[$i] <----- faulting instruction\n"; | ||
196 | } else { | ||
197 | $fulltext = $fulltext . " $lines[$i]\n"; | ||
198 | } | ||
199 | $i = $i +1; | ||
200 | } | ||
201 | |||
202 | print $fulltext; | ||
203 | |||
diff --git a/scripts/tags.sh b/scripts/tags.sh index 4e7547209852..fdbe78bb5e2b 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh | |||
@@ -24,6 +24,11 @@ else | |||
24 | tree=${srctree}/ | 24 | tree=${srctree}/ |
25 | fi | 25 | fi |
26 | 26 | ||
27 | # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH | ||
28 | if [ "${ALLSOURCE_ARCHS}" = "" ]; then | ||
29 | ALLSOURCE_ARCHS=${SRCARCH} | ||
30 | fi | ||
31 | |||
27 | # find sources in arch/$ARCH | 32 | # find sources in arch/$ARCH |
28 | find_arch_sources() | 33 | find_arch_sources() |
29 | { | 34 | { |
@@ -54,26 +59,29 @@ find_other_sources() | |||
54 | find_sources() | 59 | find_sources() |
55 | { | 60 | { |
56 | find_arch_sources $1 "$2" | 61 | find_arch_sources $1 "$2" |
57 | find_include_sources "$2" | ||
58 | find_other_sources "$2" | ||
59 | } | 62 | } |
60 | 63 | ||
61 | all_sources() | 64 | all_sources() |
62 | { | 65 | { |
63 | find_sources $SRCARCH '*.[chS]' | 66 | for arch in $ALLSOURCE_ARCHS |
67 | do | ||
68 | find_sources $arch '*.[chS]' | ||
69 | done | ||
64 | if [ ! -z "$archinclude" ]; then | 70 | if [ ! -z "$archinclude" ]; then |
65 | find_arch_include_sources $archinclude '*.[chS]' | 71 | find_arch_include_sources $archinclude '*.[chS]' |
66 | fi | 72 | fi |
73 | find_include_sources '*.[chS]' | ||
74 | find_other_sources '*.[chS]' | ||
67 | } | 75 | } |
68 | 76 | ||
69 | all_kconfigs() | 77 | all_kconfigs() |
70 | { | 78 | { |
71 | find_sources $SRCARCH 'Kconfig*' | 79 | find_sources $ALLSOURCE_ARCHS 'Kconfig*' |
72 | } | 80 | } |
73 | 81 | ||
74 | all_defconfigs() | 82 | all_defconfigs() |
75 | { | 83 | { |
76 | find_sources $SRCARCH "defconfig" | 84 | find_sources $ALLSOURCE_ARCHS "defconfig" |
77 | } | 85 | } |
78 | 86 | ||
79 | docscope() | 87 | docscope() |
@@ -84,7 +92,6 @@ docscope() | |||
84 | 92 | ||
85 | exuberant() | 93 | exuberant() |
86 | { | 94 | { |
87 | all_sources > all | ||
88 | all_sources | xargs $1 -a \ | 95 | all_sources | xargs $1 -a \ |
89 | -I __initdata,__exitdata,__acquires,__releases \ | 96 | -I __initdata,__exitdata,__acquires,__releases \ |
90 | -I __read_mostly,____cacheline_aligned \ | 97 | -I __read_mostly,____cacheline_aligned \ |