aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2017-01-04 11:45:20 -0500
committerRob Herring <robh@kernel.org>2017-01-04 11:47:53 -0500
commit6f05afcbb031722ec1eff77dde188ff2edf8940e (patch)
tree495052132dcba998f88e38d128d9781adfdc9272
parent0c744ea4f77d72b3dcebb7a8f2684633ec79be88 (diff)
scripts/dtc: Update to upstream version 0931cea3ba20
Sync to upstream dtc commit 0931cea3ba20 ("dtc: fdtdump: check fdt if not in scanning mode"). In particular, this pulls in dtc overlay support. This adds the following commits from upstream: f88865469b65 dtc: Fix memory leak in character literal parsing 00fbb8696b66 Rename boot_info 1ef86ad2c24f dtc: Clean up /dts-v1/ and /plugin/ handling in grammar e3c769aa9c16 dtc: Don't always generate __symbols__ for plugins c96cb3c0169e tests: Don't use -@ on plugin de/recompile tests 66381538ce24 tests: Remove "suppression of fixups" tests ba765b273f0f tests: Clarify dtc overlay tests 6ea8cd944fcd tests: More thorough tests of libfdt overlay application without dtc 7d8ef6e1db97 tests: Correct fdt handling of overlays without fixups and base trees without symbols b4dc0ed8b127 tests: Fix double expansion bugs in test code 3ea879dc0c8f tests: Split overlay tests into those with do/don't exercise dtc plugin generation 47b4d66a2f11 tests: Test auto-alias generation on base tree, not overlay 72e1ad811523 tests: Make overlay/plugin tests unconditional e7b3c3b5951b tests: Add overlay tests 9637e3f772a9 tests: Add check_path test 20f29d8d41f6 dtc: Plugin and fixup support a2c92cac53f8 dtc: Document the dynamic plugin internals 8f70ac39801d checks: Pass boot_info instead of root node ea10f953878f libfdt: add missing errors to fdt_strerror() daa75e8fa594 libfdt: fix fdt_stringlist_search() e28eff5b787a libfdt: fix fdt_stringlist_count() ae97c7722840 tests: overlay: Rename the device tree blobs to be more explicit 96162d2bd9cb tests: overlay: Add test suffix to the compiled blobs 5ce8634733b7 libfdt: Add fdt_overlay_apply to the exported symbols 804a9db90ad2 fdt: strerr: Remove spurious BADOVERLAY e8c3a1a493fa tests: overlay: Move back the bad fixup tests 7a72d89d3f81 libfdt: overlay: Fix symbols and fixups nodes condition cabbaa972cdd libfdt: overlay: Report a bad overlay for mismatching local fixups deb0a5c1aeaa libfdt: Add BADPHANDLE error string 7b7a6be9ba15 libfdt: Don't use 'index' as a local variable name aea8860d831e tests: Add tests cases for the overlay code 0cdd06c5135b libfdt: Add overlay application function 39240cc865cf libfdt: Extend the reach of FDT_ERR_BADPHANDLE 4aa3a6f5e6d9 libfdt: Add new errors for the overlay code 6d1832c9e64b dtc: Remove "home page" link 45fd440a9561 Fix some typing errors in libfdt.h and livetree.c a59be4939c13 Merge tag 'v1.4.2' a34bb721caca dtc: Fix assorted problems in the testcases for the -a option 874f40588d3e Implement the -a option to pad dtb aligned ec02b34c05be dtc: Makefile improvements for release uploading 1ed45d40a137 dtc: Bump version to 1.4.2 36fd7331fb11 libfdt: simplify fdt_del_mem_rsv() d877364e4a0f libfdt: Add fdt_setprop_inplace_namelen_partial 3e9037aaad44 libfdt: Add fdt_getprop_namelen_w 84e0e1346c68 libfdt: Add max phandle retrieval function d29126c90acb libfdt: Add iterator over properties 902d0f0953d0 libfdt: Add a subnodes iterator macro c539075ba8ba fdtput.c: Fix memory leak. f79ddb83e185 fdtget.c: Fix memory leak 1074ee54b63f convert-dtsv0-lexer.l: fix memory leak e24d39a024e6 fdtdump.c: make sure size_t argument to memchr is always unsigned. 44a59713cf05 Remove unused srcpos_dump() function cb9241ae3453 DTC: Fix memory leak on flatname. 1ee0ae24ea09 Simplify check field and macro names 9d97527a8621 Remove property check functions 2e709d158e11 Remove tree check functions c4cb12e193e3 Alter grammar to allow multiple /dts-v1/ tags d71d25d76012 Use xasprintf() in srcpos 9dc404958e9c util: Add xasprintf portable asprintf variant beef80b8b55f Correct a missing space in a fdt_header cast 68d43cec1253 Correct line lengths in libfdt.h b0dbceafd49a Correct space-after-tab in libfdt.h Signed-off-by: Rob Herring <robh@kernel.org>
-rw-r--r--scripts/dtc/checks.c349
-rw-r--r--scripts/dtc/dtc-lexer.l21
-rw-r--r--scripts/dtc/dtc-lexer.lex.c_shipped650
-rw-r--r--scripts/dtc/dtc-parser.tab.c_shipped752
-rw-r--r--scripts/dtc/dtc-parser.tab.h_shipped54
-rw-r--r--scripts/dtc/dtc-parser.y34
-rw-r--r--scripts/dtc/dtc.c69
-rw-r--r--scripts/dtc/dtc.h39
-rw-r--r--scripts/dtc/flattree.c41
-rw-r--r--scripts/dtc/fstree.c5
-rw-r--r--scripts/dtc/libfdt/Makefile.libfdt2
-rw-r--r--scripts/dtc/libfdt/fdt_ro.c30
-rw-r--r--scripts/dtc/libfdt/fdt_rw.c6
-rw-r--r--scripts/dtc/libfdt/fdt_strerror.c6
-rw-r--r--scripts/dtc/libfdt/fdt_wip.c29
-rw-r--r--scripts/dtc/libfdt/libfdt.h210
-rw-r--r--scripts/dtc/libfdt/libfdt_env.h1
-rw-r--r--scripts/dtc/livetree.c299
-rw-r--r--scripts/dtc/srcpos.c35
-rw-r--r--scripts/dtc/srcpos.h1
-rw-r--r--scripts/dtc/treesource.c14
-rw-r--r--scripts/dtc/util.c30
-rw-r--r--scripts/dtc/util.h1
-rw-r--r--scripts/dtc/version_gen.h2
24 files changed, 1661 insertions, 1019 deletions
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
index 386f9563313f..3d18e45374c8 100644
--- a/scripts/dtc/checks.c
+++ b/scripts/dtc/checks.c
@@ -40,16 +40,11 @@ enum checkstatus {
40 40
41struct check; 41struct check;
42 42
43typedef void (*tree_check_fn)(struct check *c, struct node *dt); 43typedef void (*check_fn)(struct check *c, struct dt_info *dti, struct node *node);
44typedef void (*node_check_fn)(struct check *c, struct node *dt, struct node *node);
45typedef void (*prop_check_fn)(struct check *c, struct node *dt,
46 struct node *node, struct property *prop);
47 44
48struct check { 45struct check {
49 const char *name; 46 const char *name;
50 tree_check_fn tree_fn; 47 check_fn fn;
51 node_check_fn node_fn;
52 prop_check_fn prop_fn;
53 void *data; 48 void *data;
54 bool warn, error; 49 bool warn, error;
55 enum checkstatus status; 50 enum checkstatus status;
@@ -58,45 +53,24 @@ struct check {
58 struct check **prereq; 53 struct check **prereq;
59}; 54};
60 55
61#define CHECK_ENTRY(nm, tfn, nfn, pfn, d, w, e, ...) \ 56#define CHECK_ENTRY(_nm, _fn, _d, _w, _e, ...) \
62 static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \ 57 static struct check *_nm##_prereqs[] = { __VA_ARGS__ }; \
63 static struct check nm = { \ 58 static struct check _nm = { \
64 .name = #nm, \ 59 .name = #_nm, \
65 .tree_fn = (tfn), \ 60 .fn = (_fn), \
66 .node_fn = (nfn), \ 61 .data = (_d), \
67 .prop_fn = (pfn), \ 62 .warn = (_w), \
68 .data = (d), \ 63 .error = (_e), \
69 .warn = (w), \
70 .error = (e), \
71 .status = UNCHECKED, \ 64 .status = UNCHECKED, \
72 .num_prereqs = ARRAY_SIZE(nm##_prereqs), \ 65 .num_prereqs = ARRAY_SIZE(_nm##_prereqs), \
73 .prereq = nm##_prereqs, \ 66 .prereq = _nm##_prereqs, \
74 }; 67 };
75#define WARNING(nm, tfn, nfn, pfn, d, ...) \ 68#define WARNING(_nm, _fn, _d, ...) \
76 CHECK_ENTRY(nm, tfn, nfn, pfn, d, true, false, __VA_ARGS__) 69 CHECK_ENTRY(_nm, _fn, _d, true, false, __VA_ARGS__)
77#define ERROR(nm, tfn, nfn, pfn, d, ...) \ 70#define ERROR(_nm, _fn, _d, ...) \
78 CHECK_ENTRY(nm, tfn, nfn, pfn, d, false, true, __VA_ARGS__) 71 CHECK_ENTRY(_nm, _fn, _d, false, true, __VA_ARGS__)
79#define CHECK(nm, tfn, nfn, pfn, d, ...) \ 72#define CHECK(_nm, _fn, _d, ...) \
80 CHECK_ENTRY(nm, tfn, nfn, pfn, d, false, false, __VA_ARGS__) 73 CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__)
81
82#define TREE_WARNING(nm, d, ...) \
83 WARNING(nm, check_##nm, NULL, NULL, d, __VA_ARGS__)
84#define TREE_ERROR(nm, d, ...) \
85 ERROR(nm, check_##nm, NULL, NULL, d, __VA_ARGS__)
86#define TREE_CHECK(nm, d, ...) \
87 CHECK(nm, check_##nm, NULL, NULL, d, __VA_ARGS__)
88#define NODE_WARNING(nm, d, ...) \
89 WARNING(nm, NULL, check_##nm, NULL, d, __VA_ARGS__)
90#define NODE_ERROR(nm, d, ...) \
91 ERROR(nm, NULL, check_##nm, NULL, d, __VA_ARGS__)
92#define NODE_CHECK(nm, d, ...) \
93 CHECK(nm, NULL, check_##nm, NULL, d, __VA_ARGS__)
94#define PROP_WARNING(nm, d, ...) \
95 WARNING(nm, NULL, NULL, check_##nm, d, __VA_ARGS__)
96#define PROP_ERROR(nm, d, ...) \
97 ERROR(nm, NULL, NULL, check_##nm, d, __VA_ARGS__)
98#define PROP_CHECK(nm, d, ...) \
99 CHECK(nm, NULL, NULL, check_##nm, d, __VA_ARGS__)
100 74
101#ifdef __GNUC__ 75#ifdef __GNUC__
102static inline void check_msg(struct check *c, const char *fmt, ...) __attribute__((format (printf, 2, 3))); 76static inline void check_msg(struct check *c, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
@@ -123,27 +97,21 @@ static inline void check_msg(struct check *c, const char *fmt, ...)
123 check_msg((c), __VA_ARGS__); \ 97 check_msg((c), __VA_ARGS__); \
124 } while (0) 98 } while (0)
125 99
126static void check_nodes_props(struct check *c, struct node *dt, struct node *node) 100static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node)
127{ 101{
128 struct node *child; 102 struct node *child;
129 struct property *prop;
130 103
131 TRACE(c, "%s", node->fullpath); 104 TRACE(c, "%s", node->fullpath);
132 if (c->node_fn) 105 if (c->fn)
133 c->node_fn(c, dt, node); 106 c->fn(c, dti, node);
134
135 if (c->prop_fn)
136 for_each_property(node, prop) {
137 TRACE(c, "%s\t'%s'", node->fullpath, prop->name);
138 c->prop_fn(c, dt, node, prop);
139 }
140 107
141 for_each_child(node, child) 108 for_each_child(node, child)
142 check_nodes_props(c, dt, child); 109 check_nodes_props(c, dti, child);
143} 110}
144 111
145static bool run_check(struct check *c, struct node *dt) 112static bool run_check(struct check *c, struct dt_info *dti)
146{ 113{
114 struct node *dt = dti->dt;
147 bool error = false; 115 bool error = false;
148 int i; 116 int i;
149 117
@@ -156,7 +124,7 @@ static bool run_check(struct check *c, struct node *dt)
156 124
157 for (i = 0; i < c->num_prereqs; i++) { 125 for (i = 0; i < c->num_prereqs; i++) {
158 struct check *prq = c->prereq[i]; 126 struct check *prq = c->prereq[i];
159 error = error || run_check(prq, dt); 127 error = error || run_check(prq, dti);
160 if (prq->status != PASSED) { 128 if (prq->status != PASSED) {
161 c->status = PREREQ; 129 c->status = PREREQ;
162 check_msg(c, "Failed prerequisite '%s'", 130 check_msg(c, "Failed prerequisite '%s'",
@@ -167,11 +135,8 @@ static bool run_check(struct check *c, struct node *dt)
167 if (c->status != UNCHECKED) 135 if (c->status != UNCHECKED)
168 goto out; 136 goto out;
169 137
170 if (c->node_fn || c->prop_fn) 138 check_nodes_props(c, dti, dt);
171 check_nodes_props(c, dt, dt);
172 139
173 if (c->tree_fn)
174 c->tree_fn(c, dt);
175 if (c->status == UNCHECKED) 140 if (c->status == UNCHECKED)
176 c->status = PASSED; 141 c->status = PASSED;
177 142
@@ -189,13 +154,14 @@ out:
189 */ 154 */
190 155
191/* A check which always fails, for testing purposes only */ 156/* A check which always fails, for testing purposes only */
192static inline void check_always_fail(struct check *c, struct node *dt) 157static inline void check_always_fail(struct check *c, struct dt_info *dti,
158 struct node *node)
193{ 159{
194 FAIL(c, "always_fail check"); 160 FAIL(c, "always_fail check");
195} 161}
196TREE_CHECK(always_fail, NULL); 162CHECK(always_fail, check_always_fail, NULL);
197 163
198static void check_is_string(struct check *c, struct node *root, 164static void check_is_string(struct check *c, struct dt_info *dti,
199 struct node *node) 165 struct node *node)
200{ 166{
201 struct property *prop; 167 struct property *prop;
@@ -210,11 +176,11 @@ static void check_is_string(struct check *c, struct node *root,
210 propname, node->fullpath); 176 propname, node->fullpath);
211} 177}
212#define WARNING_IF_NOT_STRING(nm, propname) \ 178#define WARNING_IF_NOT_STRING(nm, propname) \
213 WARNING(nm, NULL, check_is_string, NULL, (propname)) 179 WARNING(nm, check_is_string, (propname))
214#define ERROR_IF_NOT_STRING(nm, propname) \ 180#define ERROR_IF_NOT_STRING(nm, propname) \
215 ERROR(nm, NULL, check_is_string, NULL, (propname)) 181 ERROR(nm, check_is_string, (propname))
216 182
217static void check_is_cell(struct check *c, struct node *root, 183static void check_is_cell(struct check *c, struct dt_info *dti,
218 struct node *node) 184 struct node *node)
219{ 185{
220 struct property *prop; 186 struct property *prop;
@@ -229,15 +195,15 @@ static void check_is_cell(struct check *c, struct node *root,
229 propname, node->fullpath); 195 propname, node->fullpath);
230} 196}
231#define WARNING_IF_NOT_CELL(nm, propname) \ 197#define WARNING_IF_NOT_CELL(nm, propname) \
232 WARNING(nm, NULL, check_is_cell, NULL, (propname)) 198 WARNING(nm, check_is_cell, (propname))
233#define ERROR_IF_NOT_CELL(nm, propname) \ 199#define ERROR_IF_NOT_CELL(nm, propname) \
234 ERROR(nm, NULL, check_is_cell, NULL, (propname)) 200 ERROR(nm, check_is_cell, (propname))
235 201
236/* 202/*
237 * Structural check functions 203 * Structural check functions
238 */ 204 */
239 205
240static void check_duplicate_node_names(struct check *c, struct node *dt, 206static void check_duplicate_node_names(struct check *c, struct dt_info *dti,
241 struct node *node) 207 struct node *node)
242{ 208{
243 struct node *child, *child2; 209 struct node *child, *child2;
@@ -250,9 +216,9 @@ static void check_duplicate_node_names(struct check *c, struct node *dt,
250 FAIL(c, "Duplicate node name %s", 216 FAIL(c, "Duplicate node name %s",
251 child->fullpath); 217 child->fullpath);
252} 218}
253NODE_ERROR(duplicate_node_names, NULL); 219ERROR(duplicate_node_names, check_duplicate_node_names, NULL);
254 220
255static void check_duplicate_property_names(struct check *c, struct node *dt, 221static void check_duplicate_property_names(struct check *c, struct dt_info *dti,
256 struct node *node) 222 struct node *node)
257{ 223{
258 struct property *prop, *prop2; 224 struct property *prop, *prop2;
@@ -267,14 +233,14 @@ static void check_duplicate_property_names(struct check *c, struct node *dt,
267 } 233 }
268 } 234 }
269} 235}
270NODE_ERROR(duplicate_property_names, NULL); 236ERROR(duplicate_property_names, check_duplicate_property_names, NULL);
271 237
272#define LOWERCASE "abcdefghijklmnopqrstuvwxyz" 238#define LOWERCASE "abcdefghijklmnopqrstuvwxyz"
273#define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 239#define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
274#define DIGITS "0123456789" 240#define DIGITS "0123456789"
275#define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-" 241#define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-"
276 242
277static void check_node_name_chars(struct check *c, struct node *dt, 243static void check_node_name_chars(struct check *c, struct dt_info *dti,
278 struct node *node) 244 struct node *node)
279{ 245{
280 int n = strspn(node->name, c->data); 246 int n = strspn(node->name, c->data);
@@ -283,19 +249,19 @@ static void check_node_name_chars(struct check *c, struct node *dt,
283 FAIL(c, "Bad character '%c' in node %s", 249 FAIL(c, "Bad character '%c' in node %s",
284 node->name[n], node->fullpath); 250 node->name[n], node->fullpath);
285} 251}
286NODE_ERROR(node_name_chars, PROPNODECHARS "@"); 252ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@");
287 253
288static void check_node_name_format(struct check *c, struct node *dt, 254static void check_node_name_format(struct check *c, struct dt_info *dti,
289 struct node *node) 255 struct node *node)
290{ 256{
291 if (strchr(get_unitname(node), '@')) 257 if (strchr(get_unitname(node), '@'))
292 FAIL(c, "Node %s has multiple '@' characters in name", 258 FAIL(c, "Node %s has multiple '@' characters in name",
293 node->fullpath); 259 node->fullpath);
294} 260}
295NODE_ERROR(node_name_format, NULL, &node_name_chars); 261ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars);
296 262
297static void check_unit_address_vs_reg(struct check *c, struct node *dt, 263static void check_unit_address_vs_reg(struct check *c, struct dt_info *dti,
298 struct node *node) 264 struct node *node)
299{ 265{
300 const char *unitname = get_unitname(node); 266 const char *unitname = get_unitname(node);
301 struct property *prop = get_property(node, "reg"); 267 struct property *prop = get_property(node, "reg");
@@ -316,18 +282,22 @@ static void check_unit_address_vs_reg(struct check *c, struct node *dt,
316 node->fullpath); 282 node->fullpath);
317 } 283 }
318} 284}
319NODE_WARNING(unit_address_vs_reg, NULL); 285WARNING(unit_address_vs_reg, check_unit_address_vs_reg, NULL);
320 286
321static void check_property_name_chars(struct check *c, struct node *dt, 287static void check_property_name_chars(struct check *c, struct dt_info *dti,
322 struct node *node, struct property *prop) 288 struct node *node)
323{ 289{
324 int n = strspn(prop->name, c->data); 290 struct property *prop;
291
292 for_each_property(node, prop) {
293 int n = strspn(prop->name, c->data);
325 294
326 if (n < strlen(prop->name)) 295 if (n < strlen(prop->name))
327 FAIL(c, "Bad character '%c' in property name \"%s\", node %s", 296 FAIL(c, "Bad character '%c' in property name \"%s\", node %s",
328 prop->name[n], prop->name, node->fullpath); 297 prop->name[n], prop->name, node->fullpath);
298 }
329} 299}
330PROP_ERROR(property_name_chars, PROPNODECHARS); 300ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS);
331 301
332#define DESCLABEL_FMT "%s%s%s%s%s" 302#define DESCLABEL_FMT "%s%s%s%s%s"
333#define DESCLABEL_ARGS(node,prop,mark) \ 303#define DESCLABEL_ARGS(node,prop,mark) \
@@ -336,10 +306,11 @@ PROP_ERROR(property_name_chars, PROPNODECHARS);
336 ((prop) ? (prop)->name : ""), \ 306 ((prop) ? (prop)->name : ""), \
337 ((prop) ? "' in " : ""), (node)->fullpath 307 ((prop) ? "' in " : ""), (node)->fullpath
338 308
339static void check_duplicate_label(struct check *c, struct node *dt, 309static void check_duplicate_label(struct check *c, struct dt_info *dti,
340 const char *label, struct node *node, 310 const char *label, struct node *node,
341 struct property *prop, struct marker *mark) 311 struct property *prop, struct marker *mark)
342{ 312{
313 struct node *dt = dti->dt;
343 struct node *othernode = NULL; 314 struct node *othernode = NULL;
344 struct property *otherprop = NULL; 315 struct property *otherprop = NULL;
345 struct marker *othermark = NULL; 316 struct marker *othermark = NULL;
@@ -362,44 +333,43 @@ static void check_duplicate_label(struct check *c, struct node *dt,
362 DESCLABEL_ARGS(othernode, otherprop, othermark)); 333 DESCLABEL_ARGS(othernode, otherprop, othermark));
363} 334}
364 335
365static void check_duplicate_label_node(struct check *c, struct node *dt, 336static void check_duplicate_label_node(struct check *c, struct dt_info *dti,
366 struct node *node) 337 struct node *node)
367{ 338{
368 struct label *l; 339 struct label *l;
340 struct property *prop;
369 341
370 for_each_label(node->labels, l) 342 for_each_label(node->labels, l)
371 check_duplicate_label(c, dt, l->label, node, NULL, NULL); 343 check_duplicate_label(c, dti, l->label, node, NULL, NULL);
372} 344
373static void check_duplicate_label_prop(struct check *c, struct node *dt, 345 for_each_property(node, prop) {
374 struct node *node, struct property *prop) 346 struct marker *m = prop->val.markers;
375{
376 struct marker *m = prop->val.markers;
377 struct label *l;
378 347
379 for_each_label(prop->labels, l) 348 for_each_label(prop->labels, l)
380 check_duplicate_label(c, dt, l->label, node, prop, NULL); 349 check_duplicate_label(c, dti, l->label, node, prop, NULL);
381 350
382 for_each_marker_of_type(m, LABEL) 351 for_each_marker_of_type(m, LABEL)
383 check_duplicate_label(c, dt, m->ref, node, prop, m); 352 check_duplicate_label(c, dti, m->ref, node, prop, m);
353 }
384} 354}
385ERROR(duplicate_label, NULL, check_duplicate_label_node, 355ERROR(duplicate_label, check_duplicate_label_node, NULL);
386 check_duplicate_label_prop, NULL);
387 356
388static void check_explicit_phandles(struct check *c, struct node *root, 357static cell_t check_phandle_prop(struct check *c, struct dt_info *dti,
389 struct node *node, struct property *prop) 358 struct node *node, const char *propname)
390{ 359{
360 struct node *root = dti->dt;
361 struct property *prop;
391 struct marker *m; 362 struct marker *m;
392 struct node *other;
393 cell_t phandle; 363 cell_t phandle;
394 364
395 if (!streq(prop->name, "phandle") 365 prop = get_property(node, propname);
396 && !streq(prop->name, "linux,phandle")) 366 if (!prop)
397 return; 367 return 0;
398 368
399 if (prop->val.len != sizeof(cell_t)) { 369 if (prop->val.len != sizeof(cell_t)) {
400 FAIL(c, "%s has bad length (%d) %s property", 370 FAIL(c, "%s has bad length (%d) %s property",
401 node->fullpath, prop->val.len, prop->name); 371 node->fullpath, prop->val.len, prop->name);
402 return; 372 return 0;
403 } 373 }
404 374
405 m = prop->val.markers; 375 m = prop->val.markers;
@@ -411,14 +381,13 @@ static void check_explicit_phandles(struct check *c, struct node *root,
411 * by construction. */ { 381 * by construction. */ {
412 FAIL(c, "%s in %s is a reference to another node", 382 FAIL(c, "%s in %s is a reference to another node",
413 prop->name, node->fullpath); 383 prop->name, node->fullpath);
414 return;
415 } 384 }
416 /* But setting this node's phandle equal to its own 385 /* But setting this node's phandle equal to its own
417 * phandle is allowed - that means allocate a unique 386 * phandle is allowed - that means allocate a unique
418 * phandle for this node, even if it's not otherwise 387 * phandle for this node, even if it's not otherwise
419 * referenced. The value will be filled in later, so 388 * referenced. The value will be filled in later, so
420 * no further checking for now. */ 389 * we treat it as having no phandle data for now. */
421 return; 390 return 0;
422 } 391 }
423 392
424 phandle = propval_cell(prop); 393 phandle = propval_cell(prop);
@@ -426,12 +395,36 @@ static void check_explicit_phandles(struct check *c, struct node *root,
426 if ((phandle == 0) || (phandle == -1)) { 395 if ((phandle == 0) || (phandle == -1)) {
427 FAIL(c, "%s has bad value (0x%x) in %s property", 396 FAIL(c, "%s has bad value (0x%x) in %s property",
428 node->fullpath, phandle, prop->name); 397 node->fullpath, phandle, prop->name);
429 return; 398 return 0;
430 } 399 }
431 400
432 if (node->phandle && (node->phandle != phandle)) 401 return phandle;
433 FAIL(c, "%s has %s property which replaces existing phandle information", 402}
434 node->fullpath, prop->name); 403
404static void check_explicit_phandles(struct check *c, struct dt_info *dti,
405 struct node *node)
406{
407 struct node *root = dti->dt;
408 struct node *other;
409 cell_t phandle, linux_phandle;
410
411 /* Nothing should have assigned phandles yet */
412 assert(!node->phandle);
413
414 phandle = check_phandle_prop(c, dti, node, "phandle");
415
416 linux_phandle = check_phandle_prop(c, dti, node, "linux,phandle");
417
418 if (!phandle && !linux_phandle)
419 /* No valid phandles; nothing further to check */
420 return;
421
422 if (linux_phandle && phandle && (phandle != linux_phandle))
423 FAIL(c, "%s has mismatching 'phandle' and 'linux,phandle'"
424 " properties", node->fullpath);
425
426 if (linux_phandle && !phandle)
427 phandle = linux_phandle;
435 428
436 other = get_node_by_phandle(root, phandle); 429 other = get_node_by_phandle(root, phandle);
437 if (other && (other != node)) { 430 if (other && (other != node)) {
@@ -442,9 +435,9 @@ static void check_explicit_phandles(struct check *c, struct node *root,
442 435
443 node->phandle = phandle; 436 node->phandle = phandle;
444} 437}
445PROP_ERROR(explicit_phandles, NULL); 438ERROR(explicit_phandles, check_explicit_phandles, NULL);
446 439
447static void check_name_properties(struct check *c, struct node *root, 440static void check_name_properties(struct check *c, struct dt_info *dti,
448 struct node *node) 441 struct node *node)
449{ 442{
450 struct property **pp, *prop = NULL; 443 struct property **pp, *prop = NULL;
@@ -472,60 +465,73 @@ static void check_name_properties(struct check *c, struct node *root,
472 } 465 }
473} 466}
474ERROR_IF_NOT_STRING(name_is_string, "name"); 467ERROR_IF_NOT_STRING(name_is_string, "name");
475NODE_ERROR(name_properties, NULL, &name_is_string); 468ERROR(name_properties, check_name_properties, NULL, &name_is_string);
476 469
477/* 470/*
478 * Reference fixup functions 471 * Reference fixup functions
479 */ 472 */
480 473
481static void fixup_phandle_references(struct check *c, struct node *dt, 474static void fixup_phandle_references(struct check *c, struct dt_info *dti,
482 struct node *node, struct property *prop) 475 struct node *node)
483{ 476{
484 struct marker *m = prop->val.markers; 477 struct node *dt = dti->dt;
485 struct node *refnode; 478 struct property *prop;
486 cell_t phandle;
487 479
488 for_each_marker_of_type(m, REF_PHANDLE) { 480 for_each_property(node, prop) {
489 assert(m->offset + sizeof(cell_t) <= prop->val.len); 481 struct marker *m = prop->val.markers;
482 struct node *refnode;
483 cell_t phandle;
484
485 for_each_marker_of_type(m, REF_PHANDLE) {
486 assert(m->offset + sizeof(cell_t) <= prop->val.len);
487
488 refnode = get_node_by_ref(dt, m->ref);
489 if (! refnode) {
490 if (!(dti->dtsflags & DTSF_PLUGIN))
491 FAIL(c, "Reference to non-existent node or "
492 "label \"%s\"\n", m->ref);
493 else /* mark the entry as unresolved */
494 *((cell_t *)(prop->val.val + m->offset)) =
495 cpu_to_fdt32(0xffffffff);
496 continue;
497 }
490 498
491 refnode = get_node_by_ref(dt, m->ref); 499 phandle = get_node_phandle(dt, refnode);
492 if (! refnode) { 500 *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
493 FAIL(c, "Reference to non-existent node or label \"%s\"\n",
494 m->ref);
495 continue;
496 } 501 }
497
498 phandle = get_node_phandle(dt, refnode);
499 *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
500 } 502 }
501} 503}
502ERROR(phandle_references, NULL, NULL, fixup_phandle_references, NULL, 504ERROR(phandle_references, fixup_phandle_references, NULL,
503 &duplicate_node_names, &explicit_phandles); 505 &duplicate_node_names, &explicit_phandles);
504 506
505static void fixup_path_references(struct check *c, struct node *dt, 507static void fixup_path_references(struct check *c, struct dt_info *dti,
506 struct node *node, struct property *prop) 508 struct node *node)
507{ 509{
508 struct marker *m = prop->val.markers; 510 struct node *dt = dti->dt;
509 struct node *refnode; 511 struct property *prop;
510 char *path; 512
511 513 for_each_property(node, prop) {
512 for_each_marker_of_type(m, REF_PATH) { 514 struct marker *m = prop->val.markers;
513 assert(m->offset <= prop->val.len); 515 struct node *refnode;
514 516 char *path;
515 refnode = get_node_by_ref(dt, m->ref); 517
516 if (!refnode) { 518 for_each_marker_of_type(m, REF_PATH) {
517 FAIL(c, "Reference to non-existent node or label \"%s\"\n", 519 assert(m->offset <= prop->val.len);
518 m->ref);
519 continue;
520 }
521 520
522 path = refnode->fullpath; 521 refnode = get_node_by_ref(dt, m->ref);
523 prop->val = data_insert_at_marker(prop->val, m, path, 522 if (!refnode) {
524 strlen(path) + 1); 523 FAIL(c, "Reference to non-existent node or label \"%s\"\n",
524 m->ref);
525 continue;
526 }
527
528 path = refnode->fullpath;
529 prop->val = data_insert_at_marker(prop->val, m, path,
530 strlen(path) + 1);
531 }
525 } 532 }
526} 533}
527ERROR(path_references, NULL, NULL, fixup_path_references, NULL, 534ERROR(path_references, fixup_path_references, NULL, &duplicate_node_names);
528 &duplicate_node_names);
529 535
530/* 536/*
531 * Semantic checks 537 * Semantic checks
@@ -538,7 +544,7 @@ WARNING_IF_NOT_STRING(device_type_is_string, "device_type");
538WARNING_IF_NOT_STRING(model_is_string, "model"); 544WARNING_IF_NOT_STRING(model_is_string, "model");
539WARNING_IF_NOT_STRING(status_is_string, "status"); 545WARNING_IF_NOT_STRING(status_is_string, "status");
540 546
541static void fixup_addr_size_cells(struct check *c, struct node *dt, 547static void fixup_addr_size_cells(struct check *c, struct dt_info *dti,
542 struct node *node) 548 struct node *node)
543{ 549{
544 struct property *prop; 550 struct property *prop;
@@ -554,7 +560,7 @@ static void fixup_addr_size_cells(struct check *c, struct node *dt,
554 if (prop) 560 if (prop)
555 node->size_cells = propval_cell(prop); 561 node->size_cells = propval_cell(prop);
556} 562}
557WARNING(addr_size_cells, NULL, fixup_addr_size_cells, NULL, NULL, 563WARNING(addr_size_cells, fixup_addr_size_cells, NULL,
558 &address_cells_is_cell, &size_cells_is_cell); 564 &address_cells_is_cell, &size_cells_is_cell);
559 565
560#define node_addr_cells(n) \ 566#define node_addr_cells(n) \
@@ -562,7 +568,7 @@ WARNING(addr_size_cells, NULL, fixup_addr_size_cells, NULL, NULL,
562#define node_size_cells(n) \ 568#define node_size_cells(n) \
563 (((n)->size_cells == -1) ? 1 : (n)->size_cells) 569 (((n)->size_cells == -1) ? 1 : (n)->size_cells)
564 570
565static void check_reg_format(struct check *c, struct node *dt, 571static void check_reg_format(struct check *c, struct dt_info *dti,
566 struct node *node) 572 struct node *node)
567{ 573{
568 struct property *prop; 574 struct property *prop;
@@ -589,9 +595,9 @@ static void check_reg_format(struct check *c, struct node *dt,
589 "(#address-cells == %d, #size-cells == %d)", 595 "(#address-cells == %d, #size-cells == %d)",
590 node->fullpath, prop->val.len, addr_cells, size_cells); 596 node->fullpath, prop->val.len, addr_cells, size_cells);
591} 597}
592NODE_WARNING(reg_format, NULL, &addr_size_cells); 598WARNING(reg_format, check_reg_format, NULL, &addr_size_cells);
593 599
594static void check_ranges_format(struct check *c, struct node *dt, 600static void check_ranges_format(struct check *c, struct dt_info *dti,
595 struct node *node) 601 struct node *node)
596{ 602{
597 struct property *prop; 603 struct property *prop;
@@ -630,12 +636,12 @@ static void check_ranges_format(struct check *c, struct node *dt,
630 p_addr_cells, c_addr_cells, c_size_cells); 636 p_addr_cells, c_addr_cells, c_size_cells);
631 } 637 }
632} 638}
633NODE_WARNING(ranges_format, NULL, &addr_size_cells); 639WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells);
634 640
635/* 641/*
636 * Style checks 642 * Style checks
637 */ 643 */
638static void check_avoid_default_addr_size(struct check *c, struct node *dt, 644static void check_avoid_default_addr_size(struct check *c, struct dt_info *dti,
639 struct node *node) 645 struct node *node)
640{ 646{
641 struct property *reg, *ranges; 647 struct property *reg, *ranges;
@@ -657,14 +663,21 @@ static void check_avoid_default_addr_size(struct check *c, struct node *dt,
657 FAIL(c, "Relying on default #size-cells value for %s", 663 FAIL(c, "Relying on default #size-cells value for %s",
658 node->fullpath); 664 node->fullpath);
659} 665}
660NODE_WARNING(avoid_default_addr_size, NULL, &addr_size_cells); 666WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL,
667 &addr_size_cells);
661 668
662static void check_obsolete_chosen_interrupt_controller(struct check *c, 669static void check_obsolete_chosen_interrupt_controller(struct check *c,
663 struct node *dt) 670 struct dt_info *dti,
671 struct node *node)
664{ 672{
673 struct node *dt = dti->dt;
665 struct node *chosen; 674 struct node *chosen;
666 struct property *prop; 675 struct property *prop;
667 676
677 if (node != dt)
678 return;
679
680
668 chosen = get_node_by_path(dt, "/chosen"); 681 chosen = get_node_by_path(dt, "/chosen");
669 if (!chosen) 682 if (!chosen)
670 return; 683 return;
@@ -674,7 +687,8 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c,
674 FAIL(c, "/chosen has obsolete \"interrupt-controller\" " 687 FAIL(c, "/chosen has obsolete \"interrupt-controller\" "
675 "property"); 688 "property");
676} 689}
677TREE_WARNING(obsolete_chosen_interrupt_controller, NULL); 690WARNING(obsolete_chosen_interrupt_controller,
691 check_obsolete_chosen_interrupt_controller, NULL);
678 692
679static struct check *check_table[] = { 693static struct check *check_table[] = {
680 &duplicate_node_names, &duplicate_property_names, 694 &duplicate_node_names, &duplicate_property_names,
@@ -760,9 +774,8 @@ void parse_checks_option(bool warn, bool error, const char *arg)
760 die("Unrecognized check name \"%s\"\n", name); 774 die("Unrecognized check name \"%s\"\n", name);
761} 775}
762 776
763void process_checks(bool force, struct boot_info *bi) 777void process_checks(bool force, struct dt_info *dti)
764{ 778{
765 struct node *dt = bi->dt;
766 int i; 779 int i;
767 int error = 0; 780 int error = 0;
768 781
@@ -770,7 +783,7 @@ void process_checks(bool force, struct boot_info *bi)
770 struct check *c = check_table[i]; 783 struct check *c = check_table[i];
771 784
772 if (c->warn || c->error) 785 if (c->warn || c->error)
773 error = error || run_check(c, dt); 786 error = error || run_check(c, dti);
774 } 787 }
775 788
776 if (error) { 789 if (error) {
diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l
index 790fbf6cf2d7..c600603044f3 100644
--- a/scripts/dtc/dtc-lexer.l
+++ b/scripts/dtc/dtc-lexer.l
@@ -121,6 +121,11 @@ static void lexical_error(const char *fmt, ...);
121 return DT_V1; 121 return DT_V1;
122 } 122 }
123 123
124<*>"/plugin/" {
125 DPRINT("Keyword: /plugin/\n");
126 return DT_PLUGIN;
127 }
128
124<*>"/memreserve/" { 129<*>"/memreserve/" {
125 DPRINT("Keyword: /memreserve/\n"); 130 DPRINT("Keyword: /memreserve/\n");
126 BEGIN_DEFAULT(); 131 BEGIN_DEFAULT();
@@ -184,16 +189,16 @@ static void lexical_error(const char *fmt, ...);
184 if (d.len == 1) { 189 if (d.len == 1) {
185 lexical_error("Empty character literal"); 190 lexical_error("Empty character literal");
186 yylval.integer = 0; 191 yylval.integer = 0;
187 return DT_CHAR_LITERAL; 192 } else {
188 } 193 yylval.integer = (unsigned char)d.val[0];
189 194
190 yylval.integer = (unsigned char)d.val[0]; 195 if (d.len > 2)
191 196 lexical_error("Character literal has %d"
192 if (d.len > 2) 197 " characters instead of 1",
193 lexical_error("Character literal has %d" 198 d.len - 1);
194 " characters instead of 1", 199 }
195 d.len - 1);
196 200
201 data_free(d);
197 return DT_CHAR_LITERAL; 202 return DT_CHAR_LITERAL;
198 } 203 }
199 204
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped
index ba525c2f9fc2..2c862bc86ad0 100644
--- a/scripts/dtc/dtc-lexer.lex.c_shipped
+++ b/scripts/dtc/dtc-lexer.lex.c_shipped
@@ -8,8 +8,8 @@
8 8
9#define FLEX_SCANNER 9#define FLEX_SCANNER
10#define YY_FLEX_MAJOR_VERSION 2 10#define YY_FLEX_MAJOR_VERSION 2
11#define YY_FLEX_MINOR_VERSION 5 11#define YY_FLEX_MINOR_VERSION 6
12#define YY_FLEX_SUBMINOR_VERSION 39 12#define YY_FLEX_SUBMINOR_VERSION 1
13#if YY_FLEX_SUBMINOR_VERSION > 0 13#if YY_FLEX_SUBMINOR_VERSION > 0
14#define FLEX_BETA 14#define FLEX_BETA
15#endif 15#endif
@@ -88,25 +88,13 @@ typedef unsigned int flex_uint32_t;
88 88
89#endif /* ! FLEXINT_H */ 89#endif /* ! FLEXINT_H */
90 90
91#ifdef __cplusplus 91/* TODO: this is always defined, so inline it */
92
93/* The "const" storage-class-modifier is valid. */
94#define YY_USE_CONST
95
96#else /* ! __cplusplus */
97
98/* C99 requires __STDC__ to be defined as 1. */
99#if defined (__STDC__)
100
101#define YY_USE_CONST
102
103#endif /* defined (__STDC__) */
104#endif /* ! __cplusplus */
105
106#ifdef YY_USE_CONST
107#define yyconst const 92#define yyconst const
93
94#if defined(__GNUC__) && __GNUC__ >= 3
95#define yynoreturn __attribute__((__noreturn__))
108#else 96#else
109#define yyconst 97#define yynoreturn
110#endif 98#endif
111 99
112/* Returned upon end-of-file. */ 100/* Returned upon end-of-file. */
@@ -167,7 +155,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
167typedef size_t yy_size_t; 155typedef size_t yy_size_t;
168#endif 156#endif
169 157
170extern yy_size_t yyleng; 158extern int yyleng;
171 159
172extern FILE *yyin, *yyout; 160extern FILE *yyin, *yyout;
173 161
@@ -206,12 +194,12 @@ struct yy_buffer_state
206 /* Size of input buffer in bytes, not including room for EOB 194 /* Size of input buffer in bytes, not including room for EOB
207 * characters. 195 * characters.
208 */ 196 */
209 yy_size_t yy_buf_size; 197 int yy_buf_size;
210 198
211 /* Number of characters read into yy_ch_buf, not including EOB 199 /* Number of characters read into yy_ch_buf, not including EOB
212 * characters. 200 * characters.
213 */ 201 */
214 yy_size_t yy_n_chars; 202 int yy_n_chars;
215 203
216 /* Whether we "own" the buffer - i.e., we know we created it, 204 /* Whether we "own" the buffer - i.e., we know we created it,
217 * and can realloc() it to grow it, and should free() it to 205 * and can realloc() it to grow it, and should free() it to
@@ -234,7 +222,7 @@ struct yy_buffer_state
234 222
235 int yy_bs_lineno; /**< The line count. */ 223 int yy_bs_lineno; /**< The line count. */
236 int yy_bs_column; /**< The column count. */ 224 int yy_bs_column; /**< The column count. */
237 225
238 /* Whether to try to fill the input buffer when we reach the 226 /* Whether to try to fill the input buffer when we reach the
239 * end of it. 227 * end of it.
240 */ 228 */
@@ -262,7 +250,7 @@ struct yy_buffer_state
262/* Stack of input buffers. */ 250/* Stack of input buffers. */
263static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ 251static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
264static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ 252static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
265static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ 253static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
266 254
267/* We provide macros for accessing buffer states in case in the 255/* We provide macros for accessing buffer states in case in the
268 * future we want to put the buffer states in a more general 256 * future we want to put the buffer states in a more general
@@ -281,11 +269,11 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
281 269
282/* yy_hold_char holds the character lost when yytext is formed. */ 270/* yy_hold_char holds the character lost when yytext is formed. */
283static char yy_hold_char; 271static char yy_hold_char;
284static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ 272static int yy_n_chars; /* number of characters read into yy_ch_buf */
285yy_size_t yyleng; 273int yyleng;
286 274
287/* Points to current character in buffer. */ 275/* Points to current character in buffer. */
288static char *yy_c_buf_p = (char *) 0; 276static char *yy_c_buf_p = NULL;
289static int yy_init = 0; /* whether we need to initialize */ 277static int yy_init = 0; /* whether we need to initialize */
290static int yy_start = 0; /* start state number */ 278static int yy_start = 0; /* start state number */
291 279
@@ -310,7 +298,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
310 298
311YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); 299YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
312YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); 300YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
313YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); 301YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
314 302
315void *yyalloc (yy_size_t ); 303void *yyalloc (yy_size_t );
316void *yyrealloc (void *,yy_size_t ); 304void *yyrealloc (void *,yy_size_t );
@@ -342,12 +330,12 @@ void yyfree (void * );
342 330
343/* Begin user sect3 */ 331/* Begin user sect3 */
344 332
345#define yywrap() 1 333#define yywrap() (/*CONSTCOND*/1)
346#define YY_SKIP_YYWRAP 334#define YY_SKIP_YYWRAP
347 335
348typedef unsigned char YY_CHAR; 336typedef unsigned char YY_CHAR;
349 337
350FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; 338FILE *yyin = NULL, *yyout = NULL;
351 339
352typedef int yy_state_type; 340typedef int yy_state_type;
353 341
@@ -356,25 +344,28 @@ extern int yylineno;
356int yylineno = 1; 344int yylineno = 1;
357 345
358extern char *yytext; 346extern char *yytext;
347#ifdef yytext_ptr
348#undef yytext_ptr
349#endif
359#define yytext_ptr yytext 350#define yytext_ptr yytext
360 351
361static yy_state_type yy_get_previous_state (void ); 352static yy_state_type yy_get_previous_state (void );
362static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); 353static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
363static int yy_get_next_buffer (void ); 354static int yy_get_next_buffer (void );
364static void yy_fatal_error (yyconst char msg[] ); 355static void yynoreturn yy_fatal_error (yyconst char* msg );
365 356
366/* Done after the current pattern has been matched and before the 357/* Done after the current pattern has been matched and before the
367 * corresponding action - sets up yytext. 358 * corresponding action - sets up yytext.
368 */ 359 */
369#define YY_DO_BEFORE_ACTION \ 360#define YY_DO_BEFORE_ACTION \
370 (yytext_ptr) = yy_bp; \ 361 (yytext_ptr) = yy_bp; \
371 yyleng = (size_t) (yy_cp - yy_bp); \ 362 yyleng = (int) (yy_cp - yy_bp); \
372 (yy_hold_char) = *yy_cp; \ 363 (yy_hold_char) = *yy_cp; \
373 *yy_cp = '\0'; \ 364 *yy_cp = '\0'; \
374 (yy_c_buf_p) = yy_cp; 365 (yy_c_buf_p) = yy_cp;
375 366
376#define YY_NUM_RULES 30 367#define YY_NUM_RULES 31
377#define YY_END_OF_BUFFER 31 368#define YY_END_OF_BUFFER 32
378/* This struct is not used in this scanner, 369/* This struct is not used in this scanner,
379 but its presence is necessary. */ 370 but its presence is necessary. */
380struct yy_trans_info 371struct yy_trans_info
@@ -382,28 +373,29 @@ struct yy_trans_info
382 flex_int32_t yy_verify; 373 flex_int32_t yy_verify;
383 flex_int32_t yy_nxt; 374 flex_int32_t yy_nxt;
384 }; 375 };
385static yyconst flex_int16_t yy_accept[159] = 376static yyconst flex_int16_t yy_accept[166] =
386 { 0, 377 { 0,
387 0, 0, 0, 0, 0, 0, 0, 0, 31, 29, 378 0, 0, 0, 0, 0, 0, 0, 0, 32, 30,
388 18, 18, 29, 29, 29, 29, 29, 29, 29, 29, 379 19, 19, 30, 30, 30, 30, 30, 30, 30, 30,
389 29, 29, 29, 29, 29, 29, 15, 16, 16, 29, 380 30, 30, 30, 30, 30, 30, 16, 17, 17, 30,
390 16, 10, 10, 18, 26, 0, 3, 0, 27, 12, 381 17, 11, 11, 19, 27, 0, 3, 0, 28, 13,
391 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 382 0, 0, 12, 0, 0, 0, 0, 0, 0, 0,
392 21, 23, 25, 24, 22, 0, 9, 28, 0, 0, 383 0, 22, 24, 26, 25, 23, 0, 10, 29, 0,
393 0, 14, 14, 16, 16, 16, 10, 10, 10, 0, 384 0, 0, 15, 15, 17, 17, 17, 11, 11, 11,
394 12, 0, 11, 0, 0, 0, 20, 0, 0, 0, 385 0, 13, 0, 12, 0, 0, 0, 21, 0, 0,
395 0, 0, 0, 0, 0, 16, 10, 10, 10, 0, 386 0, 0, 0, 0, 0, 0, 0, 17, 11, 11,
396 13, 19, 0, 0, 0, 0, 0, 0, 0, 0, 387 11, 0, 14, 20, 0, 0, 0, 0, 0, 0,
397 388
398 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 389 0, 0, 0, 0, 17, 0, 0, 0, 0, 0,
399 0, 16, 6, 0, 0, 0, 0, 0, 0, 2, 390 0, 0, 0, 0, 0, 17, 7, 0, 0, 0,
400 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 391 0, 0, 0, 0, 2, 0, 0, 0, 0, 0,
401 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 392 0, 0, 0, 0, 4, 18, 0, 0, 5, 2,
402 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 393 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
403 5, 8, 0, 0, 0, 0, 7, 0 394 0, 0, 1, 0, 0, 0, 0, 6, 9, 0,
395 0, 0, 0, 8, 0
404 } ; 396 } ;
405 397
406static yyconst flex_int32_t yy_ec[256] = 398static yyconst YY_CHAR yy_ec[256] =
407 { 0, 399 { 0,
408 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 400 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
409 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 401 4, 4, 4, 1, 1, 1, 1, 1, 1, 1,
@@ -416,9 +408,9 @@ static yyconst flex_int32_t yy_ec[256] =
416 22, 22, 22, 22, 24, 22, 22, 25, 22, 22, 408 22, 22, 22, 22, 24, 22, 22, 25, 22, 22,
417 1, 26, 27, 1, 22, 1, 21, 28, 29, 30, 409 1, 26, 27, 1, 22, 1, 21, 28, 29, 30,
418 410
419 31, 21, 22, 22, 32, 22, 22, 33, 34, 35, 411 31, 21, 32, 22, 33, 22, 22, 34, 35, 36,
420 36, 37, 22, 38, 39, 40, 41, 42, 22, 25, 412 37, 38, 22, 39, 40, 41, 42, 43, 22, 25,
421 43, 22, 44, 45, 46, 1, 1, 1, 1, 1, 413 44, 22, 45, 46, 47, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
424 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -435,163 +427,165 @@ static yyconst flex_int32_t yy_ec[256] =
435 1, 1, 1, 1, 1 427 1, 1, 1, 1, 1
436 } ; 428 } ;
437 429
438static yyconst flex_int32_t yy_meta[47] = 430static yyconst YY_CHAR yy_meta[48] =
439 { 0, 431 { 0,
440 1, 1, 1, 1, 1, 1, 2, 3, 1, 2, 432 1, 1, 1, 1, 1, 1, 2, 3, 1, 2,
441 2, 2, 4, 5, 5, 5, 6, 1, 1, 1, 433 2, 2, 4, 5, 5, 5, 6, 1, 1, 1,
442 7, 8, 8, 8, 8, 1, 1, 7, 7, 7, 434 7, 8, 8, 8, 8, 1, 1, 7, 7, 7,
443 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 435 7, 8, 8, 8, 8, 8, 8, 8, 8, 8,
444 8, 8, 8, 3, 1, 4 436 8, 8, 8, 8, 3, 1, 4
445 } ; 437 } ;
446 438
447static yyconst flex_int16_t yy_base[173] = 439static yyconst flex_uint16_t yy_base[180] =
448 { 0, 440 { 0,
449 0, 383, 34, 382, 65, 381, 37, 105, 387, 391, 441 0, 393, 35, 392, 66, 391, 38, 107, 397, 401,
450 54, 111, 367, 110, 109, 109, 112, 41, 366, 104, 442 55, 113, 377, 112, 111, 111, 114, 42, 376, 106,
451 367, 338, 124, 117, 0, 144, 391, 0, 121, 0, 443 377, 347, 126, 120, 0, 147, 401, 0, 124, 0,
452 135, 155, 140, 179, 391, 160, 391, 379, 391, 0, 444 137, 158, 170, 163, 401, 153, 401, 389, 401, 0,
453 368, 141, 391, 167, 370, 376, 346, 103, 342, 345, 445 378, 120, 401, 131, 380, 386, 355, 139, 351, 355,
454 391, 391, 391, 391, 391, 358, 391, 391, 175, 342, 446 351, 401, 401, 401, 401, 401, 367, 401, 401, 185,
455 338, 391, 355, 0, 185, 339, 184, 347, 346, 0, 447 350, 346, 401, 364, 0, 185, 347, 189, 356, 355,
456 0, 322, 175, 357, 175, 363, 352, 324, 330, 323, 448 0, 0, 330, 180, 366, 141, 372, 361, 332, 338,
457 332, 326, 201, 324, 329, 322, 391, 333, 181, 309, 449 331, 341, 334, 326, 205, 331, 337, 329, 401, 341,
458 391, 341, 340, 313, 320, 338, 178, 311, 146, 317, 450 167, 316, 401, 349, 348, 320, 328, 346, 180, 318,
459 451
460 314, 315, 335, 331, 303, 300, 309, 299, 308, 188, 452 324, 209, 324, 320, 322, 342, 338, 309, 306, 315,
461 336, 335, 391, 305, 320, 281, 283, 271, 203, 288, 453 305, 315, 312, 192, 342, 341, 401, 293, 306, 282,
462 281, 271, 266, 264, 245, 242, 208, 104, 391, 391, 454 268, 252, 255, 203, 285, 282, 272, 268, 252, 233,
463 244, 218, 204, 219, 206, 224, 201, 212, 204, 229, 455 232, 239, 208, 107, 401, 401, 238, 211, 401, 211,
464 215, 208, 207, 200, 219, 391, 233, 221, 200, 181, 456 212, 208, 228, 203, 215, 207, 233, 222, 212, 211,
465 391, 391, 149, 122, 86, 41, 391, 391, 245, 251, 457 203, 227, 401, 237, 225, 204, 185, 401, 401, 149,
466 259, 263, 267, 273, 280, 284, 292, 300, 304, 310, 458 128, 88, 42, 401, 401, 253, 259, 267, 271, 275,
467 318, 326 459 281, 288, 292, 300, 308, 312, 318, 326, 334
468 } ; 460 } ;
469 461
470static yyconst flex_int16_t yy_def[173] = 462static yyconst flex_int16_t yy_def[180] =
471 { 0, 463 { 0,
472 158, 1, 1, 3, 158, 5, 1, 1, 158, 158, 464 165, 1, 1, 3, 165, 5, 1, 1, 165, 165,
473 158, 158, 158, 159, 160, 161, 158, 158, 158, 158, 465 165, 165, 165, 166, 167, 168, 165, 165, 165, 165,
474 162, 158, 158, 158, 163, 162, 158, 164, 165, 164, 466 169, 165, 165, 165, 170, 169, 165, 171, 172, 171,
475 164, 158, 158, 158, 158, 159, 158, 159, 158, 166, 467 171, 165, 165, 165, 165, 166, 165, 166, 165, 173,
476 158, 161, 158, 161, 167, 168, 158, 158, 158, 158, 468 165, 168, 165, 168, 174, 175, 165, 165, 165, 165,
477 158, 158, 158, 158, 158, 162, 158, 158, 158, 158, 469 165, 165, 165, 165, 165, 165, 169, 165, 165, 165,
478 158, 158, 162, 164, 165, 164, 158, 158, 158, 169, 470 165, 165, 165, 169, 171, 172, 171, 165, 165, 165,
479 166, 170, 161, 167, 167, 168, 158, 158, 158, 158, 471 176, 173, 177, 168, 174, 174, 175, 165, 165, 165,
480 158, 158, 158, 158, 158, 164, 158, 158, 169, 170, 472 165, 165, 165, 165, 165, 165, 165, 171, 165, 165,
481 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 473 176, 177, 165, 165, 165, 165, 165, 165, 165, 165,
482 474
483 158, 164, 158, 158, 158, 158, 158, 158, 158, 171, 475 165, 165, 165, 165, 171, 165, 165, 165, 165, 165,
484 158, 164, 158, 158, 158, 158, 158, 158, 171, 158, 476 165, 165, 165, 178, 165, 171, 165, 165, 165, 165,
485 171, 158, 158, 158, 158, 158, 158, 158, 158, 158, 477 165, 165, 165, 178, 165, 178, 165, 165, 165, 165,
486 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 478 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
487 172, 158, 158, 158, 172, 158, 172, 158, 158, 158, 479 165, 165, 165, 165, 165, 165, 165, 179, 165, 165,
488 158, 158, 158, 158, 158, 158, 158, 0, 158, 158, 480 165, 179, 165, 179, 165, 165, 165, 165, 165, 165,
489 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 481 165, 165, 165, 165, 0, 165, 165, 165, 165, 165,
490 158, 158 482 165, 165, 165, 165, 165, 165, 165, 165, 165
491 } ; 483 } ;
492 484
493static yyconst flex_int16_t yy_nxt[438] = 485static yyconst flex_uint16_t yy_nxt[449] =
494 { 0, 486 { 0,
495 10, 11, 12, 11, 13, 14, 10, 15, 16, 10, 487 10, 11, 12, 11, 13, 14, 10, 15, 16, 10,
496 10, 10, 17, 10, 10, 10, 10, 18, 19, 20, 488 10, 10, 17, 10, 10, 10, 10, 18, 19, 20,
497 21, 21, 21, 21, 21, 10, 10, 21, 21, 21, 489 21, 21, 21, 21, 21, 10, 10, 21, 21, 21,
498 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 490 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
499 21, 21, 21, 10, 22, 10, 24, 25, 25, 25, 491 21, 21, 21, 21, 10, 22, 10, 24, 25, 25,
500 32, 33, 33, 157, 26, 34, 34, 34, 51, 52, 492 25, 32, 33, 33, 164, 26, 34, 34, 34, 52,
501 27, 26, 26, 26, 26, 10, 11, 12, 11, 13, 493 53, 27, 26, 26, 26, 26, 10, 11, 12, 11,
502 14, 28, 15, 16, 28, 28, 28, 24, 28, 28, 494 13, 14, 28, 15, 16, 28, 28, 28, 24, 28,
503 28, 10, 18, 19, 20, 29, 29, 29, 29, 29, 495 28, 28, 10, 18, 19, 20, 29, 29, 29, 29,
504 30, 10, 29, 29, 29, 29, 29, 29, 29, 29, 496 29, 30, 10, 29, 29, 29, 29, 29, 29, 29,
505 497
506 29, 29, 29, 29, 29, 29, 29, 29, 10, 22, 498 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
507 10, 23, 34, 34, 34, 37, 39, 43, 32, 33, 499 10, 22, 10, 23, 34, 34, 34, 37, 39, 43,
508 33, 45, 54, 55, 46, 59, 45, 64, 156, 46, 500 32, 33, 33, 45, 55, 56, 46, 60, 43, 45,
509 64, 64, 64, 79, 44, 38, 59, 57, 134, 47, 501 65, 163, 46, 65, 65, 65, 44, 38, 60, 74,
510 135, 48, 80, 49, 47, 50, 48, 99, 61, 43, 502 58, 47, 141, 48, 142, 44, 49, 47, 50, 48,
511 50, 110, 41, 67, 67, 67, 60, 63, 63, 63, 503 76, 51, 62, 94, 50, 41, 44, 51, 37, 61,
512 57, 155, 68, 69, 63, 37, 44, 66, 67, 67, 504 64, 64, 64, 58, 34, 34, 34, 64, 162, 80,
513 67, 63, 63, 63, 63, 73, 59, 68, 69, 70, 505 67, 68, 68, 68, 64, 64, 64, 64, 38, 81,
514 34, 34, 34, 43, 75, 38, 154, 92, 83, 83, 506 69, 70, 71, 68, 68, 68, 60, 161, 43, 69,
515 83, 64, 44, 120, 64, 64, 64, 67, 67, 67, 507 70, 65, 69, 70, 65, 65, 65, 125, 85, 85,
516 508
517 44, 57, 99, 68, 69, 107, 68, 69, 120, 127, 509 85, 58, 68, 68, 68, 44, 102, 110, 125, 133,
518 108, 153, 152, 121, 83, 83, 83, 133, 133, 133, 510 102, 69, 70, 111, 114, 160, 159, 126, 85, 85,
519 146, 133, 133, 133, 146, 140, 140, 140, 121, 141, 511 85, 140, 140, 140, 140, 140, 140, 153, 126, 147,
520 140, 140, 140, 151, 141, 158, 150, 149, 148, 144, 512 147, 147, 153, 148, 147, 147, 147, 158, 148, 165,
521 147, 143, 142, 139, 147, 36, 36, 36, 36, 36, 513 157, 156, 155, 151, 150, 149, 146, 154, 145, 144,
522 36, 36, 36, 40, 138, 137, 136, 40, 40, 42, 514 143, 139, 154, 36, 36, 36, 36, 36, 36, 36,
523 42, 42, 42, 42, 42, 42, 42, 56, 56, 56, 515 36, 40, 138, 137, 136, 40, 40, 42, 42, 42,
524 56, 62, 132, 62, 64, 131, 130, 64, 129, 64, 516 42, 42, 42, 42, 42, 57, 57, 57, 57, 63,
525 64, 65, 128, 158, 65, 65, 65, 65, 71, 127, 517 135, 63, 65, 134, 165, 65, 133, 65, 65, 66,
526 71, 71, 74, 74, 74, 74, 74, 74, 74, 74, 518 132, 131, 66, 66, 66, 66, 72, 130, 72, 72,
527 519
528 76, 76, 76, 76, 76, 76, 76, 76, 89, 126, 520 75, 75, 75, 75, 75, 75, 75, 75, 77, 77,
529 89, 90, 125, 90, 90, 124, 90, 90, 119, 119, 521 77, 77, 77, 77, 77, 77, 91, 129, 91, 92,
530 119, 119, 119, 119, 119, 119, 145, 145, 145, 145, 522 128, 92, 92, 127, 92, 92, 124, 124, 124, 124,
531 145, 145, 145, 145, 123, 122, 59, 59, 118, 117, 523 124, 124, 124, 124, 152, 152, 152, 152, 152, 152,
532 116, 115, 114, 113, 45, 112, 108, 111, 109, 106, 524 152, 152, 60, 60, 123, 122, 121, 120, 119, 118,
533 105, 104, 46, 103, 91, 87, 102, 101, 100, 98, 525 117, 45, 116, 111, 115, 113, 112, 109, 108, 107,
534 97, 96, 95, 94, 93, 77, 75, 91, 88, 87, 526 46, 106, 93, 89, 105, 104, 103, 101, 100, 99,
535 86, 57, 85, 84, 57, 82, 81, 78, 77, 75, 527 98, 97, 96, 95, 78, 76, 93, 90, 89, 88,
536 72, 158, 58, 57, 53, 35, 158, 31, 23, 23, 528 58, 87, 86, 58, 84, 83, 82, 79, 78, 76,
537 9, 158, 158, 158, 158, 158, 158, 158, 158, 158, 529 73, 165, 59, 58, 54, 35, 165, 31, 23, 23,
538 530
539 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 531 9, 165, 165, 165, 165, 165, 165, 165, 165, 165,
540 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 532 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
541 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 533 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
542 158, 158, 158, 158, 158, 158, 158 534 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
535 165, 165, 165, 165, 165, 165, 165, 165
543 } ; 536 } ;
544 537
545static yyconst flex_int16_t yy_chk[438] = 538static yyconst flex_int16_t yy_chk[449] =
546 { 0, 539 { 0,
547 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 540 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
548 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 541 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
549 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 542 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
550 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 543 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
551 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 544 1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
552 7, 7, 7, 156, 3, 11, 11, 11, 18, 18, 545 3, 7, 7, 7, 163, 3, 11, 11, 11, 18,
553 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 546 18, 3, 3, 3, 3, 3, 5, 5, 5, 5,
554 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 547 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
555 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 548 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
556 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 549 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
557 550
558 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 551 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
559 5, 8, 12, 12, 12, 14, 15, 16, 8, 8, 552 5, 5, 5, 8, 12, 12, 12, 14, 15, 16,
560 8, 17, 20, 20, 17, 23, 24, 29, 155, 24, 553 8, 8, 8, 17, 20, 20, 17, 23, 42, 24,
561 29, 29, 29, 48, 16, 14, 31, 29, 128, 17, 554 29, 162, 24, 29, 29, 29, 16, 14, 31, 44,
562 128, 17, 48, 17, 24, 17, 24, 99, 24, 42, 555 29, 17, 134, 17, 134, 42, 17, 24, 17, 24,
563 24, 99, 15, 33, 33, 33, 23, 26, 26, 26, 556 76, 17, 24, 76, 24, 15, 44, 24, 36, 23,
564 26, 154, 33, 33, 26, 36, 42, 31, 32, 32, 557 26, 26, 26, 26, 34, 34, 34, 26, 161, 48,
565 32, 26, 26, 26, 26, 44, 59, 32, 32, 32, 558 31, 32, 32, 32, 26, 26, 26, 26, 36, 48,
566 34, 34, 34, 73, 75, 36, 153, 75, 59, 59, 559 32, 32, 32, 33, 33, 33, 60, 160, 74, 91,
567 59, 65, 44, 110, 65, 65, 65, 67, 67, 67, 560 91, 66, 33, 33, 66, 66, 66, 114, 60, 60,
568 561
569 73, 65, 83, 89, 89, 97, 67, 67, 119, 127, 562 60, 66, 68, 68, 68, 74, 85, 99, 124, 133,
570 97, 150, 149, 110, 83, 83, 83, 133, 133, 133, 563 102, 68, 68, 99, 102, 157, 156, 114, 85, 85,
571 141, 127, 127, 127, 145, 136, 136, 136, 119, 136, 564 85, 133, 133, 133, 140, 140, 140, 148, 124, 143,
572 140, 140, 140, 148, 140, 147, 144, 143, 142, 139, 565 143, 143, 152, 143, 147, 147, 147, 155, 147, 154,
573 141, 138, 137, 135, 145, 159, 159, 159, 159, 159, 566 151, 150, 149, 146, 145, 144, 142, 148, 141, 138,
574 159, 159, 159, 160, 134, 132, 131, 160, 160, 161, 567 137, 132, 152, 166, 166, 166, 166, 166, 166, 166,
575 161, 161, 161, 161, 161, 161, 161, 162, 162, 162, 568 166, 167, 131, 130, 129, 167, 167, 168, 168, 168,
576 162, 163, 126, 163, 164, 125, 124, 164, 123, 164, 569 168, 168, 168, 168, 168, 169, 169, 169, 169, 170,
577 164, 165, 122, 121, 165, 165, 165, 165, 166, 120, 570 128, 170, 171, 127, 126, 171, 125, 171, 171, 172,
578 166, 166, 167, 167, 167, 167, 167, 167, 167, 167, 571 123, 122, 172, 172, 172, 172, 173, 121, 173, 173,
579 572
580 168, 168, 168, 168, 168, 168, 168, 168, 169, 118, 573 174, 174, 174, 174, 174, 174, 174, 174, 175, 175,
581 169, 170, 117, 170, 170, 116, 170, 170, 171, 171, 574 175, 175, 175, 175, 175, 175, 176, 120, 176, 177,
582 171, 171, 171, 171, 171, 171, 172, 172, 172, 172, 575 119, 177, 177, 118, 177, 177, 178, 178, 178, 178,
583 172, 172, 172, 172, 115, 114, 112, 111, 109, 108, 576 178, 178, 178, 178, 179, 179, 179, 179, 179, 179,
584 107, 106, 105, 104, 103, 102, 101, 100, 98, 96, 577 179, 179, 116, 115, 113, 112, 111, 110, 109, 108,
585 95, 94, 93, 92, 90, 88, 86, 85, 84, 82, 578 107, 106, 105, 104, 103, 101, 100, 98, 97, 96,
586 81, 80, 79, 78, 77, 76, 74, 72, 69, 68, 579 95, 94, 92, 90, 88, 87, 86, 84, 83, 82,
587 66, 63, 61, 60, 56, 50, 49, 47, 46, 45, 580 81, 80, 79, 78, 77, 75, 73, 70, 69, 67,
581 64, 62, 61, 57, 51, 50, 49, 47, 46, 45,
588 41, 38, 22, 21, 19, 13, 9, 6, 4, 2, 582 41, 38, 22, 21, 19, 13, 9, 6, 4, 2,
589 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
590 583
591 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 584 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
592 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 585 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
593 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 586 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
594 158, 158, 158, 158, 158, 158, 158 587 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
588 165, 165, 165, 165, 165, 165, 165, 165
595 } ; 589 } ;
596 590
597static yy_state_type yy_last_accepting_state; 591static yy_state_type yy_last_accepting_state;
@@ -662,7 +656,7 @@ static int dts_version = 1;
662static void push_input_file(const char *filename); 656static void push_input_file(const char *filename);
663static bool pop_input_file(void); 657static bool pop_input_file(void);
664static void lexical_error(const char *fmt, ...); 658static void lexical_error(const char *fmt, ...);
665#line 666 "dtc-lexer.lex.c" 659#line 660 "dtc-lexer.lex.c"
666 660
667#define INITIAL 0 661#define INITIAL 0
668#define BYTESTRING 1 662#define BYTESTRING 1
@@ -698,19 +692,19 @@ void yyset_extra (YY_EXTRA_TYPE user_defined );
698 692
699FILE *yyget_in (void ); 693FILE *yyget_in (void );
700 694
701void yyset_in (FILE * in_str ); 695void yyset_in (FILE * _in_str );
702 696
703FILE *yyget_out (void ); 697FILE *yyget_out (void );
704 698
705void yyset_out (FILE * out_str ); 699void yyset_out (FILE * _out_str );
706 700
707yy_size_t yyget_leng (void ); 701 int yyget_leng (void );
708 702
709char *yyget_text (void ); 703char *yyget_text (void );
710 704
711int yyget_lineno (void ); 705int yyget_lineno (void );
712 706
713void yyset_lineno (int line_number ); 707void yyset_lineno (int _line_number );
714 708
715/* Macros after this point can all be overridden by user definitions in 709/* Macros after this point can all be overridden by user definitions in
716 * section 1. 710 * section 1.
@@ -724,6 +718,10 @@ extern int yywrap (void );
724#endif 718#endif
725#endif 719#endif
726 720
721#ifndef YY_NO_UNPUT
722
723#endif
724
727#ifndef yytext_ptr 725#ifndef yytext_ptr
728static void yy_flex_strncpy (char *,yyconst char *,int ); 726static void yy_flex_strncpy (char *,yyconst char *,int );
729#endif 727#endif
@@ -757,7 +755,7 @@ static int input (void );
757/* This used to be an fputs(), but since the string might contain NUL's, 755/* This used to be an fputs(), but since the string might contain NUL's,
758 * we now use fwrite(). 756 * we now use fwrite().
759 */ 757 */
760#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) 758#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
761#endif 759#endif
762 760
763/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 761/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -781,7 +779,7 @@ static int input (void );
781 else \ 779 else \
782 { \ 780 { \
783 errno=0; \ 781 errno=0; \
784 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ 782 while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
785 { \ 783 { \
786 if( errno != EINTR) \ 784 if( errno != EINTR) \
787 { \ 785 { \
@@ -836,7 +834,7 @@ extern int yylex (void);
836 834
837/* Code executed at the end of each rule. */ 835/* Code executed at the end of each rule. */
838#ifndef YY_BREAK 836#ifndef YY_BREAK
839#define YY_BREAK break; 837#define YY_BREAK /*LINTED*/break;
840#endif 838#endif
841 839
842#define YY_RULE_SETUP \ 840#define YY_RULE_SETUP \
@@ -849,9 +847,9 @@ extern int yylex (void);
849 */ 847 */
850YY_DECL 848YY_DECL
851{ 849{
852 register yy_state_type yy_current_state; 850 yy_state_type yy_current_state;
853 register char *yy_cp, *yy_bp; 851 char *yy_cp, *yy_bp;
854 register int yy_act; 852 int yy_act;
855 853
856 if ( !(yy_init) ) 854 if ( !(yy_init) )
857 { 855 {
@@ -882,9 +880,9 @@ YY_DECL
882 { 880 {
883#line 68 "dtc-lexer.l" 881#line 68 "dtc-lexer.l"
884 882
885#line 886 "dtc-lexer.lex.c" 883#line 884 "dtc-lexer.lex.c"
886 884
887 while ( 1 ) /* loops until end-of-file is reached */ 885 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
888 { 886 {
889 yy_cp = (yy_c_buf_p); 887 yy_cp = (yy_c_buf_p);
890 888
@@ -901,7 +899,7 @@ YY_DECL
901yy_match: 899yy_match:
902 do 900 do
903 { 901 {
904 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; 902 YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
905 if ( yy_accept[yy_current_state] ) 903 if ( yy_accept[yy_current_state] )
906 { 904 {
907 (yy_last_accepting_state) = yy_current_state; 905 (yy_last_accepting_state) = yy_current_state;
@@ -910,13 +908,13 @@ yy_match:
910 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 908 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
911 { 909 {
912 yy_current_state = (int) yy_def[yy_current_state]; 910 yy_current_state = (int) yy_def[yy_current_state];
913 if ( yy_current_state >= 159 ) 911 if ( yy_current_state >= 166 )
914 yy_c = yy_meta[(unsigned int) yy_c]; 912 yy_c = yy_meta[(unsigned int) yy_c];
915 } 913 }
916 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 914 yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
917 ++yy_cp; 915 ++yy_cp;
918 } 916 }
919 while ( yy_current_state != 158 ); 917 while ( yy_current_state != 165 );
920 yy_cp = (yy_last_accepting_cpos); 918 yy_cp = (yy_last_accepting_cpos);
921 yy_current_state = (yy_last_accepting_state); 919 yy_current_state = (yy_last_accepting_state);
922 920
@@ -1015,23 +1013,31 @@ case 5:
1015YY_RULE_SETUP 1013YY_RULE_SETUP
1016#line 124 "dtc-lexer.l" 1014#line 124 "dtc-lexer.l"
1017{ 1015{
1016 DPRINT("Keyword: /plugin/\n");
1017 return DT_PLUGIN;
1018 }
1019 YY_BREAK
1020case 6:
1021YY_RULE_SETUP
1022#line 129 "dtc-lexer.l"
1023{
1018 DPRINT("Keyword: /memreserve/\n"); 1024 DPRINT("Keyword: /memreserve/\n");
1019 BEGIN_DEFAULT(); 1025 BEGIN_DEFAULT();
1020 return DT_MEMRESERVE; 1026 return DT_MEMRESERVE;
1021 } 1027 }
1022 YY_BREAK 1028 YY_BREAK
1023case 6: 1029case 7:
1024YY_RULE_SETUP 1030YY_RULE_SETUP
1025#line 130 "dtc-lexer.l" 1031#line 135 "dtc-lexer.l"
1026{ 1032{
1027 DPRINT("Keyword: /bits/\n"); 1033 DPRINT("Keyword: /bits/\n");
1028 BEGIN_DEFAULT(); 1034 BEGIN_DEFAULT();
1029 return DT_BITS; 1035 return DT_BITS;
1030 } 1036 }
1031 YY_BREAK 1037 YY_BREAK
1032case 7: 1038case 8:
1033YY_RULE_SETUP 1039YY_RULE_SETUP
1034#line 136 "dtc-lexer.l" 1040#line 141 "dtc-lexer.l"
1035{ 1041{
1036 DPRINT("Keyword: /delete-property/\n"); 1042 DPRINT("Keyword: /delete-property/\n");
1037 DPRINT("<PROPNODENAME>\n"); 1043 DPRINT("<PROPNODENAME>\n");
@@ -1039,9 +1045,9 @@ YY_RULE_SETUP
1039 return DT_DEL_PROP; 1045 return DT_DEL_PROP;
1040 } 1046 }
1041 YY_BREAK 1047 YY_BREAK
1042case 8: 1048case 9:
1043YY_RULE_SETUP 1049YY_RULE_SETUP
1044#line 143 "dtc-lexer.l" 1050#line 148 "dtc-lexer.l"
1045{ 1051{
1046 DPRINT("Keyword: /delete-node/\n"); 1052 DPRINT("Keyword: /delete-node/\n");
1047 DPRINT("<PROPNODENAME>\n"); 1053 DPRINT("<PROPNODENAME>\n");
@@ -1049,9 +1055,9 @@ YY_RULE_SETUP
1049 return DT_DEL_NODE; 1055 return DT_DEL_NODE;
1050 } 1056 }
1051 YY_BREAK 1057 YY_BREAK
1052case 9: 1058case 10:
1053YY_RULE_SETUP 1059YY_RULE_SETUP
1054#line 150 "dtc-lexer.l" 1060#line 155 "dtc-lexer.l"
1055{ 1061{
1056 DPRINT("Label: %s\n", yytext); 1062 DPRINT("Label: %s\n", yytext);
1057 yylval.labelref = xstrdup(yytext); 1063 yylval.labelref = xstrdup(yytext);
@@ -1059,9 +1065,9 @@ YY_RULE_SETUP
1059 return DT_LABEL; 1065 return DT_LABEL;
1060 } 1066 }
1061 YY_BREAK 1067 YY_BREAK
1062case 10: 1068case 11:
1063YY_RULE_SETUP 1069YY_RULE_SETUP
1064#line 157 "dtc-lexer.l" 1070#line 162 "dtc-lexer.l"
1065{ 1071{
1066 char *e; 1072 char *e;
1067 DPRINT("Integer Literal: '%s'\n", yytext); 1073 DPRINT("Integer Literal: '%s'\n", yytext);
@@ -1084,10 +1090,10 @@ YY_RULE_SETUP
1084 return DT_LITERAL; 1090 return DT_LITERAL;
1085 } 1091 }
1086 YY_BREAK 1092 YY_BREAK
1087case 11: 1093case 12:
1088/* rule 11 can match eol */ 1094/* rule 12 can match eol */
1089YY_RULE_SETUP 1095YY_RULE_SETUP
1090#line 179 "dtc-lexer.l" 1096#line 184 "dtc-lexer.l"
1091{ 1097{
1092 struct data d; 1098 struct data d;
1093 DPRINT("Character literal: %s\n", yytext); 1099 DPRINT("Character literal: %s\n", yytext);
@@ -1096,31 +1102,31 @@ YY_RULE_SETUP
1096 if (d.len == 1) { 1102 if (d.len == 1) {
1097 lexical_error("Empty character literal"); 1103 lexical_error("Empty character literal");
1098 yylval.integer = 0; 1104 yylval.integer = 0;
1099 return DT_CHAR_LITERAL; 1105 } else {
1100 } 1106 yylval.integer = (unsigned char)d.val[0];
1101
1102 yylval.integer = (unsigned char)d.val[0];
1103 1107
1104 if (d.len > 2) 1108 if (d.len > 2)
1105 lexical_error("Character literal has %d" 1109 lexical_error("Character literal has %d"
1106 " characters instead of 1", 1110 " characters instead of 1",
1107 d.len - 1); 1111 d.len - 1);
1112 }
1108 1113
1114 data_free(d);
1109 return DT_CHAR_LITERAL; 1115 return DT_CHAR_LITERAL;
1110 } 1116 }
1111 YY_BREAK 1117 YY_BREAK
1112case 12: 1118case 13:
1113YY_RULE_SETUP 1119YY_RULE_SETUP
1114#line 200 "dtc-lexer.l" 1120#line 205 "dtc-lexer.l"
1115{ /* label reference */ 1121{ /* label reference */
1116 DPRINT("Ref: %s\n", yytext+1); 1122 DPRINT("Ref: %s\n", yytext+1);
1117 yylval.labelref = xstrdup(yytext+1); 1123 yylval.labelref = xstrdup(yytext+1);
1118 return DT_REF; 1124 return DT_REF;
1119 } 1125 }
1120 YY_BREAK 1126 YY_BREAK
1121case 13: 1127case 14:
1122YY_RULE_SETUP 1128YY_RULE_SETUP
1123#line 206 "dtc-lexer.l" 1129#line 211 "dtc-lexer.l"
1124{ /* new-style path reference */ 1130{ /* new-style path reference */
1125 yytext[yyleng-1] = '\0'; 1131 yytext[yyleng-1] = '\0';
1126 DPRINT("Ref: %s\n", yytext+2); 1132 DPRINT("Ref: %s\n", yytext+2);
@@ -1128,27 +1134,27 @@ YY_RULE_SETUP
1128 return DT_REF; 1134 return DT_REF;
1129 } 1135 }
1130 YY_BREAK 1136 YY_BREAK
1131case 14: 1137case 15:
1132YY_RULE_SETUP 1138YY_RULE_SETUP
1133#line 213 "dtc-lexer.l" 1139#line 218 "dtc-lexer.l"
1134{ 1140{
1135 yylval.byte = strtol(yytext, NULL, 16); 1141 yylval.byte = strtol(yytext, NULL, 16);
1136 DPRINT("Byte: %02x\n", (int)yylval.byte); 1142 DPRINT("Byte: %02x\n", (int)yylval.byte);
1137 return DT_BYTE; 1143 return DT_BYTE;
1138 } 1144 }
1139 YY_BREAK 1145 YY_BREAK
1140case 15: 1146case 16:
1141YY_RULE_SETUP 1147YY_RULE_SETUP
1142#line 219 "dtc-lexer.l" 1148#line 224 "dtc-lexer.l"
1143{ 1149{
1144 DPRINT("/BYTESTRING\n"); 1150 DPRINT("/BYTESTRING\n");
1145 BEGIN_DEFAULT(); 1151 BEGIN_DEFAULT();
1146 return ']'; 1152 return ']';
1147 } 1153 }
1148 YY_BREAK 1154 YY_BREAK
1149case 16: 1155case 17:
1150YY_RULE_SETUP 1156YY_RULE_SETUP
1151#line 225 "dtc-lexer.l" 1157#line 230 "dtc-lexer.l"
1152{ 1158{
1153 DPRINT("PropNodeName: %s\n", yytext); 1159 DPRINT("PropNodeName: %s\n", yytext);
1154 yylval.propnodename = xstrdup((yytext[0] == '\\') ? 1160 yylval.propnodename = xstrdup((yytext[0] == '\\') ?
@@ -1157,75 +1163,75 @@ YY_RULE_SETUP
1157 return DT_PROPNODENAME; 1163 return DT_PROPNODENAME;
1158 } 1164 }
1159 YY_BREAK 1165 YY_BREAK
1160case 17: 1166case 18:
1161YY_RULE_SETUP 1167YY_RULE_SETUP
1162#line 233 "dtc-lexer.l" 1168#line 238 "dtc-lexer.l"
1163{ 1169{
1164 DPRINT("Binary Include\n"); 1170 DPRINT("Binary Include\n");
1165 return DT_INCBIN; 1171 return DT_INCBIN;
1166 } 1172 }
1167 YY_BREAK 1173 YY_BREAK
1168case 18:
1169/* rule 18 can match eol */
1170YY_RULE_SETUP
1171#line 238 "dtc-lexer.l"
1172/* eat whitespace */
1173 YY_BREAK
1174case 19: 1174case 19:
1175/* rule 19 can match eol */ 1175/* rule 19 can match eol */
1176YY_RULE_SETUP 1176YY_RULE_SETUP
1177#line 239 "dtc-lexer.l" 1177#line 243 "dtc-lexer.l"
1178/* eat C-style comments */ 1178/* eat whitespace */
1179 YY_BREAK 1179 YY_BREAK
1180case 20: 1180case 20:
1181/* rule 20 can match eol */ 1181/* rule 20 can match eol */
1182YY_RULE_SETUP 1182YY_RULE_SETUP
1183#line 240 "dtc-lexer.l" 1183#line 244 "dtc-lexer.l"
1184/* eat C++-style comments */ 1184/* eat C-style comments */
1185 YY_BREAK 1185 YY_BREAK
1186case 21: 1186case 21:
1187/* rule 21 can match eol */
1187YY_RULE_SETUP 1188YY_RULE_SETUP
1188#line 242 "dtc-lexer.l" 1189#line 245 "dtc-lexer.l"
1189{ return DT_LSHIFT; }; 1190/* eat C++-style comments */
1190 YY_BREAK 1191 YY_BREAK
1191case 22: 1192case 22:
1192YY_RULE_SETUP 1193YY_RULE_SETUP
1193#line 243 "dtc-lexer.l" 1194#line 247 "dtc-lexer.l"
1194{ return DT_RSHIFT; }; 1195{ return DT_LSHIFT; };
1195 YY_BREAK 1196 YY_BREAK
1196case 23: 1197case 23:
1197YY_RULE_SETUP 1198YY_RULE_SETUP
1198#line 244 "dtc-lexer.l" 1199#line 248 "dtc-lexer.l"
1199{ return DT_LE; }; 1200{ return DT_RSHIFT; };
1200 YY_BREAK 1201 YY_BREAK
1201case 24: 1202case 24:
1202YY_RULE_SETUP 1203YY_RULE_SETUP
1203#line 245 "dtc-lexer.l" 1204#line 249 "dtc-lexer.l"
1204{ return DT_GE; }; 1205{ return DT_LE; };
1205 YY_BREAK 1206 YY_BREAK
1206case 25: 1207case 25:
1207YY_RULE_SETUP 1208YY_RULE_SETUP
1208#line 246 "dtc-lexer.l" 1209#line 250 "dtc-lexer.l"
1209{ return DT_EQ; }; 1210{ return DT_GE; };
1210 YY_BREAK 1211 YY_BREAK
1211case 26: 1212case 26:
1212YY_RULE_SETUP 1213YY_RULE_SETUP
1213#line 247 "dtc-lexer.l" 1214#line 251 "dtc-lexer.l"
1214{ return DT_NE; }; 1215{ return DT_EQ; };
1215 YY_BREAK 1216 YY_BREAK
1216case 27: 1217case 27:
1217YY_RULE_SETUP 1218YY_RULE_SETUP
1218#line 248 "dtc-lexer.l" 1219#line 252 "dtc-lexer.l"
1219{ return DT_AND; }; 1220{ return DT_NE; };
1220 YY_BREAK 1221 YY_BREAK
1221case 28: 1222case 28:
1222YY_RULE_SETUP 1223YY_RULE_SETUP
1223#line 249 "dtc-lexer.l" 1224#line 253 "dtc-lexer.l"
1224{ return DT_OR; }; 1225{ return DT_AND; };
1225 YY_BREAK 1226 YY_BREAK
1226case 29: 1227case 29:
1227YY_RULE_SETUP 1228YY_RULE_SETUP
1228#line 251 "dtc-lexer.l" 1229#line 254 "dtc-lexer.l"
1230{ return DT_OR; };
1231 YY_BREAK
1232case 30:
1233YY_RULE_SETUP
1234#line 256 "dtc-lexer.l"
1229{ 1235{
1230 DPRINT("Char: %c (\\x%02x)\n", yytext[0], 1236 DPRINT("Char: %c (\\x%02x)\n", yytext[0],
1231 (unsigned)yytext[0]); 1237 (unsigned)yytext[0]);
@@ -1241,12 +1247,12 @@ YY_RULE_SETUP
1241 return yytext[0]; 1247 return yytext[0];
1242 } 1248 }
1243 YY_BREAK 1249 YY_BREAK
1244case 30: 1250case 31:
1245YY_RULE_SETUP 1251YY_RULE_SETUP
1246#line 266 "dtc-lexer.l" 1252#line 271 "dtc-lexer.l"
1247ECHO; 1253ECHO;
1248 YY_BREAK 1254 YY_BREAK
1249#line 1250 "dtc-lexer.lex.c" 1255#line 1256 "dtc-lexer.lex.c"
1250 1256
1251 case YY_END_OF_BUFFER: 1257 case YY_END_OF_BUFFER:
1252 { 1258 {
@@ -1388,9 +1394,9 @@ ECHO;
1388 */ 1394 */
1389static int yy_get_next_buffer (void) 1395static int yy_get_next_buffer (void)
1390{ 1396{
1391 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; 1397 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1392 register char *source = (yytext_ptr); 1398 char *source = (yytext_ptr);
1393 register int number_to_move, i; 1399 yy_size_t number_to_move, i;
1394 int ret_val; 1400 int ret_val;
1395 1401
1396 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) 1402 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
@@ -1419,7 +1425,7 @@ static int yy_get_next_buffer (void)
1419 /* Try to read more data. */ 1425 /* Try to read more data. */
1420 1426
1421 /* First move last chars to start of buffer. */ 1427 /* First move last chars to start of buffer. */
1422 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; 1428 number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1423 1429
1424 for ( i = 0; i < number_to_move; ++i ) 1430 for ( i = 0; i < number_to_move; ++i )
1425 *(dest++) = *(source++); 1431 *(dest++) = *(source++);
@@ -1432,7 +1438,7 @@ static int yy_get_next_buffer (void)
1432 1438
1433 else 1439 else
1434 { 1440 {
1435 yy_size_t num_to_read = 1441 int num_to_read =
1436 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; 1442 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1437 1443
1438 while ( num_to_read <= 0 ) 1444 while ( num_to_read <= 0 )
@@ -1446,7 +1452,7 @@ static int yy_get_next_buffer (void)
1446 1452
1447 if ( b->yy_is_our_buffer ) 1453 if ( b->yy_is_our_buffer )
1448 { 1454 {
1449 yy_size_t new_size = b->yy_buf_size * 2; 1455 int new_size = b->yy_buf_size * 2;
1450 1456
1451 if ( new_size <= 0 ) 1457 if ( new_size <= 0 )
1452 b->yy_buf_size += b->yy_buf_size / 8; 1458 b->yy_buf_size += b->yy_buf_size / 8;
@@ -1459,7 +1465,7 @@ static int yy_get_next_buffer (void)
1459 } 1465 }
1460 else 1466 else
1461 /* Can't grow it, we don't own it. */ 1467 /* Can't grow it, we don't own it. */
1462 b->yy_ch_buf = 0; 1468 b->yy_ch_buf = NULL;
1463 1469
1464 if ( ! b->yy_ch_buf ) 1470 if ( ! b->yy_ch_buf )
1465 YY_FATAL_ERROR( 1471 YY_FATAL_ERROR(
@@ -1501,9 +1507,9 @@ static int yy_get_next_buffer (void)
1501 else 1507 else
1502 ret_val = EOB_ACT_CONTINUE_SCAN; 1508 ret_val = EOB_ACT_CONTINUE_SCAN;
1503 1509
1504 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { 1510 if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1505 /* Extend the array by 50%, plus the number we really need. */ 1511 /* Extend the array by 50%, plus the number we really need. */
1506 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); 1512 int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1507 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); 1513 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1508 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1514 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1509 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); 1515 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
@@ -1522,15 +1528,15 @@ static int yy_get_next_buffer (void)
1522 1528
1523 static yy_state_type yy_get_previous_state (void) 1529 static yy_state_type yy_get_previous_state (void)
1524{ 1530{
1525 register yy_state_type yy_current_state; 1531 yy_state_type yy_current_state;
1526 register char *yy_cp; 1532 char *yy_cp;
1527 1533
1528 yy_current_state = (yy_start); 1534 yy_current_state = (yy_start);
1529 yy_current_state += YY_AT_BOL(); 1535 yy_current_state += YY_AT_BOL();
1530 1536
1531 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) 1537 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1532 { 1538 {
1533 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); 1539 YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1534 if ( yy_accept[yy_current_state] ) 1540 if ( yy_accept[yy_current_state] )
1535 { 1541 {
1536 (yy_last_accepting_state) = yy_current_state; 1542 (yy_last_accepting_state) = yy_current_state;
@@ -1539,10 +1545,10 @@ static int yy_get_next_buffer (void)
1539 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1545 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1540 { 1546 {
1541 yy_current_state = (int) yy_def[yy_current_state]; 1547 yy_current_state = (int) yy_def[yy_current_state];
1542 if ( yy_current_state >= 159 ) 1548 if ( yy_current_state >= 166 )
1543 yy_c = yy_meta[(unsigned int) yy_c]; 1549 yy_c = yy_meta[(unsigned int) yy_c];
1544 } 1550 }
1545 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1551 yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
1546 } 1552 }
1547 1553
1548 return yy_current_state; 1554 return yy_current_state;
@@ -1555,10 +1561,10 @@ static int yy_get_next_buffer (void)
1555 */ 1561 */
1556 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) 1562 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1557{ 1563{
1558 register int yy_is_jam; 1564 int yy_is_jam;
1559 register char *yy_cp = (yy_c_buf_p); 1565 char *yy_cp = (yy_c_buf_p);
1560 1566
1561 register YY_CHAR yy_c = 1; 1567 YY_CHAR yy_c = 1;
1562 if ( yy_accept[yy_current_state] ) 1568 if ( yy_accept[yy_current_state] )
1563 { 1569 {
1564 (yy_last_accepting_state) = yy_current_state; 1570 (yy_last_accepting_state) = yy_current_state;
@@ -1567,15 +1573,19 @@ static int yy_get_next_buffer (void)
1567 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1573 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1568 { 1574 {
1569 yy_current_state = (int) yy_def[yy_current_state]; 1575 yy_current_state = (int) yy_def[yy_current_state];
1570 if ( yy_current_state >= 159 ) 1576 if ( yy_current_state >= 166 )
1571 yy_c = yy_meta[(unsigned int) yy_c]; 1577 yy_c = yy_meta[(unsigned int) yy_c];
1572 } 1578 }
1573 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1579 yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
1574 yy_is_jam = (yy_current_state == 158); 1580 yy_is_jam = (yy_current_state == 165);
1575 1581
1576 return yy_is_jam ? 0 : yy_current_state; 1582 return yy_is_jam ? 0 : yy_current_state;
1577} 1583}
1578 1584
1585#ifndef YY_NO_UNPUT
1586
1587#endif
1588
1579#ifndef YY_NO_INPUT 1589#ifndef YY_NO_INPUT
1580#ifdef __cplusplus 1590#ifdef __cplusplus
1581 static int yyinput (void) 1591 static int yyinput (void)
@@ -1600,7 +1610,7 @@ static int yy_get_next_buffer (void)
1600 1610
1601 else 1611 else
1602 { /* need more input */ 1612 { /* need more input */
1603 yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); 1613 int offset = (yy_c_buf_p) - (yytext_ptr);
1604 ++(yy_c_buf_p); 1614 ++(yy_c_buf_p);
1605 1615
1606 switch ( yy_get_next_buffer( ) ) 1616 switch ( yy_get_next_buffer( ) )
@@ -1624,7 +1634,7 @@ static int yy_get_next_buffer (void)
1624 case EOB_ACT_END_OF_FILE: 1634 case EOB_ACT_END_OF_FILE:
1625 { 1635 {
1626 if ( yywrap( ) ) 1636 if ( yywrap( ) )
1627 return EOF; 1637 return 0;
1628 1638
1629 if ( ! (yy_did_buffer_switch_on_eof) ) 1639 if ( ! (yy_did_buffer_switch_on_eof) )
1630 YY_NEW_FILE; 1640 YY_NEW_FILE;
@@ -1727,7 +1737,7 @@ static void yy_load_buffer_state (void)
1727 if ( ! b ) 1737 if ( ! b )
1728 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 1738 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1729 1739
1730 b->yy_buf_size = size; 1740 b->yy_buf_size = (yy_size_t)size;
1731 1741
1732 /* yy_ch_buf has to be 2 characters longer than the size given because 1742 /* yy_ch_buf has to be 2 characters longer than the size given because
1733 * we need to put in 2 end-of-buffer characters. 1743 * we need to put in 2 end-of-buffer characters.
@@ -1874,7 +1884,7 @@ void yypop_buffer_state (void)
1874 */ 1884 */
1875static void yyensure_buffer_stack (void) 1885static void yyensure_buffer_stack (void)
1876{ 1886{
1877 yy_size_t num_to_alloc; 1887 int num_to_alloc;
1878 1888
1879 if (!(yy_buffer_stack)) { 1889 if (!(yy_buffer_stack)) {
1880 1890
@@ -1882,15 +1892,15 @@ static void yyensure_buffer_stack (void)
1882 * scanner will even need a stack. We use 2 instead of 1 to avoid an 1892 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1883 * immediate realloc on the next call. 1893 * immediate realloc on the next call.
1884 */ 1894 */
1885 num_to_alloc = 1; 1895 num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
1886 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc 1896 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1887 (num_to_alloc * sizeof(struct yy_buffer_state*) 1897 (num_to_alloc * sizeof(struct yy_buffer_state*)
1888 ); 1898 );
1889 if ( ! (yy_buffer_stack) ) 1899 if ( ! (yy_buffer_stack) )
1890 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); 1900 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1891 1901
1892 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); 1902 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1893 1903
1894 (yy_buffer_stack_max) = num_to_alloc; 1904 (yy_buffer_stack_max) = num_to_alloc;
1895 (yy_buffer_stack_top) = 0; 1905 (yy_buffer_stack_top) = 0;
1896 return; 1906 return;
@@ -1899,7 +1909,7 @@ static void yyensure_buffer_stack (void)
1899 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ 1909 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1900 1910
1901 /* Increase the buffer to prepare for a possible push. */ 1911 /* Increase the buffer to prepare for a possible push. */
1902 int grow_size = 8 /* arbitrary grow size */; 1912 yy_size_t grow_size = 8 /* arbitrary grow size */;
1903 1913
1904 num_to_alloc = (yy_buffer_stack_max) + grow_size; 1914 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1905 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc 1915 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
@@ -1919,7 +1929,7 @@ static void yyensure_buffer_stack (void)
1919 * @param base the character buffer 1929 * @param base the character buffer
1920 * @param size the size in bytes of the character buffer 1930 * @param size the size in bytes of the character buffer
1921 * 1931 *
1922 * @return the newly allocated buffer state object. 1932 * @return the newly allocated buffer state object.
1923 */ 1933 */
1924YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) 1934YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1925{ 1935{
@@ -1929,7 +1939,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1929 base[size-2] != YY_END_OF_BUFFER_CHAR || 1939 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1930 base[size-1] != YY_END_OF_BUFFER_CHAR ) 1940 base[size-1] != YY_END_OF_BUFFER_CHAR )
1931 /* They forgot to leave room for the EOB's. */ 1941 /* They forgot to leave room for the EOB's. */
1932 return 0; 1942 return NULL;
1933 1943
1934 b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); 1944 b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1935 if ( ! b ) 1945 if ( ! b )
@@ -1938,7 +1948,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1938 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ 1948 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1939 b->yy_buf_pos = b->yy_ch_buf = base; 1949 b->yy_buf_pos = b->yy_ch_buf = base;
1940 b->yy_is_our_buffer = 0; 1950 b->yy_is_our_buffer = 0;
1941 b->yy_input_file = 0; 1951 b->yy_input_file = NULL;
1942 b->yy_n_chars = b->yy_buf_size; 1952 b->yy_n_chars = b->yy_buf_size;
1943 b->yy_is_interactive = 0; 1953 b->yy_is_interactive = 0;
1944 b->yy_at_bol = 1; 1954 b->yy_at_bol = 1;
@@ -1961,7 +1971,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1961YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) 1971YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1962{ 1972{
1963 1973
1964 return yy_scan_bytes(yystr,strlen(yystr) ); 1974 return yy_scan_bytes(yystr,(int) strlen(yystr) );
1965} 1975}
1966 1976
1967/** Setup the input buffer state to scan the given bytes. The next call to yylex() will 1977/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
@@ -1971,7 +1981,7 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1971 * 1981 *
1972 * @return the newly allocated buffer state object. 1982 * @return the newly allocated buffer state object.
1973 */ 1983 */
1974YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) 1984YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
1975{ 1985{
1976 YY_BUFFER_STATE b; 1986 YY_BUFFER_STATE b;
1977 char *buf; 1987 char *buf;
@@ -1979,7 +1989,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
1979 yy_size_t i; 1989 yy_size_t i;
1980 1990
1981 /* Get memory for full buffer, including space for trailing EOB's. */ 1991 /* Get memory for full buffer, including space for trailing EOB's. */
1982 n = _yybytes_len + 2; 1992 n = (yy_size_t) _yybytes_len + 2;
1983 buf = (char *) yyalloc(n ); 1993 buf = (char *) yyalloc(n );
1984 if ( ! buf ) 1994 if ( ! buf )
1985 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); 1995 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
@@ -2005,9 +2015,9 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
2005#define YY_EXIT_FAILURE 2 2015#define YY_EXIT_FAILURE 2
2006#endif 2016#endif
2007 2017
2008static void yy_fatal_error (yyconst char* msg ) 2018static void yynoreturn yy_fatal_error (yyconst char* msg )
2009{ 2019{
2010 (void) fprintf( stderr, "%s\n", msg ); 2020 (void) fprintf( stderr, "%s\n", msg );
2011 exit( YY_EXIT_FAILURE ); 2021 exit( YY_EXIT_FAILURE );
2012} 2022}
2013 2023
@@ -2035,7 +2045,7 @@ static void yy_fatal_error (yyconst char* msg )
2035 */ 2045 */
2036int yyget_lineno (void) 2046int yyget_lineno (void)
2037{ 2047{
2038 2048
2039 return yylineno; 2049 return yylineno;
2040} 2050}
2041 2051
@@ -2058,7 +2068,7 @@ FILE *yyget_out (void)
2058/** Get the length of the current token. 2068/** Get the length of the current token.
2059 * 2069 *
2060 */ 2070 */
2061yy_size_t yyget_leng (void) 2071int yyget_leng (void)
2062{ 2072{
2063 return yyleng; 2073 return yyleng;
2064} 2074}
@@ -2073,29 +2083,29 @@ char *yyget_text (void)
2073} 2083}
2074 2084
2075/** Set the current line number. 2085/** Set the current line number.
2076 * @param line_number 2086 * @param _line_number line number
2077 * 2087 *
2078 */ 2088 */
2079void yyset_lineno (int line_number ) 2089void yyset_lineno (int _line_number )
2080{ 2090{
2081 2091
2082 yylineno = line_number; 2092 yylineno = _line_number;
2083} 2093}
2084 2094
2085/** Set the input stream. This does not discard the current 2095/** Set the input stream. This does not discard the current
2086 * input buffer. 2096 * input buffer.
2087 * @param in_str A readable stream. 2097 * @param _in_str A readable stream.
2088 * 2098 *
2089 * @see yy_switch_to_buffer 2099 * @see yy_switch_to_buffer
2090 */ 2100 */
2091void yyset_in (FILE * in_str ) 2101void yyset_in (FILE * _in_str )
2092{ 2102{
2093 yyin = in_str ; 2103 yyin = _in_str ;
2094} 2104}
2095 2105
2096void yyset_out (FILE * out_str ) 2106void yyset_out (FILE * _out_str )
2097{ 2107{
2098 yyout = out_str ; 2108 yyout = _out_str ;
2099} 2109}
2100 2110
2101int yyget_debug (void) 2111int yyget_debug (void)
@@ -2103,9 +2113,9 @@ int yyget_debug (void)
2103 return yy_flex_debug; 2113 return yy_flex_debug;
2104} 2114}
2105 2115
2106void yyset_debug (int bdebug ) 2116void yyset_debug (int _bdebug )
2107{ 2117{
2108 yy_flex_debug = bdebug ; 2118 yy_flex_debug = _bdebug ;
2109} 2119}
2110 2120
2111static int yy_init_globals (void) 2121static int yy_init_globals (void)
@@ -2114,10 +2124,10 @@ static int yy_init_globals (void)
2114 * This function is called from yylex_destroy(), so don't allocate here. 2124 * This function is called from yylex_destroy(), so don't allocate here.
2115 */ 2125 */
2116 2126
2117 (yy_buffer_stack) = 0; 2127 (yy_buffer_stack) = NULL;
2118 (yy_buffer_stack_top) = 0; 2128 (yy_buffer_stack_top) = 0;
2119 (yy_buffer_stack_max) = 0; 2129 (yy_buffer_stack_max) = 0;
2120 (yy_c_buf_p) = (char *) 0; 2130 (yy_c_buf_p) = NULL;
2121 (yy_init) = 0; 2131 (yy_init) = 0;
2122 (yy_start) = 0; 2132 (yy_start) = 0;
2123 2133
@@ -2126,8 +2136,8 @@ static int yy_init_globals (void)
2126 yyin = stdin; 2136 yyin = stdin;
2127 yyout = stdout; 2137 yyout = stdout;
2128#else 2138#else
2129 yyin = (FILE *) 0; 2139 yyin = NULL;
2130 yyout = (FILE *) 0; 2140 yyout = NULL;
2131#endif 2141#endif
2132 2142
2133 /* For future reference: Set errno on error, since we are called by 2143 /* For future reference: Set errno on error, since we are called by
@@ -2165,7 +2175,8 @@ int yylex_destroy (void)
2165#ifndef yytext_ptr 2175#ifndef yytext_ptr
2166static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) 2176static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2167{ 2177{
2168 register int i; 2178
2179 int i;
2169 for ( i = 0; i < n; ++i ) 2180 for ( i = 0; i < n; ++i )
2170 s1[i] = s2[i]; 2181 s1[i] = s2[i];
2171} 2182}
@@ -2174,7 +2185,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2174#ifdef YY_NEED_STRLEN 2185#ifdef YY_NEED_STRLEN
2175static int yy_flex_strlen (yyconst char * s ) 2186static int yy_flex_strlen (yyconst char * s )
2176{ 2187{
2177 register int n; 2188 int n;
2178 for ( n = 0; s[n]; ++n ) 2189 for ( n = 0; s[n]; ++n )
2179 ; 2190 ;
2180 2191
@@ -2184,11 +2195,12 @@ static int yy_flex_strlen (yyconst char * s )
2184 2195
2185void *yyalloc (yy_size_t size ) 2196void *yyalloc (yy_size_t size )
2186{ 2197{
2187 return (void *) malloc( size ); 2198 return malloc(size);
2188} 2199}
2189 2200
2190void *yyrealloc (void * ptr, yy_size_t size ) 2201void *yyrealloc (void * ptr, yy_size_t size )
2191{ 2202{
2203
2192 /* The cast to (char *) in the following accommodates both 2204 /* The cast to (char *) in the following accommodates both
2193 * implementations that use char* generic pointers, and those 2205 * implementations that use char* generic pointers, and those
2194 * that use void* generic pointers. It works with the latter 2206 * that use void* generic pointers. It works with the latter
@@ -2196,17 +2208,17 @@ void *yyrealloc (void * ptr, yy_size_t size )
2196 * any pointer type to void*, and deal with argument conversions 2208 * any pointer type to void*, and deal with argument conversions
2197 * as though doing an assignment. 2209 * as though doing an assignment.
2198 */ 2210 */
2199 return (void *) realloc( (char *) ptr, size ); 2211 return realloc(ptr, size);
2200} 2212}
2201 2213
2202void yyfree (void * ptr ) 2214void yyfree (void * ptr )
2203{ 2215{
2204 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ 2216 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
2205} 2217}
2206 2218
2207#define YYTABLES_NAME "yytables" 2219#define YYTABLES_NAME "yytables"
2208 2220
2209#line 265 "dtc-lexer.l" 2221#line 271 "dtc-lexer.l"
2210 2222
2211 2223
2212 2224
diff --git a/scripts/dtc/dtc-parser.tab.c_shipped b/scripts/dtc/dtc-parser.tab.c_shipped
index 31cec50a1265..2965227a1b4a 100644
--- a/scripts/dtc/dtc-parser.tab.c_shipped
+++ b/scripts/dtc/dtc-parser.tab.c_shipped
@@ -1,8 +1,8 @@
1/* A Bison parser, made by GNU Bison 3.0.2. */ 1/* A Bison parser, made by GNU Bison 3.0.4. */
2 2
3/* Bison implementation for Yacc-like parsers in C 3/* Bison implementation for Yacc-like parsers in C
4 4
5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. 5 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6 6
7 This program is free software: you can redistribute it and/or modify 7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@
44#define YYBISON 1 44#define YYBISON 1
45 45
46/* Bison version. */ 46/* Bison version. */
47#define YYBISON_VERSION "3.0.2" 47#define YYBISON_VERSION "3.0.4"
48 48
49/* Skeleton name. */ 49/* Skeleton name. */
50#define YYSKELETON_NAME "yacc.c" 50#define YYSKELETON_NAME "yacc.c"
@@ -65,6 +65,7 @@
65#line 20 "dtc-parser.y" /* yacc.c:339 */ 65#line 20 "dtc-parser.y" /* yacc.c:339 */
66 66
67#include <stdio.h> 67#include <stdio.h>
68#include <inttypes.h>
68 69
69#include "dtc.h" 70#include "dtc.h"
70#include "srcpos.h" 71#include "srcpos.h"
@@ -77,10 +78,10 @@ extern void yyerror(char const *s);
77 treesource_error = true; \ 78 treesource_error = true; \
78 } while (0) 79 } while (0)
79 80
80extern struct boot_info *the_boot_info; 81extern struct dt_info *parser_output;
81extern bool treesource_error; 82extern bool treesource_error;
82 83
83#line 84 "dtc-parser.tab.c" /* yacc.c:339 */ 84#line 85 "dtc-parser.tab.c" /* yacc.c:339 */
84 85
85# ifndef YY_NULLPTR 86# ifndef YY_NULLPTR
86# if defined __cplusplus && 201103L <= __cplusplus 87# if defined __cplusplus && 201103L <= __cplusplus
@@ -116,35 +117,36 @@ extern int yydebug;
116 enum yytokentype 117 enum yytokentype
117 { 118 {
118 DT_V1 = 258, 119 DT_V1 = 258,
119 DT_MEMRESERVE = 259, 120 DT_PLUGIN = 259,
120 DT_LSHIFT = 260, 121 DT_MEMRESERVE = 260,
121 DT_RSHIFT = 261, 122 DT_LSHIFT = 261,
122 DT_LE = 262, 123 DT_RSHIFT = 262,
123 DT_GE = 263, 124 DT_LE = 263,
124 DT_EQ = 264, 125 DT_GE = 264,
125 DT_NE = 265, 126 DT_EQ = 265,
126 DT_AND = 266, 127 DT_NE = 266,
127 DT_OR = 267, 128 DT_AND = 267,
128 DT_BITS = 268, 129 DT_OR = 268,
129 DT_DEL_PROP = 269, 130 DT_BITS = 269,
130 DT_DEL_NODE = 270, 131 DT_DEL_PROP = 270,
131 DT_PROPNODENAME = 271, 132 DT_DEL_NODE = 271,
132 DT_LITERAL = 272, 133 DT_PROPNODENAME = 272,
133 DT_CHAR_LITERAL = 273, 134 DT_LITERAL = 273,
134 DT_BYTE = 274, 135 DT_CHAR_LITERAL = 274,
135 DT_STRING = 275, 136 DT_BYTE = 275,
136 DT_LABEL = 276, 137 DT_STRING = 276,
137 DT_REF = 277, 138 DT_LABEL = 277,
138 DT_INCBIN = 278 139 DT_REF = 278,
140 DT_INCBIN = 279
139 }; 141 };
140#endif 142#endif
141 143
142/* Value type. */ 144/* Value type. */
143#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 145#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
144typedef union YYSTYPE YYSTYPE; 146
145union YYSTYPE 147union YYSTYPE
146{ 148{
147#line 38 "dtc-parser.y" /* yacc.c:355 */ 149#line 39 "dtc-parser.y" /* yacc.c:355 */
148 150
149 char *propnodename; 151 char *propnodename;
150 char *labelref; 152 char *labelref;
@@ -162,9 +164,12 @@ union YYSTYPE
162 struct node *nodelist; 164 struct node *nodelist;
163 struct reserve_info *re; 165 struct reserve_info *re;
164 uint64_t integer; 166 uint64_t integer;
167 unsigned int flags;
165 168
166#line 167 "dtc-parser.tab.c" /* yacc.c:355 */ 169#line 170 "dtc-parser.tab.c" /* yacc.c:355 */
167}; 170};
171
172typedef union YYSTYPE YYSTYPE;
168# define YYSTYPE_IS_TRIVIAL 1 173# define YYSTYPE_IS_TRIVIAL 1
169# define YYSTYPE_IS_DECLARED 1 174# define YYSTYPE_IS_DECLARED 1
170#endif 175#endif
@@ -192,7 +197,7 @@ int yyparse (void);
192 197
193/* Copy the second part of user declarations. */ 198/* Copy the second part of user declarations. */
194 199
195#line 196 "dtc-parser.tab.c" /* yacc.c:358 */ 200#line 201 "dtc-parser.tab.c" /* yacc.c:358 */
196 201
197#ifdef short 202#ifdef short
198# undef short 203# undef short
@@ -434,23 +439,23 @@ union yyalloc
434#endif /* !YYCOPY_NEEDED */ 439#endif /* !YYCOPY_NEEDED */
435 440
436/* YYFINAL -- State number of the termination state. */ 441/* YYFINAL -- State number of the termination state. */
437#define YYFINAL 4 442#define YYFINAL 6
438/* YYLAST -- Last index in YYTABLE. */ 443/* YYLAST -- Last index in YYTABLE. */
439#define YYLAST 136 444#define YYLAST 138
440 445
441/* YYNTOKENS -- Number of terminals. */ 446/* YYNTOKENS -- Number of terminals. */
442#define YYNTOKENS 47 447#define YYNTOKENS 48
443/* YYNNTS -- Number of nonterminals. */ 448/* YYNNTS -- Number of nonterminals. */
444#define YYNNTS 28 449#define YYNNTS 30
445/* YYNRULES -- Number of rules. */ 450/* YYNRULES -- Number of rules. */
446#define YYNRULES 80 451#define YYNRULES 84
447/* YYNSTATES -- Number of states. */ 452/* YYNSTATES -- Number of states. */
448#define YYNSTATES 144 453#define YYNSTATES 149
449 454
450/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned 455/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
451 by yylex, with out-of-bounds checking. */ 456 by yylex, with out-of-bounds checking. */
452#define YYUNDEFTOK 2 457#define YYUNDEFTOK 2
453#define YYMAXUTOK 278 458#define YYMAXUTOK 279
454 459
455#define YYTRANSLATE(YYX) \ 460#define YYTRANSLATE(YYX) \
456 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 461 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -462,16 +467,16 @@ static const yytype_uint8 yytranslate[] =
462 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 467 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 468 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
464 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 469 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
465 2, 2, 2, 46, 2, 2, 2, 44, 40, 2, 470 2, 2, 2, 47, 2, 2, 2, 45, 41, 2,
466 32, 34, 43, 41, 33, 42, 2, 25, 2, 2, 471 33, 35, 44, 42, 34, 43, 2, 26, 2, 2,
467 2, 2, 2, 2, 2, 2, 2, 2, 37, 24, 472 2, 2, 2, 2, 2, 2, 2, 2, 38, 25,
468 35, 28, 29, 36, 2, 2, 2, 2, 2, 2, 473 36, 29, 30, 37, 2, 2, 2, 2, 2, 2,
469 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 474 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 475 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
471 2, 30, 2, 31, 39, 2, 2, 2, 2, 2, 476 2, 31, 2, 32, 40, 2, 2, 2, 2, 2,
472 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 477 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
473 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 478 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
474 2, 2, 2, 26, 38, 27, 45, 2, 2, 2, 479 2, 2, 2, 27, 39, 28, 46, 2, 2, 2,
475 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 480 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
476 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 481 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
477 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 482 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -486,22 +491,22 @@ static const yytype_uint8 yytranslate[] =
486 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 491 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
487 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 492 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
488 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 493 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
489 15, 16, 17, 18, 19, 20, 21, 22, 23 494 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
490}; 495};
491 496
492#if YYDEBUG 497#if YYDEBUG
493 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ 498 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
494static const yytype_uint16 yyrline[] = 499static const yytype_uint16 yyrline[] =
495{ 500{
496 0, 104, 104, 113, 116, 123, 127, 135, 139, 144, 501 0, 109, 109, 117, 121, 128, 129, 139, 142, 149,
497 155, 165, 180, 188, 191, 198, 202, 206, 210, 218, 502 153, 161, 165, 170, 181, 191, 206, 214, 217, 224,
498 222, 226, 230, 234, 250, 260, 268, 271, 275, 282, 503 228, 232, 236, 244, 248, 252, 256, 260, 276, 286,
499 298, 303, 322, 336, 343, 344, 345, 352, 356, 357, 504 294, 297, 301, 308, 324, 329, 348, 362, 369, 370,
500 361, 362, 366, 367, 371, 372, 376, 377, 381, 382, 505 371, 378, 382, 383, 387, 388, 392, 393, 397, 398,
501 386, 387, 388, 392, 393, 394, 395, 396, 400, 401, 506 402, 403, 407, 408, 412, 413, 414, 418, 419, 420,
502 402, 406, 407, 408, 412, 413, 422, 431, 435, 436, 507 421, 422, 426, 427, 428, 432, 433, 434, 438, 439,
503 437, 438, 443, 446, 450, 458, 461, 465, 473, 477, 508 448, 457, 461, 462, 463, 464, 469, 472, 476, 484,
504 481 509 487, 491, 499, 503, 507
505}; 510};
506#endif 511#endif
507 512
@@ -510,19 +515,20 @@ static const yytype_uint16 yyrline[] =
510 First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 515 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
511static const char *const yytname[] = 516static const char *const yytname[] =
512{ 517{
513 "$end", "error", "$undefined", "DT_V1", "DT_MEMRESERVE", "DT_LSHIFT", 518 "$end", "error", "$undefined", "DT_V1", "DT_PLUGIN", "DT_MEMRESERVE",
514 "DT_RSHIFT", "DT_LE", "DT_GE", "DT_EQ", "DT_NE", "DT_AND", "DT_OR", 519 "DT_LSHIFT", "DT_RSHIFT", "DT_LE", "DT_GE", "DT_EQ", "DT_NE", "DT_AND",
515 "DT_BITS", "DT_DEL_PROP", "DT_DEL_NODE", "DT_PROPNODENAME", "DT_LITERAL", 520 "DT_OR", "DT_BITS", "DT_DEL_PROP", "DT_DEL_NODE", "DT_PROPNODENAME",
516 "DT_CHAR_LITERAL", "DT_BYTE", "DT_STRING", "DT_LABEL", "DT_REF", 521 "DT_LITERAL", "DT_CHAR_LITERAL", "DT_BYTE", "DT_STRING", "DT_LABEL",
517 "DT_INCBIN", "';'", "'/'", "'{'", "'}'", "'='", "'>'", "'['", "']'", 522 "DT_REF", "DT_INCBIN", "';'", "'/'", "'{'", "'}'", "'='", "'>'", "'['",
518 "'('", "','", "')'", "'<'", "'?'", "':'", "'|'", "'^'", "'&'", "'+'", 523 "']'", "'('", "','", "')'", "'<'", "'?'", "':'", "'|'", "'^'", "'&'",
519 "'-'", "'*'", "'%'", "'~'", "'!'", "$accept", "sourcefile", 524 "'+'", "'-'", "'*'", "'%'", "'~'", "'!'", "$accept", "sourcefile",
520 "memreserves", "memreserve", "devicetree", "nodedef", "proplist", 525 "header", "headers", "memreserves", "memreserve", "devicetree",
521 "propdef", "propdata", "propdataprefix", "arrayprefix", "integer_prim", 526 "nodedef", "proplist", "propdef", "propdata", "propdataprefix",
522 "integer_expr", "integer_trinary", "integer_or", "integer_and", 527 "arrayprefix", "integer_prim", "integer_expr", "integer_trinary",
523 "integer_bitor", "integer_bitxor", "integer_bitand", "integer_eq", 528 "integer_or", "integer_and", "integer_bitor", "integer_bitxor",
524 "integer_rela", "integer_shift", "integer_add", "integer_mul", 529 "integer_bitand", "integer_eq", "integer_rela", "integer_shift",
525 "integer_unary", "bytestring", "subnodes", "subnode", YY_NULLPTR 530 "integer_add", "integer_mul", "integer_unary", "bytestring", "subnodes",
531 "subnode", YY_NULLPTR
526}; 532};
527#endif 533#endif
528 534
@@ -533,16 +539,16 @@ static const yytype_uint16 yytoknum[] =
533{ 539{
534 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 540 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
535 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 541 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
536 275, 276, 277, 278, 59, 47, 123, 125, 61, 62, 542 275, 276, 277, 278, 279, 59, 47, 123, 125, 61,
537 91, 93, 40, 44, 41, 60, 63, 58, 124, 94, 543 62, 91, 93, 40, 44, 41, 60, 63, 58, 124,
538 38, 43, 45, 42, 37, 126, 33 544 94, 38, 43, 45, 42, 37, 126, 33
539}; 545};
540# endif 546# endif
541 547
542#define YYPACT_NINF -81 548#define YYPACT_NINF -44
543 549
544#define yypact_value_is_default(Yystate) \ 550#define yypact_value_is_default(Yystate) \
545 (!!((Yystate) == (-81))) 551 (!!((Yystate) == (-44)))
546 552
547#define YYTABLE_NINF -1 553#define YYTABLE_NINF -1
548 554
@@ -553,21 +559,21 @@ static const yytype_uint16 yytoknum[] =
553 STATE-NUM. */ 559 STATE-NUM. */
554static const yytype_int8 yypact[] = 560static const yytype_int8 yypact[] =
555{ 561{
556 16, -11, 21, 10, -81, 25, 10, 19, 10, -81, 562 14, 27, 61, 14, 8, 18, -44, -44, 37, 8,
557 -81, -9, 25, -81, 2, 51, -81, -9, -9, -9, 563 40, 8, 64, -44, -44, -12, 37, -44, 50, 52,
558 -81, 1, -81, -6, 50, 14, 28, 29, 36, 3, 564 -44, -44, -12, -12, -12, -44, 51, -44, -4, 78,
559 58, 44, -3, -81, 47, -81, -81, 65, 68, 2, 565 53, 54, 55, 17, 2, 30, 38, -3, -44, 66,
560 2, -81, -81, -81, -81, -9, -9, -9, -9, -9, 566 -44, -44, 70, 72, 50, 50, -44, -44, -44, -44,
561 -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, 567 -12, -12, -12, -12, -12, -12, -12, -12, -12, -12,
562 -9, -9, -9, -9, -81, 63, 69, 2, -81, -81, 568 -12, -12, -12, -12, -12, -12, -12, -12, -12, -44,
563 50, 57, 14, 28, 29, 36, 3, 3, 58, 58, 569 3, 73, 50, -44, -44, 78, 59, 53, 54, 55,
564 58, 58, 44, 44, -3, -3, -81, -81, -81, 79, 570 17, 2, 2, 30, 30, 30, 30, 38, 38, -3,
565 80, -8, 63, -81, 72, 63, -81, -81, -9, 76, 571 -3, -44, -44, -44, 82, 83, 44, 3, -44, 74,
566 77, -81, -81, -81, -81, -81, 78, -81, -81, -81, 572 3, -44, -44, -12, 76, 79, -44, -44, -44, -44,
567 -81, -81, 35, 4, -81, -81, -81, -81, 86, -81, 573 -44, 80, -44, -44, -44, -44, -44, -10, 36, -44,
568 -81, -81, 73, -81, -81, 33, 71, 84, 39, -81, 574 -44, -44, -44, 85, -44, -44, -44, 75, -44, -44,
569 -81, -81, -81, -81, 41, -81, -81, -81, 25, -81, 575 21, 71, 88, -6, -44, -44, -44, -44, -44, 11,
570 74, 25, 75, -81 576 -44, -44, -44, 37, -44, 77, 37, 81, -44
571}; 577};
572 578
573 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. 579 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -575,37 +581,37 @@ static const yytype_int8 yypact[] =
575 means the default is an error. */ 581 means the default is an error. */
576static const yytype_uint8 yydefact[] = 582static const yytype_uint8 yydefact[] =
577{ 583{
578 0, 0, 0, 3, 1, 0, 0, 0, 3, 34, 584 0, 0, 0, 5, 7, 3, 1, 6, 0, 0,
579 35, 0, 0, 6, 0, 2, 4, 0, 0, 0, 585 0, 7, 0, 38, 39, 0, 0, 10, 0, 2,
580 68, 0, 37, 38, 40, 42, 44, 46, 48, 50, 586 8, 4, 0, 0, 0, 72, 0, 41, 42, 44,
581 53, 60, 63, 67, 0, 13, 7, 0, 0, 0, 587 46, 48, 50, 52, 54, 57, 64, 67, 71, 0,
582 0, 69, 70, 71, 36, 0, 0, 0, 0, 0, 588 17, 11, 0, 0, 0, 0, 73, 74, 75, 40,
583 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 589 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
584 0, 0, 0, 0, 5, 75, 0, 0, 10, 8, 590 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
585 41, 0, 43, 45, 47, 49, 51, 52, 56, 57, 591 79, 0, 0, 14, 12, 45, 0, 47, 49, 51,
586 55, 54, 58, 59, 61, 62, 65, 64, 66, 0, 592 53, 55, 56, 60, 61, 59, 58, 62, 63, 65,
587 0, 0, 0, 14, 0, 75, 11, 9, 0, 0, 593 66, 69, 68, 70, 0, 0, 0, 0, 18, 0,
588 0, 16, 26, 78, 18, 80, 0, 77, 76, 39, 594 79, 15, 13, 0, 0, 0, 20, 30, 82, 22,
589 17, 79, 0, 0, 12, 25, 15, 27, 0, 19, 595 84, 0, 81, 80, 43, 21, 83, 0, 0, 16,
590 28, 22, 0, 72, 30, 0, 0, 0, 0, 33, 596 29, 19, 31, 0, 23, 32, 26, 0, 76, 34,
591 32, 20, 31, 29, 0, 73, 74, 21, 0, 24, 597 0, 0, 0, 0, 37, 36, 24, 35, 33, 0,
592 0, 0, 0, 23 598 77, 78, 25, 0, 28, 0, 0, 0, 27
593}; 599};
594 600
595 /* YYPGOTO[NTERM-NUM]. */ 601 /* YYPGOTO[NTERM-NUM]. */
596static const yytype_int8 yypgoto[] = 602static const yytype_int8 yypgoto[] =
597{ 603{
598 -81, -81, 100, 104, -81, -38, -81, -80, -81, -81, 604 -44, -44, -44, 103, 99, 104, -44, -43, -44, -21,
599 -81, -5, 66, 13, -81, 70, 67, 81, 64, 82, 605 -44, -44, -44, -8, 63, 9, -44, 65, 67, 68,
600 37, 27, 34, 38, -14, -81, 22, 24 606 69, 62, 26, 4, 22, 23, -19, -44, 20, 28
601}; 607};
602 608
603 /* YYDEFGOTO[NTERM-NUM]. */ 609 /* YYDEFGOTO[NTERM-NUM]. */
604static const yytype_int16 yydefgoto[] = 610static const yytype_int16 yydefgoto[] =
605{ 611{
606 -1, 2, 7, 8, 15, 36, 65, 93, 112, 113, 612 -1, 2, 3, 4, 10, 11, 19, 41, 70, 98,
607 125, 20, 21, 22, 23, 24, 25, 26, 27, 28, 613 117, 118, 130, 25, 26, 27, 28, 29, 30, 31,
608 29, 30, 31, 32, 33, 128, 94, 95 614 32, 33, 34, 35, 36, 37, 38, 133, 99, 100
609}; 615};
610 616
611 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If 617 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
@@ -613,87 +619,87 @@ static const yytype_int16 yydefgoto[] =
613 number is the opposite. If YYTABLE_NINF, syntax error. */ 619 number is the opposite. If YYTABLE_NINF, syntax error. */
614static const yytype_uint8 yytable[] = 620static const yytype_uint8 yytable[] =
615{ 621{
616 12, 68, 69, 41, 42, 43, 45, 34, 9, 10, 622 16, 73, 74, 46, 47, 48, 13, 14, 39, 50,
617 53, 54, 104, 3, 5, 107, 101, 118, 35, 1, 623 58, 59, 120, 8, 140, 121, 141, 1, 94, 95,
618 102, 4, 61, 11, 119, 120, 121, 122, 35, 97, 624 96, 15, 12, 66, 122, 97, 142, 56, 57, 102,
619 46, 6, 55, 17, 123, 44, 18, 19, 56, 124, 625 9, 22, 60, 51, 23, 24, 62, 63, 61, 13,
620 62, 63, 9, 10, 14, 51, 52, 86, 87, 88, 626 14, 67, 68, 134, 135, 143, 144, 91, 92, 93,
621 9, 10, 48, 103, 129, 130, 115, 11, 135, 116, 627 123, 136, 5, 108, 15, 13, 14, 124, 125, 126,
622 136, 47, 131, 57, 58, 11, 37, 49, 117, 50, 628 127, 6, 83, 84, 85, 86, 18, 128, 42, 106,
623 137, 64, 38, 39, 138, 139, 40, 89, 90, 91, 629 15, 40, 129, 107, 43, 44, 109, 40, 45, 112,
624 78, 79, 80, 81, 92, 59, 60, 66, 76, 77, 630 64, 65, 81, 82, 87, 88, 49, 89, 90, 21,
625 67, 82, 83, 96, 98, 99, 100, 84, 85, 106, 631 52, 69, 53, 71, 54, 72, 55, 103, 101, 104,
626 110, 111, 114, 126, 134, 127, 133, 141, 16, 143, 632 105, 115, 111, 131, 116, 119, 7, 138, 132, 139,
627 13, 109, 71, 74, 72, 70, 105, 108, 0, 0, 633 20, 146, 114, 17, 76, 75, 148, 80, 0, 77,
628 132, 0, 0, 0, 0, 0, 0, 0, 0, 73, 634 113, 78, 137, 79, 0, 110, 0, 0, 0, 0,
629 0, 0, 75, 140, 0, 0, 142 635 0, 0, 0, 0, 0, 145, 0, 0, 147
630}; 636};
631 637
632static const yytype_int16 yycheck[] = 638static const yytype_int16 yycheck[] =
633{ 639{
634 5, 39, 40, 17, 18, 19, 12, 12, 17, 18, 640 8, 44, 45, 22, 23, 24, 18, 19, 16, 13,
635 7, 8, 92, 24, 4, 95, 24, 13, 26, 3, 641 8, 9, 22, 5, 20, 25, 22, 3, 15, 16,
636 28, 0, 25, 32, 20, 21, 22, 23, 26, 67, 642 17, 33, 4, 26, 34, 22, 32, 10, 11, 72,
637 36, 21, 29, 42, 30, 34, 45, 46, 35, 35, 643 22, 43, 30, 37, 46, 47, 6, 7, 36, 18,
638 43, 44, 17, 18, 25, 9, 10, 61, 62, 63, 644 19, 44, 45, 22, 23, 34, 35, 66, 67, 68,
639 17, 18, 38, 91, 21, 22, 21, 32, 19, 24, 645 14, 30, 25, 96, 33, 18, 19, 21, 22, 23,
640 21, 11, 29, 5, 6, 32, 15, 39, 33, 40, 646 24, 0, 58, 59, 60, 61, 26, 31, 16, 25,
641 31, 24, 21, 22, 33, 34, 25, 14, 15, 16, 647 33, 27, 36, 29, 22, 23, 97, 27, 26, 100,
642 53, 54, 55, 56, 21, 41, 42, 22, 51, 52, 648 42, 43, 56, 57, 62, 63, 35, 64, 65, 25,
643 22, 57, 58, 24, 37, 16, 16, 59, 60, 27, 649 12, 25, 39, 23, 40, 23, 41, 38, 25, 17,
644 24, 24, 24, 17, 20, 32, 35, 33, 8, 34, 650 17, 25, 28, 18, 25, 25, 3, 36, 33, 21,
645 6, 98, 46, 49, 47, 45, 92, 95, -1, -1, 651 11, 34, 103, 9, 51, 50, 35, 55, -1, 52,
646 125, -1, -1, -1, -1, -1, -1, -1, -1, 48, 652 100, 53, 130, 54, -1, 97, -1, -1, -1, -1,
647 -1, -1, 50, 138, -1, -1, 141 653 -1, -1, -1, -1, -1, 143, -1, -1, 146
648}; 654};
649 655
650 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 656 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
651 symbol of state STATE-NUM. */ 657 symbol of state STATE-NUM. */
652static const yytype_uint8 yystos[] = 658static const yytype_uint8 yystos[] =
653{ 659{
654 0, 3, 48, 24, 0, 4, 21, 49, 50, 17, 660 0, 3, 49, 50, 51, 25, 0, 51, 5, 22,
655 18, 32, 58, 50, 25, 51, 49, 42, 45, 46, 661 52, 53, 4, 18, 19, 33, 61, 53, 26, 54,
656 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 662 52, 25, 43, 46, 47, 61, 62, 63, 64, 65,
657 68, 69, 70, 71, 58, 26, 52, 15, 21, 22, 663 66, 67, 68, 69, 70, 71, 72, 73, 74, 61,
658 25, 71, 71, 71, 34, 12, 36, 11, 38, 39, 664 27, 55, 16, 22, 23, 26, 74, 74, 74, 35,
659 40, 9, 10, 7, 8, 29, 35, 5, 6, 41, 665 13, 37, 12, 39, 40, 41, 10, 11, 8, 9,
660 42, 25, 43, 44, 24, 53, 22, 22, 52, 52, 666 30, 36, 6, 7, 42, 43, 26, 44, 45, 25,
661 62, 59, 63, 64, 65, 66, 67, 67, 68, 68, 667 56, 23, 23, 55, 55, 65, 62, 66, 67, 68,
662 68, 68, 69, 69, 70, 70, 71, 71, 71, 14, 668 69, 70, 70, 71, 71, 71, 71, 72, 72, 73,
663 15, 16, 21, 54, 73, 74, 24, 52, 37, 16, 669 73, 74, 74, 74, 15, 16, 17, 22, 57, 76,
664 16, 24, 28, 52, 54, 74, 27, 54, 73, 60, 670 77, 25, 55, 38, 17, 17, 25, 29, 55, 57,
665 24, 24, 55, 56, 24, 21, 24, 33, 13, 20, 671 77, 28, 57, 76, 63, 25, 25, 58, 59, 25,
666 21, 22, 23, 30, 35, 57, 17, 32, 72, 21, 672 22, 25, 34, 14, 21, 22, 23, 24, 31, 36,
667 22, 29, 58, 35, 20, 19, 21, 31, 33, 34, 673 60, 18, 33, 75, 22, 23, 30, 61, 36, 21,
668 58, 33, 58, 34 674 20, 22, 32, 34, 35, 61, 34, 61, 35
669}; 675};
670 676
671 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 677 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
672static const yytype_uint8 yyr1[] = 678static const yytype_uint8 yyr1[] =
673{ 679{
674 0, 47, 48, 49, 49, 50, 50, 51, 51, 51, 680 0, 48, 49, 50, 50, 51, 51, 52, 52, 53,
675 51, 51, 52, 53, 53, 54, 54, 54, 54, 55, 681 53, 54, 54, 54, 54, 54, 55, 56, 56, 57,
676 55, 55, 55, 55, 55, 55, 56, 56, 56, 57, 682 57, 57, 57, 58, 58, 58, 58, 58, 58, 58,
677 57, 57, 57, 57, 58, 58, 58, 59, 60, 60, 683 59, 59, 59, 60, 60, 60, 60, 60, 61, 61,
678 61, 61, 62, 62, 63, 63, 64, 64, 65, 65, 684 61, 62, 63, 63, 64, 64, 65, 65, 66, 66,
679 66, 66, 66, 67, 67, 67, 67, 67, 68, 68, 685 67, 67, 68, 68, 69, 69, 69, 70, 70, 70,
680 68, 69, 69, 69, 70, 70, 70, 70, 71, 71, 686 70, 70, 71, 71, 71, 72, 72, 72, 73, 73,
681 71, 71, 72, 72, 72, 73, 73, 73, 74, 74, 687 73, 73, 74, 74, 74, 74, 75, 75, 75, 76,
682 74 688 76, 76, 77, 77, 77
683}; 689};
684 690
685 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ 691 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
686static const yytype_uint8 yyr2[] = 692static const yytype_uint8 yyr2[] =
687{ 693{
688 0, 2, 4, 0, 2, 4, 2, 2, 3, 4, 694 0, 2, 3, 2, 4, 1, 2, 0, 2, 4,
689 3, 4, 5, 0, 2, 4, 2, 3, 2, 2, 695 2, 2, 3, 4, 3, 4, 5, 0, 2, 4,
690 3, 4, 2, 9, 5, 2, 0, 2, 2, 3, 696 2, 3, 2, 2, 3, 4, 2, 9, 5, 2,
691 1, 2, 2, 2, 1, 1, 3, 1, 1, 5, 697 0, 2, 2, 3, 1, 2, 2, 2, 1, 1,
692 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 698 3, 1, 1, 5, 1, 3, 1, 3, 1, 3,
693 1, 3, 3, 1, 3, 3, 3, 3, 3, 3, 699 1, 3, 1, 3, 1, 3, 3, 1, 3, 3,
694 1, 3, 3, 1, 3, 3, 3, 1, 1, 2, 700 3, 3, 3, 3, 1, 3, 3, 1, 3, 3,
695 2, 2, 0, 2, 2, 0, 2, 2, 2, 3, 701 3, 1, 1, 2, 2, 2, 0, 2, 2, 0,
696 2 702 2, 2, 2, 3, 2
697}; 703};
698 704
699 705
@@ -1463,65 +1469,91 @@ yyreduce:
1463 switch (yyn) 1469 switch (yyn)
1464 { 1470 {
1465 case 2: 1471 case 2:
1466#line 105 "dtc-parser.y" /* yacc.c:1646 */ 1472#line 110 "dtc-parser.y" /* yacc.c:1646 */
1467 { 1473 {
1468 the_boot_info = build_boot_info((yyvsp[-1].re), (yyvsp[0].node), 1474 parser_output = build_dt_info((yyvsp[-2].flags), (yyvsp[-1].re), (yyvsp[0].node),
1469 guess_boot_cpuid((yyvsp[0].node))); 1475 guess_boot_cpuid((yyvsp[0].node)));
1470 } 1476 }
1471#line 1472 "dtc-parser.tab.c" /* yacc.c:1646 */ 1477#line 1478 "dtc-parser.tab.c" /* yacc.c:1646 */
1472 break; 1478 break;
1473 1479
1474 case 3: 1480 case 3:
1475#line 113 "dtc-parser.y" /* yacc.c:1646 */ 1481#line 118 "dtc-parser.y" /* yacc.c:1646 */
1476 { 1482 {
1477 (yyval.re) = NULL; 1483 (yyval.flags) = DTSF_V1;
1478 } 1484 }
1479#line 1480 "dtc-parser.tab.c" /* yacc.c:1646 */ 1485#line 1486 "dtc-parser.tab.c" /* yacc.c:1646 */
1480 break; 1486 break;
1481 1487
1482 case 4: 1488 case 4:
1483#line 117 "dtc-parser.y" /* yacc.c:1646 */ 1489#line 122 "dtc-parser.y" /* yacc.c:1646 */
1490 {
1491 (yyval.flags) = DTSF_V1 | DTSF_PLUGIN;
1492 }
1493#line 1494 "dtc-parser.tab.c" /* yacc.c:1646 */
1494 break;
1495
1496 case 6:
1497#line 130 "dtc-parser.y" /* yacc.c:1646 */
1498 {
1499 if ((yyvsp[0].flags) != (yyvsp[-1].flags))
1500 ERROR(&(yylsp[0]), "Header flags don't match earlier ones");
1501 (yyval.flags) = (yyvsp[-1].flags);
1502 }
1503#line 1504 "dtc-parser.tab.c" /* yacc.c:1646 */
1504 break;
1505
1506 case 7:
1507#line 139 "dtc-parser.y" /* yacc.c:1646 */
1508 {
1509 (yyval.re) = NULL;
1510 }
1511#line 1512 "dtc-parser.tab.c" /* yacc.c:1646 */
1512 break;
1513
1514 case 8:
1515#line 143 "dtc-parser.y" /* yacc.c:1646 */
1484 { 1516 {
1485 (yyval.re) = chain_reserve_entry((yyvsp[-1].re), (yyvsp[0].re)); 1517 (yyval.re) = chain_reserve_entry((yyvsp[-1].re), (yyvsp[0].re));
1486 } 1518 }
1487#line 1488 "dtc-parser.tab.c" /* yacc.c:1646 */ 1519#line 1520 "dtc-parser.tab.c" /* yacc.c:1646 */
1488 break; 1520 break;
1489 1521
1490 case 5: 1522 case 9:
1491#line 124 "dtc-parser.y" /* yacc.c:1646 */ 1523#line 150 "dtc-parser.y" /* yacc.c:1646 */
1492 { 1524 {
1493 (yyval.re) = build_reserve_entry((yyvsp[-2].integer), (yyvsp[-1].integer)); 1525 (yyval.re) = build_reserve_entry((yyvsp[-2].integer), (yyvsp[-1].integer));
1494 } 1526 }
1495#line 1496 "dtc-parser.tab.c" /* yacc.c:1646 */ 1527#line 1528 "dtc-parser.tab.c" /* yacc.c:1646 */
1496 break; 1528 break;
1497 1529
1498 case 6: 1530 case 10:
1499#line 128 "dtc-parser.y" /* yacc.c:1646 */ 1531#line 154 "dtc-parser.y" /* yacc.c:1646 */
1500 { 1532 {
1501 add_label(&(yyvsp[0].re)->labels, (yyvsp[-1].labelref)); 1533 add_label(&(yyvsp[0].re)->labels, (yyvsp[-1].labelref));
1502 (yyval.re) = (yyvsp[0].re); 1534 (yyval.re) = (yyvsp[0].re);
1503 } 1535 }
1504#line 1505 "dtc-parser.tab.c" /* yacc.c:1646 */ 1536#line 1537 "dtc-parser.tab.c" /* yacc.c:1646 */
1505 break; 1537 break;
1506 1538
1507 case 7: 1539 case 11:
1508#line 136 "dtc-parser.y" /* yacc.c:1646 */ 1540#line 162 "dtc-parser.y" /* yacc.c:1646 */
1509 { 1541 {
1510 (yyval.node) = name_node((yyvsp[0].node), ""); 1542 (yyval.node) = name_node((yyvsp[0].node), "");
1511 } 1543 }
1512#line 1513 "dtc-parser.tab.c" /* yacc.c:1646 */ 1544#line 1545 "dtc-parser.tab.c" /* yacc.c:1646 */
1513 break; 1545 break;
1514 1546
1515 case 8: 1547 case 12:
1516#line 140 "dtc-parser.y" /* yacc.c:1646 */ 1548#line 166 "dtc-parser.y" /* yacc.c:1646 */
1517 { 1549 {
1518 (yyval.node) = merge_nodes((yyvsp[-2].node), (yyvsp[0].node)); 1550 (yyval.node) = merge_nodes((yyvsp[-2].node), (yyvsp[0].node));
1519 } 1551 }
1520#line 1521 "dtc-parser.tab.c" /* yacc.c:1646 */ 1552#line 1553 "dtc-parser.tab.c" /* yacc.c:1646 */
1521 break; 1553 break;
1522 1554
1523 case 9: 1555 case 13:
1524#line 145 "dtc-parser.y" /* yacc.c:1646 */ 1556#line 171 "dtc-parser.y" /* yacc.c:1646 */
1525 { 1557 {
1526 struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref)); 1558 struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref));
1527 1559
@@ -1532,11 +1564,11 @@ yyreduce:
1532 ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref)); 1564 ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref));
1533 (yyval.node) = (yyvsp[-3].node); 1565 (yyval.node) = (yyvsp[-3].node);
1534 } 1566 }
1535#line 1536 "dtc-parser.tab.c" /* yacc.c:1646 */ 1567#line 1568 "dtc-parser.tab.c" /* yacc.c:1646 */
1536 break; 1568 break;
1537 1569
1538 case 10: 1570 case 14:
1539#line 156 "dtc-parser.y" /* yacc.c:1646 */ 1571#line 182 "dtc-parser.y" /* yacc.c:1646 */
1540 { 1572 {
1541 struct node *target = get_node_by_ref((yyvsp[-2].node), (yyvsp[-1].labelref)); 1573 struct node *target = get_node_by_ref((yyvsp[-2].node), (yyvsp[-1].labelref));
1542 1574
@@ -1546,11 +1578,11 @@ yyreduce:
1546 ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref)); 1578 ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref));
1547 (yyval.node) = (yyvsp[-2].node); 1579 (yyval.node) = (yyvsp[-2].node);
1548 } 1580 }
1549#line 1550 "dtc-parser.tab.c" /* yacc.c:1646 */ 1581#line 1582 "dtc-parser.tab.c" /* yacc.c:1646 */
1550 break; 1582 break;
1551 1583
1552 case 11: 1584 case 15:
1553#line 166 "dtc-parser.y" /* yacc.c:1646 */ 1585#line 192 "dtc-parser.y" /* yacc.c:1646 */
1554 { 1586 {
1555 struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref)); 1587 struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref));
1556 1588
@@ -1562,100 +1594,100 @@ yyreduce:
1562 1594
1563 (yyval.node) = (yyvsp[-3].node); 1595 (yyval.node) = (yyvsp[-3].node);
1564 } 1596 }
1565#line 1566 "dtc-parser.tab.c" /* yacc.c:1646 */ 1597#line 1598 "dtc-parser.tab.c" /* yacc.c:1646 */
1566 break; 1598 break;
1567 1599
1568 case 12: 1600 case 16:
1569#line 181 "dtc-parser.y" /* yacc.c:1646 */ 1601#line 207 "dtc-parser.y" /* yacc.c:1646 */
1570 { 1602 {
1571 (yyval.node) = build_node((yyvsp[-3].proplist), (yyvsp[-2].nodelist)); 1603 (yyval.node) = build_node((yyvsp[-3].proplist), (yyvsp[-2].nodelist));
1572 } 1604 }
1573#line 1574 "dtc-parser.tab.c" /* yacc.c:1646 */ 1605#line 1606 "dtc-parser.tab.c" /* yacc.c:1646 */
1574 break; 1606 break;
1575 1607
1576 case 13: 1608 case 17:
1577#line 188 "dtc-parser.y" /* yacc.c:1646 */ 1609#line 214 "dtc-parser.y" /* yacc.c:1646 */
1578 { 1610 {
1579 (yyval.proplist) = NULL; 1611 (yyval.proplist) = NULL;
1580 } 1612 }
1581#line 1582 "dtc-parser.tab.c" /* yacc.c:1646 */ 1613#line 1614 "dtc-parser.tab.c" /* yacc.c:1646 */
1582 break; 1614 break;
1583 1615
1584 case 14: 1616 case 18:
1585#line 192 "dtc-parser.y" /* yacc.c:1646 */ 1617#line 218 "dtc-parser.y" /* yacc.c:1646 */
1586 { 1618 {
1587 (yyval.proplist) = chain_property((yyvsp[0].prop), (yyvsp[-1].proplist)); 1619 (yyval.proplist) = chain_property((yyvsp[0].prop), (yyvsp[-1].proplist));
1588 } 1620 }
1589#line 1590 "dtc-parser.tab.c" /* yacc.c:1646 */ 1621#line 1622 "dtc-parser.tab.c" /* yacc.c:1646 */
1590 break; 1622 break;
1591 1623
1592 case 15: 1624 case 19:
1593#line 199 "dtc-parser.y" /* yacc.c:1646 */ 1625#line 225 "dtc-parser.y" /* yacc.c:1646 */
1594 { 1626 {
1595 (yyval.prop) = build_property((yyvsp[-3].propnodename), (yyvsp[-1].data)); 1627 (yyval.prop) = build_property((yyvsp[-3].propnodename), (yyvsp[-1].data));
1596 } 1628 }
1597#line 1598 "dtc-parser.tab.c" /* yacc.c:1646 */ 1629#line 1630 "dtc-parser.tab.c" /* yacc.c:1646 */
1598 break; 1630 break;
1599 1631
1600 case 16: 1632 case 20:
1601#line 203 "dtc-parser.y" /* yacc.c:1646 */ 1633#line 229 "dtc-parser.y" /* yacc.c:1646 */
1602 { 1634 {
1603 (yyval.prop) = build_property((yyvsp[-1].propnodename), empty_data); 1635 (yyval.prop) = build_property((yyvsp[-1].propnodename), empty_data);
1604 } 1636 }
1605#line 1606 "dtc-parser.tab.c" /* yacc.c:1646 */ 1637#line 1638 "dtc-parser.tab.c" /* yacc.c:1646 */
1606 break; 1638 break;
1607 1639
1608 case 17: 1640 case 21:
1609#line 207 "dtc-parser.y" /* yacc.c:1646 */ 1641#line 233 "dtc-parser.y" /* yacc.c:1646 */
1610 { 1642 {
1611 (yyval.prop) = build_property_delete((yyvsp[-1].propnodename)); 1643 (yyval.prop) = build_property_delete((yyvsp[-1].propnodename));
1612 } 1644 }
1613#line 1614 "dtc-parser.tab.c" /* yacc.c:1646 */ 1645#line 1646 "dtc-parser.tab.c" /* yacc.c:1646 */
1614 break; 1646 break;
1615 1647
1616 case 18: 1648 case 22:
1617#line 211 "dtc-parser.y" /* yacc.c:1646 */ 1649#line 237 "dtc-parser.y" /* yacc.c:1646 */
1618 { 1650 {
1619 add_label(&(yyvsp[0].prop)->labels, (yyvsp[-1].labelref)); 1651 add_label(&(yyvsp[0].prop)->labels, (yyvsp[-1].labelref));
1620 (yyval.prop) = (yyvsp[0].prop); 1652 (yyval.prop) = (yyvsp[0].prop);
1621 } 1653 }
1622#line 1623 "dtc-parser.tab.c" /* yacc.c:1646 */ 1654#line 1655 "dtc-parser.tab.c" /* yacc.c:1646 */
1623 break; 1655 break;
1624 1656
1625 case 19: 1657 case 23:
1626#line 219 "dtc-parser.y" /* yacc.c:1646 */ 1658#line 245 "dtc-parser.y" /* yacc.c:1646 */
1627 { 1659 {
1628 (yyval.data) = data_merge((yyvsp[-1].data), (yyvsp[0].data)); 1660 (yyval.data) = data_merge((yyvsp[-1].data), (yyvsp[0].data));
1629 } 1661 }
1630#line 1631 "dtc-parser.tab.c" /* yacc.c:1646 */ 1662#line 1663 "dtc-parser.tab.c" /* yacc.c:1646 */
1631 break; 1663 break;
1632 1664
1633 case 20: 1665 case 24:
1634#line 223 "dtc-parser.y" /* yacc.c:1646 */ 1666#line 249 "dtc-parser.y" /* yacc.c:1646 */
1635 { 1667 {
1636 (yyval.data) = data_merge((yyvsp[-2].data), (yyvsp[-1].array).data); 1668 (yyval.data) = data_merge((yyvsp[-2].data), (yyvsp[-1].array).data);
1637 } 1669 }
1638#line 1639 "dtc-parser.tab.c" /* yacc.c:1646 */ 1670#line 1671 "dtc-parser.tab.c" /* yacc.c:1646 */
1639 break; 1671 break;
1640 1672
1641 case 21: 1673 case 25:
1642#line 227 "dtc-parser.y" /* yacc.c:1646 */ 1674#line 253 "dtc-parser.y" /* yacc.c:1646 */
1643 { 1675 {
1644 (yyval.data) = data_merge((yyvsp[-3].data), (yyvsp[-1].data)); 1676 (yyval.data) = data_merge((yyvsp[-3].data), (yyvsp[-1].data));
1645 } 1677 }
1646#line 1647 "dtc-parser.tab.c" /* yacc.c:1646 */ 1678#line 1679 "dtc-parser.tab.c" /* yacc.c:1646 */
1647 break; 1679 break;
1648 1680
1649 case 22: 1681 case 26:
1650#line 231 "dtc-parser.y" /* yacc.c:1646 */ 1682#line 257 "dtc-parser.y" /* yacc.c:1646 */
1651 { 1683 {
1652 (yyval.data) = data_add_marker((yyvsp[-1].data), REF_PATH, (yyvsp[0].labelref)); 1684 (yyval.data) = data_add_marker((yyvsp[-1].data), REF_PATH, (yyvsp[0].labelref));
1653 } 1685 }
1654#line 1655 "dtc-parser.tab.c" /* yacc.c:1646 */ 1686#line 1687 "dtc-parser.tab.c" /* yacc.c:1646 */
1655 break; 1687 break;
1656 1688
1657 case 23: 1689 case 27:
1658#line 235 "dtc-parser.y" /* yacc.c:1646 */ 1690#line 261 "dtc-parser.y" /* yacc.c:1646 */
1659 { 1691 {
1660 FILE *f = srcfile_relative_open((yyvsp[-5].data).val, NULL); 1692 FILE *f = srcfile_relative_open((yyvsp[-5].data).val, NULL);
1661 struct data d; 1693 struct data d;
@@ -1671,11 +1703,11 @@ yyreduce:
1671 (yyval.data) = data_merge((yyvsp[-8].data), d); 1703 (yyval.data) = data_merge((yyvsp[-8].data), d);
1672 fclose(f); 1704 fclose(f);
1673 } 1705 }
1674#line 1675 "dtc-parser.tab.c" /* yacc.c:1646 */ 1706#line 1707 "dtc-parser.tab.c" /* yacc.c:1646 */
1675 break; 1707 break;
1676 1708
1677 case 24: 1709 case 28:
1678#line 251 "dtc-parser.y" /* yacc.c:1646 */ 1710#line 277 "dtc-parser.y" /* yacc.c:1646 */
1679 { 1711 {
1680 FILE *f = srcfile_relative_open((yyvsp[-1].data).val, NULL); 1712 FILE *f = srcfile_relative_open((yyvsp[-1].data).val, NULL);
1681 struct data d = empty_data; 1713 struct data d = empty_data;
@@ -1685,43 +1717,43 @@ yyreduce:
1685 (yyval.data) = data_merge((yyvsp[-4].data), d); 1717 (yyval.data) = data_merge((yyvsp[-4].data), d);
1686 fclose(f); 1718 fclose(f);
1687 } 1719 }
1688#line 1689 "dtc-parser.tab.c" /* yacc.c:1646 */ 1720#line 1721 "dtc-parser.tab.c" /* yacc.c:1646 */
1689 break; 1721 break;
1690 1722
1691 case 25: 1723 case 29:
1692#line 261 "dtc-parser.y" /* yacc.c:1646 */ 1724#line 287 "dtc-parser.y" /* yacc.c:1646 */
1693 { 1725 {
1694 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref)); 1726 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref));
1695 } 1727 }
1696#line 1697 "dtc-parser.tab.c" /* yacc.c:1646 */ 1728#line 1729 "dtc-parser.tab.c" /* yacc.c:1646 */
1697 break; 1729 break;
1698 1730
1699 case 26: 1731 case 30:
1700#line 268 "dtc-parser.y" /* yacc.c:1646 */ 1732#line 294 "dtc-parser.y" /* yacc.c:1646 */
1701 { 1733 {
1702 (yyval.data) = empty_data; 1734 (yyval.data) = empty_data;
1703 } 1735 }
1704#line 1705 "dtc-parser.tab.c" /* yacc.c:1646 */ 1736#line 1737 "dtc-parser.tab.c" /* yacc.c:1646 */
1705 break; 1737 break;
1706 1738
1707 case 27: 1739 case 31:
1708#line 272 "dtc-parser.y" /* yacc.c:1646 */ 1740#line 298 "dtc-parser.y" /* yacc.c:1646 */
1709 { 1741 {
1710 (yyval.data) = (yyvsp[-1].data); 1742 (yyval.data) = (yyvsp[-1].data);
1711 } 1743 }
1712#line 1713 "dtc-parser.tab.c" /* yacc.c:1646 */ 1744#line 1745 "dtc-parser.tab.c" /* yacc.c:1646 */
1713 break; 1745 break;
1714 1746
1715 case 28: 1747 case 32:
1716#line 276 "dtc-parser.y" /* yacc.c:1646 */ 1748#line 302 "dtc-parser.y" /* yacc.c:1646 */
1717 { 1749 {
1718 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref)); 1750 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref));
1719 } 1751 }
1720#line 1721 "dtc-parser.tab.c" /* yacc.c:1646 */ 1752#line 1753 "dtc-parser.tab.c" /* yacc.c:1646 */
1721 break; 1753 break;
1722 1754
1723 case 29: 1755 case 33:
1724#line 283 "dtc-parser.y" /* yacc.c:1646 */ 1756#line 309 "dtc-parser.y" /* yacc.c:1646 */
1725 { 1757 {
1726 unsigned long long bits; 1758 unsigned long long bits;
1727 1759
@@ -1737,20 +1769,20 @@ yyreduce:
1737 (yyval.array).data = empty_data; 1769 (yyval.array).data = empty_data;
1738 (yyval.array).bits = bits; 1770 (yyval.array).bits = bits;
1739 } 1771 }
1740#line 1741 "dtc-parser.tab.c" /* yacc.c:1646 */ 1772#line 1773 "dtc-parser.tab.c" /* yacc.c:1646 */
1741 break; 1773 break;
1742 1774
1743 case 30: 1775 case 34:
1744#line 299 "dtc-parser.y" /* yacc.c:1646 */ 1776#line 325 "dtc-parser.y" /* yacc.c:1646 */
1745 { 1777 {
1746 (yyval.array).data = empty_data; 1778 (yyval.array).data = empty_data;
1747 (yyval.array).bits = 32; 1779 (yyval.array).bits = 32;
1748 } 1780 }
1749#line 1750 "dtc-parser.tab.c" /* yacc.c:1646 */ 1781#line 1782 "dtc-parser.tab.c" /* yacc.c:1646 */
1750 break; 1782 break;
1751 1783
1752 case 31: 1784 case 35:
1753#line 304 "dtc-parser.y" /* yacc.c:1646 */ 1785#line 330 "dtc-parser.y" /* yacc.c:1646 */
1754 { 1786 {
1755 if ((yyvsp[-1].array).bits < 64) { 1787 if ((yyvsp[-1].array).bits < 64) {
1756 uint64_t mask = (1ULL << (yyvsp[-1].array).bits) - 1; 1788 uint64_t mask = (1ULL << (yyvsp[-1].array).bits) - 1;
@@ -1769,11 +1801,11 @@ yyreduce:
1769 1801
1770 (yyval.array).data = data_append_integer((yyvsp[-1].array).data, (yyvsp[0].integer), (yyvsp[-1].array).bits); 1802 (yyval.array).data = data_append_integer((yyvsp[-1].array).data, (yyvsp[0].integer), (yyvsp[-1].array).bits);
1771 } 1803 }
1772#line 1773 "dtc-parser.tab.c" /* yacc.c:1646 */ 1804#line 1805 "dtc-parser.tab.c" /* yacc.c:1646 */
1773 break; 1805 break;
1774 1806
1775 case 32: 1807 case 36:
1776#line 323 "dtc-parser.y" /* yacc.c:1646 */ 1808#line 349 "dtc-parser.y" /* yacc.c:1646 */
1777 { 1809 {
1778 uint64_t val = ~0ULL >> (64 - (yyvsp[-1].array).bits); 1810 uint64_t val = ~0ULL >> (64 - (yyvsp[-1].array).bits);
1779 1811
@@ -1787,129 +1819,129 @@ yyreduce:
1787 1819
1788 (yyval.array).data = data_append_integer((yyvsp[-1].array).data, val, (yyvsp[-1].array).bits); 1820 (yyval.array).data = data_append_integer((yyvsp[-1].array).data, val, (yyvsp[-1].array).bits);
1789 } 1821 }
1790#line 1791 "dtc-parser.tab.c" /* yacc.c:1646 */ 1822#line 1823 "dtc-parser.tab.c" /* yacc.c:1646 */
1791 break; 1823 break;
1792 1824
1793 case 33: 1825 case 37:
1794#line 337 "dtc-parser.y" /* yacc.c:1646 */ 1826#line 363 "dtc-parser.y" /* yacc.c:1646 */
1795 { 1827 {
1796 (yyval.array).data = data_add_marker((yyvsp[-1].array).data, LABEL, (yyvsp[0].labelref)); 1828 (yyval.array).data = data_add_marker((yyvsp[-1].array).data, LABEL, (yyvsp[0].labelref));
1797 } 1829 }
1798#line 1799 "dtc-parser.tab.c" /* yacc.c:1646 */ 1830#line 1831 "dtc-parser.tab.c" /* yacc.c:1646 */
1799 break; 1831 break;
1800 1832
1801 case 36: 1833 case 40:
1802#line 346 "dtc-parser.y" /* yacc.c:1646 */ 1834#line 372 "dtc-parser.y" /* yacc.c:1646 */
1803 { 1835 {
1804 (yyval.integer) = (yyvsp[-1].integer); 1836 (yyval.integer) = (yyvsp[-1].integer);
1805 } 1837 }
1806#line 1807 "dtc-parser.tab.c" /* yacc.c:1646 */ 1838#line 1839 "dtc-parser.tab.c" /* yacc.c:1646 */
1807 break; 1839 break;
1808 1840
1809 case 39: 1841 case 43:
1810#line 357 "dtc-parser.y" /* yacc.c:1646 */ 1842#line 383 "dtc-parser.y" /* yacc.c:1646 */
1811 { (yyval.integer) = (yyvsp[-4].integer) ? (yyvsp[-2].integer) : (yyvsp[0].integer); } 1843 { (yyval.integer) = (yyvsp[-4].integer) ? (yyvsp[-2].integer) : (yyvsp[0].integer); }
1812#line 1813 "dtc-parser.tab.c" /* yacc.c:1646 */ 1844#line 1845 "dtc-parser.tab.c" /* yacc.c:1646 */
1813 break; 1845 break;
1814 1846
1815 case 41: 1847 case 45:
1816#line 362 "dtc-parser.y" /* yacc.c:1646 */ 1848#line 388 "dtc-parser.y" /* yacc.c:1646 */
1817 { (yyval.integer) = (yyvsp[-2].integer) || (yyvsp[0].integer); } 1849 { (yyval.integer) = (yyvsp[-2].integer) || (yyvsp[0].integer); }
1818#line 1819 "dtc-parser.tab.c" /* yacc.c:1646 */ 1850#line 1851 "dtc-parser.tab.c" /* yacc.c:1646 */
1819 break; 1851 break;
1820 1852
1821 case 43: 1853 case 47:
1822#line 367 "dtc-parser.y" /* yacc.c:1646 */ 1854#line 393 "dtc-parser.y" /* yacc.c:1646 */
1823 { (yyval.integer) = (yyvsp[-2].integer) && (yyvsp[0].integer); } 1855 { (yyval.integer) = (yyvsp[-2].integer) && (yyvsp[0].integer); }
1824#line 1825 "dtc-parser.tab.c" /* yacc.c:1646 */ 1856#line 1857 "dtc-parser.tab.c" /* yacc.c:1646 */
1825 break; 1857 break;
1826 1858
1827 case 45: 1859 case 49:
1828#line 372 "dtc-parser.y" /* yacc.c:1646 */ 1860#line 398 "dtc-parser.y" /* yacc.c:1646 */
1829 { (yyval.integer) = (yyvsp[-2].integer) | (yyvsp[0].integer); } 1861 { (yyval.integer) = (yyvsp[-2].integer) | (yyvsp[0].integer); }
1830#line 1831 "dtc-parser.tab.c" /* yacc.c:1646 */ 1862#line 1863 "dtc-parser.tab.c" /* yacc.c:1646 */
1831 break; 1863 break;
1832 1864
1833 case 47: 1865 case 51:
1834#line 377 "dtc-parser.y" /* yacc.c:1646 */ 1866#line 403 "dtc-parser.y" /* yacc.c:1646 */
1835 { (yyval.integer) = (yyvsp[-2].integer) ^ (yyvsp[0].integer); } 1867 { (yyval.integer) = (yyvsp[-2].integer) ^ (yyvsp[0].integer); }
1836#line 1837 "dtc-parser.tab.c" /* yacc.c:1646 */ 1868#line 1869 "dtc-parser.tab.c" /* yacc.c:1646 */
1837 break; 1869 break;
1838 1870
1839 case 49: 1871 case 53:
1840#line 382 "dtc-parser.y" /* yacc.c:1646 */ 1872#line 408 "dtc-parser.y" /* yacc.c:1646 */
1841 { (yyval.integer) = (yyvsp[-2].integer) & (yyvsp[0].integer); } 1873 { (yyval.integer) = (yyvsp[-2].integer) & (yyvsp[0].integer); }
1842#line 1843 "dtc-parser.tab.c" /* yacc.c:1646 */ 1874#line 1875 "dtc-parser.tab.c" /* yacc.c:1646 */
1843 break; 1875 break;
1844 1876
1845 case 51: 1877 case 55:
1846#line 387 "dtc-parser.y" /* yacc.c:1646 */ 1878#line 413 "dtc-parser.y" /* yacc.c:1646 */
1847 { (yyval.integer) = (yyvsp[-2].integer) == (yyvsp[0].integer); } 1879 { (yyval.integer) = (yyvsp[-2].integer) == (yyvsp[0].integer); }
1848#line 1849 "dtc-parser.tab.c" /* yacc.c:1646 */ 1880#line 1881 "dtc-parser.tab.c" /* yacc.c:1646 */
1849 break; 1881 break;
1850 1882
1851 case 52: 1883 case 56:
1852#line 388 "dtc-parser.y" /* yacc.c:1646 */ 1884#line 414 "dtc-parser.y" /* yacc.c:1646 */
1853 { (yyval.integer) = (yyvsp[-2].integer) != (yyvsp[0].integer); } 1885 { (yyval.integer) = (yyvsp[-2].integer) != (yyvsp[0].integer); }
1854#line 1855 "dtc-parser.tab.c" /* yacc.c:1646 */ 1886#line 1887 "dtc-parser.tab.c" /* yacc.c:1646 */
1855 break; 1887 break;
1856 1888
1857 case 54: 1889 case 58:
1858#line 393 "dtc-parser.y" /* yacc.c:1646 */ 1890#line 419 "dtc-parser.y" /* yacc.c:1646 */
1859 { (yyval.integer) = (yyvsp[-2].integer) < (yyvsp[0].integer); } 1891 { (yyval.integer) = (yyvsp[-2].integer) < (yyvsp[0].integer); }
1860#line 1861 "dtc-parser.tab.c" /* yacc.c:1646 */ 1892#line 1893 "dtc-parser.tab.c" /* yacc.c:1646 */
1861 break; 1893 break;
1862 1894
1863 case 55: 1895 case 59:
1864#line 394 "dtc-parser.y" /* yacc.c:1646 */ 1896#line 420 "dtc-parser.y" /* yacc.c:1646 */
1865 { (yyval.integer) = (yyvsp[-2].integer) > (yyvsp[0].integer); } 1897 { (yyval.integer) = (yyvsp[-2].integer) > (yyvsp[0].integer); }
1866#line 1867 "dtc-parser.tab.c" /* yacc.c:1646 */ 1898#line 1899 "dtc-parser.tab.c" /* yacc.c:1646 */
1867 break; 1899 break;
1868 1900
1869 case 56: 1901 case 60:
1870#line 395 "dtc-parser.y" /* yacc.c:1646 */ 1902#line 421 "dtc-parser.y" /* yacc.c:1646 */
1871 { (yyval.integer) = (yyvsp[-2].integer) <= (yyvsp[0].integer); } 1903 { (yyval.integer) = (yyvsp[-2].integer) <= (yyvsp[0].integer); }
1872#line 1873 "dtc-parser.tab.c" /* yacc.c:1646 */ 1904#line 1905 "dtc-parser.tab.c" /* yacc.c:1646 */
1873 break; 1905 break;
1874 1906
1875 case 57: 1907 case 61:
1876#line 396 "dtc-parser.y" /* yacc.c:1646 */ 1908#line 422 "dtc-parser.y" /* yacc.c:1646 */
1877 { (yyval.integer) = (yyvsp[-2].integer) >= (yyvsp[0].integer); } 1909 { (yyval.integer) = (yyvsp[-2].integer) >= (yyvsp[0].integer); }
1878#line 1879 "dtc-parser.tab.c" /* yacc.c:1646 */ 1910#line 1911 "dtc-parser.tab.c" /* yacc.c:1646 */
1879 break; 1911 break;
1880 1912
1881 case 58: 1913 case 62:
1882#line 400 "dtc-parser.y" /* yacc.c:1646 */ 1914#line 426 "dtc-parser.y" /* yacc.c:1646 */
1883 { (yyval.integer) = (yyvsp[-2].integer) << (yyvsp[0].integer); } 1915 { (yyval.integer) = (yyvsp[-2].integer) << (yyvsp[0].integer); }
1884#line 1885 "dtc-parser.tab.c" /* yacc.c:1646 */ 1916#line 1917 "dtc-parser.tab.c" /* yacc.c:1646 */
1885 break; 1917 break;
1886 1918
1887 case 59: 1919 case 63:
1888#line 401 "dtc-parser.y" /* yacc.c:1646 */ 1920#line 427 "dtc-parser.y" /* yacc.c:1646 */
1889 { (yyval.integer) = (yyvsp[-2].integer) >> (yyvsp[0].integer); } 1921 { (yyval.integer) = (yyvsp[-2].integer) >> (yyvsp[0].integer); }
1890#line 1891 "dtc-parser.tab.c" /* yacc.c:1646 */ 1922#line 1923 "dtc-parser.tab.c" /* yacc.c:1646 */
1891 break; 1923 break;
1892 1924
1893 case 61: 1925 case 65:
1894#line 406 "dtc-parser.y" /* yacc.c:1646 */ 1926#line 432 "dtc-parser.y" /* yacc.c:1646 */
1895 { (yyval.integer) = (yyvsp[-2].integer) + (yyvsp[0].integer); } 1927 { (yyval.integer) = (yyvsp[-2].integer) + (yyvsp[0].integer); }
1896#line 1897 "dtc-parser.tab.c" /* yacc.c:1646 */ 1928#line 1929 "dtc-parser.tab.c" /* yacc.c:1646 */
1897 break; 1929 break;
1898 1930
1899 case 62: 1931 case 66:
1900#line 407 "dtc-parser.y" /* yacc.c:1646 */ 1932#line 433 "dtc-parser.y" /* yacc.c:1646 */
1901 { (yyval.integer) = (yyvsp[-2].integer) - (yyvsp[0].integer); } 1933 { (yyval.integer) = (yyvsp[-2].integer) - (yyvsp[0].integer); }
1902#line 1903 "dtc-parser.tab.c" /* yacc.c:1646 */ 1934#line 1935 "dtc-parser.tab.c" /* yacc.c:1646 */
1903 break; 1935 break;
1904 1936
1905 case 64: 1937 case 68:
1906#line 412 "dtc-parser.y" /* yacc.c:1646 */ 1938#line 438 "dtc-parser.y" /* yacc.c:1646 */
1907 { (yyval.integer) = (yyvsp[-2].integer) * (yyvsp[0].integer); } 1939 { (yyval.integer) = (yyvsp[-2].integer) * (yyvsp[0].integer); }
1908#line 1909 "dtc-parser.tab.c" /* yacc.c:1646 */ 1940#line 1941 "dtc-parser.tab.c" /* yacc.c:1646 */
1909 break; 1941 break;
1910 1942
1911 case 65: 1943 case 69:
1912#line 414 "dtc-parser.y" /* yacc.c:1646 */ 1944#line 440 "dtc-parser.y" /* yacc.c:1646 */
1913 { 1945 {
1914 if ((yyvsp[0].integer) != 0) { 1946 if ((yyvsp[0].integer) != 0) {
1915 (yyval.integer) = (yyvsp[-2].integer) / (yyvsp[0].integer); 1947 (yyval.integer) = (yyvsp[-2].integer) / (yyvsp[0].integer);
@@ -1918,11 +1950,11 @@ yyreduce:
1918 (yyval.integer) = 0; 1950 (yyval.integer) = 0;
1919 } 1951 }
1920 } 1952 }
1921#line 1922 "dtc-parser.tab.c" /* yacc.c:1646 */ 1953#line 1954 "dtc-parser.tab.c" /* yacc.c:1646 */
1922 break; 1954 break;
1923 1955
1924 case 66: 1956 case 70:
1925#line 423 "dtc-parser.y" /* yacc.c:1646 */ 1957#line 449 "dtc-parser.y" /* yacc.c:1646 */
1926 { 1958 {
1927 if ((yyvsp[0].integer) != 0) { 1959 if ((yyvsp[0].integer) != 0) {
1928 (yyval.integer) = (yyvsp[-2].integer) % (yyvsp[0].integer); 1960 (yyval.integer) = (yyvsp[-2].integer) % (yyvsp[0].integer);
@@ -1931,103 +1963,103 @@ yyreduce:
1931 (yyval.integer) = 0; 1963 (yyval.integer) = 0;
1932 } 1964 }
1933 } 1965 }
1934#line 1935 "dtc-parser.tab.c" /* yacc.c:1646 */ 1966#line 1967 "dtc-parser.tab.c" /* yacc.c:1646 */
1935 break; 1967 break;
1936 1968
1937 case 69: 1969 case 73:
1938#line 436 "dtc-parser.y" /* yacc.c:1646 */ 1970#line 462 "dtc-parser.y" /* yacc.c:1646 */
1939 { (yyval.integer) = -(yyvsp[0].integer); } 1971 { (yyval.integer) = -(yyvsp[0].integer); }
1940#line 1941 "dtc-parser.tab.c" /* yacc.c:1646 */ 1972#line 1973 "dtc-parser.tab.c" /* yacc.c:1646 */
1941 break; 1973 break;
1942 1974
1943 case 70: 1975 case 74:
1944#line 437 "dtc-parser.y" /* yacc.c:1646 */ 1976#line 463 "dtc-parser.y" /* yacc.c:1646 */
1945 { (yyval.integer) = ~(yyvsp[0].integer); } 1977 { (yyval.integer) = ~(yyvsp[0].integer); }
1946#line 1947 "dtc-parser.tab.c" /* yacc.c:1646 */ 1978#line 1979 "dtc-parser.tab.c" /* yacc.c:1646 */
1947 break; 1979 break;
1948 1980
1949 case 71: 1981 case 75:
1950#line 438 "dtc-parser.y" /* yacc.c:1646 */ 1982#line 464 "dtc-parser.y" /* yacc.c:1646 */
1951 { (yyval.integer) = !(yyvsp[0].integer); } 1983 { (yyval.integer) = !(yyvsp[0].integer); }
1952#line 1953 "dtc-parser.tab.c" /* yacc.c:1646 */ 1984#line 1985 "dtc-parser.tab.c" /* yacc.c:1646 */
1953 break; 1985 break;
1954 1986
1955 case 72: 1987 case 76:
1956#line 443 "dtc-parser.y" /* yacc.c:1646 */ 1988#line 469 "dtc-parser.y" /* yacc.c:1646 */
1957 { 1989 {
1958 (yyval.data) = empty_data; 1990 (yyval.data) = empty_data;
1959 } 1991 }
1960#line 1961 "dtc-parser.tab.c" /* yacc.c:1646 */ 1992#line 1993 "dtc-parser.tab.c" /* yacc.c:1646 */
1961 break; 1993 break;
1962 1994
1963 case 73: 1995 case 77:
1964#line 447 "dtc-parser.y" /* yacc.c:1646 */ 1996#line 473 "dtc-parser.y" /* yacc.c:1646 */
1965 { 1997 {
1966 (yyval.data) = data_append_byte((yyvsp[-1].data), (yyvsp[0].byte)); 1998 (yyval.data) = data_append_byte((yyvsp[-1].data), (yyvsp[0].byte));
1967 } 1999 }
1968#line 1969 "dtc-parser.tab.c" /* yacc.c:1646 */ 2000#line 2001 "dtc-parser.tab.c" /* yacc.c:1646 */
1969 break; 2001 break;
1970 2002
1971 case 74: 2003 case 78:
1972#line 451 "dtc-parser.y" /* yacc.c:1646 */ 2004#line 477 "dtc-parser.y" /* yacc.c:1646 */
1973 { 2005 {
1974 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref)); 2006 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref));
1975 } 2007 }
1976#line 1977 "dtc-parser.tab.c" /* yacc.c:1646 */ 2008#line 2009 "dtc-parser.tab.c" /* yacc.c:1646 */
1977 break; 2009 break;
1978 2010
1979 case 75: 2011 case 79:
1980#line 458 "dtc-parser.y" /* yacc.c:1646 */ 2012#line 484 "dtc-parser.y" /* yacc.c:1646 */
1981 { 2013 {
1982 (yyval.nodelist) = NULL; 2014 (yyval.nodelist) = NULL;
1983 } 2015 }
1984#line 1985 "dtc-parser.tab.c" /* yacc.c:1646 */ 2016#line 2017 "dtc-parser.tab.c" /* yacc.c:1646 */
1985 break; 2017 break;
1986 2018
1987 case 76: 2019 case 80:
1988#line 462 "dtc-parser.y" /* yacc.c:1646 */ 2020#line 488 "dtc-parser.y" /* yacc.c:1646 */
1989 { 2021 {
1990 (yyval.nodelist) = chain_node((yyvsp[-1].node), (yyvsp[0].nodelist)); 2022 (yyval.nodelist) = chain_node((yyvsp[-1].node), (yyvsp[0].nodelist));
1991 } 2023 }
1992#line 1993 "dtc-parser.tab.c" /* yacc.c:1646 */ 2024#line 2025 "dtc-parser.tab.c" /* yacc.c:1646 */
1993 break; 2025 break;
1994 2026
1995 case 77: 2027 case 81:
1996#line 466 "dtc-parser.y" /* yacc.c:1646 */ 2028#line 492 "dtc-parser.y" /* yacc.c:1646 */
1997 { 2029 {
1998 ERROR(&(yylsp[0]), "Properties must precede subnodes"); 2030 ERROR(&(yylsp[0]), "Properties must precede subnodes");
1999 YYERROR; 2031 YYERROR;
2000 } 2032 }
2001#line 2002 "dtc-parser.tab.c" /* yacc.c:1646 */ 2033#line 2034 "dtc-parser.tab.c" /* yacc.c:1646 */
2002 break; 2034 break;
2003 2035
2004 case 78: 2036 case 82:
2005#line 474 "dtc-parser.y" /* yacc.c:1646 */ 2037#line 500 "dtc-parser.y" /* yacc.c:1646 */
2006 { 2038 {
2007 (yyval.node) = name_node((yyvsp[0].node), (yyvsp[-1].propnodename)); 2039 (yyval.node) = name_node((yyvsp[0].node), (yyvsp[-1].propnodename));
2008 } 2040 }
2009#line 2010 "dtc-parser.tab.c" /* yacc.c:1646 */ 2041#line 2042 "dtc-parser.tab.c" /* yacc.c:1646 */
2010 break; 2042 break;
2011 2043
2012 case 79: 2044 case 83:
2013#line 478 "dtc-parser.y" /* yacc.c:1646 */ 2045#line 504 "dtc-parser.y" /* yacc.c:1646 */
2014 { 2046 {
2015 (yyval.node) = name_node(build_node_delete(), (yyvsp[-1].propnodename)); 2047 (yyval.node) = name_node(build_node_delete(), (yyvsp[-1].propnodename));
2016 } 2048 }
2017#line 2018 "dtc-parser.tab.c" /* yacc.c:1646 */ 2049#line 2050 "dtc-parser.tab.c" /* yacc.c:1646 */
2018 break; 2050 break;
2019 2051
2020 case 80: 2052 case 84:
2021#line 482 "dtc-parser.y" /* yacc.c:1646 */ 2053#line 508 "dtc-parser.y" /* yacc.c:1646 */
2022 { 2054 {
2023 add_label(&(yyvsp[0].node)->labels, (yyvsp[-1].labelref)); 2055 add_label(&(yyvsp[0].node)->labels, (yyvsp[-1].labelref));
2024 (yyval.node) = (yyvsp[0].node); 2056 (yyval.node) = (yyvsp[0].node);
2025 } 2057 }
2026#line 2027 "dtc-parser.tab.c" /* yacc.c:1646 */ 2058#line 2059 "dtc-parser.tab.c" /* yacc.c:1646 */
2027 break; 2059 break;
2028 2060
2029 2061
2030#line 2031 "dtc-parser.tab.c" /* yacc.c:1646 */ 2062#line 2063 "dtc-parser.tab.c" /* yacc.c:1646 */
2031 default: break; 2063 default: break;
2032 } 2064 }
2033 /* User semantic actions sometimes alter yychar, and that requires 2065 /* User semantic actions sometimes alter yychar, and that requires
@@ -2262,7 +2294,7 @@ yyreturn:
2262#endif 2294#endif
2263 return yyresult; 2295 return yyresult;
2264} 2296}
2265#line 488 "dtc-parser.y" /* yacc.c:1906 */ 2297#line 514 "dtc-parser.y" /* yacc.c:1906 */
2266 2298
2267 2299
2268void yyerror(char const *s) 2300void yyerror(char const *s)
diff --git a/scripts/dtc/dtc-parser.tab.h_shipped b/scripts/dtc/dtc-parser.tab.h_shipped
index 30867c688300..6aa512c1b337 100644
--- a/scripts/dtc/dtc-parser.tab.h_shipped
+++ b/scripts/dtc/dtc-parser.tab.h_shipped
@@ -1,8 +1,8 @@
1/* A Bison parser, made by GNU Bison 3.0.2. */ 1/* A Bison parser, made by GNU Bison 3.0.4. */
2 2
3/* Bison interface for Yacc-like parsers in C 3/* Bison interface for Yacc-like parsers in C
4 4
5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. 5 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6 6
7 This program is free software: you can redistribute it and/or modify 7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -46,35 +46,36 @@ extern int yydebug;
46 enum yytokentype 46 enum yytokentype
47 { 47 {
48 DT_V1 = 258, 48 DT_V1 = 258,
49 DT_MEMRESERVE = 259, 49 DT_PLUGIN = 259,
50 DT_LSHIFT = 260, 50 DT_MEMRESERVE = 260,
51 DT_RSHIFT = 261, 51 DT_LSHIFT = 261,
52 DT_LE = 262, 52 DT_RSHIFT = 262,
53 DT_GE = 263, 53 DT_LE = 263,
54 DT_EQ = 264, 54 DT_GE = 264,
55 DT_NE = 265, 55 DT_EQ = 265,
56 DT_AND = 266, 56 DT_NE = 266,
57 DT_OR = 267, 57 DT_AND = 267,
58 DT_BITS = 268, 58 DT_OR = 268,
59 DT_DEL_PROP = 269, 59 DT_BITS = 269,
60 DT_DEL_NODE = 270, 60 DT_DEL_PROP = 270,
61 DT_PROPNODENAME = 271, 61 DT_DEL_NODE = 271,
62 DT_LITERAL = 272, 62 DT_PROPNODENAME = 272,
63 DT_CHAR_LITERAL = 273, 63 DT_LITERAL = 273,
64 DT_BYTE = 274, 64 DT_CHAR_LITERAL = 274,
65 DT_STRING = 275, 65 DT_BYTE = 275,
66 DT_LABEL = 276, 66 DT_STRING = 276,
67 DT_REF = 277, 67 DT_LABEL = 277,
68 DT_INCBIN = 278 68 DT_REF = 278,
69 DT_INCBIN = 279
69 }; 70 };
70#endif 71#endif
71 72
72/* Value type. */ 73/* Value type. */
73#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 74#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
74typedef union YYSTYPE YYSTYPE; 75
75union YYSTYPE 76union YYSTYPE
76{ 77{
77#line 38 "dtc-parser.y" /* yacc.c:1909 */ 78#line 39 "dtc-parser.y" /* yacc.c:1909 */
78 79
79 char *propnodename; 80 char *propnodename;
80 char *labelref; 81 char *labelref;
@@ -92,9 +93,12 @@ union YYSTYPE
92 struct node *nodelist; 93 struct node *nodelist;
93 struct reserve_info *re; 94 struct reserve_info *re;
94 uint64_t integer; 95 uint64_t integer;
96 unsigned int flags;
95 97
96#line 97 "dtc-parser.tab.h" /* yacc.c:1909 */ 98#line 99 "dtc-parser.tab.h" /* yacc.c:1909 */
97}; 99};
100
101typedef union YYSTYPE YYSTYPE;
98# define YYSTYPE_IS_TRIVIAL 1 102# define YYSTYPE_IS_TRIVIAL 1
99# define YYSTYPE_IS_DECLARED 1 103# define YYSTYPE_IS_DECLARED 1
100#endif 104#endif
diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y
index 000873f070fd..b2fd4d155839 100644
--- a/scripts/dtc/dtc-parser.y
+++ b/scripts/dtc/dtc-parser.y
@@ -19,6 +19,7 @@
19 */ 19 */
20%{ 20%{
21#include <stdio.h> 21#include <stdio.h>
22#include <inttypes.h>
22 23
23#include "dtc.h" 24#include "dtc.h"
24#include "srcpos.h" 25#include "srcpos.h"
@@ -31,7 +32,7 @@ extern void yyerror(char const *s);
31 treesource_error = true; \ 32 treesource_error = true; \
32 } while (0) 33 } while (0)
33 34
34extern struct boot_info *the_boot_info; 35extern struct dt_info *parser_output;
35extern bool treesource_error; 36extern bool treesource_error;
36%} 37%}
37 38
@@ -52,9 +53,11 @@ extern bool treesource_error;
52 struct node *nodelist; 53 struct node *nodelist;
53 struct reserve_info *re; 54 struct reserve_info *re;
54 uint64_t integer; 55 uint64_t integer;
56 unsigned int flags;
55} 57}
56 58
57%token DT_V1 59%token DT_V1
60%token DT_PLUGIN
58%token DT_MEMRESERVE 61%token DT_MEMRESERVE
59%token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ DT_NE DT_AND DT_OR 62%token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ DT_NE DT_AND DT_OR
60%token DT_BITS 63%token DT_BITS
@@ -71,6 +74,8 @@ extern bool treesource_error;
71 74
72%type <data> propdata 75%type <data> propdata
73%type <data> propdataprefix 76%type <data> propdataprefix
77%type <flags> header
78%type <flags> headers
74%type <re> memreserve 79%type <re> memreserve
75%type <re> memreserves 80%type <re> memreserves
76%type <array> arrayprefix 81%type <array> arrayprefix
@@ -101,10 +106,31 @@ extern bool treesource_error;
101%% 106%%
102 107
103sourcefile: 108sourcefile:
104 DT_V1 ';' memreserves devicetree 109 headers memreserves devicetree
105 { 110 {
106 the_boot_info = build_boot_info($3, $4, 111 parser_output = build_dt_info($1, $2, $3,
107 guess_boot_cpuid($4)); 112 guess_boot_cpuid($3));
113 }
114 ;
115
116header:
117 DT_V1 ';'
118 {
119 $$ = DTSF_V1;
120 }
121 | DT_V1 ';' DT_PLUGIN ';'
122 {
123 $$ = DTSF_V1 | DTSF_PLUGIN;
124 }
125 ;
126
127headers:
128 header
129 | header headers
130 {
131 if ($2 != $1)
132 ERROR(&@2, "Header flags don't match earlier ones");
133 $$ = $1;
108 } 134 }
109 ; 135 ;
110 136
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c
index 5fa23c406266..a4edf4c7aebf 100644
--- a/scripts/dtc/dtc.c
+++ b/scripts/dtc/dtc.c
@@ -30,7 +30,16 @@ int quiet; /* Level of quietness */
30int reservenum; /* Number of memory reservation slots */ 30int reservenum; /* Number of memory reservation slots */
31int minsize; /* Minimum blob size */ 31int minsize; /* Minimum blob size */
32int padsize; /* Additional padding to blob */ 32int padsize; /* Additional padding to blob */
33int alignsize; /* Additional padding to blob accroding to the alignsize */
33int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */ 34int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */
35int generate_symbols; /* enable symbols & fixup support */
36int generate_fixups; /* suppress generation of fixups on symbol support */
37int auto_label_aliases; /* auto generate labels -> aliases */
38
39static int is_power_of_2(int x)
40{
41 return (x > 0) && ((x & (x - 1)) == 0);
42}
34 43
35static void fill_fullpaths(struct node *tree, const char *prefix) 44static void fill_fullpaths(struct node *tree, const char *prefix)
36{ 45{
@@ -53,7 +62,7 @@ static void fill_fullpaths(struct node *tree, const char *prefix)
53#define FDT_VERSION(version) _FDT_VERSION(version) 62#define FDT_VERSION(version) _FDT_VERSION(version)
54#define _FDT_VERSION(version) #version 63#define _FDT_VERSION(version) #version
55static const char usage_synopsis[] = "dtc [options] <input file>"; 64static const char usage_synopsis[] = "dtc [options] <input file>";
56static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv"; 65static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@Ahv";
57static struct option const usage_long_opts[] = { 66static struct option const usage_long_opts[] = {
58 {"quiet", no_argument, NULL, 'q'}, 67 {"quiet", no_argument, NULL, 'q'},
59 {"in-format", a_argument, NULL, 'I'}, 68 {"in-format", a_argument, NULL, 'I'},
@@ -64,6 +73,7 @@ static struct option const usage_long_opts[] = {
64 {"reserve", a_argument, NULL, 'R'}, 73 {"reserve", a_argument, NULL, 'R'},
65 {"space", a_argument, NULL, 'S'}, 74 {"space", a_argument, NULL, 'S'},
66 {"pad", a_argument, NULL, 'p'}, 75 {"pad", a_argument, NULL, 'p'},
76 {"align", a_argument, NULL, 'a'},
67 {"boot-cpu", a_argument, NULL, 'b'}, 77 {"boot-cpu", a_argument, NULL, 'b'},
68 {"force", no_argument, NULL, 'f'}, 78 {"force", no_argument, NULL, 'f'},
69 {"include", a_argument, NULL, 'i'}, 79 {"include", a_argument, NULL, 'i'},
@@ -71,6 +81,8 @@ static struct option const usage_long_opts[] = {
71 {"phandle", a_argument, NULL, 'H'}, 81 {"phandle", a_argument, NULL, 'H'},
72 {"warning", a_argument, NULL, 'W'}, 82 {"warning", a_argument, NULL, 'W'},
73 {"error", a_argument, NULL, 'E'}, 83 {"error", a_argument, NULL, 'E'},
84 {"symbols", no_argument, NULL, '@'},
85 {"auto-alias", no_argument, NULL, 'A'},
74 {"help", no_argument, NULL, 'h'}, 86 {"help", no_argument, NULL, 'h'},
75 {"version", no_argument, NULL, 'v'}, 87 {"version", no_argument, NULL, 'v'},
76 {NULL, no_argument, NULL, 0x0}, 88 {NULL, no_argument, NULL, 0x0},
@@ -91,6 +103,7 @@ static const char * const usage_opts_help[] = {
91 "\n\tMake space for <number> reserve map entries (for dtb and asm output)", 103 "\n\tMake space for <number> reserve map entries (for dtb and asm output)",
92 "\n\tMake the blob at least <bytes> long (extra space)", 104 "\n\tMake the blob at least <bytes> long (extra space)",
93 "\n\tAdd padding to the blob of <bytes> long (extra space)", 105 "\n\tAdd padding to the blob of <bytes> long (extra space)",
106 "\n\tMake the blob align to the <bytes> (extra space)",
94 "\n\tSet the physical boot cpu", 107 "\n\tSet the physical boot cpu",
95 "\n\tTry to produce output even if the input tree has errors", 108 "\n\tTry to produce output even if the input tree has errors",
96 "\n\tAdd a path to search for include files", 109 "\n\tAdd a path to search for include files",
@@ -101,6 +114,8 @@ static const char * const usage_opts_help[] = {
101 "\t\tboth - Both \"linux,phandle\" and \"phandle\" properties", 114 "\t\tboth - Both \"linux,phandle\" and \"phandle\" properties",
102 "\n\tEnable/disable warnings (prefix with \"no-\")", 115 "\n\tEnable/disable warnings (prefix with \"no-\")",
103 "\n\tEnable/disable errors (prefix with \"no-\")", 116 "\n\tEnable/disable errors (prefix with \"no-\")",
117 "\n\tEnable generation of symbols",
118 "\n\tEnable auto-alias of labels",
104 "\n\tPrint this help and exit", 119 "\n\tPrint this help and exit",
105 "\n\tPrint version and exit", 120 "\n\tPrint version and exit",
106 NULL, 121 NULL,
@@ -153,7 +168,7 @@ static const char *guess_input_format(const char *fname, const char *fallback)
153 168
154int main(int argc, char *argv[]) 169int main(int argc, char *argv[])
155{ 170{
156 struct boot_info *bi; 171 struct dt_info *dti;
157 const char *inform = NULL; 172 const char *inform = NULL;
158 const char *outform = NULL; 173 const char *outform = NULL;
159 const char *outname = "-"; 174 const char *outname = "-";
@@ -169,6 +184,7 @@ int main(int argc, char *argv[])
169 reservenum = 0; 184 reservenum = 0;
170 minsize = 0; 185 minsize = 0;
171 padsize = 0; 186 padsize = 0;
187 alignsize = 0;
172 188
173 while ((opt = util_getopt_long()) != EOF) { 189 while ((opt = util_getopt_long()) != EOF) {
174 switch (opt) { 190 switch (opt) {
@@ -196,6 +212,12 @@ int main(int argc, char *argv[])
196 case 'p': 212 case 'p':
197 padsize = strtol(optarg, NULL, 0); 213 padsize = strtol(optarg, NULL, 0);
198 break; 214 break;
215 case 'a':
216 alignsize = strtol(optarg, NULL, 0);
217 if (!is_power_of_2(alignsize))
218 die("Invalid argument \"%d\" to -a option\n",
219 optarg);
220 break;
199 case 'f': 221 case 'f':
200 force = true; 222 force = true;
201 break; 223 break;
@@ -234,6 +256,13 @@ int main(int argc, char *argv[])
234 parse_checks_option(false, true, optarg); 256 parse_checks_option(false, true, optarg);
235 break; 257 break;
236 258
259 case '@':
260 generate_symbols = 1;
261 break;
262 case 'A':
263 auto_label_aliases = 1;
264 break;
265
237 case 'h': 266 case 'h':
238 usage(NULL); 267 usage(NULL);
239 default: 268 default:
@@ -272,11 +301,11 @@ int main(int argc, char *argv[])
272 } 301 }
273 } 302 }
274 if (streq(inform, "dts")) 303 if (streq(inform, "dts"))
275 bi = dt_from_source(arg); 304 dti = dt_from_source(arg);
276 else if (streq(inform, "fs")) 305 else if (streq(inform, "fs"))
277 bi = dt_from_fs(arg); 306 dti = dt_from_fs(arg);
278 else if(streq(inform, "dtb")) 307 else if(streq(inform, "dtb"))
279 bi = dt_from_blob(arg); 308 dti = dt_from_blob(arg);
280 else 309 else
281 die("Unknown input format \"%s\"\n", inform); 310 die("Unknown input format \"%s\"\n", inform);
282 311
@@ -286,13 +315,29 @@ int main(int argc, char *argv[])
286 } 315 }
287 316
288 if (cmdline_boot_cpuid != -1) 317 if (cmdline_boot_cpuid != -1)
289 bi->boot_cpuid_phys = cmdline_boot_cpuid; 318 dti->boot_cpuid_phys = cmdline_boot_cpuid;
319
320 fill_fullpaths(dti->dt, "");
321 process_checks(force, dti);
322
323 /* on a plugin, generate by default */
324 if (dti->dtsflags & DTSF_PLUGIN) {
325 generate_fixups = 1;
326 }
290 327
291 fill_fullpaths(bi->dt, ""); 328 if (auto_label_aliases)
292 process_checks(force, bi); 329 generate_label_tree(dti, "aliases", false);
330
331 if (generate_symbols)
332 generate_label_tree(dti, "__symbols__", true);
333
334 if (generate_fixups) {
335 generate_fixups_tree(dti, "__fixups__");
336 generate_local_fixups_tree(dti, "__local_fixups__");
337 }
293 338
294 if (sort) 339 if (sort)
295 sort_tree(bi); 340 sort_tree(dti);
296 341
297 if (streq(outname, "-")) { 342 if (streq(outname, "-")) {
298 outf = stdout; 343 outf = stdout;
@@ -304,11 +349,11 @@ int main(int argc, char *argv[])
304 } 349 }
305 350
306 if (streq(outform, "dts")) { 351 if (streq(outform, "dts")) {
307 dt_to_source(outf, bi); 352 dt_to_source(outf, dti);
308 } else if (streq(outform, "dtb")) { 353 } else if (streq(outform, "dtb")) {
309 dt_to_blob(outf, bi, outversion); 354 dt_to_blob(outf, dti, outversion);
310 } else if (streq(outform, "asm")) { 355 } else if (streq(outform, "asm")) {
311 dt_to_asm(outf, bi, outversion); 356 dt_to_asm(outf, dti, outversion);
312 } else if (streq(outform, "null")) { 357 } else if (streq(outform, "null")) {
313 /* do nothing */ 358 /* do nothing */
314 } else { 359 } else {
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h
index 56212c8df660..c6f125c68ba8 100644
--- a/scripts/dtc/dtc.h
+++ b/scripts/dtc/dtc.h
@@ -53,7 +53,11 @@ extern int quiet; /* Level of quietness */
53extern int reservenum; /* Number of memory reservation slots */ 53extern int reservenum; /* Number of memory reservation slots */
54extern int minsize; /* Minimum blob size */ 54extern int minsize; /* Minimum blob size */
55extern int padsize; /* Additional padding to blob */ 55extern int padsize; /* Additional padding to blob */
56extern int alignsize; /* Additional padding to blob accroding to the alignsize */
56extern int phandle_format; /* Use linux,phandle or phandle properties */ 57extern int phandle_format; /* Use linux,phandle or phandle properties */
58extern int generate_symbols; /* generate symbols for nodes with labels */
59extern int generate_fixups; /* generate fixups */
60extern int auto_label_aliases; /* auto generate labels -> aliases */
57 61
58#define PHANDLE_LEGACY 0x1 62#define PHANDLE_LEGACY 0x1
59#define PHANDLE_EPAPR 0x2 63#define PHANDLE_EPAPR 0x2
@@ -201,6 +205,8 @@ void delete_property(struct property *prop);
201void add_child(struct node *parent, struct node *child); 205void add_child(struct node *parent, struct node *child);
202void delete_node_by_name(struct node *parent, char *name); 206void delete_node_by_name(struct node *parent, char *name);
203void delete_node(struct node *node); 207void delete_node(struct node *node);
208void append_to_property(struct node *node,
209 char *name, const void *data, int len);
204 210
205const char *get_unitname(struct node *node); 211const char *get_unitname(struct node *node);
206struct property *get_property(struct node *node, const char *propname); 212struct property *get_property(struct node *node, const char *propname);
@@ -235,35 +241,44 @@ struct reserve_info *add_reserve_entry(struct reserve_info *list,
235 struct reserve_info *new); 241 struct reserve_info *new);
236 242
237 243
238struct boot_info { 244struct dt_info {
245 unsigned int dtsflags;
239 struct reserve_info *reservelist; 246 struct reserve_info *reservelist;
240 struct node *dt; /* the device tree */
241 uint32_t boot_cpuid_phys; 247 uint32_t boot_cpuid_phys;
248 struct node *dt; /* the device tree */
242}; 249};
243 250
244struct boot_info *build_boot_info(struct reserve_info *reservelist, 251/* DTS version flags definitions */
245 struct node *tree, uint32_t boot_cpuid_phys); 252#define DTSF_V1 0x0001 /* /dts-v1/ */
246void sort_tree(struct boot_info *bi); 253#define DTSF_PLUGIN 0x0002 /* /plugin/ */
254
255struct dt_info *build_dt_info(unsigned int dtsflags,
256 struct reserve_info *reservelist,
257 struct node *tree, uint32_t boot_cpuid_phys);
258void sort_tree(struct dt_info *dti);
259void generate_label_tree(struct dt_info *dti, char *name, bool allocph);
260void generate_fixups_tree(struct dt_info *dti, char *name);
261void generate_local_fixups_tree(struct dt_info *dti, char *name);
247 262
248/* Checks */ 263/* Checks */
249 264
250void parse_checks_option(bool warn, bool error, const char *arg); 265void parse_checks_option(bool warn, bool error, const char *arg);
251void process_checks(bool force, struct boot_info *bi); 266void process_checks(bool force, struct dt_info *dti);
252 267
253/* Flattened trees */ 268/* Flattened trees */
254 269
255void dt_to_blob(FILE *f, struct boot_info *bi, int version); 270void dt_to_blob(FILE *f, struct dt_info *dti, int version);
256void dt_to_asm(FILE *f, struct boot_info *bi, int version); 271void dt_to_asm(FILE *f, struct dt_info *dti, int version);
257 272
258struct boot_info *dt_from_blob(const char *fname); 273struct dt_info *dt_from_blob(const char *fname);
259 274
260/* Tree source */ 275/* Tree source */
261 276
262void dt_to_source(FILE *f, struct boot_info *bi); 277void dt_to_source(FILE *f, struct dt_info *dti);
263struct boot_info *dt_from_source(const char *f); 278struct dt_info *dt_from_source(const char *f);
264 279
265/* FS trees */ 280/* FS trees */
266 281
267struct boot_info *dt_from_fs(const char *dirname); 282struct dt_info *dt_from_fs(const char *dirname);
268 283
269#endif /* _DTC_H */ 284#endif /* _DTC_H */
diff --git a/scripts/dtc/flattree.c b/scripts/dtc/flattree.c
index ec14954f5810..ebac548b3fa8 100644
--- a/scripts/dtc/flattree.c
+++ b/scripts/dtc/flattree.c
@@ -366,7 +366,7 @@ static void make_fdt_header(struct fdt_header *fdt,
366 fdt->size_dt_struct = cpu_to_fdt32(dtsize); 366 fdt->size_dt_struct = cpu_to_fdt32(dtsize);
367} 367}
368 368
369void dt_to_blob(FILE *f, struct boot_info *bi, int version) 369void dt_to_blob(FILE *f, struct dt_info *dti, int version)
370{ 370{
371 struct version_info *vi = NULL; 371 struct version_info *vi = NULL;
372 int i; 372 int i;
@@ -384,29 +384,36 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
384 if (!vi) 384 if (!vi)
385 die("Unknown device tree blob version %d\n", version); 385 die("Unknown device tree blob version %d\n", version);
386 386
387 flatten_tree(bi->dt, &bin_emitter, &dtbuf, &strbuf, vi); 387 flatten_tree(dti->dt, &bin_emitter, &dtbuf, &strbuf, vi);
388 bin_emit_cell(&dtbuf, FDT_END); 388 bin_emit_cell(&dtbuf, FDT_END);
389 389
390 reservebuf = flatten_reserve_list(bi->reservelist, vi); 390 reservebuf = flatten_reserve_list(dti->reservelist, vi);
391 391
392 /* Make header */ 392 /* Make header */
393 make_fdt_header(&fdt, vi, reservebuf.len, dtbuf.len, strbuf.len, 393 make_fdt_header(&fdt, vi, reservebuf.len, dtbuf.len, strbuf.len,
394 bi->boot_cpuid_phys); 394 dti->boot_cpuid_phys);
395 395
396 /* 396 /*
397 * If the user asked for more space than is used, adjust the totalsize. 397 * If the user asked for more space than is used, adjust the totalsize.
398 */ 398 */
399 if (minsize > 0) { 399 if (minsize > 0) {
400 padlen = minsize - fdt32_to_cpu(fdt.totalsize); 400 padlen = minsize - fdt32_to_cpu(fdt.totalsize);
401 if ((padlen < 0) && (quiet < 1)) 401 if (padlen < 0) {
402 fprintf(stderr, 402 padlen = 0;
403 "Warning: blob size %d >= minimum size %d\n", 403 if (quiet < 1)
404 fdt32_to_cpu(fdt.totalsize), minsize); 404 fprintf(stderr,
405 "Warning: blob size %d >= minimum size %d\n",
406 fdt32_to_cpu(fdt.totalsize), minsize);
407 }
405 } 408 }
406 409
407 if (padsize > 0) 410 if (padsize > 0)
408 padlen = padsize; 411 padlen = padsize;
409 412
413 if (alignsize > 0)
414 padlen = ALIGN(fdt32_to_cpu(fdt.totalsize) + padlen, alignsize)
415 - fdt32_to_cpu(fdt.totalsize);
416
410 if (padlen > 0) { 417 if (padlen > 0) {
411 int tsize = fdt32_to_cpu(fdt.totalsize); 418 int tsize = fdt32_to_cpu(fdt.totalsize);
412 tsize += padlen; 419 tsize += padlen;
@@ -460,7 +467,7 @@ static void dump_stringtable_asm(FILE *f, struct data strbuf)
460 } 467 }
461} 468}
462 469
463void dt_to_asm(FILE *f, struct boot_info *bi, int version) 470void dt_to_asm(FILE *f, struct dt_info *dti, int version)
464{ 471{
465 struct version_info *vi = NULL; 472 struct version_info *vi = NULL;
466 int i; 473 int i;
@@ -500,7 +507,7 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
500 507
501 if (vi->flags & FTF_BOOTCPUID) { 508 if (vi->flags & FTF_BOOTCPUID) {
502 fprintf(f, "\t/* boot_cpuid_phys */\n"); 509 fprintf(f, "\t/* boot_cpuid_phys */\n");
503 asm_emit_cell(f, bi->boot_cpuid_phys); 510 asm_emit_cell(f, dti->boot_cpuid_phys);
504 } 511 }
505 512
506 if (vi->flags & FTF_STRTABSIZE) { 513 if (vi->flags & FTF_STRTABSIZE) {
@@ -530,7 +537,7 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
530 * Use .long on high and low halfs of u64s to avoid .quad 537 * Use .long on high and low halfs of u64s to avoid .quad
531 * as it appears .quad isn't available in some assemblers. 538 * as it appears .quad isn't available in some assemblers.
532 */ 539 */
533 for (re = bi->reservelist; re; re = re->next) { 540 for (re = dti->reservelist; re; re = re->next) {
534 struct label *l; 541 struct label *l;
535 542
536 for_each_label(re->labels, l) { 543 for_each_label(re->labels, l) {
@@ -550,7 +557,7 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
550 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n"); 557 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
551 558
552 emit_label(f, symprefix, "struct_start"); 559 emit_label(f, symprefix, "struct_start");
553 flatten_tree(bi->dt, &asm_emitter, f, &strbuf, vi); 560 flatten_tree(dti->dt, &asm_emitter, f, &strbuf, vi);
554 561
555 fprintf(f, "\t/* FDT_END */\n"); 562 fprintf(f, "\t/* FDT_END */\n");
556 asm_emit_cell(f, FDT_END); 563 asm_emit_cell(f, FDT_END);
@@ -572,6 +579,8 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
572 if (padsize > 0) { 579 if (padsize > 0) {
573 fprintf(f, "\t.space\t%d, 0\n", padsize); 580 fprintf(f, "\t.space\t%d, 0\n", padsize);
574 } 581 }
582 if (alignsize > 0)
583 asm_emit_align(f, alignsize);
575 emit_label(f, symprefix, "blob_abs_end"); 584 emit_label(f, symprefix, "blob_abs_end");
576 585
577 data_free(strbuf); 586 data_free(strbuf);
@@ -797,11 +806,15 @@ static struct node *unflatten_tree(struct inbuf *dtbuf,
797 } 806 }
798 } while (val != FDT_END_NODE); 807 } while (val != FDT_END_NODE);
799 808
809 if (node->name != flatname) {
810 free(flatname);
811 }
812
800 return node; 813 return node;
801} 814}
802 815
803 816
804struct boot_info *dt_from_blob(const char *fname) 817struct dt_info *dt_from_blob(const char *fname)
805{ 818{
806 FILE *f; 819 FILE *f;
807 uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys; 820 uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys;
@@ -929,5 +942,5 @@ struct boot_info *dt_from_blob(const char *fname)
929 942
930 fclose(f); 943 fclose(f);
931 944
932 return build_boot_info(reservelist, tree, boot_cpuid_phys); 945 return build_dt_info(DTSF_V1, reservelist, tree, boot_cpuid_phys);
933} 946}
diff --git a/scripts/dtc/fstree.c b/scripts/dtc/fstree.c
index 6d1beec9581d..ae7d06c3c492 100644
--- a/scripts/dtc/fstree.c
+++ b/scripts/dtc/fstree.c
@@ -79,13 +79,12 @@ static struct node *read_fstree(const char *dirname)
79 return tree; 79 return tree;
80} 80}
81 81
82struct boot_info *dt_from_fs(const char *dirname) 82struct dt_info *dt_from_fs(const char *dirname)
83{ 83{
84 struct node *tree; 84 struct node *tree;
85 85
86 tree = read_fstree(dirname); 86 tree = read_fstree(dirname);
87 tree = name_node(tree, ""); 87 tree = name_node(tree, "");
88 88
89 return build_boot_info(NULL, tree, guess_boot_cpuid(tree)); 89 return build_dt_info(DTSF_V1, NULL, tree, guess_boot_cpuid(tree));
90} 90}
91
diff --git a/scripts/dtc/libfdt/Makefile.libfdt b/scripts/dtc/libfdt/Makefile.libfdt
index 09c322ed82ba..098b3f36e668 100644
--- a/scripts/dtc/libfdt/Makefile.libfdt
+++ b/scripts/dtc/libfdt/Makefile.libfdt
@@ -7,5 +7,5 @@ LIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1
7LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h 7LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h
8LIBFDT_VERSION = version.lds 8LIBFDT_VERSION = version.lds
9LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \ 9LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \
10 fdt_addresses.c 10 fdt_addresses.c fdt_overlay.c
11LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o) 11LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c
index 50cce864283c..3d00d2eee0e3 100644
--- a/scripts/dtc/libfdt/fdt_ro.c
+++ b/scripts/dtc/libfdt/fdt_ro.c
@@ -88,6 +88,32 @@ static int _fdt_string_eq(const void *fdt, int stroffset,
88 return (strlen(p) == len) && (memcmp(p, s, len) == 0); 88 return (strlen(p) == len) && (memcmp(p, s, len) == 0);
89} 89}
90 90
91uint32_t fdt_get_max_phandle(const void *fdt)
92{
93 uint32_t max_phandle = 0;
94 int offset;
95
96 for (offset = fdt_next_node(fdt, -1, NULL);;
97 offset = fdt_next_node(fdt, offset, NULL)) {
98 uint32_t phandle;
99
100 if (offset == -FDT_ERR_NOTFOUND)
101 return max_phandle;
102
103 if (offset < 0)
104 return (uint32_t)-1;
105
106 phandle = fdt_get_phandle(fdt, offset);
107 if (phandle == (uint32_t)-1)
108 continue;
109
110 if (phandle > max_phandle)
111 max_phandle = phandle;
112 }
113
114 return 0;
115}
116
91int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size) 117int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
92{ 118{
93 FDT_CHECK_HEADER(fdt); 119 FDT_CHECK_HEADER(fdt);
@@ -545,7 +571,7 @@ int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property)
545 571
546 list = fdt_getprop(fdt, nodeoffset, property, &length); 572 list = fdt_getprop(fdt, nodeoffset, property, &length);
547 if (!list) 573 if (!list)
548 return -length; 574 return length;
549 575
550 end = list + length; 576 end = list + length;
551 577
@@ -571,7 +597,7 @@ int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property,
571 597
572 list = fdt_getprop(fdt, nodeoffset, property, &length); 598 list = fdt_getprop(fdt, nodeoffset, property, &length);
573 if (!list) 599 if (!list)
574 return -length; 600 return length;
575 601
576 len = strlen(string) + 1; 602 len = strlen(string) + 1;
577 end = list + length; 603 end = list + length;
diff --git a/scripts/dtc/libfdt/fdt_rw.c b/scripts/dtc/libfdt/fdt_rw.c
index 8be02b1f68f3..2eed4f58387c 100644
--- a/scripts/dtc/libfdt/fdt_rw.c
+++ b/scripts/dtc/libfdt/fdt_rw.c
@@ -191,17 +191,13 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size)
191int fdt_del_mem_rsv(void *fdt, int n) 191int fdt_del_mem_rsv(void *fdt, int n)
192{ 192{
193 struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n); 193 struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n);
194 int err;
195 194
196 FDT_RW_CHECK_HEADER(fdt); 195 FDT_RW_CHECK_HEADER(fdt);
197 196
198 if (n >= fdt_num_mem_rsv(fdt)) 197 if (n >= fdt_num_mem_rsv(fdt))
199 return -FDT_ERR_NOTFOUND; 198 return -FDT_ERR_NOTFOUND;
200 199
201 err = _fdt_splice_mem_rsv(fdt, re, 1, 0); 200 return _fdt_splice_mem_rsv(fdt, re, 1, 0);
202 if (err)
203 return err;
204 return 0;
205} 201}
206 202
207static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name, 203static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
diff --git a/scripts/dtc/libfdt/fdt_strerror.c b/scripts/dtc/libfdt/fdt_strerror.c
index e6c3ceee8c58..9677a1887e57 100644
--- a/scripts/dtc/libfdt/fdt_strerror.c
+++ b/scripts/dtc/libfdt/fdt_strerror.c
@@ -69,6 +69,7 @@ static struct fdt_errtabent fdt_errtable[] = {
69 69
70 FDT_ERRTABENT(FDT_ERR_BADOFFSET), 70 FDT_ERRTABENT(FDT_ERR_BADOFFSET),
71 FDT_ERRTABENT(FDT_ERR_BADPATH), 71 FDT_ERRTABENT(FDT_ERR_BADPATH),
72 FDT_ERRTABENT(FDT_ERR_BADPHANDLE),
72 FDT_ERRTABENT(FDT_ERR_BADSTATE), 73 FDT_ERRTABENT(FDT_ERR_BADSTATE),
73 74
74 FDT_ERRTABENT(FDT_ERR_TRUNCATED), 75 FDT_ERRTABENT(FDT_ERR_TRUNCATED),
@@ -76,6 +77,11 @@ static struct fdt_errtabent fdt_errtable[] = {
76 FDT_ERRTABENT(FDT_ERR_BADVERSION), 77 FDT_ERRTABENT(FDT_ERR_BADVERSION),
77 FDT_ERRTABENT(FDT_ERR_BADSTRUCTURE), 78 FDT_ERRTABENT(FDT_ERR_BADSTRUCTURE),
78 FDT_ERRTABENT(FDT_ERR_BADLAYOUT), 79 FDT_ERRTABENT(FDT_ERR_BADLAYOUT),
80 FDT_ERRTABENT(FDT_ERR_INTERNAL),
81 FDT_ERRTABENT(FDT_ERR_BADNCELLS),
82 FDT_ERRTABENT(FDT_ERR_BADVALUE),
83 FDT_ERRTABENT(FDT_ERR_BADOVERLAY),
84 FDT_ERRTABENT(FDT_ERR_NOPHANDLES),
79}; 85};
80#define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0])) 86#define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))
81 87
diff --git a/scripts/dtc/libfdt/fdt_wip.c b/scripts/dtc/libfdt/fdt_wip.c
index c5bbb68d3273..6aaab399929c 100644
--- a/scripts/dtc/libfdt/fdt_wip.c
+++ b/scripts/dtc/libfdt/fdt_wip.c
@@ -55,21 +55,42 @@
55 55
56#include "libfdt_internal.h" 56#include "libfdt_internal.h"
57 57
58int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
59 const char *name, int namelen,
60 uint32_t idx, const void *val,
61 int len)
62{
63 void *propval;
64 int proplen;
65
66 propval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen,
67 &proplen);
68 if (!propval)
69 return proplen;
70
71 if (proplen < (len + idx))
72 return -FDT_ERR_NOSPACE;
73
74 memcpy((char *)propval + idx, val, len);
75 return 0;
76}
77
58int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, 78int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
59 const void *val, int len) 79 const void *val, int len)
60{ 80{
61 void *propval; 81 const void *propval;
62 int proplen; 82 int proplen;
63 83
64 propval = fdt_getprop_w(fdt, nodeoffset, name, &proplen); 84 propval = fdt_getprop(fdt, nodeoffset, name, &proplen);
65 if (! propval) 85 if (! propval)
66 return proplen; 86 return proplen;
67 87
68 if (proplen != len) 88 if (proplen != len)
69 return -FDT_ERR_NOSPACE; 89 return -FDT_ERR_NOSPACE;
70 90
71 memcpy(propval, val, len); 91 return fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name,
72 return 0; 92 strlen(name), 0,
93 val, len);
73} 94}
74 95
75static void _fdt_nop_region(void *start, int len) 96static void _fdt_nop_region(void *start, int len)
diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h
index 59ca33976e56..b842b156fa17 100644
--- a/scripts/dtc/libfdt/libfdt.h
+++ b/scripts/dtc/libfdt/libfdt.h
@@ -61,7 +61,7 @@
61#define FDT_ERR_NOTFOUND 1 61#define FDT_ERR_NOTFOUND 1
62 /* FDT_ERR_NOTFOUND: The requested node or property does not exist */ 62 /* FDT_ERR_NOTFOUND: The requested node or property does not exist */
63#define FDT_ERR_EXISTS 2 63#define FDT_ERR_EXISTS 2
64 /* FDT_ERR_EXISTS: Attemped to create a node or property which 64 /* FDT_ERR_EXISTS: Attempted to create a node or property which
65 * already exists */ 65 * already exists */
66#define FDT_ERR_NOSPACE 3 66#define FDT_ERR_NOSPACE 3
67 /* FDT_ERR_NOSPACE: Operation needed to expand the device 67 /* FDT_ERR_NOSPACE: Operation needed to expand the device
@@ -79,8 +79,10 @@
79 * (e.g. missing a leading / for a function which requires an 79 * (e.g. missing a leading / for a function which requires an
80 * absolute path) */ 80 * absolute path) */
81#define FDT_ERR_BADPHANDLE 6 81#define FDT_ERR_BADPHANDLE 6
82 /* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle 82 /* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle.
83 * value. phandle values of 0 and -1 are not permitted. */ 83 * This can be caused either by an invalid phandle property
84 * length, or the phandle value was either 0 or -1, which are
85 * not permitted. */
84#define FDT_ERR_BADSTATE 7 86#define FDT_ERR_BADSTATE 7
85 /* FDT_ERR_BADSTATE: Function was passed an incomplete device 87 /* FDT_ERR_BADSTATE: Function was passed an incomplete device
86 * tree created by the sequential-write functions, which is 88 * tree created by the sequential-write functions, which is
@@ -126,7 +128,16 @@
126 * value. For example: a property expected to contain a string list 128 * value. For example: a property expected to contain a string list
127 * is not NUL-terminated within the length of its value. */ 129 * is not NUL-terminated within the length of its value. */
128 130
129#define FDT_ERR_MAX 15 131#define FDT_ERR_BADOVERLAY 16
132 /* FDT_ERR_BADOVERLAY: The device tree overlay, while
133 * correctly structured, cannot be applied due to some
134 * unexpected or missing value, property or node. */
135
136#define FDT_ERR_NOPHANDLES 17
137 /* FDT_ERR_NOPHANDLES: The device tree doesn't have any
138 * phandle available anymore without causing an overflow */
139
140#define FDT_ERR_MAX 17
130 141
131/**********************************************************************/ 142/**********************************************************************/
132/* Low-level functions (you probably don't need these) */ 143/* Low-level functions (you probably don't need these) */
@@ -168,27 +179,55 @@ int fdt_first_subnode(const void *fdt, int offset);
168 */ 179 */
169int fdt_next_subnode(const void *fdt, int offset); 180int fdt_next_subnode(const void *fdt, int offset);
170 181
182/**
183 * fdt_for_each_subnode - iterate over all subnodes of a parent
184 *
185 * @node: child node (int, lvalue)
186 * @fdt: FDT blob (const void *)
187 * @parent: parent node (int)
188 *
189 * This is actually a wrapper around a for loop and would be used like so:
190 *
191 * fdt_for_each_subnode(node, fdt, parent) {
192 * Use node
193 * ...
194 * }
195 *
196 * if ((node < 0) && (node != -FDT_ERR_NOT_FOUND)) {
197 * Error handling
198 * }
199 *
200 * Note that this is implemented as a macro and @node is used as
201 * iterator in the loop. The parent variable be constant or even a
202 * literal.
203 *
204 */
205#define fdt_for_each_subnode(node, fdt, parent) \
206 for (node = fdt_first_subnode(fdt, parent); \
207 node >= 0; \
208 node = fdt_next_subnode(fdt, node))
209
171/**********************************************************************/ 210/**********************************************************************/
172/* General functions */ 211/* General functions */
173/**********************************************************************/ 212/**********************************************************************/
174 213
175#define fdt_get_header(fdt, field) \ 214#define fdt_get_header(fdt, field) \
176 (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field)) 215 (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
177#define fdt_magic(fdt) (fdt_get_header(fdt, magic)) 216#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
178#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize)) 217#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))
179#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct)) 218#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))
180#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings)) 219#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings))
181#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap)) 220#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap))
182#define fdt_version(fdt) (fdt_get_header(fdt, version)) 221#define fdt_version(fdt) (fdt_get_header(fdt, version))
183#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version)) 222#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version))
184#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys)) 223#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys))
185#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings)) 224#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))
186#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct)) 225#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))
187 226
188#define __fdt_set_hdr(name) \ 227#define __fdt_set_hdr(name) \
189 static inline void fdt_set_##name(void *fdt, uint32_t val) \ 228 static inline void fdt_set_##name(void *fdt, uint32_t val) \
190 { \ 229 { \
191 struct fdt_header *fdth = (struct fdt_header*)fdt; \ 230 struct fdt_header *fdth = (struct fdt_header *)fdt; \
192 fdth->name = cpu_to_fdt32(val); \ 231 fdth->name = cpu_to_fdt32(val); \
193 } 232 }
194__fdt_set_hdr(magic); 233__fdt_set_hdr(magic);
@@ -259,6 +298,21 @@ int fdt_move(const void *fdt, void *buf, int bufsize);
259const char *fdt_string(const void *fdt, int stroffset); 298const char *fdt_string(const void *fdt, int stroffset);
260 299
261/** 300/**
301 * fdt_get_max_phandle - retrieves the highest phandle in a tree
302 * @fdt: pointer to the device tree blob
303 *
304 * fdt_get_max_phandle retrieves the highest phandle in the given
305 * device tree. This will ignore badly formatted phandles, or phandles
306 * with a value of 0 or -1.
307 *
308 * returns:
309 * the highest phandle on success
310 * 0, if no phandle was found in the device tree
311 * -1, if an error occurred
312 */
313uint32_t fdt_get_max_phandle(const void *fdt);
314
315/**
262 * fdt_num_mem_rsv - retrieve the number of memory reserve map entries 316 * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
263 * @fdt: pointer to the device tree blob 317 * @fdt: pointer to the device tree blob
264 * 318 *
@@ -318,8 +372,9 @@ int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
318 * returns: 372 * returns:
319 * structure block offset of the requested subnode (>=0), on success 373 * structure block offset of the requested subnode (>=0), on success
320 * -FDT_ERR_NOTFOUND, if the requested subnode does not exist 374 * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
321 * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag 375 * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE
322 * -FDT_ERR_BADMAGIC, 376 * tag
377 * -FDT_ERR_BADMAGIC,
323 * -FDT_ERR_BADVERSION, 378 * -FDT_ERR_BADVERSION,
324 * -FDT_ERR_BADSTATE, 379 * -FDT_ERR_BADSTATE,
325 * -FDT_ERR_BADSTRUCTURE, 380 * -FDT_ERR_BADSTRUCTURE,
@@ -351,7 +406,8 @@ int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
351 * address). 406 * address).
352 * 407 *
353 * returns: 408 * returns:
354 * structure block offset of the node with the requested path (>=0), on success 409 * structure block offset of the node with the requested path (>=0), on
410 * success
355 * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid 411 * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid
356 * -FDT_ERR_NOTFOUND, if the requested node does not exist 412 * -FDT_ERR_NOTFOUND, if the requested node does not exist
357 * -FDT_ERR_BADMAGIC, 413 * -FDT_ERR_BADMAGIC,
@@ -375,10 +431,12 @@ int fdt_path_offset(const void *fdt, const char *path);
375 * 431 *
376 * returns: 432 * returns:
377 * pointer to the node's name, on success 433 * pointer to the node's name, on success
378 * If lenp is non-NULL, *lenp contains the length of that name (>=0) 434 * If lenp is non-NULL, *lenp contains the length of that name
435 * (>=0)
379 * NULL, on error 436 * NULL, on error
380 * if lenp is non-NULL *lenp contains an error code (<0): 437 * if lenp is non-NULL *lenp contains an error code (<0):
381 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 438 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
439 * tag
382 * -FDT_ERR_BADMAGIC, 440 * -FDT_ERR_BADMAGIC,
383 * -FDT_ERR_BADVERSION, 441 * -FDT_ERR_BADVERSION,
384 * -FDT_ERR_BADSTATE, standard meanings 442 * -FDT_ERR_BADSTATE, standard meanings
@@ -427,6 +485,33 @@ int fdt_first_property_offset(const void *fdt, int nodeoffset);
427int fdt_next_property_offset(const void *fdt, int offset); 485int fdt_next_property_offset(const void *fdt, int offset);
428 486
429/** 487/**
488 * fdt_for_each_property_offset - iterate over all properties of a node
489 *
490 * @property_offset: property offset (int, lvalue)
491 * @fdt: FDT blob (const void *)
492 * @node: node offset (int)
493 *
494 * This is actually a wrapper around a for loop and would be used like so:
495 *
496 * fdt_for_each_property_offset(property, fdt, node) {
497 * Use property
498 * ...
499 * }
500 *
501 * if ((property < 0) && (property != -FDT_ERR_NOT_FOUND)) {
502 * Error handling
503 * }
504 *
505 * Note that this is implemented as a macro and property is used as
506 * iterator in the loop. The node variable can be constant or even a
507 * literal.
508 */
509#define fdt_for_each_property_offset(property, fdt, node) \
510 for (property = fdt_first_property_offset(fdt, node); \
511 property >= 0; \
512 property = fdt_next_property_offset(fdt, property))
513
514/**
430 * fdt_get_property_by_offset - retrieve the property at a given offset 515 * fdt_get_property_by_offset - retrieve the property at a given offset
431 * @fdt: pointer to the device tree blob 516 * @fdt: pointer to the device tree blob
432 * @offset: offset of the property to retrieve 517 * @offset: offset of the property to retrieve
@@ -490,7 +575,8 @@ const struct fdt_property *fdt_get_property_namelen(const void *fdt,
490 * NULL, on error 575 * NULL, on error
491 * if lenp is non-NULL, *lenp contains an error code (<0): 576 * if lenp is non-NULL, *lenp contains an error code (<0):
492 * -FDT_ERR_NOTFOUND, node does not have named property 577 * -FDT_ERR_NOTFOUND, node does not have named property
493 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 578 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
579 * tag
494 * -FDT_ERR_BADMAGIC, 580 * -FDT_ERR_BADMAGIC,
495 * -FDT_ERR_BADVERSION, 581 * -FDT_ERR_BADVERSION,
496 * -FDT_ERR_BADSTATE, 582 * -FDT_ERR_BADSTATE,
@@ -554,6 +640,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
554 */ 640 */
555const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, 641const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
556 const char *name, int namelen, int *lenp); 642 const char *name, int namelen, int *lenp);
643static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
644 const char *name, int namelen,
645 int *lenp)
646{
647 return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
648 namelen, lenp);
649}
557 650
558/** 651/**
559 * fdt_getprop - retrieve the value of a given property 652 * fdt_getprop - retrieve the value of a given property
@@ -575,7 +668,8 @@ const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
575 * NULL, on error 668 * NULL, on error
576 * if lenp is non-NULL, *lenp contains an error code (<0): 669 * if lenp is non-NULL, *lenp contains an error code (<0):
577 * -FDT_ERR_NOTFOUND, node does not have named property 670 * -FDT_ERR_NOTFOUND, node does not have named property
578 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 671 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
672 * tag
579 * -FDT_ERR_BADMAGIC, 673 * -FDT_ERR_BADMAGIC,
580 * -FDT_ERR_BADVERSION, 674 * -FDT_ERR_BADVERSION,
581 * -FDT_ERR_BADSTATE, 675 * -FDT_ERR_BADSTATE,
@@ -617,7 +711,7 @@ const char *fdt_get_alias_namelen(const void *fdt,
617 const char *name, int namelen); 711 const char *name, int namelen);
618 712
619/** 713/**
620 * fdt_get_alias - retreive the path referenced by a given alias 714 * fdt_get_alias - retrieve the path referenced by a given alias
621 * @fdt: pointer to the device tree blob 715 * @fdt: pointer to the device tree blob
622 * @name: name of the alias th look up 716 * @name: name of the alias th look up
623 * 717 *
@@ -647,7 +741,7 @@ const char *fdt_get_alias(const void *fdt, const char *name);
647 * 0, on success 741 * 0, on success
648 * buf contains the absolute path of the node at 742 * buf contains the absolute path of the node at
649 * nodeoffset, as a NUL-terminated string. 743 * nodeoffset, as a NUL-terminated string.
650 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 744 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
651 * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1) 745 * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1)
652 * characters and will not fit in the given buffer. 746 * characters and will not fit in the given buffer.
653 * -FDT_ERR_BADMAGIC, 747 * -FDT_ERR_BADMAGIC,
@@ -677,11 +771,11 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);
677 * structure from the start to nodeoffset. 771 * structure from the start to nodeoffset.
678 * 772 *
679 * returns: 773 * returns:
680
681 * structure block offset of the node at node offset's ancestor 774 * structure block offset of the node at node offset's ancestor
682 * of depth supernodedepth (>=0), on success 775 * of depth supernodedepth (>=0), on success
683 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 776 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
684* -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of nodeoffset 777 * -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of
778 * nodeoffset
685 * -FDT_ERR_BADMAGIC, 779 * -FDT_ERR_BADMAGIC,
686 * -FDT_ERR_BADVERSION, 780 * -FDT_ERR_BADVERSION,
687 * -FDT_ERR_BADSTATE, 781 * -FDT_ERR_BADSTATE,
@@ -703,7 +797,7 @@ int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
703 * 797 *
704 * returns: 798 * returns:
705 * depth of the node at nodeoffset (>=0), on success 799 * depth of the node at nodeoffset (>=0), on success
706 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 800 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
707 * -FDT_ERR_BADMAGIC, 801 * -FDT_ERR_BADMAGIC,
708 * -FDT_ERR_BADVERSION, 802 * -FDT_ERR_BADVERSION,
709 * -FDT_ERR_BADSTATE, 803 * -FDT_ERR_BADSTATE,
@@ -726,7 +820,7 @@ int fdt_node_depth(const void *fdt, int nodeoffset);
726 * returns: 820 * returns:
727 * structure block offset of the parent of the node at nodeoffset 821 * structure block offset of the parent of the node at nodeoffset
728 * (>=0), on success 822 * (>=0), on success
729 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 823 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
730 * -FDT_ERR_BADMAGIC, 824 * -FDT_ERR_BADMAGIC,
731 * -FDT_ERR_BADVERSION, 825 * -FDT_ERR_BADVERSION,
732 * -FDT_ERR_BADSTATE, 826 * -FDT_ERR_BADSTATE,
@@ -766,7 +860,7 @@ int fdt_parent_offset(const void *fdt, int nodeoffset);
766 * on success 860 * on success
767 * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the 861 * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
768 * tree after startoffset 862 * tree after startoffset
769 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 863 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
770 * -FDT_ERR_BADMAGIC, 864 * -FDT_ERR_BADMAGIC,
771 * -FDT_ERR_BADVERSION, 865 * -FDT_ERR_BADVERSION,
772 * -FDT_ERR_BADSTATE, 866 * -FDT_ERR_BADSTATE,
@@ -813,7 +907,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle);
813 * 1, if the node has a 'compatible' property, but it does not list 907 * 1, if the node has a 'compatible' property, but it does not list
814 * the given string 908 * the given string
815 * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property 909 * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property
816 * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag 910 * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag
817 * -FDT_ERR_BADMAGIC, 911 * -FDT_ERR_BADMAGIC,
818 * -FDT_ERR_BADVERSION, 912 * -FDT_ERR_BADVERSION,
819 * -FDT_ERR_BADSTATE, 913 * -FDT_ERR_BADSTATE,
@@ -850,7 +944,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset,
850 * on success 944 * on success
851 * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the 945 * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
852 * tree after startoffset 946 * tree after startoffset
853 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag 947 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
854 * -FDT_ERR_BADMAGIC, 948 * -FDT_ERR_BADMAGIC,
855 * -FDT_ERR_BADVERSION, 949 * -FDT_ERR_BADVERSION,
856 * -FDT_ERR_BADSTATE, 950 * -FDT_ERR_BADSTATE,
@@ -960,7 +1054,8 @@ const char *fdt_stringlist_get(const void *fdt, int nodeoffset,
960 * returns: 1054 * returns:
961 * 0 <= n < FDT_MAX_NCELLS, on success 1055 * 0 <= n < FDT_MAX_NCELLS, on success
962 * 2, if the node has no #address-cells property 1056 * 2, if the node has no #address-cells property
963 * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid #address-cells property 1057 * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
1058 * #address-cells property
964 * -FDT_ERR_BADMAGIC, 1059 * -FDT_ERR_BADMAGIC,
965 * -FDT_ERR_BADVERSION, 1060 * -FDT_ERR_BADVERSION,
966 * -FDT_ERR_BADSTATE, 1061 * -FDT_ERR_BADSTATE,
@@ -980,7 +1075,8 @@ int fdt_address_cells(const void *fdt, int nodeoffset);
980 * returns: 1075 * returns:
981 * 0 <= n < FDT_MAX_NCELLS, on success 1076 * 0 <= n < FDT_MAX_NCELLS, on success
982 * 2, if the node has no #address-cells property 1077 * 2, if the node has no #address-cells property
983 * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid #size-cells property 1078 * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
1079 * #size-cells property
984 * -FDT_ERR_BADMAGIC, 1080 * -FDT_ERR_BADMAGIC,
985 * -FDT_ERR_BADVERSION, 1081 * -FDT_ERR_BADVERSION,
986 * -FDT_ERR_BADSTATE, 1082 * -FDT_ERR_BADSTATE,
@@ -995,6 +1091,27 @@ int fdt_size_cells(const void *fdt, int nodeoffset);
995/**********************************************************************/ 1091/**********************************************************************/
996 1092
997/** 1093/**
1094 * fdt_setprop_inplace_namelen_partial - change a property's value,
1095 * but not its size
1096 * @fdt: pointer to the device tree blob
1097 * @nodeoffset: offset of the node whose property to change
1098 * @name: name of the property to change
1099 * @namelen: number of characters of name to consider
1100 * @idx: index of the property to change in the array
1101 * @val: pointer to data to replace the property value with
1102 * @len: length of the property value
1103 *
1104 * Identical to fdt_setprop_inplace(), but modifies the given property
1105 * starting from the given index, and using only the first characters
1106 * of the name. It is useful when you want to manipulate only one value of
1107 * an array and you have a string that doesn't end with \0.
1108 */
1109int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
1110 const char *name, int namelen,
1111 uint32_t idx, const void *val,
1112 int len);
1113
1114/**
998 * fdt_setprop_inplace - change a property's value, but not its size 1115 * fdt_setprop_inplace - change a property's value, but not its size
999 * @fdt: pointer to the device tree blob 1116 * @fdt: pointer to the device tree blob
1000 * @nodeoffset: offset of the node whose property to change 1117 * @nodeoffset: offset of the node whose property to change
@@ -1604,9 +1721,11 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
1604 * change the offsets of some existing nodes. 1721 * change the offsets of some existing nodes.
1605 1722
1606 * returns: 1723 * returns:
1607 * structure block offset of the created nodeequested subnode (>=0), on success 1724 * structure block offset of the created nodeequested subnode (>=0), on
1725 * success
1608 * -FDT_ERR_NOTFOUND, if the requested subnode does not exist 1726 * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
1609 * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag 1727 * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE
1728 * tag
1610 * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of 1729 * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of
1611 * the given name 1730 * the given name
1612 * -FDT_ERR_NOSPACE, if there is insufficient free space in the 1731 * -FDT_ERR_NOSPACE, if there is insufficient free space in the
@@ -1644,6 +1763,37 @@ int fdt_add_subnode(void *fdt, int parentoffset, const char *name);
1644 */ 1763 */
1645int fdt_del_node(void *fdt, int nodeoffset); 1764int fdt_del_node(void *fdt, int nodeoffset);
1646 1765
1766/**
1767 * fdt_overlay_apply - Applies a DT overlay on a base DT
1768 * @fdt: pointer to the base device tree blob
1769 * @fdto: pointer to the device tree overlay blob
1770 *
1771 * fdt_overlay_apply() will apply the given device tree overlay on the
1772 * given base device tree.
1773 *
1774 * Expect the base device tree to be modified, even if the function
1775 * returns an error.
1776 *
1777 * returns:
1778 * 0, on success
1779 * -FDT_ERR_NOSPACE, there's not enough space in the base device tree
1780 * -FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or
1781 * properties in the base DT
1782 * -FDT_ERR_BADPHANDLE,
1783 * -FDT_ERR_BADOVERLAY,
1784 * -FDT_ERR_NOPHANDLES,
1785 * -FDT_ERR_INTERNAL,
1786 * -FDT_ERR_BADLAYOUT,
1787 * -FDT_ERR_BADMAGIC,
1788 * -FDT_ERR_BADOFFSET,
1789 * -FDT_ERR_BADPATH,
1790 * -FDT_ERR_BADVERSION,
1791 * -FDT_ERR_BADSTRUCTURE,
1792 * -FDT_ERR_BADSTATE,
1793 * -FDT_ERR_TRUNCATED, standard meanings
1794 */
1795int fdt_overlay_apply(void *fdt, void *fdto);
1796
1647/**********************************************************************/ 1797/**********************************************************************/
1648/* Debugging / informational functions */ 1798/* Debugging / informational functions */
1649/**********************************************************************/ 1799/**********************************************************************/
diff --git a/scripts/dtc/libfdt/libfdt_env.h b/scripts/dtc/libfdt/libfdt_env.h
index 9dea97dfff81..99f936dacc60 100644
--- a/scripts/dtc/libfdt/libfdt_env.h
+++ b/scripts/dtc/libfdt/libfdt_env.h
@@ -54,6 +54,7 @@
54 54
55#include <stddef.h> 55#include <stddef.h>
56#include <stdint.h> 56#include <stdint.h>
57#include <stdlib.h>
57#include <string.h> 58#include <string.h>
58 59
59#ifdef __CHECKER__ 60#ifdef __CHECKER__
diff --git a/scripts/dtc/livetree.c b/scripts/dtc/livetree.c
index e229b84432f9..afa2f67b142a 100644
--- a/scripts/dtc/livetree.c
+++ b/scripts/dtc/livetree.c
@@ -204,7 +204,7 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node)
204 } 204 }
205 } 205 }
206 206
207 /* if no collision occured, add child to the old node. */ 207 /* if no collision occurred, add child to the old node. */
208 if (new_child) 208 if (new_child)
209 add_child(old_node, new_child); 209 add_child(old_node, new_child);
210 } 210 }
@@ -296,6 +296,23 @@ void delete_node(struct node *node)
296 delete_labels(&node->labels); 296 delete_labels(&node->labels);
297} 297}
298 298
299void append_to_property(struct node *node,
300 char *name, const void *data, int len)
301{
302 struct data d;
303 struct property *p;
304
305 p = get_property(node, name);
306 if (p) {
307 d = data_append_data(p->val, data, len);
308 p->val = d;
309 } else {
310 d = data_append_data(empty_data, data, len);
311 p = build_property(name, d);
312 add_property(node, p);
313 }
314}
315
299struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size) 316struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size)
300{ 317{
301 struct reserve_info *new = xmalloc(sizeof(*new)); 318 struct reserve_info *new = xmalloc(sizeof(*new));
@@ -335,17 +352,19 @@ struct reserve_info *add_reserve_entry(struct reserve_info *list,
335 return list; 352 return list;
336} 353}
337 354
338struct boot_info *build_boot_info(struct reserve_info *reservelist, 355struct dt_info *build_dt_info(unsigned int dtsflags,
339 struct node *tree, uint32_t boot_cpuid_phys) 356 struct reserve_info *reservelist,
357 struct node *tree, uint32_t boot_cpuid_phys)
340{ 358{
341 struct boot_info *bi; 359 struct dt_info *dti;
342 360
343 bi = xmalloc(sizeof(*bi)); 361 dti = xmalloc(sizeof(*dti));
344 bi->reservelist = reservelist; 362 dti->dtsflags = dtsflags;
345 bi->dt = tree; 363 dti->reservelist = reservelist;
346 bi->boot_cpuid_phys = boot_cpuid_phys; 364 dti->dt = tree;
365 dti->boot_cpuid_phys = boot_cpuid_phys;
347 366
348 return bi; 367 return dti;
349} 368}
350 369
351/* 370/*
@@ -592,12 +611,12 @@ static int cmp_reserve_info(const void *ax, const void *bx)
592 return 0; 611 return 0;
593} 612}
594 613
595static void sort_reserve_entries(struct boot_info *bi) 614static void sort_reserve_entries(struct dt_info *dti)
596{ 615{
597 struct reserve_info *ri, **tbl; 616 struct reserve_info *ri, **tbl;
598 int n = 0, i = 0; 617 int n = 0, i = 0;
599 618
600 for (ri = bi->reservelist; 619 for (ri = dti->reservelist;
601 ri; 620 ri;
602 ri = ri->next) 621 ri = ri->next)
603 n++; 622 n++;
@@ -607,14 +626,14 @@ static void sort_reserve_entries(struct boot_info *bi)
607 626
608 tbl = xmalloc(n * sizeof(*tbl)); 627 tbl = xmalloc(n * sizeof(*tbl));
609 628
610 for (ri = bi->reservelist; 629 for (ri = dti->reservelist;
611 ri; 630 ri;
612 ri = ri->next) 631 ri = ri->next)
613 tbl[i++] = ri; 632 tbl[i++] = ri;
614 633
615 qsort(tbl, n, sizeof(*tbl), cmp_reserve_info); 634 qsort(tbl, n, sizeof(*tbl), cmp_reserve_info);
616 635
617 bi->reservelist = tbl[0]; 636 dti->reservelist = tbl[0];
618 for (i = 0; i < (n-1); i++) 637 for (i = 0; i < (n-1); i++)
619 tbl[i]->next = tbl[i+1]; 638 tbl[i]->next = tbl[i+1];
620 tbl[n-1]->next = NULL; 639 tbl[n-1]->next = NULL;
@@ -704,8 +723,256 @@ static void sort_node(struct node *node)
704 sort_node(c); 723 sort_node(c);
705} 724}
706 725
707void sort_tree(struct boot_info *bi) 726void sort_tree(struct dt_info *dti)
727{
728 sort_reserve_entries(dti);
729 sort_node(dti->dt);
730}
731
732/* utility helper to avoid code duplication */
733static struct node *build_and_name_child_node(struct node *parent, char *name)
734{
735 struct node *node;
736
737 node = build_node(NULL, NULL);
738 name_node(node, xstrdup(name));
739 add_child(parent, node);
740
741 return node;
742}
743
744static struct node *build_root_node(struct node *dt, char *name)
745{
746 struct node *an;
747
748 an = get_subnode(dt, name);
749 if (!an)
750 an = build_and_name_child_node(dt, name);
751
752 if (!an)
753 die("Could not build root node /%s\n", name);
754
755 return an;
756}
757
758static bool any_label_tree(struct dt_info *dti, struct node *node)
759{
760 struct node *c;
761
762 if (node->labels)
763 return true;
764
765 for_each_child(node, c)
766 if (any_label_tree(dti, c))
767 return true;
768
769 return false;
770}
771
772static void generate_label_tree_internal(struct dt_info *dti,
773 struct node *an, struct node *node,
774 bool allocph)
775{
776 struct node *dt = dti->dt;
777 struct node *c;
778 struct property *p;
779 struct label *l;
780
781 /* if there are labels */
782 if (node->labels) {
783
784 /* now add the label in the node */
785 for_each_label(node->labels, l) {
786
787 /* check whether the label already exists */
788 p = get_property(an, l->label);
789 if (p) {
790 fprintf(stderr, "WARNING: label %s already"
791 " exists in /%s", l->label,
792 an->name);
793 continue;
794 }
795
796 /* insert it */
797 p = build_property(l->label,
798 data_copy_mem(node->fullpath,
799 strlen(node->fullpath) + 1));
800 add_property(an, p);
801 }
802
803 /* force allocation of a phandle for this node */
804 if (allocph)
805 (void)get_node_phandle(dt, node);
806 }
807
808 for_each_child(node, c)
809 generate_label_tree_internal(dti, an, c, allocph);
810}
811
812static bool any_fixup_tree(struct dt_info *dti, struct node *node)
813{
814 struct node *c;
815 struct property *prop;
816 struct marker *m;
817
818 for_each_property(node, prop) {
819 m = prop->val.markers;
820 for_each_marker_of_type(m, REF_PHANDLE) {
821 if (!get_node_by_ref(dti->dt, m->ref))
822 return true;
823 }
824 }
825
826 for_each_child(node, c) {
827 if (any_fixup_tree(dti, c))
828 return true;
829 }
830
831 return false;
832}
833
834static void add_fixup_entry(struct dt_info *dti, struct node *fn,
835 struct node *node, struct property *prop,
836 struct marker *m)
708{ 837{
709 sort_reserve_entries(bi); 838 char *entry;
710 sort_node(bi->dt); 839
840 /* m->ref can only be a REF_PHANDLE, but check anyway */
841 assert(m->type == REF_PHANDLE);
842
843 /* there shouldn't be any ':' in the arguments */
844 if (strchr(node->fullpath, ':') || strchr(prop->name, ':'))
845 die("arguments should not contain ':'\n");
846
847 xasprintf(&entry, "%s:%s:%u",
848 node->fullpath, prop->name, m->offset);
849 append_to_property(fn, m->ref, entry, strlen(entry) + 1);
850}
851
852static void generate_fixups_tree_internal(struct dt_info *dti,
853 struct node *fn,
854 struct node *node)
855{
856 struct node *dt = dti->dt;
857 struct node *c;
858 struct property *prop;
859 struct marker *m;
860 struct node *refnode;
861
862 for_each_property(node, prop) {
863 m = prop->val.markers;
864 for_each_marker_of_type(m, REF_PHANDLE) {
865 refnode = get_node_by_ref(dt, m->ref);
866 if (!refnode)
867 add_fixup_entry(dti, fn, node, prop, m);
868 }
869 }
870
871 for_each_child(node, c)
872 generate_fixups_tree_internal(dti, fn, c);
873}
874
875static bool any_local_fixup_tree(struct dt_info *dti, struct node *node)
876{
877 struct node *c;
878 struct property *prop;
879 struct marker *m;
880
881 for_each_property(node, prop) {
882 m = prop->val.markers;
883 for_each_marker_of_type(m, REF_PHANDLE) {
884 if (get_node_by_ref(dti->dt, m->ref))
885 return true;
886 }
887 }
888
889 for_each_child(node, c) {
890 if (any_local_fixup_tree(dti, c))
891 return true;
892 }
893
894 return false;
895}
896
897static void add_local_fixup_entry(struct dt_info *dti,
898 struct node *lfn, struct node *node,
899 struct property *prop, struct marker *m,
900 struct node *refnode)
901{
902 struct node *wn, *nwn; /* local fixup node, walk node, new */
903 uint32_t value_32;
904 char **compp;
905 int i, depth;
906
907 /* walk back retreiving depth */
908 depth = 0;
909 for (wn = node; wn; wn = wn->parent)
910 depth++;
911
912 /* allocate name array */
913 compp = xmalloc(sizeof(*compp) * depth);
914
915 /* store names in the array */
916 for (wn = node, i = depth - 1; wn; wn = wn->parent, i--)
917 compp[i] = wn->name;
918
919 /* walk the path components creating nodes if they don't exist */
920 for (wn = lfn, i = 1; i < depth; i++, wn = nwn) {
921 /* if no node exists, create it */
922 nwn = get_subnode(wn, compp[i]);
923 if (!nwn)
924 nwn = build_and_name_child_node(wn, compp[i]);
925 }
926
927 free(compp);
928
929 value_32 = cpu_to_fdt32(m->offset);
930 append_to_property(wn, prop->name, &value_32, sizeof(value_32));
931}
932
933static void generate_local_fixups_tree_internal(struct dt_info *dti,
934 struct node *lfn,
935 struct node *node)
936{
937 struct node *dt = dti->dt;
938 struct node *c;
939 struct property *prop;
940 struct marker *m;
941 struct node *refnode;
942
943 for_each_property(node, prop) {
944 m = prop->val.markers;
945 for_each_marker_of_type(m, REF_PHANDLE) {
946 refnode = get_node_by_ref(dt, m->ref);
947 if (refnode)
948 add_local_fixup_entry(dti, lfn, node, prop, m, refnode);
949 }
950 }
951
952 for_each_child(node, c)
953 generate_local_fixups_tree_internal(dti, lfn, c);
954}
955
956void generate_label_tree(struct dt_info *dti, char *name, bool allocph)
957{
958 if (!any_label_tree(dti, dti->dt))
959 return;
960 generate_label_tree_internal(dti, build_root_node(dti->dt, name),
961 dti->dt, allocph);
962}
963
964void generate_fixups_tree(struct dt_info *dti, char *name)
965{
966 if (!any_fixup_tree(dti, dti->dt))
967 return;
968 generate_fixups_tree_internal(dti, build_root_node(dti->dt, name),
969 dti->dt);
970}
971
972void generate_local_fixups_tree(struct dt_info *dti, char *name)
973{
974 if (!any_local_fixup_tree(dti, dti->dt))
975 return;
976 generate_local_fixups_tree_internal(dti, build_root_node(dti->dt, name),
977 dti->dt);
711} 978}
diff --git a/scripts/dtc/srcpos.c b/scripts/dtc/srcpos.c
index f534c22a888d..aa3aad04cec4 100644
--- a/scripts/dtc/srcpos.c
+++ b/scripts/dtc/srcpos.c
@@ -246,46 +246,27 @@ srcpos_copy(struct srcpos *pos)
246 return pos_new; 246 return pos_new;
247} 247}
248 248
249
250
251void
252srcpos_dump(struct srcpos *pos)
253{
254 printf("file : \"%s\"\n",
255 pos->file ? (char *) pos->file : "<no file>");
256 printf("first_line : %d\n", pos->first_line);
257 printf("first_column: %d\n", pos->first_column);
258 printf("last_line : %d\n", pos->last_line);
259 printf("last_column : %d\n", pos->last_column);
260 printf("file : %s\n", pos->file->name);
261}
262
263
264char * 249char *
265srcpos_string(struct srcpos *pos) 250srcpos_string(struct srcpos *pos)
266{ 251{
267 const char *fname = "<no-file>"; 252 const char *fname = "<no-file>";
268 char *pos_str; 253 char *pos_str;
269 int rc;
270 254
271 if (pos) 255 if (pos)
272 fname = pos->file->name; 256 fname = pos->file->name;
273 257
274 258
275 if (pos->first_line != pos->last_line) 259 if (pos->first_line != pos->last_line)
276 rc = asprintf(&pos_str, "%s:%d.%d-%d.%d", fname, 260 xasprintf(&pos_str, "%s:%d.%d-%d.%d", fname,
277 pos->first_line, pos->first_column, 261 pos->first_line, pos->first_column,
278 pos->last_line, pos->last_column); 262 pos->last_line, pos->last_column);
279 else if (pos->first_column != pos->last_column) 263 else if (pos->first_column != pos->last_column)
280 rc = asprintf(&pos_str, "%s:%d.%d-%d", fname, 264 xasprintf(&pos_str, "%s:%d.%d-%d", fname,
281 pos->first_line, pos->first_column, 265 pos->first_line, pos->first_column,
282 pos->last_column); 266 pos->last_column);
283 else 267 else
284 rc = asprintf(&pos_str, "%s:%d.%d", fname, 268 xasprintf(&pos_str, "%s:%d.%d", fname,
285 pos->first_line, pos->first_column); 269 pos->first_line, pos->first_column);
286
287 if (rc == -1)
288 die("Couldn't allocate in srcpos string");
289 270
290 return pos_str; 271 return pos_str;
291} 272}
diff --git a/scripts/dtc/srcpos.h b/scripts/dtc/srcpos.h
index f81827bd684a..2cdfcd82e95e 100644
--- a/scripts/dtc/srcpos.h
+++ b/scripts/dtc/srcpos.h
@@ -105,7 +105,6 @@ extern struct srcpos srcpos_empty;
105extern void srcpos_update(struct srcpos *pos, const char *text, int len); 105extern void srcpos_update(struct srcpos *pos, const char *text, int len);
106extern struct srcpos *srcpos_copy(struct srcpos *pos); 106extern struct srcpos *srcpos_copy(struct srcpos *pos);
107extern char *srcpos_string(struct srcpos *pos); 107extern char *srcpos_string(struct srcpos *pos);
108extern void srcpos_dump(struct srcpos *pos);
109 108
110extern void srcpos_verror(struct srcpos *pos, const char *prefix, 109extern void srcpos_verror(struct srcpos *pos, const char *prefix,
111 const char *fmt, va_list va) 110 const char *fmt, va_list va)
diff --git a/scripts/dtc/treesource.c b/scripts/dtc/treesource.c
index a55d1d128cce..c9d8967969f9 100644
--- a/scripts/dtc/treesource.c
+++ b/scripts/dtc/treesource.c
@@ -25,12 +25,12 @@ extern FILE *yyin;
25extern int yyparse(void); 25extern int yyparse(void);
26extern YYLTYPE yylloc; 26extern YYLTYPE yylloc;
27 27
28struct boot_info *the_boot_info; 28struct dt_info *parser_output;
29bool treesource_error; 29bool treesource_error;
30 30
31struct boot_info *dt_from_source(const char *fname) 31struct dt_info *dt_from_source(const char *fname)
32{ 32{
33 the_boot_info = NULL; 33 parser_output = NULL;
34 treesource_error = false; 34 treesource_error = false;
35 35
36 srcfile_push(fname); 36 srcfile_push(fname);
@@ -43,7 +43,7 @@ struct boot_info *dt_from_source(const char *fname)
43 if (treesource_error) 43 if (treesource_error)
44 die("Syntax error parsing input tree\n"); 44 die("Syntax error parsing input tree\n");
45 45
46 return the_boot_info; 46 return parser_output;
47} 47}
48 48
49static void write_prefix(FILE *f, int level) 49static void write_prefix(FILE *f, int level)
@@ -263,13 +263,13 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level)
263} 263}
264 264
265 265
266void dt_to_source(FILE *f, struct boot_info *bi) 266void dt_to_source(FILE *f, struct dt_info *dti)
267{ 267{
268 struct reserve_info *re; 268 struct reserve_info *re;
269 269
270 fprintf(f, "/dts-v1/;\n\n"); 270 fprintf(f, "/dts-v1/;\n\n");
271 271
272 for (re = bi->reservelist; re; re = re->next) { 272 for (re = dti->reservelist; re; re = re->next) {
273 struct label *l; 273 struct label *l;
274 274
275 for_each_label(re->labels, l) 275 for_each_label(re->labels, l)
@@ -279,6 +279,6 @@ void dt_to_source(FILE *f, struct boot_info *bi)
279 (unsigned long long)re->re.size); 279 (unsigned long long)re->re.size);
280 } 280 }
281 281
282 write_tree_source_node(f, bi->dt, 0); 282 write_tree_source_node(f, dti->dt, 0);
283} 283}
284 284
diff --git a/scripts/dtc/util.c b/scripts/dtc/util.c
index fb124eea4919..3550f86bd6df 100644
--- a/scripts/dtc/util.c
+++ b/scripts/dtc/util.c
@@ -46,6 +46,36 @@ char *xstrdup(const char *s)
46 return d; 46 return d;
47} 47}
48 48
49/* based in part from (3) vsnprintf */
50int xasprintf(char **strp, const char *fmt, ...)
51{
52 int n, size = 128; /* start with 128 bytes */
53 char *p;
54 va_list ap;
55
56 /* initial pointer is NULL making the fist realloc to be malloc */
57 p = NULL;
58 while (1) {
59 p = xrealloc(p, size);
60
61 /* Try to print in the allocated space. */
62 va_start(ap, fmt);
63 n = vsnprintf(p, size, fmt, ap);
64 va_end(ap);
65
66 /* If that worked, return the string. */
67 if (n > -1 && n < size)
68 break;
69 /* Else try again with more space. */
70 if (n > -1) /* glibc 2.1 */
71 size = n + 1; /* precisely what is needed */
72 else /* glibc 2.0 */
73 size *= 2; /* twice the old size */
74 }
75 *strp = p;
76 return strlen(p);
77}
78
49char *join_path(const char *path, const char *name) 79char *join_path(const char *path, const char *name)
50{ 80{
51 int lenp = strlen(path); 81 int lenp = strlen(path);
diff --git a/scripts/dtc/util.h b/scripts/dtc/util.h
index f800b6011fb1..f5c4f1b50d30 100644
--- a/scripts/dtc/util.h
+++ b/scripts/dtc/util.h
@@ -59,6 +59,7 @@ static inline void *xrealloc(void *p, size_t len)
59} 59}
60 60
61extern char *xstrdup(const char *s); 61extern char *xstrdup(const char *s);
62extern int xasprintf(char **strp, const char *fmt, ...);
62extern char *join_path(const char *path, const char *name); 63extern char *join_path(const char *path, const char *name);
63 64
64/** 65/**
diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h
index ad9b05ae698b..16c2e53a85e3 100644
--- a/scripts/dtc/version_gen.h
+++ b/scripts/dtc/version_gen.h
@@ -1 +1 @@
#define DTC_VERSION "DTC 1.4.1-g53bf130b" #define DTC_VERSION "DTC 1.4.2-g0931cea3"