History

Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6

* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6: (29 commits) of/flattree: forward declare struct device_node in of_fdt.h ipmi: explicitly include of_address.h and of_irq.h sparc: explicitly cast negative phandle checks to s32 powerpc/405: Fix missing #{address,size}-cells in i2c node powerpc/5200: dts: refactor dts files powerpc/5200: dts: Change combatible strings on localbus powerpc/5200: dts: remove unused properties powerpc/5200: dts: rename nodes to prepare for refactoring dts files of/flattree: Update dtc to current mainline. of/device: Don't register disabled devices powerpc/dts: fix syntax bugs in bluestone.dts of: Fixes for OF probing on little endian systems of: make drivers depend on CONFIG_OF instead of CONFIG_PPC_OF of/flattree: Add of_flat_dt_match() helper function of_serial: explicitly include of_irq.h of/flattree: Refactor unflatten_device_tree and add fdt_unflatten_tree of/flattree: Reorder unflatten_dt_node of/flattree: Refactor unflatten_dt_node of/flattree: Add non-boottime device tree functions of/flattree: Add Kconfig for EARLY_FLATTREE ... Fix up trivial conflict in arch/sparc/prom/tree_32.c as per Grant.

Linus Torvalds committed 15 years ago

Commit 0bd2cbc2 parents 57cc721 a08174883 files · +2890 −3404Browse files

Showing the changes to scripts (19 of 83 files). Show all

Unified · Split

19 files
  1. scripts/Makefile.lib +23 −0
  2. scripts/dtc/Makefile +2 −1
  3. scripts/dtc/checks.c +94 −11
  4. scripts/dtc/dtc-lexer.l +23 −152
  5. scripts/dtc/dtc-lexer.lex.c_shipped +176 −375
  6. scripts/dtc/dtc-parser.tab.c_shipped +440 −452
  7. scripts/dtc/dtc-parser.tab.h_shipped +30 −52
  8. scripts/dtc/dtc-parser.y +63 −97
  9. scripts/dtc/dtc.c +31 −26
  10. scripts/dtc/dtc.h +38 −39
  11. scripts/dtc/flattree.c +109 −83
  12. scripts/dtc/fstree.c +5 −7
  13. scripts/dtc/livetree.c +323 −22
  14. scripts/dtc/srcpos.c +195 −63
  15. scripts/dtc/srcpos.h +50 −49
  16. scripts/dtc/treesource.c +26 −22
  17. scripts/dtc/util.c +59 −0
  18. scripts/dtc/util.h +56 −0
  19. scripts/dtc/version_gen.h +1 −1
