aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-01-10 21:41:39 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-10 21:41:39 -0500
commitabede81c4fb2e3b85d8760f25e3da39d2c69a134 (patch)
tree26c893ec108d837eb9171d678c55a1cea7b22af4 /scripts
parentc9d557c19f94df42db78d4a5de4d25feee694bad (diff)
parentc59765042f53a79a7a65585042ff463b69cb248c (diff)
Merge commit 'v2.6.29-rc1' into core/urgent
Diffstat (limited to 'scripts')
-rw-r--r--scripts/.gitignore1
-rw-r--r--scripts/Makefile3
-rw-r--r--scripts/bootgraph.pl56
-rwxr-xr-xscripts/config150
-rw-r--r--scripts/ihex2fw.c268
-rwxr-xr-xscripts/tags.sh18
6 files changed, 484 insertions, 12 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#
4ihex2fw
4conmakehash 5conmakehash
5kallsyms 6kallsyms
6pnmtologo 7pnmtologo
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
10hostprogs-y := ihex2fw
10hostprogs-$(CONFIG_KALLSYMS) += kallsyms 11hostprogs-$(CONFIG_KALLSYMS) += kallsyms
11hostprogs-$(CONFIG_LOGO) += pnmtologo 12hostprogs-$(CONFIG_LOGO) += pnmtologo
12hostprogs-$(CONFIG_VT) += conmakehash 13hostprogs-$(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
42my %start; 42my %start;
43my %end; 43my %end;
44my %type;
44my $done = 0; 45my $done = 0;
45my $maxtime = 0; 46my $maxtime = 0;
46my $firsttime = 100; 47my $firsttime = 100;
47my $count = 0; 48my $count = 0;
48my %pids; 49my %pids;
50my %pidctr;
49 51
50while (<>) { 52while (<>) {
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
90print "<?xml version=\"1.0\" standalone=\"no\"?> \n"; 121print "<?xml version=\"1.0\" standalone=\"no\"?> \n";
91print "<svg width=\"1000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n"; 122print "<svg width=\"2000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n";
92 123
93my @styles; 124my @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
108my $mult = 950.0 / ($maxtime - $firsttime); 139my $style_wait = "fill:rgb(128,128,128);fill-opacity:0.5;stroke-width:0;stroke:rgb(0,0,0)";
109my $threshold = ($maxtime - $firsttime) / 60.0; 140
141my $mult = 1950.0 / ($maxtime - $firsttime);
142my $threshold2 = ($maxtime - $firsttime) / 120.0;
143my $threshold = $threshold2/10;
110my $stylecounter = 0; 144my $stylecounter = 0;
111my %rows; 145my %rows;
112my $rowscount = 1; 146my $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/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
4usage() {
5 cat >&2 <<EOL
6Manipulate options in a .config file from the command line.
7Usage:
8config options command ...
9commands:
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
24options:
25 --file .config file to change (default .config)
26
27config doesn't check the validity of the .config file. This is done at next
28 make time.
29The options need to be already in the file before they can be changed,
30but sometimes you can cheat with the --*-after options.
31EOL
32 exit 1
33}
34
35checkarg() {
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
48replace() {
49 sed -i -e "$@" $FN
50}
51
52if [ "$1" = "--file" ]; then
53 FN="$2"
54 if [ "$FN" = "" ] ; then
55 usage
56 fi
57 shift
58 shift
59else
60 FN=.config
61fi
62
63while [ "$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
149done
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
27struct 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 **/
37static 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
45static 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
52static int process_ihex(uint8_t *data, ssize_t size);
53static void file_record(struct ihex_binrec *record);
54static int output_records(int outfd);
55
56static int sort_records = 0;
57static int wide_records = 0;
58
59int 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
69int 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
127static 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;
137next_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
238static struct ihex_binrec *records;
239
240static 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
251static 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/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}/
25fi 25fi
26 26
27# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
28if [ "${ALLSOURCE_ARCHS}" = "" ]; then
29 ALLSOURCE_ARCHS=${SRCARCH}
30fi
31
27# find sources in arch/$ARCH 32# find sources in arch/$ARCH
28find_arch_sources() 33find_arch_sources()
29{ 34{
@@ -54,26 +59,29 @@ find_other_sources()
54find_sources() 59find_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
61all_sources() 64all_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
69all_kconfigs() 77all_kconfigs()
70{ 78{
71 find_sources $SRCARCH 'Kconfig*' 79 find_sources $ALLSOURCE_ARCHS 'Kconfig*'
72} 80}
73 81
74all_defconfigs() 82all_defconfigs()
75{ 83{
76 find_sources $SRCARCH "defconfig" 84 find_sources $ALLSOURCE_ARCHS "defconfig"
77} 85}
78 86
79docscope() 87docscope()