diff --git a/contrib/dtc/Makefile.convert-dtsv0 b/contrib/dtc/Makefile.convert-dtsv0 deleted file mode 100644 index 08ea40a03a71..000000000000 --- a/contrib/dtc/Makefile.convert-dtsv0 +++ /dev/null @@ -1,13 +0,0 @@ -# -# This is not a complete Makefile of itself. -# Instead, it is designed to be easily embeddable -# into other systems of Makefiles. -# - -CONVERT_SRCS = \ - srcpos.c \ - util.c - -CONVERT_GEN_SRCS = convert-dtsv0-lexer.lex.c - -CONVERT_OBJS = $(CONVERT_SRCS:%.c=%.o) $(CONVERT_GEN_SRCS:%.c=%.o) diff --git a/contrib/dtc/Makefile.ftdump b/contrib/dtc/Makefile.ftdump deleted file mode 100644 index b70905ad10c9..000000000000 --- a/contrib/dtc/Makefile.ftdump +++ /dev/null @@ -1,12 +0,0 @@ -# -# This is not a complete Makefile of itself. -# Instead, it is designed to be easily embeddable -# into other systems of Makefiles. -# - -FTDUMP_SRCS = \ - ftdump.c - -FTDUMP_GEN_SRCS = - -FTDUMP_OBJS = $(FTDUMP_SRCS:%.c=%.o) $(FTDUMP_GEN_SRCS:%.c=%.o) diff --git a/contrib/dtc/convert-dtsv0-lexer.l b/contrib/dtc/convert-dtsv0-lexer.l deleted file mode 100644 index 89d540a7f23e..000000000000 --- a/contrib/dtc/convert-dtsv0-lexer.l +++ /dev/null @@ -1,240 +0,0 @@ -/* - * (C) Copyright David Gibson , IBM Corporation. 2005, 2008. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -%option noyywrap nounput noinput never-interactive - -%x INCLUDE -%x BYTESTRING -%x PROPNODENAME - -PROPNODECHAR [a-zA-Z0-9,._+*#?@-] -PATHCHAR ({PROPNODECHAR}|[/]) -LABEL [a-zA-Z_][a-zA-Z0-9_]* -STRING \"([^\\"]|\\.)*\" -WS [[:space:]] -COMMENT "/*"([^*]|\*+[^*/])*\*+"/" -LINECOMMENT "//".*\n -GAP ({WS}|{COMMENT}|{LINECOMMENT})* - -%{ -#include -#include -#include - -#include -#include -#include - -#include "srcpos.h" -#include "util.h" - -static int v1_tagged; /* = 0 */ -static int cbase = 16; -static int saw_hyphen; /* = 0 */ -static unsigned long long last_val; -static char *last_name; /* = NULL */ - -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) - -const struct { - const char *pattern; - int obase, width; -} guess_table[] = { - { "*-frequency", 10, 0 }, - { "num-*", 10, 0 }, - { "#*-cells", 10, 0 }, - { "*cache-line-size", 10, 0 }, - { "*cache-block-size", 10, 0 }, - { "*cache-size", 10, 0 }, - { "*cache-sets", 10, 0 }, - { "cell-index", 10, 0 }, - { "bank-width", 10, 0 }, - { "*-fifo-size", 10, 0 }, - { "*-frame-size", 10, 0 }, - { "*-channel", 10, 0 }, - { "current-speed", 10, 0 }, - { "phy-map", 16, 8 }, - { "dcr-reg", 16, 3 }, - { "reg", 16, 8 }, - { "ranges", 16, 8}, -}; -%} - -%% -<*>"/include/"{GAP}{STRING} ECHO; - -<*>\"([^\\"]|\\.)*\" ECHO; - -<*>"/dts-v1/" { - die("Input dts file is already version 1\n"); - } - -<*>"/memreserve/" { - if (!v1_tagged) { - fprintf(yyout, "/dts-v1/;\n\n"); - v1_tagged = 1; - } - - ECHO; - BEGIN(INITIAL); - } - -<*>{LABEL}: ECHO; - -[bodh]# { - if (*yytext == 'b') - cbase = 2; - else if (*yytext == 'o') - cbase = 8; - else if (*yytext == 'd') - cbase = 10; - else - cbase = 16; - } - -[0-9a-fA-F]+ { - unsigned long long val; - int obase = 16, width = 0; - int i; - - val = strtoull(yytext, NULL, cbase); - - if (saw_hyphen) - val = val - last_val + 1; - - if (last_name) { - for (i = 0; i < ARRAY_SIZE(guess_table); i++) - if (fnmatch(guess_table[i].pattern, - last_name, 0) == 0) { - obase = guess_table[i].obase; - width = guess_table[i].width; - } - } else { - obase = 16; - width = 16; - } - - if (cbase != 16) - obase = cbase; - - switch (obase) { - case 2: - case 16: - fprintf(yyout, "0x%0*llx", width, val); - break; - case 8: - fprintf(yyout, "0%0*llo", width, val); - break; - case 10: - fprintf(yyout, "%*llu", width, val); - break; - } - - cbase = 16; - last_val = val; - saw_hyphen = 0; - } - -\&{LABEL} ECHO; - -"&{/"{PATHCHAR}+\} ECHO; - -"&/"{PATHCHAR}+ fprintf(yyout, "&{/%s}", yytext + 2); - -[0-9a-fA-F]{2} ECHO; - -"]" { - ECHO; - BEGIN(INITIAL); - } - -{PROPNODECHAR}+ { - ECHO; - last_name = xstrdup(yytext); - BEGIN(INITIAL); - } - -<*>{GAP} ECHO; - -<*>- { /* Hack to convert old style memreserves */ - saw_hyphen = 1; - fprintf(yyout, " "); - } - -<*>. { - if (!v1_tagged) { - fprintf(yyout, "/dts-v1/;\n\n"); - v1_tagged = 1; - } - - ECHO; - if (yytext[0] == '[') { - BEGIN(BYTESTRING); - } - if ((yytext[0] == '{') - || (yytext[0] == ';')) { - BEGIN(PROPNODENAME); - } - } - -%% -static void usage(void) -{ - fprintf(stderr, "convert-dtsv0 ...\n"); - exit(3); -} - -static void convert_file(const char *fname) -{ - const char suffix[] = "v1"; - int len = strlen(fname); - char *newname; - - newname = xmalloc(len + sizeof(suffix)); - memcpy(newname, fname, len); - memcpy(newname + len, suffix, sizeof(suffix)); - - yyin = fopen(fname, "r"); - if (!yyin) - die("Couldn't open input file %s: %s\n", - fname, strerror(errno)); - - yyout = fopen(newname, "w"); - if (!yyout) - die("Couldn't open output file %s: %s\n", - newname, strerror(errno)); - - while(yylex()) - ; -} - -int main(int argc, char *argv[]) -{ - int i; - - if (argc < 2) - usage(); - - for (i = 1; i < argc; i++) { - fprintf(stderr, "Converting %s from dts v0 to dts v1\n", argv[i]); - convert_file(argv[i]); - } - - exit(0); -} diff --git a/contrib/dtc/ftdump.c b/contrib/dtc/ftdump.c deleted file mode 100644 index bce653573edc..000000000000 --- a/contrib/dtc/ftdump.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * ftdump.c - Contributed by Pantelis Antoniou - */ - -#include -#include -#include -#include -#include - -#include -#include - -#define FTDUMP_BUF_SIZE 65536 - -#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) -#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) -#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4))) - -static int is_printable_string(const void *data, int len) -{ - const char *s = data; - const char *ss; - - /* zero length is not */ - if (len == 0) - return 0; - - /* must terminate with zero */ - if (s[len - 1] != '\0') - return 0; - - ss = s; - while (*s && isprint(*s)) - s++; - - /* not zero, or not done yet */ - if (*s != '\0' || (s + 1 - ss) < len) - return 0; - - return 1; -} - -static void print_data(const char *data, int len) -{ - int i; - const char *p = data; - - /* no data, don't print */ - if (len == 0) - return; - - if (is_printable_string(data, len)) { - printf(" = \"%s\"", (const char *)data); - } else if ((len % 4) == 0) { - printf(" = <"); - for (i = 0; i < len; i += 4) - printf("0x%08x%s", fdt32_to_cpu(GET_CELL(p)), - i < (len - 4) ? " " : ""); - printf(">"); - } else { - printf(" = ["); - for (i = 0; i < len; i++) - printf("%02x%s", *p++, i < len - 1 ? " " : ""); - printf("]"); - } -} - -static void dump_blob(void *blob) -{ - struct fdt_header *bph = blob; - uint32_t off_mem_rsvmap = fdt32_to_cpu(bph->off_mem_rsvmap); - uint32_t off_dt = fdt32_to_cpu(bph->off_dt_struct); - uint32_t off_str = fdt32_to_cpu(bph->off_dt_strings); - struct fdt_reserve_entry *p_rsvmap = - (struct fdt_reserve_entry *)((char *)blob + off_mem_rsvmap); - const char *p_struct = (const char *)blob + off_dt; - const char *p_strings = (const char *)blob + off_str; - uint32_t version = fdt32_to_cpu(bph->version); - uint32_t totalsize = fdt32_to_cpu(bph->totalsize); - uint32_t tag; - const char *p, *s, *t; - int depth, sz, shift; - int i; - uint64_t addr, size; - - depth = 0; - shift = 4; - - printf("/dts-v1/;\n"); - printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic)); - printf("// totalsize:\t\t0x%x (%d)\n", totalsize, totalsize); - printf("// off_dt_struct:\t0x%x\n", off_dt); - printf("// off_dt_strings:\t0x%x\n", off_str); - printf("// off_mem_rsvmap:\t0x%x\n", off_mem_rsvmap); - printf("// version:\t\t%d\n", version); - printf("// last_comp_version:\t%d\n", - fdt32_to_cpu(bph->last_comp_version)); - if (version >= 2) - printf("// boot_cpuid_phys:\t0x%x\n", - fdt32_to_cpu(bph->boot_cpuid_phys)); - - if (version >= 3) - printf("// size_dt_strings:\t0x%x\n", - fdt32_to_cpu(bph->size_dt_strings)); - if (version >= 17) - printf("// size_dt_struct:\t0x%x\n", - fdt32_to_cpu(bph->size_dt_struct)); - printf("\n"); - - for (i = 0; ; i++) { - addr = fdt64_to_cpu(p_rsvmap[i].address); - size = fdt64_to_cpu(p_rsvmap[i].size); - if (addr == 0 && size == 0) - break; - - printf("/memreserve/ %llx %llx;\n", - (unsigned long long)addr, (unsigned long long)size); - } - - p = p_struct; - while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) { - - /* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */ - - if (tag == FDT_BEGIN_NODE) { - s = p; - p = PALIGN(p + strlen(s) + 1, 4); - - if (*s == '\0') - s = "/"; - - printf("%*s%s {\n", depth * shift, "", s); - - depth++; - continue; - } - - if (tag == FDT_END_NODE) { - depth--; - - printf("%*s};\n", depth * shift, ""); - continue; - } - - if (tag == FDT_NOP) { - printf("%*s// [NOP]\n", depth * shift, ""); - continue; - } - - if (tag != FDT_PROP) { - fprintf(stderr, "%*s ** Unknown tag 0x%08x\n", depth * shift, "", tag); - break; - } - sz = fdt32_to_cpu(GET_CELL(p)); - s = p_strings + fdt32_to_cpu(GET_CELL(p)); - if (version < 16 && sz >= 8) - p = PALIGN(p, 8); - t = p; - - p = PALIGN(p + sz, 4); - - printf("%*s%s", depth * shift, "", s); - print_data(t, sz); - printf(";\n"); - } -} - - -int main(int argc, char *argv[]) -{ - FILE *fp; - char *buf; - int size; - - if (argc < 2) { - fprintf(stderr, "supply input filename\n"); - return 5; - } - - if (strcmp(argv[1], "-") == 0) { - fp = stdin; - } else { - fp = fopen(argv[1], "rb"); - if (fp == NULL) { - fprintf(stderr, "unable to open %s\n", argv[1]); - return 10; - } - } - - buf = malloc(FTDUMP_BUF_SIZE); - if (!buf) { - fprintf(stderr, "Couldn't allocate %d byte buffer\n", FTDUMP_BUF_SIZE); - return 10; - } - - size = fread(buf, 1, FTDUMP_BUF_SIZE, fp); - if (size == FTDUMP_BUF_SIZE) { - fprintf(stderr, "file too large (maximum is %d bytes)\n", FTDUMP_BUF_SIZE); - return 10; - } - - dump_blob(buf); - - fclose(fp); - - return 0; -}