scripts/Makefile.lib+23−0
@@ -200,6 +200,29 @@ quiet_cmd_gzip = GZIP $@ · 199 unmodified lines
200200 cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \
201201 (rm -f $@ ; false)
202202
203+# DTC
204+# ---------------------------------------------------------------------------
205+
206+# Generate an assembly file to wrap the output of the device tree compiler
207+quiet_cmd_dt_S_dtb= DTB $@
208+cmd_dt_S_dtb= \
209+( \
210+ echo '\#include <asm-generic/vmlinux.lds.h>'; \
211+ echo '.section .dtb.init.rodata,"a"'; \
212+ echo '.balign STRUCT_ALIGNMENT'; \
213+ echo '.global __dtb_$(*F)_begin'; \
214+ echo '__dtb_$(*F)_begin:'; \
215+ echo '.incbin "$<" '; \
216+ echo '__dtb_$(*F)_end:'; \
217+ echo '.global __dtb_$(*F)_end'; \
218+ echo '.balign STRUCT_ALIGNMENT'; \
219+) > $@
220+
221+$(obj)/%.dtb.S: $(obj)/%.dtb
222+ $(call cmd,dt_S_dtb)
223+
224+quiet_cmd_dtc = DTC $@
225+cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $<
203226
204227 # Bzip2
205228 # ---------------------------------------------------------------------------
scripts/dtc/Makefile+2−1
@@ -4,7 +4,7 @@ hostprogs-y := dtc · 3 unmodified lines
44 always := $(hostprogs-y)
55
66 dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
7− srcpos.o checks.o
7+ srcpos.o checks.o util.o
88 dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o
99
1010 # Source files need to get at the userspace version of libfdt_env.h to compile
@@ -19,6 +19,7 @@ HOSTCFLAGS_fstree.o := $(HOSTCFLAGS_DTC) · 8 unmodified lines
1919 HOSTCFLAGS_livetree.o := $(HOSTCFLAGS_DTC)
2020 HOSTCFLAGS_srcpos.o := $(HOSTCFLAGS_DTC)
2121 HOSTCFLAGS_treesource.o := $(HOSTCFLAGS_DTC)
22+HOSTCFLAGS_util.o := $(HOSTCFLAGS_DTC)
2223
2324 HOSTCFLAGS_dtc-lexer.lex.o := $(HOSTCFLAGS_DTC)
2425 HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC)
scripts/dtc/checks.c+94−11
@@ -278,32 +278,112 @@ static void check_property_name_chars(struct check *c, struct node *dt, · 277 unmodified lines
278278 }
279279 PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR);
280280
281+#define DESCLABEL_FMT "%s%s%s%s%s"
282+#define DESCLABEL_ARGS(node,prop,mark) \
283+ ((mark) ? "value of " : ""), \
284+ ((prop) ? "'" : ""), \
285+ ((prop) ? (prop)->name : ""), \
286+ ((prop) ? "' in " : ""), (node)->fullpath
287+
288+static void check_duplicate_label(struct check *c, struct node *dt,
289+ const char *label, struct node *node,
290+ struct property *prop, struct marker *mark)
291+{
292+ struct node *othernode = NULL;
293+ struct property *otherprop = NULL;
294+ struct marker *othermark = NULL;
295+
296+ othernode = get_node_by_label(dt, label);
297+
298+ if (!othernode)
299+ otherprop = get_property_by_label(dt, label, &othernode);
300+ if (!othernode)
301+ othermark = get_marker_label(dt, label, &othernode,
302+ &otherprop);
303+
304+ if (!othernode)
305+ return;
306+
307+ if ((othernode != node) || (otherprop != prop) || (othermark != mark))
308+ FAIL(c, "Duplicate label '%s' on " DESCLABEL_FMT
309+ " and " DESCLABEL_FMT,
310+ label, DESCLABEL_ARGS(node, prop, mark),
311+ DESCLABEL_ARGS(othernode, otherprop, othermark));
312+}
313+
314+static void check_duplicate_label_node(struct check *c, struct node *dt,
315+ struct node *node)
316+{
317+ struct label *l;
318+
319+ for_each_label(node->labels, l)
320+ check_duplicate_label(c, dt, l->label, node, NULL, NULL);
321+}
322+static void check_duplicate_label_prop(struct check *c, struct node *dt,
323+ struct node *node, struct property *prop)
324+{
325+ struct marker *m = prop->val.markers;
326+ struct label *l;
327+
328+ for_each_label(prop->labels, l)
329+ check_duplicate_label(c, dt, l->label, node, prop, NULL);
330+
331+ for_each_marker_of_type(m, LABEL)
332+ check_duplicate_label(c, dt, m->ref, node, prop, m);
333+}
334+CHECK(duplicate_label, NULL, check_duplicate_label_node,
335+ check_duplicate_label_prop, NULL, ERROR);
336+
281337 static void check_explicit_phandles(struct check *c, struct node *root,
282− struct node *node)
338+ struct node *node, struct property *prop)
283339 {
284− struct property *prop;
340+ struct marker *m;
285341 struct node *other;
286342 cell_t phandle;
287343
288− prop = get_property(node, "linux,phandle");
289− if (! prop)
290− return; /* No phandle, that's fine */
344+ if (!streq(prop->name, "phandle")
345+ && !streq(prop->name, "linux,phandle"))
346+ return;
291347
292348 if (prop->val.len != sizeof(cell_t)) {
293− FAIL(c, "%s has bad length (%d) linux,phandle property",
294− node->fullpath, prop->val.len);
349+ FAIL(c, "%s has bad length (%d) %s property",
350+ node->fullpath, prop->val.len, prop->name);
351+ return;
352+ }
353+
354+ m = prop->val.markers;
355+ for_each_marker_of_type(m, REF_PHANDLE) {
356+ assert(m->offset == 0);
357+ if (node != get_node_by_ref(root, m->ref))
358+ /* "Set this node's phandle equal to some
359+ * other node's phandle". That's nonsensical
360+ * by construction. */ {
361+ FAIL(c, "%s in %s is a reference to another node",
362+ prop->name, node->fullpath);
363+ return;
364+ }
365+ /* But setting this node's phandle equal to its own
366+ * phandle is allowed - that means allocate a unique
367+ * phandle for this node, even if it's not otherwise
368+ * referenced. The value will be filled in later, so
369+ * no further checking for now. */
295370 return;
296371 }
297372
298373 phandle = propval_cell(prop);
374+
299375 if ((phandle == 0) || (phandle == -1)) {
300− FAIL(c, "%s has invalid linux,phandle value 0x%x",
301− node->fullpath, phandle);
376+ FAIL(c, "%s has bad value (0x%x) in %s property",
377+ node->fullpath, phandle, prop->name);
302378 return;
303379 }
304380
381+ if (node->phandle && (node->phandle != phandle))
382+ FAIL(c, "%s has %s property which replaces existing phandle information",
383+ node->fullpath, prop->name);
384+
305385 other = get_node_by_phandle(root, phandle);
306− if (other) {
386+ if (other && (other != node)) {
307387 FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)",
308388 node->fullpath, phandle, other->fullpath);
309389 return;
@@ -311,7 +391,7 @@ static void check_explicit_phandles(struct check *c, struct node *root, · 1 unmodified line
311391
312392 node->phandle = phandle;
313393 }
314−NODE_CHECK(explicit_phandles, NULL, ERROR);
394+PROP_CHECK(explicit_phandles, NULL, ERROR);
315395
316396 static void check_name_properties(struct check *c, struct node *root,
317397 struct node *node)
@@ -549,6 +629,9 @@ static struct check *check_table[] = { · 231 unmodified lines
549629 &duplicate_node_names, &duplicate_property_names,
550630 &node_name_chars, &node_name_format, &property_name_chars,
551631 &name_is_string, &name_properties,
632+
633+ &duplicate_label,
634+
552635 &explicit_phandles,
553636 &phandle_references, &path_references,
554637
scripts/dtc/dtc-lexer.l+23−152
@@ -18,7 +18,7 @@ · 17 unmodified lines
1818 * USA
1919 */
2020
21−%option noyywrap noinput nounput yylineno
21+%option noyywrap nounput noinput never-interactive
2222
2323 %x INCLUDE
2424 %x BYTESTRING
@@ -38,6 +38,13 @@ LINECOMMENT "//".*\n · 13 unmodified lines
3838 #include "srcpos.h"
3939 #include "dtc-parser.tab.h"
4040
41+YYLTYPE yylloc;
42+
43+/* CAUTION: this will stop working if we ever use yyless() or yyunput() */
44+#define YY_USER_ACTION \
45+ { \
46+ srcpos_update(&yylloc, yytext, yyleng); \
47+ }
4148
4249 /*#define LEXDEBUG 1*/
4350
@@ -47,15 +54,10 @@ LINECOMMENT "//".*\n · 3 unmodified lines
4754 #define DPRINT(fmt, ...) do { } while (0)
4855 #endif
4956
50−static int dts_version; /* = 0 */
57+static int dts_version = 1;
5158
52−#define BEGIN_DEFAULT() if (dts_version == 0) { \
53− DPRINT("<INITIAL>\n"); \
54− BEGIN(INITIAL); \
55− } else { \
56− DPRINT("<V1>\n"); \
59+#define BEGIN_DEFAULT() DPRINT("<V1>\n"); \
5760 BEGIN(V1); \
58− }
5961
6062 static void push_input_file(const char *filename);
6163 static int pop_input_file(void);
@@ -75,18 +77,13 @@ static int pop_input_file(void); · 13 unmodified lines
7577 }
7678
7779 <*>{STRING} {
78− yylloc.file = srcpos_file;
79− yylloc.first_line = yylineno;
8080 DPRINT("String: %s\n", yytext);
8181 yylval.data = data_copy_escape_string(yytext+1,
8282 yyleng-2);
83− yylloc.first_line = yylineno;
8483 return DT_STRING;
8584 }
8685
8786 <*>"/dts-v1/" {
88− yylloc.file = srcpos_file;
89− yylloc.first_line = yylineno;
9087 DPRINT("Keyword: /dts-v1/\n");
9188 dts_version = 1;
9289 BEGIN_DEFAULT();
@@ -94,106 +91,57 @@ static int pop_input_file(void); · 1 unmodified line
9491 }
9592
9693 <*>"/memreserve/" {
97− yylloc.file = srcpos_file;
98− yylloc.first_line = yylineno;
9994 DPRINT("Keyword: /memreserve/\n");
10095 BEGIN_DEFAULT();
10196 return DT_MEMRESERVE;
10297 }
10398
10499 <*>{LABEL}: {
105− yylloc.file = srcpos_file;
106− yylloc.first_line = yylineno;
107100 DPRINT("Label: %s\n", yytext);
108− yylval.labelref = strdup(yytext);
101+ yylval.labelref = xstrdup(yytext);
109102 yylval.labelref[yyleng-1] = '\0';
110103 return DT_LABEL;
111104 }
112105
113−<INITIAL>[bodh]# {
114− yylloc.file = srcpos_file;
115− yylloc.first_line = yylineno;
116− if (*yytext == 'b')
117− yylval.cbase = 2;
118− else if (*yytext == 'o')
119− yylval.cbase = 8;
120− else if (*yytext == 'd')
121− yylval.cbase = 10;
122− else
123− yylval.cbase = 16;
124− DPRINT("Base: %d\n", yylval.cbase);
125− return DT_BASE;
126− }
127−
128−<INITIAL>[0-9a-fA-F]+ {
129− yylloc.file = srcpos_file;
130− yylloc.first_line = yylineno;
131− yylval.literal = strdup(yytext);
132− DPRINT("Literal: '%s'\n", yylval.literal);
133− return DT_LEGACYLITERAL;
134− }
135−
136106 <V1>[0-9]+|0[xX][0-9a-fA-F]+ {
137− yylloc.file = srcpos_file;
138− yylloc.first_line = yylineno;
139− yylval.literal = strdup(yytext);
107+ yylval.literal = xstrdup(yytext);
140108 DPRINT("Literal: '%s'\n", yylval.literal);
141109 return DT_LITERAL;
142110 }
143111
144−\&{LABEL} { /* label reference */
145− yylloc.file = srcpos_file;
146− yylloc.first_line = yylineno;
112+<*>\&{LABEL} { /* label reference */
147113 DPRINT("Ref: %s\n", yytext+1);
148− yylval.labelref = strdup(yytext+1);
114+ yylval.labelref = xstrdup(yytext+1);
149115 return DT_REF;
150116 }
151117
152−"&{/"{PATHCHAR}+\} { /* new-style path reference */
153− yylloc.file = srcpos_file;
154− yylloc.first_line = yylineno;
118+<*>"&{/"{PATHCHAR}+\} { /* new-style path reference */
155119 yytext[yyleng-1] = '\0';
156120 DPRINT("Ref: %s\n", yytext+2);
157− yylval.labelref = strdup(yytext+2);
158− return DT_REF;
159− }
160−
161−<INITIAL>"&/"{PATHCHAR}+ { /* old-style path reference */
162− yylloc.file = srcpos_file;
163− yylloc.first_line = yylineno;
164− DPRINT("Ref: %s\n", yytext+1);
165− yylval.labelref = strdup(yytext+1);
121+ yylval.labelref = xstrdup(yytext+2);
166122 return DT_REF;
167123 }
168124
169125 <BYTESTRING>[0-9a-fA-F]{2} {
170− yylloc.file = srcpos_file;
171− yylloc.first_line = yylineno;
172126 yylval.byte = strtol(yytext, NULL, 16);
173127 DPRINT("Byte: %02x\n", (int)yylval.byte);
174128 return DT_BYTE;
175129 }
176130
177131 <BYTESTRING>"]" {
178− yylloc.file = srcpos_file;
179− yylloc.first_line = yylineno;
180132 DPRINT("/BYTESTRING\n");
181133 BEGIN_DEFAULT();
182134 return ']';
183135 }
184136
185137 <PROPNODENAME>{PROPNODECHAR}+ {
186− yylloc.file = srcpos_file;
187− yylloc.first_line = yylineno;
188138 DPRINT("PropNodeName: %s\n", yytext);
189− yylval.propnodename = strdup(yytext);
139+ yylval.propnodename = xstrdup(yytext);
190140 BEGIN_DEFAULT();
191141 return DT_PROPNODENAME;
192142 }
193143
194144 "/incbin/" {
195− yylloc.file = srcpos_file;
196− yylloc.first_line = yylineno;
197145 DPRINT("Binary Include\n");
198146 return DT_INCBIN;
199147 }
@@ -203,8 +151,6 @@ static int pop_input_file(void); · 3 unmodified lines
203151 <*>{LINECOMMENT}+ /* eat C++-style comments */
204152
205153 <*>. {
206− yylloc.file = srcpos_file;
207− yylloc.first_line = yylineno;
208154 DPRINT("Char: %c (\\x%02x)\n", yytext[0],
209155 (unsigned)yytext[0]);
210156 if (yytext[0] == '[') {
@@ -221,100 +167,25 @@ static int pop_input_file(void); · 10 unmodified lines
221167
222168 %%
223169
224−
225−/*
226− * Stack of nested include file contexts.
227− */
228−
229−struct incl_file {
230− struct dtc_file *file;
231− YY_BUFFER_STATE yy_prev_buf;
232− int yy_prev_lineno;
233− struct incl_file *prev;
234−};
235−
236−static struct incl_file *incl_file_stack;
237−
238−
239−/*
240− * Detect infinite include recursion.
241− */
242−#define MAX_INCLUDE_DEPTH (100)
243−
244−static int incl_depth = 0;
245−
246−
247170 static void push_input_file(const char *filename)
248171 {
249− struct incl_file *incl_file;
250− struct dtc_file *newfile;
251− struct search_path search, *searchptr = NULL;
252−
253172 assert(filename);
254173
255− if (incl_depth++ >= MAX_INCLUDE_DEPTH)
256− die("Includes nested too deeply");
257−
258− if (srcpos_file) {
259− search.dir = srcpos_file->dir;
260− search.next = NULL;
261− search.prev = NULL;
262− searchptr = &search;
263− }
264−
265− newfile = dtc_open_file(filename, searchptr);
174+ srcfile_push(filename);
266175
267− incl_file = xmalloc(sizeof(struct incl_file));
176+ yyin = current_srcfile->f;
268177
269− /*
270− * Save current context.
271− */
272− incl_file->yy_prev_buf = YY_CURRENT_BUFFER;
273− incl_file->yy_prev_lineno = yylineno;
274− incl_file->file = srcpos_file;
275− incl_file->prev = incl_file_stack;
276−
277− incl_file_stack = incl_file;
278−
279− /*
280− * Establish new context.
281− */
282− srcpos_file = newfile;
283− yylineno = 1;
284− yyin = newfile->file;
285− yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
178+ yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE));
286179 }
287180
288181
289182 static int pop_input_file(void)
290183 {
291− struct incl_file *incl_file;
292−
293− if (incl_file_stack == 0)
184+ if (srcfile_pop() == 0)
294185 return 0;
295186
296− dtc_close_file(srcpos_file);
297−
298− /*
299− * Pop.
300− */
301− --incl_depth;
302− incl_file = incl_file_stack;
303− incl_file_stack = incl_file->prev;
304−
305− /*
306− * Recover old context.
307− */
308− yy_delete_buffer(YY_CURRENT_BUFFER);
309− yy_switch_to_buffer(incl_file->yy_prev_buf);
310− yylineno = incl_file->yy_prev_lineno;
311− srcpos_file = incl_file->file;
312− yyin = incl_file->file ? incl_file->file->file : NULL;
313−
314− /*
315− * Free old state.
316− */
317− free(incl_file);
187+ yypop_buffer_state();
188+ yyin = current_srcfile->f;
318189
319190 return 1;
320191 }
scripts/dtc/dtc-lexer.lex.c_shipped+176−375
@@ -170,20 +170,7 @@ extern FILE *yyin, *yyout; · 169 unmodified lines
170170 #define EOB_ACT_END_OF_FILE 1
171171 #define EOB_ACT_LAST_MATCH 2
172172
173− /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
174− * access to the local variable yy_act. Since yyless() is a macro, it would break
175− * existing scanners that call yyless() from OUTSIDE yylex.
176− * One obvious solution it to make yy_act a global. I tried that, and saw
177− * a 5% performance hit in a non-yylineno scanner, because yy_act is
178− * normally declared as a register variable-- so it is not worth it.
179− */
180− #define YY_LESS_LINENO(n) \
181− do { \
182− int yyl;\
183− for ( yyl = n; yyl < yyleng; ++yyl )\
184− if ( yytext[yyl] == '\n' )\
185− --yylineno;\
186− }while(0)
173+ #define YY_LESS_LINENO(n)
187174
188175 /* Return all but the first "n" matched characters back to the input stream. */
189176 #define yyless(n) \
@@ -385,8 +372,8 @@ static void yy_fatal_error (yyconst char msg[] ); · 195 unmodified lines
385372 *yy_cp = '\0'; \
386373 (yy_c_buf_p) = yy_cp;
387374
388−#define YY_NUM_RULES 20
389−#define YY_END_OF_BUFFER 21
375+#define YY_NUM_RULES 17
376+#define YY_END_OF_BUFFER 18
390377 /* This struct is not used in this scanner,
391378 but its presence is necessary. */
392379 struct yy_trans_info
@@ -394,20 +381,19 @@ struct yy_trans_info · 1 unmodified line
394381 flex_int32_t yy_verify;
395382 flex_int32_t yy_nxt;
396383 };
397−static yyconst flex_int16_t yy_accept[104] =
384+static yyconst flex_int16_t yy_accept[94] =
398385 { 0,
399386 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
400− 21, 19, 16, 16, 19, 19, 19, 7, 7, 19,
401− 7, 19, 19, 19, 19, 13, 14, 14, 19, 8,
402− 8, 16, 0, 2, 0, 0, 9, 0, 0, 0,
403− 0, 0, 0, 7, 7, 5, 0, 6, 0, 12,
404− 12, 14, 14, 8, 0, 11, 9, 0, 0, 0,
405− 0, 18, 0, 0, 0, 0, 8, 0, 17, 0,
406− 0, 0, 0, 0, 10, 0, 0, 0, 0, 0,
407− 0, 0, 0, 0, 0, 0, 0, 0, 3, 15,
387+ 18, 16, 13, 13, 16, 16, 16, 16, 16, 16,
388+ 16, 10, 11, 11, 6, 6, 13, 0, 2, 0,
389+ 7, 0, 0, 0, 0, 0, 0, 0, 5, 0,
390+ 9, 9, 11, 11, 6, 0, 7, 0, 0, 0,
391+ 0, 15, 0, 0, 0, 0, 6, 0, 14, 0,
392+ 0, 0, 0, 0, 8, 0, 0, 0, 0, 0,
393+ 0, 0, 0, 0, 0, 0, 0, 0, 3, 12,
408394 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
409−
410395 0, 4, 0
396+
411397 } ;
412398
413399 static yyconst flex_int32_t yy_ec[256] =
@@ -416,16 +402,16 @@ static yyconst flex_int32_t yy_ec[256] = · 2 unmodified lines
416402 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
417403 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
418404 1, 2, 1, 4, 5, 1, 1, 6, 1, 1,
419− 1, 7, 8, 8, 9, 8, 10, 11, 12, 13,
420− 13, 13, 13, 13, 13, 13, 13, 14, 1, 1,
421− 1, 1, 8, 8, 15, 15, 15, 15, 15, 15,
422− 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
423− 16, 16, 16, 16, 16, 16, 16, 17, 16, 16,
424− 1, 18, 19, 1, 16, 1, 15, 20, 21, 22,
425−
426− 23, 15, 16, 24, 25, 16, 16, 26, 27, 28,
427− 24, 16, 16, 29, 30, 31, 32, 33, 16, 17,
428− 16, 16, 34, 1, 35, 1, 1, 1, 1, 1,
405+ 1, 7, 5, 5, 8, 5, 9, 10, 11, 12,
406+ 12, 12, 12, 12, 12, 12, 12, 13, 1, 1,
407+ 1, 1, 5, 5, 14, 14, 14, 14, 14, 14,
408+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
409+ 15, 15, 15, 15, 15, 15, 15, 16, 15, 15,
410+ 1, 17, 18, 1, 15, 1, 14, 19, 20, 21,
411+
412+ 22, 14, 15, 15, 23, 15, 15, 24, 25, 26,
413+ 15, 15, 15, 27, 28, 29, 30, 31, 15, 16,
414+ 15, 15, 32, 1, 33, 1, 1, 1, 1, 1,
429415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
431417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -442,136 +428,114 @@ static yyconst flex_int32_t yy_ec[256] = · 10 unmodified lines
442428 1, 1, 1, 1, 1
443429 } ;
444430
445−static yyconst flex_int32_t yy_meta[36] =
431+static yyconst flex_int32_t yy_meta[34] =
446432 { 0,
447− 1, 1, 1, 1, 2, 1, 2, 2, 2, 3,
448− 4, 4, 4, 5, 6, 7, 7, 1, 1, 6,
449− 6, 6, 6, 7, 7, 7, 7, 7, 7, 7,
450− 7, 7, 7, 8, 1
433+ 1, 1, 1, 1, 2, 1, 2, 2, 3, 4,
434+ 4, 4, 5, 6, 7, 7, 1, 1, 6, 6,
435+ 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
436+ 7, 8, 1
451437 } ;
452438
453−static yyconst flex_int16_t yy_base[117] =
439+static yyconst flex_int16_t yy_base[106] =
454440 { 0,
455− 0, 0, 30, 0, 44, 0, 67, 0, 97, 105,
456− 302, 303, 35, 44, 40, 94, 112, 0, 129, 152,
457− 296, 295, 159, 0, 176, 303, 0, 116, 95, 165,
458− 49, 46, 102, 303, 296, 0, 0, 288, 290, 293,
459− 264, 266, 270, 0, 0, 303, 0, 303, 264, 303,
460− 0, 0, 195, 101, 0, 0, 0, 0, 284, 125,
461− 277, 265, 225, 230, 216, 218, 0, 202, 224, 221,
462− 217, 107, 196, 188, 303, 206, 179, 186, 178, 185,
463− 183, 162, 161, 150, 169, 160, 145, 125, 303, 303,
464− 137, 109, 190, 103, 203, 167, 108, 197, 303, 123,
465−
466− 29, 303, 303, 215, 221, 226, 229, 234, 240, 246,
467− 250, 257, 265, 270, 275, 282
441+ 0, 0, 237, 236, 25, 0, 47, 0, 30, 71,
442+ 244, 247, 82, 84, 84, 211, 95, 229, 218, 0,
443+ 111, 247, 0, 84, 83, 95, 106, 86, 247, 237,
444+ 0, 230, 231, 234, 207, 209, 212, 220, 247, 206,
445+ 247, 218, 0, 106, 116, 0, 0, 0, 223, 89,
446+ 226, 219, 199, 206, 200, 204, 0, 190, 213, 212,
447+ 202, 91, 178, 161, 247, 172, 144, 150, 140, 130,
448+ 140, 124, 128, 120, 138, 137, 123, 122, 247, 247,
449+ 134, 114, 132, 86, 135, 125, 90, 136, 247, 97,
450+ 29, 247, 247, 153, 156, 161, 165, 170, 176, 180,
451+
452+ 187, 195, 200, 205, 212
468453 } ;
469454
470−static yyconst flex_int16_t yy_def[117] =
455+static yyconst flex_int16_t yy_def[106] =
471456 { 0,
472− 103, 1, 1, 3, 3, 5, 103, 7, 3, 3,
473− 103, 103, 103, 103, 104, 105, 103, 106, 103, 19,
474− 19, 20, 103, 107, 20, 103, 108, 109, 105, 103,
475− 103, 103, 104, 103, 104, 110, 111, 103, 112, 113,
476− 103, 103, 103, 106, 19, 103, 20, 103, 103, 103,
477− 20, 108, 109, 103, 114, 110, 111, 115, 112, 112,
478− 113, 103, 103, 103, 103, 103, 114, 115, 103, 103,
479− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
480− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
481− 103, 103, 103, 103, 103, 116, 103, 116, 103, 116,
482−
483− 103, 103, 0, 103, 103, 103, 103, 103, 103, 103,
484− 103, 103, 103, 103, 103, 103
457+ 93, 1, 1, 1, 1, 5, 93, 7, 1, 1,
458+ 93, 93, 93, 93, 94, 95, 93, 96, 17, 97,
459+ 96, 93, 98, 99, 93, 93, 93, 94, 93, 94,
460+ 100, 93, 101, 102, 93, 93, 93, 96, 93, 93,
461+ 93, 96, 98, 99, 93, 103, 100, 104, 101, 101,
462+ 102, 93, 93, 93, 93, 93, 103, 104, 93, 93,
463+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
464+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
465+ 93, 93, 93, 93, 93, 105, 93, 105, 93, 105,
466+ 93, 93, 0, 93, 93, 93, 93, 93, 93, 93,
467+
468+ 93, 93, 93, 93, 93
485469 } ;
486470
487−static yyconst flex_int16_t yy_nxt[339] =
471+static yyconst flex_int16_t yy_nxt[281] =
488472 { 0,
489− 12, 13, 14, 15, 12, 16, 12, 12, 12, 17,
490− 18, 18, 18, 12, 19, 20, 20, 12, 12, 21,
491− 19, 21, 19, 22, 20, 20, 20, 20, 20, 20,
492− 20, 20, 20, 12, 12, 12, 32, 32, 102, 23,
493− 12, 12, 12, 34, 20, 32, 32, 32, 32, 20,
494− 20, 20, 20, 20, 24, 24, 24, 35, 25, 54,
495− 54, 54, 26, 25, 25, 25, 25, 12, 13, 14,
496− 15, 27, 12, 27, 27, 27, 23, 27, 27, 27,
497− 12, 28, 28, 28, 12, 12, 28, 28, 28, 28,
498− 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
499−
500− 12, 12, 29, 36, 103, 34, 17, 30, 31, 31,
501− 29, 54, 54, 54, 17, 30, 31, 31, 39, 35,
502− 52, 40, 52, 52, 52, 103, 78, 38, 38, 46,
503− 101, 60, 79, 41, 69, 97, 42, 94, 43, 45,
504− 45, 45, 46, 45, 47, 47, 93, 92, 45, 45,
505− 45, 45, 47, 47, 47, 47, 47, 47, 47, 47,
506− 47, 47, 47, 47, 47, 39, 47, 91, 40, 90,
507− 99, 47, 47, 47, 47, 54, 54, 54, 89, 88,
508− 41, 55, 87, 49, 100, 43, 51, 51, 51, 86,
509− 51, 95, 95, 96, 85, 51, 51, 51, 51, 52,
510−
511− 99, 52, 52, 52, 95, 95, 96, 84, 46, 83,
512− 82, 81, 39, 79, 100, 33, 33, 33, 33, 33,
513− 33, 33, 33, 37, 80, 77, 37, 37, 37, 44,
514− 40, 44, 50, 76, 50, 52, 75, 52, 74, 52,
515− 52, 53, 73, 53, 53, 53, 53, 56, 56, 56,
516− 72, 56, 56, 57, 71, 57, 57, 59, 59, 59,
517− 59, 59, 59, 59, 59, 61, 61, 61, 61, 61,
518− 61, 61, 61, 67, 70, 67, 68, 68, 68, 62,
519− 68, 68, 98, 98, 98, 98, 98, 98, 98, 98,
520− 60, 66, 65, 64, 63, 62, 60, 58, 103, 48,
521−
522− 48, 103, 11, 103, 103, 103, 103, 103, 103, 103,
523− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
524− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
525− 103, 103, 103, 103, 103, 103, 103, 103
473+ 12, 13, 14, 15, 12, 16, 12, 12, 17, 12,
474+ 12, 12, 12, 18, 18, 18, 12, 12, 18, 18,
475+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
476+ 18, 12, 12, 19, 20, 20, 20, 92, 21, 25,
477+ 26, 26, 22, 21, 21, 21, 21, 12, 13, 14,
478+ 15, 23, 16, 23, 23, 19, 23, 23, 23, 12,
479+ 24, 24, 24, 12, 12, 24, 24, 24, 24, 24,
480+ 24, 24, 24, 24, 24, 24, 24, 24, 12, 12,
481+ 25, 26, 26, 27, 27, 27, 27, 29, 43, 29,
482+ 43, 43, 45, 45, 45, 50, 39, 59, 46, 93,
483+
484+ 30, 33, 30, 34, 45, 45, 45, 27, 27, 68,
485+ 43, 91, 43, 43, 69, 35, 87, 36, 39, 37,
486+ 42, 42, 42, 39, 42, 45, 45, 45, 89, 42,
487+ 42, 42, 42, 85, 85, 86, 85, 85, 86, 89,
488+ 84, 90, 83, 82, 81, 80, 79, 78, 77, 76,
489+ 75, 74, 90, 28, 28, 28, 28, 28, 28, 28,
490+ 28, 31, 31, 31, 38, 38, 38, 38, 41, 73,
491+ 41, 43, 72, 43, 71, 43, 43, 44, 33, 44,
492+ 44, 44, 44, 47, 69, 47, 47, 49, 49, 49,
493+ 49, 49, 49, 49, 49, 51, 51, 51, 51, 51,
494+
495+ 51, 51, 51, 57, 70, 57, 58, 58, 58, 67,
496+ 58, 58, 88, 88, 88, 88, 88, 88, 88, 88,
497+ 34, 66, 65, 64, 63, 62, 61, 60, 52, 50,
498+ 39, 56, 39, 55, 54, 53, 52, 50, 48, 93,
499+ 40, 39, 32, 93, 19, 19, 11, 93, 93, 93,
500+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
501+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
502+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93
526503 } ;
527504
528−static yyconst flex_int16_t yy_chk[339] =
505+static yyconst flex_int16_t yy_chk[281] =
529506 { 0,
530507 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
531508 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
532509 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
533− 1, 1, 1, 1, 1, 3, 13, 13, 101, 3,
534− 3, 3, 3, 15, 3, 14, 14, 32, 32, 3,
535− 3, 3, 3, 3, 5, 5, 5, 15, 5, 31,
536− 31, 31, 5, 5, 5, 5, 5, 7, 7, 7,
510+ 1, 1, 1, 5, 5, 5, 5, 91, 5, 9,
511+ 9, 9, 5, 5, 5, 5, 5, 7, 7, 7,
537512 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
538513 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
539514 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
540−
541− 7, 7, 9, 16, 29, 33, 9, 9, 9, 9,
542− 10, 54, 54, 54, 10, 10, 10, 10, 17, 33,
543− 28, 17, 28, 28, 28, 100, 72, 16, 29, 28,
544− 97, 60, 72, 17, 60, 94, 17, 92, 17, 19,
545− 19, 19, 19, 19, 19, 19, 91, 88, 19, 19,
546− 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
547− 19, 19, 20, 20, 20, 23, 20, 87, 23, 86,
548− 96, 20, 20, 20, 20, 30, 30, 30, 85, 84,
549− 23, 30, 83, 23, 96, 23, 25, 25, 25, 82,
550− 25, 93, 93, 93, 81, 25, 25, 25, 25, 53,
551−
552− 98, 53, 53, 53, 95, 95, 95, 80, 53, 79,
553− 78, 77, 76, 74, 98, 104, 104, 104, 104, 104,
554− 104, 104, 104, 105, 73, 71, 105, 105, 105, 106,
555− 70, 106, 107, 69, 107, 108, 68, 108, 66, 108,
556− 108, 109, 65, 109, 109, 109, 109, 110, 110, 110,
557− 64, 110, 110, 111, 63, 111, 111, 112, 112, 112,
558− 112, 112, 112, 112, 112, 113, 113, 113, 113, 113,
559− 113, 113, 113, 114, 62, 114, 115, 115, 115, 61,
560− 115, 115, 116, 116, 116, 116, 116, 116, 116, 116,
561− 59, 49, 43, 42, 41, 40, 39, 38, 35, 22,
562−
563− 21, 11, 103, 103, 103, 103, 103, 103, 103, 103,
564− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
565− 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
566− 103, 103, 103, 103, 103, 103, 103, 103
515+ 10, 10, 10, 13, 13, 14, 14, 15, 24, 28,
516+ 24, 24, 25, 25, 25, 50, 24, 50, 25, 90,
517+
518+ 15, 17, 28, 17, 26, 26, 26, 27, 27, 62,
519+ 44, 87, 44, 44, 62, 17, 84, 17, 44, 17,
520+ 21, 21, 21, 21, 21, 45, 45, 45, 86, 21,
521+ 21, 21, 21, 83, 83, 83, 85, 85, 85, 88,
522+ 82, 86, 81, 78, 77, 76, 75, 74, 73, 72,
523+ 71, 70, 88, 94, 94, 94, 94, 94, 94, 94,
524+ 94, 95, 95, 95, 96, 96, 96, 96, 97, 69,
525+ 97, 98, 68, 98, 67, 98, 98, 99, 66, 99,
526+ 99, 99, 99, 100, 64, 100, 100, 101, 101, 101,
527+ 101, 101, 101, 101, 101, 102, 102, 102, 102, 102,
528+
529+ 102, 102, 102, 103, 63, 103, 104, 104, 104, 61,
530+ 104, 104, 105, 105, 105, 105, 105, 105, 105, 105,
531+ 60, 59, 58, 56, 55, 54, 53, 52, 51, 49,
532+ 42, 40, 38, 37, 36, 35, 34, 33, 32, 30,
533+ 19, 18, 16, 11, 4, 3, 93, 93, 93, 93,
534+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
535+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
536+ 93, 93, 93, 93, 93, 93, 93, 93, 93, 93
567537 } ;
568538
569−/* Table of booleans, true if rule could match eol. */
570−static yyconst flex_int32_t yy_rule_can_match_eol[21] =
571− { 0,
572−1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0,
573− 0, };
574−
575539 static yy_state_type yy_last_accepting_state;
576540 static char *yy_last_accepting_cpos;
577541
@@ -616,6 +580,13 @@ char *yytext; · 38 unmodified lines
616580 #include "srcpos.h"
617581 #include "dtc-parser.tab.h"
618582
583+YYLTYPE yylloc;
584+
585+/* CAUTION: this will stop working if we ever use yyless() or yyunput() */
586+#define YY_USER_ACTION \
587+ { \
588+ srcpos_update(&yylloc, yytext, yyleng); \
589+ }
619590
620591 /*#define LEXDEBUG 1*/
621592
@@ -625,19 +596,14 @@ char *yytext; · 3 unmodified lines
625596 #define DPRINT(fmt, ...) do { } while (0)
626597 #endif
627598
628−static int dts_version; /* = 0 */
599+static int dts_version = 1;
629600
630−#define BEGIN_DEFAULT() if (dts_version == 0) { \
631− DPRINT("<INITIAL>\n"); \
632− BEGIN(INITIAL); \
633− } else { \
634− DPRINT("<V1>\n"); \
601+#define BEGIN_DEFAULT() DPRINT("<V1>\n"); \
635602 BEGIN(V1); \
636− }
637603
638604 static void push_input_file(const char *filename);
639605 static int pop_input_file(void);
640−#line 641 "dtc-lexer.lex.c"
606+#line 607 "dtc-lexer.lex.c"
641607
642608 #define INITIAL 0
643609 #define INCLUDE 1
@@ -826,9 +792,9 @@ YY_DECL · 182 unmodified lines
826792 register char *yy_cp, *yy_bp;
827793 register int yy_act;
828794
829−#line 64 "dtc-lexer.l"
795+#line 66 "dtc-lexer.l"
830796
831−#line 832 "dtc-lexer.lex.c"
797+#line 798 "dtc-lexer.lex.c"
832798
833799 if ( !(yy_init) )
834800 {
@@ -881,35 +847,21 @@ yy_match: · 46 unmodified lines
881847 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
882848 {
883849 yy_current_state = (int) yy_def[yy_current_state];
884− if ( yy_current_state >= 104 )
850+ if ( yy_current_state >= 94 )
885851 yy_c = yy_meta[(unsigned int) yy_c];
886852 }
887853 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
888854 ++yy_cp;
889855 }
890− while ( yy_base[yy_current_state] != 303 );
856+ while ( yy_current_state != 93 );
857+ yy_cp = (yy_last_accepting_cpos);
858+ yy_current_state = (yy_last_accepting_state);
891859
892860 yy_find_action:
893861 yy_act = yy_accept[yy_current_state];
894− if ( yy_act == 0 )
895− { /* have to back up */
896− yy_cp = (yy_last_accepting_cpos);
897− yy_current_state = (yy_last_accepting_state);
898− yy_act = yy_accept[yy_current_state];
899− }
900862
901863 YY_DO_BEFORE_ACTION;
902864
903− if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
904− {
905− int yyl;
906− for ( yyl = 0; yyl < yyleng; ++yyl )
907− if ( yytext[yyl] == '\n' )
908−
909− yylineno++;
910−;
911− }
912−
913865 do_action: /* This label is used only to access EOF actions. */
914866
915867 switch ( yy_act )
@@ -924,7 +876,7 @@ do_action: /* This label is used only to access EOF actions. */ · 8 unmodified lines
924876 case 1:
925877 /* rule 1 can match eol */
926878 YY_RULE_SETUP
927−#line 65 "dtc-lexer.l"
879+#line 67 "dtc-lexer.l"
928880 {
929881 char *name = strchr(yytext, '\"') + 1;
930882 yytext[yyleng-1] = '\0';
@@ -936,7 +888,7 @@ case YY_STATE_EOF(INCLUDE): · 5 unmodified lines
936888 case YY_STATE_EOF(BYTESTRING):
937889 case YY_STATE_EOF(PROPNODENAME):
938890 case YY_STATE_EOF(V1):
939−#line 71 "dtc-lexer.l"
891+#line 73 "dtc-lexer.l"
940892 {
941893 if (!pop_input_file()) {
942894 yyterminate();
@@ -946,23 +898,18 @@ case YY_STATE_EOF(V1): · 3 unmodified lines
946898 case 2:
947899 /* rule 2 can match eol */
948900 YY_RULE_SETUP
949−#line 77 "dtc-lexer.l"
901+#line 79 "dtc-lexer.l"
950902 {
951− yylloc.file = srcpos_file;
952− yylloc.first_line = yylineno;
953903 DPRINT("String: %s\n", yytext);
954904 yylval.data = data_copy_escape_string(yytext+1,
955905 yyleng-2);
956− yylloc.first_line = yylineno;
957906 return DT_STRING;
958907 }
959908 YY_BREAK
960909 case 3:
961910 YY_RULE_SETUP
962−#line 87 "dtc-lexer.l"
911+#line 86 "dtc-lexer.l"
963912 {
964− yylloc.file = srcpos_file;
965− yylloc.first_line = yylineno;
966913 DPRINT("Keyword: /dts-v1/\n");
967914 dts_version = 1;
968915 BEGIN_DEFAULT();
@@ -971,10 +918,8 @@ YY_RULE_SETUP · 2 unmodified lines
971918 YY_BREAK
972919 case 4:
973920 YY_RULE_SETUP
974−#line 96 "dtc-lexer.l"
921+#line 93 "dtc-lexer.l"
975922 {
976− yylloc.file = srcpos_file;
977− yylloc.first_line = yylineno;
978923 DPRINT("Keyword: /memreserve/\n");
979924 BEGIN_DEFAULT();
980925 return DT_MEMRESERVE;
@@ -982,158 +927,100 @@ YY_RULE_SETUP · 1 unmodified line
982927 YY_BREAK
983928 case 5:
984929 YY_RULE_SETUP
985−#line 104 "dtc-lexer.l"
930+#line 99 "dtc-lexer.l"
986931 {
987− yylloc.file = srcpos_file;
988− yylloc.first_line = yylineno;
989932 DPRINT("Label: %s\n", yytext);
990− yylval.labelref = strdup(yytext);
933+ yylval.labelref = xstrdup(yytext);
991934 yylval.labelref[yyleng-1] = '\0';
992935 return DT_LABEL;
993936 }
994937 YY_BREAK
995938 case 6:
996939 YY_RULE_SETUP
997−#line 113 "dtc-lexer.l"
998−{
999− yylloc.file = srcpos_file;
1000− yylloc.first_line = yylineno;
1001− if (*yytext == 'b')
1002− yylval.cbase = 2;
1003− else if (*yytext == 'o')
1004− yylval.cbase = 8;
1005− else if (*yytext == 'd')
1006− yylval.cbase = 10;
1007− else
1008− yylval.cbase = 16;
1009− DPRINT("Base: %d\n", yylval.cbase);
1010− return DT_BASE;
1011− }
1012− YY_BREAK
1013−case 7:
1014−YY_RULE_SETUP
1015−#line 128 "dtc-lexer.l"
940+#line 106 "dtc-lexer.l"
1016941 {
1017− yylloc.file = srcpos_file;
1018− yylloc.first_line = yylineno;
1019− yylval.literal = strdup(yytext);
1020− DPRINT("Literal: '%s'\n", yylval.literal);
1021− return DT_LEGACYLITERAL;
1022− }
1023− YY_BREAK
1024−case 8:
1025−YY_RULE_SETUP
1026−#line 136 "dtc-lexer.l"
1027−{
1028− yylloc.file = srcpos_file;
1029− yylloc.first_line = yylineno;
1030− yylval.literal = strdup(yytext);
942+ yylval.literal = xstrdup(yytext);
1031943 DPRINT("Literal: '%s'\n", yylval.literal);
1032944 return DT_LITERAL;
1033945 }
1034946 YY_BREAK
1035−case 9:
947+case 7:
1036948 YY_RULE_SETUP
1037−#line 144 "dtc-lexer.l"
949+#line 112 "dtc-lexer.l"
1038950 { /* label reference */
1039− yylloc.file = srcpos_file;
1040− yylloc.first_line = yylineno;
1041951 DPRINT("Ref: %s\n", yytext+1);
1042− yylval.labelref = strdup(yytext+1);
952+ yylval.labelref = xstrdup(yytext+1);
1043953 return DT_REF;
1044954 }
1045955 YY_BREAK
1046−case 10:
956+case 8:
1047957 YY_RULE_SETUP
1048−#line 152 "dtc-lexer.l"
958+#line 118 "dtc-lexer.l"
1049959 { /* new-style path reference */
1050− yylloc.file = srcpos_file;
1051− yylloc.first_line = yylineno;
1052960 yytext[yyleng-1] = '\0';
1053961 DPRINT("Ref: %s\n", yytext+2);
1054− yylval.labelref = strdup(yytext+2);
962+ yylval.labelref = xstrdup(yytext+2);
1055963 return DT_REF;
1056964 }
1057965 YY_BREAK
1058−case 11:
1059−YY_RULE_SETUP
1060−#line 161 "dtc-lexer.l"
1061−{ /* old-style path reference */
1062− yylloc.file = srcpos_file;
1063− yylloc.first_line = yylineno;
1064− DPRINT("Ref: %s\n", yytext+1);
1065− yylval.labelref = strdup(yytext+1);
1066− return DT_REF;
1067− }
1068− YY_BREAK
1069−case 12:
966+case 9:
1070967 YY_RULE_SETUP
1071−#line 169 "dtc-lexer.l"
968+#line 125 "dtc-lexer.l"
1072969 {
1073− yylloc.file = srcpos_file;
1074− yylloc.first_line = yylineno;
1075970 yylval.byte = strtol(yytext, NULL, 16);
1076971 DPRINT("Byte: %02x\n", (int)yylval.byte);
1077972 return DT_BYTE;
1078973 }
1079974 YY_BREAK
1080−case 13:
975+case 10:
1081976 YY_RULE_SETUP
1082−#line 177 "dtc-lexer.l"
977+#line 131 "dtc-lexer.l"
1083978 {
1084− yylloc.file = srcpos_file;
1085− yylloc.first_line = yylineno;
1086979 DPRINT("/BYTESTRING\n");
1087980 BEGIN_DEFAULT();
1088981 return ']';
1089982 }
1090983 YY_BREAK
1091−case 14:
984+case 11:
1092985 YY_RULE_SETUP
1093−#line 185 "dtc-lexer.l"
986+#line 137 "dtc-lexer.l"
1094987 {
1095− yylloc.file = srcpos_file;
1096− yylloc.first_line = yylineno;
1097988 DPRINT("PropNodeName: %s\n", yytext);
1098− yylval.propnodename = strdup(yytext);
989+ yylval.propnodename = xstrdup(yytext);
1099990 BEGIN_DEFAULT();
1100991 return DT_PROPNODENAME;
1101992 }
1102993 YY_BREAK
1103−case 15:
994+case 12:
1104995 YY_RULE_SETUP
1105−#line 194 "dtc-lexer.l"
996+#line 144 "dtc-lexer.l"
1106997 {
1107− yylloc.file = srcpos_file;
1108− yylloc.first_line = yylineno;
1109998 DPRINT("Binary Include\n");
1110999 return DT_INCBIN;
11111000 }
11121001 YY_BREAK
1113−case 16:
1114−/* rule 16 can match eol */
1002+case 13:
1003+/* rule 13 can match eol */
11151004 YY_RULE_SETUP
1116−#line 201 "dtc-lexer.l"
1005+#line 149 "dtc-lexer.l"
11171006 /* eat whitespace */
11181007 YY_BREAK
1119−case 17:
1120−/* rule 17 can match eol */
1008+case 14:
1009+/* rule 14 can match eol */
11211010 YY_RULE_SETUP
1122−#line 202 "dtc-lexer.l"
1011+#line 150 "dtc-lexer.l"
11231012 /* eat C-style comments */
11241013 YY_BREAK
1125−case 18:
1126−/* rule 18 can match eol */
1014+case 15:
1015+/* rule 15 can match eol */
11271016 YY_RULE_SETUP
1128−#line 203 "dtc-lexer.l"
1017+#line 151 "dtc-lexer.l"
11291018 /* eat C++-style comments */
11301019 YY_BREAK
1131−case 19:
1020+case 16:
11321021 YY_RULE_SETUP
1133−#line 205 "dtc-lexer.l"
1022+#line 153 "dtc-lexer.l"
11341023 {
1135− yylloc.file = srcpos_file;
1136− yylloc.first_line = yylineno;
11371024 DPRINT("Char: %c (\\x%02x)\n", yytext[0],
11381025 (unsigned)yytext[0]);
11391026 if (yytext[0] == '[') {
@@ -1148,12 +1035,12 @@ YY_RULE_SETUP · 8 unmodified lines
11481035 return yytext[0];
11491036 }
11501037 YY_BREAK
1151−case 20:
1038+case 17:
11521039 YY_RULE_SETUP
1153−#line 222 "dtc-lexer.l"
1040+#line 168 "dtc-lexer.l"
11541041 ECHO;
11551042 YY_BREAK
1156−#line 1157 "dtc-lexer.lex.c"
1043+#line 1044 "dtc-lexer.lex.c"
11571044
11581045 case YY_END_OF_BUFFER:
11591046 {
@@ -1218,7 +1105,8 @@ ECHO; · 58 unmodified lines
12181105
12191106 else
12201107 {
1221− yy_cp = (yy_c_buf_p);
1108+ yy_cp = (yy_last_accepting_cpos);
1109+ yy_current_state = (yy_last_accepting_state);
12221110 goto yy_find_action;
12231111 }
12241112 }
@@ -1443,7 +1331,7 @@ static int yy_get_next_buffer (void) · 218 unmodified lines
14431331 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
14441332 {
14451333 yy_current_state = (int) yy_def[yy_current_state];
1446− if ( yy_current_state >= 104 )
1334+ if ( yy_current_state >= 94 )
14471335 yy_c = yy_meta[(unsigned int) yy_c];
14481336 }
14491337 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1471,11 +1359,11 @@ static int yy_get_next_buffer (void) · 21 unmodified lines
14711359 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
14721360 {
14731361 yy_current_state = (int) yy_def[yy_current_state];
1474− if ( yy_current_state >= 104 )
1362+ if ( yy_current_state >= 94 )
14751363 yy_c = yy_meta[(unsigned int) yy_c];
14761364 }
14771365 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1478− yy_is_jam = (yy_current_state == 103);
1366+ yy_is_jam = (yy_current_state == 93);
14791367
14801368 return yy_is_jam ? 0 : yy_current_state;
14811369 }
@@ -1550,11 +1438,6 @@ static int yy_get_next_buffer (void) · 68 unmodified lines
15501438 *(yy_c_buf_p) = '\0'; /* preserve yytext */
15511439 (yy_hold_char) = *++(yy_c_buf_p);
15521440
1553− if ( c == '\n' )
1554−
1555− yylineno++;
1556−;
1557−
15581441 return c;
15591442 }
15601443 #endif /* ifndef YY_NO_INPUT */
@@ -1669,10 +1552,6 @@ static void yy_load_buffer_state (void) · 108 unmodified lines
16691552 yyfree((void *) b );
16701553 }
16711554
1672−#ifndef __cplusplus
1673−extern int isatty (int );
1674−#endif /* __cplusplus */
1675−
16761555 /* Initializes or reinitializes a buffer.
16771556 * This function is sometimes called more than once on the same buffer,
16781557 * such as during a yyrestart() or at EOF.
@@ -1696,7 +1575,7 @@ extern int isatty (int ); · 17 unmodified lines
16961575 b->yy_bs_column = 0;
16971576 }
16981577
1699− b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1578+ b->yy_is_interactive = 0;
17001579
17011580 errno = oerrno;
17021581 }
@@ -2025,9 +1904,6 @@ static int yy_init_globals (void) · 322 unmodified lines
20251904 * This function is called from yylex_destroy(), so don't allocate here.
20261905 */
20271906
2028− /* We do not touch yylineno unless the option is enabled. */
2029− yylineno = 1;
2030−
20311907 (yy_buffer_stack) = 0;
20321908 (yy_buffer_stack_top) = 0;
20331909 (yy_buffer_stack_max) = 0;
@@ -2120,104 +1996,29 @@ void yyfree (void * ptr ) · 86 unmodified lines
21201996
21211997 #define YYTABLES_NAME "yytables"
21221998
2123−#line 222 "dtc-lexer.l"
2124−
2125−
2126−
2127−
2128−/*
2129− * Stack of nested include file contexts.
2130− */
2131−
2132−struct incl_file {
2133− struct dtc_file *file;
2134− YY_BUFFER_STATE yy_prev_buf;
2135− int yy_prev_lineno;
2136− struct incl_file *prev;
2137−};
2138−
2139−static struct incl_file *incl_file_stack;
1999+#line 168 "dtc-lexer.l"
21402000
21412001
2142−/*
2143− * Detect infinite include recursion.
2144− */
2145−#define MAX_INCLUDE_DEPTH (100)
2146−
2147−static int incl_depth = 0;
2148−
21492002
21502003 static void push_input_file(const char *filename)
21512004 {
2152− struct incl_file *incl_file;
2153− struct dtc_file *newfile;
2154− struct search_path search, *searchptr = NULL;
2155−
21562005 assert(filename);
21572006
2158− if (incl_depth++ >= MAX_INCLUDE_DEPTH)
2159− die("Includes nested too deeply");
2160−
2161− if (srcpos_file) {
2162− search.dir = srcpos_file->dir;
2163− search.next = NULL;
2164− search.prev = NULL;
2165− searchptr = &search;
2166− }
2167−
2168− newfile = dtc_open_file(filename, searchptr);
2007+ srcfile_push(filename);
21692008
2170− incl_file = xmalloc(sizeof(struct incl_file));
2009+ yyin = current_srcfile->f;
21712010
2172− /*
2173− * Save current context.
2174− */
2175− incl_file->yy_prev_buf = YY_CURRENT_BUFFER;
2176− incl_file->yy_prev_lineno = yylineno;
2177− incl_file->file = srcpos_file;
2178− incl_file->prev = incl_file_stack;
2179−
2180− incl_file_stack = incl_file;
2181−
2182− /*
2183− * Establish new context.
2184− */
2185− srcpos_file = newfile;
2186− yylineno = 1;
2187− yyin = newfile->file;
2188− yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
2011+ yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE));
21892012 }
21902013
21912014
21922015 static int pop_input_file(void)
21932016 {
2194− struct incl_file *incl_file;
2195−
2196− if (incl_file_stack == 0)
2017+ if (srcfile_pop() == 0)
21972018 return 0;
21982019
2199− dtc_close_file(srcpos_file);
2200−
2201− /*
2202− * Pop.
2203− */
2204− --incl_depth;
2205− incl_file = incl_file_stack;
2206− incl_file_stack = incl_file->prev;
2207−
2208− /*
2209− * Recover old context.
2210− */
2211− yy_delete_buffer(YY_CURRENT_BUFFER);
2212− yy_switch_to_buffer(incl_file->yy_prev_buf);
2213− yylineno = incl_file->yy_prev_lineno;
2214− srcpos_file = incl_file->file;
2215− yyin = incl_file->file ? incl_file->file->file : NULL;
2216−
2217− /*
2218− * Free old state.
2219− */
2220− free(incl_file);
2020+ yypop_buffer_state();
2021+ yyin = current_srcfile->f;
22212022
22222023 return 1;
22232024 }
scripts/dtc/dtc-parser.tab.c_shipped+440−452
@@ -1,24 +1,23 @@
1−/* A Bison parser, made by GNU Bison 2.3. */
21
3−/* Skeleton implementation for Bison's Yacc-like parsers in C
2+/* A Bison parser, made by GNU Bison 2.4.1. */
43
5− Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
4+/* Skeleton implementation for Bison's Yacc-like parsers in C
5+
6+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
67 Free Software Foundation, Inc.
7−
8− This program is free software; you can redistribute it and/or modify
8+
9+ This program is free software: you can redistribute it and/or modify
910 it under the terms of the GNU General Public License as published by
10− the Free Software Foundation; either version 2, or (at your option)
11− any later version.
12−
11+ the Free Software Foundation, either version 3 of the License, or
12+ (at your option) any later version.
13+
1314 This program is distributed in the hope that it will be useful,
1415 but WITHOUT ANY WARRANTY; without even the implied warranty of
1516 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1617 GNU General Public License for more details.
17−
18+
1819 You should have received a copy of the GNU General Public License
19− along with this program; if not, write to the Free Software
20− Foundation, Inc., 51 Franklin Street, Fifth Floor,
21− Boston, MA 02110-1301, USA. */
20+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2221
2322 /* As a special exception, you may create a larger work that contains
2423 part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +28,7 @@ · 4 unmodified lines
2928 special exception, which will cause the skeleton and the resulting
3029 Bison output files to be licensed under the GNU General Public
3130 License without this special exception.
32−
31+
3332 This special exception was added by the Free Software Foundation in
3433 version 2.2 of Bison. */
3534
@@ -47,7 +46,7 @@ · 11 unmodified lines
4746 #define YYBISON 1
4847
4948 /* Bison version. */
50−#define YYBISON_VERSION "2.3"
49+#define YYBISON_VERSION "2.4.1"
5150
5251 /* Skeleton name. */
5352 #define YYSKELETON_NAME "yacc.c"
@@ -55,55 +54,32 @@ · 1 unmodified line
5554 /* Pure parsers. */
5655 #define YYPURE 0
5756
58−/* Using locations. */
59−#define YYLSP_NEEDED 1
60−
57+/* Push parsers. */
58+#define YYPUSH 0
6159
60+/* Pull parsers. */
61+#define YYPULL 1
6262
63−/* Tokens. */
64−#ifndef YYTOKENTYPE
65−# define YYTOKENTYPE
66− /* Put the tokens into the symbol table, so that GDB and other debuggers
67− know about them. */
68− enum yytokentype {
69− DT_V1 = 258,
70− DT_MEMRESERVE = 259,
71− DT_PROPNODENAME = 260,
72− DT_LITERAL = 261,
73− DT_LEGACYLITERAL = 262,
74− DT_BASE = 263,
75− DT_BYTE = 264,
76− DT_STRING = 265,
77− DT_LABEL = 266,
78− DT_REF = 267,
79− DT_INCBIN = 268
80− };
81−#endif
82−/* Tokens. */
83−#define DT_V1 258
84−#define DT_MEMRESERVE 259
85−#define DT_PROPNODENAME 260
86−#define DT_LITERAL 261
87−#define DT_LEGACYLITERAL 262
88−#define DT_BASE 263
89−#define DT_BYTE 264
90−#define DT_STRING 265
91−#define DT_LABEL 266
92−#define DT_REF 267
93−#define DT_INCBIN 268
94−
63+/* Using locations. */
64+#define YYLSP_NEEDED 0
9565
9666
9767
9868 /* Copy the first part of user declarations. */
99−#line 23 "dtc-parser.y"
69+
70+/* Line 189 of yacc.c */
71+#line 21 "dtc-parser.y"
10072
10173 #include <stdio.h>
10274
10375 #include "dtc.h"
10476 #include "srcpos.h"
10577
78+YYLTYPE yylloc;
79+
10680 extern int yylex(void);
81+extern void print_error(char const *fmt, ...);
82+extern void yyerror(char const *s);
10783
10884 extern struct boot_info *the_boot_info;
10985 extern int treesource_error;
@@ -111,6 +87,9 @@ extern int treesource_error; · 1 unmodified line
11187 static unsigned long long eval_literal(const char *s, int base, int bits);
11288
11389
90+/* Line 189 of yacc.c */
91+#line 92 "dtc-parser.tab.c"
92+
11493 /* Enabling traces. */
11594 #ifndef YYDEBUG
11695 # define YYDEBUG 0
@@ -129,10 +108,35 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 12 unmodified lines
129108 # define YYTOKEN_TABLE 0
130109 #endif
131110
111+
112+/* Tokens. */
113+#ifndef YYTOKENTYPE
114+# define YYTOKENTYPE
115+ /* Put the tokens into the symbol table, so that GDB and other debuggers
116+ know about them. */
117+ enum yytokentype {
118+ DT_V1 = 258,
119+ DT_MEMRESERVE = 259,
120+ DT_PROPNODENAME = 260,
121+ DT_LITERAL = 261,
122+ DT_BASE = 262,
123+ DT_BYTE = 263,
124+ DT_STRING = 264,
125+ DT_LABEL = 265,
126+ DT_REF = 266,
127+ DT_INCBIN = 267
128+ };
129+#endif
130+
131+
132+
132133 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
133134 typedef union YYSTYPE
134−#line 37 "dtc-parser.y"
135135 {
136+
137+/* Line 214 of yacc.c */
138+#line 39 "dtc-parser.y"
139+
136140 char *propnodename;
137141 char *literal;
138142 char *labelref;
@@ -147,34 +151,23 @@ typedef union YYSTYPE · 8 unmodified lines
147151 struct node *node;
148152 struct node *nodelist;
149153 struct reserve_info *re;
150−}
151−/* Line 187 of yacc.c. */
152−#line 153 "dtc-parser.tab.c"
153− YYSTYPE;
154+
155+
156+
157+/* Line 214 of yacc.c */
158+#line 159 "dtc-parser.tab.c"
159+} YYSTYPE;
160+# define YYSTYPE_IS_TRIVIAL 1
154161 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
155162 # define YYSTYPE_IS_DECLARED 1
156−# define YYSTYPE_IS_TRIVIAL 1
157−#endif
158−
159−#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
160−typedef struct YYLTYPE
161−{
162− int first_line;
163− int first_column;
164− int last_line;
165− int last_column;
166−} YYLTYPE;
167−# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
168−# define YYLTYPE_IS_DECLARED 1
169−# define YYLTYPE_IS_TRIVIAL 1
170163 #endif
171164
172165
173166 /* Copy the second part of user declarations. */
174167
175168
176−/* Line 216 of yacc.c. */
177−#line 178 "dtc-parser.tab.c"
169+/* Line 264 of yacc.c */
170+#line 171 "dtc-parser.tab.c"
178171
179172 #ifdef short
180173 # undef short
@@ -249,14 +242,14 @@ typedef short int yytype_int16; · 68 unmodified lines
249242 #if (defined __STDC__ || defined __C99__FUNC__ \
250243 || defined __cplusplus || defined _MSC_VER)
251244 static int
252−YYID (int i)
245+YYID (int yyi)
253246 #else
254247 static int
255−YYID (i)
256− int i;
248+YYID (yyi)
249+ int yyi;
257250 #endif
258251 {
259− return i;
252+ return yyi;
260253 }
261254 #endif
262255
@@ -332,15 +325,13 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ · 69 unmodified lines
332325
333326 #if (! defined yyoverflow \
334327 && (! defined __cplusplus \
335− || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
336− && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
328+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
337329
338330 /* A type that is properly aligned for any stack member. */
339331 union yyalloc
340332 {
341− yytype_int16 yyss;
342− YYSTYPE yyvs;
343− YYLTYPE yyls;
333+ yytype_int16 yyss_alloc;
334+ YYSTYPE yyvs_alloc;
344335 };
345336
346337 /* The size of the maximum gap between one aligned stack and the next. */
@@ -349,8 +340,8 @@ union yyalloc · 2 unmodified lines
349340 /* The size of an array large to enough to hold all stacks, each with
350341 N elements. */
351342 # define YYSTACK_BYTES(N) \
352− ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
353− + 2 * YYSTACK_GAP_MAXIMUM)
343+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
344+ + YYSTACK_GAP_MAXIMUM)
354345
355346 /* Copy COUNT objects from FROM to TO. The source and destination do
356347 not overlap. */
@@ -375,12 +366,12 @@ union yyalloc · 18 unmodified lines
375366 elements in the stack, and YYPTR gives the new location of the
376367 stack. Advance YYPTR to a properly aligned location for the next
377368 stack. */
378−# define YYSTACK_RELOCATE(Stack) \
369+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
379370 do \
380371 { \
381372 YYSIZE_T yynewbytes; \
382− YYCOPY (&yyptr->Stack, Stack, yysize); \
383− Stack = &yyptr->Stack; \
373+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
374+ Stack = &yyptr->Stack_alloc; \
384375 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
385376 yyptr += yynewbytes / sizeof (*yyptr); \
386377 } \
@@ -389,22 +380,22 @@ union yyalloc · 2 unmodified lines
389380 #endif
390381
391382 /* YYFINAL -- State number of the termination state. */
392−#define YYFINAL 9
383+#define YYFINAL 4
393384 /* YYLAST -- Last index in YYTABLE. */
394−#define YYLAST 73
385+#define YYLAST 56
395386
396387 /* YYNTOKENS -- Number of terminals. */
397−#define YYNTOKENS 27
388+#define YYNTOKENS 25
398389 /* YYNNTS -- Number of nonterminals. */
399−#define YYNNTS 20
390+#define YYNNTS 16
400391 /* YYNRULES -- Number of rules. */
401−#define YYNRULES 45
392+#define YYNRULES 39
402393 /* YYNRULES -- Number of states. */
403−#define YYNSTATES 76
394+#define YYNSTATES 67
404395
405396 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
406397 #define YYUNDEFTOK 2
407−#define YYMAXUTOK 268
398+#define YYMAXUTOK 267
408399
409400 #define YYTRANSLATE(YYX) \
410401 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -416,15 +407,15 @@ static const yytype_uint8 yytranslate[] = · 5 unmodified lines
416407 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417408 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418409 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419− 24, 26, 2, 2, 25, 15, 2, 16, 2, 2,
420− 2, 2, 2, 2, 2, 2, 2, 2, 2, 14,
421− 20, 19, 21, 2, 2, 2, 2, 2, 2, 2,
410+ 22, 24, 2, 2, 23, 2, 2, 14, 2, 2,
411+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 13,
412+ 18, 17, 19, 2, 2, 2, 2, 2, 2, 2,
422413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424− 2, 22, 2, 23, 2, 2, 2, 2, 2, 2,
415+ 2, 20, 2, 21, 2, 2, 2, 2, 2, 2,
425416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427− 2, 2, 2, 17, 2, 18, 2, 2, 2, 2,
418+ 2, 2, 2, 15, 2, 16, 2, 2, 2, 2,
428419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -438,7 +429,7 @@ static const yytype_uint8 yytranslate[] = · 7 unmodified lines
438429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440431 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
441− 5, 6, 7, 8, 9, 10, 11, 12, 13
432+ 5, 6, 7, 8, 9, 10, 11, 12
442433 };
443434
444435 #if YYDEBUG
@@ -446,41 +437,37 @@ static const yytype_uint8 yytranslate[] = · 1 unmodified line
446437 YYRHS. */
447438 static const yytype_uint8 yyprhs[] =
448439 {
449− 0, 0, 3, 8, 11, 12, 15, 21, 22, 25,
450− 27, 34, 36, 38, 41, 47, 48, 51, 57, 61,
451− 64, 69, 74, 77, 87, 93, 96, 97, 100, 103,
452− 104, 107, 110, 113, 114, 116, 118, 121, 122, 125,
453− 128, 129, 132, 135, 139, 140
440+ 0, 0, 3, 8, 9, 12, 17, 20, 22, 25,
441+ 29, 33, 39, 40, 43, 48, 51, 54, 57, 62,
442+ 67, 70, 80, 86, 89, 90, 93, 96, 97, 100,
443+ 103, 106, 108, 109, 112, 115, 116, 119, 122, 125
454444 };
455445
456446 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
457447 static const yytype_int8 yyrhs[] =
458448 {
459− 28, 0, -1, 3, 14, 29, 34, -1, 31, 34,
460− -1, -1, 30, 29, -1, 46, 4, 33, 33, 14,
461− -1, -1, 32, 31, -1, 30, -1, 46, 4, 33,
462− 15, 33, 14, -1, 6, -1, 7, -1, 16, 35,
463− -1, 17, 36, 44, 18, 14, -1, -1, 36, 37,
464− -1, 46, 5, 19, 38, 14, -1, 46, 5, 14,
465− -1, 39, 10, -1, 39, 20, 40, 21, -1, 39,
466− 22, 43, 23, -1, 39, 12, -1, 39, 13, 24,
467− 10, 25, 33, 25, 33, 26, -1, 39, 13, 24,
468− 10, 26, -1, 38, 11, -1, -1, 38, 25, -1,
469− 39, 11, -1, -1, 40, 42, -1, 40, 12, -1,
470− 40, 11, -1, -1, 8, -1, 6, -1, 41, 7,
471− -1, -1, 43, 9, -1, 43, 11, -1, -1, 45,
472− 44, -1, 45, 37, -1, 46, 5, 35, -1, -1,
473− 11, -1
449+ 26, 0, -1, 3, 13, 27, 30, -1, -1, 28,
450+ 27, -1, 4, 29, 29, 13, -1, 10, 28, -1,
451+ 6, -1, 14, 31, -1, 30, 14, 31, -1, 30,
452+ 11, 31, -1, 15, 32, 39, 16, 13, -1, -1,
453+ 32, 33, -1, 5, 17, 34, 13, -1, 5, 13,
454+ -1, 10, 33, -1, 35, 9, -1, 35, 18, 36,
455+ 19, -1, 35, 20, 38, 21, -1, 35, 11, -1,
456+ 35, 12, 22, 9, 23, 29, 23, 29, 24, -1,
457+ 35, 12, 22, 9, 24, -1, 34, 10, -1, -1,
458+ 34, 23, -1, 35, 10, -1, -1, 36, 37, -1,
459+ 36, 11, -1, 36, 10, -1, 6, -1, -1, 38,
460+ 8, -1, 38, 10, -1, -1, 40, 39, -1, 40,
461+ 33, -1, 5, 31, -1, 10, 40, -1
474462 };
475463
476464 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
477465 static const yytype_uint16 yyrline[] =
478466 {
479− 0, 89, 89, 93, 101, 104, 111, 119, 122, 129,
480− 133, 140, 144, 151, 158, 166, 169, 176, 180, 187,
481− 191, 195, 199, 203, 220, 231, 239, 242, 246, 254,
482− 257, 261, 266, 274, 277, 281, 285, 293, 296, 300,
483− 308, 311, 315, 323, 331, 334
467+ 0, 86, 86, 95, 98, 105, 109, 117, 124, 128,
468+ 132, 145, 153, 156, 163, 167, 171, 179, 183, 187,
469+ 191, 195, 212, 222, 230, 233, 237, 245, 248, 252,
470+ 257, 264, 272, 275, 279, 287, 290, 294, 302, 306
484471 };
485472 #endif
486473
@@ -490,13 +477,12 @@ static const yytype_uint16 yyrline[] = · 3 unmodified lines
490477 static const char *const yytname[] =
491478 {
492479 "$end", "error", "$undefined", "DT_V1", "DT_MEMRESERVE",
493− "DT_PROPNODENAME", "DT_LITERAL", "DT_LEGACYLITERAL", "DT_BASE",
494− "DT_BYTE", "DT_STRING", "DT_LABEL", "DT_REF", "DT_INCBIN", "';'", "'-'",
495− "'/'", "'{'", "'}'", "'='", "'<'", "'>'", "'['", "']'", "'('", "','",
496− "')'", "$accept", "sourcefile", "memreserves", "memreserve",
497− "v0_memreserves", "v0_memreserve", "addr", "devicetree", "nodedef",
498− "proplist", "propdef", "propdata", "propdataprefix", "celllist",
499− "cellbase", "cellval", "bytestring", "subnodes", "subnode", "label", 0
480+ "DT_PROPNODENAME", "DT_LITERAL", "DT_BASE", "DT_BYTE", "DT_STRING",
481+ "DT_LABEL", "DT_REF", "DT_INCBIN", "';'", "'/'", "'{'", "'}'", "'='",
482+ "'<'", "'>'", "'['", "']'", "'('", "','", "')'", "$accept", "sourcefile",
483+ "memreserves", "memreserve", "addr", "devicetree", "nodedef", "proplist",
484+ "propdef", "propdata", "propdataprefix", "celllist", "cellval",
485+ "bytestring", "subnodes", "subnode", 0
500486 };
501487 #endif
502488
@@ -506,29 +492,27 @@ static const char *const yytname[] = · 3 unmodified lines
506492 static const yytype_uint16 yytoknum[] =
507493 {
508494 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
509− 265, 266, 267, 268, 59, 45, 47, 123, 125, 61,
510− 60, 62, 91, 93, 40, 44, 41
495+ 265, 266, 267, 59, 47, 123, 125, 61, 60, 62,
496+ 91, 93, 40, 44, 41
511497 };
512498 # endif
513499
514500 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
515501 static const yytype_uint8 yyr1[] =
516502 {
517− 0, 27, 28, 28, 29, 29, 30, 31, 31, 32,
518− 32, 33, 33, 34, 35, 36, 36, 37, 37, 38,
519− 38, 38, 38, 38, 38, 38, 39, 39, 39, 40,
520− 40, 40, 40, 41, 41, 42, 42, 43, 43, 43,
521− 44, 44, 44, 45, 46, 46
503+ 0, 25, 26, 27, 27, 28, 28, 29, 30, 30,
504+ 30, 31, 32, 32, 33, 33, 33, 34, 34, 34,
505+ 34, 34, 34, 34, 35, 35, 35, 36, 36, 36,
506+ 36, 37, 38, 38, 38, 39, 39, 39, 40, 40
522507 };
523508
524509 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
525510 static const yytype_uint8 yyr2[] =
526511 {
527− 0, 2, 4, 2, 0, 2, 5, 0, 2, 1,
528− 6, 1, 1, 2, 5, 0, 2, 5, 3, 2,
529− 4, 4, 2, 9, 5, 2, 0, 2, 2, 0,
530− 2, 2, 2, 0, 1, 1, 2, 0, 2, 2,
531− 0, 2, 2, 3, 0, 1
512+ 0, 2, 4, 0, 2, 4, 2, 1, 2, 3,
513+ 3, 5, 0, 2, 4, 2, 2, 2, 4, 4,
514+ 2, 9, 5, 2, 0, 2, 2, 0, 2, 2,
515+ 2, 1, 0, 2, 2, 0, 2, 2, 2, 2
532516 };
533517
534518 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -536,86 +520,79 @@ static const yytype_uint8 yyr2[] = · 1 unmodified line
536520 means the default is an error. */
537521 static const yytype_uint8 yydefact[] =
538522 {
539− 7, 0, 45, 0, 9, 0, 7, 0, 4, 1,
540− 0, 3, 8, 0, 0, 4, 0, 15, 13, 11,
541− 12, 0, 2, 5, 0, 40, 0, 0, 0, 16,
542− 0, 40, 0, 0, 6, 0, 42, 41, 0, 10,
543− 14, 18, 26, 43, 0, 0, 25, 17, 27, 19,
544− 28, 22, 0, 29, 37, 0, 33, 0, 0, 35,
545− 34, 32, 31, 20, 0, 30, 38, 39, 21, 0,
546− 24, 36, 0, 0, 0, 23
523+ 0, 0, 0, 3, 1, 0, 0, 0, 3, 7,
524+ 0, 6, 0, 2, 4, 0, 12, 8, 0, 0,
525+ 5, 35, 10, 9, 0, 0, 13, 0, 35, 15,
526+ 24, 38, 16, 39, 0, 37, 36, 0, 0, 11,
527+ 23, 14, 25, 17, 26, 20, 0, 27, 32, 0,
528+ 0, 0, 0, 31, 30, 29, 18, 28, 33, 34,
529+ 19, 0, 22, 0, 0, 0, 21
547530 };
548531
549532 /* YYDEFGOTO[NTERM-NUM]. */
550533 static const yytype_int8 yydefgoto[] =
551534 {
552− -1, 3, 14, 4, 5, 6, 27, 11, 18, 25,
553− 29, 44, 45, 56, 64, 65, 57, 30, 31, 7
535+ -1, 2, 7, 8, 10, 13, 17, 21, 26, 37,
536+ 38, 50, 57, 51, 27, 28
554537 };
555538
556539 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
557540 STATE-NUM. */
558−#define YYPACT_NINF -14
541+#define YYPACT_NINF -12
559542 static const yytype_int8 yypact[] =
560543 {
561− 30, -11, -14, 7, -14, -1, 27, 13, 27, -14,
562− 8, -14, -14, 40, -1, 27, 35, -14, -14, -14,
563− -14, 21, -14, -14, 40, 24, 40, 28, 40, -14,
564− 32, 24, 46, 38, -14, 39, -14, -14, 26, -14,
565− -14, -14, -14, -14, -9, 10, -14, -14, -14, -14,
566− -14, -14, 31, -14, -14, 44, -2, 3, 23, -14,
567− -14, -14, -14, -14, 50, -14, -14, -14, -14, 40,
568− -14, -14, 33, 40, 36, -14
544+ 10, -11, 18, -1, -12, 22, -1, 15, -1, -12,
545+ 22, -12, 20, 1, -12, 17, -12, -12, 20, 20,
546+ -12, 6, -12, -12, 21, 6, -12, 23, 6, -12,
547+ -12, -12, -12, -12, 28, -12, -12, -6, 13, -12,
548+ -12, -12, -12, -12, -12, -12, 24, -12, -12, 33,
549+ -5, 0, -4, -12, -12, -12, -12, -12, -12, -12,
550+ -12, 22, -12, 25, 22, 19, -12
569551 };
570552
571553 /* YYPGOTO[NTERM-NUM]. */
572554 static const yytype_int8 yypgoto[] =
573555 {
574− -14, -14, 48, 29, 53, -14, -13, 47, 34, -14,
575− 37, -14, -14, -14, -14, -14, -14, 42, -14, -7
556+ -12, -12, 36, 39, -10, -12, 8, -12, 12, -12,
557+ -12, -12, -12, -12, 27, 31
576558 };
577559
578560 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
579561 positive, shift that token. If negative, reduce the rule which
580562 number is the opposite. If zero, do what YYDEFACT says.
581563 If YYTABLE_NINF, syntax error. */
582−#define YYTABLE_NINF -45
583−static const yytype_int8 yytable[] =
564+#define YYTABLE_NINF -1
565+static const yytype_uint8 yytable[] =
584566 {
585− 21, 16, 46, 8, 59, 47, 60, 9, 16, 61,
586− 62, 28, 66, 33, 67, 10, 48, 13, 32, 63,
587− 49, 50, 51, 52, 32, 17, 68, 19, 20, -44,
588− 53, -44, 54, 1, -44, 2, 26, 15, 2, 24,
589− 41, 2, 34, 17, 15, 42, 19, 20, 69, 70,
590− 35, 38, 39, 40, 58, 55, 72, 71, 73, 12,
591− 74, 22, 75, 23, 0, 0, 0, 0, 36, 0,
592− 0, 0, 43, 37
567+ 15, 53, 3, 5, 40, 54, 55, 41, 58, 6,
568+ 59, 24, 18, 1, 56, 19, 25, 42, 4, 61,
569+ 62, 60, 43, 44, 45, 46, 22, 23, 9, 12,
570+ 20, 47, 31, 48, 29, 16, 16, 32, 30, 34,
571+ 35, 39, 52, 66, 14, 11, 49, 0, 64, 0,
572+ 0, 63, 0, 0, 65, 36, 33
593573 };
594574
595575 static const yytype_int8 yycheck[] =
596576 {
597− 13, 8, 11, 14, 6, 14, 8, 0, 15, 11,
598− 12, 24, 9, 26, 11, 16, 25, 4, 25, 21,
599− 10, 11, 12, 13, 31, 17, 23, 6, 7, 5,
600− 20, 4, 22, 3, 4, 11, 15, 8, 11, 4,
601− 14, 11, 14, 17, 15, 19, 6, 7, 25, 26,
602− 18, 5, 14, 14, 10, 24, 69, 7, 25, 6,
603− 73, 14, 26, 15, -1, -1, -1, -1, 31, -1,
604− -1, -1, 38, 31
577+ 10, 6, 13, 4, 10, 10, 11, 13, 8, 10,
578+ 10, 5, 11, 3, 19, 14, 10, 23, 0, 23,
579+ 24, 21, 9, 10, 11, 12, 18, 19, 6, 14,
580+ 13, 18, 24, 20, 13, 15, 15, 25, 17, 16,
581+ 28, 13, 9, 24, 8, 6, 22, -1, 23, -1,
582+ -1, 61, -1, -1, 64, 28, 25
605583 };
606584
607585 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
608586 symbol of state STATE-NUM. */
609587 static const yytype_uint8 yystos[] =
610588 {
611− 0, 3, 11, 28, 30, 31, 32, 46, 14, 0,
612− 16, 34, 31, 4, 29, 30, 46, 17, 35, 6,
613− 7, 33, 34, 29, 4, 36, 15, 33, 33, 37,
614− 44, 45, 46, 33, 14, 18, 37, 44, 5, 14,
615− 14, 14, 19, 35, 38, 39, 11, 14, 25, 10,
616− 11, 12, 13, 20, 22, 24, 40, 43, 10, 6,
617− 8, 11, 12, 21, 41, 42, 9, 11, 23, 25,
618− 26, 7, 33, 25, 33, 26
589+ 0, 3, 26, 13, 0, 4, 10, 27, 28, 6,
590+ 29, 28, 14, 30, 27, 29, 15, 31, 11, 14,
591+ 13, 32, 31, 31, 5, 10, 33, 39, 40, 13,
592+ 17, 31, 33, 40, 16, 33, 39, 34, 35, 13,
593+ 10, 13, 23, 9, 10, 11, 12, 18, 20, 22,
594+ 36, 38, 9, 6, 10, 11, 19, 37, 8, 10,
595+ 21, 23, 24, 29, 23, 29, 24
619596 };
620597
621598 #define yyerrok (yyerrstatus = 0)
@@ -728,7 +705,7 @@ do { \ · 106 unmodified lines
728705 { \
729706 YYFPRINTF (stderr, "%s ", Title); \
730707 yy_symbol_print (stderr, \
731− Type, Value, Location); \
708+ Type, Value); \
732709 YYFPRINTF (stderr, "\n"); \
733710 } \
734711 } while (YYID (0))
@@ -742,19 +719,17 @@ do { \ · 7 unmodified lines
742719 #if (defined __STDC__ || defined __C99__FUNC__ \
743720 || defined __cplusplus || defined _MSC_VER)
744721 static void
745−yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
722+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
746723 #else
747724 static void
748−yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
725+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
749726 FILE *yyoutput;
750727 int yytype;
751728 YYSTYPE const * const yyvaluep;
752− YYLTYPE const * const yylocationp;
753729 #endif
754730 {
755731 if (!yyvaluep)
756732 return;
757− YYUSE (yylocationp);
758733 # ifdef YYPRINT
759734 if (yytype < YYNTOKENS)
760735 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
@@ -776,14 +751,13 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) · 15 unmodified lines
776751 #if (defined __STDC__ || defined __C99__FUNC__ \
777752 || defined __cplusplus || defined _MSC_VER)
778753 static void
779−yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
754+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
780755 #else
781756 static void
782−yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
757+yy_symbol_print (yyoutput, yytype, yyvaluep)
783758 FILE *yyoutput;
784759 int yytype;
785760 YYSTYPE const * const yyvaluep;
786− YYLTYPE const * const yylocationp;
787761 #endif
788762 {
789763 if (yytype < YYNTOKENS)
@@ -791,9 +765,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) · 1 unmodified line
791765 else
792766 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
793767
794− YY_LOCATION_PRINT (yyoutput, *yylocationp);
795− YYFPRINTF (yyoutput, ": ");
796− yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
768+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
797769 YYFPRINTF (yyoutput, ")");
798770 }
799771
@@ -805,17 +777,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) · 5 unmodified lines
805777 #if (defined __STDC__ || defined __C99__FUNC__ \
806778 || defined __cplusplus || defined _MSC_VER)
807779 static void
808−yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
780+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
809781 #else
810782 static void
811−yy_stack_print (bottom, top)
812− yytype_int16 *bottom;
813− yytype_int16 *top;
783+yy_stack_print (yybottom, yytop)
784+ yytype_int16 *yybottom;
785+ yytype_int16 *yytop;
814786 #endif
815787 {
816788 YYFPRINTF (stderr, "Stack now");
817− for (; bottom <= top; ++bottom)
818− YYFPRINTF (stderr, " %d", *bottom);
789+ for (; yybottom <= yytop; yybottom++)
790+ {
791+ int yybot = *yybottom;
792+ YYFPRINTF (stderr, " %d", yybot);
793+ }
819794 YYFPRINTF (stderr, "\n");
820795 }
821796
@@ -833,12 +808,11 @@ do { \ · 11 unmodified lines
833808 #if (defined __STDC__ || defined __C99__FUNC__ \
834809 || defined __cplusplus || defined _MSC_VER)
835810 static void
836−yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
811+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
837812 #else
838813 static void
839−yy_reduce_print (yyvsp, yylsp, yyrule)
814+yy_reduce_print (yyvsp, yyrule)
840815 YYSTYPE *yyvsp;
841− YYLTYPE *yylsp;
842816 int yyrule;
843817 #endif
844818 {
@@ -850,18 +824,18 @@ yy_reduce_print (yyvsp, yylsp, yyrule) · 5 unmodified lines
850824 /* The symbols being reduced. */
851825 for (yyi = 0; yyi < yynrhs; yyi++)
852826 {
853− fprintf (stderr, " $%d = ", yyi + 1);
827+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
854828 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
855829 &(yyvsp[(yyi + 1) - (yynrhs)])
856− , &(yylsp[(yyi + 1) - (yynrhs)]) );
857− fprintf (stderr, "\n");
830+ );
831+ YYFPRINTF (stderr, "\n");
858832 }
859833 }
860834
861835 # define YY_REDUCE_PRINT(Rule) \
862836 do { \
863837 if (yydebug) \
864− yy_reduce_print (yyvsp, yylsp, Rule); \
838+ yy_reduce_print (yyvsp, Rule); \
865839 } while (YYID (0))
866840
867841 /* Nonzero means print parse trace. It is left uninitialized so that
@@ -1112,18 +1086,16 @@ yysyntax_error (char *yyresult, int yystate, int yychar) · 244 unmodified lines
11121086 #if (defined __STDC__ || defined __C99__FUNC__ \
11131087 || defined __cplusplus || defined _MSC_VER)
11141088 static void
1115−yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
1089+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
11161090 #else
11171091 static void
1118−yydestruct (yymsg, yytype, yyvaluep, yylocationp)
1092+yydestruct (yymsg, yytype, yyvaluep)
11191093 const char *yymsg;
11201094 int yytype;
11211095 YYSTYPE *yyvaluep;
1122− YYLTYPE *yylocationp;
11231096 #endif
11241097 {
11251098 YYUSE (yyvaluep);
1126− YYUSE (yylocationp);
11271099
11281100 if (!yymsg)
11291101 yymsg = "Deleting";
@@ -1136,10 +1108,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp) · 6 unmodified lines
11361108 break;
11371109 }
11381110 }
1139−
11401111
11411112 /* Prevent warnings from -Wmissing-prototypes. */
1142−
11431113 #ifdef YYPARSE_PARAM
11441114 #if defined __STDC__ || defined __cplusplus
11451115 int yyparse (void *YYPARSE_PARAM);
@@ -1155,23 +1125,20 @@ int yyparse (); · 9 unmodified lines
11551125 #endif /* ! YYPARSE_PARAM */
11561126
11571127
1158−
1159−/* The look-ahead symbol. */
1128+/* The lookahead symbol. */
11601129 int yychar;
11611130
1162−/* The semantic value of the look-ahead symbol. */
1131+/* The semantic value of the lookahead symbol. */
11631132 YYSTYPE yylval;
11641133
11651134 /* Number of syntax errors so far. */
11661135 int yynerrs;
1167−/* Location data for the look-ahead symbol. */
1168−YYLTYPE yylloc;
11691136
11701137
11711138
1172−/*----------.
1173−| yyparse. |
1174−`----------*/
1139+/*-------------------------.
1140+| yyparse or yypush_parse. |
1141+`-------------------------*/
11751142
11761143 #ifdef YYPARSE_PARAM
11771144 #if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1195,79 +1162,70 @@ yyparse () · 17 unmodified lines
11951162 #endif
11961163 #endif
11971164 {
1198−
1199− int yystate;
1200− int yyn;
1201− int yyresult;
1202− /* Number of tokens to shift before error messages enabled. */
1203− int yyerrstatus;
1204− /* Look-ahead token as an internal (translated) token number. */
1205− int yytoken = 0;
1206−#if YYERROR_VERBOSE
1207− /* Buffer for error messages, and its allocated size. */
1208− char yymsgbuf[128];
1209− char *yymsg = yymsgbuf;
1210− YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1211−#endif
12121165
1213− /* Three stacks and their tools:
1214− `yyss': related to states,
1215− `yyvs': related to semantic values,
1216− `yyls': related to locations.
12171166
1218− Refer to the stacks thru separate pointers, to allow yyoverflow
1219− to reallocate them elsewhere. */
1167+ int yystate;
1168+ /* Number of tokens to shift before error messages enabled. */
1169+ int yyerrstatus;
12201170
1221− /* The state stack. */
1222− yytype_int16 yyssa[YYINITDEPTH];
1223− yytype_int16 *yyss = yyssa;
1224− yytype_int16 *yyssp;
1171+ /* The stacks and their tools:
1172+ `yyss': related to states.
1173+ `yyvs': related to semantic values.
12251174
1226− /* The semantic value stack. */
1227− YYSTYPE yyvsa[YYINITDEPTH];
1228− YYSTYPE *yyvs = yyvsa;
1229− YYSTYPE *yyvsp;
1175+ Refer to the stacks thru separate pointers, to allow yyoverflow
1176+ to reallocate them elsewhere. */
12301177
1231− /* The location stack. */
1232− YYLTYPE yylsa[YYINITDEPTH];
1233− YYLTYPE *yyls = yylsa;
1234− YYLTYPE *yylsp;
1235− /* The locations where the error started and ended. */
1236− YYLTYPE yyerror_range[2];
1178+ /* The state stack. */
1179+ yytype_int16 yyssa[YYINITDEPTH];
1180+ yytype_int16 *yyss;
1181+ yytype_int16 *yyssp;
12371182
1238−#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1183+ /* The semantic value stack. */
1184+ YYSTYPE yyvsa[YYINITDEPTH];
1185+ YYSTYPE *yyvs;
1186+ YYSTYPE *yyvsp;
12391187
1240− YYSIZE_T yystacksize = YYINITDEPTH;
1188+ YYSIZE_T yystacksize;
12411189
1190+ int yyn;
1191+ int yyresult;
1192+ /* Lookahead token as an internal (translated) token number. */
1193+ int yytoken;
12421194 /* The variables used to return semantic value and location from the
12431195 action routines. */
12441196 YYSTYPE yyval;
1245− YYLTYPE yyloc;
1197+
1198+#if YYERROR_VERBOSE
1199+ /* Buffer for error messages, and its allocated size. */
1200+ char yymsgbuf[128];
1201+ char *yymsg = yymsgbuf;
1202+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1203+#endif
1204+
1205+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
12461206
12471207 /* The number of symbols on the RHS of the reduced rule.
12481208 Keep to zero when no symbol should be popped. */
12491209 int yylen = 0;
12501210
1211+ yytoken = 0;
1212+ yyss = yyssa;
1213+ yyvs = yyvsa;
1214+ yystacksize = YYINITDEPTH;
1215+
12511216 YYDPRINTF ((stderr, "Starting parse\n"));
12521217
12531218 yystate = 0;
12541219 yyerrstatus = 0;
12551220 yynerrs = 0;
1256− yychar = YYEMPTY; /* Cause a token to be read. */
1221+ yychar = YYEMPTY; /* Cause a token to be read. */
12571222
12581223 /* Initialize stack pointers.
12591224 Waste one element of value and location stack
12601225 so that they stay on the same level as the state stack.
12611226 The wasted elements are never initialized. */
1262−
12631227 yyssp = yyss;
12641228 yyvsp = yyvs;
1265− yylsp = yyls;
1266−#if YYLTYPE_IS_TRIVIAL
1267− /* Initialize the default location before parsing starts. */
1268− yylloc.first_line = yylloc.last_line = 1;
1269− yylloc.first_column = yylloc.last_column = 0;
1270−#endif
12711229
12721230 goto yysetstate;
12731231
@@ -1294,7 +1252,6 @@ yyparse () · 20 unmodified lines
12941252 memory. */
12951253 YYSTYPE *yyvs1 = yyvs;
12961254 yytype_int16 *yyss1 = yyss;
1297− YYLTYPE *yyls1 = yyls;
12981255
12991256 /* Each stack pointer address is followed by the size of the
13001257 data in use in that stack, in bytes. This used to be a
@@ -1303,9 +1260,8 @@ yyparse () · 2 unmodified lines
13031260 yyoverflow (YY_("memory exhausted"),
13041261 &yyss1, yysize * sizeof (*yyssp),
13051262 &yyvs1, yysize * sizeof (*yyvsp),
1306− &yyls1, yysize * sizeof (*yylsp),
13071263 &yystacksize);
1308− yyls = yyls1;
1264+
13091265 yyss = yyss1;
13101266 yyvs = yyvs1;
13111267 }
@@ -1326,9 +1282,8 @@ yyparse () · 14 unmodified lines
13261282 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
13271283 if (! yyptr)
13281284 goto yyexhaustedlab;
1329− YYSTACK_RELOCATE (yyss);
1330− YYSTACK_RELOCATE (yyvs);
1331− YYSTACK_RELOCATE (yyls);
1285+ YYSTACK_RELOCATE (yyss_alloc, yyss);
1286+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
13321287 # undef YYSTACK_RELOCATE
13331288 if (yyss1 != yyssa)
13341289 YYSTACK_FREE (yyss1);
@@ -1338,7 +1293,6 @@ yyparse () · 3 unmodified lines
13381293
13391294 yyssp = yyss + yysize - 1;
13401295 yyvsp = yyvs + yysize - 1;
1341− yylsp = yyls + yysize - 1;
13421296
13431297 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
13441298 (unsigned long int) yystacksize));
@@ -1349,6 +1303,9 @@ yyparse () · 4 unmodified lines
13491303
13501304 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
13511305
1306+ if (yystate == YYFINAL)
1307+ YYACCEPT;
1308+
13521309 goto yybackup;
13531310
13541311 /*-----------.
@@ -1357,16 +1314,16 @@ yyparse () · 2 unmodified lines
13571314 yybackup:
13581315
13591316 /* Do appropriate processing given the current state. Read a
1360− look-ahead token if we need one and don't already have one. */
1317+ lookahead token if we need one and don't already have one. */
13611318
1362− /* First try to decide what to do without reference to look-ahead token. */
1319+ /* First try to decide what to do without reference to lookahead token. */
13631320 yyn = yypact[yystate];
13641321 if (yyn == YYPACT_NINF)
13651322 goto yydefault;
13661323
1367− /* Not known => get a look-ahead token if don't already have one. */
1324+ /* Not known => get a lookahead token if don't already have one. */
13681325
1369− /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1326+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
13701327 if (yychar == YYEMPTY)
13711328 {
13721329 YYDPRINTF ((stderr, "Reading a token: "));
@@ -1398,24 +1355,20 @@ yybackup: · 25 unmodified lines
13981355 goto yyreduce;
13991356 }
14001357
1401− if (yyn == YYFINAL)
1402− YYACCEPT;
1403−
14041358 /* Count tokens shifted since error; after three, turn off error
14051359 status. */
14061360 if (yyerrstatus)
14071361 yyerrstatus--;
14081362
1409− /* Shift the look-ahead token. */
1363+ /* Shift the lookahead token. */
14101364 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
14111365
1412− /* Discard the shifted token unless it is eof. */
1413− if (yychar != YYEOF)
1414− yychar = YYEMPTY;
1366+ /* Discard the shifted token. */
1367+ yychar = YYEMPTY;
14151368
14161369 yystate = yyn;
14171370 *++yyvsp = yylval;
1418− *++yylsp = yylloc;
1371+
14191372 goto yynewstate;
14201373
14211374
@@ -1446,337 +1399,387 @@ yyreduce: · 24 unmodified lines
14461399 GCC warning that YYVAL may be used uninitialized. */
14471400 yyval = yyvsp[1-yylen];
14481401
1449− /* Default location. */
1450− YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1402+
14511403 YY_REDUCE_PRINT (yyn);
14521404 switch (yyn)
14531405 {
14541406 case 2:
1455−#line 90 "dtc-parser.y"
1407+
1408+/* Line 1455 of yacc.c */
1409+#line 87 "dtc-parser.y"
14561410 {
1457− the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), 0);
1411+ the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node),
1412+ guess_boot_cpuid((yyvsp[(4) - (4)].node)));
14581413 ;}
14591414 break;
14601415
14611416 case 3:
1462−#line 94 "dtc-parser.y"
1417+
1418+/* Line 1455 of yacc.c */
1419+#line 95 "dtc-parser.y"
14631420 {
1464− the_boot_info = build_boot_info((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].node), 0);
1421+ (yyval.re) = NULL;
14651422 ;}
14661423 break;
14671424
14681425 case 4:
1469−#line 101 "dtc-parser.y"
1426+
1427+/* Line 1455 of yacc.c */
1428+#line 99 "dtc-parser.y"
14701429 {
1471− (yyval.re) = NULL;
1430+ (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re));
14721431 ;}
14731432 break;
14741433
14751434 case 5:
1476−#line 105 "dtc-parser.y"
1435+
1436+/* Line 1455 of yacc.c */
1437+#line 106 "dtc-parser.y"
14771438 {
1478− (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re));
1439+ (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].addr), (yyvsp[(3) - (4)].addr));
14791440 ;}
14801441 break;
14811442
14821443 case 6:
1483−#line 112 "dtc-parser.y"
1444+
1445+/* Line 1455 of yacc.c */
1446+#line 110 "dtc-parser.y"
14841447 {
1485− (yyval.re) = build_reserve_entry((yyvsp[(3) - (5)].addr), (yyvsp[(4) - (5)].addr), (yyvsp[(1) - (5)].labelref));
1448+ add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref));
1449+ (yyval.re) = (yyvsp[(2) - (2)].re);
14861450 ;}
14871451 break;
14881452
14891453 case 7:
1490−#line 119 "dtc-parser.y"
1454+
1455+/* Line 1455 of yacc.c */
1456+#line 118 "dtc-parser.y"
14911457 {
1492− (yyval.re) = NULL;
1458+ (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64);
14931459 ;}
14941460 break;
14951461
14961462 case 8:
1497−#line 123 "dtc-parser.y"
1463+
1464+/* Line 1455 of yacc.c */
1465+#line 125 "dtc-parser.y"
14981466 {
1499− (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re));
1467+ (yyval.node) = name_node((yyvsp[(2) - (2)].node), "");
15001468 ;}
15011469 break;
15021470
15031471 case 9:
1504−#line 130 "dtc-parser.y"
1472+
1473+/* Line 1455 of yacc.c */
1474+#line 129 "dtc-parser.y"
15051475 {
1506− (yyval.re) = (yyvsp[(1) - (1)].re);
1476+ (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
15071477 ;}
15081478 break;
15091479
15101480 case 10:
1511−#line 134 "dtc-parser.y"
1481+
1482+/* Line 1455 of yacc.c */
1483+#line 133 "dtc-parser.y"
15121484 {
1513− (yyval.re) = build_reserve_entry((yyvsp[(3) - (6)].addr), (yyvsp[(5) - (6)].addr) - (yyvsp[(3) - (6)].addr) + 1, (yyvsp[(1) - (6)].labelref));
1485+ struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref));
1486+
1487+ if (target)
1488+ merge_nodes(target, (yyvsp[(3) - (3)].node));
1489+ else
1490+ print_error("label or path, '%s', not found", (yyvsp[(2) - (3)].labelref));
1491+ (yyval.node) = (yyvsp[(1) - (3)].node);
15141492 ;}
15151493 break;
15161494
15171495 case 11:
1518−#line 141 "dtc-parser.y"
1496+
1497+/* Line 1455 of yacc.c */
1498+#line 146 "dtc-parser.y"
15191499 {
1520− (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64);
1500+ (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist));
15211501 ;}
15221502 break;
15231503
15241504 case 12:
1525−#line 145 "dtc-parser.y"
1505+
1506+/* Line 1455 of yacc.c */
1507+#line 153 "dtc-parser.y"
15261508 {
1527− (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 16, 64);
1509+ (yyval.proplist) = NULL;
15281510 ;}
15291511 break;
15301512
15311513 case 13:
1532−#line 152 "dtc-parser.y"
1514+
1515+/* Line 1455 of yacc.c */
1516+#line 157 "dtc-parser.y"
15331517 {
1534− (yyval.node) = name_node((yyvsp[(2) - (2)].node), "", NULL);
1518+ (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist));
15351519 ;}
15361520 break;
15371521
15381522 case 14:
1539−#line 159 "dtc-parser.y"
1523+
1524+/* Line 1455 of yacc.c */
1525+#line 164 "dtc-parser.y"
15401526 {
1541− (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist));
1527+ (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data));
15421528 ;}
15431529 break;
15441530
15451531 case 15:
1546−#line 166 "dtc-parser.y"
1532+
1533+/* Line 1455 of yacc.c */
1534+#line 168 "dtc-parser.y"
15471535 {
1548− (yyval.proplist) = NULL;
1536+ (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data);
15491537 ;}
15501538 break;
15511539
15521540 case 16:
1553−#line 170 "dtc-parser.y"
1541+
1542+/* Line 1455 of yacc.c */
1543+#line 172 "dtc-parser.y"
15541544 {
1555− (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist));
1545+ add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref));
1546+ (yyval.prop) = (yyvsp[(2) - (2)].prop);
15561547 ;}
15571548 break;
15581549
15591550 case 17:
1560−#line 177 "dtc-parser.y"
1551+
1552+/* Line 1455 of yacc.c */
1553+#line 180 "dtc-parser.y"
15611554 {
1562− (yyval.prop) = build_property((yyvsp[(2) - (5)].propnodename), (yyvsp[(4) - (5)].data), (yyvsp[(1) - (5)].labelref));
1555+ (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data));
15631556 ;}
15641557 break;
15651558
15661559 case 18:
1567−#line 181 "dtc-parser.y"
1560+
1561+/* Line 1455 of yacc.c */
1562+#line 184 "dtc-parser.y"
15681563 {
1569− (yyval.prop) = build_property((yyvsp[(2) - (3)].propnodename), empty_data, (yyvsp[(1) - (3)].labelref));
1564+ (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
15701565 ;}
15711566 break;
15721567
15731568 case 19:
1569+
1570+/* Line 1455 of yacc.c */
15741571 #line 188 "dtc-parser.y"
15751572 {
1576− (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data));
1573+ (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
15771574 ;}
15781575 break;
15791576
15801577 case 20:
1578+
1579+/* Line 1455 of yacc.c */
15811580 #line 192 "dtc-parser.y"
15821581 {
1583− (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
1582+ (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref));
15841583 ;}
15851584 break;
15861585
15871586 case 21:
1588−#line 196 "dtc-parser.y"
1589− {
1590− (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
1591− ;}
1592− break;
1593−
1594− case 22:
1595−#line 200 "dtc-parser.y"
1596− {
1597− (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref));
1598− ;}
1599− break;
16001587
1601− case 23:
1602−#line 204 "dtc-parser.y"
1588+/* Line 1455 of yacc.c */
1589+#line 196 "dtc-parser.y"
16031590 {
1604− struct search_path path = { srcpos_file->dir, NULL, NULL };
1605− struct dtc_file *file = dtc_open_file((yyvsp[(4) - (9)].data).val, &path);
1606− struct data d = empty_data;
1591+ FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL);
1592+ struct data d;
16071593
16081594 if ((yyvsp[(6) - (9)].addr) != 0)
1609− if (fseek(file->file, (yyvsp[(6) - (9)].addr), SEEK_SET) != 0)
1610− yyerrorf("Couldn't seek to offset %llu in \"%s\": %s",
1611− (unsigned long long)(yyvsp[(6) - (9)].addr),
1612− (yyvsp[(4) - (9)].data).val, strerror(errno));
1595+ if (fseek(f, (yyvsp[(6) - (9)].addr), SEEK_SET) != 0)
1596+ print_error("Couldn't seek to offset %llu in \"%s\": %s",
1597+ (unsigned long long)(yyvsp[(6) - (9)].addr),
1598+ (yyvsp[(4) - (9)].data).val,
1599+ strerror(errno));
16131600
1614− d = data_copy_file(file->file, (yyvsp[(8) - (9)].addr));
1601+ d = data_copy_file(f, (yyvsp[(8) - (9)].addr));
16151602
16161603 (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d);
1617− dtc_close_file(file);
1604+ fclose(f);
16181605 ;}
16191606 break;
16201607
1621− case 24:
1622−#line 221 "dtc-parser.y"
1608+ case 22:
1609+
1610+/* Line 1455 of yacc.c */
1611+#line 213 "dtc-parser.y"
16231612 {
1624− struct search_path path = { srcpos_file->dir, NULL, NULL };
1625− struct dtc_file *file = dtc_open_file((yyvsp[(4) - (5)].data).val, &path);
1613+ FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL);
16261614 struct data d = empty_data;
16271615
1628− d = data_copy_file(file->file, -1);
1616+ d = data_copy_file(f, -1);
16291617
16301618 (yyval.data) = data_merge((yyvsp[(1) - (5)].data), d);
1631− dtc_close_file(file);
1619+ fclose(f);
16321620 ;}
16331621 break;
16341622
1635− case 25:
1636−#line 232 "dtc-parser.y"
1623+ case 23:
1624+
1625+/* Line 1455 of yacc.c */
1626+#line 223 "dtc-parser.y"
16371627 {
16381628 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
16391629 ;}
16401630 break;
16411631
1642− case 26:
1643−#line 239 "dtc-parser.y"
1632+ case 24:
1633+
1634+/* Line 1455 of yacc.c */
1635+#line 230 "dtc-parser.y"
16441636 {
16451637 (yyval.data) = empty_data;
16461638 ;}
16471639 break;
16481640
1649− case 27:
1650−#line 243 "dtc-parser.y"
1641+ case 25:
1642+
1643+/* Line 1455 of yacc.c */
1644+#line 234 "dtc-parser.y"
16511645 {
16521646 (yyval.data) = (yyvsp[(1) - (2)].data);
16531647 ;}
16541648 break;
16551649
1656− case 28:
1657−#line 247 "dtc-parser.y"
1650+ case 26:
1651+
1652+/* Line 1455 of yacc.c */
1653+#line 238 "dtc-parser.y"
16581654 {
16591655 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
16601656 ;}
16611657 break;
16621658
1663− case 29:
1664−#line 254 "dtc-parser.y"
1659+ case 27:
1660+
1661+/* Line 1455 of yacc.c */
1662+#line 245 "dtc-parser.y"
16651663 {
16661664 (yyval.data) = empty_data;
16671665 ;}
16681666 break;
16691667
1670− case 30:
1671−#line 258 "dtc-parser.y"
1668+ case 28:
1669+
1670+/* Line 1455 of yacc.c */
1671+#line 249 "dtc-parser.y"
16721672 {
16731673 (yyval.data) = data_append_cell((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].cell));
16741674 ;}
16751675 break;
16761676
1677− case 31:
1678−#line 262 "dtc-parser.y"
1677+ case 29:
1678+
1679+/* Line 1455 of yacc.c */
1680+#line 253 "dtc-parser.y"
16791681 {
16801682 (yyval.data) = data_append_cell(data_add_marker((yyvsp[(1) - (2)].data), REF_PHANDLE,
16811683 (yyvsp[(2) - (2)].labelref)), -1);
16821684 ;}
16831685 break;
16841686
1685− case 32:
1686−#line 267 "dtc-parser.y"
1687+ case 30:
1688+
1689+/* Line 1455 of yacc.c */
1690+#line 258 "dtc-parser.y"
16871691 {
16881692 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
16891693 ;}
16901694 break;
16911695
1692− case 33:
1693−#line 274 "dtc-parser.y"
1694− {
1695− (yyval.cbase) = 16;
1696− ;}
1697− break;
1696+ case 31:
16981697
1699− case 35:
1700−#line 282 "dtc-parser.y"
1698+/* Line 1455 of yacc.c */
1699+#line 265 "dtc-parser.y"
17011700 {
17021701 (yyval.cell) = eval_literal((yyvsp[(1) - (1)].literal), 0, 32);
17031702 ;}
17041703 break;
17051704
1706− case 36:
1707−#line 286 "dtc-parser.y"
1708− {
1709− (yyval.cell) = eval_literal((yyvsp[(2) - (2)].literal), (yyvsp[(1) - (2)].cbase), 32);
1710− ;}
1711− break;
1705+ case 32:
17121706
1713− case 37:
1714−#line 293 "dtc-parser.y"
1707+/* Line 1455 of yacc.c */
1708+#line 272 "dtc-parser.y"
17151709 {
17161710 (yyval.data) = empty_data;
17171711 ;}
17181712 break;
17191713
1720− case 38:
1721−#line 297 "dtc-parser.y"
1714+ case 33:
1715+
1716+/* Line 1455 of yacc.c */
1717+#line 276 "dtc-parser.y"
17221718 {
17231719 (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte));
17241720 ;}
17251721 break;
17261722
1727− case 39:
1728−#line 301 "dtc-parser.y"
1723+ case 34:
1724+
1725+/* Line 1455 of yacc.c */
1726+#line 280 "dtc-parser.y"
17291727 {
17301728 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
17311729 ;}
17321730 break;
17331731
1734− case 40:
1735−#line 308 "dtc-parser.y"
1732+ case 35:
1733+
1734+/* Line 1455 of yacc.c */
1735+#line 287 "dtc-parser.y"
17361736 {
17371737 (yyval.nodelist) = NULL;
17381738 ;}
17391739 break;
17401740
1741− case 41:
1742−#line 312 "dtc-parser.y"
1741+ case 36:
1742+
1743+/* Line 1455 of yacc.c */
1744+#line 291 "dtc-parser.y"
17431745 {
17441746 (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist));
17451747 ;}
17461748 break;
17471749
1748− case 42:
1749−#line 316 "dtc-parser.y"
1750+ case 37:
1751+
1752+/* Line 1455 of yacc.c */
1753+#line 295 "dtc-parser.y"
17501754 {
1751− yyerror("syntax error: properties must precede subnodes");
1755+ print_error("syntax error: properties must precede subnodes");
17521756 YYERROR;
17531757 ;}
17541758 break;
17551759
1756− case 43:
1757−#line 324 "dtc-parser.y"
1758− {
1759− (yyval.node) = name_node((yyvsp[(3) - (3)].node), (yyvsp[(2) - (3)].propnodename), (yyvsp[(1) - (3)].labelref));
1760− ;}
1761− break;
1760+ case 38:
17621761
1763− case 44:
1764−#line 331 "dtc-parser.y"
1762+/* Line 1455 of yacc.c */
1763+#line 303 "dtc-parser.y"
17651764 {
1766− (yyval.labelref) = NULL;
1765+ (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename));
17671766 ;}
17681767 break;
17691768
1770− case 45:
1771−#line 335 "dtc-parser.y"
1769+ case 39:
1770+
1771+/* Line 1455 of yacc.c */
1772+#line 307 "dtc-parser.y"
17721773 {
1773− (yyval.labelref) = (yyvsp[(1) - (1)].labelref);
1774+ add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref));
1775+ (yyval.node) = (yyvsp[(2) - (2)].node);
17741776 ;}
17751777 break;
17761778
17771779
1778−/* Line 1267 of yacc.c. */
1779−#line 1780 "dtc-parser.tab.c"
1780+
1781+/* Line 1455 of yacc.c */
1782+#line 1783 "dtc-parser.tab.c"
17801783 default: break;
17811784 }
17821785 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1786,7 +1789,6 @@ yyreduce: · 3 unmodified lines
17861789 YY_STACK_PRINT (yyss, yyssp);
17871790
17881791 *++yyvsp = yyval;
1789− *++yylsp = yyloc;
17901792
17911793 /* Now `shift' the result of the reduction. Determine what state
17921794 that goes to, based on the state we popped back to and the rule
@@ -1848,11 +1850,11 @@ yyerrlab: · 55 unmodified lines
18481850 #endif
18491851 }
18501852
1851− yyerror_range[0] = yylloc;
1853+
18521854
18531855 if (yyerrstatus == 3)
18541856 {
1855− /* If just tried and failed to reuse look-ahead token after an
1857+ /* If just tried and failed to reuse lookahead token after an
18561858 error, discard it. */
18571859
18581860 if (yychar <= YYEOF)
@@ -1864,12 +1866,12 @@ yyerrlab: · 5 unmodified lines
18641866 else
18651867 {
18661868 yydestruct ("Error: discarding",
1867− yytoken, &yylval, &yylloc);
1869+ yytoken, &yylval);
18681870 yychar = YYEMPTY;
18691871 }
18701872 }
18711873
1872− /* Else will try to reuse look-ahead token after shifting the error
1874+ /* Else will try to reuse lookahead token after shifting the error
18731875 token. */
18741876 goto yyerrlab1;
18751877
@@ -1885,7 +1887,6 @@ yyerrorlab: · 9 unmodified lines
18851887 if (/*CONSTCOND*/ 0)
18861888 goto yyerrorlab;
18871889
1888− yyerror_range[0] = yylsp[1-yylen];
18891890 /* Do not reclaim the symbols of the rule which action triggered
18901891 this YYERROR. */
18911892 YYPOPSTACK (yylen);
@@ -1919,24 +1920,16 @@ yyerrlab1: · 27 unmodified lines
19191920 if (yyssp == yyss)
19201921 YYABORT;
19211922
1922− yyerror_range[0] = *yylsp;
1923+
19231924 yydestruct ("Error: popping",
1924− yystos[yystate], yyvsp, yylsp);
1925+ yystos[yystate], yyvsp);
19251926 YYPOPSTACK (1);
19261927 yystate = *yyssp;
19271928 YY_STACK_PRINT (yyss, yyssp);
19281929 }
19291930
1930− if (yyn == YYFINAL)
1931− YYACCEPT;
1932−
19331931 *++yyvsp = yylval;
19341932
1935− yyerror_range[1] = yylloc;
1936− /* Using YYLLOC is tempting, but would change the location of
1937− the look-ahead. YYLOC is available though. */
1938− YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
1939− *++yylsp = yyloc;
19401933
19411934 /* Shift the error token. */
19421935 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
@@ -1959,7 +1952,7 @@ yyabortlab: · 16 unmodified lines
19591952 yyresult = 1;
19601953 goto yyreturn;
19611954
1962−#ifndef yyoverflow
1955+#if !defined(yyoverflow) || YYERROR_VERBOSE
19631956 /*-------------------------------------------------.
19641957 | yyexhaustedlab -- memory exhaustion comes here. |
19651958 `-------------------------------------------------*/
@@ -1970,9 +1963,9 @@ yyexhaustedlab: · 4 unmodified lines
19701963 #endif
19711964
19721965 yyreturn:
1973− if (yychar != YYEOF && yychar != YYEMPTY)
1966+ if (yychar != YYEMPTY)
19741967 yydestruct ("Cleanup: discarding lookahead",
1975− yytoken, &yylval, &yylloc);
1968+ yytoken, &yylval);
19761969 /* Do not reclaim the symbols of the rule which action triggered
19771970 this YYABORT or YYACCEPT. */
19781971 YYPOPSTACK (yylen);
@@ -1980,7 +1973,7 @@ yyreturn: · 1 unmodified line
19801973 while (yyssp != yyss)
19811974 {
19821975 yydestruct ("Cleanup: popping",
1983− yystos[*yyssp], yyvsp, yylsp);
1976+ yystos[*yyssp], yyvsp);
19841977 YYPOPSTACK (1);
19851978 }
19861979 #ifndef yyoverflow
@@ -1996,29 +1989,24 @@ yyreturn: · 9 unmodified lines
19961989 }
19971990
19981991
1999−#line 340 "dtc-parser.y"
1992+
1993+/* Line 1675 of yacc.c */
1994+#line 313 "dtc-parser.y"
20001995
20011996
2002−void yyerrorf(char const *s, ...)
1997+void print_error(char const *fmt, ...)
20031998 {
2004− const char *fname = srcpos_file ? srcpos_file->name : "<no-file>";
20051999 va_list va;
2006− va_start(va, s);
2007−
2008− if (strcmp(fname, "-") == 0)
2009− fname = "stdin";
20102000
2011− fprintf(stderr, "%s:%d ", fname, yylloc.first_line);
2012− vfprintf(stderr, s, va);
2013− fprintf(stderr, "\n");
2001+ va_start(va, fmt);
2002+ srcpos_verror(&yylloc, fmt, va);
2003+ va_end(va);
20142004
20152005 treesource_error = 1;
2016− va_end(va);
20172006 }
20182007
2019−void yyerror (char const *s)
2020−{
2021− yyerrorf("%s", s);
2008+void yyerror(char const *s) {
2009+ print_error("%s", s);
20222010 }
20232011
20242012 static unsigned long long eval_literal(const char *s, int base, int bits)
@@ -2029,12 +2017,12 @@ static unsigned long long eval_literal(const char *s, int base, int bits) · 4 unmodified lines
20292017 errno = 0;
20302018 val = strtoull(s, &e, base);
20312019 if (*e)
2032− yyerror("bad characters in literal");
2020+ print_error("bad characters in literal");
20332021 else if ((errno == ERANGE)
20342022 || ((bits < 64) && (val >= (1ULL << bits))))
2035− yyerror("literal out of range");
2023+ print_error("literal out of range");
20362024 else if (errno != 0)
2037− yyerror("bad literal");
2025+ print_error("bad literal");
20382026 return val;
20392027 }
20402028
scripts/dtc/dtc-parser.tab.h_shipped+30−52
@@ -1,24 +1,23 @@
1−/* A Bison parser, made by GNU Bison 2.3. */
21
3−/* Skeleton interface for Bison's Yacc-like parsers in C
2+/* A Bison parser, made by GNU Bison 2.4.1. */
43
5− Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
4+/* Skeleton interface for Bison's Yacc-like parsers in C
5+
6+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
67 Free Software Foundation, Inc.
7−
8− This program is free software; you can redistribute it and/or modify
8+
9+ This program is free software: you can redistribute it and/or modify
910 it under the terms of the GNU General Public License as published by
10− the Free Software Foundation; either version 2, or (at your option)
11− any later version.
12−
11+ the Free Software Foundation, either version 3 of the License, or
12+ (at your option) any later version.
13+
1314 This program is distributed in the hope that it will be useful,
1415 but WITHOUT ANY WARRANTY; without even the implied warranty of
1516 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1617 GNU General Public License for more details.
17−
18+
1819 You should have received a copy of the GNU General Public License
19− along with this program; if not, write to the Free Software
20− Foundation, Inc., 51 Franklin Street, Fifth Floor,
21− Boston, MA 02110-1301, USA. */
20+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2221
2322 /* As a special exception, you may create a larger work that contains
2423 part or all of the Bison parser skeleton and distribute that work
@@ -29,10 +28,11 @@ · 4 unmodified lines
2928 special exception, which will cause the skeleton and the resulting
3029 Bison output files to be licensed under the GNU General Public
3130 License without this special exception.
32−
31+
3332 This special exception was added by the Free Software Foundation in
3433 version 2.2 of Bison. */
3534
35+
3636 /* Tokens. */
3737 #ifndef YYTOKENTYPE
3838 # define YYTOKENTYPE
@@ -43,35 +43,24 @@ · 4 unmodified lines
4343 DT_MEMRESERVE = 259,
4444 DT_PROPNODENAME = 260,
4545 DT_LITERAL = 261,
46− DT_LEGACYLITERAL = 262,
47− DT_BASE = 263,
48− DT_BYTE = 264,
49− DT_STRING = 265,
50− DT_LABEL = 266,
51− DT_REF = 267,
52− DT_INCBIN = 268
46+ DT_BASE = 262,
47+ DT_BYTE = 263,
48+ DT_STRING = 264,
49+ DT_LABEL = 265,
50+ DT_REF = 266,
51+ DT_INCBIN = 267
5352 };
5453 #endif
55−/* Tokens. */
56−#define DT_V1 258
57−#define DT_MEMRESERVE 259
58−#define DT_PROPNODENAME 260
59−#define DT_LITERAL 261
60−#define DT_LEGACYLITERAL 262
61−#define DT_BASE 263
62−#define DT_BYTE 264
63−#define DT_STRING 265
64−#define DT_LABEL 266
65−#define DT_REF 267
66−#define DT_INCBIN 268
67−
6854
6955
7056
7157 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
7258 typedef union YYSTYPE
73−#line 37 "dtc-parser.y"
7459 {
60+
61+/* Line 1676 of yacc.c */
62+#line 39 "dtc-parser.y"
63+
7564 char *propnodename;
7665 char *literal;
7766 char *labelref;
@@ -86,28 +75,17 @@ typedef union YYSTYPE · 8 unmodified lines
8675 struct node *node;
8776 struct node *nodelist;
8877 struct reserve_info *re;
89−}
90−/* Line 1489 of yacc.c. */
91−#line 92 "dtc-parser.tab.h"
92− YYSTYPE;
78+
79+
80+
81+/* Line 1676 of yacc.c */
82+#line 83 "dtc-parser.tab.h"
83+} YYSTYPE;
84+# define YYSTYPE_IS_TRIVIAL 1
9385 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
9486 # define YYSTYPE_IS_DECLARED 1
95−# define YYSTYPE_IS_TRIVIAL 1
9687 #endif
9788
9889 extern YYSTYPE yylval;
9990
100−#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
101−typedef struct YYLTYPE
102−{
103− int first_line;
104− int first_column;
105− int last_line;
106− int last_column;
107−} YYLTYPE;
108−# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
109−# define YYLTYPE_IS_DECLARED 1
110−# define YYLTYPE_IS_TRIVIAL 1
111−#endif
11291
113−extern YYLTYPE yylloc;
scripts/dtc/dtc-parser.y+63−97
@@ -18,15 +18,17 @@ · 17 unmodified lines
1818 * USA
1919 */
2020
21−%locations
22−
2321 %{
2422 #include <stdio.h>
2523
2624 #include "dtc.h"
2725 #include "srcpos.h"
2826
27+YYLTYPE yylloc;
28+
2929 extern int yylex(void);
30+extern void print_error(char const *fmt, ...);
31+extern void yyerror(char const *s);
3032
3133 extern struct boot_info *the_boot_info;
3234 extern int treesource_error;
@@ -55,7 +57,6 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 22 unmodified lines
5557 %token DT_MEMRESERVE
5658 %token <propnodename> DT_PROPNODENAME
5759 %token <literal> DT_LITERAL
58−%token <literal> DT_LEGACYLITERAL
5960 %token <cbase> DT_BASE
6061 %token <byte> DT_BYTE
6162 %token <data> DT_STRING
@@ -67,11 +68,8 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 5 unmodified lines
6768 %type <data> propdataprefix
6869 %type <re> memreserve
6970 %type <re> memreserves
70−%type <re> v0_memreserve
71−%type <re> v0_memreserves
7271 %type <addr> addr
7372 %type <data> celllist
74−%type <cbase> cellbase
7573 %type <cell> cellval
7674 %type <data> bytestring
7775 %type <prop> propdef
@@ -81,18 +79,14 @@ static unsigned long long eval_literal(const char *s, int base, int bits); · 3 unmodified lines
8179 %type <node> nodedef
8280 %type <node> subnode
8381 %type <nodelist> subnodes
84−%type <labelref> label
8582
8683 %%
8784
8885 sourcefile:
8986 DT_V1 ';' memreserves devicetree
9087 {
91− the_boot_info = build_boot_info($3, $4, 0);
92− }
93− | v0_memreserves devicetree
94− {
95− the_boot_info = build_boot_info($1, $2, 0);
88+ the_boot_info = build_boot_info($3, $4,
89+ guess_boot_cpuid($4));
9690 }
9791 ;
9892
@@ -108,31 +102,14 @@ memreserves: · 9 unmodified lines
108102 ;
109103
110104 memreserve:
111− label DT_MEMRESERVE addr addr ';'
105+ DT_MEMRESERVE addr addr ';'
112106 {
113− $$ = build_reserve_entry($3, $4, $1);
107+ $$ = build_reserve_entry($2, $3);
114108 }
115− ;
116−
117−v0_memreserves:
118− /* empty */
109+ | DT_LABEL memreserve
119110 {
120− $$ = NULL;
121− }
122− | v0_memreserve v0_memreserves
123− {
124− $$ = chain_reserve_entry($1, $2);
125− };
126− ;
127−
128−v0_memreserve:
129− memreserve
130− {
131− $$ = $1;
132− }
133− | label DT_MEMRESERVE addr '-' addr ';'
134− {
135− $$ = build_reserve_entry($3, $5 - $3 + 1, $1);
111+ add_label(&$2->labels, $1);
112+ $$ = $2;
136113 }
137114 ;
138115
@@ -141,16 +118,26 @@ addr: · 2 unmodified lines
141118 {
142119 $$ = eval_literal($1, 0, 64);
143120 }
144− | DT_LEGACYLITERAL
145− {
146− $$ = eval_literal($1, 16, 64);
147− }
148121 ;
149122
150123 devicetree:
151124 '/' nodedef
152125 {
153− $$ = name_node($2, "", NULL);
126+ $$ = name_node($2, "");
127+ }
128+ | devicetree '/' nodedef
129+ {
130+ $$ = merge_nodes($1, $3);
131+ }
132+ | devicetree DT_REF nodedef
133+ {
134+ struct node *target = get_node_by_ref($1, $2);
135+
136+ if (target)
137+ merge_nodes(target, $3);
138+ else
139+ print_error("label or path, '%s', not found", $2);
140+ $$ = $1;
154141 }
155142 ;
156143
@@ -173,13 +160,18 @@ proplist: · 16 unmodified lines
173160 ;
174161
175162 propdef:
176− label DT_PROPNODENAME '=' propdata ';'
163+ DT_PROPNODENAME '=' propdata ';'
164+ {
165+ $$ = build_property($1, $3);
166+ }
167+ | DT_PROPNODENAME ';'
177168 {
178− $$ = build_property($2, $4, $1);
169+ $$ = build_property($1, empty_data);
179170 }
180− | label DT_PROPNODENAME ';'
171+ | DT_LABEL propdef
181172 {
182− $$ = build_property($2, empty_data, $1);
173+ add_label(&$2->labels, $1);
174+ $$ = $2;
183175 }
184176 ;
185177
@@ -202,31 +194,30 @@ propdata: · 16 unmodified lines
202194 }
203195 | propdataprefix DT_INCBIN '(' DT_STRING ',' addr ',' addr ')'
204196 {
205− struct search_path path = { srcpos_file->dir, NULL, NULL };
206− struct dtc_file *file = dtc_open_file($4.val, &path);
207− struct data d = empty_data;
197+ FILE *f = srcfile_relative_open($4.val, NULL);
198+ struct data d;
208199
209200 if ($6 != 0)
210− if (fseek(file->file, $6, SEEK_SET) != 0)
211− yyerrorf("Couldn't seek to offset %llu in \"%s\": %s",
212− (unsigned long long)$6,
213− $4.val, strerror(errno));
201+ if (fseek(f, $6, SEEK_SET) != 0)
202+ print_error("Couldn't seek to offset %llu in \"%s\": %s",
203+ (unsigned long long)$6,
204+ $4.val,
205+ strerror(errno));
214206
215− d = data_copy_file(file->file, $8);
207+ d = data_copy_file(f, $8);
216208
217209 $$ = data_merge($1, d);
218− dtc_close_file(file);
210+ fclose(f);
219211 }
220212 | propdataprefix DT_INCBIN '(' DT_STRING ')'
221213 {
222− struct search_path path = { srcpos_file->dir, NULL, NULL };
223− struct dtc_file *file = dtc_open_file($4.val, &path);
214+ FILE *f = srcfile_relative_open($4.val, NULL);
224215 struct data d = empty_data;
225216
226− d = data_copy_file(file->file, -1);
217+ d = data_copy_file(f, -1);
227218
228219 $$ = data_merge($1, d);
229− dtc_close_file(file);
220+ fclose(f);
230221 }
231222 | propdata DT_LABEL
232223 {
@@ -269,23 +260,11 @@ celllist: · 36 unmodified lines
269260 }
270261 ;
271262
272−cellbase:
273− /* empty */
274− {
275− $$ = 16;
276− }
277− | DT_BASE
278− ;
279−
280263 cellval:
281264 DT_LITERAL
282265 {
283266 $$ = eval_literal($1, 0, 32);
284267 }
285− | cellbase DT_LEGACYLITERAL
286− {
287− $$ = eval_literal($2, $1, 32);
288− }
289268 ;
290269
291270 bytestring:
@@ -308,57 +287,44 @@ subnodes: · 16 unmodified lines
308287 {
309288 $$ = NULL;
310289 }
311− | subnode subnodes
290+ | subnode subnodes
312291 {
313292 $$ = chain_node($1, $2);
314293 }
315294 | subnode propdef
316295 {
317− yyerror("syntax error: properties must precede subnodes");
296+ print_error("syntax error: properties must precede subnodes");
318297 YYERROR;
319298 }
320299 ;
321300
322301 subnode:
323− label DT_PROPNODENAME nodedef
302+ DT_PROPNODENAME nodedef
324303 {
325− $$ = name_node($3, $2, $1);
304+ $$ = name_node($2, $1);
326305 }
327− ;
328−
329−label:
330− /* empty */
306+ | DT_LABEL subnode
331307 {
332− $$ = NULL;
333− }
334− | DT_LABEL
335− {
336− $$ = $1;
308+ add_label(&$2->labels, $1);
309+ $$ = $2;
337310 }
338311 ;
339312
340313 %%
341314
342−void yyerrorf(char const *s, ...)
315+void print_error(char const *fmt, ...)
343316 {
344− const char *fname = srcpos_file ? srcpos_file->name : "<no-file>";
345317 va_list va;
346− va_start(va, s);
347−
348− if (strcmp(fname, "-") == 0)
349− fname = "stdin";
350318
351− fprintf(stderr, "%s:%d ", fname, yylloc.first_line);
352− vfprintf(stderr, s, va);
353− fprintf(stderr, "\n");
319+ va_start(va, fmt);
320+ srcpos_verror(&yylloc, fmt, va);
321+ va_end(va);
354322
355323 treesource_error = 1;
356− va_end(va);
357324 }
358325
359−void yyerror (char const *s)
360−{
361− yyerrorf("%s", s);
326+void yyerror(char const *s) {
327+ print_error("%s", s);
362328 }
363329
364330 static unsigned long long eval_literal(const char *s, int base, int bits)
@@ -369,11 +335,11 @@ static unsigned long long eval_literal(const char *s, int base, int bits) · 4 unmodified lines
369335 errno = 0;
370336 val = strtoull(s, &e, base);
371337 if (*e)
372− yyerror("bad characters in literal");
338+ print_error("bad characters in literal");
373339 else if ((errno == ERANGE)
374340 || ((bits < 64) && (val >= (1ULL << bits))))
375− yyerror("literal out of range");
341+ print_error("literal out of range");
376342 else if (errno != 0)
377− yyerror("bad literal");
343+ print_error("bad literal");
378344 return val;
379345 }
scripts/dtc/dtc.c+31−26
@@ -30,30 +30,7 @@ int quiet; /* Level of quietness */ · 29 unmodified lines
3030 int reservenum; /* Number of memory reservation slots */
3131 int minsize; /* Minimum blob size */
3232 int padsize; /* Additional padding to blob */
33−
34−char *join_path(const char *path, const char *name)
35−{
36− int lenp = strlen(path);
37− int lenn = strlen(name);
38− int len;
39− int needslash = 1;
40− char *str;
41−
42− len = lenp + lenn + 2;
43− if ((lenp > 0) && (path[lenp-1] == '/')) {
44− needslash = 0;
45− len--;
46− }
47−
48− str = xmalloc(len);
49− memcpy(str, path, lenp);
50− if (needslash) {
51− str[lenp] = '/';
52− lenp++;
53− }
54− memcpy(str+lenp, name, lenn+1);
55− return str;
56−}
33+int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */
5734
5835 static void fill_fullpaths(struct node *tree, const char *prefix)
5936 {
@@ -104,8 +81,15 @@ static void __attribute__ ((noreturn)) usage(void) · 44 unmodified lines
10481 fprintf(stderr, "\t\tSet the physical boot cpu\n");
10582 fprintf(stderr, "\t-f\n");
10683 fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n");
84+ fprintf(stderr, "\t-s\n");
85+ fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n");
10786 fprintf(stderr, "\t-v\n");
10887 fprintf(stderr, "\t\tPrint DTC version and exit\n");
88+ fprintf(stderr, "\t-H <phandle format>\n");
89+ fprintf(stderr, "\t\tphandle formats are:\n");
90+ fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n");
91+ fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n");
92+ fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n");
10993 exit(3);
11094 }
11195
@@ -115,7 +99,7 @@ int main(int argc, char *argv[]) · 3 unmodified lines
11599 const char *inform = "dts";
116100 const char *outform = "dts";
117101 const char *outname = "-";
118− int force = 0, check = 0;
102+ int force = 0, check = 0, sort = 0;
119103 const char *arg;
120104 int opt;
121105 FILE *outf = NULL;
@@ -127,7 +111,7 @@ int main(int argc, char *argv[]) · 5 unmodified lines
127111 minsize = 0;
128112 padsize = 0;
129113
130− while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:v")) != EOF) {
114+ while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:s")) != EOF) {
131115 switch (opt) {
132116 case 'I':
133117 inform = optarg;
@@ -165,6 +149,22 @@ int main(int argc, char *argv[]) · 31 unmodified lines
165149 case 'v':
166150 printf("Version: %s\n", DTC_VERSION);
167151 exit(0);
152+ case 'H':
153+ if (streq(optarg, "legacy"))
154+ phandle_format = PHANDLE_LEGACY;
155+ else if (streq(optarg, "epapr"))
156+ phandle_format = PHANDLE_EPAPR;
157+ else if (streq(optarg, "both"))
158+ phandle_format = PHANDLE_BOTH;
159+ else
160+ die("Invalid argument \"%s\" to -H option\n",
161+ optarg);
162+ break;
163+
164+ case 's':
165+ sort = 1;
166+ break;
167+
168168 case 'h':
169169 default:
170170 usage();
@@ -182,6 +182,9 @@ int main(int argc, char *argv[]) · 11 unmodified lines
182182 if (minsize && padsize)
183183 die("Can't set both -p and -S\n");
184184
185+ if (minsize)
186+ fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n");
187+
185188 fprintf(stderr, "DTC: %s->%s on file \"%s\"\n",
186189 inform, outform, arg);
187190
@@ -200,6 +203,8 @@ int main(int argc, char *argv[]) · 12 unmodified lines
200203 fill_fullpaths(bi->dt, "");
201204 process_checks(force, bi);
202205
206+ if (sort)
207+ sort_tree(bi);
203208
204209 if (streq(outname, "-")) {
205210 outf = stdout;
scripts/dtc/dtc.h+38−39
@@ -34,7 +34,17 @@ · 33 unmodified lines
3434 #include <libfdt_env.h>
3535 #include <fdt.h>
3636
37+#include "util.h"
38+
39+#ifdef DEBUG
40+#define debug(fmt,args...) printf(fmt, ##args)
41+#else
42+#define debug(fmt,args...)
43+#endif
44+
45+
3746 #define DEFAULT_FDT_VERSION 17
47+
3848 /*
3949 * Command line options
4050 */
@@ -42,36 +52,11 @@ extern int quiet; /* Level of quietness */ · 1 unmodified line
4252 extern int reservenum; /* Number of memory reservation slots */
4353 extern int minsize; /* Minimum blob size */
4454 extern int padsize; /* Additional padding to blob */
55+extern int phandle_format; /* Use linux,phandle or phandle properties */
4556
46−static inline void __attribute__((noreturn)) die(char * str, ...)
47−{
48− va_list ap;
49−
50− va_start(ap, str);
51− fprintf(stderr, "FATAL ERROR: ");
52− vfprintf(stderr, str, ap);
53− exit(1);
54−}
55−
56−static inline void *xmalloc(size_t len)
57−{
58− void *new = malloc(len);
59−
60− if (! new)
61− die("malloc() failed\n");
62−
63− return new;
64−}
65−
66−static inline void *xrealloc(void *p, size_t len)
67−{
68− void *new = realloc(p, len);
69−
70− if (! new)
71− die("realloc() failed (len=%d)\n", len);
72−
73− return new;
74−}
57+#define PHANDLE_LEGACY 0x1
58+#define PHANDLE_EPAPR 0x2
59+#define PHANDLE_BOTH 0x3
7560
7661 typedef uint32_t cell_t;
7762
@@ -140,13 +125,18 @@ int data_is_one_string(struct data d); · 62 unmodified lines
140125 #define MAX_NODENAME_LEN 31
141126
142127 /* Live trees */
128+struct label {
129+ char *label;
130+ struct label *next;
131+};
132+
143133 struct property {
144134 char *name;
145135 struct data val;
146136
147137 struct property *next;
148138
149− char *label;
139+ struct label *labels;
150140 };
151141
152142 struct node {
@@ -163,22 +153,28 @@ struct node { · 10 unmodified lines
163153 cell_t phandle;
164154 int addr_cells, size_cells;
165155
166− char *label;
156+ struct label *labels;
167157 };
168158
159+#define for_each_label(l0, l) \
160+ for ((l) = (l0); (l); (l) = (l)->next)
161+
169162 #define for_each_property(n, p) \
170163 for ((p) = (n)->proplist; (p); (p) = (p)->next)
171164
172165 #define for_each_child(n, c) \
173166 for ((c) = (n)->children; (c); (c) = (c)->next_sibling)
174167
175−struct property *build_property(char *name, struct data val, char *label);
168+void add_label(struct label **labels, char *label);
169+
170+struct property *build_property(char *name, struct data val);
176171 struct property *chain_property(struct property *first, struct property *list);
177172 struct property *reverse_properties(struct property *first);
178173
179174 struct node *build_node(struct property *proplist, struct node *children);
180−struct node *name_node(struct node *node, char *name, char *label);
175+struct node *name_node(struct node *node, char *name);
181176 struct node *chain_node(struct node *first, struct node *list);
177+struct node *merge_nodes(struct node *old_node, struct node *new_node);
182178
183179 void add_property(struct node *node, struct property *prop);
184180 void add_child(struct node *parent, struct node *child);
@@ -186,6 +182,10 @@ void add_child(struct node *parent, struct node *child); · 1 unmodified line
186182 const char *get_unitname(struct node *node);
187183 struct property *get_property(struct node *node, const char *propname);
188184 cell_t propval_cell(struct property *prop);
185+struct property *get_property_by_label(struct node *tree, const char *label,
186+ struct node **node);
187+struct marker *get_marker_label(struct node *tree, const char *label,
188+ struct node **node, struct property **prop);
189189 struct node *get_subnode(struct node *node, const char *nodename);
190190 struct node *get_node_by_path(struct node *tree, const char *path);
191191 struct node *get_node_by_label(struct node *tree, const char *label);
@@ -193,6 +193,8 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle); · 1 unmodified line
193193 struct node *get_node_by_ref(struct node *tree, const char *ref);
194194 cell_t get_node_phandle(struct node *root, struct node *node);
195195
196+uint32_t guess_boot_cpuid(struct node *tree);
197+
196198 /* Boot info (tree plus memreserve information */
197199
198200 struct reserve_info {
@@ -200,10 +202,10 @@ struct reserve_info { · 1 unmodified line
200202
201203 struct reserve_info *next;
202204
203− char *label;
205+ struct label *labels;
204206 };
205207
206−struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len, char *label);
208+struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len);
207209 struct reserve_info *chain_reserve_entry(struct reserve_info *first,
208210 struct reserve_info *list);
209211 struct reserve_info *add_reserve_entry(struct reserve_info *list,
@@ -218,6 +220,7 @@ struct boot_info { · 8 unmodified lines
218220
219221 struct boot_info *build_boot_info(struct reserve_info *reservelist,
220222 struct node *tree, uint32_t boot_cpuid_phys);
223+void sort_tree(struct boot_info *bi);
221224
222225 /* Checks */
223226
@@ -239,8 +242,4 @@ struct boot_info *dt_from_source(const char *f); · 15 unmodified lines
239242
240243 struct boot_info *dt_from_fs(const char *dirname);
241244
242−/* misc */
243−
244−char *join_path(const char *path, const char *name);
245−
246245 #endif /* _DTC_H */
scripts/dtc/flattree.c+109−83
@@ -52,9 +52,9 @@ struct emitter { · 51 unmodified lines
5252 void (*string)(void *, char *, int);
5353 void (*align)(void *, int);
5454 void (*data)(void *, struct data);
55− void (*beginnode)(void *, const char *);
56− void (*endnode)(void *, const char *);
57− void (*property)(void *, const char *);
55+ void (*beginnode)(void *, struct label *labels);
56+ void (*endnode)(void *, struct label *labels);
57+ void (*property)(void *, struct label *labels);
5858 };
5959
6060 static void bin_emit_cell(void *e, cell_t val)
@@ -89,17 +89,17 @@ static void bin_emit_data(void *e, struct data d) · 28 unmodified lines
8989 *dtbuf = data_append_data(*dtbuf, d.val, d.len);
9090 }
9191
92−static void bin_emit_beginnode(void *e, const char *label)
92+static void bin_emit_beginnode(void *e, struct label *labels)
9393 {
9494 bin_emit_cell(e, FDT_BEGIN_NODE);
9595 }
9696
97−static void bin_emit_endnode(void *e, const char *label)
97+static void bin_emit_endnode(void *e, struct label *labels)
9898 {
9999 bin_emit_cell(e, FDT_END_NODE);
100100 }
101101
102−static void bin_emit_property(void *e, const char *label)
102+static void bin_emit_property(void *e, struct label *labels)
103103 {
104104 bin_emit_cell(e, FDT_PROP);
105105 }
@@ -127,11 +127,21 @@ static void emit_offset_label(FILE *f, const char *label, int offset) · 21 unmodified lines
127127 fprintf(f, "%s\t= . + %d\n", label, offset);
128128 }
129129
130+#define ASM_EMIT_BELONG(f, fmt, ...) \
131+ { \
132+ fprintf((f), "\t.byte\t((" fmt ") >> 24) & 0xff\n", __VA_ARGS__); \
133+ fprintf((f), "\t.byte\t((" fmt ") >> 16) & 0xff\n", __VA_ARGS__); \
134+ fprintf((f), "\t.byte\t((" fmt ") >> 8) & 0xff\n", __VA_ARGS__); \
135+ fprintf((f), "\t.byte\t(" fmt ") & 0xff\n", __VA_ARGS__); \
136+ }
137+
130138 static void asm_emit_cell(void *e, cell_t val)
131139 {
132140 FILE *f = e;
133141
134− fprintf(f, "\t.long\t0x%x\n", val);
142+ fprintf(f, "\t.byte 0x%02x; .byte 0x%02x; .byte 0x%02x; .byte 0x%02x\n",
143+ (val >> 24) & 0xff, (val >> 16) & 0xff,
144+ (val >> 8) & 0xff, val & 0xff);
135145 }
136146
137147 static void asm_emit_string(void *e, char *str, int len)
@@ -156,7 +166,7 @@ static void asm_emit_align(void *e, int a) · 18 unmodified lines
156166 {
157167 FILE *f = e;
158168
159− fprintf(f, "\t.balign\t%d\n", a);
169+ fprintf(f, "\t.balign\t%d, 0\n", a);
160170 }
161171
162172 static void asm_emit_data(void *e, struct data d)
@@ -169,8 +179,7 @@ static void asm_emit_data(void *e, struct data d) · 6 unmodified lines
169179 emit_offset_label(f, m->ref, m->offset);
170180
171181 while ((d.len - off) >= sizeof(uint32_t)) {
172− fprintf(f, "\t.long\t0x%x\n",
173− fdt32_to_cpu(*((uint32_t *)(d.val+off))));
182+ asm_emit_cell(e, fdt32_to_cpu(*((uint32_t *)(d.val+off))));
174183 off += sizeof(uint32_t);
175184 }
176185
@@ -182,37 +191,43 @@ static void asm_emit_data(void *e, struct data d) · 5 unmodified lines
182191 assert(off == d.len);
183192 }
184193
185−static void asm_emit_beginnode(void *e, const char *label)
194+static void asm_emit_beginnode(void *e, struct label *labels)
186195 {
187196 FILE *f = e;
197+ struct label *l;
188198
189− if (label) {
190− fprintf(f, "\t.globl\t%s\n", label);
191− fprintf(f, "%s:\n", label);
199+ for_each_label(labels, l) {
200+ fprintf(f, "\t.globl\t%s\n", l->label);
201+ fprintf(f, "%s:\n", l->label);
192202 }
193− fprintf(f, "\t.long\tFDT_BEGIN_NODE\n");
203+ fprintf(f, "\t/* FDT_BEGIN_NODE */\n");
204+ asm_emit_cell(e, FDT_BEGIN_NODE);
194205 }
195206
196−static void asm_emit_endnode(void *e, const char *label)
207+static void asm_emit_endnode(void *e, struct label *labels)
197208 {
198209 FILE *f = e;
210+ struct label *l;
199211
200− fprintf(f, "\t.long\tFDT_END_NODE\n");
201− if (label) {
202− fprintf(f, "\t.globl\t%s_end\n", label);
203− fprintf(f, "%s_end:\n", label);
212+ fprintf(f, "\t/* FDT_END_NODE */\n");
213+ asm_emit_cell(e, FDT_END_NODE);
214+ for_each_label(labels, l) {
215+ fprintf(f, "\t.globl\t%s_end\n", l->label);
216+ fprintf(f, "%s_end:\n", l->label);
204217 }
205218 }
206219
207−static void asm_emit_property(void *e, const char *label)
220+static void asm_emit_property(void *e, struct label *labels)
208221 {
209222 FILE *f = e;
223+ struct label *l;
210224
211− if (label) {
212− fprintf(f, "\t.globl\t%s\n", label);
213− fprintf(f, "%s:\n", label);
225+ for_each_label(labels, l) {
226+ fprintf(f, "\t.globl\t%s\n", l->label);
227+ fprintf(f, "%s:\n", l->label);
214228 }
215− fprintf(f, "\t.long\tFDT_PROP\n");
229+ fprintf(f, "\t/* FDT_PROP */\n");
230+ asm_emit_cell(e, FDT_PROP);
216231 }
217232
218233 static struct emitter asm_emitter = {
@@ -248,7 +263,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, · 29 unmodified lines
248263 struct node *child;
249264 int seen_name_prop = 0;
250265
251− emit->beginnode(etarget, tree->label);
266+ emit->beginnode(etarget, tree->labels);
252267
253268 if (vi->flags & FTF_FULLPATH)
254269 emit->string(etarget, tree->fullpath, 0);
@@ -265,7 +280,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, · 10 unmodified lines
265280
266281 nameoff = stringtable_insert(strbuf, prop->name);
267282
268− emit->property(etarget, prop->label);
283+ emit->property(etarget, prop->labels);
269284 emit->cell(etarget, prop->val.len);
270285 emit->cell(etarget, nameoff);
271286
@@ -292,7 +307,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, · 20 unmodified lines
292307 flatten_tree(child, emit, etarget, strbuf, vi);
293308 }
294309
295− emit->endnode(etarget, tree->label);
310+ emit->endnode(etarget, tree->labels);
296311 }
297312
298313 static struct data flatten_reserve_list(struct reserve_info *reservelist,
@@ -413,10 +428,13 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version) · 114 unmodified lines
413428 if (padlen > 0)
414429 blob = data_append_zeroes(blob, padlen);
415430
416− fwrite(blob.val, blob.len, 1, f);
417−
418− if (ferror(f))
419− die("Error writing device tree blob: %s\n", strerror(errno));
431+ if (fwrite(blob.val, blob.len, 1, f) != 1) {
432+ if (ferror(f))
433+ die("Error writing device tree blob: %s\n",
434+ strerror(errno));
435+ else
436+ die("Short write on device tree blob\n");
437+ }
420438
421439 /*
422440 * data_merge() frees the right-hand element so only the blob
@@ -455,39 +473,44 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) · 32 unmodified lines
455473 die("Unknown device tree blob version %d\n", version);
456474
457475 fprintf(f, "/* autogenerated by dtc, do not edit */\n\n");
458− fprintf(f, "#define FDT_MAGIC 0x%x\n", FDT_MAGIC);
459− fprintf(f, "#define FDT_BEGIN_NODE 0x%x\n", FDT_BEGIN_NODE);
460− fprintf(f, "#define FDT_END_NODE 0x%x\n", FDT_END_NODE);
461− fprintf(f, "#define FDT_PROP 0x%x\n", FDT_PROP);
462− fprintf(f, "#define FDT_END 0x%x\n", FDT_END);
463− fprintf(f, "\n");
464476
465477 emit_label(f, symprefix, "blob_start");
466478 emit_label(f, symprefix, "header");
467− fprintf(f, "\t.long\tFDT_MAGIC\t\t\t\t/* magic */\n");
468− fprintf(f, "\t.long\t_%s_blob_abs_end - _%s_blob_start\t/* totalsize */\n",
469− symprefix, symprefix);
470− fprintf(f, "\t.long\t_%s_struct_start - _%s_blob_start\t/* off_dt_struct */\n",
479+ fprintf(f, "\t/* magic */\n");
480+ asm_emit_cell(f, FDT_MAGIC);
481+ fprintf(f, "\t/* totalsize */\n");
482+ ASM_EMIT_BELONG(f, "_%s_blob_abs_end - _%s_blob_start",
483+ symprefix, symprefix);
484+ fprintf(f, "\t/* off_dt_struct */\n");
485+ ASM_EMIT_BELONG(f, "_%s_struct_start - _%s_blob_start",
471486 symprefix, symprefix);
472− fprintf(f, "\t.long\t_%s_strings_start - _%s_blob_start\t/* off_dt_strings */\n",
487+ fprintf(f, "\t/* off_dt_strings */\n");
488+ ASM_EMIT_BELONG(f, "_%s_strings_start - _%s_blob_start",
473489 symprefix, symprefix);
474− fprintf(f, "\t.long\t_%s_reserve_map - _%s_blob_start\t/* off_dt_strings */\n",
490+ fprintf(f, "\t/* off_mem_rsvmap */\n");
491+ ASM_EMIT_BELONG(f, "_%s_reserve_map - _%s_blob_start",
475492 symprefix, symprefix);
476− fprintf(f, "\t.long\t%d\t\t\t\t\t/* version */\n", vi->version);
477− fprintf(f, "\t.long\t%d\t\t\t\t\t/* last_comp_version */\n",
478− vi->last_comp_version);
479−
480− if (vi->flags & FTF_BOOTCPUID)
481− fprintf(f, "\t.long\t%i\t\t\t\t\t/* boot_cpuid_phys */\n",
482− bi->boot_cpuid_phys);
493+ fprintf(f, "\t/* version */\n");
494+ asm_emit_cell(f, vi->version);
495+ fprintf(f, "\t/* last_comp_version */\n");
496+ asm_emit_cell(f, vi->last_comp_version);
497+
498+ if (vi->flags & FTF_BOOTCPUID) {
499+ fprintf(f, "\t/* boot_cpuid_phys */\n");
500+ asm_emit_cell(f, bi->boot_cpuid_phys);
501+ }
483502
484− if (vi->flags & FTF_STRTABSIZE)
485− fprintf(f, "\t.long\t_%s_strings_end - _%s_strings_start\t/* size_dt_strings */\n",
486− symprefix, symprefix);
503+ if (vi->flags & FTF_STRTABSIZE) {
504+ fprintf(f, "\t/* size_dt_strings */\n");
505+ ASM_EMIT_BELONG(f, "_%s_strings_end - _%s_strings_start",
506+ symprefix, symprefix);
507+ }
487508
488− if (vi->flags & FTF_STRUCTSIZE)
489− fprintf(f, "\t.long\t_%s_struct_end - _%s_struct_start\t/* size_dt_struct */\n",
509+ if (vi->flags & FTF_STRUCTSIZE) {
510+ fprintf(f, "\t/* size_dt_struct */\n");
511+ ASM_EMIT_BELONG(f, "_%s_struct_end - _%s_struct_start",
490512 symprefix, symprefix);
513+ }
491514
492515 /*
493516 * Reserve map entries.
@@ -505,16 +528,17 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) · 11 unmodified lines
505528 * as it appears .quad isn't available in some assemblers.
506529 */
507530 for (re = bi->reservelist; re; re = re->next) {
508− if (re->label) {
509− fprintf(f, "\t.globl\t%s\n", re->label);
510− fprintf(f, "%s:\n", re->label);
531+ struct label *l;
532+
533+ for_each_label(re->labels, l) {
534+ fprintf(f, "\t.globl\t%s\n", l->label);
535+ fprintf(f, "%s:\n", l->label);
511536 }
512− fprintf(f, "\t.long\t0x%08x, 0x%08x\n",
513− (unsigned int)(re->re.address >> 32),
514− (unsigned int)(re->re.address & 0xffffffff));
515− fprintf(f, "\t.long\t0x%08x, 0x%08x\n",
516− (unsigned int)(re->re.size >> 32),
517− (unsigned int)(re->re.size & 0xffffffff));
537+ ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.address >> 32));
538+ ASM_EMIT_BELONG(f, "0x%08x",
539+ (unsigned int)(re->re.address & 0xffffffff));
540+ ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size >> 32));
541+ ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size & 0xffffffff));
518542 }
519543 for (i = 0; i < reservenum; i++) {
520544 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
@@ -524,7 +548,9 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) · 3 unmodified lines
524548
525549 emit_label(f, symprefix, "struct_start");
526550 flatten_tree(bi->dt, &asm_emitter, f, &strbuf, vi);
527− fprintf(f, "\t.long\tFDT_END\n");
551+
552+ fprintf(f, "\t/* FDT_END */\n");
553+ asm_emit_cell(f, FDT_END);
528554 emit_label(f, symprefix, "struct_end");
529555
530556 emit_label(f, symprefix, "strings_start");
@@ -601,7 +627,7 @@ static char *flat_read_string(struct inbuf *inb) · 70 unmodified lines
601627 len++;
602628 } while ((*p++) != '\0');
603629
604− str = strdup(inb->ptr);
630+ str = xstrdup(inb->ptr);
605631
606632 inb->ptr += len;
607633
@@ -643,7 +669,7 @@ static char *flat_read_stringtable(struct inbuf *inb, int offset) · 35 unmodified lines
643669 p++;
644670 }
645671
646− return strdup(inb->base + offset);
672+ return xstrdup(inb->base + offset);
647673 }
648674
649675 static struct property *flat_read_property(struct inbuf *dtbuf,
@@ -663,7 +689,7 @@ static struct property *flat_read_property(struct inbuf *dtbuf, · 13 unmodified lines
663689
664690 val = flat_read_data(dtbuf, proplen);
665691
666− return build_property(name, val, NULL);
692+ return build_property(name, val);
667693 }
668694
669695
@@ -688,7 +714,7 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb) · 18 unmodified lines
688714 if (re.size == 0)
689715 break;
690716
691− new = build_reserve_entry(re.address, re.size, NULL);
717+ new = build_reserve_entry(re.address, re.size);
692718 reservelist = add_reserve_entry(reservelist, new);
693719 }
694720
@@ -710,7 +736,7 @@ static char *nodename_from_path(const char *ppath, const char *cpath) · 15 unmodified lines
710736 if (!streq(ppath, "/"))
711737 plen++;
712738
713− return strdup(cpath + plen);
739+ return xstrdup(cpath + plen);
714740 }
715741
716742 static struct node *unflatten_tree(struct inbuf *dtbuf,
@@ -776,7 +802,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf, · 59 unmodified lines
776802
777803 struct boot_info *dt_from_blob(const char *fname)
778804 {
779− struct dtc_file *dtcf;
805+ FILE *f;
780806 uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys;
781807 uint32_t off_dt, off_str, off_mem_rsvmap;
782808 int rc;
@@ -791,14 +817,14 @@ struct boot_info *dt_from_blob(const char *fname) · 8 unmodified lines
791817 uint32_t val;
792818 int flags = 0;
793819
794− dtcf = dtc_open_file(fname, NULL);
820+ f = srcfile_relative_open(fname, NULL);
795821
796− rc = fread(&magic, sizeof(magic), 1, dtcf->file);
797− if (ferror(dtcf->file))
822+ rc = fread(&magic, sizeof(magic), 1, f);
823+ if (ferror(f))
798824 die("Error reading DT blob magic number: %s\n",
799825 strerror(errno));
800826 if (rc < 1) {
801− if (feof(dtcf->file))
827+ if (feof(f))
802828 die("EOF reading DT blob magic number\n");
803829 else
804830 die("Mysterious short read reading magic number\n");
@@ -808,11 +834,11 @@ struct boot_info *dt_from_blob(const char *fname) · 3 unmodified lines
808834 if (magic != FDT_MAGIC)
809835 die("Blob has incorrect magic number\n");
810836
811− rc = fread(&totalsize, sizeof(totalsize), 1, dtcf->file);
812− if (ferror(dtcf->file))
837+ rc = fread(&totalsize, sizeof(totalsize), 1, f);
838+ if (ferror(f))
813839 die("Error reading DT blob size: %s\n", strerror(errno));
814840 if (rc < 1) {
815− if (feof(dtcf->file))
841+ if (feof(f))
816842 die("EOF reading DT blob size\n");
817843 else
818844 die("Mysterious short read reading blob size\n");
@@ -832,12 +858,12 @@ struct boot_info *dt_from_blob(const char *fname) · 13 unmodified lines
832858 p = blob + sizeof(magic) + sizeof(totalsize);
833859
834860 while (sizeleft) {
835− if (feof(dtcf->file))
861+ if (feof(f))
836862 die("EOF before reading %d bytes of DT blob\n",
837863 totalsize);
838864
839− rc = fread(p, 1, sizeleft, dtcf->file);
840− if (ferror(dtcf->file))
865+ rc = fread(p, 1, sizeleft, f);
866+ if (ferror(f))
841867 die("Error reading DT blob: %s\n",
842868 strerror(errno));
843869
@@ -900,7 +926,7 @@ struct boot_info *dt_from_blob(const char *fname) · 56 unmodified lines
900926
901927 free(blob);
902928
903− dtc_close_file(dtcf);
929+ fclose(f);
904930
905931 return build_boot_info(reservelist, tree, boot_cpuid_phys);
906932 }
scripts/dtc/fstree.c+5−7
@@ -58,10 +58,9 @@ static struct node *read_fstree(const char *dirname) · 57 unmodified lines
5858 "WARNING: Cannot open %s: %s\n",
5959 tmpnam, strerror(errno));
6060 } else {
61− prop = build_property(strdup(de->d_name),
61+ prop = build_property(xstrdup(de->d_name),
6262 data_copy_file(pfile,
63− st.st_size),
64− NULL);
63+ st.st_size));
6564 add_property(tree, prop);
6665 fclose(pfile);
6766 }
@@ -69,8 +68,7 @@ static struct node *read_fstree(const char *dirname) · 1 unmodified line
6968 struct node *newchild;
7069
7170 newchild = read_fstree(tmpnam);
72− newchild = name_node(newchild, strdup(de->d_name),
73− NULL);
71+ newchild = name_node(newchild, xstrdup(de->d_name));
7472 add_child(tree, newchild);
7573 }
7674
@@ -86,8 +84,8 @@ struct boot_info *dt_from_fs(const char *dirname) · 9 unmodified lines
8684 struct node *tree;
8785
8886 tree = read_fstree(dirname);
89− tree = name_node(tree, "", NULL);
87+ tree = name_node(tree, "");
9088
91− return build_boot_info(NULL, tree, 0);
89+ return build_boot_info(NULL, tree, guess_boot_cpuid(tree));
9290 }
9391
scripts/dtc/livetree.c+323−22
@@ -24,17 +24,30 @@ · 23 unmodified lines
2424 * Tree building functions
2525 */
2626
27−struct property *build_property(char *name, struct data val, char *label)
27+void add_label(struct label **labels, char *label)
28+{
29+ struct label *new;
30+
31+ /* Make sure the label isn't already there */
32+ for_each_label(*labels, new)
33+ if (streq(new->label, label))
34+ return;
35+
36+ new = xmalloc(sizeof(*new));
37+ new->label = label;
38+ new->next = *labels;
39+ *labels = new;
40+}
41+
42+struct property *build_property(char *name, struct data val)
2843 {
2944 struct property *new = xmalloc(sizeof(*new));
3045
46+ memset(new, 0, sizeof(*new));
47+
3148 new->name = name;
3249 new->val = val;
3350
34− new->next = NULL;
35−
36− new->label = label;
37−
3851 return new;
3952 }
4053
@@ -78,17 +91,82 @@ struct node *build_node(struct property *proplist, struct node *children) · 37 unmodified lines
7891 return new;
7992 }
8093
81−struct node *name_node(struct node *node, char *name, char * label)
94+struct node *name_node(struct node *node, char *name)
8295 {
8396 assert(node->name == NULL);
8497
8598 node->name = name;
8699
87− node->label = label;
88−
89100 return node;
90101 }
91102
103+struct node *merge_nodes(struct node *old_node, struct node *new_node)
104+{
105+ struct property *new_prop, *old_prop;
106+ struct node *new_child, *old_child;
107+ struct label *l;
108+
109+ /* Add new node labels to old node */
110+ for_each_label(new_node->labels, l)
111+ add_label(&old_node->labels, l->label);
112+
113+ /* Move properties from the new node to the old node. If there
114+ * is a collision, replace the old value with the new */
115+ while (new_node->proplist) {
116+ /* Pop the property off the list */
117+ new_prop = new_node->proplist;
118+ new_node->proplist = new_prop->next;
119+ new_prop->next = NULL;
120+
121+ /* Look for a collision, set new value if there is */
122+ for_each_property(old_node, old_prop) {
123+ if (streq(old_prop->name, new_prop->name)) {
124+ /* Add new labels to old property */
125+ for_each_label(new_prop->labels, l)
126+ add_label(&old_prop->labels, l->label);
127+
128+ old_prop->val = new_prop->val;
129+ free(new_prop);
130+ new_prop = NULL;
131+ break;
132+ }
133+ }
134+
135+ /* if no collision occurred, add property to the old node. */
136+ if (new_prop)
137+ add_property(old_node, new_prop);
138+ }
139+
140+ /* Move the override child nodes into the primary node. If
141+ * there is a collision, then merge the nodes. */
142+ while (new_node->children) {
143+ /* Pop the child node off the list */
144+ new_child = new_node->children;
145+ new_node->children = new_child->next_sibling;
146+ new_child->parent = NULL;
147+ new_child->next_sibling = NULL;
148+
149+ /* Search for a collision. Merge if there is */
150+ for_each_child(old_node, old_child) {
151+ if (streq(old_child->name, new_child->name)) {
152+ merge_nodes(old_child, new_child);
153+ new_child = NULL;
154+ break;
155+ }
156+ }
157+
158+ /* if no collision occured, add child to the old node. */
159+ if (new_child)
160+ add_child(old_node, new_child);
161+ }
162+
163+ /* The new node contents are now merged into the old node. Free
164+ * the new node. */
165+ free(new_node);
166+
167+ return old_node;
168+}
169+
92170 struct node *chain_node(struct node *first, struct node *list)
93171 {
94172 assert(first->next_sibling == NULL);
@@ -124,18 +202,15 @@ void add_child(struct node *parent, struct node *child) · 29 unmodified lines
124202 *p = child;
125203 }
126204
127−struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size,
128− char *label)
205+struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size)
129206 {
130207 struct reserve_info *new = xmalloc(sizeof(*new));
131208
209+ memset(new, 0, sizeof(*new));
210+
132211 new->re.address = address;
133212 new->re.size = size;
134213
135− new->next = NULL;
136−
137− new->label = label;
138−
139214 return new;
140215 }
141216
@@ -208,6 +283,60 @@ cell_t propval_cell(struct property *prop) · 66 unmodified lines
208283 return fdt32_to_cpu(*((cell_t *)prop->val.val));
209284 }
210285
286+struct property *get_property_by_label(struct node *tree, const char *label,
287+ struct node **node)
288+{
289+ struct property *prop;
290+ struct node *c;
291+
292+ *node = tree;
293+
294+ for_each_property(tree, prop) {
295+ struct label *l;
296+
297+ for_each_label(prop->labels, l)
298+ if (streq(l->label, label))
299+ return prop;
300+ }
301+
302+ for_each_child(tree, c) {
303+ prop = get_property_by_label(c, label, node);
304+ if (prop)
305+ return prop;
306+ }
307+
308+ *node = NULL;
309+ return NULL;
310+}
311+
312+struct marker *get_marker_label(struct node *tree, const char *label,
313+ struct node **node, struct property **prop)
314+{
315+ struct marker *m;
316+ struct property *p;
317+ struct node *c;
318+
319+ *node = tree;
320+
321+ for_each_property(tree, p) {
322+ *prop = p;
323+ m = p->val.markers;
324+ for_each_marker_of_type(m, LABEL)
325+ if (streq(m->ref, label))
326+ return m;
327+ }
328+
329+ for_each_child(tree, c) {
330+ m = get_marker_label(c, label, node, prop);
331+ if (m)
332+ return m;
333+ }
334+
335+ *prop = NULL;
336+ *node = NULL;
337+ return NULL;
338+}
339+
211340 struct node *get_subnode(struct node *node, const char *nodename)
212341 {
213342 struct node *child;
@@ -245,11 +374,13 @@ struct node *get_node_by_path(struct node *tree, const char *path) · 31 unmodified lines
245374 struct node *get_node_by_label(struct node *tree, const char *label)
246375 {
247376 struct node *child, *node;
377+ struct label *l;
248378
249379 assert(label && (strlen(label) > 0));
250380
251− if (tree->label && streq(tree->label, label))
252− return tree;
381+ for_each_label(tree->labels, l)
382+ if (streq(l->label, label))
383+ return tree;
253384
254385 for_each_child(tree, child) {
255386 node = get_node_by_label(child, label);
@@ -293,16 +424,186 @@ cell_t get_node_phandle(struct node *root, struct node *node) · 37 unmodified lines
293424 if ((node->phandle != 0) && (node->phandle != -1))
294425 return node->phandle;
295426
296− assert(! get_property(node, "linux,phandle"));
297−
298427 while (get_node_by_phandle(root, phandle))
299428 phandle++;
300429
301430 node->phandle = phandle;
302− add_property(node,
303− build_property("linux,phandle",
304− data_append_cell(empty_data, phandle),
305− NULL));
431+
432+ if (!get_property(node, "linux,phandle")
433+ && (phandle_format & PHANDLE_LEGACY))
434+ add_property(node,
435+ build_property("linux,phandle",
436+ data_append_cell(empty_data, phandle)));
437+
438+ if (!get_property(node, "phandle")
439+ && (phandle_format & PHANDLE_EPAPR))
440+ add_property(node,
441+ build_property("phandle",
442+ data_append_cell(empty_data, phandle)));
443+
444+ /* If the node *does* have a phandle property, we must
445+ * be dealing with a self-referencing phandle, which will be
446+ * fixed up momentarily in the caller */
306447
307448 return node->phandle;
308449 }
450+
451+uint32_t guess_boot_cpuid(struct node *tree)
452+{
453+ struct node *cpus, *bootcpu;
454+ struct property *reg;
455+
456+ cpus = get_node_by_path(tree, "/cpus");
457+ if (!cpus)
458+ return 0;
459+
460+
461+ bootcpu = cpus->children;
462+ if (!bootcpu)
463+ return 0;
464+
465+ reg = get_property(bootcpu, "reg");
466+ if (!reg || (reg->val.len != sizeof(uint32_t)))
467+ return 0;
468+
469+ /* FIXME: Sanity check node? */
470+
471+ return propval_cell(reg);
472+}
473+
474+static int cmp_reserve_info(const void *ax, const void *bx)
475+{
476+ const struct reserve_info *a, *b;
477+
478+ a = *((const struct reserve_info * const *)ax);
479+ b = *((const struct reserve_info * const *)bx);
480+
481+ if (a->re.address < b->re.address)
482+ return -1;
483+ else if (a->re.address > b->re.address)
484+ return 1;
485+ else if (a->re.size < b->re.size)
486+ return -1;
487+ else if (a->re.size > b->re.size)
488+ return 1;
489+ else
490+ return 0;
491+}
492+
493+static void sort_reserve_entries(struct boot_info *bi)
494+{
495+ struct reserve_info *ri, **tbl;
496+ int n = 0, i = 0;
497+
498+ for (ri = bi->reservelist;
499+ ri;
500+ ri = ri->next)
501+ n++;
502+
503+ if (n == 0)
504+ return;
505+
506+ tbl = xmalloc(n * sizeof(*tbl));
507+
508+ for (ri = bi->reservelist;
509+ ri;
510+ ri = ri->next)
511+ tbl[i++] = ri;
512+
513+ qsort(tbl, n, sizeof(*tbl), cmp_reserve_info);
514+
515+ bi->reservelist = tbl[0];
516+ for (i = 0; i < (n-1); i++)
517+ tbl[i]->next = tbl[i+1];
518+ tbl[n-1]->next = NULL;
519+
520+ free(tbl);
521+}
522+
523+static int cmp_prop(const void *ax, const void *bx)
524+{
525+ const struct property *a, *b;
526+
527+ a = *((const struct property * const *)ax);
528+ b = *((const struct property * const *)bx);
529+
530+ return strcmp(a->name, b->name);
531+}
532+
533+static void sort_properties(struct node *node)
534+{
535+ int n = 0, i = 0;
536+ struct property *prop, **tbl;
537+
538+ for_each_property(node, prop)
539+ n++;
540+
541+ if (n == 0)
542+ return;
543+
544+ tbl = xmalloc(n * sizeof(*tbl));
545+
546+ for_each_property(node, prop)
547+ tbl[i++] = prop;
548+
549+ qsort(tbl, n, sizeof(*tbl), cmp_prop);
550+
551+ node->proplist = tbl[0];
552+ for (i = 0; i < (n-1); i++)
553+ tbl[i]->next = tbl[i+1];
554+ tbl[n-1]->next = NULL;
555+
556+ free(tbl);
557+}
558+
559+static int cmp_subnode(const void *ax, const void *bx)
560+{
561+ const struct node *a, *b;
562+
563+ a = *((const struct node * const *)ax);
564+ b = *((const struct node * const *)bx);
565+
566+ return strcmp(a->name, b->name);
567+}
568+
569+static void sort_subnodes(struct node *node)
570+{
571+ int n = 0, i = 0;
572+ struct node *subnode, **tbl;
573+
574+ for_each_child(node, subnode)
575+ n++;
576+
577+ if (n == 0)
578+ return;
579+
580+ tbl = xmalloc(n * sizeof(*tbl));
581+
582+ for_each_child(node, subnode)
583+ tbl[i++] = subnode;
584+
585+ qsort(tbl, n, sizeof(*tbl), cmp_subnode);
586+
587+ node->children = tbl[0];
588+ for (i = 0; i < (n-1); i++)
589+ tbl[i]->next_sibling = tbl[i+1];
590+ tbl[n-1]->next_sibling = NULL;
591+
592+ free(tbl);
593+}
594+
595+static void sort_node(struct node *node)
596+{
597+ struct node *c;
598+
599+ sort_properties(node);
600+ sort_subnodes(node);
601+ for_each_child(node, c)
602+ sort_node(c);
603+}
604+
605+void sort_tree(struct boot_info *bi)
606+{
607+ sort_reserve_entries(bi);
608+ sort_node(bi->dt);
609+}
scripts/dtc/srcpos.c+195−63
@@ -17,100 +17,232 @@ · 16 unmodified lines
1717 * USA
1818 */
1919
20+#define _GNU_SOURCE
21+
22+#include <stdio.h>
23+
2024 #include "dtc.h"
2125 #include "srcpos.h"
2226
23−/*
24− * Like yylineno, this is the current open file pos.
25− */
2627
27−struct dtc_file *srcpos_file;
28+static char *dirname(const char *path)
29+{
30+ const char *slash = strrchr(path, '/');
31+
32+ if (slash) {
33+ int len = slash - path;
34+ char *dir = xmalloc(len + 1);
35+
36+ memcpy(dir, path, len);
37+ dir[len] = '\0';
38+ return dir;
39+ }
40+ return NULL;
41+}
42+
43+struct srcfile_state *current_srcfile; /* = NULL */
2844
29−static int dtc_open_one(struct dtc_file *file,
30− const char *search,
31− const char *fname)
45+/* Detect infinite include recursion. */
46+#define MAX_SRCFILE_DEPTH (100)
47+static int srcfile_depth; /* = 0 */
48+
49+FILE *srcfile_relative_open(const char *fname, char **fullnamep)
3250 {
51+ FILE *f;
3352 char *fullname;
3453
35− if (search) {
36− fullname = xmalloc(strlen(search) + strlen(fname) + 2);
37−
38− strcpy(fullname, search);
39− strcat(fullname, "/");
40− strcat(fullname, fname);
54+ if (streq(fname, "-")) {
55+ f = stdin;
56+ fullname = xstrdup("<stdin>");
4157 } else {
42− fullname = strdup(fname);
58+ if (!current_srcfile || !current_srcfile->dir
59+ || (fname[0] == '/'))
60+ fullname = xstrdup(fname);
61+ else
62+ fullname = join_path(current_srcfile->dir, fname);
63+
64+ f = fopen(fullname, "r");
65+ if (!f)
66+ die("Couldn't open \"%s\": %s\n", fname,
67+ strerror(errno));
4368 }
4469
45− file->file = fopen(fullname, "r");
46− if (!file->file) {
70+ if (fullnamep)
71+ *fullnamep = fullname;
72+ else
4773 free(fullname);
48− return 0;
49− }
5074
51− file->name = fullname;
52− return 1;
75+ return f;
5376 }
5477
78+void srcfile_push(const char *fname)
79+{
80+ struct srcfile_state *srcfile;
81+
82+ if (srcfile_depth++ >= MAX_SRCFILE_DEPTH)
83+ die("Includes nested too deeply");
84+
85+ srcfile = xmalloc(sizeof(*srcfile));
86+
87+ srcfile->f = srcfile_relative_open(fname, &srcfile->name);
88+ srcfile->dir = dirname(srcfile->name);
89+ srcfile->prev = current_srcfile;
90+
91+ srcfile->lineno = 1;
92+ srcfile->colno = 1;
93+
94+ current_srcfile = srcfile;
95+}
5596
56−struct dtc_file *dtc_open_file(const char *fname,
57− const struct search_path *search)
97+int srcfile_pop(void)
5898 {
59− static const struct search_path default_search = { NULL, NULL, NULL };
99+ struct srcfile_state *srcfile = current_srcfile;
60100
61− struct dtc_file *file;
62− const char *slash;
101+ assert(srcfile);
63102
64− file = xmalloc(sizeof(struct dtc_file));
103+ current_srcfile = srcfile->prev;
65104
66− slash = strrchr(fname, '/');
67− if (slash) {
68− char *dir = xmalloc(slash - fname + 1);
105+ if (fclose(srcfile->f))
106+ die("Error closing \"%s\": %s\n", srcfile->name,
107+ strerror(errno));
69108
70− memcpy(dir, fname, slash - fname);
71− dir[slash - fname] = 0;
72− file->dir = dir;
73− } else {
74− file->dir = NULL;
75− }
109+ /* FIXME: We allow the srcfile_state structure to leak,
110+ * because it could still be referenced from a location
111+ * variable being carried through the parser somewhere. To
112+ * fix this we could either allocate all the files from a
113+ * table, or use a pool allocator. */
76114
77− if (streq(fname, "-")) {
78− file->name = "stdin";
79− file->file = stdin;
80− return file;
81− }
115+ return current_srcfile ? 1 : 0;
116+}
82117
83− if (fname[0] == '/') {
84− file->file = fopen(fname, "r");
85− if (!file->file)
86− goto fail;
118+/*
119+ * The empty source position.
120+ */
87121
88− file->name = strdup(fname);
89− return file;
90− }
122+struct srcpos srcpos_empty = {
123+ .first_line = 0,
124+ .first_column = 0,
125+ .last_line = 0,
126+ .last_column = 0,
127+ .file = NULL,
128+};
91129
92− if (!search)
93− search = &default_search;
130+#define TAB_SIZE 8
94131
95− while (search) {
96− if (dtc_open_one(file, search->dir, fname))
97− return file;
132+void srcpos_update(struct srcpos *pos, const char *text, int len)
133+{
134+ int i;
135+
136+ pos->file = current_srcfile;
137+
138+ pos->first_line = current_srcfile->lineno;
139+ pos->first_column = current_srcfile->colno;
140+
141+ for (i = 0; i < len; i++)
142+ if (text[i] == '\n') {
143+ current_srcfile->lineno++;
144+ current_srcfile->colno = 1;
145+ } else if (text[i] == '\t') {
146+ current_srcfile->colno =
147+ ALIGN(current_srcfile->colno, TAB_SIZE);
148+ } else {
149+ current_srcfile->colno++;
150+ }
151+
152+ pos->last_line = current_srcfile->lineno;
153+ pos->last_column = current_srcfile->colno;
154+}
98155
99− if (errno != ENOENT)
100− goto fail;
156+struct srcpos *
157+srcpos_copy(struct srcpos *pos)
158+{
159+ struct srcpos *pos_new;
101160
102− search = search->next;
103− }
161+ pos_new = xmalloc(sizeof(struct srcpos));
162+ memcpy(pos_new, pos, sizeof(struct srcpos));
163+
164+ return pos_new;
165+}
166+
167+
168+
169+void
170+srcpos_dump(struct srcpos *pos)
171+{
172+ printf("file : \"%s\"\n",
173+ pos->file ? (char *) pos->file : "<no file>");
174+ printf("first_line : %d\n", pos->first_line);
175+ printf("first_column: %d\n", pos->first_column);
176+ printf("last_line : %d\n", pos->last_line);
177+ printf("last_column : %d\n", pos->last_column);
178+ printf("file : %s\n", pos->file->name);
179+}
104180
105−fail:
106− die("Couldn't open \"%s\": %s\n", fname, strerror(errno));
181+
182+char *
183+srcpos_string(struct srcpos *pos)
184+{
185+ const char *fname = "<no-file>";
186+ char *pos_str;
187+ int rc;
188+
189+ if (pos)
190+ fname = pos->file->name;
191+
192+
193+ if (pos->first_line != pos->last_line)
194+ rc = asprintf(&pos_str, "%s:%d.%d-%d.%d", fname,
195+ pos->first_line, pos->first_column,
196+ pos->last_line, pos->last_column);
197+ else if (pos->first_column != pos->last_column)
198+ rc = asprintf(&pos_str, "%s:%d.%d-%d", fname,
199+ pos->first_line, pos->first_column,
200+ pos->last_column);
201+ else
202+ rc = asprintf(&pos_str, "%s:%d.%d", fname,
203+ pos->first_line, pos->first_column);
204+
205+ if (rc == -1)
206+ die("Couldn't allocate in srcpos string");
207+
208+ return pos_str;
209+}
210+
211+void
212+srcpos_verror(struct srcpos *pos, char const *fmt, va_list va)
213+{
214+ const char *srcstr;
215+
216+ srcstr = srcpos_string(pos);
217+
218+ fprintf(stdout, "Error: %s ", srcstr);
219+ vfprintf(stdout, fmt, va);
220+ fprintf(stdout, "\n");
107221 }
108222
109−void dtc_close_file(struct dtc_file *file)
223+void
224+srcpos_error(struct srcpos *pos, char const *fmt, ...)
110225 {
111− if (fclose(file->file))
112− die("Error closing \"%s\": %s\n", file->name, strerror(errno));
226+ va_list va;
227+
228+ va_start(va, fmt);
229+ srcpos_verror(pos, fmt, va);
230+ va_end(va);
231+}
232+
233+
234+void
235+srcpos_warn(struct srcpos *pos, char const *fmt, ...)
236+{
237+ const char *srcstr;
238+ va_list va;
239+ va_start(va, fmt);
240+
241+ srcstr = srcpos_string(pos);
242+
243+ fprintf(stderr, "Warning: %s ", srcstr);
244+ vfprintf(stderr, fmt, va);
245+ fprintf(stderr, "\n");
113246
114− free(file->dir);
115− free(file);
247+ va_end(va);
116248 }
scripts/dtc/srcpos.h+50−49
@@ -17,69 +17,70 @@ · 16 unmodified lines
1717 * USA
1818 */
1919
20−/*
21− * Augment the standard YYLTYPE with a filenum index into an
22− * array of all opened filenames.
23− */
20+#ifndef _SRCPOS_H_
21+#define _SRCPOS_H_
2422
2523 #include <stdio.h>
2624
27−struct dtc_file {
25+struct srcfile_state {
26+ FILE *f;
27+ char *name;
2828 char *dir;
29− const char *name;
30− FILE *file;
29+ int lineno, colno;
30+ struct srcfile_state *prev;
3131 };
3232
33−#if ! defined(YYLTYPE) && ! defined(YYLTYPE_IS_DECLARED)
34−typedef struct YYLTYPE {
33+extern struct srcfile_state *current_srcfile; /* = NULL */
34+
35+FILE *srcfile_relative_open(const char *fname, char **fullnamep);
36+void srcfile_push(const char *fname);
37+int srcfile_pop(void);
38+
39+struct srcpos {
3540 int first_line;
3641 int first_column;
3742 int last_line;
3843 int last_column;
39− struct dtc_file *file;
40−} YYLTYPE;
41−
42−#define YYLTYPE_IS_DECLARED 1
43−#define YYLTYPE_IS_TRIVIAL 1
44−#endif
45−
46−/* Cater to old parser templates. */
47−#ifndef YYID
48−#define YYID(n) (n)
49−#endif
44+ struct srcfile_state *file;
45+};
5046
51−#define YYLLOC_DEFAULT(Current, Rhs, N) \
52− do \
53− if (YYID (N)) \
54− { \
55− (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
56− (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
57− (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
58− (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
59− (Current).file = YYRHSLOC (Rhs, N).file; \
60− } \
61− else \
62− { \
63− (Current).first_line = (Current).last_line = \
64− YYRHSLOC (Rhs, 0).last_line; \
65− (Current).first_column = (Current).last_column = \
66− YYRHSLOC (Rhs, 0).last_column; \
67− (Current).file = YYRHSLOC (Rhs, 0).file; \
68− } \
69− while (YYID (0))
47+#define YYLTYPE struct srcpos
7048
49+#define YYLLOC_DEFAULT(Current, Rhs, N) \
50+ do { \
51+ if (N) { \
52+ (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
53+ (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
54+ (Current).last_line = YYRHSLOC(Rhs, N).last_line; \
55+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
56+ (Current).file = YYRHSLOC(Rhs, N).file; \
57+ } else { \
58+ (Current).first_line = (Current).last_line = \
59+ YYRHSLOC(Rhs, 0).last_line; \
60+ (Current).first_column = (Current).last_column = \
61+ YYRHSLOC(Rhs, 0).last_column; \
62+ (Current).file = YYRHSLOC (Rhs, 0).file; \
63+ } \
64+ } while (0)
7165
7266
73−extern void yyerror(char const *);
74−extern void yyerrorf(char const *, ...) __attribute__((format(printf, 1, 2)));
67+/*
68+ * Fictional source position used for IR nodes that are
69+ * created without otherwise knowing a true source position.
70+ * For example,constant definitions from the command line.
71+ */
72+extern struct srcpos srcpos_empty;
7573
76−extern struct dtc_file *srcpos_file;
74+extern void srcpos_update(struct srcpos *pos, const char *text, int len);
75+extern struct srcpos *srcpos_copy(struct srcpos *pos);
76+extern char *srcpos_string(struct srcpos *pos);
77+extern void srcpos_dump(struct srcpos *pos);
7778
78−struct search_path {
79− const char *dir; /* NULL for current directory */
80− struct search_path *prev, *next;
81−};
79+extern void srcpos_verror(struct srcpos *pos, char const *, va_list va)
80+ __attribute__((format(printf, 2, 0)));
81+extern void srcpos_error(struct srcpos *pos, char const *, ...)
82+ __attribute__((format(printf, 2, 3)));
83+extern void srcpos_warn(struct srcpos *pos, char const *, ...)
84+ __attribute__((format(printf, 2, 3)));
8285
83−extern struct dtc_file *dtc_open_file(const char *fname,
84− const struct search_path *search);
85−extern void dtc_close_file(struct dtc_file *file);
86+#endif /* _SRCPOS_H_ */
scripts/dtc/treesource.c+26−22
@@ -32,8 +32,8 @@ struct boot_info *dt_from_source(const char *fname) · 31 unmodified lines
3232 the_boot_info = NULL;
3333 treesource_error = 0;
3434
35− srcpos_file = dtc_open_file(fname, NULL);
36− yyin = srcpos_file->file;
35+ srcfile_push(fname);
36+ yyin = current_srcfile->f;
3737
3838 if (yyparse() != 0)
3939 die("Unable to parse input tree\n");
@@ -63,26 +63,20 @@ static void write_propval_string(FILE *f, struct data val) · 23 unmodified lines
6363 {
6464 const char *str = val.val;
6565 int i;
66− int newchunk = 1;
6766 struct marker *m = val.markers;
6867
6968 assert(str[val.len-1] == '\0');
7069
70+ while (m && (m->offset == 0)) {
71+ if (m->type == LABEL)
72+ fprintf(f, "%s: ", m->ref);
73+ m = m->next;
74+ }
75+ fprintf(f, "\"");
76+
7177 for (i = 0; i < (val.len-1); i++) {
7278 char c = str[i];
7379
74− if (newchunk) {
75− while (m && (m->offset <= i)) {
76− if (m->type == LABEL) {
77− assert(m->offset == i);
78− fprintf(f, "%s: ", m->ref);
79− }
80− m = m->next;
81− }
82− fprintf(f, "\"");
83− newchunk = 0;
84− }
85−
8680 switch (c) {
8781 case '\a':
8882 fprintf(f, "\\a");
@@ -113,7 +107,14 @@ static void write_propval_string(FILE *f, struct data val) · 24 unmodified lines
113107 break;
114108 case '\0':
115109 fprintf(f, "\", ");
116− newchunk = 1;
110+ while (m && (m->offset < i)) {
111+ if (m->type == LABEL) {
112+ assert(m->offset == (i+1));
113+ fprintf(f, "%s: ", m->ref);
114+ }
115+ m = m->next;
116+ }
117+ fprintf(f, "\"");
117118 break;
118119 default:
119120 if (isprint(c))
@@ -234,10 +235,11 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level) · 114 unmodified lines
234235 {
235236 struct property *prop;
236237 struct node *child;
238+ struct label *l;
237239
238240 write_prefix(f, level);
239− if (tree->label)
240− fprintf(f, "%s: ", tree->label);
241+ for_each_label(tree->labels, l)
242+ fprintf(f, "%s: ", l->label);
241243 if (tree->name && (*tree->name))
242244 fprintf(f, "%s {\n", tree->name);
243245 else
@@ -245,8 +247,8 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level) · 1 unmodified line
245247
246248 for_each_property(tree, prop) {
247249 write_prefix(f, level+1);
248− if (prop->label)
249− fprintf(f, "%s: ", prop->label);
250+ for_each_label(prop->labels, l)
251+ fprintf(f, "%s: ", l->label);
250252 fprintf(f, "%s", prop->name);
251253 write_propval(f, prop);
252254 }
@@ -266,8 +268,10 @@ void dt_to_source(FILE *f, struct boot_info *bi) · 13 unmodified lines
266268 fprintf(f, "/dts-v1/;\n\n");
267269
268270 for (re = bi->reservelist; re; re = re->next) {
269− if (re->label)
270− fprintf(f, "%s: ", re->label);
271+ struct label *l;
272+
273+ for_each_label(re->labels, l)
274+ fprintf(f, "%s: ", l->label);
271275 fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n",
272276 (unsigned long long)re->re.address,
273277 (unsigned long long)re->re.size);
scripts/dtc/util.c+59−0
@@ -0,0 +1,59 @@
1+/*
2+ * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
3+ *
4+ * This program is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU General Public License as
6+ * published by the Free Software Foundation; either version 2 of the
7+ * License, or (at your option) any later version.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ * General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program; if not, write to the Free Software
16+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17+ * USA
18+ */
19+
20+#include <stdio.h>
21+#include <stdlib.h>
22+#include <stdarg.h>
23+#include <string.h>
24+
25+#include "util.h"
26+
27+char *xstrdup(const char *s)
28+{
29+ int len = strlen(s) + 1;
30+ char *dup = xmalloc(len);
31+
32+ memcpy(dup, s, len);
33+
34+ return dup;
35+}
36+
37+char *join_path(const char *path, const char *name)
38+{
39+ int lenp = strlen(path);
40+ int lenn = strlen(name);
41+ int len;
42+ int needslash = 1;
43+ char *str;
44+
45+ len = lenp + lenn + 2;
46+ if ((lenp > 0) && (path[lenp-1] == '/')) {
47+ needslash = 0;
48+ len--;
49+ }
50+
51+ str = xmalloc(len);
52+ memcpy(str, path, lenp);
53+ if (needslash) {
54+ str[lenp] = '/';
55+ lenp++;
56+ }
57+ memcpy(str+lenp, name, lenn+1);
58+ return str;
59+}
scripts/dtc/util.h+56−0
@@ -0,0 +1,56 @@
1+#ifndef _UTIL_H
2+#define _UTIL_H
3+
4+/*
5+ * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License as
9+ * published by the Free Software Foundation; either version 2 of the
10+ * License, or (at your option) any later version.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+ * General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program; if not, write to the Free Software
19+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20+ * USA
21+ */
22+
23+static inline void __attribute__((noreturn)) die(char * str, ...)
24+{
25+ va_list ap;
26+
27+ va_start(ap, str);
28+ fprintf(stderr, "FATAL ERROR: ");
29+ vfprintf(stderr, str, ap);
30+ exit(1);
31+}
32+
33+static inline void *xmalloc(size_t len)
34+{
35+ void *new = malloc(len);
36+
37+ if (!new)
38+ die("malloc() failed\n");
39+
40+ return new;
41+}
42+
43+static inline void *xrealloc(void *p, size_t len)
44+{
45+ void *new = realloc(p, len);
46+
47+ if (!new)
48+ die("realloc() failed (len=%d)\n", len);
49+
50+ return new;
51+}
52+
53+extern char *xstrdup(const char *s);
54+extern char *join_path(const char *path, const char *name);
55+
56+#endif /* _UTIL_H */
scripts/dtc/version_gen.h+1−1
@@ -1 +1 @@
1−#define DTC_VERSION "DTC 1.2.0"
1+#define DTC_VERSION "DTC 1.2.0-g37c0b6a0"