Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

of/flattree: Update dtc to current mainline.

Pull in recent changes from the main dtc repository. These changes
primarily allow multiple device trees to be declared which are merged
by dtc. This feature allows us to include a basic dts file and then
provide more information for the specific system through the merging
functionality.

Changes pulled from git://git.jdl.com/software/dtc.git
commit id: 37c0b6a0, "dtc: Add code to make diffing trees easier"

Signed-off-by: John Bonesio <bones@secretlab.ca>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>

authored by

John Bonesio and committed by
Grant Likely
658f29a5 cd1e6504

+1774 -1505
+2 -1
scripts/dtc/Makefile
··· 4 4 always := $(hostprogs-y) 5 5 6 6 dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \ 7 - srcpos.o checks.o 7 + srcpos.o checks.o util.o 8 8 dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o 9 9 10 10 # Source files need to get at the userspace version of libfdt_env.h to compile ··· 19 19 HOSTCFLAGS_livetree.o := $(HOSTCFLAGS_DTC) 20 20 HOSTCFLAGS_srcpos.o := $(HOSTCFLAGS_DTC) 21 21 HOSTCFLAGS_treesource.o := $(HOSTCFLAGS_DTC) 22 + HOSTCFLAGS_util.o := $(HOSTCFLAGS_DTC) 22 23 23 24 HOSTCFLAGS_dtc-lexer.lex.o := $(HOSTCFLAGS_DTC) 24 25 HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC)
+95 -12
scripts/dtc/checks.c
··· 278 278 } 279 279 PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR); 280 280 281 - static void check_explicit_phandles(struct check *c, struct node *root, 282 - struct node *node) 281 + #define DESCLABEL_FMT "%s%s%s%s%s" 282 + #define DESCLABEL_ARGS(node,prop,mark) \ 283 + ((mark) ? "value of " : ""), \ 284 + ((prop) ? "'" : ""), \ 285 + ((prop) ? (prop)->name : ""), \ 286 + ((prop) ? "' in " : ""), (node)->fullpath 287 + 288 + static void check_duplicate_label(struct check *c, struct node *dt, 289 + const char *label, struct node *node, 290 + struct property *prop, struct marker *mark) 283 291 { 284 - struct property *prop; 292 + struct node *othernode = NULL; 293 + struct property *otherprop = NULL; 294 + struct marker *othermark = NULL; 295 + 296 + othernode = get_node_by_label(dt, label); 297 + 298 + if (!othernode) 299 + otherprop = get_property_by_label(dt, label, &othernode); 300 + if (!othernode) 301 + othermark = get_marker_label(dt, label, &othernode, 302 + &otherprop); 303 + 304 + if (!othernode) 305 + return; 306 + 307 + if ((othernode != node) || (otherprop != prop) || (othermark != mark)) 308 + FAIL(c, "Duplicate label '%s' on " DESCLABEL_FMT 309 + " and " DESCLABEL_FMT, 310 + label, DESCLABEL_ARGS(node, prop, mark), 311 + DESCLABEL_ARGS(othernode, otherprop, othermark)); 312 + } 313 + 314 + static void check_duplicate_label_node(struct check *c, struct node *dt, 315 + struct node *node) 316 + { 317 + struct label *l; 318 + 319 + for_each_label(node->labels, l) 320 + check_duplicate_label(c, dt, l->label, node, NULL, NULL); 321 + } 322 + static void check_duplicate_label_prop(struct check *c, struct node *dt, 323 + struct node *node, struct property *prop) 324 + { 325 + struct marker *m = prop->val.markers; 326 + struct label *l; 327 + 328 + for_each_label(prop->labels, l) 329 + check_duplicate_label(c, dt, l->label, node, prop, NULL); 330 + 331 + for_each_marker_of_type(m, LABEL) 332 + check_duplicate_label(c, dt, m->ref, node, prop, m); 333 + } 334 + CHECK(duplicate_label, NULL, check_duplicate_label_node, 335 + check_duplicate_label_prop, NULL, ERROR); 336 + 337 + static void check_explicit_phandles(struct check *c, struct node *root, 338 + struct node *node, struct property *prop) 339 + { 340 + struct marker *m; 285 341 struct node *other; 286 342 cell_t phandle; 287 343 288 - prop = get_property(node, "linux,phandle"); 289 - if (! prop) 290 - return; /* No phandle, that's fine */ 344 + if (!streq(prop->name, "phandle") 345 + && !streq(prop->name, "linux,phandle")) 346 + return; 291 347 292 348 if (prop->val.len != sizeof(cell_t)) { 293 - FAIL(c, "%s has bad length (%d) linux,phandle property", 294 - node->fullpath, prop->val.len); 349 + FAIL(c, "%s has bad length (%d) %s property", 350 + node->fullpath, prop->val.len, prop->name); 351 + return; 352 + } 353 + 354 + m = prop->val.markers; 355 + for_each_marker_of_type(m, REF_PHANDLE) { 356 + assert(m->offset == 0); 357 + if (node != get_node_by_ref(root, m->ref)) 358 + /* "Set this node's phandle equal to some 359 + * other node's phandle". That's nonsensical 360 + * by construction. */ { 361 + FAIL(c, "%s in %s is a reference to another node", 362 + prop->name, node->fullpath); 363 + return; 364 + } 365 + /* But setting this node's phandle equal to its own 366 + * phandle is allowed - that means allocate a unique 367 + * phandle for this node, even if it's not otherwise 368 + * referenced. The value will be filled in later, so 369 + * no further checking for now. */ 295 370 return; 296 371 } 297 372 298 373 phandle = propval_cell(prop); 374 + 299 375 if ((phandle == 0) || (phandle == -1)) { 300 - FAIL(c, "%s has invalid linux,phandle value 0x%x", 301 - node->fullpath, phandle); 376 + FAIL(c, "%s has bad value (0x%x) in %s property", 377 + node->fullpath, phandle, prop->name); 302 378 return; 303 379 } 304 380 381 + if (node->phandle && (node->phandle != phandle)) 382 + FAIL(c, "%s has %s property which replaces existing phandle information", 383 + node->fullpath, prop->name); 384 + 305 385 other = get_node_by_phandle(root, phandle); 306 - if (other) { 386 + if (other && (other != node)) { 307 387 FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)", 308 388 node->fullpath, phandle, other->fullpath); 309 389 return; ··· 391 311 392 312 node->phandle = phandle; 393 313 } 394 - NODE_CHECK(explicit_phandles, NULL, ERROR); 314 + PROP_CHECK(explicit_phandles, NULL, ERROR); 395 315 396 316 static void check_name_properties(struct check *c, struct node *root, 397 317 struct node *node) ··· 629 549 &duplicate_node_names, &duplicate_property_names, 630 550 &node_name_chars, &node_name_format, &property_name_chars, 631 551 &name_is_string, &name_properties, 552 + 553 + &duplicate_label, 554 + 632 555 &explicit_phandles, 633 556 &phandle_references, &path_references, 634 557
+23 -152
scripts/dtc/dtc-lexer.l
··· 18 18 * USA 19 19 */ 20 20 21 - %option noyywrap noinput nounput yylineno 21 + %option noyywrap nounput noinput never-interactive 22 22 23 23 %x INCLUDE 24 24 %x BYTESTRING ··· 38 38 #include "srcpos.h" 39 39 #include "dtc-parser.tab.h" 40 40 41 + YYLTYPE yylloc; 42 + 43 + /* CAUTION: this will stop working if we ever use yyless() or yyunput() */ 44 + #define YY_USER_ACTION \ 45 + { \ 46 + srcpos_update(&yylloc, yytext, yyleng); \ 47 + } 41 48 42 49 /*#define LEXDEBUG 1*/ 43 50 ··· 54 47 #define DPRINT(fmt, ...) do { } while (0) 55 48 #endif 56 49 57 - static int dts_version; /* = 0 */ 50 + static int dts_version = 1; 58 51 59 - #define BEGIN_DEFAULT() if (dts_version == 0) { \ 60 - DPRINT("<INITIAL>\n"); \ 61 - BEGIN(INITIAL); \ 62 - } else { \ 63 - DPRINT("<V1>\n"); \ 52 + #define BEGIN_DEFAULT() DPRINT("<V1>\n"); \ 64 53 BEGIN(V1); \ 65 - } 66 54 67 55 static void push_input_file(const char *filename); 68 56 static int pop_input_file(void); ··· 77 75 } 78 76 79 77 <*>{STRING} { 80 - yylloc.file = srcpos_file; 81 - yylloc.first_line = yylineno; 82 78 DPRINT("String: %s\n", yytext); 83 79 yylval.data = data_copy_escape_string(yytext+1, 84 80 yyleng-2); 85 - yylloc.first_line = yylineno; 86 81 return DT_STRING; 87 82 } 88 83 89 84 <*>"/dts-v1/" { 90 - yylloc.file = srcpos_file; 91 - yylloc.first_line = yylineno; 92 85 DPRINT("Keyword: /dts-v1/\n"); 93 86 dts_version = 1; 94 87 BEGIN_DEFAULT(); ··· 91 94 } 92 95 93 96 <*>"/memreserve/" { 94 - yylloc.file = srcpos_file; 95 - yylloc.first_line = yylineno; 96 97 DPRINT("Keyword: /memreserve/\n"); 97 98 BEGIN_DEFAULT(); 98 99 return DT_MEMRESERVE; 99 100 } 100 101 101 102 <*>{LABEL}: { 102 - yylloc.file = srcpos_file; 103 - yylloc.first_line = yylineno; 104 103 DPRINT("Label: %s\n", yytext); 105 - yylval.labelref = strdup(yytext); 104 + yylval.labelref = xstrdup(yytext); 106 105 yylval.labelref[yyleng-1] = '\0'; 107 106 return DT_LABEL; 108 107 } 109 108 110 - <INITIAL>[bodh]# { 111 - yylloc.file = srcpos_file; 112 - yylloc.first_line = yylineno; 113 - if (*yytext == 'b') 114 - yylval.cbase = 2; 115 - else if (*yytext == 'o') 116 - yylval.cbase = 8; 117 - else if (*yytext == 'd') 118 - yylval.cbase = 10; 119 - else 120 - yylval.cbase = 16; 121 - DPRINT("Base: %d\n", yylval.cbase); 122 - return DT_BASE; 123 - } 124 - 125 - <INITIAL>[0-9a-fA-F]+ { 126 - yylloc.file = srcpos_file; 127 - yylloc.first_line = yylineno; 128 - yylval.literal = strdup(yytext); 129 - DPRINT("Literal: '%s'\n", yylval.literal); 130 - return DT_LEGACYLITERAL; 131 - } 132 - 133 109 <V1>[0-9]+|0[xX][0-9a-fA-F]+ { 134 - yylloc.file = srcpos_file; 135 - yylloc.first_line = yylineno; 136 - yylval.literal = strdup(yytext); 110 + yylval.literal = xstrdup(yytext); 137 111 DPRINT("Literal: '%s'\n", yylval.literal); 138 112 return DT_LITERAL; 139 113 } 140 114 141 - \&{LABEL} { /* label reference */ 142 - yylloc.file = srcpos_file; 143 - yylloc.first_line = yylineno; 115 + <*>\&{LABEL} { /* label reference */ 144 116 DPRINT("Ref: %s\n", yytext+1); 145 - yylval.labelref = strdup(yytext+1); 117 + yylval.labelref = xstrdup(yytext+1); 146 118 return DT_REF; 147 119 } 148 120 149 - "&{/"{PATHCHAR}+\} { /* new-style path reference */ 150 - yylloc.file = srcpos_file; 151 - yylloc.first_line = yylineno; 121 + <*>"&{/"{PATHCHAR}+\} { /* new-style path reference */ 152 122 yytext[yyleng-1] = '\0'; 153 123 DPRINT("Ref: %s\n", yytext+2); 154 - yylval.labelref = strdup(yytext+2); 155 - return DT_REF; 156 - } 157 - 158 - <INITIAL>"&/"{PATHCHAR}+ { /* old-style path reference */ 159 - yylloc.file = srcpos_file; 160 - yylloc.first_line = yylineno; 161 - DPRINT("Ref: %s\n", yytext+1); 162 - yylval.labelref = strdup(yytext+1); 124 + yylval.labelref = xstrdup(yytext+2); 163 125 return DT_REF; 164 126 } 165 127 166 128 <BYTESTRING>[0-9a-fA-F]{2} { 167 - yylloc.file = srcpos_file; 168 - yylloc.first_line = yylineno; 169 129 yylval.byte = strtol(yytext, NULL, 16); 170 130 DPRINT("Byte: %02x\n", (int)yylval.byte); 171 131 return DT_BYTE; 172 132 } 173 133 174 134 <BYTESTRING>"]" { 175 - yylloc.file = srcpos_file; 176 - yylloc.first_line = yylineno; 177 135 DPRINT("/BYTESTRING\n"); 178 136 BEGIN_DEFAULT(); 179 137 return ']'; 180 138 } 181 139 182 140 <PROPNODENAME>{PROPNODECHAR}+ { 183 - yylloc.file = srcpos_file; 184 - yylloc.first_line = yylineno; 185 141 DPRINT("PropNodeName: %s\n", yytext); 186 - yylval.propnodename = strdup(yytext); 142 + yylval.propnodename = xstrdup(yytext); 187 143 BEGIN_DEFAULT(); 188 144 return DT_PROPNODENAME; 189 145 } 190 146 191 147 "/incbin/" { 192 - yylloc.file = srcpos_file; 193 - yylloc.first_line = yylineno; 194 148 DPRINT("Binary Include\n"); 195 149 return DT_INCBIN; 196 150 } ··· 151 203 <*>{LINECOMMENT}+ /* eat C++-style comments */ 152 204 153 205 <*>. { 154 - yylloc.file = srcpos_file; 155 - yylloc.first_line = yylineno; 156 206 DPRINT("Char: %c (\\x%02x)\n", yytext[0], 157 207 (unsigned)yytext[0]); 158 208 if (yytext[0] == '[') { ··· 167 221 168 222 %% 169 223 170 - 171 - /* 172 - * Stack of nested include file contexts. 173 - */ 174 - 175 - struct incl_file { 176 - struct dtc_file *file; 177 - YY_BUFFER_STATE yy_prev_buf; 178 - int yy_prev_lineno; 179 - struct incl_file *prev; 180 - }; 181 - 182 - static struct incl_file *incl_file_stack; 183 - 184 - 185 - /* 186 - * Detect infinite include recursion. 187 - */ 188 - #define MAX_INCLUDE_DEPTH (100) 189 - 190 - static int incl_depth = 0; 191 - 192 - 193 224 static void push_input_file(const char *filename) 194 225 { 195 - struct incl_file *incl_file; 196 - struct dtc_file *newfile; 197 - struct search_path search, *searchptr = NULL; 198 - 199 226 assert(filename); 200 227 201 - if (incl_depth++ >= MAX_INCLUDE_DEPTH) 202 - die("Includes nested too deeply"); 228 + srcfile_push(filename); 203 229 204 - if (srcpos_file) { 205 - search.dir = srcpos_file->dir; 206 - search.next = NULL; 207 - search.prev = NULL; 208 - searchptr = &search; 209 - } 230 + yyin = current_srcfile->f; 210 231 211 - newfile = dtc_open_file(filename, searchptr); 212 - 213 - incl_file = xmalloc(sizeof(struct incl_file)); 214 - 215 - /* 216 - * Save current context. 217 - */ 218 - incl_file->yy_prev_buf = YY_CURRENT_BUFFER; 219 - incl_file->yy_prev_lineno = yylineno; 220 - incl_file->file = srcpos_file; 221 - incl_file->prev = incl_file_stack; 222 - 223 - incl_file_stack = incl_file; 224 - 225 - /* 226 - * Establish new context. 227 - */ 228 - srcpos_file = newfile; 229 - yylineno = 1; 230 - yyin = newfile->file; 231 - yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); 232 + yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE)); 232 233 } 233 234 234 235 235 236 static int pop_input_file(void) 236 237 { 237 - struct incl_file *incl_file; 238 - 239 - if (incl_file_stack == 0) 238 + if (srcfile_pop() == 0) 240 239 return 0; 241 240 242 - dtc_close_file(srcpos_file); 243 - 244 - /* 245 - * Pop. 246 - */ 247 - --incl_depth; 248 - incl_file = incl_file_stack; 249 - incl_file_stack = incl_file->prev; 250 - 251 - /* 252 - * Recover old context. 253 - */ 254 - yy_delete_buffer(YY_CURRENT_BUFFER); 255 - yy_switch_to_buffer(incl_file->yy_prev_buf); 256 - yylineno = incl_file->yy_prev_lineno; 257 - srcpos_file = incl_file->file; 258 - yyin = incl_file->file ? incl_file->file->file : NULL; 259 - 260 - /* 261 - * Free old state. 262 - */ 263 - free(incl_file); 241 + yypop_buffer_state(); 242 + yyin = current_srcfile->f; 264 243 265 244 return 1; 266 245 }
+169 -368
scripts/dtc/dtc-lexer.lex.c_shipped
··· 170 170 #define EOB_ACT_END_OF_FILE 1 171 171 #define EOB_ACT_LAST_MATCH 2 172 172 173 - /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires 174 - * access to the local variable yy_act. Since yyless() is a macro, it would break 175 - * existing scanners that call yyless() from OUTSIDE yylex. 176 - * One obvious solution it to make yy_act a global. I tried that, and saw 177 - * a 5% performance hit in a non-yylineno scanner, because yy_act is 178 - * normally declared as a register variable-- so it is not worth it. 179 - */ 180 - #define YY_LESS_LINENO(n) \ 181 - do { \ 182 - int yyl;\ 183 - for ( yyl = n; yyl < yyleng; ++yyl )\ 184 - if ( yytext[yyl] == '\n' )\ 185 - --yylineno;\ 186 - }while(0) 173 + #define YY_LESS_LINENO(n) 187 174 188 175 /* Return all but the first "n" matched characters back to the input stream. */ 189 176 #define yyless(n) \ ··· 372 385 *yy_cp = '\0'; \ 373 386 (yy_c_buf_p) = yy_cp; 374 387 375 - #define YY_NUM_RULES 20 376 - #define YY_END_OF_BUFFER 21 388 + #define YY_NUM_RULES 17 389 + #define YY_END_OF_BUFFER 18 377 390 /* This struct is not used in this scanner, 378 391 but its presence is necessary. */ 379 392 struct yy_trans_info ··· 381 394 flex_int32_t yy_verify; 382 395 flex_int32_t yy_nxt; 383 396 }; 384 - static yyconst flex_int16_t yy_accept[104] = 397 + static yyconst flex_int16_t yy_accept[94] = 385 398 { 0, 386 399 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 387 - 21, 19, 16, 16, 19, 19, 19, 7, 7, 19, 388 - 7, 19, 19, 19, 19, 13, 14, 14, 19, 8, 389 - 8, 16, 0, 2, 0, 0, 9, 0, 0, 0, 390 - 0, 0, 0, 7, 7, 5, 0, 6, 0, 12, 391 - 12, 14, 14, 8, 0, 11, 9, 0, 0, 0, 392 - 0, 18, 0, 0, 0, 0, 8, 0, 17, 0, 393 - 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 394 - 0, 0, 0, 0, 0, 0, 0, 0, 3, 15, 400 + 18, 16, 13, 13, 16, 16, 16, 16, 16, 16, 401 + 16, 10, 11, 11, 6, 6, 13, 0, 2, 0, 402 + 7, 0, 0, 0, 0, 0, 0, 0, 5, 0, 403 + 9, 9, 11, 11, 6, 0, 7, 0, 0, 0, 404 + 0, 15, 0, 0, 0, 0, 6, 0, 14, 0, 405 + 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 406 + 0, 0, 0, 0, 0, 0, 0, 0, 3, 12, 395 407 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 396 - 397 408 0, 4, 0 409 + 398 410 } ; 399 411 400 412 static yyconst flex_int32_t yy_ec[256] = ··· 402 416 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 403 417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 404 418 1, 2, 1, 4, 5, 1, 1, 6, 1, 1, 405 - 1, 7, 8, 8, 9, 8, 10, 11, 12, 13, 406 - 13, 13, 13, 13, 13, 13, 13, 14, 1, 1, 407 - 1, 1, 8, 8, 15, 15, 15, 15, 15, 15, 408 - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 409 - 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 410 - 1, 18, 19, 1, 16, 1, 15, 20, 21, 22, 419 + 1, 7, 5, 5, 8, 5, 9, 10, 11, 12, 420 + 12, 12, 12, 12, 12, 12, 12, 13, 1, 1, 421 + 1, 1, 5, 5, 14, 14, 14, 14, 14, 14, 422 + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 423 + 15, 15, 15, 15, 15, 15, 15, 16, 15, 15, 424 + 1, 17, 18, 1, 15, 1, 14, 19, 20, 21, 411 425 412 - 23, 15, 16, 24, 25, 16, 16, 26, 27, 28, 413 - 24, 16, 16, 29, 30, 31, 32, 33, 16, 17, 414 - 16, 16, 34, 1, 35, 1, 1, 1, 1, 1, 426 + 22, 14, 15, 15, 23, 15, 15, 24, 25, 26, 427 + 15, 15, 15, 27, 28, 29, 30, 31, 15, 16, 428 + 15, 15, 32, 1, 33, 1, 1, 1, 1, 1, 415 429 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 416 430 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 417 431 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ··· 428 442 1, 1, 1, 1, 1 429 443 } ; 430 444 431 - static yyconst flex_int32_t yy_meta[36] = 445 + static yyconst flex_int32_t yy_meta[34] = 432 446 { 0, 433 - 1, 1, 1, 1, 2, 1, 2, 2, 2, 3, 434 - 4, 4, 4, 5, 6, 7, 7, 1, 1, 6, 435 - 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 436 - 7, 7, 7, 8, 1 447 + 1, 1, 1, 1, 2, 1, 2, 2, 3, 4, 448 + 4, 4, 5, 6, 7, 7, 1, 1, 6, 6, 449 + 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 450 + 7, 8, 1 437 451 } ; 438 452 439 - static yyconst flex_int16_t yy_base[117] = 453 + static yyconst flex_int16_t yy_base[106] = 440 454 { 0, 441 - 0, 0, 30, 0, 44, 0, 67, 0, 97, 105, 442 - 302, 303, 35, 44, 40, 94, 112, 0, 129, 152, 443 - 296, 295, 159, 0, 176, 303, 0, 116, 95, 165, 444 - 49, 46, 102, 303, 296, 0, 0, 288, 290, 293, 445 - 264, 266, 270, 0, 0, 303, 0, 303, 264, 303, 446 - 0, 0, 195, 101, 0, 0, 0, 0, 284, 125, 447 - 277, 265, 225, 230, 216, 218, 0, 202, 224, 221, 448 - 217, 107, 196, 188, 303, 206, 179, 186, 178, 185, 449 - 183, 162, 161, 150, 169, 160, 145, 125, 303, 303, 450 - 137, 109, 190, 103, 203, 167, 108, 197, 303, 123, 455 + 0, 0, 237, 236, 25, 0, 47, 0, 30, 71, 456 + 244, 247, 82, 84, 84, 211, 95, 229, 218, 0, 457 + 111, 247, 0, 84, 83, 95, 106, 86, 247, 237, 458 + 0, 230, 231, 234, 207, 209, 212, 220, 247, 206, 459 + 247, 218, 0, 106, 116, 0, 0, 0, 223, 89, 460 + 226, 219, 199, 206, 200, 204, 0, 190, 213, 212, 461 + 202, 91, 178, 161, 247, 172, 144, 150, 140, 130, 462 + 140, 124, 128, 120, 138, 137, 123, 122, 247, 247, 463 + 134, 114, 132, 86, 135, 125, 90, 136, 247, 97, 464 + 29, 247, 247, 153, 156, 161, 165, 170, 176, 180, 451 465 452 - 29, 303, 303, 215, 221, 226, 229, 234, 240, 246, 453 - 250, 257, 265, 270, 275, 282 466 + 187, 195, 200, 205, 212 454 467 } ; 455 468 456 - static yyconst flex_int16_t yy_def[117] = 469 + static yyconst flex_int16_t yy_def[106] = 457 470 { 0, 458 - 103, 1, 1, 3, 3, 5, 103, 7, 3, 3, 459 - 103, 103, 103, 103, 104, 105, 103, 106, 103, 19, 460 - 19, 20, 103, 107, 20, 103, 108, 109, 105, 103, 461 - 103, 103, 104, 103, 104, 110, 111, 103, 112, 113, 462 - 103, 103, 103, 106, 19, 103, 20, 103, 103, 103, 463 - 20, 108, 109, 103, 114, 110, 111, 115, 112, 112, 464 - 113, 103, 103, 103, 103, 103, 114, 115, 103, 103, 465 - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 466 - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 467 - 103, 103, 103, 103, 103, 116, 103, 116, 103, 116, 471 + 93, 1, 1, 1, 1, 5, 93, 7, 1, 1, 472 + 93, 93, 93, 93, 94, 95, 93, 96, 17, 97, 473 + 96, 93, 98, 99, 93, 93, 93, 94, 93, 94, 474 + 100, 93, 101, 102, 93, 93, 93, 96, 93, 93, 475 + 93, 96, 98, 99, 93, 103, 100, 104, 101, 101, 476 + 102, 93, 93, 93, 93, 93, 103, 104, 93, 93, 477 + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 478 + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 479 + 93, 93, 93, 93, 93, 105, 93, 105, 93, 105, 480 + 93, 93, 0, 93, 93, 93, 93, 93, 93, 93, 468 481 469 - 103, 103, 0, 103, 103, 103, 103, 103, 103, 103, 470 - 103, 103, 103, 103, 103, 103 482 + 93, 93, 93, 93, 93 471 483 } ; 472 484 473 - static yyconst flex_int16_t yy_nxt[339] = 485 + static yyconst flex_int16_t yy_nxt[281] = 474 486 { 0, 475 - 12, 13, 14, 15, 12, 16, 12, 12, 12, 17, 476 - 18, 18, 18, 12, 19, 20, 20, 12, 12, 21, 477 - 19, 21, 19, 22, 20, 20, 20, 20, 20, 20, 478 - 20, 20, 20, 12, 12, 12, 32, 32, 102, 23, 479 - 12, 12, 12, 34, 20, 32, 32, 32, 32, 20, 480 - 20, 20, 20, 20, 24, 24, 24, 35, 25, 54, 481 - 54, 54, 26, 25, 25, 25, 25, 12, 13, 14, 482 - 15, 27, 12, 27, 27, 27, 23, 27, 27, 27, 483 - 12, 28, 28, 28, 12, 12, 28, 28, 28, 28, 484 - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 487 + 12, 13, 14, 15, 12, 16, 12, 12, 17, 12, 488 + 12, 12, 12, 18, 18, 18, 12, 12, 18, 18, 489 + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 490 + 18, 12, 12, 19, 20, 20, 20, 92, 21, 25, 491 + 26, 26, 22, 21, 21, 21, 21, 12, 13, 14, 492 + 15, 23, 16, 23, 23, 19, 23, 23, 23, 12, 493 + 24, 24, 24, 12, 12, 24, 24, 24, 24, 24, 494 + 24, 24, 24, 24, 24, 24, 24, 24, 12, 12, 495 + 25, 26, 26, 27, 27, 27, 27, 29, 43, 29, 496 + 43, 43, 45, 45, 45, 50, 39, 59, 46, 93, 485 497 486 - 12, 12, 29, 36, 103, 34, 17, 30, 31, 31, 487 - 29, 54, 54, 54, 17, 30, 31, 31, 39, 35, 488 - 52, 40, 52, 52, 52, 103, 78, 38, 38, 46, 489 - 101, 60, 79, 41, 69, 97, 42, 94, 43, 45, 490 - 45, 45, 46, 45, 47, 47, 93, 92, 45, 45, 491 - 45, 45, 47, 47, 47, 47, 47, 47, 47, 47, 492 - 47, 47, 47, 47, 47, 39, 47, 91, 40, 90, 493 - 99, 47, 47, 47, 47, 54, 54, 54, 89, 88, 494 - 41, 55, 87, 49, 100, 43, 51, 51, 51, 86, 495 - 51, 95, 95, 96, 85, 51, 51, 51, 51, 52, 498 + 30, 33, 30, 34, 45, 45, 45, 27, 27, 68, 499 + 43, 91, 43, 43, 69, 35, 87, 36, 39, 37, 500 + 42, 42, 42, 39, 42, 45, 45, 45, 89, 42, 501 + 42, 42, 42, 85, 85, 86, 85, 85, 86, 89, 502 + 84, 90, 83, 82, 81, 80, 79, 78, 77, 76, 503 + 75, 74, 90, 28, 28, 28, 28, 28, 28, 28, 504 + 28, 31, 31, 31, 38, 38, 38, 38, 41, 73, 505 + 41, 43, 72, 43, 71, 43, 43, 44, 33, 44, 506 + 44, 44, 44, 47, 69, 47, 47, 49, 49, 49, 507 + 49, 49, 49, 49, 49, 51, 51, 51, 51, 51, 496 508 497 - 99, 52, 52, 52, 95, 95, 96, 84, 46, 83, 498 - 82, 81, 39, 79, 100, 33, 33, 33, 33, 33, 499 - 33, 33, 33, 37, 80, 77, 37, 37, 37, 44, 500 - 40, 44, 50, 76, 50, 52, 75, 52, 74, 52, 501 - 52, 53, 73, 53, 53, 53, 53, 56, 56, 56, 502 - 72, 56, 56, 57, 71, 57, 57, 59, 59, 59, 503 - 59, 59, 59, 59, 59, 61, 61, 61, 61, 61, 504 - 61, 61, 61, 67, 70, 67, 68, 68, 68, 62, 505 - 68, 68, 98, 98, 98, 98, 98, 98, 98, 98, 506 - 60, 66, 65, 64, 63, 62, 60, 58, 103, 48, 507 - 508 - 48, 103, 11, 103, 103, 103, 103, 103, 103, 103, 509 - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 510 - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 511 - 103, 103, 103, 103, 103, 103, 103, 103 509 + 51, 51, 51, 57, 70, 57, 58, 58, 58, 67, 510 + 58, 58, 88, 88, 88, 88, 88, 88, 88, 88, 511 + 34, 66, 65, 64, 63, 62, 61, 60, 52, 50, 512 + 39, 56, 39, 55, 54, 53, 52, 50, 48, 93, 513 + 40, 39, 32, 93, 19, 19, 11, 93, 93, 93, 514 + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 515 + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 516 + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93 512 517 } ; 513 518 514 - static yyconst flex_int16_t yy_chk[339] = 519 + static yyconst flex_int16_t yy_chk[281] = 515 520 { 0, 516 521 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 517 522 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 518 523 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 519 - 1, 1, 1, 1, 1, 3, 13, 13, 101, 3, 520 - 3, 3, 3, 15, 3, 14, 14, 32, 32, 3, 521 - 3, 3, 3, 3, 5, 5, 5, 15, 5, 31, 522 - 31, 31, 5, 5, 5, 5, 5, 7, 7, 7, 524 + 1, 1, 1, 5, 5, 5, 5, 91, 5, 9, 525 + 9, 9, 5, 5, 5, 5, 5, 7, 7, 7, 523 526 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 524 527 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 525 528 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 529 + 10, 10, 10, 13, 13, 14, 14, 15, 24, 28, 530 + 24, 24, 25, 25, 25, 50, 24, 50, 25, 90, 526 531 527 - 7, 7, 9, 16, 29, 33, 9, 9, 9, 9, 528 - 10, 54, 54, 54, 10, 10, 10, 10, 17, 33, 529 - 28, 17, 28, 28, 28, 100, 72, 16, 29, 28, 530 - 97, 60, 72, 17, 60, 94, 17, 92, 17, 19, 531 - 19, 19, 19, 19, 19, 19, 91, 88, 19, 19, 532 - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 533 - 19, 19, 20, 20, 20, 23, 20, 87, 23, 86, 534 - 96, 20, 20, 20, 20, 30, 30, 30, 85, 84, 535 - 23, 30, 83, 23, 96, 23, 25, 25, 25, 82, 536 - 25, 93, 93, 93, 81, 25, 25, 25, 25, 53, 532 + 15, 17, 28, 17, 26, 26, 26, 27, 27, 62, 533 + 44, 87, 44, 44, 62, 17, 84, 17, 44, 17, 534 + 21, 21, 21, 21, 21, 45, 45, 45, 86, 21, 535 + 21, 21, 21, 83, 83, 83, 85, 85, 85, 88, 536 + 82, 86, 81, 78, 77, 76, 75, 74, 73, 72, 537 + 71, 70, 88, 94, 94, 94, 94, 94, 94, 94, 538 + 94, 95, 95, 95, 96, 96, 96, 96, 97, 69, 539 + 97, 98, 68, 98, 67, 98, 98, 99, 66, 99, 540 + 99, 99, 99, 100, 64, 100, 100, 101, 101, 101, 541 + 101, 101, 101, 101, 101, 102, 102, 102, 102, 102, 537 542 538 - 98, 53, 53, 53, 95, 95, 95, 80, 53, 79, 539 - 78, 77, 76, 74, 98, 104, 104, 104, 104, 104, 540 - 104, 104, 104, 105, 73, 71, 105, 105, 105, 106, 541 - 70, 106, 107, 69, 107, 108, 68, 108, 66, 108, 542 - 108, 109, 65, 109, 109, 109, 109, 110, 110, 110, 543 - 64, 110, 110, 111, 63, 111, 111, 112, 112, 112, 544 - 112, 112, 112, 112, 112, 113, 113, 113, 113, 113, 545 - 113, 113, 113, 114, 62, 114, 115, 115, 115, 61, 546 - 115, 115, 116, 116, 116, 116, 116, 116, 116, 116, 547 - 59, 49, 43, 42, 41, 40, 39, 38, 35, 22, 548 - 549 - 21, 11, 103, 103, 103, 103, 103, 103, 103, 103, 550 - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 551 - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 552 - 103, 103, 103, 103, 103, 103, 103, 103 543 + 102, 102, 102, 103, 63, 103, 104, 104, 104, 61, 544 + 104, 104, 105, 105, 105, 105, 105, 105, 105, 105, 545 + 60, 59, 58, 56, 55, 54, 53, 52, 51, 49, 546 + 42, 40, 38, 37, 36, 35, 34, 33, 32, 30, 547 + 19, 18, 16, 11, 4, 3, 93, 93, 93, 93, 548 + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 549 + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 550 + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93 553 551 } ; 554 - 555 - /* Table of booleans, true if rule could match eol. */ 556 - static yyconst flex_int32_t yy_rule_can_match_eol[21] = 557 - { 0, 558 - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 559 - 0, }; 560 552 561 553 static yy_state_type yy_last_accepting_state; 562 554 static char *yy_last_accepting_cpos; ··· 580 616 #include "srcpos.h" 581 617 #include "dtc-parser.tab.h" 582 618 619 + YYLTYPE yylloc; 620 + 621 + /* CAUTION: this will stop working if we ever use yyless() or yyunput() */ 622 + #define YY_USER_ACTION \ 623 + { \ 624 + srcpos_update(&yylloc, yytext, yyleng); \ 625 + } 583 626 584 627 /*#define LEXDEBUG 1*/ 585 628 ··· 596 625 #define DPRINT(fmt, ...) do { } while (0) 597 626 #endif 598 627 599 - static int dts_version; /* = 0 */ 628 + static int dts_version = 1; 600 629 601 - #define BEGIN_DEFAULT() if (dts_version == 0) { \ 602 - DPRINT("<INITIAL>\n"); \ 603 - BEGIN(INITIAL); \ 604 - } else { \ 605 - DPRINT("<V1>\n"); \ 630 + #define BEGIN_DEFAULT() DPRINT("<V1>\n"); \ 606 631 BEGIN(V1); \ 607 - } 608 632 609 633 static void push_input_file(const char *filename); 610 634 static int pop_input_file(void); 611 - #line 641 "dtc-lexer.lex.c" 635 + #line 607 "dtc-lexer.lex.c" 612 636 613 637 #define INITIAL 0 614 638 #define INCLUDE 1 ··· 792 826 register char *yy_cp, *yy_bp; 793 827 register int yy_act; 794 828 795 - #line 64 "dtc-lexer.l" 829 + #line 66 "dtc-lexer.l" 796 830 797 - #line 832 "dtc-lexer.lex.c" 831 + #line 798 "dtc-lexer.lex.c" 798 832 799 833 if ( !(yy_init) ) 800 834 { ··· 847 881 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 848 882 { 849 883 yy_current_state = (int) yy_def[yy_current_state]; 850 - if ( yy_current_state >= 104 ) 884 + if ( yy_current_state >= 94 ) 851 885 yy_c = yy_meta[(unsigned int) yy_c]; 852 886 } 853 887 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 854 888 ++yy_cp; 855 889 } 856 - while ( yy_base[yy_current_state] != 303 ); 890 + while ( yy_current_state != 93 ); 891 + yy_cp = (yy_last_accepting_cpos); 892 + yy_current_state = (yy_last_accepting_state); 857 893 858 894 yy_find_action: 859 895 yy_act = yy_accept[yy_current_state]; 860 - if ( yy_act == 0 ) 861 - { /* have to back up */ 862 - yy_cp = (yy_last_accepting_cpos); 863 - yy_current_state = (yy_last_accepting_state); 864 - yy_act = yy_accept[yy_current_state]; 865 - } 866 896 867 897 YY_DO_BEFORE_ACTION; 868 - 869 - if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) 870 - { 871 - int yyl; 872 - for ( yyl = 0; yyl < yyleng; ++yyl ) 873 - if ( yytext[yyl] == '\n' ) 874 - 875 - yylineno++; 876 - ; 877 - } 878 898 879 899 do_action: /* This label is used only to access EOF actions. */ 880 900 ··· 876 924 case 1: 877 925 /* rule 1 can match eol */ 878 926 YY_RULE_SETUP 879 - #line 65 "dtc-lexer.l" 927 + #line 67 "dtc-lexer.l" 880 928 { 881 929 char *name = strchr(yytext, '\"') + 1; 882 930 yytext[yyleng-1] = '\0'; ··· 888 936 case YY_STATE_EOF(BYTESTRING): 889 937 case YY_STATE_EOF(PROPNODENAME): 890 938 case YY_STATE_EOF(V1): 891 - #line 71 "dtc-lexer.l" 939 + #line 73 "dtc-lexer.l" 892 940 { 893 941 if (!pop_input_file()) { 894 942 yyterminate(); ··· 898 946 case 2: 899 947 /* rule 2 can match eol */ 900 948 YY_RULE_SETUP 901 - #line 77 "dtc-lexer.l" 949 + #line 79 "dtc-lexer.l" 902 950 { 903 - yylloc.file = srcpos_file; 904 - yylloc.first_line = yylineno; 905 951 DPRINT("String: %s\n", yytext); 906 952 yylval.data = data_copy_escape_string(yytext+1, 907 953 yyleng-2); 908 - yylloc.first_line = yylineno; 909 954 return DT_STRING; 910 955 } 911 956 YY_BREAK 912 957 case 3: 913 958 YY_RULE_SETUP 914 - #line 87 "dtc-lexer.l" 959 + #line 86 "dtc-lexer.l" 915 960 { 916 - yylloc.file = srcpos_file; 917 - yylloc.first_line = yylineno; 918 961 DPRINT("Keyword: /dts-v1/\n"); 919 962 dts_version = 1; 920 963 BEGIN_DEFAULT(); ··· 918 971 YY_BREAK 919 972 case 4: 920 973 YY_RULE_SETUP 921 - #line 96 "dtc-lexer.l" 974 + #line 93 "dtc-lexer.l" 922 975 { 923 - yylloc.file = srcpos_file; 924 - yylloc.first_line = yylineno; 925 976 DPRINT("Keyword: /memreserve/\n"); 926 977 BEGIN_DEFAULT(); 927 978 return DT_MEMRESERVE; ··· 927 982 YY_BREAK 928 983 case 5: 929 984 YY_RULE_SETUP 930 - #line 104 "dtc-lexer.l" 985 + #line 99 "dtc-lexer.l" 931 986 { 932 - yylloc.file = srcpos_file; 933 - yylloc.first_line = yylineno; 934 987 DPRINT("Label: %s\n", yytext); 935 - yylval.labelref = strdup(yytext); 988 + yylval.labelref = xstrdup(yytext); 936 989 yylval.labelref[yyleng-1] = '\0'; 937 990 return DT_LABEL; 938 991 } 939 992 YY_BREAK 940 993 case 6: 941 994 YY_RULE_SETUP 942 - #line 113 "dtc-lexer.l" 995 + #line 106 "dtc-lexer.l" 943 996 { 944 - yylloc.file = srcpos_file; 945 - yylloc.first_line = yylineno; 946 - if (*yytext == 'b') 947 - yylval.cbase = 2; 948 - else if (*yytext == 'o') 949 - yylval.cbase = 8; 950 - else if (*yytext == 'd') 951 - yylval.cbase = 10; 952 - else 953 - yylval.cbase = 16; 954 - DPRINT("Base: %d\n", yylval.cbase); 955 - return DT_BASE; 956 - } 957 - YY_BREAK 958 - case 7: 959 - YY_RULE_SETUP 960 - #line 128 "dtc-lexer.l" 961 - { 962 - yylloc.file = srcpos_file; 963 - yylloc.first_line = yylineno; 964 - yylval.literal = strdup(yytext); 965 - DPRINT("Literal: '%s'\n", yylval.literal); 966 - return DT_LEGACYLITERAL; 967 - } 968 - YY_BREAK 969 - case 8: 970 - YY_RULE_SETUP 971 - #line 136 "dtc-lexer.l" 972 - { 973 - yylloc.file = srcpos_file; 974 - yylloc.first_line = yylineno; 975 - yylval.literal = strdup(yytext); 997 + yylval.literal = xstrdup(yytext); 976 998 DPRINT("Literal: '%s'\n", yylval.literal); 977 999 return DT_LITERAL; 978 1000 } 979 1001 YY_BREAK 980 - case 9: 1002 + case 7: 981 1003 YY_RULE_SETUP 982 - #line 144 "dtc-lexer.l" 1004 + #line 112 "dtc-lexer.l" 983 1005 { /* label reference */ 984 - yylloc.file = srcpos_file; 985 - yylloc.first_line = yylineno; 986 1006 DPRINT("Ref: %s\n", yytext+1); 987 - yylval.labelref = strdup(yytext+1); 1007 + yylval.labelref = xstrdup(yytext+1); 988 1008 return DT_REF; 989 1009 } 990 1010 YY_BREAK 991 - case 10: 1011 + case 8: 992 1012 YY_RULE_SETUP 993 - #line 152 "dtc-lexer.l" 1013 + #line 118 "dtc-lexer.l" 994 1014 { /* new-style path reference */ 995 - yylloc.file = srcpos_file; 996 - yylloc.first_line = yylineno; 997 1015 yytext[yyleng-1] = '\0'; 998 1016 DPRINT("Ref: %s\n", yytext+2); 999 - yylval.labelref = strdup(yytext+2); 1017 + yylval.labelref = xstrdup(yytext+2); 1000 1018 return DT_REF; 1001 1019 } 1002 1020 YY_BREAK 1003 - case 11: 1021 + case 9: 1004 1022 YY_RULE_SETUP 1005 - #line 161 "dtc-lexer.l" 1006 - { /* old-style path reference */ 1007 - yylloc.file = srcpos_file; 1008 - yylloc.first_line = yylineno; 1009 - DPRINT("Ref: %s\n", yytext+1); 1010 - yylval.labelref = strdup(yytext+1); 1011 - return DT_REF; 1012 - } 1013 - YY_BREAK 1014 - case 12: 1015 - YY_RULE_SETUP 1016 - #line 169 "dtc-lexer.l" 1023 + #line 125 "dtc-lexer.l" 1017 1024 { 1018 - yylloc.file = srcpos_file; 1019 - yylloc.first_line = yylineno; 1020 1025 yylval.byte = strtol(yytext, NULL, 16); 1021 1026 DPRINT("Byte: %02x\n", (int)yylval.byte); 1022 1027 return DT_BYTE; 1023 1028 } 1024 1029 YY_BREAK 1025 - case 13: 1030 + case 10: 1026 1031 YY_RULE_SETUP 1027 - #line 177 "dtc-lexer.l" 1032 + #line 131 "dtc-lexer.l" 1028 1033 { 1029 - yylloc.file = srcpos_file; 1030 - yylloc.first_line = yylineno; 1031 1034 DPRINT("/BYTESTRING\n"); 1032 1035 BEGIN_DEFAULT(); 1033 1036 return ']'; 1034 1037 } 1035 1038 YY_BREAK 1036 - case 14: 1039 + case 11: 1037 1040 YY_RULE_SETUP 1038 - #line 185 "dtc-lexer.l" 1041 + #line 137 "dtc-lexer.l" 1039 1042 { 1040 - yylloc.file = srcpos_file; 1041 - yylloc.first_line = yylineno; 1042 1043 DPRINT("PropNodeName: %s\n", yytext); 1043 - yylval.propnodename = strdup(yytext); 1044 + yylval.propnodename = xstrdup(yytext); 1044 1045 BEGIN_DEFAULT(); 1045 1046 return DT_PROPNODENAME; 1046 1047 } 1047 1048 YY_BREAK 1048 - case 15: 1049 + case 12: 1049 1050 YY_RULE_SETUP 1050 - #line 194 "dtc-lexer.l" 1051 + #line 144 "dtc-lexer.l" 1051 1052 { 1052 - yylloc.file = srcpos_file; 1053 - yylloc.first_line = yylineno; 1054 1053 DPRINT("Binary Include\n"); 1055 1054 return DT_INCBIN; 1056 1055 } 1057 1056 YY_BREAK 1058 - case 16: 1059 - /* rule 16 can match eol */ 1057 + case 13: 1058 + /* rule 13 can match eol */ 1060 1059 YY_RULE_SETUP 1061 - #line 201 "dtc-lexer.l" 1060 + #line 149 "dtc-lexer.l" 1062 1061 /* eat whitespace */ 1063 1062 YY_BREAK 1064 - case 17: 1065 - /* rule 17 can match eol */ 1063 + case 14: 1064 + /* rule 14 can match eol */ 1066 1065 YY_RULE_SETUP 1067 - #line 202 "dtc-lexer.l" 1066 + #line 150 "dtc-lexer.l" 1068 1067 /* eat C-style comments */ 1069 1068 YY_BREAK 1070 - case 18: 1071 - /* rule 18 can match eol */ 1069 + case 15: 1070 + /* rule 15 can match eol */ 1072 1071 YY_RULE_SETUP 1073 - #line 203 "dtc-lexer.l" 1072 + #line 151 "dtc-lexer.l" 1074 1073 /* eat C++-style comments */ 1075 1074 YY_BREAK 1076 - case 19: 1075 + case 16: 1077 1076 YY_RULE_SETUP 1078 - #line 205 "dtc-lexer.l" 1077 + #line 153 "dtc-lexer.l" 1079 1078 { 1080 - yylloc.file = srcpos_file; 1081 - yylloc.first_line = yylineno; 1082 1079 DPRINT("Char: %c (\\x%02x)\n", yytext[0], 1083 1080 (unsigned)yytext[0]); 1084 1081 if (yytext[0] == '[') { ··· 1035 1148 return yytext[0]; 1036 1149 } 1037 1150 YY_BREAK 1038 - case 20: 1151 + case 17: 1039 1152 YY_RULE_SETUP 1040 - #line 222 "dtc-lexer.l" 1153 + #line 168 "dtc-lexer.l" 1041 1154 ECHO; 1042 1155 YY_BREAK 1043 - #line 1157 "dtc-lexer.lex.c" 1156 + #line 1044 "dtc-lexer.lex.c" 1044 1157 1045 1158 case YY_END_OF_BUFFER: 1046 1159 { ··· 1105 1218 1106 1219 else 1107 1220 { 1108 - yy_cp = (yy_c_buf_p); 1221 + yy_cp = (yy_last_accepting_cpos); 1222 + yy_current_state = (yy_last_accepting_state); 1109 1223 goto yy_find_action; 1110 1224 } 1111 1225 } ··· 1331 1443 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1332 1444 { 1333 1445 yy_current_state = (int) yy_def[yy_current_state]; 1334 - if ( yy_current_state >= 104 ) 1446 + if ( yy_current_state >= 94 ) 1335 1447 yy_c = yy_meta[(unsigned int) yy_c]; 1336 1448 } 1337 1449 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ··· 1359 1471 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1360 1472 { 1361 1473 yy_current_state = (int) yy_def[yy_current_state]; 1362 - if ( yy_current_state >= 104 ) 1474 + if ( yy_current_state >= 94 ) 1363 1475 yy_c = yy_meta[(unsigned int) yy_c]; 1364 1476 } 1365 1477 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1366 - yy_is_jam = (yy_current_state == 103); 1478 + yy_is_jam = (yy_current_state == 93); 1367 1479 1368 1480 return yy_is_jam ? 0 : yy_current_state; 1369 1481 } ··· 1437 1549 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ 1438 1550 *(yy_c_buf_p) = '\0'; /* preserve yytext */ 1439 1551 (yy_hold_char) = *++(yy_c_buf_p); 1440 - 1441 - if ( c == '\n' ) 1442 - 1443 - yylineno++; 1444 - ; 1445 1552 1446 1553 return c; 1447 1554 } ··· 1552 1669 yyfree((void *) b ); 1553 1670 } 1554 1671 1555 - #ifndef __cplusplus 1556 - extern int isatty (int ); 1557 - #endif /* __cplusplus */ 1558 - 1559 1672 /* Initializes or reinitializes a buffer. 1560 1673 * This function is sometimes called more than once on the same buffer, 1561 1674 * such as during a yyrestart() or at EOF. ··· 1575 1696 b->yy_bs_column = 0; 1576 1697 } 1577 1698 1578 - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; 1699 + b->yy_is_interactive = 0; 1579 1700 1580 1701 errno = oerrno; 1581 1702 } ··· 1904 2025 * This function is called from yylex_destroy(), so don't allocate here. 1905 2026 */ 1906 2027 1907 - /* We do not touch yylineno unless the option is enabled. */ 1908 - yylineno = 1; 1909 - 1910 2028 (yy_buffer_stack) = 0; 1911 2029 (yy_buffer_stack_top) = 0; 1912 2030 (yy_buffer_stack_max) = 0; ··· 1996 2120 1997 2121 #define YYTABLES_NAME "yytables" 1998 2122 1999 - #line 222 "dtc-lexer.l" 2123 + #line 168 "dtc-lexer.l" 2000 2124 2001 - 2002 - 2003 - 2004 - /* 2005 - * Stack of nested include file contexts. 2006 - */ 2007 - 2008 - struct incl_file { 2009 - struct dtc_file *file; 2010 - YY_BUFFER_STATE yy_prev_buf; 2011 - int yy_prev_lineno; 2012 - struct incl_file *prev; 2013 - }; 2014 - 2015 - static struct incl_file *incl_file_stack; 2016 - 2017 - 2018 - /* 2019 - * Detect infinite include recursion. 2020 - */ 2021 - #define MAX_INCLUDE_DEPTH (100) 2022 - 2023 - static int incl_depth = 0; 2024 2125 2025 2126 2026 2127 static void push_input_file(const char *filename) 2027 2128 { 2028 - struct incl_file *incl_file; 2029 - struct dtc_file *newfile; 2030 - struct search_path search, *searchptr = NULL; 2031 - 2032 2129 assert(filename); 2033 2130 2034 - if (incl_depth++ >= MAX_INCLUDE_DEPTH) 2035 - die("Includes nested too deeply"); 2131 + srcfile_push(filename); 2036 2132 2037 - if (srcpos_file) { 2038 - search.dir = srcpos_file->dir; 2039 - search.next = NULL; 2040 - search.prev = NULL; 2041 - searchptr = &search; 2042 - } 2133 + yyin = current_srcfile->f; 2043 2134 2044 - newfile = dtc_open_file(filename, searchptr); 2045 - 2046 - incl_file = xmalloc(sizeof(struct incl_file)); 2047 - 2048 - /* 2049 - * Save current context. 2050 - */ 2051 - incl_file->yy_prev_buf = YY_CURRENT_BUFFER; 2052 - incl_file->yy_prev_lineno = yylineno; 2053 - incl_file->file = srcpos_file; 2054 - incl_file->prev = incl_file_stack; 2055 - 2056 - incl_file_stack = incl_file; 2057 - 2058 - /* 2059 - * Establish new context. 2060 - */ 2061 - srcpos_file = newfile; 2062 - yylineno = 1; 2063 - yyin = newfile->file; 2064 - yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); 2135 + yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE)); 2065 2136 } 2066 2137 2067 2138 2068 2139 static int pop_input_file(void) 2069 2140 { 2070 - struct incl_file *incl_file; 2071 - 2072 - if (incl_file_stack == 0) 2141 + if (srcfile_pop() == 0) 2073 2142 return 0; 2074 2143 2075 - dtc_close_file(srcpos_file); 2076 - 2077 - /* 2078 - * Pop. 2079 - */ 2080 - --incl_depth; 2081 - incl_file = incl_file_stack; 2082 - incl_file_stack = incl_file->prev; 2083 - 2084 - /* 2085 - * Recover old context. 2086 - */ 2087 - yy_delete_buffer(YY_CURRENT_BUFFER); 2088 - yy_switch_to_buffer(incl_file->yy_prev_buf); 2089 - yylineno = incl_file->yy_prev_lineno; 2090 - srcpos_file = incl_file->file; 2091 - yyin = incl_file->file ? incl_file->file->file : NULL; 2092 - 2093 - /* 2094 - * Free old state. 2095 - */ 2096 - free(incl_file); 2144 + yypop_buffer_state(); 2145 + yyin = current_srcfile->f; 2097 2146 2098 2147 return 1; 2099 2148 }
+473 -485
scripts/dtc/dtc-parser.tab.c_shipped
··· 1 - /* A Bison parser, made by GNU Bison 2.3. */ 1 + 2 + /* A Bison parser, made by GNU Bison 2.4.1. */ 2 3 3 4 /* Skeleton implementation for Bison's Yacc-like parsers in C 4 - 5 - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 5 + 6 + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 6 7 Free Software Foundation, Inc. 7 - 8 - This program is free software; you can redistribute it and/or modify 8 + 9 + This program is free software: you can redistribute it and/or modify 9 10 it under the terms of the GNU General Public License as published by 10 - the Free Software Foundation; either version 2, or (at your option) 11 - any later version. 12 - 11 + the Free Software Foundation, either version 3 of the License, or 12 + (at your option) any later version. 13 + 13 14 This program is distributed in the hope that it will be useful, 14 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 17 GNU General Public License for more details. 17 - 18 + 18 19 You should have received a copy of the GNU General Public License 19 - along with this program; if not, write to the Free Software 20 - Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 - Boston, MA 02110-1301, USA. */ 20 + along with this program. If not, see <http://www.gnu.org/licenses/>. */ 22 21 23 22 /* As a special exception, you may create a larger work that contains 24 23 part or all of the Bison parser skeleton and distribute that work ··· 28 29 special exception, which will cause the skeleton and the resulting 29 30 Bison output files to be licensed under the GNU General Public 30 31 License without this special exception. 31 - 32 + 32 33 This special exception was added by the Free Software Foundation in 33 34 version 2.2 of Bison. */ 34 35 ··· 46 47 #define YYBISON 1 47 48 48 49 /* Bison version. */ 49 - #define YYBISON_VERSION "2.3" 50 + #define YYBISON_VERSION "2.4.1" 50 51 51 52 /* Skeleton name. */ 52 53 #define YYSKELETON_NAME "yacc.c" ··· 54 55 /* Pure parsers. */ 55 56 #define YYPURE 0 56 57 58 + /* Push parsers. */ 59 + #define YYPUSH 0 60 + 61 + /* Pull parsers. */ 62 + #define YYPULL 1 63 + 57 64 /* Using locations. */ 58 - #define YYLSP_NEEDED 1 59 - 60 - 61 - 62 - /* Tokens. */ 63 - #ifndef YYTOKENTYPE 64 - # define YYTOKENTYPE 65 - /* Put the tokens into the symbol table, so that GDB and other debuggers 66 - know about them. */ 67 - enum yytokentype { 68 - DT_V1 = 258, 69 - DT_MEMRESERVE = 259, 70 - DT_PROPNODENAME = 260, 71 - DT_LITERAL = 261, 72 - DT_LEGACYLITERAL = 262, 73 - DT_BASE = 263, 74 - DT_BYTE = 264, 75 - DT_STRING = 265, 76 - DT_LABEL = 266, 77 - DT_REF = 267, 78 - DT_INCBIN = 268 79 - }; 80 - #endif 81 - /* Tokens. */ 82 - #define DT_V1 258 83 - #define DT_MEMRESERVE 259 84 - #define DT_PROPNODENAME 260 85 - #define DT_LITERAL 261 86 - #define DT_LEGACYLITERAL 262 87 - #define DT_BASE 263 88 - #define DT_BYTE 264 89 - #define DT_STRING 265 90 - #define DT_LABEL 266 91 - #define DT_REF 267 92 - #define DT_INCBIN 268 93 - 65 + #define YYLSP_NEEDED 0 94 66 95 67 96 68 97 69 /* Copy the first part of user declarations. */ 98 - #line 23 "dtc-parser.y" 70 + 71 + /* Line 189 of yacc.c */ 72 + #line 21 "dtc-parser.y" 99 73 100 74 #include <stdio.h> 101 75 102 76 #include "dtc.h" 103 77 #include "srcpos.h" 104 78 79 + YYLTYPE yylloc; 80 + 105 81 extern int yylex(void); 82 + extern void print_error(char const *fmt, ...); 83 + extern void yyerror(char const *s); 106 84 107 85 extern struct boot_info *the_boot_info; 108 86 extern int treesource_error; 109 87 110 88 static unsigned long long eval_literal(const char *s, int base, int bits); 111 89 90 + 91 + /* Line 189 of yacc.c */ 92 + #line 92 "dtc-parser.tab.c" 112 93 113 94 /* Enabling traces. */ 114 95 #ifndef YYDEBUG ··· 108 129 # define YYTOKEN_TABLE 0 109 130 #endif 110 131 132 + 133 + /* Tokens. */ 134 + #ifndef YYTOKENTYPE 135 + # define YYTOKENTYPE 136 + /* Put the tokens into the symbol table, so that GDB and other debuggers 137 + know about them. */ 138 + enum yytokentype { 139 + DT_V1 = 258, 140 + DT_MEMRESERVE = 259, 141 + DT_PROPNODENAME = 260, 142 + DT_LITERAL = 261, 143 + DT_BASE = 262, 144 + DT_BYTE = 263, 145 + DT_STRING = 264, 146 + DT_LABEL = 265, 147 + DT_REF = 266, 148 + DT_INCBIN = 267 149 + }; 150 + #endif 151 + 152 + 153 + 111 154 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 112 155 typedef union YYSTYPE 113 - #line 37 "dtc-parser.y" 114 156 { 157 + 158 + /* Line 214 of yacc.c */ 159 + #line 39 "dtc-parser.y" 160 + 115 161 char *propnodename; 116 162 char *literal; 117 163 char *labelref; ··· 151 147 struct node *node; 152 148 struct node *nodelist; 153 149 struct reserve_info *re; 154 - } 155 - /* Line 187 of yacc.c. */ 156 - #line 153 "dtc-parser.tab.c" 157 - YYSTYPE; 150 + 151 + 152 + 153 + /* Line 214 of yacc.c */ 154 + #line 159 "dtc-parser.tab.c" 155 + } YYSTYPE; 156 + # define YYSTYPE_IS_TRIVIAL 1 158 157 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ 159 158 # define YYSTYPE_IS_DECLARED 1 160 - # define YYSTYPE_IS_TRIVIAL 1 161 - #endif 162 - 163 - #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED 164 - typedef struct YYLTYPE 165 - { 166 - int first_line; 167 - int first_column; 168 - int last_line; 169 - int last_column; 170 - } YYLTYPE; 171 - # define yyltype YYLTYPE /* obsolescent; will be withdrawn */ 172 - # define YYLTYPE_IS_DECLARED 1 173 - # define YYLTYPE_IS_TRIVIAL 1 174 159 #endif 175 160 176 161 177 162 /* Copy the second part of user declarations. */ 178 163 179 164 180 - /* Line 216 of yacc.c. */ 181 - #line 178 "dtc-parser.tab.c" 165 + /* Line 264 of yacc.c */ 166 + #line 171 "dtc-parser.tab.c" 182 167 183 168 #ifdef short 184 169 # undef short ··· 242 249 #if (defined __STDC__ || defined __C99__FUNC__ \ 243 250 || defined __cplusplus || defined _MSC_VER) 244 251 static int 245 - YYID (int i) 252 + YYID (int yyi) 246 253 #else 247 254 static int 248 - YYID (i) 249 - int i; 255 + YYID (yyi) 256 + int yyi; 250 257 #endif 251 258 { 252 - return i; 259 + return yyi; 253 260 } 254 261 #endif 255 262 ··· 325 332 326 333 #if (! defined yyoverflow \ 327 334 && (! defined __cplusplus \ 328 - || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ 329 - && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) 335 + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) 330 336 331 337 /* A type that is properly aligned for any stack member. */ 332 338 union yyalloc 333 339 { 334 - yytype_int16 yyss; 335 - YYSTYPE yyvs; 336 - YYLTYPE yyls; 340 + yytype_int16 yyss_alloc; 341 + YYSTYPE yyvs_alloc; 337 342 }; 338 343 339 344 /* The size of the maximum gap between one aligned stack and the next. */ ··· 340 349 /* The size of an array large to enough to hold all stacks, each with 341 350 N elements. */ 342 351 # define YYSTACK_BYTES(N) \ 343 - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ 344 - + 2 * YYSTACK_GAP_MAXIMUM) 352 + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ 353 + + YYSTACK_GAP_MAXIMUM) 345 354 346 355 /* Copy COUNT objects from FROM to TO. The source and destination do 347 356 not overlap. */ ··· 366 375 elements in the stack, and YYPTR gives the new location of the 367 376 stack. Advance YYPTR to a properly aligned location for the next 368 377 stack. */ 369 - # define YYSTACK_RELOCATE(Stack) \ 378 + # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ 370 379 do \ 371 380 { \ 372 381 YYSIZE_T yynewbytes; \ 373 - YYCOPY (&yyptr->Stack, Stack, yysize); \ 374 - Stack = &yyptr->Stack; \ 382 + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ 383 + Stack = &yyptr->Stack_alloc; \ 375 384 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ 376 385 yyptr += yynewbytes / sizeof (*yyptr); \ 377 386 } \ ··· 380 389 #endif 381 390 382 391 /* YYFINAL -- State number of the termination state. */ 383 - #define YYFINAL 9 392 + #define YYFINAL 4 384 393 /* YYLAST -- Last index in YYTABLE. */ 385 - #define YYLAST 73 394 + #define YYLAST 56 386 395 387 396 /* YYNTOKENS -- Number of terminals. */ 388 - #define YYNTOKENS 27 397 + #define YYNTOKENS 25 389 398 /* YYNNTS -- Number of nonterminals. */ 390 - #define YYNNTS 20 399 + #define YYNNTS 16 391 400 /* YYNRULES -- Number of rules. */ 392 - #define YYNRULES 45 401 + #define YYNRULES 39 393 402 /* YYNRULES -- Number of states. */ 394 - #define YYNSTATES 76 403 + #define YYNSTATES 67 395 404 396 405 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 397 406 #define YYUNDEFTOK 2 398 - #define YYMAXUTOK 268 407 + #define YYMAXUTOK 267 399 408 400 409 #define YYTRANSLATE(YYX) \ 401 410 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) ··· 407 416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 408 417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 409 418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 410 - 24, 26, 2, 2, 25, 15, 2, 16, 2, 2, 411 - 2, 2, 2, 2, 2, 2, 2, 2, 2, 14, 412 - 20, 19, 21, 2, 2, 2, 2, 2, 2, 2, 419 + 22, 24, 2, 2, 23, 2, 2, 14, 2, 2, 420 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 13, 421 + 18, 17, 19, 2, 2, 2, 2, 2, 2, 2, 413 422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 414 423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 415 - 2, 22, 2, 23, 2, 2, 2, 2, 2, 2, 424 + 2, 20, 2, 21, 2, 2, 2, 2, 2, 2, 416 425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 417 426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 418 - 2, 2, 2, 17, 2, 18, 2, 2, 2, 2, 427 + 2, 2, 2, 15, 2, 16, 2, 2, 2, 2, 419 428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 420 429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 421 430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ··· 429 438 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 430 439 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 431 440 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 432 - 5, 6, 7, 8, 9, 10, 11, 12, 13 441 + 5, 6, 7, 8, 9, 10, 11, 12 433 442 }; 434 443 435 444 #if YYDEBUG ··· 437 446 YYRHS. */ 438 447 static const yytype_uint8 yyprhs[] = 439 448 { 440 - 0, 0, 3, 8, 11, 12, 15, 21, 22, 25, 441 - 27, 34, 36, 38, 41, 47, 48, 51, 57, 61, 442 - 64, 69, 74, 77, 87, 93, 96, 97, 100, 103, 443 - 104, 107, 110, 113, 114, 116, 118, 121, 122, 125, 444 - 128, 129, 132, 135, 139, 140 449 + 0, 0, 3, 8, 9, 12, 17, 20, 22, 25, 450 + 29, 33, 39, 40, 43, 48, 51, 54, 57, 62, 451 + 67, 70, 80, 86, 89, 90, 93, 96, 97, 100, 452 + 103, 106, 108, 109, 112, 115, 116, 119, 122, 125 445 453 }; 446 454 447 455 /* YYRHS -- A `-1'-separated list of the rules' RHS. */ 448 456 static const yytype_int8 yyrhs[] = 449 457 { 450 - 28, 0, -1, 3, 14, 29, 34, -1, 31, 34, 451 - -1, -1, 30, 29, -1, 46, 4, 33, 33, 14, 452 - -1, -1, 32, 31, -1, 30, -1, 46, 4, 33, 453 - 15, 33, 14, -1, 6, -1, 7, -1, 16, 35, 454 - -1, 17, 36, 44, 18, 14, -1, -1, 36, 37, 455 - -1, 46, 5, 19, 38, 14, -1, 46, 5, 14, 456 - -1, 39, 10, -1, 39, 20, 40, 21, -1, 39, 457 - 22, 43, 23, -1, 39, 12, -1, 39, 13, 24, 458 - 10, 25, 33, 25, 33, 26, -1, 39, 13, 24, 459 - 10, 26, -1, 38, 11, -1, -1, 38, 25, -1, 460 - 39, 11, -1, -1, 40, 42, -1, 40, 12, -1, 461 - 40, 11, -1, -1, 8, -1, 6, -1, 41, 7, 462 - -1, -1, 43, 9, -1, 43, 11, -1, -1, 45, 463 - 44, -1, 45, 37, -1, 46, 5, 35, -1, -1, 464 - 11, -1 458 + 26, 0, -1, 3, 13, 27, 30, -1, -1, 28, 459 + 27, -1, 4, 29, 29, 13, -1, 10, 28, -1, 460 + 6, -1, 14, 31, -1, 30, 14, 31, -1, 30, 461 + 11, 31, -1, 15, 32, 39, 16, 13, -1, -1, 462 + 32, 33, -1, 5, 17, 34, 13, -1, 5, 13, 463 + -1, 10, 33, -1, 35, 9, -1, 35, 18, 36, 464 + 19, -1, 35, 20, 38, 21, -1, 35, 11, -1, 465 + 35, 12, 22, 9, 23, 29, 23, 29, 24, -1, 466 + 35, 12, 22, 9, 24, -1, 34, 10, -1, -1, 467 + 34, 23, -1, 35, 10, -1, -1, 36, 37, -1, 468 + 36, 11, -1, 36, 10, -1, 6, -1, -1, 38, 469 + 8, -1, 38, 10, -1, -1, 40, 39, -1, 40, 470 + 33, -1, 5, 31, -1, 10, 40, -1 465 471 }; 466 472 467 473 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 468 474 static const yytype_uint16 yyrline[] = 469 475 { 470 - 0, 89, 89, 93, 101, 104, 111, 119, 122, 129, 471 - 133, 140, 144, 151, 158, 166, 169, 176, 180, 187, 472 - 191, 195, 199, 203, 220, 231, 239, 242, 246, 254, 473 - 257, 261, 266, 274, 277, 281, 285, 293, 296, 300, 474 - 308, 311, 315, 323, 331, 334 476 + 0, 86, 86, 95, 98, 105, 109, 117, 124, 128, 477 + 132, 145, 153, 156, 163, 167, 171, 179, 183, 187, 478 + 191, 195, 212, 222, 230, 233, 237, 245, 248, 252, 479 + 257, 264, 272, 275, 279, 287, 290, 294, 302, 306 475 480 }; 476 481 #endif 477 482 ··· 477 490 static const char *const yytname[] = 478 491 { 479 492 "$end", "error", "$undefined", "DT_V1", "DT_MEMRESERVE", 480 - "DT_PROPNODENAME", "DT_LITERAL", "DT_LEGACYLITERAL", "DT_BASE", 481 - "DT_BYTE", "DT_STRING", "DT_LABEL", "DT_REF", "DT_INCBIN", "';'", "'-'", 482 - "'/'", "'{'", "'}'", "'='", "'<'", "'>'", "'['", "']'", "'('", "','", 483 - "')'", "$accept", "sourcefile", "memreserves", "memreserve", 484 - "v0_memreserves", "v0_memreserve", "addr", "devicetree", "nodedef", 485 - "proplist", "propdef", "propdata", "propdataprefix", "celllist", 486 - "cellbase", "cellval", "bytestring", "subnodes", "subnode", "label", 0 493 + "DT_PROPNODENAME", "DT_LITERAL", "DT_BASE", "DT_BYTE", "DT_STRING", 494 + "DT_LABEL", "DT_REF", "DT_INCBIN", "';'", "'/'", "'{'", "'}'", "'='", 495 + "'<'", "'>'", "'['", "']'", "'('", "','", "')'", "$accept", "sourcefile", 496 + "memreserves", "memreserve", "addr", "devicetree", "nodedef", "proplist", 497 + "propdef", "propdata", "propdataprefix", "celllist", "cellval", 498 + "bytestring", "subnodes", "subnode", 0 487 499 }; 488 500 #endif 489 501 ··· 492 506 static const yytype_uint16 yytoknum[] = 493 507 { 494 508 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 495 - 265, 266, 267, 268, 59, 45, 47, 123, 125, 61, 496 - 60, 62, 91, 93, 40, 44, 41 509 + 265, 266, 267, 59, 47, 123, 125, 61, 60, 62, 510 + 91, 93, 40, 44, 41 497 511 }; 498 512 # endif 499 513 500 514 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 501 515 static const yytype_uint8 yyr1[] = 502 516 { 503 - 0, 27, 28, 28, 29, 29, 30, 31, 31, 32, 504 - 32, 33, 33, 34, 35, 36, 36, 37, 37, 38, 505 - 38, 38, 38, 38, 38, 38, 39, 39, 39, 40, 506 - 40, 40, 40, 41, 41, 42, 42, 43, 43, 43, 507 - 44, 44, 44, 45, 46, 46 517 + 0, 25, 26, 27, 27, 28, 28, 29, 30, 30, 518 + 30, 31, 32, 32, 33, 33, 33, 34, 34, 34, 519 + 34, 34, 34, 34, 35, 35, 35, 36, 36, 36, 520 + 36, 37, 38, 38, 38, 39, 39, 39, 40, 40 508 521 }; 509 522 510 523 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 511 524 static const yytype_uint8 yyr2[] = 512 525 { 513 - 0, 2, 4, 2, 0, 2, 5, 0, 2, 1, 514 - 6, 1, 1, 2, 5, 0, 2, 5, 3, 2, 515 - 4, 4, 2, 9, 5, 2, 0, 2, 2, 0, 516 - 2, 2, 2, 0, 1, 1, 2, 0, 2, 2, 517 - 0, 2, 2, 3, 0, 1 526 + 0, 2, 4, 0, 2, 4, 2, 1, 2, 3, 527 + 3, 5, 0, 2, 4, 2, 2, 2, 4, 4, 528 + 2, 9, 5, 2, 0, 2, 2, 0, 2, 2, 529 + 2, 1, 0, 2, 2, 0, 2, 2, 2, 2 518 530 }; 519 531 520 532 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state ··· 520 536 means the default is an error. */ 521 537 static const yytype_uint8 yydefact[] = 522 538 { 523 - 7, 0, 45, 0, 9, 0, 7, 0, 4, 1, 524 - 0, 3, 8, 0, 0, 4, 0, 15, 13, 11, 525 - 12, 0, 2, 5, 0, 40, 0, 0, 0, 16, 526 - 0, 40, 0, 0, 6, 0, 42, 41, 0, 10, 527 - 14, 18, 26, 43, 0, 0, 25, 17, 27, 19, 528 - 28, 22, 0, 29, 37, 0, 33, 0, 0, 35, 529 - 34, 32, 31, 20, 0, 30, 38, 39, 21, 0, 530 - 24, 36, 0, 0, 0, 23 539 + 0, 0, 0, 3, 1, 0, 0, 0, 3, 7, 540 + 0, 6, 0, 2, 4, 0, 12, 8, 0, 0, 541 + 5, 35, 10, 9, 0, 0, 13, 0, 35, 15, 542 + 24, 38, 16, 39, 0, 37, 36, 0, 0, 11, 543 + 23, 14, 25, 17, 26, 20, 0, 27, 32, 0, 544 + 0, 0, 0, 31, 30, 29, 18, 28, 33, 34, 545 + 19, 0, 22, 0, 0, 0, 21 531 546 }; 532 547 533 548 /* YYDEFGOTO[NTERM-NUM]. */ 534 549 static const yytype_int8 yydefgoto[] = 535 550 { 536 - -1, 3, 14, 4, 5, 6, 27, 11, 18, 25, 537 - 29, 44, 45, 56, 64, 65, 57, 30, 31, 7 551 + -1, 2, 7, 8, 10, 13, 17, 21, 26, 37, 552 + 38, 50, 57, 51, 27, 28 538 553 }; 539 554 540 555 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 541 556 STATE-NUM. */ 542 - #define YYPACT_NINF -14 557 + #define YYPACT_NINF -12 543 558 static const yytype_int8 yypact[] = 544 559 { 545 - 30, -11, -14, 7, -14, -1, 27, 13, 27, -14, 546 - 8, -14, -14, 40, -1, 27, 35, -14, -14, -14, 547 - -14, 21, -14, -14, 40, 24, 40, 28, 40, -14, 548 - 32, 24, 46, 38, -14, 39, -14, -14, 26, -14, 549 - -14, -14, -14, -14, -9, 10, -14, -14, -14, -14, 550 - -14, -14, 31, -14, -14, 44, -2, 3, 23, -14, 551 - -14, -14, -14, -14, 50, -14, -14, -14, -14, 40, 552 - -14, -14, 33, 40, 36, -14 560 + 10, -11, 18, -1, -12, 22, -1, 15, -1, -12, 561 + 22, -12, 20, 1, -12, 17, -12, -12, 20, 20, 562 + -12, 6, -12, -12, 21, 6, -12, 23, 6, -12, 563 + -12, -12, -12, -12, 28, -12, -12, -6, 13, -12, 564 + -12, -12, -12, -12, -12, -12, 24, -12, -12, 33, 565 + -5, 0, -4, -12, -12, -12, -12, -12, -12, -12, 566 + -12, 22, -12, 25, 22, 19, -12 553 567 }; 554 568 555 569 /* YYPGOTO[NTERM-NUM]. */ 556 570 static const yytype_int8 yypgoto[] = 557 571 { 558 - -14, -14, 48, 29, 53, -14, -13, 47, 34, -14, 559 - 37, -14, -14, -14, -14, -14, -14, 42, -14, -7 572 + -12, -12, 36, 39, -10, -12, 8, -12, 12, -12, 573 + -12, -12, -12, -12, 27, 31 560 574 }; 561 575 562 576 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 563 577 positive, shift that token. If negative, reduce the rule which 564 578 number is the opposite. If zero, do what YYDEFACT says. 565 579 If YYTABLE_NINF, syntax error. */ 566 - #define YYTABLE_NINF -45 567 - static const yytype_int8 yytable[] = 580 + #define YYTABLE_NINF -1 581 + static const yytype_uint8 yytable[] = 568 582 { 569 - 21, 16, 46, 8, 59, 47, 60, 9, 16, 61, 570 - 62, 28, 66, 33, 67, 10, 48, 13, 32, 63, 571 - 49, 50, 51, 52, 32, 17, 68, 19, 20, -44, 572 - 53, -44, 54, 1, -44, 2, 26, 15, 2, 24, 573 - 41, 2, 34, 17, 15, 42, 19, 20, 69, 70, 574 - 35, 38, 39, 40, 58, 55, 72, 71, 73, 12, 575 - 74, 22, 75, 23, 0, 0, 0, 0, 36, 0, 576 - 0, 0, 43, 37 583 + 15, 53, 3, 5, 40, 54, 55, 41, 58, 6, 584 + 59, 24, 18, 1, 56, 19, 25, 42, 4, 61, 585 + 62, 60, 43, 44, 45, 46, 22, 23, 9, 12, 586 + 20, 47, 31, 48, 29, 16, 16, 32, 30, 34, 587 + 35, 39, 52, 66, 14, 11, 49, 0, 64, 0, 588 + 0, 63, 0, 0, 65, 36, 33 577 589 }; 578 590 579 591 static const yytype_int8 yycheck[] = 580 592 { 581 - 13, 8, 11, 14, 6, 14, 8, 0, 15, 11, 582 - 12, 24, 9, 26, 11, 16, 25, 4, 25, 21, 583 - 10, 11, 12, 13, 31, 17, 23, 6, 7, 5, 584 - 20, 4, 22, 3, 4, 11, 15, 8, 11, 4, 585 - 14, 11, 14, 17, 15, 19, 6, 7, 25, 26, 586 - 18, 5, 14, 14, 10, 24, 69, 7, 25, 6, 587 - 73, 14, 26, 15, -1, -1, -1, -1, 31, -1, 588 - -1, -1, 38, 31 593 + 10, 6, 13, 4, 10, 10, 11, 13, 8, 10, 594 + 10, 5, 11, 3, 19, 14, 10, 23, 0, 23, 595 + 24, 21, 9, 10, 11, 12, 18, 19, 6, 14, 596 + 13, 18, 24, 20, 13, 15, 15, 25, 17, 16, 597 + 28, 13, 9, 24, 8, 6, 22, -1, 23, -1, 598 + -1, 61, -1, -1, 64, 28, 25 589 599 }; 590 600 591 601 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 592 602 symbol of state STATE-NUM. */ 593 603 static const yytype_uint8 yystos[] = 594 604 { 595 - 0, 3, 11, 28, 30, 31, 32, 46, 14, 0, 596 - 16, 34, 31, 4, 29, 30, 46, 17, 35, 6, 597 - 7, 33, 34, 29, 4, 36, 15, 33, 33, 37, 598 - 44, 45, 46, 33, 14, 18, 37, 44, 5, 14, 599 - 14, 14, 19, 35, 38, 39, 11, 14, 25, 10, 600 - 11, 12, 13, 20, 22, 24, 40, 43, 10, 6, 601 - 8, 11, 12, 21, 41, 42, 9, 11, 23, 25, 602 - 26, 7, 33, 25, 33, 26 605 + 0, 3, 26, 13, 0, 4, 10, 27, 28, 6, 606 + 29, 28, 14, 30, 27, 29, 15, 31, 11, 14, 607 + 13, 32, 31, 31, 5, 10, 33, 39, 40, 13, 608 + 17, 31, 33, 40, 16, 33, 39, 34, 35, 13, 609 + 10, 13, 23, 9, 10, 11, 12, 18, 20, 22, 610 + 36, 38, 9, 6, 10, 11, 19, 37, 8, 10, 611 + 21, 23, 24, 29, 23, 29, 24 603 612 }; 604 613 605 614 #define yyerrok (yyerrstatus = 0) ··· 705 728 { \ 706 729 YYFPRINTF (stderr, "%s ", Title); \ 707 730 yy_symbol_print (stderr, \ 708 - Type, Value, Location); \ 731 + Type, Value); \ 709 732 YYFPRINTF (stderr, "\n"); \ 710 733 } \ 711 734 } while (YYID (0)) ··· 719 742 #if (defined __STDC__ || defined __C99__FUNC__ \ 720 743 || defined __cplusplus || defined _MSC_VER) 721 744 static void 722 - yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) 745 + yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) 723 746 #else 724 747 static void 725 - yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) 748 + yy_symbol_value_print (yyoutput, yytype, yyvaluep) 726 749 FILE *yyoutput; 727 750 int yytype; 728 751 YYSTYPE const * const yyvaluep; 729 - YYLTYPE const * const yylocationp; 730 752 #endif 731 753 { 732 754 if (!yyvaluep) 733 755 return; 734 - YYUSE (yylocationp); 735 756 # ifdef YYPRINT 736 757 if (yytype < YYNTOKENS) 737 758 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); ··· 751 776 #if (defined __STDC__ || defined __C99__FUNC__ \ 752 777 || defined __cplusplus || defined _MSC_VER) 753 778 static void 754 - yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) 779 + yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) 755 780 #else 756 781 static void 757 - yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) 782 + yy_symbol_print (yyoutput, yytype, yyvaluep) 758 783 FILE *yyoutput; 759 784 int yytype; 760 785 YYSTYPE const * const yyvaluep; 761 - YYLTYPE const * const yylocationp; 762 786 #endif 763 787 { 764 788 if (yytype < YYNTOKENS) ··· 765 791 else 766 792 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); 767 793 768 - YY_LOCATION_PRINT (yyoutput, *yylocationp); 769 - YYFPRINTF (yyoutput, ": "); 770 - yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp); 794 + yy_symbol_value_print (yyoutput, yytype, yyvaluep); 771 795 YYFPRINTF (yyoutput, ")"); 772 796 } 773 797 ··· 777 805 #if (defined __STDC__ || defined __C99__FUNC__ \ 778 806 || defined __cplusplus || defined _MSC_VER) 779 807 static void 780 - yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) 808 + yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) 781 809 #else 782 810 static void 783 - yy_stack_print (bottom, top) 784 - yytype_int16 *bottom; 785 - yytype_int16 *top; 811 + yy_stack_print (yybottom, yytop) 812 + yytype_int16 *yybottom; 813 + yytype_int16 *yytop; 786 814 #endif 787 815 { 788 816 YYFPRINTF (stderr, "Stack now"); 789 - for (; bottom <= top; ++bottom) 790 - YYFPRINTF (stderr, " %d", *bottom); 817 + for (; yybottom <= yytop; yybottom++) 818 + { 819 + int yybot = *yybottom; 820 + YYFPRINTF (stderr, " %d", yybot); 821 + } 791 822 YYFPRINTF (stderr, "\n"); 792 823 } 793 824 ··· 808 833 #if (defined __STDC__ || defined __C99__FUNC__ \ 809 834 || defined __cplusplus || defined _MSC_VER) 810 835 static void 811 - yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) 836 + yy_reduce_print (YYSTYPE *yyvsp, int yyrule) 812 837 #else 813 838 static void 814 - yy_reduce_print (yyvsp, yylsp, yyrule) 839 + yy_reduce_print (yyvsp, yyrule) 815 840 YYSTYPE *yyvsp; 816 - YYLTYPE *yylsp; 817 841 int yyrule; 818 842 #endif 819 843 { ··· 824 850 /* The symbols being reduced. */ 825 851 for (yyi = 0; yyi < yynrhs; yyi++) 826 852 { 827 - fprintf (stderr, " $%d = ", yyi + 1); 853 + YYFPRINTF (stderr, " $%d = ", yyi + 1); 828 854 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], 829 855 &(yyvsp[(yyi + 1) - (yynrhs)]) 830 - , &(yylsp[(yyi + 1) - (yynrhs)]) ); 831 - fprintf (stderr, "\n"); 856 + ); 857 + YYFPRINTF (stderr, "\n"); 832 858 } 833 859 } 834 860 835 861 # define YY_REDUCE_PRINT(Rule) \ 836 862 do { \ 837 863 if (yydebug) \ 838 - yy_reduce_print (yyvsp, yylsp, Rule); \ 864 + yy_reduce_print (yyvsp, Rule); \ 839 865 } while (YYID (0)) 840 866 841 867 /* Nonzero means print parse trace. It is left uninitialized so that ··· 1086 1112 #if (defined __STDC__ || defined __C99__FUNC__ \ 1087 1113 || defined __cplusplus || defined _MSC_VER) 1088 1114 static void 1089 - yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) 1115 + yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) 1090 1116 #else 1091 1117 static void 1092 - yydestruct (yymsg, yytype, yyvaluep, yylocationp) 1118 + yydestruct (yymsg, yytype, yyvaluep) 1093 1119 const char *yymsg; 1094 1120 int yytype; 1095 1121 YYSTYPE *yyvaluep; 1096 - YYLTYPE *yylocationp; 1097 1122 #endif 1098 1123 { 1099 1124 YYUSE (yyvaluep); 1100 - YYUSE (yylocationp); 1101 1125 1102 1126 if (!yymsg) 1103 1127 yymsg = "Deleting"; ··· 1108 1136 break; 1109 1137 } 1110 1138 } 1111 - 1112 1139 1113 1140 /* Prevent warnings from -Wmissing-prototypes. */ 1114 - 1115 1141 #ifdef YYPARSE_PARAM 1116 1142 #if defined __STDC__ || defined __cplusplus 1117 1143 int yyparse (void *YYPARSE_PARAM); ··· 1125 1155 #endif /* ! YYPARSE_PARAM */ 1126 1156 1127 1157 1128 - 1129 - /* The look-ahead symbol. */ 1158 + /* The lookahead symbol. */ 1130 1159 int yychar; 1131 1160 1132 - /* The semantic value of the look-ahead symbol. */ 1161 + /* The semantic value of the lookahead symbol. */ 1133 1162 YYSTYPE yylval; 1134 1163 1135 1164 /* Number of syntax errors so far. */ 1136 1165 int yynerrs; 1137 - /* Location data for the look-ahead symbol. */ 1138 - YYLTYPE yylloc; 1139 1166 1140 1167 1141 1168 1142 - /*----------. 1143 - | yyparse. | 1144 - `----------*/ 1169 + /*-------------------------. 1170 + | yyparse or yypush_parse. | 1171 + `-------------------------*/ 1145 1172 1146 1173 #ifdef YYPARSE_PARAM 1147 1174 #if (defined __STDC__ || defined __C99__FUNC__ \ ··· 1162 1195 #endif 1163 1196 #endif 1164 1197 { 1165 - 1166 - int yystate; 1198 + 1199 + 1200 + int yystate; 1201 + /* Number of tokens to shift before error messages enabled. */ 1202 + int yyerrstatus; 1203 + 1204 + /* The stacks and their tools: 1205 + `yyss': related to states. 1206 + `yyvs': related to semantic values. 1207 + 1208 + Refer to the stacks thru separate pointers, to allow yyoverflow 1209 + to reallocate them elsewhere. */ 1210 + 1211 + /* The state stack. */ 1212 + yytype_int16 yyssa[YYINITDEPTH]; 1213 + yytype_int16 *yyss; 1214 + yytype_int16 *yyssp; 1215 + 1216 + /* The semantic value stack. */ 1217 + YYSTYPE yyvsa[YYINITDEPTH]; 1218 + YYSTYPE *yyvs; 1219 + YYSTYPE *yyvsp; 1220 + 1221 + YYSIZE_T yystacksize; 1222 + 1167 1223 int yyn; 1168 1224 int yyresult; 1169 - /* Number of tokens to shift before error messages enabled. */ 1170 - int yyerrstatus; 1171 - /* Look-ahead token as an internal (translated) token number. */ 1172 - int yytoken = 0; 1225 + /* Lookahead token as an internal (translated) token number. */ 1226 + int yytoken; 1227 + /* The variables used to return semantic value and location from the 1228 + action routines. */ 1229 + YYSTYPE yyval; 1230 + 1173 1231 #if YYERROR_VERBOSE 1174 1232 /* Buffer for error messages, and its allocated size. */ 1175 1233 char yymsgbuf[128]; ··· 1202 1210 YYSIZE_T yymsg_alloc = sizeof yymsgbuf; 1203 1211 #endif 1204 1212 1205 - /* Three stacks and their tools: 1206 - `yyss': related to states, 1207 - `yyvs': related to semantic values, 1208 - `yyls': related to locations. 1209 - 1210 - Refer to the stacks thru separate pointers, to allow yyoverflow 1211 - to reallocate them elsewhere. */ 1212 - 1213 - /* The state stack. */ 1214 - yytype_int16 yyssa[YYINITDEPTH]; 1215 - yytype_int16 *yyss = yyssa; 1216 - yytype_int16 *yyssp; 1217 - 1218 - /* The semantic value stack. */ 1219 - YYSTYPE yyvsa[YYINITDEPTH]; 1220 - YYSTYPE *yyvs = yyvsa; 1221 - YYSTYPE *yyvsp; 1222 - 1223 - /* The location stack. */ 1224 - YYLTYPE yylsa[YYINITDEPTH]; 1225 - YYLTYPE *yyls = yylsa; 1226 - YYLTYPE *yylsp; 1227 - /* The locations where the error started and ended. */ 1228 - YYLTYPE yyerror_range[2]; 1229 - 1230 - #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) 1231 - 1232 - YYSIZE_T yystacksize = YYINITDEPTH; 1233 - 1234 - /* The variables used to return semantic value and location from the 1235 - action routines. */ 1236 - YYSTYPE yyval; 1237 - YYLTYPE yyloc; 1213 + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) 1238 1214 1239 1215 /* The number of symbols on the RHS of the reduced rule. 1240 1216 Keep to zero when no symbol should be popped. */ 1241 1217 int yylen = 0; 1218 + 1219 + yytoken = 0; 1220 + yyss = yyssa; 1221 + yyvs = yyvsa; 1222 + yystacksize = YYINITDEPTH; 1242 1223 1243 1224 YYDPRINTF ((stderr, "Starting parse\n")); 1244 1225 1245 1226 yystate = 0; 1246 1227 yyerrstatus = 0; 1247 1228 yynerrs = 0; 1248 - yychar = YYEMPTY; /* Cause a token to be read. */ 1229 + yychar = YYEMPTY; /* Cause a token to be read. */ 1249 1230 1250 1231 /* Initialize stack pointers. 1251 1232 Waste one element of value and location stack 1252 1233 so that they stay on the same level as the state stack. 1253 1234 The wasted elements are never initialized. */ 1254 - 1255 1235 yyssp = yyss; 1256 1236 yyvsp = yyvs; 1257 - yylsp = yyls; 1258 - #if YYLTYPE_IS_TRIVIAL 1259 - /* Initialize the default location before parsing starts. */ 1260 - yylloc.first_line = yylloc.last_line = 1; 1261 - yylloc.first_column = yylloc.last_column = 0; 1262 - #endif 1263 1237 1264 1238 goto yysetstate; 1265 1239 ··· 1252 1294 memory. */ 1253 1295 YYSTYPE *yyvs1 = yyvs; 1254 1296 yytype_int16 *yyss1 = yyss; 1255 - YYLTYPE *yyls1 = yyls; 1256 1297 1257 1298 /* Each stack pointer address is followed by the size of the 1258 1299 data in use in that stack, in bytes. This used to be a ··· 1260 1303 yyoverflow (YY_("memory exhausted"), 1261 1304 &yyss1, yysize * sizeof (*yyssp), 1262 1305 &yyvs1, yysize * sizeof (*yyvsp), 1263 - &yyls1, yysize * sizeof (*yylsp), 1264 1306 &yystacksize); 1265 - yyls = yyls1; 1307 + 1266 1308 yyss = yyss1; 1267 1309 yyvs = yyvs1; 1268 1310 } ··· 1282 1326 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1283 1327 if (! yyptr) 1284 1328 goto yyexhaustedlab; 1285 - YYSTACK_RELOCATE (yyss); 1286 - YYSTACK_RELOCATE (yyvs); 1287 - YYSTACK_RELOCATE (yyls); 1329 + YYSTACK_RELOCATE (yyss_alloc, yyss); 1330 + YYSTACK_RELOCATE (yyvs_alloc, yyvs); 1288 1331 # undef YYSTACK_RELOCATE 1289 1332 if (yyss1 != yyssa) 1290 1333 YYSTACK_FREE (yyss1); ··· 1293 1338 1294 1339 yyssp = yyss + yysize - 1; 1295 1340 yyvsp = yyvs + yysize - 1; 1296 - yylsp = yyls + yysize - 1; 1297 1341 1298 1342 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 1299 1343 (unsigned long int) yystacksize)); ··· 1303 1349 1304 1350 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1305 1351 1352 + if (yystate == YYFINAL) 1353 + YYACCEPT; 1354 + 1306 1355 goto yybackup; 1307 1356 1308 1357 /*-----------. ··· 1314 1357 yybackup: 1315 1358 1316 1359 /* Do appropriate processing given the current state. Read a 1317 - look-ahead token if we need one and don't already have one. */ 1360 + lookahead token if we need one and don't already have one. */ 1318 1361 1319 - /* First try to decide what to do without reference to look-ahead token. */ 1362 + /* First try to decide what to do without reference to lookahead token. */ 1320 1363 yyn = yypact[yystate]; 1321 1364 if (yyn == YYPACT_NINF) 1322 1365 goto yydefault; 1323 1366 1324 - /* Not known => get a look-ahead token if don't already have one. */ 1367 + /* Not known => get a lookahead token if don't already have one. */ 1325 1368 1326 - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ 1369 + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ 1327 1370 if (yychar == YYEMPTY) 1328 1371 { 1329 1372 YYDPRINTF ((stderr, "Reading a token: ")); ··· 1355 1398 goto yyreduce; 1356 1399 } 1357 1400 1358 - if (yyn == YYFINAL) 1359 - YYACCEPT; 1360 - 1361 1401 /* Count tokens shifted since error; after three, turn off error 1362 1402 status. */ 1363 1403 if (yyerrstatus) 1364 1404 yyerrstatus--; 1365 1405 1366 - /* Shift the look-ahead token. */ 1406 + /* Shift the lookahead token. */ 1367 1407 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1368 1408 1369 - /* Discard the shifted token unless it is eof. */ 1370 - if (yychar != YYEOF) 1371 - yychar = YYEMPTY; 1409 + /* Discard the shifted token. */ 1410 + yychar = YYEMPTY; 1372 1411 1373 1412 yystate = yyn; 1374 1413 *++yyvsp = yylval; 1375 - *++yylsp = yylloc; 1414 + 1376 1415 goto yynewstate; 1377 1416 1378 1417 ··· 1399 1446 GCC warning that YYVAL may be used uninitialized. */ 1400 1447 yyval = yyvsp[1-yylen]; 1401 1448 1402 - /* Default location. */ 1403 - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); 1449 + 1404 1450 YY_REDUCE_PRINT (yyn); 1405 1451 switch (yyn) 1406 1452 { 1407 1453 case 2: 1408 - #line 90 "dtc-parser.y" 1454 + 1455 + /* Line 1455 of yacc.c */ 1456 + #line 87 "dtc-parser.y" 1409 1457 { 1410 - the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), 0); 1458 + the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), 1459 + guess_boot_cpuid((yyvsp[(4) - (4)].node))); 1411 1460 ;} 1412 1461 break; 1413 1462 1414 1463 case 3: 1415 - #line 94 "dtc-parser.y" 1464 + 1465 + /* Line 1455 of yacc.c */ 1466 + #line 95 "dtc-parser.y" 1416 1467 { 1417 - the_boot_info = build_boot_info((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].node), 0); 1468 + (yyval.re) = NULL; 1418 1469 ;} 1419 1470 break; 1420 1471 1421 1472 case 4: 1422 - #line 101 "dtc-parser.y" 1473 + 1474 + /* Line 1455 of yacc.c */ 1475 + #line 99 "dtc-parser.y" 1423 1476 { 1424 - (yyval.re) = NULL; 1477 + (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); 1425 1478 ;} 1426 1479 break; 1427 1480 1428 1481 case 5: 1429 - #line 105 "dtc-parser.y" 1482 + 1483 + /* Line 1455 of yacc.c */ 1484 + #line 106 "dtc-parser.y" 1430 1485 { 1431 - (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); 1486 + (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].addr), (yyvsp[(3) - (4)].addr)); 1432 1487 ;} 1433 1488 break; 1434 1489 1435 1490 case 6: 1436 - #line 112 "dtc-parser.y" 1491 + 1492 + /* Line 1455 of yacc.c */ 1493 + #line 110 "dtc-parser.y" 1437 1494 { 1438 - (yyval.re) = build_reserve_entry((yyvsp[(3) - (5)].addr), (yyvsp[(4) - (5)].addr), (yyvsp[(1) - (5)].labelref)); 1495 + add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref)); 1496 + (yyval.re) = (yyvsp[(2) - (2)].re); 1439 1497 ;} 1440 1498 break; 1441 1499 1442 1500 case 7: 1443 - #line 119 "dtc-parser.y" 1444 - { 1445 - (yyval.re) = NULL; 1446 - ;} 1447 - break; 1448 1501 1449 - case 8: 1450 - #line 123 "dtc-parser.y" 1451 - { 1452 - (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); 1453 - ;} 1454 - break; 1455 - 1456 - case 9: 1457 - #line 130 "dtc-parser.y" 1458 - { 1459 - (yyval.re) = (yyvsp[(1) - (1)].re); 1460 - ;} 1461 - break; 1462 - 1463 - case 10: 1464 - #line 134 "dtc-parser.y" 1465 - { 1466 - (yyval.re) = build_reserve_entry((yyvsp[(3) - (6)].addr), (yyvsp[(5) - (6)].addr) - (yyvsp[(3) - (6)].addr) + 1, (yyvsp[(1) - (6)].labelref)); 1467 - ;} 1468 - break; 1469 - 1470 - case 11: 1471 - #line 141 "dtc-parser.y" 1502 + /* Line 1455 of yacc.c */ 1503 + #line 118 "dtc-parser.y" 1472 1504 { 1473 1505 (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); 1474 1506 ;} 1475 1507 break; 1476 1508 1477 - case 12: 1478 - #line 145 "dtc-parser.y" 1509 + case 8: 1510 + 1511 + /* Line 1455 of yacc.c */ 1512 + #line 125 "dtc-parser.y" 1479 1513 { 1480 - (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 16, 64); 1514 + (yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); 1481 1515 ;} 1482 1516 break; 1483 1517 1484 - case 13: 1485 - #line 152 "dtc-parser.y" 1518 + case 9: 1519 + 1520 + /* Line 1455 of yacc.c */ 1521 + #line 129 "dtc-parser.y" 1486 1522 { 1487 - (yyval.node) = name_node((yyvsp[(2) - (2)].node), "", NULL); 1523 + (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); 1488 1524 ;} 1489 1525 break; 1490 1526 1491 - case 14: 1492 - #line 159 "dtc-parser.y" 1527 + case 10: 1528 + 1529 + /* Line 1455 of yacc.c */ 1530 + #line 133 "dtc-parser.y" 1531 + { 1532 + struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref)); 1533 + 1534 + if (target) 1535 + merge_nodes(target, (yyvsp[(3) - (3)].node)); 1536 + else 1537 + print_error("label or path, '%s', not found", (yyvsp[(2) - (3)].labelref)); 1538 + (yyval.node) = (yyvsp[(1) - (3)].node); 1539 + ;} 1540 + break; 1541 + 1542 + case 11: 1543 + 1544 + /* Line 1455 of yacc.c */ 1545 + #line 146 "dtc-parser.y" 1493 1546 { 1494 1547 (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); 1495 1548 ;} 1496 1549 break; 1497 1550 1498 - case 15: 1499 - #line 166 "dtc-parser.y" 1551 + case 12: 1552 + 1553 + /* Line 1455 of yacc.c */ 1554 + #line 153 "dtc-parser.y" 1500 1555 { 1501 1556 (yyval.proplist) = NULL; 1502 1557 ;} 1503 1558 break; 1504 1559 1505 - case 16: 1506 - #line 170 "dtc-parser.y" 1560 + case 13: 1561 + 1562 + /* Line 1455 of yacc.c */ 1563 + #line 157 "dtc-parser.y" 1507 1564 { 1508 1565 (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); 1509 1566 ;} 1510 1567 break; 1511 1568 1569 + case 14: 1570 + 1571 + /* Line 1455 of yacc.c */ 1572 + #line 164 "dtc-parser.y" 1573 + { 1574 + (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data)); 1575 + ;} 1576 + break; 1577 + 1578 + case 15: 1579 + 1580 + /* Line 1455 of yacc.c */ 1581 + #line 168 "dtc-parser.y" 1582 + { 1583 + (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); 1584 + ;} 1585 + break; 1586 + 1587 + case 16: 1588 + 1589 + /* Line 1455 of yacc.c */ 1590 + #line 172 "dtc-parser.y" 1591 + { 1592 + add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref)); 1593 + (yyval.prop) = (yyvsp[(2) - (2)].prop); 1594 + ;} 1595 + break; 1596 + 1512 1597 case 17: 1513 - #line 177 "dtc-parser.y" 1514 - { 1515 - (yyval.prop) = build_property((yyvsp[(2) - (5)].propnodename), (yyvsp[(4) - (5)].data), (yyvsp[(1) - (5)].labelref)); 1516 - ;} 1517 - break; 1518 1598 1519 - case 18: 1520 - #line 181 "dtc-parser.y" 1521 - { 1522 - (yyval.prop) = build_property((yyvsp[(2) - (3)].propnodename), empty_data, (yyvsp[(1) - (3)].labelref)); 1523 - ;} 1524 - break; 1525 - 1526 - case 19: 1527 - #line 188 "dtc-parser.y" 1599 + /* Line 1455 of yacc.c */ 1600 + #line 180 "dtc-parser.y" 1528 1601 { 1529 1602 (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); 1530 1603 ;} 1531 1604 break; 1532 1605 1606 + case 18: 1607 + 1608 + /* Line 1455 of yacc.c */ 1609 + #line 184 "dtc-parser.y" 1610 + { 1611 + (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); 1612 + ;} 1613 + break; 1614 + 1615 + case 19: 1616 + 1617 + /* Line 1455 of yacc.c */ 1618 + #line 188 "dtc-parser.y" 1619 + { 1620 + (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); 1621 + ;} 1622 + break; 1623 + 1533 1624 case 20: 1625 + 1626 + /* Line 1455 of yacc.c */ 1534 1627 #line 192 "dtc-parser.y" 1535 - { 1536 - (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); 1537 - ;} 1538 - break; 1539 - 1540 - case 21: 1541 - #line 196 "dtc-parser.y" 1542 - { 1543 - (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); 1544 - ;} 1545 - break; 1546 - 1547 - case 22: 1548 - #line 200 "dtc-parser.y" 1549 1628 { 1550 1629 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref)); 1551 1630 ;} 1552 1631 break; 1553 1632 1554 - case 23: 1555 - #line 204 "dtc-parser.y" 1633 + case 21: 1634 + 1635 + /* Line 1455 of yacc.c */ 1636 + #line 196 "dtc-parser.y" 1556 1637 { 1557 - struct search_path path = { srcpos_file->dir, NULL, NULL }; 1558 - struct dtc_file *file = dtc_open_file((yyvsp[(4) - (9)].data).val, &path); 1559 - struct data d = empty_data; 1638 + FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL); 1639 + struct data d; 1560 1640 1561 1641 if ((yyvsp[(6) - (9)].addr) != 0) 1562 - if (fseek(file->file, (yyvsp[(6) - (9)].addr), SEEK_SET) != 0) 1563 - yyerrorf("Couldn't seek to offset %llu in \"%s\": %s", 1564 - (unsigned long long)(yyvsp[(6) - (9)].addr), 1565 - (yyvsp[(4) - (9)].data).val, strerror(errno)); 1642 + if (fseek(f, (yyvsp[(6) - (9)].addr), SEEK_SET) != 0) 1643 + print_error("Couldn't seek to offset %llu in \"%s\": %s", 1644 + (unsigned long long)(yyvsp[(6) - (9)].addr), 1645 + (yyvsp[(4) - (9)].data).val, 1646 + strerror(errno)); 1566 1647 1567 - d = data_copy_file(file->file, (yyvsp[(8) - (9)].addr)); 1648 + d = data_copy_file(f, (yyvsp[(8) - (9)].addr)); 1568 1649 1569 1650 (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d); 1570 - dtc_close_file(file); 1651 + fclose(f); 1571 1652 ;} 1572 1653 break; 1573 1654 1574 - case 24: 1575 - #line 221 "dtc-parser.y" 1655 + case 22: 1656 + 1657 + /* Line 1455 of yacc.c */ 1658 + #line 213 "dtc-parser.y" 1576 1659 { 1577 - struct search_path path = { srcpos_file->dir, NULL, NULL }; 1578 - struct dtc_file *file = dtc_open_file((yyvsp[(4) - (5)].data).val, &path); 1660 + FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL); 1579 1661 struct data d = empty_data; 1580 1662 1581 - d = data_copy_file(file->file, -1); 1663 + d = data_copy_file(f, -1); 1582 1664 1583 1665 (yyval.data) = data_merge((yyvsp[(1) - (5)].data), d); 1584 - dtc_close_file(file); 1666 + fclose(f); 1585 1667 ;} 1586 1668 break; 1587 1669 1588 - case 25: 1589 - #line 232 "dtc-parser.y" 1670 + case 23: 1671 + 1672 + /* Line 1455 of yacc.c */ 1673 + #line 223 "dtc-parser.y" 1590 1674 { 1591 1675 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1592 1676 ;} 1593 1677 break; 1594 1678 1595 - case 26: 1596 - #line 239 "dtc-parser.y" 1679 + case 24: 1680 + 1681 + /* Line 1455 of yacc.c */ 1682 + #line 230 "dtc-parser.y" 1597 1683 { 1598 1684 (yyval.data) = empty_data; 1599 1685 ;} 1600 1686 break; 1601 1687 1602 - case 27: 1603 - #line 243 "dtc-parser.y" 1688 + case 25: 1689 + 1690 + /* Line 1455 of yacc.c */ 1691 + #line 234 "dtc-parser.y" 1604 1692 { 1605 1693 (yyval.data) = (yyvsp[(1) - (2)].data); 1606 1694 ;} 1607 1695 break; 1608 1696 1609 - case 28: 1610 - #line 247 "dtc-parser.y" 1697 + case 26: 1698 + 1699 + /* Line 1455 of yacc.c */ 1700 + #line 238 "dtc-parser.y" 1611 1701 { 1612 1702 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1613 1703 ;} 1614 1704 break; 1615 1705 1616 - case 29: 1617 - #line 254 "dtc-parser.y" 1706 + case 27: 1707 + 1708 + /* Line 1455 of yacc.c */ 1709 + #line 245 "dtc-parser.y" 1618 1710 { 1619 1711 (yyval.data) = empty_data; 1620 1712 ;} 1621 1713 break; 1622 1714 1623 - case 30: 1624 - #line 258 "dtc-parser.y" 1715 + case 28: 1716 + 1717 + /* Line 1455 of yacc.c */ 1718 + #line 249 "dtc-parser.y" 1625 1719 { 1626 1720 (yyval.data) = data_append_cell((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].cell)); 1627 1721 ;} 1628 1722 break; 1629 1723 1630 - case 31: 1631 - #line 262 "dtc-parser.y" 1724 + case 29: 1725 + 1726 + /* Line 1455 of yacc.c */ 1727 + #line 253 "dtc-parser.y" 1632 1728 { 1633 1729 (yyval.data) = data_append_cell(data_add_marker((yyvsp[(1) - (2)].data), REF_PHANDLE, 1634 1730 (yyvsp[(2) - (2)].labelref)), -1); 1635 1731 ;} 1636 1732 break; 1637 1733 1638 - case 32: 1639 - #line 267 "dtc-parser.y" 1734 + case 30: 1735 + 1736 + /* Line 1455 of yacc.c */ 1737 + #line 258 "dtc-parser.y" 1640 1738 { 1641 1739 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1642 1740 ;} 1643 1741 break; 1644 1742 1645 - case 33: 1646 - #line 274 "dtc-parser.y" 1647 - { 1648 - (yyval.cbase) = 16; 1649 - ;} 1650 - break; 1743 + case 31: 1651 1744 1652 - case 35: 1653 - #line 282 "dtc-parser.y" 1745 + /* Line 1455 of yacc.c */ 1746 + #line 265 "dtc-parser.y" 1654 1747 { 1655 1748 (yyval.cell) = eval_literal((yyvsp[(1) - (1)].literal), 0, 32); 1656 1749 ;} 1657 1750 break; 1658 1751 1659 - case 36: 1660 - #line 286 "dtc-parser.y" 1661 - { 1662 - (yyval.cell) = eval_literal((yyvsp[(2) - (2)].literal), (yyvsp[(1) - (2)].cbase), 32); 1663 - ;} 1664 - break; 1752 + case 32: 1665 1753 1666 - case 37: 1667 - #line 293 "dtc-parser.y" 1754 + /* Line 1455 of yacc.c */ 1755 + #line 272 "dtc-parser.y" 1668 1756 { 1669 1757 (yyval.data) = empty_data; 1670 1758 ;} 1671 1759 break; 1672 1760 1673 - case 38: 1674 - #line 297 "dtc-parser.y" 1761 + case 33: 1762 + 1763 + /* Line 1455 of yacc.c */ 1764 + #line 276 "dtc-parser.y" 1675 1765 { 1676 1766 (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); 1677 1767 ;} 1678 1768 break; 1679 1769 1680 - case 39: 1681 - #line 301 "dtc-parser.y" 1770 + case 34: 1771 + 1772 + /* Line 1455 of yacc.c */ 1773 + #line 280 "dtc-parser.y" 1682 1774 { 1683 1775 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1684 1776 ;} 1685 1777 break; 1686 1778 1687 - case 40: 1688 - #line 308 "dtc-parser.y" 1779 + case 35: 1780 + 1781 + /* Line 1455 of yacc.c */ 1782 + #line 287 "dtc-parser.y" 1689 1783 { 1690 1784 (yyval.nodelist) = NULL; 1691 1785 ;} 1692 1786 break; 1693 1787 1694 - case 41: 1695 - #line 312 "dtc-parser.y" 1788 + case 36: 1789 + 1790 + /* Line 1455 of yacc.c */ 1791 + #line 291 "dtc-parser.y" 1696 1792 { 1697 1793 (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); 1698 1794 ;} 1699 1795 break; 1700 1796 1701 - case 42: 1702 - #line 316 "dtc-parser.y" 1797 + case 37: 1798 + 1799 + /* Line 1455 of yacc.c */ 1800 + #line 295 "dtc-parser.y" 1703 1801 { 1704 - yyerror("syntax error: properties must precede subnodes"); 1802 + print_error("syntax error: properties must precede subnodes"); 1705 1803 YYERROR; 1706 1804 ;} 1707 1805 break; 1708 1806 1709 - case 43: 1710 - #line 324 "dtc-parser.y" 1807 + case 38: 1808 + 1809 + /* Line 1455 of yacc.c */ 1810 + #line 303 "dtc-parser.y" 1711 1811 { 1712 - (yyval.node) = name_node((yyvsp[(3) - (3)].node), (yyvsp[(2) - (3)].propnodename), (yyvsp[(1) - (3)].labelref)); 1812 + (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); 1713 1813 ;} 1714 1814 break; 1715 1815 1716 - case 44: 1717 - #line 331 "dtc-parser.y" 1718 - { 1719 - (yyval.labelref) = NULL; 1720 - ;} 1721 - break; 1816 + case 39: 1722 1817 1723 - case 45: 1724 - #line 335 "dtc-parser.y" 1818 + /* Line 1455 of yacc.c */ 1819 + #line 307 "dtc-parser.y" 1725 1820 { 1726 - (yyval.labelref) = (yyvsp[(1) - (1)].labelref); 1821 + add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref)); 1822 + (yyval.node) = (yyvsp[(2) - (2)].node); 1727 1823 ;} 1728 1824 break; 1729 1825 1730 1826 1731 - /* Line 1267 of yacc.c. */ 1732 - #line 1780 "dtc-parser.tab.c" 1827 + 1828 + /* Line 1455 of yacc.c */ 1829 + #line 1783 "dtc-parser.tab.c" 1733 1830 default: break; 1734 1831 } 1735 1832 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); ··· 1789 1786 YY_STACK_PRINT (yyss, yyssp); 1790 1787 1791 1788 *++yyvsp = yyval; 1792 - *++yylsp = yyloc; 1793 1789 1794 1790 /* Now `shift' the result of the reduction. Determine what state 1795 1791 that goes to, based on the state we popped back to and the rule ··· 1850 1848 #endif 1851 1849 } 1852 1850 1853 - yyerror_range[0] = yylloc; 1851 + 1854 1852 1855 1853 if (yyerrstatus == 3) 1856 1854 { 1857 - /* If just tried and failed to reuse look-ahead token after an 1855 + /* If just tried and failed to reuse lookahead token after an 1858 1856 error, discard it. */ 1859 1857 1860 1858 if (yychar <= YYEOF) ··· 1866 1864 else 1867 1865 { 1868 1866 yydestruct ("Error: discarding", 1869 - yytoken, &yylval, &yylloc); 1867 + yytoken, &yylval); 1870 1868 yychar = YYEMPTY; 1871 1869 } 1872 1870 } 1873 1871 1874 - /* Else will try to reuse look-ahead token after shifting the error 1872 + /* Else will try to reuse lookahead token after shifting the error 1875 1873 token. */ 1876 1874 goto yyerrlab1; 1877 1875 ··· 1887 1885 if (/*CONSTCOND*/ 0) 1888 1886 goto yyerrorlab; 1889 1887 1890 - yyerror_range[0] = yylsp[1-yylen]; 1891 1888 /* Do not reclaim the symbols of the rule which action triggered 1892 1889 this YYERROR. */ 1893 1890 YYPOPSTACK (yylen); ··· 1920 1919 if (yyssp == yyss) 1921 1920 YYABORT; 1922 1921 1923 - yyerror_range[0] = *yylsp; 1922 + 1924 1923 yydestruct ("Error: popping", 1925 - yystos[yystate], yyvsp, yylsp); 1924 + yystos[yystate], yyvsp); 1926 1925 YYPOPSTACK (1); 1927 1926 yystate = *yyssp; 1928 1927 YY_STACK_PRINT (yyss, yyssp); 1929 1928 } 1930 1929 1931 - if (yyn == YYFINAL) 1932 - YYACCEPT; 1933 - 1934 1930 *++yyvsp = yylval; 1935 1931 1936 - yyerror_range[1] = yylloc; 1937 - /* Using YYLLOC is tempting, but would change the location of 1938 - the look-ahead. YYLOC is available though. */ 1939 - YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); 1940 - *++yylsp = yyloc; 1941 1932 1942 1933 /* Shift the error token. */ 1943 1934 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); ··· 1952 1959 yyresult = 1; 1953 1960 goto yyreturn; 1954 1961 1955 - #ifndef yyoverflow 1962 + #if !defined(yyoverflow) || YYERROR_VERBOSE 1956 1963 /*-------------------------------------------------. 1957 1964 | yyexhaustedlab -- memory exhaustion comes here. | 1958 1965 `-------------------------------------------------*/ ··· 1963 1970 #endif 1964 1971 1965 1972 yyreturn: 1966 - if (yychar != YYEOF && yychar != YYEMPTY) 1973 + if (yychar != YYEMPTY) 1967 1974 yydestruct ("Cleanup: discarding lookahead", 1968 - yytoken, &yylval, &yylloc); 1975 + yytoken, &yylval); 1969 1976 /* Do not reclaim the symbols of the rule which action triggered 1970 1977 this YYABORT or YYACCEPT. */ 1971 1978 YYPOPSTACK (yylen); ··· 1973 1980 while (yyssp != yyss) 1974 1981 { 1975 1982 yydestruct ("Cleanup: popping", 1976 - yystos[*yyssp], yyvsp, yylsp); 1983 + yystos[*yyssp], yyvsp); 1977 1984 YYPOPSTACK (1); 1978 1985 } 1979 1986 #ifndef yyoverflow ··· 1989 1996 } 1990 1997 1991 1998 1992 - #line 340 "dtc-parser.y" 1999 + 2000 + /* Line 1675 of yacc.c */ 2001 + #line 313 "dtc-parser.y" 1993 2002 1994 2003 1995 - void yyerrorf(char const *s, ...) 2004 + void print_error(char const *fmt, ...) 1996 2005 { 1997 - const char *fname = srcpos_file ? srcpos_file->name : "<no-file>"; 1998 2006 va_list va; 1999 - va_start(va, s); 2000 2007 2001 - if (strcmp(fname, "-") == 0) 2002 - fname = "stdin"; 2003 - 2004 - fprintf(stderr, "%s:%d ", fname, yylloc.first_line); 2005 - vfprintf(stderr, s, va); 2006 - fprintf(stderr, "\n"); 2008 + va_start(va, fmt); 2009 + srcpos_verror(&yylloc, fmt, va); 2010 + va_end(va); 2007 2011 2008 2012 treesource_error = 1; 2009 - va_end(va); 2010 2013 } 2011 2014 2012 - void yyerror (char const *s) 2013 - { 2014 - yyerrorf("%s", s); 2015 + void yyerror(char const *s) { 2016 + print_error("%s", s); 2015 2017 } 2016 2018 2017 2019 static unsigned long long eval_literal(const char *s, int base, int bits) ··· 2017 2029 errno = 0; 2018 2030 val = strtoull(s, &e, base); 2019 2031 if (*e) 2020 - yyerror("bad characters in literal"); 2032 + print_error("bad characters in literal"); 2021 2033 else if ((errno == ERANGE) 2022 2034 || ((bits < 64) && (val >= (1ULL << bits)))) 2023 - yyerror("literal out of range"); 2035 + print_error("literal out of range"); 2024 2036 else if (errno != 0) 2025 - yyerror("bad literal"); 2037 + print_error("bad literal"); 2026 2038 return val; 2027 2039 } 2028 2040
+30 -52
scripts/dtc/dtc-parser.tab.h_shipped
··· 1 - /* A Bison parser, made by GNU Bison 2.3. */ 1 + 2 + /* A Bison parser, made by GNU Bison 2.4.1. */ 2 3 3 4 /* Skeleton interface for Bison's Yacc-like parsers in C 4 - 5 - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 5 + 6 + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 6 7 Free Software Foundation, Inc. 7 - 8 - This program is free software; you can redistribute it and/or modify 8 + 9 + This program is free software: you can redistribute it and/or modify 9 10 it under the terms of the GNU General Public License as published by 10 - the Free Software Foundation; either version 2, or (at your option) 11 - any later version. 12 - 11 + the Free Software Foundation, either version 3 of the License, or 12 + (at your option) any later version. 13 + 13 14 This program is distributed in the hope that it will be useful, 14 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 17 GNU General Public License for more details. 17 - 18 + 18 19 You should have received a copy of the GNU General Public License 19 - along with this program; if not, write to the Free Software 20 - Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 - Boston, MA 02110-1301, USA. */ 20 + along with this program. If not, see <http://www.gnu.org/licenses/>. */ 22 21 23 22 /* As a special exception, you may create a larger work that contains 24 23 part or all of the Bison parser skeleton and distribute that work ··· 28 29 special exception, which will cause the skeleton and the resulting 29 30 Bison output files to be licensed under the GNU General Public 30 31 License without this special exception. 31 - 32 + 32 33 This special exception was added by the Free Software Foundation in 33 34 version 2.2 of Bison. */ 35 + 34 36 35 37 /* Tokens. */ 36 38 #ifndef YYTOKENTYPE ··· 43 43 DT_MEMRESERVE = 259, 44 44 DT_PROPNODENAME = 260, 45 45 DT_LITERAL = 261, 46 - DT_LEGACYLITERAL = 262, 47 - DT_BASE = 263, 48 - DT_BYTE = 264, 49 - DT_STRING = 265, 50 - DT_LABEL = 266, 51 - DT_REF = 267, 52 - DT_INCBIN = 268 46 + DT_BASE = 262, 47 + DT_BYTE = 263, 48 + DT_STRING = 264, 49 + DT_LABEL = 265, 50 + DT_REF = 266, 51 + DT_INCBIN = 267 53 52 }; 54 53 #endif 55 - /* Tokens. */ 56 - #define DT_V1 258 57 - #define DT_MEMRESERVE 259 58 - #define DT_PROPNODENAME 260 59 - #define DT_LITERAL 261 60 - #define DT_LEGACYLITERAL 262 61 - #define DT_BASE 263 62 - #define DT_BYTE 264 63 - #define DT_STRING 265 64 - #define DT_LABEL 266 65 - #define DT_REF 267 66 - #define DT_INCBIN 268 67 - 68 54 69 55 70 56 71 57 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 72 58 typedef union YYSTYPE 73 - #line 37 "dtc-parser.y" 74 59 { 60 + 61 + /* Line 1676 of yacc.c */ 62 + #line 39 "dtc-parser.y" 63 + 75 64 char *propnodename; 76 65 char *literal; 77 66 char *labelref; ··· 75 86 struct node *node; 76 87 struct node *nodelist; 77 88 struct reserve_info *re; 78 - } 79 - /* Line 1489 of yacc.c. */ 80 - #line 92 "dtc-parser.tab.h" 81 - YYSTYPE; 89 + 90 + 91 + 92 + /* Line 1676 of yacc.c */ 93 + #line 83 "dtc-parser.tab.h" 94 + } YYSTYPE; 95 + # define YYSTYPE_IS_TRIVIAL 1 82 96 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ 83 97 # define YYSTYPE_IS_DECLARED 1 84 - # define YYSTYPE_IS_TRIVIAL 1 85 98 #endif 86 99 87 100 extern YYSTYPE yylval; 88 101 89 - #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED 90 - typedef struct YYLTYPE 91 - { 92 - int first_line; 93 - int first_column; 94 - int last_line; 95 - int last_column; 96 - } YYLTYPE; 97 - # define yyltype YYLTYPE /* obsolescent; will be withdrawn */ 98 - # define YYLTYPE_IS_DECLARED 1 99 - # define YYLTYPE_IS_TRIVIAL 1 100 - #endif 101 102 102 - extern YYLTYPE yylloc;
+63 -97
scripts/dtc/dtc-parser.y
··· 18 18 * USA 19 19 */ 20 20 21 - %locations 22 - 23 21 %{ 24 22 #include <stdio.h> 25 23 26 24 #include "dtc.h" 27 25 #include "srcpos.h" 28 26 27 + YYLTYPE yylloc; 28 + 29 29 extern int yylex(void); 30 + extern void print_error(char const *fmt, ...); 31 + extern void yyerror(char const *s); 30 32 31 33 extern struct boot_info *the_boot_info; 32 34 extern int treesource_error; ··· 57 55 %token DT_MEMRESERVE 58 56 %token <propnodename> DT_PROPNODENAME 59 57 %token <literal> DT_LITERAL 60 - %token <literal> DT_LEGACYLITERAL 61 58 %token <cbase> DT_BASE 62 59 %token <byte> DT_BYTE 63 60 %token <data> DT_STRING ··· 68 67 %type <data> propdataprefix 69 68 %type <re> memreserve 70 69 %type <re> memreserves 71 - %type <re> v0_memreserve 72 - %type <re> v0_memreserves 73 70 %type <addr> addr 74 71 %type <data> celllist 75 - %type <cbase> cellbase 76 72 %type <cell> cellval 77 73 %type <data> bytestring 78 74 %type <prop> propdef ··· 79 81 %type <node> nodedef 80 82 %type <node> subnode 81 83 %type <nodelist> subnodes 82 - %type <labelref> label 83 84 84 85 %% 85 86 86 87 sourcefile: 87 88 DT_V1 ';' memreserves devicetree 88 89 { 89 - the_boot_info = build_boot_info($3, $4, 0); 90 - } 91 - | v0_memreserves devicetree 92 - { 93 - the_boot_info = build_boot_info($1, $2, 0); 90 + the_boot_info = build_boot_info($3, $4, 91 + guess_boot_cpuid($4)); 94 92 } 95 93 ; 96 94 ··· 102 108 ; 103 109 104 110 memreserve: 105 - label DT_MEMRESERVE addr addr ';' 111 + DT_MEMRESERVE addr addr ';' 106 112 { 107 - $$ = build_reserve_entry($3, $4, $1); 113 + $$ = build_reserve_entry($2, $3); 108 114 } 109 - ; 110 - 111 - v0_memreserves: 112 - /* empty */ 115 + | DT_LABEL memreserve 113 116 { 114 - $$ = NULL; 115 - } 116 - | v0_memreserve v0_memreserves 117 - { 118 - $$ = chain_reserve_entry($1, $2); 119 - }; 120 - ; 121 - 122 - v0_memreserve: 123 - memreserve 124 - { 125 - $$ = $1; 126 - } 127 - | label DT_MEMRESERVE addr '-' addr ';' 128 - { 129 - $$ = build_reserve_entry($3, $5 - $3 + 1, $1); 117 + add_label(&$2->labels, $1); 118 + $$ = $2; 130 119 } 131 120 ; 132 121 ··· 118 141 { 119 142 $$ = eval_literal($1, 0, 64); 120 143 } 121 - | DT_LEGACYLITERAL 122 - { 123 - $$ = eval_literal($1, 16, 64); 124 - } 125 144 ; 126 145 127 146 devicetree: 128 147 '/' nodedef 129 148 { 130 - $$ = name_node($2, "", NULL); 149 + $$ = name_node($2, ""); 150 + } 151 + | devicetree '/' nodedef 152 + { 153 + $$ = merge_nodes($1, $3); 154 + } 155 + | devicetree DT_REF nodedef 156 + { 157 + struct node *target = get_node_by_ref($1, $2); 158 + 159 + if (target) 160 + merge_nodes(target, $3); 161 + else 162 + print_error("label or path, '%s', not found", $2); 163 + $$ = $1; 131 164 } 132 165 ; 133 166 ··· 160 173 ; 161 174 162 175 propdef: 163 - label DT_PROPNODENAME '=' propdata ';' 176 + DT_PROPNODENAME '=' propdata ';' 164 177 { 165 - $$ = build_property($2, $4, $1); 178 + $$ = build_property($1, $3); 166 179 } 167 - | label DT_PROPNODENAME ';' 180 + | DT_PROPNODENAME ';' 168 181 { 169 - $$ = build_property($2, empty_data, $1); 182 + $$ = build_property($1, empty_data); 183 + } 184 + | DT_LABEL propdef 185 + { 186 + add_label(&$2->labels, $1); 187 + $$ = $2; 170 188 } 171 189 ; 172 190 ··· 194 202 } 195 203 | propdataprefix DT_INCBIN '(' DT_STRING ',' addr ',' addr ')' 196 204 { 197 - struct search_path path = { srcpos_file->dir, NULL, NULL }; 198 - struct dtc_file *file = dtc_open_file($4.val, &path); 199 - struct data d = empty_data; 205 + FILE *f = srcfile_relative_open($4.val, NULL); 206 + struct data d; 200 207 201 208 if ($6 != 0) 202 - if (fseek(file->file, $6, SEEK_SET) != 0) 203 - yyerrorf("Couldn't seek to offset %llu in \"%s\": %s", 204 - (unsigned long long)$6, 205 - $4.val, strerror(errno)); 209 + if (fseek(f, $6, SEEK_SET) != 0) 210 + print_error("Couldn't seek to offset %llu in \"%s\": %s", 211 + (unsigned long long)$6, 212 + $4.val, 213 + strerror(errno)); 206 214 207 - d = data_copy_file(file->file, $8); 215 + d = data_copy_file(f, $8); 208 216 209 217 $$ = data_merge($1, d); 210 - dtc_close_file(file); 218 + fclose(f); 211 219 } 212 220 | propdataprefix DT_INCBIN '(' DT_STRING ')' 213 221 { 214 - struct search_path path = { srcpos_file->dir, NULL, NULL }; 215 - struct dtc_file *file = dtc_open_file($4.val, &path); 222 + FILE *f = srcfile_relative_open($4.val, NULL); 216 223 struct data d = empty_data; 217 224 218 - d = data_copy_file(file->file, -1); 225 + d = data_copy_file(f, -1); 219 226 220 227 $$ = data_merge($1, d); 221 - dtc_close_file(file); 228 + fclose(f); 222 229 } 223 230 | propdata DT_LABEL 224 231 { ··· 260 269 } 261 270 ; 262 271 263 - cellbase: 264 - /* empty */ 265 - { 266 - $$ = 16; 267 - } 268 - | DT_BASE 269 - ; 270 - 271 272 cellval: 272 273 DT_LITERAL 273 274 { 274 275 $$ = eval_literal($1, 0, 32); 275 - } 276 - | cellbase DT_LEGACYLITERAL 277 - { 278 - $$ = eval_literal($2, $1, 32); 279 276 } 280 277 ; 281 278 ··· 287 308 { 288 309 $$ = NULL; 289 310 } 290 - | subnode subnodes 311 + | subnode subnodes 291 312 { 292 313 $$ = chain_node($1, $2); 293 314 } 294 315 | subnode propdef 295 316 { 296 - yyerror("syntax error: properties must precede subnodes"); 317 + print_error("syntax error: properties must precede subnodes"); 297 318 YYERROR; 298 319 } 299 320 ; 300 321 301 322 subnode: 302 - label DT_PROPNODENAME nodedef 323 + DT_PROPNODENAME nodedef 303 324 { 304 - $$ = name_node($3, $2, $1); 325 + $$ = name_node($2, $1); 305 326 } 306 - ; 307 - 308 - label: 309 - /* empty */ 327 + | DT_LABEL subnode 310 328 { 311 - $$ = NULL; 312 - } 313 - | DT_LABEL 314 - { 315 - $$ = $1; 329 + add_label(&$2->labels, $1); 330 + $$ = $2; 316 331 } 317 332 ; 318 333 319 334 %% 320 335 321 - void yyerrorf(char const *s, ...) 336 + void print_error(char const *fmt, ...) 322 337 { 323 - const char *fname = srcpos_file ? srcpos_file->name : "<no-file>"; 324 338 va_list va; 325 - va_start(va, s); 326 339 327 - if (strcmp(fname, "-") == 0) 328 - fname = "stdin"; 329 - 330 - fprintf(stderr, "%s:%d ", fname, yylloc.first_line); 331 - vfprintf(stderr, s, va); 332 - fprintf(stderr, "\n"); 340 + va_start(va, fmt); 341 + srcpos_verror(&yylloc, fmt, va); 342 + va_end(va); 333 343 334 344 treesource_error = 1; 335 - va_end(va); 336 345 } 337 346 338 - void yyerror (char const *s) 339 - { 340 - yyerrorf("%s", s); 347 + void yyerror(char const *s) { 348 + print_error("%s", s); 341 349 } 342 350 343 351 static unsigned long long eval_literal(const char *s, int base, int bits) ··· 335 369 errno = 0; 336 370 val = strtoull(s, &e, base); 337 371 if (*e) 338 - yyerror("bad characters in literal"); 372 + print_error("bad characters in literal"); 339 373 else if ((errno == ERANGE) 340 374 || ((bits < 64) && (val >= (1ULL << bits)))) 341 - yyerror("literal out of range"); 375 + print_error("literal out of range"); 342 376 else if (errno != 0) 343 - yyerror("bad literal"); 377 + print_error("bad literal"); 344 378 return val; 345 379 }
+31 -26
scripts/dtc/dtc.c
··· 30 30 int reservenum; /* Number of memory reservation slots */ 31 31 int minsize; /* Minimum blob size */ 32 32 int padsize; /* Additional padding to blob */ 33 - 34 - char *join_path(const char *path, const char *name) 35 - { 36 - int lenp = strlen(path); 37 - int lenn = strlen(name); 38 - int len; 39 - int needslash = 1; 40 - char *str; 41 - 42 - len = lenp + lenn + 2; 43 - if ((lenp > 0) && (path[lenp-1] == '/')) { 44 - needslash = 0; 45 - len--; 46 - } 47 - 48 - str = xmalloc(len); 49 - memcpy(str, path, lenp); 50 - if (needslash) { 51 - str[lenp] = '/'; 52 - lenp++; 53 - } 54 - memcpy(str+lenp, name, lenn+1); 55 - return str; 56 - } 33 + int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */ 57 34 58 35 static void fill_fullpaths(struct node *tree, const char *prefix) 59 36 { ··· 81 104 fprintf(stderr, "\t\tSet the physical boot cpu\n"); 82 105 fprintf(stderr, "\t-f\n"); 83 106 fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n"); 107 + fprintf(stderr, "\t-s\n"); 108 + fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n"); 84 109 fprintf(stderr, "\t-v\n"); 85 110 fprintf(stderr, "\t\tPrint DTC version and exit\n"); 111 + fprintf(stderr, "\t-H <phandle format>\n"); 112 + fprintf(stderr, "\t\tphandle formats are:\n"); 113 + fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n"); 114 + fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n"); 115 + fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n"); 86 116 exit(3); 87 117 } 88 118 ··· 99 115 const char *inform = "dts"; 100 116 const char *outform = "dts"; 101 117 const char *outname = "-"; 102 - int force = 0, check = 0; 118 + int force = 0, check = 0, sort = 0; 103 119 const char *arg; 104 120 int opt; 105 121 FILE *outf = NULL; ··· 111 127 minsize = 0; 112 128 padsize = 0; 113 129 114 - while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:v")) != EOF) { 130 + while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:s")) != EOF) { 115 131 switch (opt) { 116 132 case 'I': 117 133 inform = optarg; ··· 149 165 case 'v': 150 166 printf("Version: %s\n", DTC_VERSION); 151 167 exit(0); 168 + case 'H': 169 + if (streq(optarg, "legacy")) 170 + phandle_format = PHANDLE_LEGACY; 171 + else if (streq(optarg, "epapr")) 172 + phandle_format = PHANDLE_EPAPR; 173 + else if (streq(optarg, "both")) 174 + phandle_format = PHANDLE_BOTH; 175 + else 176 + die("Invalid argument \"%s\" to -H option\n", 177 + optarg); 178 + break; 179 + 180 + case 's': 181 + sort = 1; 182 + break; 183 + 152 184 case 'h': 153 185 default: 154 186 usage(); ··· 181 181 /* minsize and padsize are mutually exclusive */ 182 182 if (minsize && padsize) 183 183 die("Can't set both -p and -S\n"); 184 + 185 + if (minsize) 186 + fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n"); 184 187 185 188 fprintf(stderr, "DTC: %s->%s on file \"%s\"\n", 186 189 inform, outform, arg); ··· 203 200 fill_fullpaths(bi->dt, ""); 204 201 process_checks(force, bi); 205 202 203 + if (sort) 204 + sort_tree(bi); 206 205 207 206 if (streq(outname, "-")) { 208 207 outf = stdout;
+38 -39
scripts/dtc/dtc.h
··· 34 34 #include <libfdt_env.h> 35 35 #include <fdt.h> 36 36 37 + #include "util.h" 38 + 39 + #ifdef DEBUG 40 + #define debug(fmt,args...) printf(fmt, ##args) 41 + #else 42 + #define debug(fmt,args...) 43 + #endif 44 + 45 + 37 46 #define DEFAULT_FDT_VERSION 17 47 + 38 48 /* 39 49 * Command line options 40 50 */ ··· 52 42 extern int reservenum; /* Number of memory reservation slots */ 53 43 extern int minsize; /* Minimum blob size */ 54 44 extern int padsize; /* Additional padding to blob */ 45 + extern int phandle_format; /* Use linux,phandle or phandle properties */ 55 46 56 - static inline void __attribute__((noreturn)) die(char * str, ...) 57 - { 58 - va_list ap; 59 - 60 - va_start(ap, str); 61 - fprintf(stderr, "FATAL ERROR: "); 62 - vfprintf(stderr, str, ap); 63 - exit(1); 64 - } 65 - 66 - static inline void *xmalloc(size_t len) 67 - { 68 - void *new = malloc(len); 69 - 70 - if (! new) 71 - die("malloc() failed\n"); 72 - 73 - return new; 74 - } 75 - 76 - static inline void *xrealloc(void *p, size_t len) 77 - { 78 - void *new = realloc(p, len); 79 - 80 - if (! new) 81 - die("realloc() failed (len=%d)\n", len); 82 - 83 - return new; 84 - } 47 + #define PHANDLE_LEGACY 0x1 48 + #define PHANDLE_EPAPR 0x2 49 + #define PHANDLE_BOTH 0x3 85 50 86 51 typedef uint32_t cell_t; 87 52 ··· 125 140 #define MAX_NODENAME_LEN 31 126 141 127 142 /* Live trees */ 143 + struct label { 144 + char *label; 145 + struct label *next; 146 + }; 147 + 128 148 struct property { 129 149 char *name; 130 150 struct data val; 131 151 132 152 struct property *next; 133 153 134 - char *label; 154 + struct label *labels; 135 155 }; 136 156 137 157 struct node { ··· 153 163 cell_t phandle; 154 164 int addr_cells, size_cells; 155 165 156 - char *label; 166 + struct label *labels; 157 167 }; 168 + 169 + #define for_each_label(l0, l) \ 170 + for ((l) = (l0); (l); (l) = (l)->next) 158 171 159 172 #define for_each_property(n, p) \ 160 173 for ((p) = (n)->proplist; (p); (p) = (p)->next) ··· 165 172 #define for_each_child(n, c) \ 166 173 for ((c) = (n)->children; (c); (c) = (c)->next_sibling) 167 174 168 - struct property *build_property(char *name, struct data val, char *label); 175 + void add_label(struct label **labels, char *label); 176 + 177 + struct property *build_property(char *name, struct data val); 169 178 struct property *chain_property(struct property *first, struct property *list); 170 179 struct property *reverse_properties(struct property *first); 171 180 172 181 struct node *build_node(struct property *proplist, struct node *children); 173 - struct node *name_node(struct node *node, char *name, char *label); 182 + struct node *name_node(struct node *node, char *name); 174 183 struct node *chain_node(struct node *first, struct node *list); 184 + struct node *merge_nodes(struct node *old_node, struct node *new_node); 175 185 176 186 void add_property(struct node *node, struct property *prop); 177 187 void add_child(struct node *parent, struct node *child); ··· 182 186 const char *get_unitname(struct node *node); 183 187 struct property *get_property(struct node *node, const char *propname); 184 188 cell_t propval_cell(struct property *prop); 189 + struct property *get_property_by_label(struct node *tree, const char *label, 190 + struct node **node); 191 + struct marker *get_marker_label(struct node *tree, const char *label, 192 + struct node **node, struct property **prop); 185 193 struct node *get_subnode(struct node *node, const char *nodename); 186 194 struct node *get_node_by_path(struct node *tree, const char *path); 187 195 struct node *get_node_by_label(struct node *tree, const char *label); 188 196 struct node *get_node_by_phandle(struct node *tree, cell_t phandle); 189 197 struct node *get_node_by_ref(struct node *tree, const char *ref); 190 198 cell_t get_node_phandle(struct node *root, struct node *node); 199 + 200 + uint32_t guess_boot_cpuid(struct node *tree); 191 201 192 202 /* Boot info (tree plus memreserve information */ 193 203 ··· 202 200 203 201 struct reserve_info *next; 204 202 205 - char *label; 203 + struct label *labels; 206 204 }; 207 205 208 - struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len, char *label); 206 + struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len); 209 207 struct reserve_info *chain_reserve_entry(struct reserve_info *first, 210 208 struct reserve_info *list); 211 209 struct reserve_info *add_reserve_entry(struct reserve_info *list, ··· 220 218 221 219 struct boot_info *build_boot_info(struct reserve_info *reservelist, 222 220 struct node *tree, uint32_t boot_cpuid_phys); 221 + void sort_tree(struct boot_info *bi); 223 222 224 223 /* Checks */ 225 224 ··· 241 238 /* FS trees */ 242 239 243 240 struct boot_info *dt_from_fs(const char *dirname); 244 - 245 - /* misc */ 246 - 247 - char *join_path(const char *path, const char *name); 248 241 249 242 #endif /* _DTC_H */
+112 -86
scripts/dtc/flattree.c
··· 52 52 void (*string)(void *, char *, int); 53 53 void (*align)(void *, int); 54 54 void (*data)(void *, struct data); 55 - void (*beginnode)(void *, const char *); 56 - void (*endnode)(void *, const char *); 57 - void (*property)(void *, const char *); 55 + void (*beginnode)(void *, struct label *labels); 56 + void (*endnode)(void *, struct label *labels); 57 + void (*property)(void *, struct label *labels); 58 58 }; 59 59 60 60 static void bin_emit_cell(void *e, cell_t val) ··· 89 89 *dtbuf = data_append_data(*dtbuf, d.val, d.len); 90 90 } 91 91 92 - static void bin_emit_beginnode(void *e, const char *label) 92 + static void bin_emit_beginnode(void *e, struct label *labels) 93 93 { 94 94 bin_emit_cell(e, FDT_BEGIN_NODE); 95 95 } 96 96 97 - static void bin_emit_endnode(void *e, const char *label) 97 + static void bin_emit_endnode(void *e, struct label *labels) 98 98 { 99 99 bin_emit_cell(e, FDT_END_NODE); 100 100 } 101 101 102 - static void bin_emit_property(void *e, const char *label) 102 + static void bin_emit_property(void *e, struct label *labels) 103 103 { 104 104 bin_emit_cell(e, FDT_PROP); 105 105 } ··· 127 127 fprintf(f, "%s\t= . + %d\n", label, offset); 128 128 } 129 129 130 + #define ASM_EMIT_BELONG(f, fmt, ...) \ 131 + { \ 132 + fprintf((f), "\t.byte\t((" fmt ") >> 24) & 0xff\n", __VA_ARGS__); \ 133 + fprintf((f), "\t.byte\t((" fmt ") >> 16) & 0xff\n", __VA_ARGS__); \ 134 + fprintf((f), "\t.byte\t((" fmt ") >> 8) & 0xff\n", __VA_ARGS__); \ 135 + fprintf((f), "\t.byte\t(" fmt ") & 0xff\n", __VA_ARGS__); \ 136 + } 137 + 130 138 static void asm_emit_cell(void *e, cell_t val) 131 139 { 132 140 FILE *f = e; 133 141 134 - fprintf(f, "\t.long\t0x%x\n", val); 142 + fprintf(f, "\t.byte 0x%02x; .byte 0x%02x; .byte 0x%02x; .byte 0x%02x\n", 143 + (val >> 24) & 0xff, (val >> 16) & 0xff, 144 + (val >> 8) & 0xff, val & 0xff); 135 145 } 136 146 137 147 static void asm_emit_string(void *e, char *str, int len) ··· 166 156 { 167 157 FILE *f = e; 168 158 169 - fprintf(f, "\t.balign\t%d\n", a); 159 + fprintf(f, "\t.balign\t%d, 0\n", a); 170 160 } 171 161 172 162 static void asm_emit_data(void *e, struct data d) ··· 179 169 emit_offset_label(f, m->ref, m->offset); 180 170 181 171 while ((d.len - off) >= sizeof(uint32_t)) { 182 - fprintf(f, "\t.long\t0x%x\n", 183 - fdt32_to_cpu(*((uint32_t *)(d.val+off)))); 172 + asm_emit_cell(e, fdt32_to_cpu(*((uint32_t *)(d.val+off)))); 184 173 off += sizeof(uint32_t); 185 174 } 186 175 ··· 191 182 assert(off == d.len); 192 183 } 193 184 194 - static void asm_emit_beginnode(void *e, const char *label) 185 + static void asm_emit_beginnode(void *e, struct label *labels) 195 186 { 196 187 FILE *f = e; 188 + struct label *l; 197 189 198 - if (label) { 199 - fprintf(f, "\t.globl\t%s\n", label); 200 - fprintf(f, "%s:\n", label); 190 + for_each_label(labels, l) { 191 + fprintf(f, "\t.globl\t%s\n", l->label); 192 + fprintf(f, "%s:\n", l->label); 201 193 } 202 - fprintf(f, "\t.long\tFDT_BEGIN_NODE\n"); 194 + fprintf(f, "\t/* FDT_BEGIN_NODE */\n"); 195 + asm_emit_cell(e, FDT_BEGIN_NODE); 203 196 } 204 197 205 - static void asm_emit_endnode(void *e, const char *label) 198 + static void asm_emit_endnode(void *e, struct label *labels) 206 199 { 207 200 FILE *f = e; 201 + struct label *l; 208 202 209 - fprintf(f, "\t.long\tFDT_END_NODE\n"); 210 - if (label) { 211 - fprintf(f, "\t.globl\t%s_end\n", label); 212 - fprintf(f, "%s_end:\n", label); 203 + fprintf(f, "\t/* FDT_END_NODE */\n"); 204 + asm_emit_cell(e, FDT_END_NODE); 205 + for_each_label(labels, l) { 206 + fprintf(f, "\t.globl\t%s_end\n", l->label); 207 + fprintf(f, "%s_end:\n", l->label); 213 208 } 214 209 } 215 210 216 - static void asm_emit_property(void *e, const char *label) 211 + static void asm_emit_property(void *e, struct label *labels) 217 212 { 218 213 FILE *f = e; 214 + struct label *l; 219 215 220 - if (label) { 221 - fprintf(f, "\t.globl\t%s\n", label); 222 - fprintf(f, "%s:\n", label); 216 + for_each_label(labels, l) { 217 + fprintf(f, "\t.globl\t%s\n", l->label); 218 + fprintf(f, "%s:\n", l->label); 223 219 } 224 - fprintf(f, "\t.long\tFDT_PROP\n"); 220 + fprintf(f, "\t/* FDT_PROP */\n"); 221 + asm_emit_cell(e, FDT_PROP); 225 222 } 226 223 227 224 static struct emitter asm_emitter = { ··· 263 248 struct node *child; 264 249 int seen_name_prop = 0; 265 250 266 - emit->beginnode(etarget, tree->label); 251 + emit->beginnode(etarget, tree->labels); 267 252 268 253 if (vi->flags & FTF_FULLPATH) 269 254 emit->string(etarget, tree->fullpath, 0); ··· 280 265 281 266 nameoff = stringtable_insert(strbuf, prop->name); 282 267 283 - emit->property(etarget, prop->label); 268 + emit->property(etarget, prop->labels); 284 269 emit->cell(etarget, prop->val.len); 285 270 emit->cell(etarget, nameoff); 286 271 ··· 307 292 flatten_tree(child, emit, etarget, strbuf, vi); 308 293 } 309 294 310 - emit->endnode(etarget, tree->label); 295 + emit->endnode(etarget, tree->labels); 311 296 } 312 297 313 298 static struct data flatten_reserve_list(struct reserve_info *reservelist, ··· 428 413 if (padlen > 0) 429 414 blob = data_append_zeroes(blob, padlen); 430 415 431 - fwrite(blob.val, blob.len, 1, f); 432 - 433 - if (ferror(f)) 434 - die("Error writing device tree blob: %s\n", strerror(errno)); 416 + if (fwrite(blob.val, blob.len, 1, f) != 1) { 417 + if (ferror(f)) 418 + die("Error writing device tree blob: %s\n", 419 + strerror(errno)); 420 + else 421 + die("Short write on device tree blob\n"); 422 + } 435 423 436 424 /* 437 425 * data_merge() frees the right-hand element so only the blob ··· 473 455 die("Unknown device tree blob version %d\n", version); 474 456 475 457 fprintf(f, "/* autogenerated by dtc, do not edit */\n\n"); 476 - fprintf(f, "#define FDT_MAGIC 0x%x\n", FDT_MAGIC); 477 - fprintf(f, "#define FDT_BEGIN_NODE 0x%x\n", FDT_BEGIN_NODE); 478 - fprintf(f, "#define FDT_END_NODE 0x%x\n", FDT_END_NODE); 479 - fprintf(f, "#define FDT_PROP 0x%x\n", FDT_PROP); 480 - fprintf(f, "#define FDT_END 0x%x\n", FDT_END); 481 - fprintf(f, "\n"); 482 458 483 459 emit_label(f, symprefix, "blob_start"); 484 460 emit_label(f, symprefix, "header"); 485 - fprintf(f, "\t.long\tFDT_MAGIC\t\t\t\t/* magic */\n"); 486 - fprintf(f, "\t.long\t_%s_blob_abs_end - _%s_blob_start\t/* totalsize */\n", 487 - symprefix, symprefix); 488 - fprintf(f, "\t.long\t_%s_struct_start - _%s_blob_start\t/* off_dt_struct */\n", 489 - symprefix, symprefix); 490 - fprintf(f, "\t.long\t_%s_strings_start - _%s_blob_start\t/* off_dt_strings */\n", 491 - symprefix, symprefix); 492 - fprintf(f, "\t.long\t_%s_reserve_map - _%s_blob_start\t/* off_dt_strings */\n", 493 - symprefix, symprefix); 494 - fprintf(f, "\t.long\t%d\t\t\t\t\t/* version */\n", vi->version); 495 - fprintf(f, "\t.long\t%d\t\t\t\t\t/* last_comp_version */\n", 496 - vi->last_comp_version); 497 - 498 - if (vi->flags & FTF_BOOTCPUID) 499 - fprintf(f, "\t.long\t%i\t\t\t\t\t/* boot_cpuid_phys */\n", 500 - bi->boot_cpuid_phys); 501 - 502 - if (vi->flags & FTF_STRTABSIZE) 503 - fprintf(f, "\t.long\t_%s_strings_end - _%s_strings_start\t/* size_dt_strings */\n", 461 + fprintf(f, "\t/* magic */\n"); 462 + asm_emit_cell(f, FDT_MAGIC); 463 + fprintf(f, "\t/* totalsize */\n"); 464 + ASM_EMIT_BELONG(f, "_%s_blob_abs_end - _%s_blob_start", 504 465 symprefix, symprefix); 466 + fprintf(f, "\t/* off_dt_struct */\n"); 467 + ASM_EMIT_BELONG(f, "_%s_struct_start - _%s_blob_start", 468 + symprefix, symprefix); 469 + fprintf(f, "\t/* off_dt_strings */\n"); 470 + ASM_EMIT_BELONG(f, "_%s_strings_start - _%s_blob_start", 471 + symprefix, symprefix); 472 + fprintf(f, "\t/* off_mem_rsvmap */\n"); 473 + ASM_EMIT_BELONG(f, "_%s_reserve_map - _%s_blob_start", 474 + symprefix, symprefix); 475 + fprintf(f, "\t/* version */\n"); 476 + asm_emit_cell(f, vi->version); 477 + fprintf(f, "\t/* last_comp_version */\n"); 478 + asm_emit_cell(f, vi->last_comp_version); 505 479 506 - if (vi->flags & FTF_STRUCTSIZE) 507 - fprintf(f, "\t.long\t_%s_struct_end - _%s_struct_start\t/* size_dt_struct */\n", 480 + if (vi->flags & FTF_BOOTCPUID) { 481 + fprintf(f, "\t/* boot_cpuid_phys */\n"); 482 + asm_emit_cell(f, bi->boot_cpuid_phys); 483 + } 484 + 485 + if (vi->flags & FTF_STRTABSIZE) { 486 + fprintf(f, "\t/* size_dt_strings */\n"); 487 + ASM_EMIT_BELONG(f, "_%s_strings_end - _%s_strings_start", 488 + symprefix, symprefix); 489 + } 490 + 491 + if (vi->flags & FTF_STRUCTSIZE) { 492 + fprintf(f, "\t/* size_dt_struct */\n"); 493 + ASM_EMIT_BELONG(f, "_%s_struct_end - _%s_struct_start", 508 494 symprefix, symprefix); 495 + } 509 496 510 497 /* 511 498 * Reserve map entries. ··· 528 505 * as it appears .quad isn't available in some assemblers. 529 506 */ 530 507 for (re = bi->reservelist; re; re = re->next) { 531 - if (re->label) { 532 - fprintf(f, "\t.globl\t%s\n", re->label); 533 - fprintf(f, "%s:\n", re->label); 508 + struct label *l; 509 + 510 + for_each_label(re->labels, l) { 511 + fprintf(f, "\t.globl\t%s\n", l->label); 512 + fprintf(f, "%s:\n", l->label); 534 513 } 535 - fprintf(f, "\t.long\t0x%08x, 0x%08x\n", 536 - (unsigned int)(re->re.address >> 32), 537 - (unsigned int)(re->re.address & 0xffffffff)); 538 - fprintf(f, "\t.long\t0x%08x, 0x%08x\n", 539 - (unsigned int)(re->re.size >> 32), 540 - (unsigned int)(re->re.size & 0xffffffff)); 514 + ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.address >> 32)); 515 + ASM_EMIT_BELONG(f, "0x%08x", 516 + (unsigned int)(re->re.address & 0xffffffff)); 517 + ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size >> 32)); 518 + ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size & 0xffffffff)); 541 519 } 542 520 for (i = 0; i < reservenum; i++) { 543 521 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n"); ··· 548 524 549 525 emit_label(f, symprefix, "struct_start"); 550 526 flatten_tree(bi->dt, &asm_emitter, f, &strbuf, vi); 551 - fprintf(f, "\t.long\tFDT_END\n"); 527 + 528 + fprintf(f, "\t/* FDT_END */\n"); 529 + asm_emit_cell(f, FDT_END); 552 530 emit_label(f, symprefix, "struct_end"); 553 531 554 532 emit_label(f, symprefix, "strings_start"); ··· 627 601 len++; 628 602 } while ((*p++) != '\0'); 629 603 630 - str = strdup(inb->ptr); 604 + str = xstrdup(inb->ptr); 631 605 632 606 inb->ptr += len; 633 607 ··· 669 643 p++; 670 644 } 671 645 672 - return strdup(inb->base + offset); 646 + return xstrdup(inb->base + offset); 673 647 } 674 648 675 649 static struct property *flat_read_property(struct inbuf *dtbuf, ··· 689 663 690 664 val = flat_read_data(dtbuf, proplen); 691 665 692 - return build_property(name, val, NULL); 666 + return build_property(name, val); 693 667 } 694 668 695 669 ··· 714 688 if (re.size == 0) 715 689 break; 716 690 717 - new = build_reserve_entry(re.address, re.size, NULL); 691 + new = build_reserve_entry(re.address, re.size); 718 692 reservelist = add_reserve_entry(reservelist, new); 719 693 } 720 694 ··· 736 710 if (!streq(ppath, "/")) 737 711 plen++; 738 712 739 - return strdup(cpath + plen); 713 + return xstrdup(cpath + plen); 740 714 } 741 715 742 716 static struct node *unflatten_tree(struct inbuf *dtbuf, ··· 802 776 803 777 struct boot_info *dt_from_blob(const char *fname) 804 778 { 805 - struct dtc_file *dtcf; 779 + FILE *f; 806 780 uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys; 807 781 uint32_t off_dt, off_str, off_mem_rsvmap; 808 782 int rc; ··· 817 791 uint32_t val; 818 792 int flags = 0; 819 793 820 - dtcf = dtc_open_file(fname, NULL); 794 + f = srcfile_relative_open(fname, NULL); 821 795 822 - rc = fread(&magic, sizeof(magic), 1, dtcf->file); 823 - if (ferror(dtcf->file)) 796 + rc = fread(&magic, sizeof(magic), 1, f); 797 + if (ferror(f)) 824 798 die("Error reading DT blob magic number: %s\n", 825 799 strerror(errno)); 826 800 if (rc < 1) { 827 - if (feof(dtcf->file)) 801 + if (feof(f)) 828 802 die("EOF reading DT blob magic number\n"); 829 803 else 830 804 die("Mysterious short read reading magic number\n"); ··· 834 808 if (magic != FDT_MAGIC) 835 809 die("Blob has incorrect magic number\n"); 836 810 837 - rc = fread(&totalsize, sizeof(totalsize), 1, dtcf->file); 838 - if (ferror(dtcf->file)) 811 + rc = fread(&totalsize, sizeof(totalsize), 1, f); 812 + if (ferror(f)) 839 813 die("Error reading DT blob size: %s\n", strerror(errno)); 840 814 if (rc < 1) { 841 - if (feof(dtcf->file)) 815 + if (feof(f)) 842 816 die("EOF reading DT blob size\n"); 843 817 else 844 818 die("Mysterious short read reading blob size\n"); ··· 858 832 p = blob + sizeof(magic) + sizeof(totalsize); 859 833 860 834 while (sizeleft) { 861 - if (feof(dtcf->file)) 835 + if (feof(f)) 862 836 die("EOF before reading %d bytes of DT blob\n", 863 837 totalsize); 864 838 865 - rc = fread(p, 1, sizeleft, dtcf->file); 866 - if (ferror(dtcf->file)) 839 + rc = fread(p, 1, sizeleft, f); 840 + if (ferror(f)) 867 841 die("Error reading DT blob: %s\n", 868 842 strerror(errno)); 869 843 ··· 926 900 927 901 free(blob); 928 902 929 - dtc_close_file(dtcf); 903 + fclose(f); 930 904 931 905 return build_boot_info(reservelist, tree, boot_cpuid_phys); 932 906 }
+5 -7
scripts/dtc/fstree.c
··· 58 58 "WARNING: Cannot open %s: %s\n", 59 59 tmpnam, strerror(errno)); 60 60 } else { 61 - prop = build_property(strdup(de->d_name), 61 + prop = build_property(xstrdup(de->d_name), 62 62 data_copy_file(pfile, 63 - st.st_size), 64 - NULL); 63 + st.st_size)); 65 64 add_property(tree, prop); 66 65 fclose(pfile); 67 66 } ··· 68 69 struct node *newchild; 69 70 70 71 newchild = read_fstree(tmpnam); 71 - newchild = name_node(newchild, strdup(de->d_name), 72 - NULL); 72 + newchild = name_node(newchild, xstrdup(de->d_name)); 73 73 add_child(tree, newchild); 74 74 } 75 75 ··· 84 86 struct node *tree; 85 87 86 88 tree = read_fstree(dirname); 87 - tree = name_node(tree, "", NULL); 89 + tree = name_node(tree, ""); 88 90 89 - return build_boot_info(NULL, tree, 0); 91 + return build_boot_info(NULL, tree, guess_boot_cpuid(tree)); 90 92 } 91 93
+323 -22
scripts/dtc/livetree.c
··· 24 24 * Tree building functions 25 25 */ 26 26 27 - struct property *build_property(char *name, struct data val, char *label) 27 + void add_label(struct label **labels, char *label) 28 + { 29 + struct label *new; 30 + 31 + /* Make sure the label isn't already there */ 32 + for_each_label(*labels, new) 33 + if (streq(new->label, label)) 34 + return; 35 + 36 + new = xmalloc(sizeof(*new)); 37 + new->label = label; 38 + new->next = *labels; 39 + *labels = new; 40 + } 41 + 42 + struct property *build_property(char *name, struct data val) 28 43 { 29 44 struct property *new = xmalloc(sizeof(*new)); 30 45 46 + memset(new, 0, sizeof(*new)); 47 + 31 48 new->name = name; 32 49 new->val = val; 33 - 34 - new->next = NULL; 35 - 36 - new->label = label; 37 50 38 51 return new; 39 52 } ··· 91 78 return new; 92 79 } 93 80 94 - struct node *name_node(struct node *node, char *name, char * label) 81 + struct node *name_node(struct node *node, char *name) 95 82 { 96 83 assert(node->name == NULL); 97 84 98 85 node->name = name; 99 86 100 - node->label = label; 101 - 102 87 return node; 88 + } 89 + 90 + struct node *merge_nodes(struct node *old_node, struct node *new_node) 91 + { 92 + struct property *new_prop, *old_prop; 93 + struct node *new_child, *old_child; 94 + struct label *l; 95 + 96 + /* Add new node labels to old node */ 97 + for_each_label(new_node->labels, l) 98 + add_label(&old_node->labels, l->label); 99 + 100 + /* Move properties from the new node to the old node. If there 101 + * is a collision, replace the old value with the new */ 102 + while (new_node->proplist) { 103 + /* Pop the property off the list */ 104 + new_prop = new_node->proplist; 105 + new_node->proplist = new_prop->next; 106 + new_prop->next = NULL; 107 + 108 + /* Look for a collision, set new value if there is */ 109 + for_each_property(old_node, old_prop) { 110 + if (streq(old_prop->name, new_prop->name)) { 111 + /* Add new labels to old property */ 112 + for_each_label(new_prop->labels, l) 113 + add_label(&old_prop->labels, l->label); 114 + 115 + old_prop->val = new_prop->val; 116 + free(new_prop); 117 + new_prop = NULL; 118 + break; 119 + } 120 + } 121 + 122 + /* if no collision occurred, add property to the old node. */ 123 + if (new_prop) 124 + add_property(old_node, new_prop); 125 + } 126 + 127 + /* Move the override child nodes into the primary node. If 128 + * there is a collision, then merge the nodes. */ 129 + while (new_node->children) { 130 + /* Pop the child node off the list */ 131 + new_child = new_node->children; 132 + new_node->children = new_child->next_sibling; 133 + new_child->parent = NULL; 134 + new_child->next_sibling = NULL; 135 + 136 + /* Search for a collision. Merge if there is */ 137 + for_each_child(old_node, old_child) { 138 + if (streq(old_child->name, new_child->name)) { 139 + merge_nodes(old_child, new_child); 140 + new_child = NULL; 141 + break; 142 + } 143 + } 144 + 145 + /* if no collision occured, add child to the old node. */ 146 + if (new_child) 147 + add_child(old_node, new_child); 148 + } 149 + 150 + /* The new node contents are now merged into the old node. Free 151 + * the new node. */ 152 + free(new_node); 153 + 154 + return old_node; 103 155 } 104 156 105 157 struct node *chain_node(struct node *first, struct node *list) ··· 202 124 *p = child; 203 125 } 204 126 205 - struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size, 206 - char *label) 127 + struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size) 207 128 { 208 129 struct reserve_info *new = xmalloc(sizeof(*new)); 209 130 131 + memset(new, 0, sizeof(*new)); 132 + 210 133 new->re.address = address; 211 134 new->re.size = size; 212 - 213 - new->next = NULL; 214 - 215 - new->label = label; 216 135 217 136 return new; 218 137 } ··· 283 208 return fdt32_to_cpu(*((cell_t *)prop->val.val)); 284 209 } 285 210 211 + struct property *get_property_by_label(struct node *tree, const char *label, 212 + struct node **node) 213 + { 214 + struct property *prop; 215 + struct node *c; 216 + 217 + *node = tree; 218 + 219 + for_each_property(tree, prop) { 220 + struct label *l; 221 + 222 + for_each_label(prop->labels, l) 223 + if (streq(l->label, label)) 224 + return prop; 225 + } 226 + 227 + for_each_child(tree, c) { 228 + prop = get_property_by_label(c, label, node); 229 + if (prop) 230 + return prop; 231 + } 232 + 233 + *node = NULL; 234 + return NULL; 235 + } 236 + 237 + struct marker *get_marker_label(struct node *tree, const char *label, 238 + struct node **node, struct property **prop) 239 + { 240 + struct marker *m; 241 + struct property *p; 242 + struct node *c; 243 + 244 + *node = tree; 245 + 246 + for_each_property(tree, p) { 247 + *prop = p; 248 + m = p->val.markers; 249 + for_each_marker_of_type(m, LABEL) 250 + if (streq(m->ref, label)) 251 + return m; 252 + } 253 + 254 + for_each_child(tree, c) { 255 + m = get_marker_label(c, label, node, prop); 256 + if (m) 257 + return m; 258 + } 259 + 260 + *prop = NULL; 261 + *node = NULL; 262 + return NULL; 263 + } 264 + 286 265 struct node *get_subnode(struct node *node, const char *nodename) 287 266 { 288 267 struct node *child; ··· 374 245 struct node *get_node_by_label(struct node *tree, const char *label) 375 246 { 376 247 struct node *child, *node; 248 + struct label *l; 377 249 378 250 assert(label && (strlen(label) > 0)); 379 251 380 - if (tree->label && streq(tree->label, label)) 381 - return tree; 252 + for_each_label(tree->labels, l) 253 + if (streq(l->label, label)) 254 + return tree; 382 255 383 256 for_each_child(tree, child) { 384 257 node = get_node_by_label(child, label); ··· 424 293 if ((node->phandle != 0) && (node->phandle != -1)) 425 294 return node->phandle; 426 295 427 - assert(! get_property(node, "linux,phandle")); 428 - 429 296 while (get_node_by_phandle(root, phandle)) 430 297 phandle++; 431 298 432 299 node->phandle = phandle; 433 - add_property(node, 434 - build_property("linux,phandle", 435 - data_append_cell(empty_data, phandle), 436 - NULL)); 300 + 301 + if (!get_property(node, "linux,phandle") 302 + && (phandle_format & PHANDLE_LEGACY)) 303 + add_property(node, 304 + build_property("linux,phandle", 305 + data_append_cell(empty_data, phandle))); 306 + 307 + if (!get_property(node, "phandle") 308 + && (phandle_format & PHANDLE_EPAPR)) 309 + add_property(node, 310 + build_property("phandle", 311 + data_append_cell(empty_data, phandle))); 312 + 313 + /* If the node *does* have a phandle property, we must 314 + * be dealing with a self-referencing phandle, which will be 315 + * fixed up momentarily in the caller */ 437 316 438 317 return node->phandle; 318 + } 319 + 320 + uint32_t guess_boot_cpuid(struct node *tree) 321 + { 322 + struct node *cpus, *bootcpu; 323 + struct property *reg; 324 + 325 + cpus = get_node_by_path(tree, "/cpus"); 326 + if (!cpus) 327 + return 0; 328 + 329 + 330 + bootcpu = cpus->children; 331 + if (!bootcpu) 332 + return 0; 333 + 334 + reg = get_property(bootcpu, "reg"); 335 + if (!reg || (reg->val.len != sizeof(uint32_t))) 336 + return 0; 337 + 338 + /* FIXME: Sanity check node? */ 339 + 340 + return propval_cell(reg); 341 + } 342 + 343 + static int cmp_reserve_info(const void *ax, const void *bx) 344 + { 345 + const struct reserve_info *a, *b; 346 + 347 + a = *((const struct reserve_info * const *)ax); 348 + b = *((const struct reserve_info * const *)bx); 349 + 350 + if (a->re.address < b->re.address) 351 + return -1; 352 + else if (a->re.address > b->re.address) 353 + return 1; 354 + else if (a->re.size < b->re.size) 355 + return -1; 356 + else if (a->re.size > b->re.size) 357 + return 1; 358 + else 359 + return 0; 360 + } 361 + 362 + static void sort_reserve_entries(struct boot_info *bi) 363 + { 364 + struct reserve_info *ri, **tbl; 365 + int n = 0, i = 0; 366 + 367 + for (ri = bi->reservelist; 368 + ri; 369 + ri = ri->next) 370 + n++; 371 + 372 + if (n == 0) 373 + return; 374 + 375 + tbl = xmalloc(n * sizeof(*tbl)); 376 + 377 + for (ri = bi->reservelist; 378 + ri; 379 + ri = ri->next) 380 + tbl[i++] = ri; 381 + 382 + qsort(tbl, n, sizeof(*tbl), cmp_reserve_info); 383 + 384 + bi->reservelist = tbl[0]; 385 + for (i = 0; i < (n-1); i++) 386 + tbl[i]->next = tbl[i+1]; 387 + tbl[n-1]->next = NULL; 388 + 389 + free(tbl); 390 + } 391 + 392 + static int cmp_prop(const void *ax, const void *bx) 393 + { 394 + const struct property *a, *b; 395 + 396 + a = *((const struct property * const *)ax); 397 + b = *((const struct property * const *)bx); 398 + 399 + return strcmp(a->name, b->name); 400 + } 401 + 402 + static void sort_properties(struct node *node) 403 + { 404 + int n = 0, i = 0; 405 + struct property *prop, **tbl; 406 + 407 + for_each_property(node, prop) 408 + n++; 409 + 410 + if (n == 0) 411 + return; 412 + 413 + tbl = xmalloc(n * sizeof(*tbl)); 414 + 415 + for_each_property(node, prop) 416 + tbl[i++] = prop; 417 + 418 + qsort(tbl, n, sizeof(*tbl), cmp_prop); 419 + 420 + node->proplist = tbl[0]; 421 + for (i = 0; i < (n-1); i++) 422 + tbl[i]->next = tbl[i+1]; 423 + tbl[n-1]->next = NULL; 424 + 425 + free(tbl); 426 + } 427 + 428 + static int cmp_subnode(const void *ax, const void *bx) 429 + { 430 + const struct node *a, *b; 431 + 432 + a = *((const struct node * const *)ax); 433 + b = *((const struct node * const *)bx); 434 + 435 + return strcmp(a->name, b->name); 436 + } 437 + 438 + static void sort_subnodes(struct node *node) 439 + { 440 + int n = 0, i = 0; 441 + struct node *subnode, **tbl; 442 + 443 + for_each_child(node, subnode) 444 + n++; 445 + 446 + if (n == 0) 447 + return; 448 + 449 + tbl = xmalloc(n * sizeof(*tbl)); 450 + 451 + for_each_child(node, subnode) 452 + tbl[i++] = subnode; 453 + 454 + qsort(tbl, n, sizeof(*tbl), cmp_subnode); 455 + 456 + node->children = tbl[0]; 457 + for (i = 0; i < (n-1); i++) 458 + tbl[i]->next_sibling = tbl[i+1]; 459 + tbl[n-1]->next_sibling = NULL; 460 + 461 + free(tbl); 462 + } 463 + 464 + static void sort_node(struct node *node) 465 + { 466 + struct node *c; 467 + 468 + sort_properties(node); 469 + sort_subnodes(node); 470 + for_each_child(node, c) 471 + sort_node(c); 472 + } 473 + 474 + void sort_tree(struct boot_info *bi) 475 + { 476 + sort_reserve_entries(bi); 477 + sort_node(bi->dt); 439 478 }
+213 -81
scripts/dtc/srcpos.c
··· 17 17 * USA 18 18 */ 19 19 20 + #define _GNU_SOURCE 21 + 22 + #include <stdio.h> 23 + 20 24 #include "dtc.h" 21 25 #include "srcpos.h" 22 26 23 - /* 24 - * Like yylineno, this is the current open file pos. 25 - */ 26 27 27 - struct dtc_file *srcpos_file; 28 - 29 - static int dtc_open_one(struct dtc_file *file, 30 - const char *search, 31 - const char *fname) 28 + static char *dirname(const char *path) 32 29 { 30 + const char *slash = strrchr(path, '/'); 31 + 32 + if (slash) { 33 + int len = slash - path; 34 + char *dir = xmalloc(len + 1); 35 + 36 + memcpy(dir, path, len); 37 + dir[len] = '\0'; 38 + return dir; 39 + } 40 + return NULL; 41 + } 42 + 43 + struct srcfile_state *current_srcfile; /* = NULL */ 44 + 45 + /* Detect infinite include recursion. */ 46 + #define MAX_SRCFILE_DEPTH (100) 47 + static int srcfile_depth; /* = 0 */ 48 + 49 + FILE *srcfile_relative_open(const char *fname, char **fullnamep) 50 + { 51 + FILE *f; 33 52 char *fullname; 34 53 35 - if (search) { 36 - fullname = xmalloc(strlen(search) + strlen(fname) + 2); 37 - 38 - strcpy(fullname, search); 39 - strcat(fullname, "/"); 40 - strcat(fullname, fname); 41 - } else { 42 - fullname = strdup(fname); 43 - } 44 - 45 - file->file = fopen(fullname, "r"); 46 - if (!file->file) { 47 - free(fullname); 48 - return 0; 49 - } 50 - 51 - file->name = fullname; 52 - return 1; 53 - } 54 - 55 - 56 - struct dtc_file *dtc_open_file(const char *fname, 57 - const struct search_path *search) 58 - { 59 - static const struct search_path default_search = { NULL, NULL, NULL }; 60 - 61 - struct dtc_file *file; 62 - const char *slash; 63 - 64 - file = xmalloc(sizeof(struct dtc_file)); 65 - 66 - slash = strrchr(fname, '/'); 67 - if (slash) { 68 - char *dir = xmalloc(slash - fname + 1); 69 - 70 - memcpy(dir, fname, slash - fname); 71 - dir[slash - fname] = 0; 72 - file->dir = dir; 73 - } else { 74 - file->dir = NULL; 75 - } 76 - 77 54 if (streq(fname, "-")) { 78 - file->name = "stdin"; 79 - file->file = stdin; 80 - return file; 55 + f = stdin; 56 + fullname = xstrdup("<stdin>"); 57 + } else { 58 + if (!current_srcfile || !current_srcfile->dir 59 + || (fname[0] == '/')) 60 + fullname = xstrdup(fname); 61 + else 62 + fullname = join_path(current_srcfile->dir, fname); 63 + 64 + f = fopen(fullname, "r"); 65 + if (!f) 66 + die("Couldn't open \"%s\": %s\n", fname, 67 + strerror(errno)); 81 68 } 82 69 83 - if (fname[0] == '/') { 84 - file->file = fopen(fname, "r"); 85 - if (!file->file) 86 - goto fail; 70 + if (fullnamep) 71 + *fullnamep = fullname; 72 + else 73 + free(fullname); 87 74 88 - file->name = strdup(fname); 89 - return file; 90 - } 91 - 92 - if (!search) 93 - search = &default_search; 94 - 95 - while (search) { 96 - if (dtc_open_one(file, search->dir, fname)) 97 - return file; 98 - 99 - if (errno != ENOENT) 100 - goto fail; 101 - 102 - search = search->next; 103 - } 104 - 105 - fail: 106 - die("Couldn't open \"%s\": %s\n", fname, strerror(errno)); 75 + return f; 107 76 } 108 77 109 - void dtc_close_file(struct dtc_file *file) 78 + void srcfile_push(const char *fname) 110 79 { 111 - if (fclose(file->file)) 112 - die("Error closing \"%s\": %s\n", file->name, strerror(errno)); 80 + struct srcfile_state *srcfile; 113 81 114 - free(file->dir); 115 - free(file); 82 + if (srcfile_depth++ >= MAX_SRCFILE_DEPTH) 83 + die("Includes nested too deeply"); 84 + 85 + srcfile = xmalloc(sizeof(*srcfile)); 86 + 87 + srcfile->f = srcfile_relative_open(fname, &srcfile->name); 88 + srcfile->dir = dirname(srcfile->name); 89 + srcfile->prev = current_srcfile; 90 + 91 + srcfile->lineno = 1; 92 + srcfile->colno = 1; 93 + 94 + current_srcfile = srcfile; 95 + } 96 + 97 + int srcfile_pop(void) 98 + { 99 + struct srcfile_state *srcfile = current_srcfile; 100 + 101 + assert(srcfile); 102 + 103 + current_srcfile = srcfile->prev; 104 + 105 + if (fclose(srcfile->f)) 106 + die("Error closing \"%s\": %s\n", srcfile->name, 107 + strerror(errno)); 108 + 109 + /* FIXME: We allow the srcfile_state structure to leak, 110 + * because it could still be referenced from a location 111 + * variable being carried through the parser somewhere. To 112 + * fix this we could either allocate all the files from a 113 + * table, or use a pool allocator. */ 114 + 115 + return current_srcfile ? 1 : 0; 116 + } 117 + 118 + /* 119 + * The empty source position. 120 + */ 121 + 122 + struct srcpos srcpos_empty = { 123 + .first_line = 0, 124 + .first_column = 0, 125 + .last_line = 0, 126 + .last_column = 0, 127 + .file = NULL, 128 + }; 129 + 130 + #define TAB_SIZE 8 131 + 132 + void srcpos_update(struct srcpos *pos, const char *text, int len) 133 + { 134 + int i; 135 + 136 + pos->file = current_srcfile; 137 + 138 + pos->first_line = current_srcfile->lineno; 139 + pos->first_column = current_srcfile->colno; 140 + 141 + for (i = 0; i < len; i++) 142 + if (text[i] == '\n') { 143 + current_srcfile->lineno++; 144 + current_srcfile->colno = 1; 145 + } else if (text[i] == '\t') { 146 + current_srcfile->colno = 147 + ALIGN(current_srcfile->colno, TAB_SIZE); 148 + } else { 149 + current_srcfile->colno++; 150 + } 151 + 152 + pos->last_line = current_srcfile->lineno; 153 + pos->last_column = current_srcfile->colno; 154 + } 155 + 156 + struct srcpos * 157 + srcpos_copy(struct srcpos *pos) 158 + { 159 + struct srcpos *pos_new; 160 + 161 + pos_new = xmalloc(sizeof(struct srcpos)); 162 + memcpy(pos_new, pos, sizeof(struct srcpos)); 163 + 164 + return pos_new; 165 + } 166 + 167 + 168 + 169 + void 170 + srcpos_dump(struct srcpos *pos) 171 + { 172 + printf("file : \"%s\"\n", 173 + pos->file ? (char *) pos->file : "<no file>"); 174 + printf("first_line : %d\n", pos->first_line); 175 + printf("first_column: %d\n", pos->first_column); 176 + printf("last_line : %d\n", pos->last_line); 177 + printf("last_column : %d\n", pos->last_column); 178 + printf("file : %s\n", pos->file->name); 179 + } 180 + 181 + 182 + char * 183 + srcpos_string(struct srcpos *pos) 184 + { 185 + const char *fname = "<no-file>"; 186 + char *pos_str; 187 + int rc; 188 + 189 + if (pos) 190 + fname = pos->file->name; 191 + 192 + 193 + if (pos->first_line != pos->last_line) 194 + rc = asprintf(&pos_str, "%s:%d.%d-%d.%d", fname, 195 + pos->first_line, pos->first_column, 196 + pos->last_line, pos->last_column); 197 + else if (pos->first_column != pos->last_column) 198 + rc = asprintf(&pos_str, "%s:%d.%d-%d", fname, 199 + pos->first_line, pos->first_column, 200 + pos->last_column); 201 + else 202 + rc = asprintf(&pos_str, "%s:%d.%d", fname, 203 + pos->first_line, pos->first_column); 204 + 205 + if (rc == -1) 206 + die("Couldn't allocate in srcpos string"); 207 + 208 + return pos_str; 209 + } 210 + 211 + void 212 + srcpos_verror(struct srcpos *pos, char const *fmt, va_list va) 213 + { 214 + const char *srcstr; 215 + 216 + srcstr = srcpos_string(pos); 217 + 218 + fprintf(stdout, "Error: %s ", srcstr); 219 + vfprintf(stdout, fmt, va); 220 + fprintf(stdout, "\n"); 221 + } 222 + 223 + void 224 + srcpos_error(struct srcpos *pos, char const *fmt, ...) 225 + { 226 + va_list va; 227 + 228 + va_start(va, fmt); 229 + srcpos_verror(pos, fmt, va); 230 + va_end(va); 231 + } 232 + 233 + 234 + void 235 + srcpos_warn(struct srcpos *pos, char const *fmt, ...) 236 + { 237 + const char *srcstr; 238 + va_list va; 239 + va_start(va, fmt); 240 + 241 + srcstr = srcpos_string(pos); 242 + 243 + fprintf(stderr, "Warning: %s ", srcstr); 244 + vfprintf(stderr, fmt, va); 245 + fprintf(stderr, "\n"); 246 + 247 + va_end(va); 116 248 }
+55 -54
scripts/dtc/srcpos.h
··· 17 17 * USA 18 18 */ 19 19 20 - /* 21 - * Augment the standard YYLTYPE with a filenum index into an 22 - * array of all opened filenames. 23 - */ 20 + #ifndef _SRCPOS_H_ 21 + #define _SRCPOS_H_ 24 22 25 23 #include <stdio.h> 26 24 27 - struct dtc_file { 25 + struct srcfile_state { 26 + FILE *f; 27 + char *name; 28 28 char *dir; 29 - const char *name; 30 - FILE *file; 29 + int lineno, colno; 30 + struct srcfile_state *prev; 31 31 }; 32 32 33 - #if ! defined(YYLTYPE) && ! defined(YYLTYPE_IS_DECLARED) 34 - typedef struct YYLTYPE { 33 + extern struct srcfile_state *current_srcfile; /* = NULL */ 34 + 35 + FILE *srcfile_relative_open(const char *fname, char **fullnamep); 36 + void srcfile_push(const char *fname); 37 + int srcfile_pop(void); 38 + 39 + struct srcpos { 35 40 int first_line; 36 41 int first_column; 37 42 int last_line; 38 43 int last_column; 39 - struct dtc_file *file; 40 - } YYLTYPE; 41 - 42 - #define YYLTYPE_IS_DECLARED 1 43 - #define YYLTYPE_IS_TRIVIAL 1 44 - #endif 45 - 46 - /* Cater to old parser templates. */ 47 - #ifndef YYID 48 - #define YYID(n) (n) 49 - #endif 50 - 51 - #define YYLLOC_DEFAULT(Current, Rhs, N) \ 52 - do \ 53 - if (YYID (N)) \ 54 - { \ 55 - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ 56 - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ 57 - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ 58 - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ 59 - (Current).file = YYRHSLOC (Rhs, N).file; \ 60 - } \ 61 - else \ 62 - { \ 63 - (Current).first_line = (Current).last_line = \ 64 - YYRHSLOC (Rhs, 0).last_line; \ 65 - (Current).first_column = (Current).last_column = \ 66 - YYRHSLOC (Rhs, 0).last_column; \ 67 - (Current).file = YYRHSLOC (Rhs, 0).file; \ 68 - } \ 69 - while (YYID (0)) 70 - 71 - 72 - 73 - extern void yyerror(char const *); 74 - extern void yyerrorf(char const *, ...) __attribute__((format(printf, 1, 2))); 75 - 76 - extern struct dtc_file *srcpos_file; 77 - 78 - struct search_path { 79 - const char *dir; /* NULL for current directory */ 80 - struct search_path *prev, *next; 44 + struct srcfile_state *file; 81 45 }; 82 46 83 - extern struct dtc_file *dtc_open_file(const char *fname, 84 - const struct search_path *search); 85 - extern void dtc_close_file(struct dtc_file *file); 47 + #define YYLTYPE struct srcpos 48 + 49 + #define YYLLOC_DEFAULT(Current, Rhs, N) \ 50 + do { \ 51 + if (N) { \ 52 + (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ 53 + (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ 54 + (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ 55 + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ 56 + (Current).file = YYRHSLOC(Rhs, N).file; \ 57 + } else { \ 58 + (Current).first_line = (Current).last_line = \ 59 + YYRHSLOC(Rhs, 0).last_line; \ 60 + (Current).first_column = (Current).last_column = \ 61 + YYRHSLOC(Rhs, 0).last_column; \ 62 + (Current).file = YYRHSLOC (Rhs, 0).file; \ 63 + } \ 64 + } while (0) 65 + 66 + 67 + /* 68 + * Fictional source position used for IR nodes that are 69 + * created without otherwise knowing a true source position. 70 + * For example,constant definitions from the command line. 71 + */ 72 + extern struct srcpos srcpos_empty; 73 + 74 + extern void srcpos_update(struct srcpos *pos, const char *text, int len); 75 + extern struct srcpos *srcpos_copy(struct srcpos *pos); 76 + extern char *srcpos_string(struct srcpos *pos); 77 + extern void srcpos_dump(struct srcpos *pos); 78 + 79 + extern void srcpos_verror(struct srcpos *pos, char const *, va_list va) 80 + __attribute__((format(printf, 2, 0))); 81 + extern void srcpos_error(struct srcpos *pos, char const *, ...) 82 + __attribute__((format(printf, 2, 3))); 83 + extern void srcpos_warn(struct srcpos *pos, char const *, ...) 84 + __attribute__((format(printf, 2, 3))); 85 + 86 + #endif /* _SRCPOS_H_ */
+26 -22
scripts/dtc/treesource.c
··· 32 32 the_boot_info = NULL; 33 33 treesource_error = 0; 34 34 35 - srcpos_file = dtc_open_file(fname, NULL); 36 - yyin = srcpos_file->file; 35 + srcfile_push(fname); 36 + yyin = current_srcfile->f; 37 37 38 38 if (yyparse() != 0) 39 39 die("Unable to parse input tree\n"); ··· 63 63 { 64 64 const char *str = val.val; 65 65 int i; 66 - int newchunk = 1; 67 66 struct marker *m = val.markers; 68 67 69 68 assert(str[val.len-1] == '\0'); 70 69 70 + while (m && (m->offset == 0)) { 71 + if (m->type == LABEL) 72 + fprintf(f, "%s: ", m->ref); 73 + m = m->next; 74 + } 75 + fprintf(f, "\""); 76 + 71 77 for (i = 0; i < (val.len-1); i++) { 72 78 char c = str[i]; 73 - 74 - if (newchunk) { 75 - while (m && (m->offset <= i)) { 76 - if (m->type == LABEL) { 77 - assert(m->offset == i); 78 - fprintf(f, "%s: ", m->ref); 79 - } 80 - m = m->next; 81 - } 82 - fprintf(f, "\""); 83 - newchunk = 0; 84 - } 85 79 86 80 switch (c) { 87 81 case '\a': ··· 107 113 break; 108 114 case '\0': 109 115 fprintf(f, "\", "); 110 - newchunk = 1; 116 + while (m && (m->offset < i)) { 117 + if (m->type == LABEL) { 118 + assert(m->offset == (i+1)); 119 + fprintf(f, "%s: ", m->ref); 120 + } 121 + m = m->next; 122 + } 123 + fprintf(f, "\""); 111 124 break; 112 125 default: 113 126 if (isprint(c)) ··· 235 234 { 236 235 struct property *prop; 237 236 struct node *child; 237 + struct label *l; 238 238 239 239 write_prefix(f, level); 240 - if (tree->label) 241 - fprintf(f, "%s: ", tree->label); 240 + for_each_label(tree->labels, l) 241 + fprintf(f, "%s: ", l->label); 242 242 if (tree->name && (*tree->name)) 243 243 fprintf(f, "%s {\n", tree->name); 244 244 else ··· 247 245 248 246 for_each_property(tree, prop) { 249 247 write_prefix(f, level+1); 250 - if (prop->label) 251 - fprintf(f, "%s: ", prop->label); 248 + for_each_label(prop->labels, l) 249 + fprintf(f, "%s: ", l->label); 252 250 fprintf(f, "%s", prop->name); 253 251 write_propval(f, prop); 254 252 } ··· 268 266 fprintf(f, "/dts-v1/;\n\n"); 269 267 270 268 for (re = bi->reservelist; re; re = re->next) { 271 - if (re->label) 272 - fprintf(f, "%s: ", re->label); 269 + struct label *l; 270 + 271 + for_each_label(re->labels, l) 272 + fprintf(f, "%s: ", l->label); 273 273 fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n", 274 274 (unsigned long long)re->re.address, 275 275 (unsigned long long)re->re.size);
+59
scripts/dtc/util.c
··· 1 + /* 2 + * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. 3 + * 4 + * This program is free software; you can redistribute it and/or 5 + * modify it under the terms of the GNU General Public License as 6 + * published by the Free Software Foundation; either version 2 of the 7 + * License, or (at your option) any later version. 8 + * 9 + * This program is distributed in the hope that it will be useful, 10 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 + * General Public License for more details. 13 + * 14 + * You should have received a copy of the GNU General Public License 15 + * along with this program; if not, write to the Free Software 16 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 17 + * USA 18 + */ 19 + 20 + #include <stdio.h> 21 + #include <stdlib.h> 22 + #include <stdarg.h> 23 + #include <string.h> 24 + 25 + #include "util.h" 26 + 27 + char *xstrdup(const char *s) 28 + { 29 + int len = strlen(s) + 1; 30 + char *dup = xmalloc(len); 31 + 32 + memcpy(dup, s, len); 33 + 34 + return dup; 35 + } 36 + 37 + char *join_path(const char *path, const char *name) 38 + { 39 + int lenp = strlen(path); 40 + int lenn = strlen(name); 41 + int len; 42 + int needslash = 1; 43 + char *str; 44 + 45 + len = lenp + lenn + 2; 46 + if ((lenp > 0) && (path[lenp-1] == '/')) { 47 + needslash = 0; 48 + len--; 49 + } 50 + 51 + str = xmalloc(len); 52 + memcpy(str, path, lenp); 53 + if (needslash) { 54 + str[lenp] = '/'; 55 + lenp++; 56 + } 57 + memcpy(str+lenp, name, lenn+1); 58 + return str; 59 + }
+56
scripts/dtc/util.h
··· 1 + #ifndef _UTIL_H 2 + #define _UTIL_H 3 + 4 + /* 5 + * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. 6 + * 7 + * This program is free software; you can redistribute it and/or 8 + * modify it under the terms of the GNU General Public License as 9 + * published by the Free Software Foundation; either version 2 of the 10 + * License, or (at your option) any later version. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 + * General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 + * USA 21 + */ 22 + 23 + static inline void __attribute__((noreturn)) die(char * str, ...) 24 + { 25 + va_list ap; 26 + 27 + va_start(ap, str); 28 + fprintf(stderr, "FATAL ERROR: "); 29 + vfprintf(stderr, str, ap); 30 + exit(1); 31 + } 32 + 33 + static inline void *xmalloc(size_t len) 34 + { 35 + void *new = malloc(len); 36 + 37 + if (!new) 38 + die("malloc() failed\n"); 39 + 40 + return new; 41 + } 42 + 43 + static inline void *xrealloc(void *p, size_t len) 44 + { 45 + void *new = realloc(p, len); 46 + 47 + if (!new) 48 + die("realloc() failed (len=%d)\n", len); 49 + 50 + return new; 51 + } 52 + 53 + extern char *xstrdup(const char *s); 54 + extern char *join_path(const char *path, const char *name); 55 + 56 + #endif /* _UTIL_H */
+1 -1
scripts/dtc/version_gen.h
··· 1 - #define DTC_VERSION "DTC 1.2.0" 1 + #define DTC_VERSION "DTC 1.2.0-g37c0b6a0"