diff options
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/config | 150 | ||||
-rw-r--r-- | scripts/ihex2fw.c | 268 | ||||
-rwxr-xr-x | scripts/tags.sh | 18 |
6 files changed, 445 insertions, 11 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore index b939fbd01195..09e2406f3b78 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -1,6 +1,7 @@ # # Generated files # +ihex2fw conmakehash kallsyms pnmtologo diff --git a/scripts/Makefile b/scripts/Makefile index aafdf064feef..035182e16afb 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -2,11 +2,12 @@ # scripts contains sources for various helper programs used throughout # the kernel for the build process. # --------------------------------------------------------------------------- +# ihex2fw: Parser/loader for IHEX formatted data # kallsyms: Find all symbols in vmlinux # pnmttologo: Convert pnm files to logo files -# conmakehash: Create chartable # conmakehash: Create arrays for initializing the kernel console tables +hostprogs-y := ihex2fw hostprogs-$(CONFIG_KALLSYMS) += kallsyms hostprogs-$(CONFIG_LOGO) += pnmtologo 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 } print "<?xml version=\"1.0\" standalone=\"no\"?> \n"; -print "<svg width=\"1000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n"; +print "<svg width=\"2000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n"; my @styles; @@ -105,8 +105,9 @@ $styles[9] = "fill:rgb(255,255,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0 $styles[10] = "fill:rgb(255,128,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; $styles[11] = "fill:rgb(128,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; -my $mult = 950.0 / ($maxtime - $firsttime); -my $threshold = ($maxtime - $firsttime) / 60.0; +my $mult = 1950.0 / ($maxtime - $firsttime); +my $threshold2 = ($maxtime - $firsttime) / 120.0; +my $threshold = $threshold2/10; my $stylecounter = 0; my %rows; my $rowscount = 1; @@ -116,7 +117,7 @@ foreach my $key (@initcalls) { my $duration = $end{$key} - $start{$key}; if ($duration >= $threshold) { - my ($s, $s2, $e, $w, $y, $y2, $style); + my ($s, $s2, $s3, $e, $w, $y, $y2, $style); my $pid = $pids{$key}; if (!defined($rows{$pid})) { @@ -125,6 +126,7 @@ foreach my $key (@initcalls) { } $s = ($start{$key} - $firsttime) * $mult; $s2 = $s + 6; + $s3 = $s + 1; $e = ($end{$key} - $firsttime) * $mult; $w = $e - $s; @@ -138,7 +140,11 @@ foreach my $key (@initcalls) { }; print "<rect x=\"$s\" width=\"$w\" y=\"$y\" height=\"145\" style=\"$style\"/>\n"; - print "<text transform=\"translate($s2,$y2) rotate(90)\">$key</text>\n"; + if ($duration >= $threshold2) { + print "<text transform=\"translate($s2,$y2) rotate(90)\">$key</text>\n"; + } else { + print "<text transform=\"translate($s3,$y2) rotate(90)\" font-size=\"3pt\">$key</text>\n"; + } } } diff --git a/scripts/config b/scripts/config new file mode 100755 index 000000000000..68b9761cdc38 --- /dev/null +++ b/scripts/config @@ -0,0 +1,150 @@ +#!/bin/bash +# Manipulate options in a .config file from the command line + +usage() { + cat >&2 <<EOL +Manipulate options in a .config file from the command line. +Usage: +config options command ... +commands: + --enable|-e option Enable option + --disable|-d option Disable option + --module|-m option Turn option into a module + --state|-s option Print state of option (n,y,m,undef) + + --enable-after|-E beforeopt option + Enable option directly after other option + --disable-after|-D beforeopt option + Disable option directly after other option + --module-after|-M beforeopt option + Turn option into module directly after other option + + commands can be repeated multiple times + +options: + --file .config file to change (default .config) + +config doesn't check the validity of the .config file. This is done at next + make time. +The options need to be already in the file before they can be changed, +but sometimes you can cheat with the --*-after options. +EOL + exit 1 +} + +checkarg() { + ARG="$1" + if [ "$ARG" = "" ] ; then + usage + fi + case "$ARG" in + CONFIG_*) + ARG="${ARG/CONFIG_/}" + ;; + esac + ARG="`echo $ARG | tr a-z A-Z`" +} + +replace() { + sed -i -e "$@" $FN +} + +if [ "$1" = "--file" ]; then + FN="$2" + if [ "$FN" = "" ] ; then + usage + fi + shift + shift +else + FN=.config +fi + +while [ "$1" != "" ] ; do + CMD="$1" + shift + case "$CMD" in + --enable|-e) + checkarg "$1" + replace "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/" + shift + ;; + + --disable|-d) + checkarg "$1" + replace "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/" + shift + ;; + + --module|-m) + checkarg "$1" + replace "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \ + -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/" + shift + ;; + + --state|-s) + checkarg "$1" + if grep -q "# CONFIG_$ARG is not set" $FN ; then + echo n + else + V="$(grep "^CONFIG_$ARG=" $FN)" + if [ $? != 0 ] ; then + echo undef + else + V="${V/CONFIG_$ARG=/}" + V="${V/\"/}" + echo "$V" + fi + fi + shift + ;; + + --enable-after|-E) + checkarg "$1" + A=$ARG + checkarg "$2" + B=$ARG + replace "/CONFIG_$A=[my]/aCONFIG_$B=y" \ + -e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=y" \ + -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/" + shift + shift + ;; + + --disable-after|-D) + checkarg "$1" + A=$ARG + checkarg "$2" + B=$ARG + replace "/CONFIG_$A=[my]/a# CONFIG_$B is not set" \ + -e "/# CONFIG_$ARG is not set/a/# CONFIG_$ARG is not set" \ + -e "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/" + shift + shift + ;; + + --module-after|-M) + checkarg "$1" + A=$ARG + checkarg "$2" + B=$ARG + replace "/CONFIG_$A=[my]/aCONFIG_$B=m" \ + -e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=m" \ + -e "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \ + -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/" + shift + shift + ;; + + # undocumented because it ignores --file (fixme) + --refresh) + yes "" | make oldconfig + ;; + + *) + usage + ;; + esac +done + 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 @@ +/* + * Parser/loader for IHEX formatted data. + * + * Copyright © 2008 David Woodhouse <dwmw2@infradead.org> + * Copyright © 2005 Jan Harkes <jaharkes@cs.cmu.edu> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <stdint.h> +#include <arpa/inet.h> +#include <stdio.h> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <fcntl.h> +#include <string.h> +#include <unistd.h> +#include <stdlib.h> +#define _GNU_SOURCE +#include <getopt.h> + + +struct ihex_binrec { + struct ihex_binrec *next; /* not part of the real data structure */ + uint32_t addr; + uint16_t len; + uint8_t data[]; +}; + +/** + * nybble/hex are little helpers to parse hexadecimal numbers to a byte value + **/ +static uint8_t nybble(const uint8_t n) +{ + if (n >= '0' && n <= '9') return n - '0'; + else if (n >= 'A' && n <= 'F') return n - ('A' - 10); + else if (n >= 'a' && n <= 'f') return n - ('a' - 10); + return 0; +} + +static uint8_t hex(const uint8_t *data, uint8_t *crc) +{ + uint8_t val = (nybble(data[0]) << 4) | nybble(data[1]); + *crc += val; + return val; +} + +static int process_ihex(uint8_t *data, ssize_t size); +static void file_record(struct ihex_binrec *record); +static int output_records(int outfd); + +static int sort_records = 0; +static int wide_records = 0; + +int usage(void) +{ + fprintf(stderr, "ihex2fw: Convert ihex files into binary " + "representation for use by Linux kernel\n"); + fprintf(stderr, "usage: ihex2fw [<options>] <src.HEX> <dst.fw>\n"); + fprintf(stderr, " -w: wide records (16-bit length)\n"); + fprintf(stderr, " -s: sort records by address\n"); + return 1; +} + +int main(int argc, char **argv) +{ + int infd, outfd; + struct stat st; + uint8_t *data; + int opt; + + while ((opt = getopt(argc, argv, "ws")) != -1) { + switch (opt) { + case 'w': + wide_records = 1; + break; + case 's': + sort_records = 1; + break; + default: + return usage(); + } + } + + if (optind + 2 != argc) + return usage(); + + if (!strcmp(argv[optind], "-")) + infd = 0; + else + infd = open(argv[optind], O_RDONLY); + if (infd == -1) { + fprintf(stderr, "Failed to open source file: %s", + strerror(errno)); + return usage(); + } + if (fstat(infd, &st)) { + perror("stat"); + return 1; + } + data = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, infd, 0); + if (data == MAP_FAILED) { + perror("mmap"); + return 1; + } + + if (!strcmp(argv[optind+1], "-")) + outfd = 1; + else + outfd = open(argv[optind+1], O_TRUNC|O_CREAT|O_WRONLY, 0644); + if (outfd == -1) { + fprintf(stderr, "Failed to open destination file: %s", + strerror(errno)); + return usage(); + } + if (process_ihex(data, st.st_size)) + return 1; + + output_records(outfd); + return 0; +} + +static int process_ihex(uint8_t *data, ssize_t size) +{ + struct ihex_binrec *record; + uint32_t offset = 0; + uint8_t type, crc = 0, crcbyte = 0; + int i, j; + int line = 1; + int len; + + i = 0; +next_record: + /* search for the start of record character */ + while (i < size) { + if (data[i] == '\n') line++; + if (data[i++] == ':') break; + } + + /* Minimum record length would be about 10 characters */ + if (i + 10 > size) { + fprintf(stderr, "Can't find valid record at line %d\n", line); + return -EINVAL; + } + + len = hex(data + i, &crc); i += 2; + if (wide_records) { + len <<= 8; + len += hex(data + i, &crc); i += 2; + } + record = malloc((sizeof (*record) + len + 3) & ~3); + if (!record) { + fprintf(stderr, "out of memory for records\n"); + return -ENOMEM; + } + memset(record, 0, (sizeof(*record) + len + 3) & ~3); + record->len = len; + + /* now check if we have enough data to read everything */ + if (i + 8 + (record->len * 2) > size) { + fprintf(stderr, "Not enough data to read complete record at line %d\n", + line); + return -EINVAL; + } + + record->addr = hex(data + i, &crc) << 8; i += 2; + record->addr |= hex(data + i, &crc); i += 2; + type = hex(data + i, &crc); i += 2; + + for (j = 0; j < record->len; j++, i += 2) + record->data[j] = hex(data + i, &crc); + + /* check CRC */ + crcbyte = hex(data + i, &crc); i += 2; + if (crc != 0) { + fprintf(stderr, "CRC failure at line %d: got 0x%X, expected 0x%X\n", + line, crcbyte, (unsigned char)(crcbyte-crc)); + return -EINVAL; + } + + /* Done reading the record */ + switch (type) { + case 0: + /* old style EOF record? */ + if (!record->len) + break; + + record->addr += offset; + file_record(record); + goto next_record; + + case 1: /* End-Of-File Record */ + if (record->addr || record->len) { + fprintf(stderr, "Bad EOF record (type 01) format at line %d", + line); + return -EINVAL; + } + break; + + case 2: /* Extended Segment Address Record (HEX86) */ + case 4: /* Extended Linear Address Record (HEX386) */ + if (record->addr || record->len != 2) { + fprintf(stderr, "Bad HEX86/HEX386 record (type %02X) at line %d\n", + type, line); + return -EINVAL; + } + + /* We shouldn't really be using the offset for HEX86 because + * the wraparound case is specified quite differently. */ + offset = record->data[0] << 8 | record->data[1]; + offset <<= (type == 2 ? 4 : 16); + goto next_record; + + case 3: /* Start Segment Address Record */ + case 5: /* Start Linear Address Record */ + if (record->addr || record->len != 4) { + fprintf(stderr, "Bad Start Address record (type %02X) at line %d\n", + type, line); + return -EINVAL; + } + + /* These records contain the CS/IP or EIP where execution + * starts. Don't really know what to do with them. */ + goto next_record; + + default: + fprintf(stderr, "Unknown record (type %02X)\n", type); + return -EINVAL; + } + + return 0; +} + +static struct ihex_binrec *records; + +static void file_record(struct ihex_binrec *record) +{ + struct ihex_binrec **p = &records; + + while ((*p) && (!sort_records || (*p)->addr < record->addr)) + p = &((*p)->next); + + record->next = *p; + *p = record; +} + +static int output_records(int outfd) +{ + unsigned char zeroes[6] = {0, 0, 0, 0, 0, 0}; + struct ihex_binrec *p = records; + + while (p) { + uint16_t writelen = (p->len + 9) & ~3; + + p->addr = htonl(p->addr); + p->len = htons(p->len); + write(outfd, &p->addr, writelen); + p = p->next; + } + /* EOF record is zero length, since we don't bother to represent + the type field in the binary version */ + write(outfd, zeroes, 6); + return 0; +} 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 tree=${srctree}/ fi +# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH +if [ "${ALLSOURCE_ARCHS}" = "" ]; then + ALLSOURCE_ARCHS=${SRCARCH} +fi + # find sources in arch/$ARCH find_arch_sources() { @@ -54,26 +59,29 @@ find_other_sources() find_sources() { find_arch_sources $1 "$2" - find_include_sources "$2" - find_other_sources "$2" } all_sources() { - find_sources $SRCARCH '*.[chS]' + for arch in $ALLSOURCE_ARCHS + do + find_sources $arch '*.[chS]' + done if [ ! -z "$archinclude" ]; then find_arch_include_sources $archinclude '*.[chS]' fi + find_include_sources '*.[chS]' + find_other_sources '*.[chS]' } all_kconfigs() { - find_sources $SRCARCH 'Kconfig*' + find_sources $ALLSOURCE_ARCHS 'Kconfig*' } all_defconfigs() { - find_sources $SRCARCH "defconfig" + find_sources $ALLSOURCE_ARCHS "defconfig" } docscope() |