diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-01-10 06:04:41 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-10 06:04:41 -0500 |
commit | b17304245f0db0ac69b795c411407808f3f2796d (patch) | |
tree | 63ed3915d9295bd08f640bf25c322064ba787fad /scripts | |
parent | 889c92d21db40be0b7d22a59395060237895bb85 (diff) | |
parent | 9a100a4464917b5ffff3a8ce1c2758088fd9bb32 (diff) |
Merge branch 'linus' into x86/setup-lzma
Conflicts:
init/do_mounts_rd.c
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/.gitignore | 1 | ||||
-rw-r--r-- | scripts/Makefile | 3 | ||||
-rw-r--r-- | scripts/bootgraph.pl | 16 | ||||
-rwxr-xr-x | scripts/checkpatch.pl | 172 | ||||
-rwxr-xr-x | scripts/config | 150 | ||||
-rw-r--r-- | scripts/ihex2fw.c | 268 | ||||
-rw-r--r-- | scripts/markup_oops.pl | 162 | ||||
-rwxr-xr-x | scripts/tags.sh | 18 |
8 files changed, 736 insertions, 54 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..0a498e33b30b 100644 --- a/scripts/bootgraph.pl +++ b/scripts/bootgraph.pl | |||
@@ -88,7 +88,7 @@ END | |||
88 | } | 88 | } |
89 | 89 | ||
90 | print "<?xml version=\"1.0\" standalone=\"no\"?> \n"; | 90 | 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"; | 91 | print "<svg width=\"2000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n"; |
92 | 92 | ||
93 | my @styles; | 93 | my @styles; |
94 | 94 | ||
@@ -105,8 +105,9 @@ $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)"; | 105 | $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)"; | 106 | $styles[11] = "fill:rgb(128,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; |
107 | 107 | ||
108 | my $mult = 950.0 / ($maxtime - $firsttime); | 108 | my $mult = 1950.0 / ($maxtime - $firsttime); |
109 | my $threshold = ($maxtime - $firsttime) / 60.0; | 109 | my $threshold2 = ($maxtime - $firsttime) / 120.0; |
110 | my $threshold = $threshold2/10; | ||
110 | my $stylecounter = 0; | 111 | my $stylecounter = 0; |
111 | my %rows; | 112 | my %rows; |
112 | my $rowscount = 1; | 113 | my $rowscount = 1; |
@@ -116,7 +117,7 @@ foreach my $key (@initcalls) { | |||
116 | my $duration = $end{$key} - $start{$key}; | 117 | my $duration = $end{$key} - $start{$key}; |
117 | 118 | ||
118 | if ($duration >= $threshold) { | 119 | if ($duration >= $threshold) { |
119 | my ($s, $s2, $e, $w, $y, $y2, $style); | 120 | my ($s, $s2, $s3, $e, $w, $y, $y2, $style); |
120 | my $pid = $pids{$key}; | 121 | my $pid = $pids{$key}; |
121 | 122 | ||
122 | if (!defined($rows{$pid})) { | 123 | if (!defined($rows{$pid})) { |
@@ -125,6 +126,7 @@ foreach my $key (@initcalls) { | |||
125 | } | 126 | } |
126 | $s = ($start{$key} - $firsttime) * $mult; | 127 | $s = ($start{$key} - $firsttime) * $mult; |
127 | $s2 = $s + 6; | 128 | $s2 = $s + 6; |
129 | $s3 = $s + 1; | ||
128 | $e = ($end{$key} - $firsttime) * $mult; | 130 | $e = ($end{$key} - $firsttime) * $mult; |
129 | $w = $e - $s; | 131 | $w = $e - $s; |
130 | 132 | ||
@@ -138,7 +140,11 @@ foreach my $key (@initcalls) { | |||
138 | }; | 140 | }; |
139 | 141 | ||
140 | print "<rect x=\"$s\" width=\"$w\" y=\"$y\" height=\"145\" style=\"$style\"/>\n"; | 142 | print "<rect x=\"$s\" width=\"$w\" y=\"$y\" height=\"145\" style=\"$style\"/>\n"; |
141 | print "<text transform=\"translate($s2,$y2) rotate(90)\">$key</text>\n"; | 143 | if ($duration >= $threshold2) { |
144 | print "<text transform=\"translate($s2,$y2) rotate(90)\">$key</text>\n"; | ||
145 | } else { | ||
146 | print "<text transform=\"translate($s3,$y2) rotate(90)\" font-size=\"3pt\">$key</text>\n"; | ||
147 | } | ||
142 | } | 148 | } |
143 | } | 149 | } |
144 | 150 | ||
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/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/markup_oops.pl b/scripts/markup_oops.pl new file mode 100644 index 000000000000..700a7a654a3f --- /dev/null +++ b/scripts/markup_oops.pl | |||
@@ -0,0 +1,162 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | |||
3 | # Copyright 2008, Intel Corporation | ||
4 | # | ||
5 | # This file is part of the Linux kernel | ||
6 | # | ||
7 | # This program file is free software; you can redistribute it and/or modify it | ||
8 | # under the terms of the GNU General Public License as published by the | ||
9 | # Free Software Foundation; version 2 of the License. | ||
10 | # | ||
11 | # Authors: | ||
12 | # Arjan van de Ven <arjan@linux.intel.com> | ||
13 | |||
14 | |||
15 | my $vmlinux_name = $ARGV[0]; | ||
16 | |||
17 | # | ||
18 | # Step 1: Parse the oops to find the EIP value | ||
19 | # | ||
20 | |||
21 | my $target = "0"; | ||
22 | while (<STDIN>) { | ||
23 | if ($_ =~ /EIP: 0060:\[\<([a-z0-9]+)\>\]/) { | ||
24 | $target = $1; | ||
25 | } | ||
26 | } | ||
27 | |||
28 | if ($target =~ /^f8/) { | ||
29 | print "This script does not work on modules ... \n"; | ||
30 | exit; | ||
31 | } | ||
32 | |||
33 | if ($target eq "0") { | ||
34 | print "No oops found!\n"; | ||
35 | print "Usage: \n"; | ||
36 | print " dmesg | perl scripts/markup_oops.pl vmlinux\n"; | ||
37 | exit; | ||
38 | } | ||
39 | |||
40 | my $counter = 0; | ||
41 | my $state = 0; | ||
42 | my $center = 0; | ||
43 | my @lines; | ||
44 | |||
45 | sub InRange { | ||
46 | my ($address, $target) = @_; | ||
47 | my $ad = "0x".$address; | ||
48 | my $ta = "0x".$target; | ||
49 | my $delta = hex($ad) - hex($ta); | ||
50 | |||
51 | if (($delta > -4096) && ($delta < 4096)) { | ||
52 | return 1; | ||
53 | } | ||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | |||
58 | |||
59 | # first, parse the input into the lines array, but to keep size down, | ||
60 | # we only do this for 4Kb around the sweet spot | ||
61 | |||
62 | my $filename; | ||
63 | |||
64 | open(FILE, "objdump -dS $vmlinux_name |") || die "Cannot start objdump"; | ||
65 | |||
66 | while (<FILE>) { | ||
67 | my $line = $_; | ||
68 | chomp($line); | ||
69 | if ($state == 0) { | ||
70 | if ($line =~ /^([a-f0-9]+)\:/) { | ||
71 | if (InRange($1, $target)) { | ||
72 | $state = 1; | ||
73 | } | ||
74 | } | ||
75 | } else { | ||
76 | if ($line =~ /^([a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]+)\:/) { | ||
77 | my $val = $1; | ||
78 | if (!InRange($val, $target)) { | ||
79 | last; | ||
80 | } | ||
81 | if ($val eq $target) { | ||
82 | $center = $counter; | ||
83 | } | ||
84 | } | ||
85 | $lines[$counter] = $line; | ||
86 | |||
87 | $counter = $counter + 1; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | close(FILE); | ||
92 | |||
93 | if ($counter == 0) { | ||
94 | print "No matching code found \n"; | ||
95 | exit; | ||
96 | } | ||
97 | |||
98 | if ($center == 0) { | ||
99 | print "No matching code found \n"; | ||
100 | exit; | ||
101 | } | ||
102 | |||
103 | my $start; | ||
104 | my $finish; | ||
105 | my $codelines = 0; | ||
106 | my $binarylines = 0; | ||
107 | # now we go up and down in the array to find how much we want to print | ||
108 | |||
109 | $start = $center; | ||
110 | |||
111 | while ($start > 1) { | ||
112 | $start = $start - 1; | ||
113 | my $line = $lines[$start]; | ||
114 | if ($line =~ /^([a-f0-9]+)\:/) { | ||
115 | $binarylines = $binarylines + 1; | ||
116 | } else { | ||
117 | $codelines = $codelines + 1; | ||
118 | } | ||
119 | if ($codelines > 10) { | ||
120 | last; | ||
121 | } | ||
122 | if ($binarylines > 20) { | ||
123 | last; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | |||
128 | $finish = $center; | ||
129 | $codelines = 0; | ||
130 | $binarylines = 0; | ||
131 | while ($finish < $counter) { | ||
132 | $finish = $finish + 1; | ||
133 | my $line = $lines[$finish]; | ||
134 | if ($line =~ /^([a-f0-9]+)\:/) { | ||
135 | $binarylines = $binarylines + 1; | ||
136 | } else { | ||
137 | $codelines = $codelines + 1; | ||
138 | } | ||
139 | if ($codelines > 10) { | ||
140 | last; | ||
141 | } | ||
142 | if ($binarylines > 20) { | ||
143 | last; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | |||
148 | my $i; | ||
149 | |||
150 | my $fulltext = ""; | ||
151 | $i = $start; | ||
152 | while ($i < $finish) { | ||
153 | if ($i == $center) { | ||
154 | $fulltext = $fulltext . "*$lines[$i] <----- faulting instruction\n"; | ||
155 | } else { | ||
156 | $fulltext = $fulltext . " $lines[$i]\n"; | ||
157 | } | ||
158 | $i = $i +1; | ||
159 | } | ||
160 | |||
161 | print $fulltext; | ||
162 | |||
diff --git a/scripts/tags.sh b/scripts/tags.sh index 9e3451d2c3a1..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() |