Thu Jun 8 16:00:40 2017 UTC ()
Merge conflicts


(skrll)
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/.gitignore
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/.travis.yml
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/data.c
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/dtc-lexer.l
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/dtc-parser.y
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/dtc.h
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/fdtdump.c
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/fdtput.c
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/flattree.c
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/srcpos.c
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/util.h
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/Makefile.libfdt
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/TODO
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/fdt.c
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/fdt.h
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/fdt_addresses.c
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/fdt_empty_tree.c
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/fdt_ro.c
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/fdt_rw.c
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/fdt_strerror.c
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/fdt_sw.c
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/fdt_wip.c
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/libfdt.h
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/libfdt_env.h
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/libfdt_internal.h
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/libfdt/version.lds
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/tests/mangle-layout.c
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/tests/move_and_save.c
diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/tests/tests.h
diff -r1.1.1.1 -r0 src/external/gpl2/dtc/dist/tests/test_tree1_body.dtsi

File Deleted: src/external/gpl2/dtc/dist/Attic/.gitignore

File Deleted: src/external/gpl2/dtc/dist/Attic/.travis.yml

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/data.c (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/data.c 2017/06/06 20:19:04 1.2
+++ src/external/gpl2/dtc/dist/data.c 2017/06/08 16:00:40 1.3
@@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
 1/* $NetBSD: data.c,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1/* 3/*
2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. 4 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
3 * 5 *
4 * 6 *
5 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the 9 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version. 10 * License, or (at your option) any later version.
9 * 11 *
10 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details. 15 * General Public License for more details.
@@ -161,60 +163,60 @@ struct data data_merge(struct data d1, s @@ -161,60 +163,60 @@ struct data data_merge(struct data d1, s
161 /* Adjust for the length of d1 */ 163 /* Adjust for the length of d1 */
162 for_each_marker(m2) 164 for_each_marker(m2)
163 m2->offset += d1.len; 165 m2->offset += d1.len;
164 166
165 d2.markers = NULL; /* So data_free() doesn't clobber them */ 167 d2.markers = NULL; /* So data_free() doesn't clobber them */
166 data_free(d2); 168 data_free(d2);
167 169
168 return d; 170 return d;
169} 171}
170 172
171struct data data_append_integer(struct data d, uint64_t value, int bits) 173struct data data_append_integer(struct data d, uint64_t value, int bits)
172{ 174{
173 uint8_t value_8; 175 uint8_t value_8;
174 uint16_t value_16; 176 fdt16_t value_16;
175 uint32_t value_32; 177 fdt32_t value_32;
176 uint64_t value_64; 178 fdt64_t value_64;
177 179
178 switch (bits) { 180 switch (bits) {
179 case 8: 181 case 8:
180 value_8 = value; 182 value_8 = value;
181 return data_append_data(d, &value_8, 1); 183 return data_append_data(d, &value_8, 1);
182 184
183 case 16: 185 case 16:
184 value_16 = cpu_to_fdt16(value); 186 value_16 = cpu_to_fdt16(value);
185 return data_append_data(d, &value_16, 2); 187 return data_append_data(d, &value_16, 2);
186 188
187 case 32: 189 case 32:
188 value_32 = cpu_to_fdt32(value); 190 value_32 = cpu_to_fdt32(value);
189 return data_append_data(d, &value_32, 4); 191 return data_append_data(d, &value_32, 4);
190 192
191 case 64: 193 case 64:
192 value_64 = cpu_to_fdt64(value); 194 value_64 = cpu_to_fdt64(value);
193 return data_append_data(d, &value_64, 8); 195 return data_append_data(d, &value_64, 8);
194 196
195 default: 197 default:
196 die("Invalid literal size (%d)\n", bits); 198 die("Invalid literal size (%d)\n", bits);
197 } 199 }
198} 200}
199 201
200struct data data_append_re(struct data d, const struct fdt_reserve_entry *re) 202struct data data_append_re(struct data d, uint64_t address, uint64_t size)
201{ 203{
202 struct fdt_reserve_entry bere; 204 struct fdt_reserve_entry re;
203 205
204 bere.address = cpu_to_fdt64(re->address); 206 re.address = cpu_to_fdt64(address);
205 bere.size = cpu_to_fdt64(re->size); 207 re.size = cpu_to_fdt64(size);
206 208
207 return data_append_data(d, &bere, sizeof(bere)); 209 return data_append_data(d, &re, sizeof(re));
208} 210}
209 211
210struct data data_append_cell(struct data d, cell_t word) 212struct data data_append_cell(struct data d, cell_t word)
211{ 213{
212 return data_append_integer(d, word, sizeof(word) * 8); 214 return data_append_integer(d, word, sizeof(word) * 8);
213} 215}
214 216
215struct data data_append_addr(struct data d, uint64_t addr) 217struct data data_append_addr(struct data d, uint64_t addr)
216{ 218{
217 return data_append_integer(d, addr, sizeof(addr) * 8); 219 return data_append_integer(d, addr, sizeof(addr) * 8);
218} 220}
219 221
220struct data data_append_byte(struct data d, uint8_t byte) 222struct data data_append_byte(struct data d, uint8_t byte)

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/dtc-lexer.l (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/dtc-lexer.l 2017/06/05 18:59:10 1.2
+++ src/external/gpl2/dtc/dist/dtc-lexer.l 2017/06/08 16:00:40 1.3
@@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
 1/* $NetBSD: dtc-lexer.l,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1/* 3/*
2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. 4 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
3 * 5 *
4 * 6 *
5 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the 9 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version. 10 * License, or (at your option) any later version.
9 * 11 *
10 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details. 15 * General Public License for more details.
@@ -52,77 +54,91 @@ extern bool treesource_error; @@ -52,77 +54,91 @@ extern bool treesource_error;
52#ifdef LEXDEBUG 54#ifdef LEXDEBUG
53#define DPRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__) 55#define DPRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
54#else 56#else
55#define DPRINT(fmt, ...) do { } while (0) 57#define DPRINT(fmt, ...) do { } while (0)
56#endif 58#endif
57 59
58static int dts_version = 1; 60static int dts_version = 1;
59 61
60#define BEGIN_DEFAULT() DPRINT("<V1>\n"); \ 62#define BEGIN_DEFAULT() DPRINT("<V1>\n"); \
61 BEGIN(V1); \ 63 BEGIN(V1); \
62 64
63static void push_input_file(const char *filename); 65static void push_input_file(const char *filename);
64static bool pop_input_file(void); 66static bool pop_input_file(void);
65static void lexical_error(const char *fmt, ...); 67static void PRINTF(1, 2) lexical_error(const char *fmt, ...);
 68
66%} 69%}
67 70
68%% 71%%
69<*>"/include/"{WS}*{STRING} { 72<*>"/include/"{WS}*{STRING} {
70 char *name = strchr(yytext, '\"') + 1; 73 char *name = strchr(yytext, '\"') + 1;
71 yytext[yyleng-1] = '\0'; 74 yytext[yyleng-1] = '\0';
72 push_input_file(name); 75 push_input_file(name);
73 } 76 }
74 77
75<*>^"#"(line)?[ \t]+[0-9]+[ \t]+{STRING}([ \t]+[0-9]+)? { 78<*>^"#"(line)?[ \t]+[0-9]+[ \t]+{STRING}([ \t]+[0-9]+)? {
76 char *line, *tmp, *fn; 79 char *line, *fnstart, *fnend;
 80 struct data fn;
77 /* skip text before line # */ 81 /* skip text before line # */
78 line = yytext; 82 line = yytext;
79 while (!isdigit((unsigned char)*line)) 83 while (!isdigit((unsigned char)*line))
80 line++; 84 line++;
81 /* skip digits in line # */ 85
82 tmp = line; 86 /* regexp ensures that first and list "
83 while (!isspace((unsigned char)*tmp)) 87 * in the whole yytext are those at
84 tmp++; 88 * beginning and end of the filename string */
85 /* "NULL"-terminate line # */ 89 fnstart = memchr(yytext, '"', yyleng);
86 *tmp = '\0'; 90 for (fnend = yytext + yyleng - 1;
87 /* start of filename */ 91 *fnend != '"'; fnend--)
88 fn = strchr(tmp + 1, '"') + 1; 92 ;
89 /* strip trailing " from filename */ 93 assert(fnstart && fnend && (fnend > fnstart));
90 tmp = strchr(fn, '"'); 94
91 *tmp = 0; 95 fn = data_copy_escape_string(fnstart + 1,
 96 fnend - fnstart - 1);
 97
 98 /* Don't allow nuls in filenames */
 99 if (memchr(fn.val, '\0', fn.len - 1))
 100 lexical_error("nul in line number directive");
 101
92 /* -1 since #line is the number of the next line */ 102 /* -1 since #line is the number of the next line */
93 srcpos_set_line(xstrdup(fn), atoi(line) - 1); 103 srcpos_set_line(xstrdup(fn.val), atoi(line) - 1);
 104 data_free(fn);
94 } 105 }
95 106
96<*><<EOF>> { 107<*><<EOF>> {
97 if (!pop_input_file()) { 108 if (!pop_input_file()) {
98 yyterminate(); 109 yyterminate();
99 } 110 }
100 } 111 }
101 112
102<*>{STRING} { 113<*>{STRING} {
103 DPRINT("String: %s\n", yytext); 114 DPRINT("String: %s\n", yytext);
104 yylval.data = data_copy_escape_string(yytext+1, 115 yylval.data = data_copy_escape_string(yytext+1,
105 yyleng-2); 116 yyleng-2);
106 return DT_STRING; 117 return DT_STRING;
107 } 118 }
108 119
109<*>"/dts-v1/" { 120<*>"/dts-v1/" {
110 DPRINT("Keyword: /dts-v1/\n"); 121 DPRINT("Keyword: /dts-v1/\n");
111 dts_version = 1; 122 dts_version = 1;
112 BEGIN_DEFAULT(); 123 BEGIN_DEFAULT();
113 return DT_V1; 124 return DT_V1;
114 } 125 }
115 126
 127<*>"/plugin/" {
 128 DPRINT("Keyword: /plugin/\n");
 129 return DT_PLUGIN;
 130 }
 131
116<*>"/memreserve/" { 132<*>"/memreserve/" {
117 DPRINT("Keyword: /memreserve/\n"); 133 DPRINT("Keyword: /memreserve/\n");
118 BEGIN_DEFAULT(); 134 BEGIN_DEFAULT();
119 return DT_MEMRESERVE; 135 return DT_MEMRESERVE;
120 } 136 }
121 137
122<*>"/bits/" { 138<*>"/bits/" {
123 DPRINT("Keyword: /bits/\n"); 139 DPRINT("Keyword: /bits/\n");
124 BEGIN_DEFAULT(); 140 BEGIN_DEFAULT();
125 return DT_BITS; 141 return DT_BITS;
126 } 142 }
127 143
128<*>"/delete-property/" { 144<*>"/delete-property/" {
@@ -143,56 +159,59 @@ static void lexical_error(const char *fm @@ -143,56 +159,59 @@ static void lexical_error(const char *fm
143 DPRINT("Label: %s\n", yytext); 159 DPRINT("Label: %s\n", yytext);
144 yylval.labelref = xstrdup(yytext); 160 yylval.labelref = xstrdup(yytext);
145 yylval.labelref[yyleng-1] = '\0'; 161 yylval.labelref[yyleng-1] = '\0';
146 return DT_LABEL; 162 return DT_LABEL;
147 } 163 }
148 164
149<V1>([0-9]+|0[xX][0-9a-fA-F]+)(U|L|UL|LL|ULL)? { 165<V1>([0-9]+|0[xX][0-9a-fA-F]+)(U|L|UL|LL|ULL)? {
150 char *e; 166 char *e;
151 DPRINT("Integer Literal: '%s'\n", yytext); 167 DPRINT("Integer Literal: '%s'\n", yytext);
152 168
153 errno = 0; 169 errno = 0;
154 yylval.integer = strtoull(yytext, &e, 0); 170 yylval.integer = strtoull(yytext, &e, 0);
155 171
156 assert(!(*e) || !e[strspn(e, "UL")]); 172 if (*e && e[strspn(e, "UL")]) {
 173 lexical_error("Bad integer literal '%s'",
 174 yytext);
 175 }
157 176
158 if (errno == ERANGE) 177 if (errno == ERANGE)
159 lexical_error("Integer literal '%s' out of range", 178 lexical_error("Integer literal '%s' out of range",
160 yytext); 179 yytext);
161 else 180 else
162 /* ERANGE is the only strtoull error triggerable 181 /* ERANGE is the only strtoull error triggerable
163 * by strings matching the pattern */ 182 * by strings matching the pattern */
164 assert(errno == 0); 183 assert(errno == 0);
165 return DT_LITERAL; 184 return DT_LITERAL;
166 } 185 }
167 186
168<*>{CHAR_LITERAL} { 187<*>{CHAR_LITERAL} {
169 struct data d; 188 struct data d;
170 DPRINT("Character literal: %s\n", yytext); 189 DPRINT("Character literal: %s\n", yytext);
171 190
172 d = data_copy_escape_string(yytext+1, yyleng-2); 191 d = data_copy_escape_string(yytext+1, yyleng-2);
173 if (d.len == 1) { 192 if (d.len == 1) {
174 lexical_error("Empty character literal"); 193 lexical_error("Empty character literal");
175 yylval.integer = 0; 194 yylval.integer = 0;
176 return DT_CHAR_LITERAL; 195 } else {
177 } 196 yylval.integer = (unsigned char)d.val[0];
178 197
179 yylval.integer = (unsigned char)d.val[0]; 198 if (d.len > 2)
180 199 lexical_error("Character literal has %d"
181 if (d.len > 2) 200 " characters instead of 1",
182 lexical_error("Character literal has %d" 201 d.len - 1);
183 " characters instead of 1", 202 }
184 d.len - 1); 
185 203
 204 data_free(d);
186 return DT_CHAR_LITERAL; 205 return DT_CHAR_LITERAL;
187 } 206 }
188 207
189<*>\&{LABEL} { /* label reference */ 208<*>\&{LABEL} { /* label reference */
190 DPRINT("Ref: %s\n", yytext+1); 209 DPRINT("Ref: %s\n", yytext+1);
191 yylval.labelref = xstrdup(yytext+1); 210 yylval.labelref = xstrdup(yytext+1);
192 return DT_REF; 211 return DT_REF;
193 } 212 }
194 213
195<*>"&{/"{PATHCHAR}*\} { /* new-style path reference */ 214<*>"&{/"{PATHCHAR}*\} { /* new-style path reference */
196 yytext[yyleng-1] = '\0'; 215 yytext[yyleng-1] = '\0';
197 DPRINT("Ref: %s\n", yytext+2); 216 DPRINT("Ref: %s\n", yytext+2);
198 yylval.labelref = xstrdup(yytext+2); 217 yylval.labelref = xstrdup(yytext+2);

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/dtc-parser.y (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/dtc-parser.y 2017/06/05 18:59:21 1.2
+++ src/external/gpl2/dtc/dist/dtc-parser.y 2017/06/08 16:00:40 1.3
@@ -1,90 +1,97 @@ @@ -1,90 +1,97 @@
 1/* $NetBSD: dtc-parser.y,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1/* 3/*
2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. 4 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
3 * 5 *
4 * 6 *
5 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the 9 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version. 10 * License, or (at your option) any later version.
9 * 11 *
10 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details. 15 * General Public License for more details.
14 * 16 *
15 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 * USA 20 * USA
19 */ 21 */
20%{ 22%{
21#include <stdio.h> 23#include <stdio.h>
 24#include <inttypes.h>
22 25
23#include "dtc.h" 26#include "dtc.h"
24#include "srcpos.h" 27#include "srcpos.h"
25 28
26extern int yylex(void); 29extern int yylex(void);
27#ifndef YYBYACC 30#ifndef YYBYACC
28extern void yyerror(char const *s); 31extern void yyerror(char const *s);
29#else 32#else
30#include "dtc-parser.h" 33#include "dtc-parser.h"
31#endif 34#endif
32#define ERROR(loc, ...) \ 35#define ERROR(loc, ...) \
33 do { \ 36 do { \
34 srcpos_error((loc), "Error", __VA_ARGS__); \ 37 srcpos_error((loc), "Error", __VA_ARGS__); \
35 treesource_error = true; \ 38 treesource_error = true; \
36 } while (0) 39 } while (0)
37 40
38extern struct boot_info *the_boot_info; 41extern struct dt_info *parser_output;
39extern bool treesource_error; 42extern bool treesource_error;
40%} 43%}
41 44
42%union { 45%union {
43 char *propnodename; 46 char *propnodename;
44 char *labelref; 47 char *labelref;
45 uint8_t byte; 48 uint8_t byte;
46 struct data data; 49 struct data data;
47 50
48 struct { 51 struct {
49 struct data data; 52 struct data data;
50 int bits; 53 int bits;
51 } array; 54 } array;
52 55
53 struct property *prop; 56 struct property *prop;
54 struct property *proplist; 57 struct property *proplist;
55 struct node *node; 58 struct node *node;
56 struct node *nodelist; 59 struct node *nodelist;
57 struct reserve_info *re; 60 struct reserve_info *re;
58 uint64_t integer; 61 uint64_t integer;
 62 unsigned int flags;
59} 63}
60 64
61%token DT_V1 65%token DT_V1
 66%token DT_PLUGIN
62%token DT_MEMRESERVE 67%token DT_MEMRESERVE
63%token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ DT_NE DT_AND DT_OR 68%token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ DT_NE DT_AND DT_OR
64%token DT_BITS 69%token DT_BITS
65%token DT_DEL_PROP 70%token DT_DEL_PROP
66%token DT_DEL_NODE 71%token DT_DEL_NODE
67%token <propnodename> DT_PROPNODENAME 72%token <propnodename> DT_PROPNODENAME
68%token <integer> DT_LITERAL 73%token <integer> DT_LITERAL
69%token <integer> DT_CHAR_LITERAL 74%token <integer> DT_CHAR_LITERAL
70%token <byte> DT_BYTE 75%token <byte> DT_BYTE
71%token <data> DT_STRING 76%token <data> DT_STRING
72%token <labelref> DT_LABEL 77%token <labelref> DT_LABEL
73%token <labelref> DT_REF 78%token <labelref> DT_REF
74%token DT_INCBIN 79%token DT_INCBIN
75 80
76%type <data> propdata 81%type <data> propdata
77%type <data> propdataprefix 82%type <data> propdataprefix
 83%type <flags> header
 84%type <flags> headers
78%type <re> memreserve 85%type <re> memreserve
79%type <re> memreserves 86%type <re> memreserves
80%type <array> arrayprefix 87%type <array> arrayprefix
81%type <data> bytestring 88%type <data> bytestring
82%type <prop> propdef 89%type <prop> propdef
83%type <proplist> proplist 90%type <proplist> proplist
84 91
85%type <node> devicetree 92%type <node> devicetree
86%type <node> nodedef 93%type <node> nodedef
87%type <node> subnode 94%type <node> subnode
88%type <nodelist> subnodes 95%type <nodelist> subnodes
89 96
90%type <integer> integer_prim 97%type <integer> integer_prim
@@ -95,30 +102,51 @@ extern bool treesource_error; @@ -95,30 +102,51 @@ extern bool treesource_error;
95%type <integer> integer_rela 102%type <integer> integer_rela
96%type <integer> integer_eq 103%type <integer> integer_eq
97%type <integer> integer_bitand 104%type <integer> integer_bitand
98%type <integer> integer_bitxor 105%type <integer> integer_bitxor
99%type <integer> integer_bitor 106%type <integer> integer_bitor
100%type <integer> integer_and 107%type <integer> integer_and
101%type <integer> integer_or 108%type <integer> integer_or
102%type <integer> integer_trinary 109%type <integer> integer_trinary
103%type <integer> integer_expr 110%type <integer> integer_expr
104 111
105%% 112%%
106 113
107sourcefile: 114sourcefile:
108 DT_V1 ';' memreserves devicetree 115 headers memreserves devicetree
 116 {
 117 parser_output = build_dt_info($1, $2, $3,
 118 guess_boot_cpuid($3));
 119 }
 120 ;
 121
 122header:
 123 DT_V1 ';'
 124 {
 125 $$ = DTSF_V1;
 126 }
 127 | DT_V1 ';' DT_PLUGIN ';'
 128 {
 129 $$ = DTSF_V1 | DTSF_PLUGIN;
 130 }
 131 ;
 132
 133headers:
 134 header
 135 | header headers
109 { 136 {
110 the_boot_info = build_boot_info($3, $4, 137 if ($2 != $1)
111 guess_boot_cpuid($4)); 138 ERROR(&@2, "Header flags don't match earlier ones");
 139 $$ = $1;
112 } 140 }
113 ; 141 ;
114 142
115memreserves: 143memreserves:
116 /* empty */ 144 /* empty */
117 { 145 {
118 $$ = NULL; 146 $$ = NULL;
119 } 147 }
120 | memreserve memreserves 148 | memreserve memreserves
121 { 149 {
122 $$ = chain_reserve_entry($1, $2); 150 $$ = chain_reserve_entry($1, $2);
123 } 151 }
124 ; 152 ;
@@ -139,30 +167,30 @@ devicetree: @@ -139,30 +167,30 @@ devicetree:
139 '/' nodedef 167 '/' nodedef
140 { 168 {
141 $$ = name_node($2, ""); 169 $$ = name_node($2, "");
142 } 170 }
143 | devicetree '/' nodedef 171 | devicetree '/' nodedef
144 { 172 {
145 $$ = merge_nodes($1, $3); 173 $$ = merge_nodes($1, $3);
146 } 174 }
147 175
148 | devicetree DT_LABEL DT_REF nodedef 176 | devicetree DT_LABEL DT_REF nodedef
149 { 177 {
150 struct node *target = get_node_by_ref($1, $3); 178 struct node *target = get_node_by_ref($1, $3);
151 179
152 add_label(&target->labels, $2); 180 if (target) {
153 if (target) 181 add_label(&target->labels, $2);
154 merge_nodes(target, $4); 182 merge_nodes(target, $4);
155 else 183 } else
156 ERROR(&@3, "Label or path %s not found", $3); 184 ERROR(&@3, "Label or path %s not found", $3);
157 $$ = $1; 185 $$ = $1;
158 } 186 }
159 | devicetree DT_REF nodedef 187 | devicetree DT_REF nodedef
160 { 188 {
161 struct node *target = get_node_by_ref($1, $2); 189 struct node *target = get_node_by_ref($1, $2);
162 190
163 if (target) 191 if (target)
164 merge_nodes(target, $3); 192 merge_nodes(target, $3);
165 else 193 else
166 ERROR(&@2, "Label or path %s not found", $2); 194 ERROR(&@2, "Label or path %s not found", $2);
167 $$ = $1; 195 $$ = $1;
168 } 196 }
@@ -404,28 +432,44 @@ integer_shift: @@ -404,28 +432,44 @@ integer_shift:
404 integer_shift DT_LSHIFT integer_add { $$ = $1 << $3; } 432 integer_shift DT_LSHIFT integer_add { $$ = $1 << $3; }
405 | integer_shift DT_RSHIFT integer_add { $$ = $1 >> $3; } 433 | integer_shift DT_RSHIFT integer_add { $$ = $1 >> $3; }
406 | integer_add 434 | integer_add
407 ; 435 ;
408 436
409integer_add: 437integer_add:
410 integer_add '+' integer_mul { $$ = $1 + $3; } 438 integer_add '+' integer_mul { $$ = $1 + $3; }
411 | integer_add '-' integer_mul { $$ = $1 - $3; } 439 | integer_add '-' integer_mul { $$ = $1 - $3; }
412 | integer_mul 440 | integer_mul
413 ; 441 ;
414 442
415integer_mul: 443integer_mul:
416 integer_mul '*' integer_unary { $$ = $1 * $3; } 444 integer_mul '*' integer_unary { $$ = $1 * $3; }
417 | integer_mul '/' integer_unary { $$ = $1 / $3; } 445 | integer_mul '/' integer_unary
418 | integer_mul '%' integer_unary { $$ = $1 % $3; } 446 {
 447 if ($3 != 0) {
 448 $$ = $1 / $3;
 449 } else {
 450 ERROR(&@$, "Division by zero");
 451 $$ = 0;
 452 }
 453 }
 454 | integer_mul '%' integer_unary
 455 {
 456 if ($3 != 0) {
 457 $$ = $1 % $3;
 458 } else {
 459 ERROR(&@$, "Division by zero");
 460 $$ = 0;
 461 }
 462 }
419 | integer_unary 463 | integer_unary
420 ; 464 ;
421 465
422integer_unary: 466integer_unary:
423 integer_prim 467 integer_prim
424 | '-' integer_unary { $$ = -$2; } 468 | '-' integer_unary { $$ = -$2; }
425 | '~' integer_unary { $$ = ~$2; } 469 | '~' integer_unary { $$ = ~$2; }
426 | '!' integer_unary { $$ = !$2; } 470 | '!' integer_unary { $$ = !$2; }
427 ; 471 ;
428 472
429bytestring: 473bytestring:
430 /* empty */ 474 /* empty */
431 { 475 {

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/dtc.h (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/dtc.h 2017/06/06 20:19:04 1.2
+++ src/external/gpl2/dtc/dist/dtc.h 2017/06/08 16:00:40 1.3
@@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
 1/* $NetBSD: dtc.h,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1#ifndef _DTC_H 3#ifndef _DTC_H
2#define _DTC_H 4#define _DTC_H
3 5
4/* 6/*
5 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. 7 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
6 * 8 *
7 * 9 *
8 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 11 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the 12 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version. 13 * License, or (at your option) any later version.
12 * 14 *
13 * This program is distributed in the hope that it will be useful, 15 * This program is distributed in the hope that it will be useful,
@@ -33,37 +35,40 @@ @@ -33,37 +35,40 @@
33#include <unistd.h> 35#include <unistd.h>
34 36
35#include <libfdt_env.h> 37#include <libfdt_env.h>
36#include <fdt.h> 38#include <fdt.h>
37 39
38#include "util.h" 40#include "util.h"
39 41
40#ifdef DEBUG 42#ifdef DEBUG
41#define debug(...) printf(__VA_ARGS__) 43#define debug(...) printf(__VA_ARGS__)
42#else 44#else
43#define debug(...) 45#define debug(...)
44#endif 46#endif
45 47
46 
47#define DEFAULT_FDT_VERSION 17 48#define DEFAULT_FDT_VERSION 17
48 49
49/* 50/*
50 * Command line options 51 * Command line options
51 */ 52 */
52extern int quiet; /* Level of quietness */ 53extern int quiet; /* Level of quietness */
53extern int reservenum; /* Number of memory reservation slots */ 54extern int reservenum; /* Number of memory reservation slots */
54extern int minsize; /* Minimum blob size */ 55extern int minsize; /* Minimum blob size */
55extern int padsize; /* Additional padding to blob */ 56extern int padsize; /* Additional padding to blob */
 57extern int alignsize; /* Additional padding to blob accroding to the alignsize */
56extern int phandle_format; /* Use linux,phandle or phandle properties */ 58extern int phandle_format; /* Use linux,phandle or phandle properties */
 59extern int generate_symbols; /* generate symbols for nodes with labels */
 60extern int generate_fixups; /* generate fixups */
 61extern int auto_label_aliases; /* auto generate labels -> aliases */
57 62
58#define PHANDLE_LEGACY 0x1 63#define PHANDLE_LEGACY 0x1
59#define PHANDLE_EPAPR 0x2 64#define PHANDLE_EPAPR 0x2
60#define PHANDLE_BOTH 0x3 65#define PHANDLE_BOTH 0x3
61 66
62typedef uint32_t cell_t; 67typedef uint32_t cell_t;
63 68
64 69
65#define streq(a, b) (strcmp((a), (b)) == 0) 70#define streq(a, b) (strcmp((a), (b)) == 0)
66#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0) 71#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
67 72
68/* Data blobs */ 73/* Data blobs */
69enum markertype { 74enum markertype {
@@ -98,27 +103,27 @@ void data_free(struct data d); @@ -98,27 +103,27 @@ void data_free(struct data d);
98 103
99struct data data_grow_for(struct data d, int xlen); 104struct data data_grow_for(struct data d, int xlen);
100 105
101struct data data_copy_mem(const char *mem, int len); 106struct data data_copy_mem(const char *mem, int len);
102struct data data_copy_escape_string(const char *s, int len); 107struct data data_copy_escape_string(const char *s, int len);
103struct data data_copy_file(FILE *f, size_t len); 108struct data data_copy_file(FILE *f, size_t len);
104 109
105struct data data_append_data(struct data d, const void *p, int len); 110struct data data_append_data(struct data d, const void *p, int len);
106struct data data_insert_at_marker(struct data d, struct marker *m, 111struct data data_insert_at_marker(struct data d, struct marker *m,
107 const void *p, int len); 112 const void *p, int len);
108struct data data_merge(struct data d1, struct data d2); 113struct data data_merge(struct data d1, struct data d2);
109struct data data_append_cell(struct data d, cell_t word); 114struct data data_append_cell(struct data d, cell_t word);
110struct data data_append_integer(struct data d, uint64_t word, int bits); 115struct data data_append_integer(struct data d, uint64_t word, int bits);
111struct data data_append_re(struct data d, const struct fdt_reserve_entry *re); 116struct data data_append_re(struct data d, uint64_t address, uint64_t size);
112struct data data_append_addr(struct data d, uint64_t addr); 117struct data data_append_addr(struct data d, uint64_t addr);
113struct data data_append_byte(struct data d, uint8_t byte); 118struct data data_append_byte(struct data d, uint8_t byte);
114struct data data_append_zeroes(struct data d, int len); 119struct data data_append_zeroes(struct data d, int len);
115struct data data_append_align(struct data d, int align); 120struct data data_append_align(struct data d, int align);
116 121
117struct data data_add_marker(struct data d, enum markertype type, char *ref); 122struct data data_add_marker(struct data d, enum markertype type, char *ref);
118 123
119bool data_is_one_string(struct data d); 124bool data_is_one_string(struct data d);
120 125
121/* DT constraints */ 126/* DT constraints */
122 127
123#define MAX_PROPNAME_LEN 31 128#define MAX_PROPNAME_LEN 31
124#define MAX_NODENAME_LEN 31 129#define MAX_NODENAME_LEN 31
@@ -189,79 +194,91 @@ struct property *reverse_properties(stru @@ -189,79 +194,91 @@ struct property *reverse_properties(stru
189 194
190struct node *build_node(struct property *proplist, struct node *children); 195struct node *build_node(struct property *proplist, struct node *children);
191struct node *build_node_delete(void); 196struct node *build_node_delete(void);
192struct node *name_node(struct node *node, char *name); 197struct node *name_node(struct node *node, char *name);
193struct node *chain_node(struct node *first, struct node *list); 198struct node *chain_node(struct node *first, struct node *list);
194struct node *merge_nodes(struct node *old_node, struct node *new_node); 199struct node *merge_nodes(struct node *old_node, struct node *new_node);
195 200
196void add_property(struct node *node, struct property *prop); 201void add_property(struct node *node, struct property *prop);
197void delete_property_by_name(struct node *node, char *name); 202void delete_property_by_name(struct node *node, char *name);
198void delete_property(struct property *prop); 203void delete_property(struct property *prop);
199void add_child(struct node *parent, struct node *child); 204void add_child(struct node *parent, struct node *child);
200void delete_node_by_name(struct node *parent, char *name); 205void delete_node_by_name(struct node *parent, char *name);
201void delete_node(struct node *node); 206void delete_node(struct node *node);
 207void append_to_property(struct node *node,
 208 char *name, const void *data, int len);
202 209
203const char *get_unitname(struct node *node); 210const char *get_unitname(struct node *node);
204struct property *get_property(struct node *node, const char *propname); 211struct property *get_property(struct node *node, const char *propname);
205cell_t propval_cell(struct property *prop); 212cell_t propval_cell(struct property *prop);
206struct property *get_property_by_label(struct node *tree, const char *label, 213struct property *get_property_by_label(struct node *tree, const char *label,
207 struct node **node); 214 struct node **node);
208struct marker *get_marker_label(struct node *tree, const char *label, 215struct marker *get_marker_label(struct node *tree, const char *label,
209 struct node **node, struct property **prop); 216 struct node **node, struct property **prop);
210struct node *get_subnode(struct node *node, const char *nodename); 217struct node *get_subnode(struct node *node, const char *nodename);
211struct node *get_node_by_path(struct node *tree, const char *path); 218struct node *get_node_by_path(struct node *tree, const char *path);
212struct node *get_node_by_label(struct node *tree, const char *label); 219struct node *get_node_by_label(struct node *tree, const char *label);
213struct node *get_node_by_phandle(struct node *tree, cell_t phandle); 220struct node *get_node_by_phandle(struct node *tree, cell_t phandle);
214struct node *get_node_by_ref(struct node *tree, const char *ref); 221struct node *get_node_by_ref(struct node *tree, const char *ref);
215cell_t get_node_phandle(struct node *root, struct node *node); 222cell_t get_node_phandle(struct node *root, struct node *node);
216 223
217uint32_t guess_boot_cpuid(struct node *tree); 224uint32_t guess_boot_cpuid(struct node *tree);
218 225
219/* Boot info (tree plus memreserve information */ 226/* Boot info (tree plus memreserve information */
220 227
221struct reserve_info { 228struct reserve_info {
222 struct fdt_reserve_entry re; 229 uint64_t address, size;
223 230
224 struct reserve_info *next; 231 struct reserve_info *next;
225 232
226 struct label *labels; 233 struct label *labels;
227}; 234};
228 235
229struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len); 236struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len);
230struct reserve_info *chain_reserve_entry(struct reserve_info *first, 237struct reserve_info *chain_reserve_entry(struct reserve_info *first,
231 struct reserve_info *list); 238 struct reserve_info *list);
232struct reserve_info *add_reserve_entry(struct reserve_info *list, 239struct reserve_info *add_reserve_entry(struct reserve_info *list,
233 struct reserve_info *new); 240 struct reserve_info *new);
234 241
235 242
236struct boot_info { 243struct dt_info {
 244 unsigned int dtsflags;
237 struct reserve_info *reservelist; 245 struct reserve_info *reservelist;
238 struct node *dt; /* the device tree */ 
239 uint32_t boot_cpuid_phys; 246 uint32_t boot_cpuid_phys;
 247 struct node *dt; /* the device tree */
 248 const char *outname; /* filename being written to, "-" for stdout */
240}; 249};
241 250
242struct boot_info *build_boot_info(struct reserve_info *reservelist, 251/* DTS version flags definitions */
243 struct node *tree, uint32_t boot_cpuid_phys); 252#define DTSF_V1 0x0001 /* /dts-v1/ */
244void sort_tree(struct boot_info *bi); 253#define DTSF_PLUGIN 0x0002 /* /plugin/ */
 254
 255struct dt_info *build_dt_info(unsigned int dtsflags,
 256 struct reserve_info *reservelist,
 257 struct node *tree, uint32_t boot_cpuid_phys);
 258void sort_tree(struct dt_info *dti);
 259void generate_label_tree(struct dt_info *dti, char *name, bool allocph);
 260void generate_fixups_tree(struct dt_info *dti, char *name);
 261void generate_local_fixups_tree(struct dt_info *dti, char *name);
245 262
246/* Checks */ 263/* Checks */
247 264
248void parse_checks_option(bool warn, bool error, const char *arg); 265void parse_checks_option(bool warn, bool error, const char *arg);
249void process_checks(bool force, struct boot_info *bi); 266void process_checks(bool force, struct dt_info *dti);
250 267
251/* Flattened trees */ 268/* Flattened trees */
252 269
253void dt_to_blob(FILE *f, struct boot_info *bi, int version); 270void dt_to_blob(FILE *f, struct dt_info *dti, int version);
254void dt_to_asm(FILE *f, struct boot_info *bi, int version); 271void dt_to_asm(FILE *f, struct dt_info *dti, int version);
255 272
256struct boot_info *dt_from_blob(const char *fname); 273struct dt_info *dt_from_blob(const char *fname);
257 274
258/* Tree source */ 275/* Tree source */
259 276
260void dt_to_source(FILE *f, struct boot_info *bi); 277void dt_to_source(FILE *f, struct dt_info *dti);
261struct boot_info *dt_from_source(const char *f); 278struct dt_info *dt_from_source(const char *f);
262 279
263/* FS trees */ 280/* FS trees */
264 281
265struct boot_info *dt_from_fs(const char *dirname); 282struct dt_info *dt_from_fs(const char *dirname);
266 283
267#endif /* _DTC_H */ 284#endif /* _DTC_H */

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/fdtdump.c (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/fdtdump.c 2017/06/06 20:19:04 1.2
+++ src/external/gpl2/dtc/dist/fdtdump.c 2017/06/08 16:00:40 1.3
@@ -1,31 +1,36 @@ @@ -1,31 +1,36 @@
 1/* $NetBSD: fdtdump.c,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1/* 3/*
2 * fdtdump.c - Contributed by Pantelis Antoniou <pantelis.antoniou AT gmail.com> 4 * fdtdump.c - Contributed by Pantelis Antoniou <pantelis.antoniou AT gmail.com>
3 */ 5 */
4 6
5#include <stdbool.h> 7#include <stdbool.h>
6#include <stdint.h> 8#include <stdint.h>
7#include <stdio.h> 9#include <stdio.h>
8#include <stdlib.h> 10#include <stdlib.h>
9#include <string.h> 11#include <string.h>
10#include <ctype.h> 12#include <ctype.h>
11 13
12#include <libfdt.h> 14#include <libfdt.h>
13#include <libfdt_env.h> 15#include <libfdt_env.h>
14#include <fdt.h> 16#include <fdt.h>
15 17
16#include "util.h" 18#include "util.h"
17 19
18#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4))) 20#define FDT_MAGIC_SIZE 4
 21#define MAX_VERSION 17
 22
 23#define GET_CELL(p) (p += 4, *((const fdt32_t *)(p-4)))
19 24
20static const char *tagname(uint32_t tag) 25static const char *tagname(uint32_t tag)
21{ 26{
22 static const char * const names[] = { 27 static const char * const names[] = {
23#define TN(t) [t] = #t 28#define TN(t) [t] = #t
24 TN(FDT_BEGIN_NODE), 29 TN(FDT_BEGIN_NODE),
25 TN(FDT_END_NODE), 30 TN(FDT_END_NODE),
26 TN(FDT_PROP), 31 TN(FDT_PROP),
27 TN(FDT_NOP), 32 TN(FDT_NOP),
28 TN(FDT_END), 33 TN(FDT_END),
29#undef TN 34#undef TN
30 }; 35 };
31 if (tag < ARRAY_SIZE(names)) 36 if (tag < ARRAY_SIZE(names))
@@ -145,26 +150,40 @@ static void dump_blob(void *blob, bool d @@ -145,26 +150,40 @@ static void dump_blob(void *blob, bool d
145static const char usage_synopsis[] = "fdtdump [options] <file>"; 150static const char usage_synopsis[] = "fdtdump [options] <file>";
146static const char usage_short_opts[] = "ds" USAGE_COMMON_SHORT_OPTS; 151static const char usage_short_opts[] = "ds" USAGE_COMMON_SHORT_OPTS;
147static struct option const usage_long_opts[] = { 152static struct option const usage_long_opts[] = {
148 {"debug", no_argument, NULL, 'd'}, 153 {"debug", no_argument, NULL, 'd'},
149 {"scan", no_argument, NULL, 's'}, 154 {"scan", no_argument, NULL, 's'},
150 USAGE_COMMON_LONG_OPTS 155 USAGE_COMMON_LONG_OPTS
151}; 156};
152static const char * const usage_opts_help[] = { 157static const char * const usage_opts_help[] = {
153 "Dump debug information while decoding the file", 158 "Dump debug information while decoding the file",
154 "Scan for an embedded fdt in file", 159 "Scan for an embedded fdt in file",
155 USAGE_COMMON_OPTS_HELP 160 USAGE_COMMON_OPTS_HELP
156}; 161};
157 162
 163static bool valid_header(char *p, off_t len)
 164{
 165 if (len < sizeof(struct fdt_header) ||
 166 fdt_magic(p) != FDT_MAGIC ||
 167 fdt_version(p) > MAX_VERSION ||
 168 fdt_last_comp_version(p) >= MAX_VERSION ||
 169 fdt_totalsize(p) >= len ||
 170 fdt_off_dt_struct(p) >= len ||
 171 fdt_off_dt_strings(p) >= len)
 172 return 0;
 173 else
 174 return 1;
 175}
 176
158int main(int argc, char *argv[]) 177int main(int argc, char *argv[])
159{ 178{
160 int opt; 179 int opt;
161 const char *file; 180 const char *file;
162 char *buf; 181 char *buf;
163 bool debug = false; 182 bool debug = false;
164 bool scan = false; 183 bool scan = false;
165 off_t len; 184 off_t len;
166 185
167 while ((opt = util_getopt_long()) != EOF) { 186 while ((opt = util_getopt_long()) != EOF) {
168 switch (opt) { 187 switch (opt) {
169 case_USAGE_COMMON_FLAGS 188 case_USAGE_COMMON_FLAGS
170 189
@@ -176,50 +195,46 @@ int main(int argc, char *argv[]) @@ -176,50 +195,46 @@ int main(int argc, char *argv[])
176 break; 195 break;
177 } 196 }
178 } 197 }
179 if (optind != argc - 1) 198 if (optind != argc - 1)
180 usage("missing input filename"); 199 usage("missing input filename");
181 file = argv[optind]; 200 file = argv[optind];
182 201
183 buf = utilfdt_read_len(file, &len); 202 buf = utilfdt_read_len(file, &len);
184 if (!buf) 203 if (!buf)
185 die("could not read: %s\n", file); 204 die("could not read: %s\n", file);
186 205
187 /* try and locate an embedded fdt in a bigger blob */ 206 /* try and locate an embedded fdt in a bigger blob */
188 if (scan) { 207 if (scan) {
189 unsigned char smagic[4]; 208 unsigned char smagic[FDT_MAGIC_SIZE];
190 char *p = buf; 209 char *p = buf;
191 char *endp = buf + len; 210 char *endp = buf + len;
192 211
193 fdt_set_magic(smagic, FDT_MAGIC); 212 fdt_set_magic(smagic, FDT_MAGIC);
194 213
195 /* poor man's memmem */ 214 /* poor man's memmem */
196 while (true) { 215 while ((endp - p) >= FDT_MAGIC_SIZE) {
197 p = memchr(p, smagic[0], endp - p - 4); 216 p = memchr(p, smagic[0], endp - p - FDT_MAGIC_SIZE);
198 if (!p) 217 if (!p)
199 break; 218 break;
200 if (fdt_magic(p) == FDT_MAGIC) { 219 if (fdt_magic(p) == FDT_MAGIC) {
201 /* try and validate the main struct */ 220 /* try and validate the main struct */
202 off_t this_len = endp - p; 221 off_t this_len = endp - p;
203 fdt32_t max_version = 17; 222 if (valid_header(p, this_len))
204 if (fdt_version(p) <= max_version && 
205 fdt_last_comp_version(p) < max_version && 
206 fdt_totalsize(p) < this_len && 
207 fdt_off_dt_struct(p) < this_len && 
208 fdt_off_dt_strings(p) < this_len) 
209 break; 223 break;
210 if (debug) 224 if (debug)
211 printf("%s: skipping fdt magic at offset %#zx\n", 225 printf("%s: skipping fdt magic at offset %#zx\n",
212 file, p - buf); 226 file, p - buf);
213 } 227 }
214 ++p; 228 ++p;
215 } 229 }
216 if (!p) 230 if (!p || endp - p < sizeof(struct fdt_header))
217 die("%s: could not locate fdt magic\n", file); 231 die("%s: could not locate fdt magic\n", file);
218 printf("%s: found fdt at offset %#zx\n", file, p - buf); 232 printf("%s: found fdt at offset %#zx\n", file, p - buf);
219 buf = p; 233 buf = p;
220 } 234 } else if (!valid_header(buf, len))
 235 die("%s: header is not valid\n", file);
221 236
222 dump_blob(buf, debug); 237 dump_blob(buf, debug);
223 238
224 return 0; 239 return 0;
225} 240}

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/fdtput.c (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/fdtput.c 2017/06/06 20:19:04 1.2
+++ src/external/gpl2/dtc/dist/fdtput.c 2017/06/08 16:00:40 1.3
@@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
 1/* $NetBSD: fdtput.c,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1/* 3/*
2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 4 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
3 * 5 *
4 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of 8 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version. 9 * the License, or (at your option) any later version.
8 * 10 *
9 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 14 * GNU General Public License for more details.
13 * 15 *
@@ -57,27 +59,27 @@ static void report_error(const char *nam @@ -57,27 +59,27 @@ static void report_error(const char *nam
57 if (namelen == -1) 59 if (namelen == -1)
58 namelen = strlen(name); 60 namelen = strlen(name);
59 fprintf(stderr, "Error at '%1.*s': %s\n", namelen, name, 61 fprintf(stderr, "Error at '%1.*s': %s\n", namelen, name,
60 fdt_strerror(err)); 62 fdt_strerror(err));
61} 63}
62 64
63/** 65/**
64 * Encode a series of arguments in a property value. 66 * Encode a series of arguments in a property value.
65 * 67 *
66 * @param disp Display information / options 68 * @param disp Display information / options
67 * @param arg List of arguments from command line 69 * @param arg List of arguments from command line
68 * @param arg_count Number of arguments (may be 0) 70 * @param arg_count Number of arguments (may be 0)
69 * @param valuep Returns buffer containing value 71 * @param valuep Returns buffer containing value
70 * @param *value_len Returns length of value encoded 72 * @param value_len Returns length of value encoded
71 */ 73 */
72static int encode_value(struct display_info *disp, char **arg, int arg_count, 74static int encode_value(struct display_info *disp, char **arg, int arg_count,
73 char **valuep, int *value_len) 75 char **valuep, int *value_len)
74{ 76{
75 char *value = NULL; /* holding area for value */ 77 char *value = NULL; /* holding area for value */
76 int value_size = 0; /* size of holding area */ 78 int value_size = 0; /* size of holding area */
77 char *ptr; /* pointer to current value position */ 79 char *ptr; /* pointer to current value position */
78 int len; /* length of this cell/string/byte */ 80 int len; /* length of this cell/string/byte */
79 int ival; 81 int ival;
80 int upto; /* the number of bytes we have written to buf */ 82 int upto; /* the number of bytes we have written to buf */
81 char fmt[3]; 83 char fmt[3];
82 84
83 upto = 0; 85 upto = 0;
@@ -97,27 +99,27 @@ static int encode_value(struct display_i @@ -97,27 +99,27 @@ static int encode_value(struct display_i
97 99
98 /* enlarge our value buffer by a suitable margin if needed */ 100 /* enlarge our value buffer by a suitable margin if needed */
99 if (upto + len > value_size) { 101 if (upto + len > value_size) {
100 value_size = (upto + len) + 500; 102 value_size = (upto + len) + 500;
101 value = xrealloc(value, value_size); 103 value = xrealloc(value, value_size);
102 } 104 }
103 105
104 ptr = value + upto; 106 ptr = value + upto;
105 if (disp->type == 's') { 107 if (disp->type == 's') {
106 memcpy(ptr, *arg, len); 108 memcpy(ptr, *arg, len);
107 if (disp->verbose) 109 if (disp->verbose)
108 fprintf(stderr, "\tstring: '%s'\n", ptr); 110 fprintf(stderr, "\tstring: '%s'\n", ptr);
109 } else { 111 } else {
110 int *iptr = (int *)ptr; 112 fdt32_t *iptr = (fdt32_t *)ptr;
111 sscanf(*arg, fmt, &ival); 113 sscanf(*arg, fmt, &ival);
112 if (len == 4) 114 if (len == 4)
113 *iptr = cpu_to_fdt32(ival); 115 *iptr = cpu_to_fdt32(ival);
114 else 116 else
115 *ptr = (uint8_t)ival; 117 *ptr = (uint8_t)ival;
116 if (disp->verbose) { 118 if (disp->verbose) {
117 fprintf(stderr, "\t%s: %d\n", 119 fprintf(stderr, "\t%s: %d\n",
118 disp->size == 1 ? "byte" : 120 disp->size == 1 ? "byte" :
119 disp->size == 2 ? "short" : "int", 121 disp->size == 2 ? "short" : "int",
120 ival); 122 ival);
121 } 123 }
122 } 124 }
123 } 125 }
@@ -318,27 +320,27 @@ static int delete_node(char *blob, const @@ -318,27 +320,27 @@ static int delete_node(char *blob, const
318 320
319 node = fdt_del_node(blob, node); 321 node = fdt_del_node(blob, node);
320 if (node < 0) { 322 if (node < 0) {
321 report_error(node_name, -1, node); 323 report_error(node_name, -1, node);
322 return -1; 324 return -1;
323 } 325 }
324 326
325 return 0; 327 return 0;
326} 328}
327 329
328static int do_fdtput(struct display_info *disp, const char *filename, 330static int do_fdtput(struct display_info *disp, const char *filename,
329 char **arg, int arg_count) 331 char **arg, int arg_count)
330{ 332{
331 char *value; 333 char *value = NULL;
332 char *blob; 334 char *blob;
333 char *node; 335 char *node;
334 int len, ret = 0; 336 int len, ret = 0;
335 337
336 blob = utilfdt_read(filename); 338 blob = utilfdt_read(filename);
337 if (!blob) 339 if (!blob)
338 return -1; 340 return -1;
339 341
340 switch (disp->oper) { 342 switch (disp->oper) {
341 case OPER_WRITE_PROP: 343 case OPER_WRITE_PROP:
342 /* 344 /*
343 * Convert the arguments into a single binary value, then 345 * Convert the arguments into a single binary value, then
344 * store them into the property. 346 * store them into the property.
@@ -364,26 +366,31 @@ static int do_fdtput(struct display_info @@ -364,26 +366,31 @@ static int do_fdtput(struct display_info
364 break; 366 break;
365 case OPER_DELETE_PROP: 367 case OPER_DELETE_PROP:
366 node = *arg; 368 node = *arg;
367 for (arg++; ret >= 0 && arg_count-- > 1; arg++) 369 for (arg++; ret >= 0 && arg_count-- > 1; arg++)
368 ret = delete_prop(blob, node, *arg); 370 ret = delete_prop(blob, node, *arg);
369 break; 371 break;
370 } 372 }
371 if (ret >= 0) { 373 if (ret >= 0) {
372 fdt_pack(blob); 374 fdt_pack(blob);
373 ret = utilfdt_write(filename, blob); 375 ret = utilfdt_write(filename, blob);
374 } 376 }
375 377
376 free(blob); 378 free(blob);
 379
 380 if (value) {
 381 free(value);
 382 }
 383
377 return ret; 384 return ret;
378} 385}
379 386
380/* Usage related data. */ 387/* Usage related data. */
381static const char usage_synopsis[] = 388static const char usage_synopsis[] =
382 "write a property value to a device tree\n" 389 "write a property value to a device tree\n"
383 " fdtput <options> <dt file> <node> <property> [<value>...]\n" 390 " fdtput <options> <dt file> <node> <property> [<value>...]\n"
384 " fdtput -c <options> <dt file> [<node>...]\n" 391 " fdtput -c <options> <dt file> [<node>...]\n"
385 " fdtput -r <options> <dt file> [<node>...]\n" 392 " fdtput -r <options> <dt file> [<node>...]\n"
386 " fdtput -d <options> <dt file> <node> [<property>...]\n" 393 " fdtput -d <options> <dt file> <node> [<property>...]\n"
387 "\n" 394 "\n"
388 "The command line arguments are joined together into a single value.\n" 395 "The command line arguments are joined together into a single value.\n"
389 USAGE_TYPE_MSG; 396 USAGE_TYPE_MSG;

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/flattree.c (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/flattree.c 2017/06/06 20:19:04 1.2
+++ src/external/gpl2/dtc/dist/flattree.c 2017/06/08 16:00:40 1.3
@@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
 1/* $NetBSD: flattree.c,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1/* 3/*
2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. 4 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
3 * 5 *
4 * 6 *
5 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the 9 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version. 10 * License, or (at your option) any later version.
9 * 11 *
10 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details. 15 * General Public License for more details.
@@ -39,42 +41,42 @@ static struct version_info { @@ -39,42 +41,42 @@ static struct version_info {
39 FTF_FULLPATH|FTF_VARALIGN|FTF_NAMEPROPS}, 41 FTF_FULLPATH|FTF_VARALIGN|FTF_NAMEPROPS},
40 {2, 1, FDT_V2_SIZE, 42 {2, 1, FDT_V2_SIZE,
41 FTF_FULLPATH|FTF_VARALIGN|FTF_NAMEPROPS|FTF_BOOTCPUID}, 43 FTF_FULLPATH|FTF_VARALIGN|FTF_NAMEPROPS|FTF_BOOTCPUID},
42 {3, 1, FDT_V3_SIZE, 44 {3, 1, FDT_V3_SIZE,
43 FTF_FULLPATH|FTF_VARALIGN|FTF_NAMEPROPS|FTF_BOOTCPUID|FTF_STRTABSIZE}, 45 FTF_FULLPATH|FTF_VARALIGN|FTF_NAMEPROPS|FTF_BOOTCPUID|FTF_STRTABSIZE},
44 {16, 16, FDT_V3_SIZE, 46 {16, 16, FDT_V3_SIZE,
45 FTF_BOOTCPUID|FTF_STRTABSIZE|FTF_NOPS}, 47 FTF_BOOTCPUID|FTF_STRTABSIZE|FTF_NOPS},
46 {17, 16, FDT_V17_SIZE, 48 {17, 16, FDT_V17_SIZE,
47 FTF_BOOTCPUID|FTF_STRTABSIZE|FTF_STRUCTSIZE|FTF_NOPS}, 49 FTF_BOOTCPUID|FTF_STRTABSIZE|FTF_STRUCTSIZE|FTF_NOPS},
48}; 50};
49 51
50struct emitter { 52struct emitter {
51 void (*cell)(void *, cell_t); 53 void (*cell)(void *, cell_t);
52 void (*string)(void *, char *, int); 54 void (*string)(void *, const char *, int);
53 void (*align)(void *, int); 55 void (*align)(void *, int);
54 void (*data)(void *, struct data); 56 void (*data)(void *, struct data);
55 void (*beginnode)(void *, struct label *labels); 57 void (*beginnode)(void *, struct label *labels);
56 void (*endnode)(void *, struct label *labels); 58 void (*endnode)(void *, struct label *labels);
57 void (*property)(void *, struct label *labels); 59 void (*property)(void *, struct label *labels);
58}; 60};
59 61
60static void bin_emit_cell(void *e, cell_t val) 62static void bin_emit_cell(void *e, cell_t val)
61{ 63{
62 struct data *dtbuf = e; 64 struct data *dtbuf = e;
63 65
64 *dtbuf = data_append_cell(*dtbuf, val); 66 *dtbuf = data_append_cell(*dtbuf, val);
65} 67}
66 68
67static void bin_emit_string(void *e, char *str, int len) 69static void bin_emit_string(void *e, const char *str, int len)
68{ 70{
69 struct data *dtbuf = e; 71 struct data *dtbuf = e;
70 72
71 if (len == 0) 73 if (len == 0)
72 len = strlen(str); 74 len = strlen(str);
73 75
74 *dtbuf = data_append_data(*dtbuf, str, len); 76 *dtbuf = data_append_data(*dtbuf, str, len);
75 *dtbuf = data_append_byte(*dtbuf, '\0'); 77 *dtbuf = data_append_byte(*dtbuf, '\0');
76} 78}
77 79
78static void bin_emit_align(void *e, int a) 80static void bin_emit_align(void *e, int a)
79{ 81{
80 struct data *dtbuf = e; 82 struct data *dtbuf = e;
@@ -134,62 +136,54 @@ static void emit_offset_label(FILE *f, c @@ -134,62 +136,54 @@ static void emit_offset_label(FILE *f, c
134 fprintf((f), "\t.byte\t((" fmt ") >> 8) & 0xff\n", __VA_ARGS__); \ 136 fprintf((f), "\t.byte\t((" fmt ") >> 8) & 0xff\n", __VA_ARGS__); \
135 fprintf((f), "\t.byte\t(" fmt ") & 0xff\n", __VA_ARGS__); \ 137 fprintf((f), "\t.byte\t(" fmt ") & 0xff\n", __VA_ARGS__); \
136 } 138 }
137 139
138static void asm_emit_cell(void *e, cell_t val) 140static void asm_emit_cell(void *e, cell_t val)
139{ 141{
140 FILE *f = e; 142 FILE *f = e;
141 143
142 fprintf(f, "\t.byte 0x%02x; .byte 0x%02x; .byte 0x%02x; .byte 0x%02x\n", 144 fprintf(f, "\t.byte 0x%02x; .byte 0x%02x; .byte 0x%02x; .byte 0x%02x\n",
143 (val >> 24) & 0xff, (val >> 16) & 0xff, 145 (val >> 24) & 0xff, (val >> 16) & 0xff,
144 (val >> 8) & 0xff, val & 0xff); 146 (val >> 8) & 0xff, val & 0xff);
145} 147}
146 148
147static void asm_emit_string(void *e, char *str, int len) 149static void asm_emit_string(void *e, const char *str, int len)
148{ 150{
149 FILE *f = e; 151 FILE *f = e;
150 char c = 0; 
151 
152 if (len != 0) { 
153 /* XXX: ewww */ 
154 c = str[len]; 
155 str[len] = '\0'; 
156 } 
157 152
158 fprintf(f, "\t.string\t\"%s\"\n", str); 153 if (len != 0)
159 154 fprintf(f, "\t.string\t\"%.*s\"\n", len, str);
160 if (len != 0) { 155 else
161 str[len] = c; 156 fprintf(f, "\t.string\t\"%s\"\n", str);
162 } 
163} 157}
164 158
165static void asm_emit_align(void *e, int a) 159static void asm_emit_align(void *e, int a)
166{ 160{
167 FILE *f = e; 161 FILE *f = e;
168 162
169 fprintf(f, "\t.balign\t%d, 0\n", a); 163 fprintf(f, "\t.balign\t%d, 0\n", a);
170} 164}
171 165
172static void asm_emit_data(void *e, struct data d) 166static void asm_emit_data(void *e, struct data d)
173{ 167{
174 FILE *f = e; 168 FILE *f = e;
175 int off = 0; 169 int off = 0;
176 struct marker *m = d.markers; 170 struct marker *m = d.markers;
177 171
178 for_each_marker_of_type(m, LABEL) 172 for_each_marker_of_type(m, LABEL)
179 emit_offset_label(f, m->ref, m->offset); 173 emit_offset_label(f, m->ref, m->offset);
180 174
181 while ((d.len - off) >= sizeof(uint32_t)) { 175 while ((d.len - off) >= sizeof(uint32_t)) {
182 asm_emit_cell(e, fdt32_to_cpu(*((uint32_t *)(d.val+off)))); 176 asm_emit_cell(e, fdt32_to_cpu(*((fdt32_t *)(d.val+off))));
183 off += sizeof(uint32_t); 177 off += sizeof(uint32_t);
184 } 178 }
185 179
186 while ((d.len - off) >= 1) { 180 while ((d.len - off) >= 1) {
187 fprintf(f, "\t.byte\t0x%hhx\n", d.val[off]); 181 fprintf(f, "\t.byte\t0x%hhx\n", d.val[off]);
188 off += 1; 182 off += 1;
189 } 183 }
190 184
191 assert(off == d.len); 185 assert(off == d.len);
192} 186}
193 187
194static void asm_emit_beginnode(void *e, struct label *labels) 188static void asm_emit_beginnode(void *e, struct label *labels)
195{ 189{
@@ -308,37 +302,36 @@ static void flatten_tree(struct node *tr @@ -308,37 +302,36 @@ static void flatten_tree(struct node *tr
308 302
309 for_each_child(tree, child) { 303 for_each_child(tree, child) {
310 flatten_tree(child, emit, etarget, strbuf, vi); 304 flatten_tree(child, emit, etarget, strbuf, vi);
311 } 305 }
312 306
313 emit->endnode(etarget, tree->labels); 307 emit->endnode(etarget, tree->labels);
314} 308}
315 309
316static struct data flatten_reserve_list(struct reserve_info *reservelist, 310static struct data flatten_reserve_list(struct reserve_info *reservelist,
317 struct version_info *vi) 311 struct version_info *vi)
318{ 312{
319 struct reserve_info *re; 313 struct reserve_info *re;
320 struct data d = empty_data; 314 struct data d = empty_data;
321 static struct fdt_reserve_entry null_re = {0,0}; 
322 int j; 315 int j;
323 316
324 for (re = reservelist; re; re = re->next) { 317 for (re = reservelist; re; re = re->next) {
325 d = data_append_re(d, &re->re); 318 d = data_append_re(d, re->address, re->size);
326 } 319 }
327 /* 320 /*
328 * Add additional reserved slots if the user asked for them. 321 * Add additional reserved slots if the user asked for them.
329 */ 322 */
330 for (j = 0; j < reservenum; j++) { 323 for (j = 0; j < reservenum; j++) {
331 d = data_append_re(d, &null_re); 324 d = data_append_re(d, 0, 0);
332 } 325 }
333 326
334 return d; 327 return d;
335} 328}
336 329
337static void make_fdt_header(struct fdt_header *fdt, 330static void make_fdt_header(struct fdt_header *fdt,
338 struct version_info *vi, 331 struct version_info *vi,
339 int reservesize, int dtsize, int strsize, 332 int reservesize, int dtsize, int strsize,
340 int boot_cpuid_phys) 333 int boot_cpuid_phys)
341{ 334{
342 int reserve_off; 335 int reserve_off;
343 336
344 reservesize += sizeof(struct fdt_reserve_entry); 337 reservesize += sizeof(struct fdt_reserve_entry);
@@ -356,67 +349,74 @@ static void make_fdt_header(struct fdt_h @@ -356,67 +349,74 @@ static void make_fdt_header(struct fdt_h
356 fdt->off_dt_struct = cpu_to_fdt32(reserve_off + reservesize); 349 fdt->off_dt_struct = cpu_to_fdt32(reserve_off + reservesize);
357 fdt->off_dt_strings = cpu_to_fdt32(reserve_off + reservesize 350 fdt->off_dt_strings = cpu_to_fdt32(reserve_off + reservesize
358 + dtsize); 351 + dtsize);
359 fdt->totalsize = cpu_to_fdt32(reserve_off + reservesize + dtsize + strsize); 352 fdt->totalsize = cpu_to_fdt32(reserve_off + reservesize + dtsize + strsize);
360 353
361 if (vi->flags & FTF_BOOTCPUID) 354 if (vi->flags & FTF_BOOTCPUID)
362 fdt->boot_cpuid_phys = cpu_to_fdt32(boot_cpuid_phys); 355 fdt->boot_cpuid_phys = cpu_to_fdt32(boot_cpuid_phys);
363 if (vi->flags & FTF_STRTABSIZE) 356 if (vi->flags & FTF_STRTABSIZE)
364 fdt->size_dt_strings = cpu_to_fdt32(strsize); 357 fdt->size_dt_strings = cpu_to_fdt32(strsize);
365 if (vi->flags & FTF_STRUCTSIZE) 358 if (vi->flags & FTF_STRUCTSIZE)
366 fdt->size_dt_struct = cpu_to_fdt32(dtsize); 359 fdt->size_dt_struct = cpu_to_fdt32(dtsize);
367} 360}
368 361
369void dt_to_blob(FILE *f, struct boot_info *bi, int version) 362void dt_to_blob(FILE *f, struct dt_info *dti, int version)
370{ 363{
371 struct version_info *vi = NULL; 364 struct version_info *vi = NULL;
372 int i; 365 int i;
373 struct data blob = empty_data; 366 struct data blob = empty_data;
374 struct data reservebuf = empty_data; 367 struct data reservebuf = empty_data;
375 struct data dtbuf = empty_data; 368 struct data dtbuf = empty_data;
376 struct data strbuf = empty_data; 369 struct data strbuf = empty_data;
377 struct fdt_header fdt; 370 struct fdt_header fdt;
378 int padlen = 0; 371 int padlen = 0;
379 372
380 for (i = 0; i < ARRAY_SIZE(version_table); i++) { 373 for (i = 0; i < ARRAY_SIZE(version_table); i++) {
381 if (version_table[i].version == version) 374 if (version_table[i].version == version)
382 vi = &version_table[i]; 375 vi = &version_table[i];
383 } 376 }
384 if (!vi) 377 if (!vi)
385 die("Unknown device tree blob version %d\n", version); 378 die("Unknown device tree blob version %d\n", version);
386 379
387 flatten_tree(bi->dt, &bin_emitter, &dtbuf, &strbuf, vi); 380 flatten_tree(dti->dt, &bin_emitter, &dtbuf, &strbuf, vi);
388 bin_emit_cell(&dtbuf, FDT_END); 381 bin_emit_cell(&dtbuf, FDT_END);
389 382
390 reservebuf = flatten_reserve_list(bi->reservelist, vi); 383 reservebuf = flatten_reserve_list(dti->reservelist, vi);
391 384
392 /* Make header */ 385 /* Make header */
393 make_fdt_header(&fdt, vi, reservebuf.len, dtbuf.len, strbuf.len, 386 make_fdt_header(&fdt, vi, reservebuf.len, dtbuf.len, strbuf.len,
394 bi->boot_cpuid_phys); 387 dti->boot_cpuid_phys);
395 388
396 /* 389 /*
397 * If the user asked for more space than is used, adjust the totalsize. 390 * If the user asked for more space than is used, adjust the totalsize.
398 */ 391 */
399 if (minsize > 0) { 392 if (minsize > 0) {
400 padlen = minsize - fdt32_to_cpu(fdt.totalsize); 393 padlen = minsize - fdt32_to_cpu(fdt.totalsize);
401 if ((padlen < 0) && (quiet < 1)) 394 if (padlen < 0) {
402 fprintf(stderr, 395 padlen = 0;
403 "Warning: blob size %d >= minimum size %d\n", 396 if (quiet < 1)
404 fdt32_to_cpu(fdt.totalsize), minsize); 397 fprintf(stderr,
 398 "Warning: blob size %d >= minimum size %d\n",
 399 fdt32_to_cpu(fdt.totalsize), minsize);
 400 }
405 } 401 }
406 402
407 if (padsize > 0) 403 if (padsize > 0)
408 padlen = padsize; 404 padlen = padsize;
409 405
 406 if (alignsize > 0)
 407 padlen = ALIGN(fdt32_to_cpu(fdt.totalsize) + padlen, alignsize)
 408 - fdt32_to_cpu(fdt.totalsize);
 409
410 if (padlen > 0) { 410 if (padlen > 0) {
411 int tsize = fdt32_to_cpu(fdt.totalsize); 411 int tsize = fdt32_to_cpu(fdt.totalsize);
412 tsize += padlen; 412 tsize += padlen;
413 fdt.totalsize = cpu_to_fdt32(tsize); 413 fdt.totalsize = cpu_to_fdt32(tsize);
414 } 414 }
415 415
416 /* 416 /*
417 * Assemble the blob: start with the header, add with alignment 417 * Assemble the blob: start with the header, add with alignment
418 * the reserve buffer, add the reserve map terminating zeroes, 418 * the reserve buffer, add the reserve map terminating zeroes,
419 * the device tree itself, and finally the strings. 419 * the device tree itself, and finally the strings.
420 */ 420 */
421 blob = data_append_data(blob, &fdt, vi->hdr_size); 421 blob = data_append_data(blob, &fdt, vi->hdr_size);
422 blob = data_append_align(blob, 8); 422 blob = data_append_align(blob, 8);
@@ -450,27 +450,27 @@ static void dump_stringtable_asm(FILE *f @@ -450,27 +450,27 @@ static void dump_stringtable_asm(FILE *f
450{ 450{
451 const char *p; 451 const char *p;
452 int len; 452 int len;
453 453
454 p = strbuf.val; 454 p = strbuf.val;
455 455
456 while (p < (strbuf.val + strbuf.len)) { 456 while (p < (strbuf.val + strbuf.len)) {
457 len = strlen(p); 457 len = strlen(p);
458 fprintf(f, "\t.string \"%s\"\n", p); 458 fprintf(f, "\t.string \"%s\"\n", p);
459 p += len+1; 459 p += len+1;
460 } 460 }
461} 461}
462 462
463void dt_to_asm(FILE *f, struct boot_info *bi, int version) 463void dt_to_asm(FILE *f, struct dt_info *dti, int version)
464{ 464{
465 struct version_info *vi = NULL; 465 struct version_info *vi = NULL;
466 int i; 466 int i;
467 struct data strbuf = empty_data; 467 struct data strbuf = empty_data;
468 struct reserve_info *re; 468 struct reserve_info *re;
469 const char *symprefix = "dt"; 469 const char *symprefix = "dt";
470 470
471 for (i = 0; i < ARRAY_SIZE(version_table); i++) { 471 for (i = 0; i < ARRAY_SIZE(version_table); i++) {
472 if (version_table[i].version == version) 472 if (version_table[i].version == version)
473 vi = &version_table[i]; 473 vi = &version_table[i];
474 } 474 }
475 if (!vi) 475 if (!vi)
476 die("Unknown device tree blob version %d\n", version); 476 die("Unknown device tree blob version %d\n", version);
@@ -490,27 +490,27 @@ void dt_to_asm(FILE *f, struct boot_info @@ -490,27 +490,27 @@ void dt_to_asm(FILE *f, struct boot_info
490 fprintf(f, "\t/* off_dt_strings */\n"); 490 fprintf(f, "\t/* off_dt_strings */\n");
491 ASM_EMIT_BELONG(f, "_%s_strings_start - _%s_blob_start", 491 ASM_EMIT_BELONG(f, "_%s_strings_start - _%s_blob_start",
492 symprefix, symprefix); 492 symprefix, symprefix);
493 fprintf(f, "\t/* off_mem_rsvmap */\n"); 493 fprintf(f, "\t/* off_mem_rsvmap */\n");
494 ASM_EMIT_BELONG(f, "_%s_reserve_map - _%s_blob_start", 494 ASM_EMIT_BELONG(f, "_%s_reserve_map - _%s_blob_start",
495 symprefix, symprefix); 495 symprefix, symprefix);
496 fprintf(f, "\t/* version */\n"); 496 fprintf(f, "\t/* version */\n");
497 asm_emit_cell(f, vi->version); 497 asm_emit_cell(f, vi->version);
498 fprintf(f, "\t/* last_comp_version */\n"); 498 fprintf(f, "\t/* last_comp_version */\n");
499 asm_emit_cell(f, vi->last_comp_version); 499 asm_emit_cell(f, vi->last_comp_version);
500 500
501 if (vi->flags & FTF_BOOTCPUID) { 501 if (vi->flags & FTF_BOOTCPUID) {
502 fprintf(f, "\t/* boot_cpuid_phys */\n"); 502 fprintf(f, "\t/* boot_cpuid_phys */\n");
503 asm_emit_cell(f, bi->boot_cpuid_phys); 503 asm_emit_cell(f, dti->boot_cpuid_phys);
504 } 504 }
505 505
506 if (vi->flags & FTF_STRTABSIZE) { 506 if (vi->flags & FTF_STRTABSIZE) {
507 fprintf(f, "\t/* size_dt_strings */\n"); 507 fprintf(f, "\t/* size_dt_strings */\n");
508 ASM_EMIT_BELONG(f, "_%s_strings_end - _%s_strings_start", 508 ASM_EMIT_BELONG(f, "_%s_strings_end - _%s_strings_start",
509 symprefix, symprefix); 509 symprefix, symprefix);
510 } 510 }
511 511
512 if (vi->flags & FTF_STRUCTSIZE) { 512 if (vi->flags & FTF_STRUCTSIZE) {
513 fprintf(f, "\t/* size_dt_struct */\n"); 513 fprintf(f, "\t/* size_dt_struct */\n");
514 ASM_EMIT_BELONG(f, "_%s_struct_end - _%s_struct_start", 514 ASM_EMIT_BELONG(f, "_%s_struct_end - _%s_struct_start",
515 symprefix, symprefix); 515 symprefix, symprefix);
516 } 516 }
@@ -520,68 +520,70 @@ void dt_to_asm(FILE *f, struct boot_info @@ -520,68 +520,70 @@ void dt_to_asm(FILE *f, struct boot_info
520 * Align the reserve map to a doubleword boundary. 520 * Align the reserve map to a doubleword boundary.
521 * Each entry is an (address, size) pair of u64 values. 521 * Each entry is an (address, size) pair of u64 values.
522 * Always supply a zero-sized temination entry. 522 * Always supply a zero-sized temination entry.
523 */ 523 */
524 asm_emit_align(f, 8); 524 asm_emit_align(f, 8);
525 emit_label(f, symprefix, "reserve_map"); 525 emit_label(f, symprefix, "reserve_map");
526 526
527 fprintf(f, "/* Memory reserve map from source file */\n"); 527 fprintf(f, "/* Memory reserve map from source file */\n");
528 528
529 /* 529 /*
530 * Use .long on high and low halfs of u64s to avoid .quad 530 * Use .long on high and low halfs of u64s to avoid .quad
531 * as it appears .quad isn't available in some assemblers. 531 * as it appears .quad isn't available in some assemblers.
532 */ 532 */
533 for (re = bi->reservelist; re; re = re->next) { 533 for (re = dti->reservelist; re; re = re->next) {
534 struct label *l; 534 struct label *l;
535 535
536 for_each_label(re->labels, l) { 536 for_each_label(re->labels, l) {
537 fprintf(f, "\t.globl\t%s\n", l->label); 537 fprintf(f, "\t.globl\t%s\n", l->label);
538 fprintf(f, "%s:\n", l->label); 538 fprintf(f, "%s:\n", l->label);
539 } 539 }
540 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.address >> 32)); 540 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->address >> 32));
541 ASM_EMIT_BELONG(f, "0x%08x", 541 ASM_EMIT_BELONG(f, "0x%08x",
542 (unsigned int)(re->re.address & 0xffffffff)); 542 (unsigned int)(re->address & 0xffffffff));
543 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size >> 32)); 543 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->size >> 32));
544 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size & 0xffffffff)); 544 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->size & 0xffffffff));
545 } 545 }
546 for (i = 0; i < reservenum; i++) { 546 for (i = 0; i < reservenum; i++) {
547 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n"); 547 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
548 } 548 }
549 549
550 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n"); 550 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
551 551
552 emit_label(f, symprefix, "struct_start"); 552 emit_label(f, symprefix, "struct_start");
553 flatten_tree(bi->dt, &asm_emitter, f, &strbuf, vi); 553 flatten_tree(dti->dt, &asm_emitter, f, &strbuf, vi);
554 554
555 fprintf(f, "\t/* FDT_END */\n"); 555 fprintf(f, "\t/* FDT_END */\n");
556 asm_emit_cell(f, FDT_END); 556 asm_emit_cell(f, FDT_END);
557 emit_label(f, symprefix, "struct_end"); 557 emit_label(f, symprefix, "struct_end");
558 558
559 emit_label(f, symprefix, "strings_start"); 559 emit_label(f, symprefix, "strings_start");
560 dump_stringtable_asm(f, strbuf); 560 dump_stringtable_asm(f, strbuf);
561 emit_label(f, symprefix, "strings_end"); 561 emit_label(f, symprefix, "strings_end");
562 562
563 emit_label(f, symprefix, "blob_end"); 563 emit_label(f, symprefix, "blob_end");
564 564
565 /* 565 /*
566 * If the user asked for more space than is used, pad it out. 566 * If the user asked for more space than is used, pad it out.
567 */ 567 */
568 if (minsize > 0) { 568 if (minsize > 0) {
569 fprintf(f, "\t.space\t%d - (_%s_blob_end - _%s_blob_start), 0\n", 569 fprintf(f, "\t.space\t%d - (_%s_blob_end - _%s_blob_start), 0\n",
570 minsize, symprefix, symprefix); 570 minsize, symprefix, symprefix);
571 } 571 }
572 if (padsize > 0) { 572 if (padsize > 0) {
573 fprintf(f, "\t.space\t%d, 0\n", padsize); 573 fprintf(f, "\t.space\t%d, 0\n", padsize);
574 } 574 }
 575 if (alignsize > 0)
 576 asm_emit_align(f, alignsize);
575 emit_label(f, symprefix, "blob_abs_end"); 577 emit_label(f, symprefix, "blob_abs_end");
576 578
577 data_free(strbuf); 579 data_free(strbuf);
578} 580}
579 581
580struct inbuf { 582struct inbuf {
581 char *base, *limit, *ptr; 583 char *base, *limit, *ptr;
582}; 584};
583 585
584static void inbuf_init(struct inbuf *inb, void *base, void *limit) 586static void inbuf_init(struct inbuf *inb, void *base, void *limit)
585{ 587{
586 inb->base = base; 588 inb->base = base;
587 inb->limit = limit; 589 inb->limit = limit;
@@ -590,27 +592,27 @@ static void inbuf_init(struct inbuf *inb @@ -590,27 +592,27 @@ static void inbuf_init(struct inbuf *inb
590 592
591static void flat_read_chunk(struct inbuf *inb, void *p, int len) 593static void flat_read_chunk(struct inbuf *inb, void *p, int len)
592{ 594{
593 if ((inb->ptr + len) > inb->limit) 595 if ((inb->ptr + len) > inb->limit)
594 die("Premature end of data parsing flat device tree\n"); 596 die("Premature end of data parsing flat device tree\n");
595 597
596 memcpy(p, inb->ptr, len); 598 memcpy(p, inb->ptr, len);
597 599
598 inb->ptr += len; 600 inb->ptr += len;
599} 601}
600 602
601static uint32_t flat_read_word(struct inbuf *inb) 603static uint32_t flat_read_word(struct inbuf *inb)
602{ 604{
603 uint32_t val; 605 fdt32_t val;
604 606
605 assert(((inb->ptr - inb->base) % sizeof(val)) == 0); 607 assert(((inb->ptr - inb->base) % sizeof(val)) == 0);
606 608
607 flat_read_chunk(inb, &val, sizeof(val)); 609 flat_read_chunk(inb, &val, sizeof(val));
608 610
609 return fdt32_to_cpu(val); 611 return fdt32_to_cpu(val);
610} 612}
611 613
612static void flat_realign(struct inbuf *inb, int align) 614static void flat_realign(struct inbuf *inb, int align)
613{ 615{
614 int off = inb->ptr - inb->base; 616 int off = inb->ptr - inb->base;
615 617
616 inb->ptr = inb->base + FDTALIGN2(off, align); 618 inb->ptr = inb->base + FDTALIGN2(off, align);
@@ -699,33 +701,35 @@ static struct property *flat_read_proper @@ -699,33 +701,35 @@ static struct property *flat_read_proper
699static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb) 701static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb)
700{ 702{
701 struct reserve_info *reservelist = NULL; 703 struct reserve_info *reservelist = NULL;
702 struct reserve_info *new; 704 struct reserve_info *new;
703 struct fdt_reserve_entry re; 705 struct fdt_reserve_entry re;
704 706
705 /* 707 /*
706 * Each entry is a pair of u64 (addr, size) values for 4 cell_t's. 708 * Each entry is a pair of u64 (addr, size) values for 4 cell_t's.
707 * List terminates at an entry with size equal to zero. 709 * List terminates at an entry with size equal to zero.
708 * 710 *
709 * First pass, count entries. 711 * First pass, count entries.
710 */ 712 */
711 while (1) { 713 while (1) {
 714 uint64_t address, size;
 715
712 flat_read_chunk(inb, &re, sizeof(re)); 716 flat_read_chunk(inb, &re, sizeof(re));
713 re.address = fdt64_to_cpu(re.address); 717 address = fdt64_to_cpu(re.address);
714 re.size = fdt64_to_cpu(re.size); 718 size = fdt64_to_cpu(re.size);
715 if (re.size == 0) 719 if (size == 0)
716 break; 720 break;
717 721
718 new = build_reserve_entry(re.address, re.size); 722 new = build_reserve_entry(address, size);
719 reservelist = add_reserve_entry(reservelist, new); 723 reservelist = add_reserve_entry(reservelist, new);
720 } 724 }
721 725
722 return reservelist; 726 return reservelist;
723} 727}
724 728
725 729
726static char *nodename_from_path(const char *ppath, const char *cpath) 730static char *nodename_from_path(const char *ppath, const char *cpath)
727{ 731{
728 int plen; 732 int plen;
729 733
730 plen = strlen(ppath); 734 plen = strlen(ppath);
731 735
@@ -787,75 +791,80 @@ static struct node *unflatten_tree(struc @@ -787,75 +791,80 @@ static struct node *unflatten_tree(struc
787 if (!(flags & FTF_NOPS)) 791 if (!(flags & FTF_NOPS))
788 fprintf(stderr, "Warning: NOP tag found in flat tree" 792 fprintf(stderr, "Warning: NOP tag found in flat tree"
789 " version <16\n"); 793 " version <16\n");
790 794
791 /* Ignore */ 795 /* Ignore */
792 break; 796 break;
793 797
794 default: 798 default:
795 die("Invalid opcode word %08x in device tree blob\n", 799 die("Invalid opcode word %08x in device tree blob\n",
796 val); 800 val);
797 } 801 }
798 } while (val != FDT_END_NODE); 802 } while (val != FDT_END_NODE);
799 803
 804 if (node->name != flatname) {
 805 free(flatname);
 806 }
 807
800 return node; 808 return node;
801} 809}
802 810
803 811
804struct boot_info *dt_from_blob(const char *fname) 812struct dt_info *dt_from_blob(const char *fname)
805{ 813{
806 FILE *f; 814 FILE *f;
 815 fdt32_t magic_buf, totalsize_buf;
807 uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys; 816 uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys;
808 uint32_t off_dt, off_str, off_mem_rsvmap; 817 uint32_t off_dt, off_str, off_mem_rsvmap;
809 int rc; 818 int rc;
810 char *blob; 819 char *blob;
811 struct fdt_header *fdt; 820 struct fdt_header *fdt;
812 char *p; 821 char *p;
813 struct inbuf dtbuf, strbuf; 822 struct inbuf dtbuf, strbuf;
814 struct inbuf memresvbuf; 823 struct inbuf memresvbuf;
815 int sizeleft; 824 int sizeleft;
816 struct reserve_info *reservelist; 825 struct reserve_info *reservelist;
817 struct node *tree; 826 struct node *tree;
818 uint32_t val; 827 uint32_t val;
819 int flags = 0; 828 int flags = 0;
820 829
821 f = srcfile_relative_open(fname, NULL); 830 f = srcfile_relative_open(fname, NULL);
822 831
823 rc = fread(&magic, sizeof(magic), 1, f); 832 rc = fread(&magic_buf, sizeof(magic_buf), 1, f);
824 if (ferror(f)) 833 if (ferror(f))
825 die("Error reading DT blob magic number: %s\n", 834 die("Error reading DT blob magic number: %s\n",
826 strerror(errno)); 835 strerror(errno));
827 if (rc < 1) { 836 if (rc < 1) {
828 if (feof(f)) 837 if (feof(f))
829 die("EOF reading DT blob magic number\n"); 838 die("EOF reading DT blob magic number\n");
830 else 839 else
831 die("Mysterious short read reading magic number\n"); 840 die("Mysterious short read reading magic number\n");
832 } 841 }
833 842
834 magic = fdt32_to_cpu(magic); 843 magic = fdt32_to_cpu(magic_buf);
835 if (magic != FDT_MAGIC) 844 if (magic != FDT_MAGIC)
836 die("Blob has incorrect magic number\n"); 845 die("Blob has incorrect magic number\n");
837 846
838 rc = fread(&totalsize, sizeof(totalsize), 1, f); 847 rc = fread(&totalsize_buf, sizeof(totalsize_buf), 1, f);
839 if (ferror(f)) 848 if (ferror(f))
840 die("Error reading DT blob size: %s\n", strerror(errno)); 849 die("Error reading DT blob size: %s\n", strerror(errno));
841 if (rc < 1) { 850 if (rc < 1) {
842 if (feof(f)) 851 if (feof(f))
843 die("EOF reading DT blob size\n"); 852 die("EOF reading DT blob size\n");
844 else 853 else
845 die("Mysterious short read reading blob size\n"); 854 die("Mysterious short read reading blob size\n");
846 } 855 }
847 856
848 totalsize = fdt32_to_cpu(totalsize); 857 totalsize = fdt32_to_cpu(totalsize_buf);
849 if (totalsize < FDT_V1_SIZE) 858 if (totalsize < FDT_V1_SIZE)
850 die("DT blob size (%d) is too small\n", totalsize); 859 die("DT blob size (%d) is too small\n", totalsize);
851 860
852 blob = xmalloc(totalsize); 861 blob = xmalloc(totalsize);
853 862
854 fdt = (struct fdt_header *)blob; 863 fdt = (struct fdt_header *)blob;
855 fdt->magic = cpu_to_fdt32(magic); 864 fdt->magic = cpu_to_fdt32(magic);
856 fdt->totalsize = cpu_to_fdt32(totalsize); 865 fdt->totalsize = cpu_to_fdt32(totalsize);
857 866
858 sizeleft = totalsize - sizeof(magic) - sizeof(totalsize); 867 sizeleft = totalsize - sizeof(magic) - sizeof(totalsize);
859 p = blob + sizeof(magic) + sizeof(totalsize); 868 p = blob + sizeof(magic) + sizeof(totalsize);
860 869
861 while (sizeleft) { 870 while (sizeleft) {
@@ -879,36 +888,36 @@ struct boot_info *dt_from_blob(const cha @@ -879,36 +888,36 @@ struct boot_info *dt_from_blob(const cha
879 boot_cpuid_phys = fdt32_to_cpu(fdt->boot_cpuid_phys); 888 boot_cpuid_phys = fdt32_to_cpu(fdt->boot_cpuid_phys);
880 889
881 if (off_mem_rsvmap >= totalsize) 890 if (off_mem_rsvmap >= totalsize)
882 die("Mem Reserve structure offset exceeds total size\n"); 891 die("Mem Reserve structure offset exceeds total size\n");
883 892
884 if (off_dt >= totalsize) 893 if (off_dt >= totalsize)
885 die("DT structure offset exceeds total size\n"); 894 die("DT structure offset exceeds total size\n");
886 895
887 if (off_str > totalsize) 896 if (off_str > totalsize)
888 die("String table offset exceeds total size\n"); 897 die("String table offset exceeds total size\n");
889 898
890 if (version >= 3) { 899 if (version >= 3) {
891 uint32_t size_str = fdt32_to_cpu(fdt->size_dt_strings); 900 uint32_t size_str = fdt32_to_cpu(fdt->size_dt_strings);
892 if (off_str+size_str > totalsize) 901 if ((off_str+size_str < off_str) || (off_str+size_str > totalsize))
893 die("String table extends past total size\n"); 902 die("String table extends past total size\n");
894 inbuf_init(&strbuf, blob + off_str, blob + off_str + size_str); 903 inbuf_init(&strbuf, blob + off_str, blob + off_str + size_str);
895 } else { 904 } else {
896 inbuf_init(&strbuf, blob + off_str, blob + totalsize); 905 inbuf_init(&strbuf, blob + off_str, blob + totalsize);
897 } 906 }
898 907
899 if (version >= 17) { 908 if (version >= 17) {
900 size_dt = fdt32_to_cpu(fdt->size_dt_struct); 909 size_dt = fdt32_to_cpu(fdt->size_dt_struct);
901 if (off_dt+size_dt > totalsize) 910 if ((off_dt+size_dt < off_dt) || (off_dt+size_dt > totalsize))
902 die("Structure block extends past total size\n"); 911 die("Structure block extends past total size\n");
903 } 912 }
904 913
905 if (version < 16) { 914 if (version < 16) {
906 flags |= FTF_FULLPATH | FTF_NAMEPROPS | FTF_VARALIGN; 915 flags |= FTF_FULLPATH | FTF_NAMEPROPS | FTF_VARALIGN;
907 } else { 916 } else {
908 flags |= FTF_NOPS; 917 flags |= FTF_NOPS;
909 } 918 }
910 919
911 inbuf_init(&memresvbuf, 920 inbuf_init(&memresvbuf,
912 blob + off_mem_rsvmap, blob + totalsize); 921 blob + off_mem_rsvmap, blob + totalsize);
913 inbuf_init(&dtbuf, blob + off_dt, blob + totalsize); 922 inbuf_init(&dtbuf, blob + off_dt, blob + totalsize);
914 923
@@ -919,15 +928,15 @@ struct boot_info *dt_from_blob(const cha @@ -919,15 +928,15 @@ struct boot_info *dt_from_blob(const cha
919 if (val != FDT_BEGIN_NODE) 928 if (val != FDT_BEGIN_NODE)
920 die("Device tree blob doesn't begin with FDT_BEGIN_NODE (begins with 0x%08x)\n", val); 929 die("Device tree blob doesn't begin with FDT_BEGIN_NODE (begins with 0x%08x)\n", val);
921 930
922 tree = unflatten_tree(&dtbuf, &strbuf, "", flags); 931 tree = unflatten_tree(&dtbuf, &strbuf, "", flags);
923 932
924 val = flat_read_word(&dtbuf); 933 val = flat_read_word(&dtbuf);
925 if (val != FDT_END) 934 if (val != FDT_END)
926 die("Device tree blob doesn't end with FDT_END\n"); 935 die("Device tree blob doesn't end with FDT_END\n");
927 936
928 free(blob); 937 free(blob);
929 938
930 fclose(f); 939 fclose(f);
931 940
932 return build_boot_info(reservelist, tree, boot_cpuid_phys); 941 return build_dt_info(DTSF_V1, reservelist, tree, boot_cpuid_phys);
933} 942}

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/srcpos.c (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/srcpos.c 2017/06/06 20:19:04 1.2
+++ src/external/gpl2/dtc/dist/srcpos.c 2017/06/08 16:00:40 1.3
@@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
 1/* $NetBSD: srcpos.c,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1/* 3/*
2 * Copyright 2007 Jon Loeliger, Freescale Semiconductor, Inc. 4 * Copyright 2007 Jon Loeliger, Freescale Semiconductor, Inc.
3 * 5 *
4 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the 8 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version. 9 * License, or (at your option) any later version.
8 * 10 *
9 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details. 14 * General Public License for more details.
13 * 15 *
@@ -236,66 +238,47 @@ void srcpos_update(struct srcpos *pos, c @@ -236,66 +238,47 @@ void srcpos_update(struct srcpos *pos, c
236} 238}
237 239
238struct srcpos * 240struct srcpos *
239srcpos_copy(struct srcpos *pos) 241srcpos_copy(struct srcpos *pos)
240{ 242{
241 struct srcpos *pos_new; 243 struct srcpos *pos_new;
242 244
243 pos_new = xmalloc(sizeof(struct srcpos)); 245 pos_new = xmalloc(sizeof(struct srcpos));
244 memcpy(pos_new, pos, sizeof(struct srcpos)); 246 memcpy(pos_new, pos, sizeof(struct srcpos));
245 247
246 return pos_new; 248 return pos_new;
247} 249}
248 250
249 
250 
251void 
252srcpos_dump(struct srcpos *pos) 
253{ 
254 printf("file : \"%s\"\n", 
255 pos->file ? (char *) pos->file : "<no file>"); 
256 printf("first_line : %d\n", pos->first_line); 
257 printf("first_column: %d\n", pos->first_column); 
258 printf("last_line : %d\n", pos->last_line); 
259 printf("last_column : %d\n", pos->last_column); 
260 printf("file : %s\n", pos->file->name); 
261} 
262 
263 
264char * 251char *
265srcpos_string(struct srcpos *pos) 252srcpos_string(struct srcpos *pos)
266{ 253{
267 const char *fname = "<no-file>"; 254 const char *fname = "<no-file>";
268 char *pos_str; 255 char *pos_str;
269 int rc; 
270 256
271 if (pos) 257 if (pos->file && pos->file->name)
272 fname = pos->file->name; 258 fname = pos->file->name;
273 259
274 260
275 if (pos->first_line != pos->last_line) 261 if (pos->first_line != pos->last_line)
276 rc = asprintf(&pos_str, "%s:%d.%d-%d.%d", fname, 262 xasprintf(&pos_str, "%s:%d.%d-%d.%d", fname,
277 pos->first_line, pos->first_column, 263 pos->first_line, pos->first_column,
278 pos->last_line, pos->last_column); 264 pos->last_line, pos->last_column);
279 else if (pos->first_column != pos->last_column) 265 else if (pos->first_column != pos->last_column)
280 rc = asprintf(&pos_str, "%s:%d.%d-%d", fname, 266 xasprintf(&pos_str, "%s:%d.%d-%d", fname,
281 pos->first_line, pos->first_column, 267 pos->first_line, pos->first_column,
282 pos->last_column); 268 pos->last_column);
283 else 269 else
284 rc = asprintf(&pos_str, "%s:%d.%d", fname, 270 xasprintf(&pos_str, "%s:%d.%d", fname,
285 pos->first_line, pos->first_column); 271 pos->first_line, pos->first_column);
286 
287 if (rc == -1) 
288 die("Couldn't allocate in srcpos string"); 
289 272
290 return pos_str; 273 return pos_str;
291} 274}
292 275
293void srcpos_verror(struct srcpos *pos, const char *prefix, 276void srcpos_verror(struct srcpos *pos, const char *prefix,
294 const char *fmt, va_list va) 277 const char *fmt, va_list va)
295{ 278{
296 char *srcstr; 279 char *srcstr;
297 280
298 srcstr = srcpos_string(pos); 281 srcstr = srcpos_string(pos);
299 282
300 fprintf(stderr, "%s: %s ", prefix, srcstr); 283 fprintf(stderr, "%s: %s ", prefix, srcstr);
301 vfprintf(stderr, fmt, va); 284 vfprintf(stderr, fmt, va);

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/util.h (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/util.h 2017/06/06 20:19:04 1.2
+++ src/external/gpl2/dtc/dist/util.h 2017/06/08 16:00:40 1.3
@@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
 1/* $NetBSD: util.h,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1#ifndef _UTIL_H 3#ifndef _UTIL_H
2#define _UTIL_H 4#define _UTIL_H
3 5
4#include <stdarg.h> 6#include <stdarg.h>
5#include <stdbool.h> 7#include <stdbool.h>
6#include <getopt.h> 8#include <getopt.h>
7 9
8/* 10/*
9 * Copyright 2011 The Chromium Authors, All Rights Reserved. 11 * Copyright 2011 The Chromium Authors, All Rights Reserved.
10 * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. 12 * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
11 * 13 *
12 * This program is free software; you can redistribute it and/or 14 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as 15 * modify it under the terms of the GNU General Public License as
@@ -15,62 +17,72 @@ @@ -15,62 +17,72 @@
15 * License, or (at your option) any later version. 17 * License, or (at your option) any later version.
16 * 18 *
17 * This program is distributed in the hope that it will be useful, 19 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details. 22 * General Public License for more details.
21 * 23 *
22 * You should have received a copy of the GNU General Public License 24 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software 25 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 * USA 27 * USA
26 */ 28 */
27 29
 30#ifdef __GNUC__
 31#define PRINTF(i, j) __attribute__((format (printf, i, j)))
 32#define NORETURN __attribute__((noreturn))
 33#else
 34#define PRINTF(i, j)
 35#define NORETURN
 36#endif
 37
28#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 38#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
29#define FDTALIGN2(x, a) (((x) + (a) - 1) & ~((a) - 1)) 39#define FDTALIGN2(x, a) (((x) + (a) - 1) & ~((a) - 1))
30#define PALIGN(p, a) ((void *)(FDTALIGN2((unsigned long)(p), (a)))) 40#define PALIGN(p, a) ((void *)(FDTALIGN2((unsigned long)(p), (a))))
31 41
32static inline void __attribute__((noreturn)) die(const char *str, ...) 42static inline void NORETURN PRINTF(1, 2) die(const char *str, ...)
33{ 43{
34 va_list ap; 44 va_list ap;
35 45
36 va_start(ap, str); 46 va_start(ap, str);
37 fprintf(stderr, "FATAL ERROR: "); 47 fprintf(stderr, "FATAL ERROR: ");
38 vfprintf(stderr, str, ap); 48 vfprintf(stderr, str, ap);
39 va_end(ap); 49 va_end(ap);
40 exit(1); 50 exit(1);
41} 51}
42 52
43static inline void *xmalloc(size_t len) 53static inline void *xmalloc(size_t len)
44{ 54{
45 void *new = malloc(len); 55 void *new = malloc(len);
46 56
47 if (!new) 57 if (!new)
48 die("malloc() failed\n"); 58 die("malloc() failed\n");
49 59
50 return new; 60 return new;
51} 61}
52 62
53static inline void *xrealloc(void *p, size_t len) 63static inline void *xrealloc(void *p, size_t len)
54{ 64{
55 void *new = realloc(p, len); 65 void *new = realloc(p, len);
56 66
57 if (!new) 67 if (!new)
58 die("realloc() failed (len=%d)\n", len); 68 die("realloc() failed (len=%zd)\n", len);
59 69
60 return new; 70 return new;
61} 71}
62 72
63extern char *xstrdup(const char *s); 73extern char *xstrdup(const char *s);
 74
 75extern int PRINTF(2, 3) xasprintf(char **strp, const char *fmt, ...);
64extern char *join_path(const char *path, const char *name); 76extern char *join_path(const char *path, const char *name);
65 77
66/** 78/**
67 * Check a property of a given length to see if it is all printable and 79 * Check a property of a given length to see if it is all printable and
68 * has a valid terminator. The property can contain either a single string, 80 * has a valid terminator. The property can contain either a single string,
69 * or multiple strings each of non-zero length. 81 * or multiple strings each of non-zero length.
70 * 82 *
71 * @param data The string to check 83 * @param data The string to check
72 * @param len The string length including terminator 84 * @param len The string length including terminator
73 * @return 1 if a valid printable string, 0 if not 85 * @return 1 if a valid printable string, 0 if not
74 */ 86 */
75bool util_is_printable_string(const void *data, int len); 87bool util_is_printable_string(const void *data, int len);
76 88
@@ -179,43 +191,44 @@ int utilfdt_decode_type(const char *fmt, @@ -179,43 +191,44 @@ int utilfdt_decode_type(const char *fmt,
179 * the data will be displayed either as cells (if len is a multiple of 4 191 * the data will be displayed either as cells (if len is a multiple of 4
180 * bytes) or bytes. 192 * bytes) or bytes.
181 * 193 *
182 * If len is 0 then this function does nothing. 194 * If len is 0 then this function does nothing.
183 * 195 *
184 * @param data Pointers to property data 196 * @param data Pointers to property data
185 * @param len Length of property data 197 * @param len Length of property data
186 */ 198 */
187void utilfdt_print_data(const char *data, int len); 199void utilfdt_print_data(const char *data, int len);
188 200
189/** 201/**
190 * Show source version and exit 202 * Show source version and exit
191 */ 203 */
192void util_version(void) __attribute__((noreturn)); 204void NORETURN util_version(void);
193 205
194/** 206/**
195 * Show usage and exit 207 * Show usage and exit
196 * 208 *
197 * This helps standardize the output of various utils. You most likely want 209 * This helps standardize the output of various utils. You most likely want
198 * to use the usage() helper below rather than call this. 210 * to use the usage() helper below rather than call this.
199 * 211 *
200 * @param errmsg If non-NULL, an error message to display 212 * @param errmsg If non-NULL, an error message to display
201 * @param synopsis The initial example usage text (and possible examples) 213 * @param synopsis The initial example usage text (and possible examples)
202 * @param short_opts The string of short options 214 * @param short_opts The string of short options
203 * @param long_opts The structure of long options 215 * @param long_opts The structure of long options
204 * @param opts_help An array of help strings (should align with long_opts) 216 * @param opts_help An array of help strings (should align with long_opts)
205 */ 217 */
206void util_usage(const char *errmsg, const char *synopsis, 218void NORETURN util_usage(const char *errmsg, const char *synopsis,
207 const char *short_opts, struct option const long_opts[], 219 const char *short_opts,
208 const char * const opts_help[]) __attribute__((noreturn)); 220 struct option const long_opts[],
 221 const char * const opts_help[]);
209 222
210/** 223/**
211 * Show usage and exit 224 * Show usage and exit
212 * 225 *
213 * If you name all your usage variables with usage_xxx, then you can call this 226 * If you name all your usage variables with usage_xxx, then you can call this
214 * help macro rather than expanding all arguments yourself. 227 * help macro rather than expanding all arguments yourself.
215 * 228 *
216 * @param errmsg If non-NULL, an error message to display 229 * @param errmsg If non-NULL, an error message to display
217 */ 230 */
218#define usage(errmsg) \ 231#define usage(errmsg) \
219 util_usage(errmsg, usage_synopsis, usage_short_opts, \ 232 util_usage(errmsg, usage_synopsis, usage_short_opts, \
220 usage_long_opts, usage_opts_help) 233 usage_long_opts, usage_opts_help)
221 234

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/Makefile.libfdt

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/TODO

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/fdt.c

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/fdt.h

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/fdt_addresses.c

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/fdt_empty_tree.c

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/fdt_ro.c

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/fdt_rw.c

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/fdt_strerror.c

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/fdt_sw.c

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/fdt_wip.c

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/libfdt.h

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/libfdt_env.h

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/libfdt_internal.h

File Deleted: src/external/gpl2/dtc/dist/libfdt/Attic/version.lds

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/tests/mangle-layout.c (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/tests/mangle-layout.c 2017/06/06 20:19:04 1.2
+++ src/external/gpl2/dtc/dist/tests/mangle-layout.c 2017/06/08 16:00:40 1.3
@@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
 1/* $NetBSD: mangle-layout.c,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1/* 3/*
2 * libfdt - Flat Device Tree manipulation 4 * libfdt - Flat Device Tree manipulation
3 * Testcase/tool for rearranging blocks of a dtb 5 * Testcase/tool for rearranging blocks of a dtb
4 * Copyright (C) 2006 David Gibson, IBM Corporation. 6 * Copyright (C) 2006 David Gibson, IBM Corporation.
5 * 7 *
6 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License 9 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1 of 10 * as published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
10 * 12 *
11 * This library is distributed in the hope that it will be useful, but 13 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/tests/move_and_save.c (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/tests/move_and_save.c 2017/06/06 20:19:04 1.2
+++ src/external/gpl2/dtc/dist/tests/move_and_save.c 2017/06/08 16:00:40 1.3
@@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
 1/* $NetBSD: move_and_save.c,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1/* 3/*
2 * libfdt - Flat Device Tree manipulation 4 * libfdt - Flat Device Tree manipulation
3 * Basic testcase for read-only access 5 * Basic testcase for read-only access
4 * Copyright (C) 2006 David Gibson, IBM Corporation. 6 * Copyright (C) 2006 David Gibson, IBM Corporation.
5 * 7 *
6 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License 9 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1 of 10 * as published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
10 * 12 *
11 * This library is distributed in the hope that it will be useful, but 13 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

cvs diff -r1.2 -r1.3 src/external/gpl2/dtc/dist/tests/tests.h (expand / switch to unified diff)

--- src/external/gpl2/dtc/dist/tests/tests.h 2017/06/06 20:19:04 1.2
+++ src/external/gpl2/dtc/dist/tests/tests.h 2017/06/08 16:00:40 1.3
@@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
 1/* $NetBSD: tests.h,v 1.3 2017/06/08 16:00:40 skrll Exp $ */
 2
1#ifndef _TESTS_H 3#ifndef _TESTS_H
2#define _TESTS_H 4#define _TESTS_H
3/* 5/*
4 * libfdt - Flat Device Tree manipulation 6 * libfdt - Flat Device Tree manipulation
5 * Testcase definitions 7 * Testcase definitions
6 * Copyright (C) 2006 David Gibson, IBM Corporation. 8 * Copyright (C) 2006 David Gibson, IBM Corporation.
7 * 9 *
8 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License 11 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of 12 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version. 13 * the License, or (at your option) any later version.
12 * 14 *
13 * This library is distributed in the hope that it will be useful, but 15 * This library is distributed in the hope that it will be useful, but
@@ -89,41 +91,41 @@ void cleanup(void); @@ -89,41 +91,41 @@ void cleanup(void);
89#define TEST_BUG(fmt, ...) \ 91#define TEST_BUG(fmt, ...) \
90 do { \ 92 do { \
91 cleanup(); \ 93 cleanup(); \
92 printf("BUG in testsuite: " fmt "\n", ##__VA_ARGS__); \ 94 printf("BUG in testsuite: " fmt "\n", ##__VA_ARGS__); \
93 exit(RC_BUG); \ 95 exit(RC_BUG); \
94 } while (0) 96 } while (0)
95 97
96void check_mem_rsv(void *fdt, int n, uint64_t addr, uint64_t size); 98void check_mem_rsv(void *fdt, int n, uint64_t addr, uint64_t size);
97 99
98void check_property(void *fdt, int nodeoffset, const char *name, 100void check_property(void *fdt, int nodeoffset, const char *name,
99 int len, const void *val); 101 int len, const void *val);
100#define check_property_cell(fdt, nodeoffset, name, val) \ 102#define check_property_cell(fdt, nodeoffset, name, val) \
101 ({ \ 103 ({ \
102 uint32_t x = cpu_to_fdt32(val); \ 104 fdt32_t x = cpu_to_fdt32(val); \
103 check_property(fdt, nodeoffset, name, sizeof(x), &x); \ 105 check_property(fdt, nodeoffset, name, sizeof(x), &x); \
104 }) 106 })
105 107
106 108
107const void *check_getprop(void *fdt, int nodeoffset, const char *name, 109const void *check_getprop(void *fdt, int nodeoffset, const char *name,
108 int len, const void *val); 110 int len, const void *val);
109#define check_getprop_cell(fdt, nodeoffset, name, val) \ 111#define check_getprop_cell(fdt, nodeoffset, name, val) \
110 ({ \ 112 ({ \
111 uint32_t x = cpu_to_fdt32(val); \ 113 fdt32_t x = cpu_to_fdt32(val); \
112 check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \ 114 check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
113 }) 115 })
114#define check_getprop_64(fdt, nodeoffset, name, val) \ 116#define check_getprop_64(fdt, nodeoffset, name, val) \
115 ({ \ 117 ({ \
116 uint64_t x = cpu_to_fdt64(val); \ 118 fdt64_t x = cpu_to_fdt64(val); \
117 check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \ 119 check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
118 }) 120 })
119#define check_getprop_string(fdt, nodeoffset, name, s) \ 121#define check_getprop_string(fdt, nodeoffset, name, s) \
120 check_getprop((fdt), (nodeoffset), (name), strlen(s)+1, (s)) 122 check_getprop((fdt), (nodeoffset), (name), strlen(s)+1, (s))
121int nodename_eq(const char *s1, const char *s2); 123int nodename_eq(const char *s1, const char *s2);
122void *load_blob(const char *filename); 124void *load_blob(const char *filename);
123void *load_blob_arg(int argc, char *argv[]); 125void *load_blob_arg(int argc, char *argv[]);
124void save_blob(const char *filename, void *blob); 126void save_blob(const char *filename, void *blob);
125void *open_blob_rw(void *blob); 127void *open_blob_rw(void *blob);
126 128
127#include "util.h" 129#include "util.h"
128 130
129#endif /* _TESTS_H */ 131#endif /* _TESTS_H */

File Deleted: src/external/gpl2/dtc/dist/tests/Attic/test_tree1_body.dtsi