aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/dtc/dtc-parser.tab.c_shipped469
-rw-r--r--scripts/dtc/dtc-parser.tab.h_shipped36
-rw-r--r--scripts/dtc/dtc.c119
-rw-r--r--scripts/dtc/dtc.h1
-rw-r--r--scripts/dtc/srcpos.c6
-rwxr-xr-xscripts/dtc/update-dtc-source.sh54
-rw-r--r--scripts/dtc/util.c141
-rw-r--r--scripts/dtc/util.h107
-rw-r--r--scripts/dtc/version_gen.h2
9 files changed, 570 insertions, 365 deletions
diff --git a/scripts/dtc/dtc-parser.tab.c_shipped b/scripts/dtc/dtc-parser.tab.c_shipped
index ee1d8c3042fb..c8769d550cfb 100644
--- a/scripts/dtc/dtc-parser.tab.c_shipped
+++ b/scripts/dtc/dtc-parser.tab.c_shipped
@@ -1,8 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.5. */ 1/* A Bison parser, made by GNU Bison 2.7.12-4996. */
2 2
3/* Bison implementation for Yacc-like parsers in C 3/* Bison implementation for Yacc-like parsers in C
4 4
5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. 5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6 6
7 This program is free software: you can redistribute it and/or modify 7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@
44#define YYBISON 1 44#define YYBISON 1
45 45
46/* Bison version. */ 46/* Bison version. */
47#define YYBISON_VERSION "2.5" 47#define YYBISON_VERSION "2.7.12-4996"
48 48
49/* Skeleton name. */ 49/* Skeleton name. */
50#define YYSKELETON_NAME "yacc.c" 50#define YYSKELETON_NAME "yacc.c"
@@ -58,14 +58,11 @@
58/* Pull parsers. */ 58/* Pull parsers. */
59#define YYPULL 1 59#define YYPULL 1
60 60
61/* Using locations. */
62#define YYLSP_NEEDED 0
63 61
64 62
65 63
66/* Copy the first part of user declarations. */ 64/* Copy the first part of user declarations. */
67 65/* Line 371 of yacc.c */
68/* Line 268 of yacc.c */
69#line 21 "dtc-parser.y" 66#line 21 "dtc-parser.y"
70 67
71#include <stdio.h> 68#include <stdio.h>
@@ -85,14 +82,16 @@ extern int treesource_error;
85static unsigned long long eval_literal(const char *s, int base, int bits); 82static unsigned long long eval_literal(const char *s, int base, int bits);
86static unsigned char eval_char_literal(const char *s); 83static unsigned char eval_char_literal(const char *s);
87 84
85/* Line 371 of yacc.c */
86#line 87 "dtc-parser.tab.c"
88 87
89/* Line 268 of yacc.c */ 88# ifndef YY_NULL
90#line 91 "dtc-parser.tab.c" 89# if defined __cplusplus && 201103L <= __cplusplus
91 90# define YY_NULL nullptr
92/* Enabling traces. */ 91# else
93#ifndef YYDEBUG 92# define YY_NULL 0
94# define YYDEBUG 0 93# endif
95#endif 94# endif
96 95
97/* Enabling verbose error messages. */ 96/* Enabling verbose error messages. */
98#ifdef YYERROR_VERBOSE 97#ifdef YYERROR_VERBOSE
@@ -102,11 +101,17 @@ static unsigned char eval_char_literal(const char *s);
102# define YYERROR_VERBOSE 0 101# define YYERROR_VERBOSE 0
103#endif 102#endif
104 103
105/* Enabling the token table. */ 104/* In a future release of Bison, this section will be replaced
106#ifndef YYTOKEN_TABLE 105 by #include "dtc-parser.tab.h". */
107# define YYTOKEN_TABLE 0 106#ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED
107# define YY_YY_DTC_PARSER_TAB_H_INCLUDED
108/* Enabling traces. */
109#ifndef YYDEBUG
110# define YYDEBUG 0
111#endif
112#if YYDEBUG
113extern int yydebug;
108#endif 114#endif
109
110 115
111/* Tokens. */ 116/* Tokens. */
112#ifndef YYTOKENTYPE 117#ifndef YYTOKENTYPE
@@ -140,12 +145,10 @@ static unsigned char eval_char_literal(const char *s);
140#endif 145#endif
141 146
142 147
143
144#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 148#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
145typedef union YYSTYPE 149typedef union YYSTYPE
146{ 150{
147 151/* Line 387 of yacc.c */
148/* Line 293 of yacc.c */
149#line 40 "dtc-parser.y" 152#line 40 "dtc-parser.y"
150 153
151 char *propnodename; 154 char *propnodename;
@@ -168,21 +171,36 @@ typedef union YYSTYPE
168 uint64_t integer; 171 uint64_t integer;
169 172
170 173
171 174/* Line 387 of yacc.c */
172/* Line 293 of yacc.c */ 175#line 176 "dtc-parser.tab.c"
173#line 174 "dtc-parser.tab.c"
174} YYSTYPE; 176} YYSTYPE;
175# define YYSTYPE_IS_TRIVIAL 1 177# define YYSTYPE_IS_TRIVIAL 1
176# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 178# define yystype YYSTYPE /* obsolescent; will be withdrawn */
177# define YYSTYPE_IS_DECLARED 1 179# define YYSTYPE_IS_DECLARED 1
178#endif 180#endif
179 181
182extern YYSTYPE yylval;
180 183
181/* Copy the second part of user declarations. */ 184#ifdef YYPARSE_PARAM
185#if defined __STDC__ || defined __cplusplus
186int yyparse (void *YYPARSE_PARAM);
187#else
188int yyparse ();
189#endif
190#else /* ! YYPARSE_PARAM */
191#if defined __STDC__ || defined __cplusplus
192int yyparse (void);
193#else
194int yyparse ();
195#endif
196#endif /* ! YYPARSE_PARAM */
182 197
198#endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */
183 199
184/* Line 343 of yacc.c */ 200/* Copy the second part of user declarations. */
185#line 186 "dtc-parser.tab.c" 201
202/* Line 390 of yacc.c */
203#line 204 "dtc-parser.tab.c"
186 204
187#ifdef short 205#ifdef short
188# undef short 206# undef short
@@ -235,24 +253,33 @@ typedef short int yytype_int16;
235# if defined YYENABLE_NLS && YYENABLE_NLS 253# if defined YYENABLE_NLS && YYENABLE_NLS
236# if ENABLE_NLS 254# if ENABLE_NLS
237# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ 255# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
238# define YY_(msgid) dgettext ("bison-runtime", msgid) 256# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
239# endif 257# endif
240# endif 258# endif
241# ifndef YY_ 259# ifndef YY_
242# define YY_(msgid) msgid 260# define YY_(Msgid) Msgid
261# endif
262#endif
263
264#ifndef __attribute__
265/* This feature is available in gcc versions 2.5 and later. */
266# if (! defined __GNUC__ || __GNUC__ < 2 \
267 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
268# define __attribute__(Spec) /* empty */
243# endif 269# endif
244#endif 270#endif
245 271
246/* Suppress unused-variable warnings by "using" E. */ 272/* Suppress unused-variable warnings by "using" E. */
247#if ! defined lint || defined __GNUC__ 273#if ! defined lint || defined __GNUC__
248# define YYUSE(e) ((void) (e)) 274# define YYUSE(E) ((void) (E))
249#else 275#else
250# define YYUSE(e) /* empty */ 276# define YYUSE(E) /* empty */
251#endif 277#endif
252 278
279
253/* Identity function, used to suppress warnings about constant conditions. */ 280/* Identity function, used to suppress warnings about constant conditions. */
254#ifndef lint 281#ifndef lint
255# define YYID(n) (n) 282# define YYID(N) (N)
256#else 283#else
257#if (defined __STDC__ || defined __C99__FUNC__ \ 284#if (defined __STDC__ || defined __C99__FUNC__ \
258 || defined __cplusplus || defined _MSC_VER) 285 || defined __cplusplus || defined _MSC_VER)
@@ -288,6 +315,7 @@ YYID (yyi)
288# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ 315# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
289 || defined __cplusplus || defined _MSC_VER) 316 || defined __cplusplus || defined _MSC_VER)
290# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 317# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
318 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
291# ifndef EXIT_SUCCESS 319# ifndef EXIT_SUCCESS
292# define EXIT_SUCCESS 0 320# define EXIT_SUCCESS 0
293# endif 321# endif
@@ -379,20 +407,20 @@ union yyalloc
379#endif 407#endif
380 408
381#if defined YYCOPY_NEEDED && YYCOPY_NEEDED 409#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
382/* Copy COUNT objects from FROM to TO. The source and destination do 410/* Copy COUNT objects from SRC to DST. The source and destination do
383 not overlap. */ 411 not overlap. */
384# ifndef YYCOPY 412# ifndef YYCOPY
385# if defined __GNUC__ && 1 < __GNUC__ 413# if defined __GNUC__ && 1 < __GNUC__
386# define YYCOPY(To, From, Count) \ 414# define YYCOPY(Dst, Src, Count) \
387 __builtin_memcpy (To, From, (Count) * sizeof (*(From))) 415 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
388# else 416# else
389# define YYCOPY(To, From, Count) \ 417# define YYCOPY(Dst, Src, Count) \
390 do \ 418 do \
391 { \ 419 { \
392 YYSIZE_T yyi; \ 420 YYSIZE_T yyi; \
393 for (yyi = 0; yyi < (Count); yyi++) \ 421 for (yyi = 0; yyi < (Count); yyi++) \
394 (To)[yyi] = (From)[yyi]; \ 422 (Dst)[yyi] = (Src)[yyi]; \
395 } \ 423 } \
396 while (YYID (0)) 424 while (YYID (0))
397# endif 425# endif
398# endif 426# endif
@@ -513,7 +541,7 @@ static const yytype_uint16 yyrline[] =
513}; 541};
514#endif 542#endif
515 543
516#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE 544#if YYDEBUG || YYERROR_VERBOSE || 0
517/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 545/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
518 First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 546 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
519static const char *const yytname[] = 547static const char *const yytname[] =
@@ -530,7 +558,7 @@ static const char *const yytname[] =
530 "integer_expr", "integer_trinary", "integer_or", "integer_and", 558 "integer_expr", "integer_trinary", "integer_or", "integer_and",
531 "integer_bitor", "integer_bitxor", "integer_bitand", "integer_eq", 559 "integer_bitor", "integer_bitxor", "integer_bitand", "integer_eq",
532 "integer_rela", "integer_shift", "integer_add", "integer_mul", 560 "integer_rela", "integer_shift", "integer_add", "integer_mul",
533 "integer_unary", "bytestring", "subnodes", "subnode", 0 561 "integer_unary", "bytestring", "subnodes", "subnode", YY_NULL
534}; 562};
535#endif 563#endif
536 564
@@ -655,10 +683,10 @@ static const yytype_uint8 yytable[] =
655 137, 0, 73, 139 683 137, 0, 73, 139
656}; 684};
657 685
658#define yypact_value_is_default(yystate) \ 686#define yypact_value_is_default(Yystate) \
659 ((yystate) == (-78)) 687 (!!((Yystate) == (-78)))
660 688
661#define yytable_value_is_error(yytable_value) \ 689#define yytable_value_is_error(Yytable_value) \
662 YYID (0) 690 YYID (0)
663 691
664static const yytype_int16 yycheck[] = 692static const yytype_int16 yycheck[] =
@@ -727,62 +755,35 @@ static const yytype_uint8 yystos[] =
727 755
728#define YYRECOVERING() (!!yyerrstatus) 756#define YYRECOVERING() (!!yyerrstatus)
729 757
730#define YYBACKUP(Token, Value) \ 758#define YYBACKUP(Token, Value) \
731do \ 759do \
732 if (yychar == YYEMPTY && yylen == 1) \ 760 if (yychar == YYEMPTY) \
733 { \ 761 { \
734 yychar = (Token); \ 762 yychar = (Token); \
735 yylval = (Value); \ 763 yylval = (Value); \
736 YYPOPSTACK (1); \ 764 YYPOPSTACK (yylen); \
737 goto yybackup; \ 765 yystate = *yyssp; \
738 } \ 766 goto yybackup; \
739 else \ 767 } \
740 { \ 768 else \
769 { \
741 yyerror (YY_("syntax error: cannot back up")); \ 770 yyerror (YY_("syntax error: cannot back up")); \
742 YYERROR; \ 771 YYERROR; \
743 } \ 772 } \
744while (YYID (0)) 773while (YYID (0))
745 774
746 775/* Error token number */
747#define YYTERROR 1 776#define YYTERROR 1
748#define YYERRCODE 256 777#define YYERRCODE 256
749 778
750 779
751/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
752 If N is 0, then set CURRENT to the empty location which ends
753 the previous symbol: RHS[0] (always defined). */
754
755#define YYRHSLOC(Rhs, K) ((Rhs)[K])
756#ifndef YYLLOC_DEFAULT
757# define YYLLOC_DEFAULT(Current, Rhs, N) \
758 do \
759 if (YYID (N)) \
760 { \
761 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
762 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
763 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
764 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
765 } \
766 else \
767 { \
768 (Current).first_line = (Current).last_line = \
769 YYRHSLOC (Rhs, 0).last_line; \
770 (Current).first_column = (Current).last_column = \
771 YYRHSLOC (Rhs, 0).last_column; \
772 } \
773 while (YYID (0))
774#endif
775
776
777/* This macro is provided for backward compatibility. */ 780/* This macro is provided for backward compatibility. */
778
779#ifndef YY_LOCATION_PRINT 781#ifndef YY_LOCATION_PRINT
780# define YY_LOCATION_PRINT(File, Loc) ((void) 0) 782# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
781#endif 783#endif
782 784
783 785
784/* YYLEX -- calling `yylex' with the right arguments. */ 786/* YYLEX -- calling `yylex' with the right arguments. */
785
786#ifdef YYLEX_PARAM 787#ifdef YYLEX_PARAM
787# define YYLEX yylex (YYLEX_PARAM) 788# define YYLEX yylex (YYLEX_PARAM)
788#else 789#else
@@ -832,6 +833,8 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep)
832 YYSTYPE const * const yyvaluep; 833 YYSTYPE const * const yyvaluep;
833#endif 834#endif
834{ 835{
836 FILE *yyo = yyoutput;
837 YYUSE (yyo);
835 if (!yyvaluep) 838 if (!yyvaluep)
836 return; 839 return;
837# ifdef YYPRINT 840# ifdef YYPRINT
@@ -840,11 +843,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep)
840# else 843# else
841 YYUSE (yyoutput); 844 YYUSE (yyoutput);
842# endif 845# endif
843 switch (yytype) 846 YYUSE (yytype);
844 {
845 default:
846 break;
847 }
848} 847}
849 848
850 849
@@ -1083,12 +1082,11 @@ static int
1083yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, 1082yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1084 yytype_int16 *yyssp, int yytoken) 1083 yytype_int16 *yyssp, int yytoken)
1085{ 1084{
1086 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); 1085 YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1087 YYSIZE_T yysize = yysize0; 1086 YYSIZE_T yysize = yysize0;
1088 YYSIZE_T yysize1;
1089 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 1087 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1090 /* Internationalized format string. */ 1088 /* Internationalized format string. */
1091 const char *yyformat = 0; 1089 const char *yyformat = YY_NULL;
1092 /* Arguments of yyformat. */ 1090 /* Arguments of yyformat. */
1093 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 1091 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1094 /* Number of reported tokens (one for the "unexpected", one per 1092 /* Number of reported tokens (one for the "unexpected", one per
@@ -1148,11 +1146,13 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1148 break; 1146 break;
1149 } 1147 }
1150 yyarg[yycount++] = yytname[yyx]; 1148 yyarg[yycount++] = yytname[yyx];
1151 yysize1 = yysize + yytnamerr (0, yytname[yyx]); 1149 {
1152 if (! (yysize <= yysize1 1150 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1153 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) 1151 if (! (yysize <= yysize1
1154 return 2; 1152 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1155 yysize = yysize1; 1153 return 2;
1154 yysize = yysize1;
1155 }
1156 } 1156 }
1157 } 1157 }
1158 } 1158 }
@@ -1172,10 +1172,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1172# undef YYCASE_ 1172# undef YYCASE_
1173 } 1173 }
1174 1174
1175 yysize1 = yysize + yystrlen (yyformat); 1175 {
1176 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) 1176 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1177 return 2; 1177 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1178 yysize = yysize1; 1178 return 2;
1179 yysize = yysize1;
1180 }
1179 1181
1180 if (*yymsg_alloc < yysize) 1182 if (*yymsg_alloc < yysize)
1181 { 1183 {
@@ -1231,36 +1233,26 @@ yydestruct (yymsg, yytype, yyvaluep)
1231 yymsg = "Deleting"; 1233 yymsg = "Deleting";
1232 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 1234 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1233 1235
1234 switch (yytype) 1236 YYUSE (yytype);
1235 {
1236
1237 default:
1238 break;
1239 }
1240} 1237}
1241 1238
1242 1239
1243/* Prevent warnings from -Wmissing-prototypes. */
1244#ifdef YYPARSE_PARAM
1245#if defined __STDC__ || defined __cplusplus
1246int yyparse (void *YYPARSE_PARAM);
1247#else
1248int yyparse ();
1249#endif
1250#else /* ! YYPARSE_PARAM */
1251#if defined __STDC__ || defined __cplusplus
1252int yyparse (void);
1253#else
1254int yyparse ();
1255#endif
1256#endif /* ! YYPARSE_PARAM */
1257 1240
1258 1241
1259/* The lookahead symbol. */ 1242/* The lookahead symbol. */
1260int yychar; 1243int yychar;
1261 1244
1245
1246#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1247# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1248# define YY_IGNORE_MAYBE_UNINITIALIZED_END
1249#endif
1250#ifndef YY_INITIAL_VALUE
1251# define YY_INITIAL_VALUE(Value) /* Nothing. */
1252#endif
1253
1262/* The semantic value of the lookahead symbol. */ 1254/* The semantic value of the lookahead symbol. */
1263YYSTYPE yylval; 1255YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1264 1256
1265/* Number of syntax errors so far. */ 1257/* Number of syntax errors so far. */
1266int yynerrs; 1258int yynerrs;
@@ -1300,7 +1292,7 @@ yyparse ()
1300 `yyss': related to states. 1292 `yyss': related to states.
1301 `yyvs': related to semantic values. 1293 `yyvs': related to semantic values.
1302 1294
1303 Refer to the stacks thru separate pointers, to allow yyoverflow 1295 Refer to the stacks through separate pointers, to allow yyoverflow
1304 to reallocate them elsewhere. */ 1296 to reallocate them elsewhere. */
1305 1297
1306 /* The state stack. */ 1298 /* The state stack. */
@@ -1318,7 +1310,7 @@ yyparse ()
1318 int yyn; 1310 int yyn;
1319 int yyresult; 1311 int yyresult;
1320 /* Lookahead token as an internal (translated) token number. */ 1312 /* Lookahead token as an internal (translated) token number. */
1321 int yytoken; 1313 int yytoken = 0;
1322 /* The variables used to return semantic value and location from the 1314 /* The variables used to return semantic value and location from the
1323 action routines. */ 1315 action routines. */
1324 YYSTYPE yyval; 1316 YYSTYPE yyval;
@@ -1336,9 +1328,8 @@ yyparse ()
1336 Keep to zero when no symbol should be popped. */ 1328 Keep to zero when no symbol should be popped. */
1337 int yylen = 0; 1329 int yylen = 0;
1338 1330
1339 yytoken = 0; 1331 yyssp = yyss = yyssa;
1340 yyss = yyssa; 1332 yyvsp = yyvs = yyvsa;
1341 yyvs = yyvsa;
1342 yystacksize = YYINITDEPTH; 1333 yystacksize = YYINITDEPTH;
1343 1334
1344 YYDPRINTF ((stderr, "Starting parse\n")); 1335 YYDPRINTF ((stderr, "Starting parse\n"));
@@ -1347,14 +1338,6 @@ yyparse ()
1347 yyerrstatus = 0; 1338 yyerrstatus = 0;
1348 yynerrs = 0; 1339 yynerrs = 0;
1349 yychar = YYEMPTY; /* Cause a token to be read. */ 1340 yychar = YYEMPTY; /* Cause a token to be read. */
1350
1351 /* Initialize stack pointers.
1352 Waste one element of value and location stack
1353 so that they stay on the same level as the state stack.
1354 The wasted elements are never initialized. */
1355 yyssp = yyss;
1356 yyvsp = yyvs;
1357
1358 goto yysetstate; 1341 goto yysetstate;
1359 1342
1360/*------------------------------------------------------------. 1343/*------------------------------------------------------------.
@@ -1495,7 +1478,9 @@ yybackup:
1495 yychar = YYEMPTY; 1478 yychar = YYEMPTY;
1496 1479
1497 yystate = yyn; 1480 yystate = yyn;
1481 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1498 *++yyvsp = yylval; 1482 *++yyvsp = yylval;
1483 YY_IGNORE_MAYBE_UNINITIALIZED_END
1499 1484
1500 goto yynewstate; 1485 goto yynewstate;
1501 1486
@@ -1532,8 +1517,7 @@ yyreduce:
1532 switch (yyn) 1517 switch (yyn)
1533 { 1518 {
1534 case 2: 1519 case 2:
1535 1520/* Line 1787 of yacc.c */
1536/* Line 1806 of yacc.c */
1537#line 110 "dtc-parser.y" 1521#line 110 "dtc-parser.y"
1538 { 1522 {
1539 the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), 1523 the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node),
@@ -1542,8 +1526,7 @@ yyreduce:
1542 break; 1526 break;
1543 1527
1544 case 3: 1528 case 3:
1545 1529/* Line 1787 of yacc.c */
1546/* Line 1806 of yacc.c */
1547#line 118 "dtc-parser.y" 1530#line 118 "dtc-parser.y"
1548 { 1531 {
1549 (yyval.re) = NULL; 1532 (yyval.re) = NULL;
@@ -1551,8 +1534,7 @@ yyreduce:
1551 break; 1534 break;
1552 1535
1553 case 4: 1536 case 4:
1554 1537/* Line 1787 of yacc.c */
1555/* Line 1806 of yacc.c */
1556#line 122 "dtc-parser.y" 1538#line 122 "dtc-parser.y"
1557 { 1539 {
1558 (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); 1540 (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re));
@@ -1560,8 +1542,7 @@ yyreduce:
1560 break; 1542 break;
1561 1543
1562 case 5: 1544 case 5:
1563 1545/* Line 1787 of yacc.c */
1564/* Line 1806 of yacc.c */
1565#line 129 "dtc-parser.y" 1546#line 129 "dtc-parser.y"
1566 { 1547 {
1567 (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer)); 1548 (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer));
@@ -1569,8 +1550,7 @@ yyreduce:
1569 break; 1550 break;
1570 1551
1571 case 6: 1552 case 6:
1572 1553/* Line 1787 of yacc.c */
1573/* Line 1806 of yacc.c */
1574#line 133 "dtc-parser.y" 1554#line 133 "dtc-parser.y"
1575 { 1555 {
1576 add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref)); 1556 add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref));
@@ -1579,8 +1559,7 @@ yyreduce:
1579 break; 1559 break;
1580 1560
1581 case 7: 1561 case 7:
1582 1562/* Line 1787 of yacc.c */
1583/* Line 1806 of yacc.c */
1584#line 141 "dtc-parser.y" 1563#line 141 "dtc-parser.y"
1585 { 1564 {
1586 (yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); 1565 (yyval.node) = name_node((yyvsp[(2) - (2)].node), "");
@@ -1588,8 +1567,7 @@ yyreduce:
1588 break; 1567 break;
1589 1568
1590 case 8: 1569 case 8:
1591 1570/* Line 1787 of yacc.c */
1592/* Line 1806 of yacc.c */
1593#line 145 "dtc-parser.y" 1571#line 145 "dtc-parser.y"
1594 { 1572 {
1595 (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); 1573 (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
@@ -1597,8 +1575,7 @@ yyreduce:
1597 break; 1575 break;
1598 1576
1599 case 9: 1577 case 9:
1600 1578/* Line 1787 of yacc.c */
1601/* Line 1806 of yacc.c */
1602#line 149 "dtc-parser.y" 1579#line 149 "dtc-parser.y"
1603 { 1580 {
1604 struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref)); 1581 struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref));
@@ -1612,8 +1589,7 @@ yyreduce:
1612 break; 1589 break;
1613 1590
1614 case 10: 1591 case 10:
1615 1592/* Line 1787 of yacc.c */
1616/* Line 1806 of yacc.c */
1617#line 159 "dtc-parser.y" 1593#line 159 "dtc-parser.y"
1618 { 1594 {
1619 struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref)); 1595 struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref));
@@ -1628,8 +1604,7 @@ yyreduce:
1628 break; 1604 break;
1629 1605
1630 case 11: 1606 case 11:
1631 1607/* Line 1787 of yacc.c */
1632/* Line 1806 of yacc.c */
1633#line 173 "dtc-parser.y" 1608#line 173 "dtc-parser.y"
1634 { 1609 {
1635 (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); 1610 (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist));
@@ -1637,8 +1612,7 @@ yyreduce:
1637 break; 1612 break;
1638 1613
1639 case 12: 1614 case 12:
1640 1615/* Line 1787 of yacc.c */
1641/* Line 1806 of yacc.c */
1642#line 180 "dtc-parser.y" 1616#line 180 "dtc-parser.y"
1643 { 1617 {
1644 (yyval.proplist) = NULL; 1618 (yyval.proplist) = NULL;
@@ -1646,8 +1620,7 @@ yyreduce:
1646 break; 1620 break;
1647 1621
1648 case 13: 1622 case 13:
1649 1623/* Line 1787 of yacc.c */
1650/* Line 1806 of yacc.c */
1651#line 184 "dtc-parser.y" 1624#line 184 "dtc-parser.y"
1652 { 1625 {
1653 (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); 1626 (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist));
@@ -1655,8 +1628,7 @@ yyreduce:
1655 break; 1628 break;
1656 1629
1657 case 14: 1630 case 14:
1658 1631/* Line 1787 of yacc.c */
1659/* Line 1806 of yacc.c */
1660#line 191 "dtc-parser.y" 1632#line 191 "dtc-parser.y"
1661 { 1633 {
1662 (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data)); 1634 (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data));
@@ -1664,8 +1636,7 @@ yyreduce:
1664 break; 1636 break;
1665 1637
1666 case 15: 1638 case 15:
1667 1639/* Line 1787 of yacc.c */
1668/* Line 1806 of yacc.c */
1669#line 195 "dtc-parser.y" 1640#line 195 "dtc-parser.y"
1670 { 1641 {
1671 (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); 1642 (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data);
@@ -1673,8 +1644,7 @@ yyreduce:
1673 break; 1644 break;
1674 1645
1675 case 16: 1646 case 16:
1676 1647/* Line 1787 of yacc.c */
1677/* Line 1806 of yacc.c */
1678#line 199 "dtc-parser.y" 1648#line 199 "dtc-parser.y"
1679 { 1649 {
1680 (yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename)); 1650 (yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename));
@@ -1682,8 +1652,7 @@ yyreduce:
1682 break; 1652 break;
1683 1653
1684 case 17: 1654 case 17:
1685 1655/* Line 1787 of yacc.c */
1686/* Line 1806 of yacc.c */
1687#line 203 "dtc-parser.y" 1656#line 203 "dtc-parser.y"
1688 { 1657 {
1689 add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref)); 1658 add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref));
@@ -1692,8 +1661,7 @@ yyreduce:
1692 break; 1661 break;
1693 1662
1694 case 18: 1663 case 18:
1695 1664/* Line 1787 of yacc.c */
1696/* Line 1806 of yacc.c */
1697#line 211 "dtc-parser.y" 1665#line 211 "dtc-parser.y"
1698 { 1666 {
1699 (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); 1667 (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data));
@@ -1701,8 +1669,7 @@ yyreduce:
1701 break; 1669 break;
1702 1670
1703 case 19: 1671 case 19:
1704 1672/* Line 1787 of yacc.c */
1705/* Line 1806 of yacc.c */
1706#line 215 "dtc-parser.y" 1673#line 215 "dtc-parser.y"
1707 { 1674 {
1708 (yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data); 1675 (yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data);
@@ -1710,8 +1677,7 @@ yyreduce:
1710 break; 1677 break;
1711 1678
1712 case 20: 1679 case 20:
1713 1680/* Line 1787 of yacc.c */
1714/* Line 1806 of yacc.c */
1715#line 219 "dtc-parser.y" 1681#line 219 "dtc-parser.y"
1716 { 1682 {
1717 (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); 1683 (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
@@ -1719,8 +1685,7 @@ yyreduce:
1719 break; 1685 break;
1720 1686
1721 case 21: 1687 case 21:
1722 1688/* Line 1787 of yacc.c */
1723/* Line 1806 of yacc.c */
1724#line 223 "dtc-parser.y" 1689#line 223 "dtc-parser.y"
1725 { 1690 {
1726 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref)); 1691 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref));
@@ -1728,8 +1693,7 @@ yyreduce:
1728 break; 1693 break;
1729 1694
1730 case 22: 1695 case 22:
1731 1696/* Line 1787 of yacc.c */
1732/* Line 1806 of yacc.c */
1733#line 227 "dtc-parser.y" 1697#line 227 "dtc-parser.y"
1734 { 1698 {
1735 FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL); 1699 FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL);
@@ -1750,8 +1714,7 @@ yyreduce:
1750 break; 1714 break;
1751 1715
1752 case 23: 1716 case 23:
1753 1717/* Line 1787 of yacc.c */
1754/* Line 1806 of yacc.c */
1755#line 244 "dtc-parser.y" 1718#line 244 "dtc-parser.y"
1756 { 1719 {
1757 FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL); 1720 FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL);
@@ -1765,8 +1728,7 @@ yyreduce:
1765 break; 1728 break;
1766 1729
1767 case 24: 1730 case 24:
1768 1731/* Line 1787 of yacc.c */
1769/* Line 1806 of yacc.c */
1770#line 254 "dtc-parser.y" 1732#line 254 "dtc-parser.y"
1771 { 1733 {
1772 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1734 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
@@ -1774,8 +1736,7 @@ yyreduce:
1774 break; 1736 break;
1775 1737
1776 case 25: 1738 case 25:
1777 1739/* Line 1787 of yacc.c */
1778/* Line 1806 of yacc.c */
1779#line 261 "dtc-parser.y" 1740#line 261 "dtc-parser.y"
1780 { 1741 {
1781 (yyval.data) = empty_data; 1742 (yyval.data) = empty_data;
@@ -1783,8 +1744,7 @@ yyreduce:
1783 break; 1744 break;
1784 1745
1785 case 26: 1746 case 26:
1786 1747/* Line 1787 of yacc.c */
1787/* Line 1806 of yacc.c */
1788#line 265 "dtc-parser.y" 1748#line 265 "dtc-parser.y"
1789 { 1749 {
1790 (yyval.data) = (yyvsp[(1) - (2)].data); 1750 (yyval.data) = (yyvsp[(1) - (2)].data);
@@ -1792,8 +1752,7 @@ yyreduce:
1792 break; 1752 break;
1793 1753
1794 case 27: 1754 case 27:
1795 1755/* Line 1787 of yacc.c */
1796/* Line 1806 of yacc.c */
1797#line 269 "dtc-parser.y" 1756#line 269 "dtc-parser.y"
1798 { 1757 {
1799 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1758 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
@@ -1801,8 +1760,7 @@ yyreduce:
1801 break; 1760 break;
1802 1761
1803 case 28: 1762 case 28:
1804 1763/* Line 1787 of yacc.c */
1805/* Line 1806 of yacc.c */
1806#line 276 "dtc-parser.y" 1764#line 276 "dtc-parser.y"
1807 { 1765 {
1808 (yyval.array).data = empty_data; 1766 (yyval.array).data = empty_data;
@@ -1821,8 +1779,7 @@ yyreduce:
1821 break; 1779 break;
1822 1780
1823 case 29: 1781 case 29:
1824 1782/* Line 1787 of yacc.c */
1825/* Line 1806 of yacc.c */
1826#line 291 "dtc-parser.y" 1783#line 291 "dtc-parser.y"
1827 { 1784 {
1828 (yyval.array).data = empty_data; 1785 (yyval.array).data = empty_data;
@@ -1831,8 +1788,7 @@ yyreduce:
1831 break; 1788 break;
1832 1789
1833 case 30: 1790 case 30:
1834 1791/* Line 1787 of yacc.c */
1835/* Line 1806 of yacc.c */
1836#line 296 "dtc-parser.y" 1792#line 296 "dtc-parser.y"
1837 { 1793 {
1838 if ((yyvsp[(1) - (2)].array).bits < 64) { 1794 if ((yyvsp[(1) - (2)].array).bits < 64) {
@@ -1856,8 +1812,7 @@ yyreduce:
1856 break; 1812 break;
1857 1813
1858 case 31: 1814 case 31:
1859 1815/* Line 1787 of yacc.c */
1860/* Line 1806 of yacc.c */
1861#line 316 "dtc-parser.y" 1816#line 316 "dtc-parser.y"
1862 { 1817 {
1863 uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits); 1818 uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits);
@@ -1875,8 +1830,7 @@ yyreduce:
1875 break; 1830 break;
1876 1831
1877 case 32: 1832 case 32:
1878 1833/* Line 1787 of yacc.c */
1879/* Line 1806 of yacc.c */
1880#line 330 "dtc-parser.y" 1834#line 330 "dtc-parser.y"
1881 { 1835 {
1882 (yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref)); 1836 (yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref));
@@ -1884,8 +1838,7 @@ yyreduce:
1884 break; 1838 break;
1885 1839
1886 case 33: 1840 case 33:
1887 1841/* Line 1787 of yacc.c */
1888/* Line 1806 of yacc.c */
1889#line 337 "dtc-parser.y" 1842#line 337 "dtc-parser.y"
1890 { 1843 {
1891 (yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); 1844 (yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64);
@@ -1893,8 +1846,7 @@ yyreduce:
1893 break; 1846 break;
1894 1847
1895 case 34: 1848 case 34:
1896 1849/* Line 1787 of yacc.c */
1897/* Line 1806 of yacc.c */
1898#line 341 "dtc-parser.y" 1850#line 341 "dtc-parser.y"
1899 { 1851 {
1900 (yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal)); 1852 (yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal));
@@ -1902,8 +1854,7 @@ yyreduce:
1902 break; 1854 break;
1903 1855
1904 case 35: 1856 case 35:
1905 1857/* Line 1787 of yacc.c */
1906/* Line 1806 of yacc.c */
1907#line 345 "dtc-parser.y" 1858#line 345 "dtc-parser.y"
1908 { 1859 {
1909 (yyval.integer) = (yyvsp[(2) - (3)].integer); 1860 (yyval.integer) = (yyvsp[(2) - (3)].integer);
@@ -1911,162 +1862,139 @@ yyreduce:
1911 break; 1862 break;
1912 1863
1913 case 38: 1864 case 38:
1914 1865/* Line 1787 of yacc.c */
1915/* Line 1806 of yacc.c */
1916#line 356 "dtc-parser.y" 1866#line 356 "dtc-parser.y"
1917 { (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); } 1867 { (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); }
1918 break; 1868 break;
1919 1869
1920 case 40: 1870 case 40:
1921 1871/* Line 1787 of yacc.c */
1922/* Line 1806 of yacc.c */
1923#line 361 "dtc-parser.y" 1872#line 361 "dtc-parser.y"
1924 { (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); } 1873 { (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); }
1925 break; 1874 break;
1926 1875
1927 case 42: 1876 case 42:
1928 1877/* Line 1787 of yacc.c */
1929/* Line 1806 of yacc.c */
1930#line 366 "dtc-parser.y" 1878#line 366 "dtc-parser.y"
1931 { (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); } 1879 { (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); }
1932 break; 1880 break;
1933 1881
1934 case 44: 1882 case 44:
1935 1883/* Line 1787 of yacc.c */
1936/* Line 1806 of yacc.c */
1937#line 371 "dtc-parser.y" 1884#line 371 "dtc-parser.y"
1938 { (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); } 1885 { (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); }
1939 break; 1886 break;
1940 1887
1941 case 46: 1888 case 46:
1942 1889/* Line 1787 of yacc.c */
1943/* Line 1806 of yacc.c */
1944#line 376 "dtc-parser.y" 1890#line 376 "dtc-parser.y"
1945 { (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); } 1891 { (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); }
1946 break; 1892 break;
1947 1893
1948 case 48: 1894 case 48:
1949 1895/* Line 1787 of yacc.c */
1950/* Line 1806 of yacc.c */
1951#line 381 "dtc-parser.y" 1896#line 381 "dtc-parser.y"
1952 { (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); } 1897 { (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); }
1953 break; 1898 break;
1954 1899
1955 case 50: 1900 case 50:
1956 1901/* Line 1787 of yacc.c */
1957/* Line 1806 of yacc.c */
1958#line 386 "dtc-parser.y" 1902#line 386 "dtc-parser.y"
1959 { (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); } 1903 { (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); }
1960 break; 1904 break;
1961 1905
1962 case 51: 1906 case 51:
1963 1907/* Line 1787 of yacc.c */
1964/* Line 1806 of yacc.c */
1965#line 387 "dtc-parser.y" 1908#line 387 "dtc-parser.y"
1966 { (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); } 1909 { (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); }
1967 break; 1910 break;
1968 1911
1969 case 53: 1912 case 53:
1970 1913/* Line 1787 of yacc.c */
1971/* Line 1806 of yacc.c */
1972#line 392 "dtc-parser.y" 1914#line 392 "dtc-parser.y"
1973 { (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); } 1915 { (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); }
1974 break; 1916 break;
1975 1917
1976 case 54: 1918 case 54:
1977 1919/* Line 1787 of yacc.c */
1978/* Line 1806 of yacc.c */
1979#line 393 "dtc-parser.y" 1920#line 393 "dtc-parser.y"
1980 { (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); } 1921 { (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); }
1981 break; 1922 break;
1982 1923
1983 case 55: 1924 case 55:
1984 1925/* Line 1787 of yacc.c */
1985/* Line 1806 of yacc.c */
1986#line 394 "dtc-parser.y" 1926#line 394 "dtc-parser.y"
1987 { (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); } 1927 { (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); }
1988 break; 1928 break;
1989 1929
1990 case 56: 1930 case 56:
1991 1931/* Line 1787 of yacc.c */
1992/* Line 1806 of yacc.c */
1993#line 395 "dtc-parser.y" 1932#line 395 "dtc-parser.y"
1994 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); } 1933 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); }
1995 break; 1934 break;
1996 1935
1997 case 57: 1936 case 57:
1998 1937/* Line 1787 of yacc.c */
1999/* Line 1806 of yacc.c */
2000#line 399 "dtc-parser.y" 1938#line 399 "dtc-parser.y"
2001 { (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); } 1939 { (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); }
2002 break; 1940 break;
2003 1941
2004 case 58: 1942 case 58:
2005 1943/* Line 1787 of yacc.c */
2006/* Line 1806 of yacc.c */
2007#line 400 "dtc-parser.y" 1944#line 400 "dtc-parser.y"
2008 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); } 1945 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); }
2009 break; 1946 break;
2010 1947
2011 case 60: 1948 case 60:
2012 1949/* Line 1787 of yacc.c */
2013/* Line 1806 of yacc.c */
2014#line 405 "dtc-parser.y" 1950#line 405 "dtc-parser.y"
2015 { (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); } 1951 { (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); }
2016 break; 1952 break;
2017 1953
2018 case 61: 1954 case 61:
2019 1955/* Line 1787 of yacc.c */
2020/* Line 1806 of yacc.c */
2021#line 406 "dtc-parser.y" 1956#line 406 "dtc-parser.y"
2022 { (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); } 1957 { (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); }
2023 break; 1958 break;
2024 1959
2025 case 63: 1960 case 63:
2026 1961/* Line 1787 of yacc.c */
2027/* Line 1806 of yacc.c */
2028#line 411 "dtc-parser.y" 1962#line 411 "dtc-parser.y"
2029 { (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); } 1963 { (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); }
2030 break; 1964 break;
2031 1965
2032 case 64: 1966 case 64:
2033 1967/* Line 1787 of yacc.c */
2034/* Line 1806 of yacc.c */
2035#line 412 "dtc-parser.y" 1968#line 412 "dtc-parser.y"
2036 { (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); } 1969 { (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); }
2037 break; 1970 break;
2038 1971
2039 case 65: 1972 case 65:
2040 1973/* Line 1787 of yacc.c */
2041/* Line 1806 of yacc.c */
2042#line 413 "dtc-parser.y" 1974#line 413 "dtc-parser.y"
2043 { (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); } 1975 { (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); }
2044 break; 1976 break;
2045 1977
2046 case 68: 1978 case 68:
2047 1979/* Line 1787 of yacc.c */
2048/* Line 1806 of yacc.c */
2049#line 419 "dtc-parser.y" 1980#line 419 "dtc-parser.y"
2050 { (yyval.integer) = -(yyvsp[(2) - (2)].integer); } 1981 { (yyval.integer) = -(yyvsp[(2) - (2)].integer); }
2051 break; 1982 break;
2052 1983
2053 case 69: 1984 case 69:
2054 1985/* Line 1787 of yacc.c */
2055/* Line 1806 of yacc.c */
2056#line 420 "dtc-parser.y" 1986#line 420 "dtc-parser.y"
2057 { (yyval.integer) = ~(yyvsp[(2) - (2)].integer); } 1987 { (yyval.integer) = ~(yyvsp[(2) - (2)].integer); }
2058 break; 1988 break;
2059 1989
2060 case 70: 1990 case 70:
2061 1991/* Line 1787 of yacc.c */
2062/* Line 1806 of yacc.c */
2063#line 421 "dtc-parser.y" 1992#line 421 "dtc-parser.y"
2064 { (yyval.integer) = !(yyvsp[(2) - (2)].integer); } 1993 { (yyval.integer) = !(yyvsp[(2) - (2)].integer); }
2065 break; 1994 break;
2066 1995
2067 case 71: 1996 case 71:
2068 1997/* Line 1787 of yacc.c */
2069/* Line 1806 of yacc.c */
2070#line 426 "dtc-parser.y" 1998#line 426 "dtc-parser.y"
2071 { 1999 {
2072 (yyval.data) = empty_data; 2000 (yyval.data) = empty_data;
@@ -2074,8 +2002,7 @@ yyreduce:
2074 break; 2002 break;
2075 2003
2076 case 72: 2004 case 72:
2077 2005/* Line 1787 of yacc.c */
2078/* Line 1806 of yacc.c */
2079#line 430 "dtc-parser.y" 2006#line 430 "dtc-parser.y"
2080 { 2007 {
2081 (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); 2008 (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte));
@@ -2083,8 +2010,7 @@ yyreduce:
2083 break; 2010 break;
2084 2011
2085 case 73: 2012 case 73:
2086 2013/* Line 1787 of yacc.c */
2087/* Line 1806 of yacc.c */
2088#line 434 "dtc-parser.y" 2014#line 434 "dtc-parser.y"
2089 { 2015 {
2090 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 2016 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
@@ -2092,8 +2018,7 @@ yyreduce:
2092 break; 2018 break;
2093 2019
2094 case 74: 2020 case 74:
2095 2021/* Line 1787 of yacc.c */
2096/* Line 1806 of yacc.c */
2097#line 441 "dtc-parser.y" 2022#line 441 "dtc-parser.y"
2098 { 2023 {
2099 (yyval.nodelist) = NULL; 2024 (yyval.nodelist) = NULL;
@@ -2101,8 +2026,7 @@ yyreduce:
2101 break; 2026 break;
2102 2027
2103 case 75: 2028 case 75:
2104 2029/* Line 1787 of yacc.c */
2105/* Line 1806 of yacc.c */
2106#line 445 "dtc-parser.y" 2030#line 445 "dtc-parser.y"
2107 { 2031 {
2108 (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); 2032 (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist));
@@ -2110,8 +2034,7 @@ yyreduce:
2110 break; 2034 break;
2111 2035
2112 case 76: 2036 case 76:
2113 2037/* Line 1787 of yacc.c */
2114/* Line 1806 of yacc.c */
2115#line 449 "dtc-parser.y" 2038#line 449 "dtc-parser.y"
2116 { 2039 {
2117 print_error("syntax error: properties must precede subnodes"); 2040 print_error("syntax error: properties must precede subnodes");
@@ -2120,8 +2043,7 @@ yyreduce:
2120 break; 2043 break;
2121 2044
2122 case 77: 2045 case 77:
2123 2046/* Line 1787 of yacc.c */
2124/* Line 1806 of yacc.c */
2125#line 457 "dtc-parser.y" 2047#line 457 "dtc-parser.y"
2126 { 2048 {
2127 (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); 2049 (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename));
@@ -2129,8 +2051,7 @@ yyreduce:
2129 break; 2051 break;
2130 2052
2131 case 78: 2053 case 78:
2132 2054/* Line 1787 of yacc.c */
2133/* Line 1806 of yacc.c */
2134#line 461 "dtc-parser.y" 2055#line 461 "dtc-parser.y"
2135 { 2056 {
2136 (yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename)); 2057 (yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename));
@@ -2138,8 +2059,7 @@ yyreduce:
2138 break; 2059 break;
2139 2060
2140 case 79: 2061 case 79:
2141 2062/* Line 1787 of yacc.c */
2142/* Line 1806 of yacc.c */
2143#line 465 "dtc-parser.y" 2063#line 465 "dtc-parser.y"
2144 { 2064 {
2145 add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref)); 2065 add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref));
@@ -2148,9 +2068,8 @@ yyreduce:
2148 break; 2068 break;
2149 2069
2150 2070
2151 2071/* Line 1787 of yacc.c */
2152/* Line 1806 of yacc.c */ 2072#line 2073 "dtc-parser.tab.c"
2153#line 2154 "dtc-parser.tab.c"
2154 default: break; 2073 default: break;
2155 } 2074 }
2156 /* User semantic actions sometimes alter yychar, and that requires 2075 /* User semantic actions sometimes alter yychar, and that requires
@@ -2313,7 +2232,9 @@ yyerrlab1:
2313 YY_STACK_PRINT (yyss, yyssp); 2232 YY_STACK_PRINT (yyss, yyssp);
2314 } 2233 }
2315 2234
2235 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2316 *++yyvsp = yylval; 2236 *++yyvsp = yylval;
2237 YY_IGNORE_MAYBE_UNINITIALIZED_END
2317 2238
2318 2239
2319 /* Shift the error token. */ 2240 /* Shift the error token. */
@@ -2337,7 +2258,7 @@ yyabortlab:
2337 yyresult = 1; 2258 yyresult = 1;
2338 goto yyreturn; 2259 goto yyreturn;
2339 2260
2340#if !defined(yyoverflow) || YYERROR_VERBOSE 2261#if !defined yyoverflow || YYERROR_VERBOSE
2341/*-------------------------------------------------. 2262/*-------------------------------------------------.
2342| yyexhaustedlab -- memory exhaustion comes here. | 2263| yyexhaustedlab -- memory exhaustion comes here. |
2343`-------------------------------------------------*/ 2264`-------------------------------------------------*/
@@ -2379,8 +2300,7 @@ yyreturn:
2379} 2300}
2380 2301
2381 2302
2382 2303/* Line 2050 of yacc.c */
2383/* Line 2067 of yacc.c */
2384#line 471 "dtc-parser.y" 2304#line 471 "dtc-parser.y"
2385 2305
2386 2306
@@ -2444,4 +2364,3 @@ static unsigned char eval_char_literal(const char *s)
2444 2364
2445 return c; 2365 return c;
2446} 2366}
2447
diff --git a/scripts/dtc/dtc-parser.tab.h_shipped b/scripts/dtc/dtc-parser.tab.h_shipped
index 25d3b88c6132..b2e7a86cd85e 100644
--- a/scripts/dtc/dtc-parser.tab.h_shipped
+++ b/scripts/dtc/dtc-parser.tab.h_shipped
@@ -1,8 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.5. */ 1/* A Bison parser, made by GNU Bison 2.7.12-4996. */
2 2
3/* Bison interface for Yacc-like parsers in C 3/* Bison interface for Yacc-like parsers in C
4 4
5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. 5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6 6
7 This program is free software: you can redistribute it and/or modify 7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -30,6 +30,15 @@
30 This special exception was added by the Free Software Foundation in 30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */ 31 version 2.2 of Bison. */
32 32
33#ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED
34# define YY_YY_DTC_PARSER_TAB_H_INCLUDED
35/* Enabling traces. */
36#ifndef YYDEBUG
37# define YYDEBUG 0
38#endif
39#if YYDEBUG
40extern int yydebug;
41#endif
33 42
34/* Tokens. */ 43/* Tokens. */
35#ifndef YYTOKENTYPE 44#ifndef YYTOKENTYPE
@@ -63,12 +72,10 @@
63#endif 72#endif
64 73
65 74
66
67#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 75#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
68typedef union YYSTYPE 76typedef union YYSTYPE
69{ 77{
70 78/* Line 2053 of yacc.c */
71/* Line 2068 of yacc.c */
72#line 40 "dtc-parser.y" 79#line 40 "dtc-parser.y"
73 80
74 char *propnodename; 81 char *propnodename;
@@ -91,9 +98,8 @@ typedef union YYSTYPE
91 uint64_t integer; 98 uint64_t integer;
92 99
93 100
94 101/* Line 2053 of yacc.c */
95/* Line 2068 of yacc.c */ 102#line 103 "dtc-parser.tab.h"
96#line 97 "dtc-parser.tab.h"
97} YYSTYPE; 103} YYSTYPE;
98# define YYSTYPE_IS_TRIVIAL 1 104# define YYSTYPE_IS_TRIVIAL 1
99# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 105# define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -102,4 +108,18 @@ typedef union YYSTYPE
102 108
103extern YYSTYPE yylval; 109extern YYSTYPE yylval;
104 110
111#ifdef YYPARSE_PARAM
112#if defined __STDC__ || defined __cplusplus
113int yyparse (void *YYPARSE_PARAM);
114#else
115int yyparse ();
116#endif
117#else /* ! YYPARSE_PARAM */
118#if defined __STDC__ || defined __cplusplus
119int yyparse (void);
120#else
121int yyparse ();
122#endif
123#endif /* ! YYPARSE_PARAM */
105 124
125#endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c
index a375683c1534..e3c96536fd9d 100644
--- a/scripts/dtc/dtc.c
+++ b/scripts/dtc/dtc.c
@@ -21,8 +21,6 @@
21#include "dtc.h" 21#include "dtc.h"
22#include "srcpos.h" 22#include "srcpos.h"
23 23
24#include "version_gen.h"
25
26/* 24/*
27 * Command line options 25 * Command line options
28 */ 26 */
@@ -49,55 +47,60 @@ static void fill_fullpaths(struct node *tree, const char *prefix)
49 fill_fullpaths(child, tree->fullpath); 47 fill_fullpaths(child, tree->fullpath);
50} 48}
51 49
52static void __attribute__ ((noreturn)) usage(void) 50/* Usage related data. */
53{ 51static const char usage_synopsis[] = "dtc [options] <input file>";
54 fprintf(stderr, "Usage:\n"); 52static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv";
55 fprintf(stderr, "\tdtc [options] <input file>\n"); 53static struct option const usage_long_opts[] = {
56 fprintf(stderr, "\nOptions:\n"); 54 {"quiet", no_argument, NULL, 'q'},
57 fprintf(stderr, "\t-h\n"); 55 {"in-format", a_argument, NULL, 'I'},
58 fprintf(stderr, "\t\tThis help text\n"); 56 {"out", a_argument, NULL, 'o'},
59 fprintf(stderr, "\t-q\n"); 57 {"out-format", a_argument, NULL, 'O'},
60 fprintf(stderr, "\t\tQuiet: -q suppress warnings, -qq errors, -qqq all\n"); 58 {"out-version", a_argument, NULL, 'V'},
61 fprintf(stderr, "\t-I <input format>\n"); 59 {"out-dependency", a_argument, NULL, 'd'},
62 fprintf(stderr, "\t\tInput formats are:\n"); 60 {"reserve", a_argument, NULL, 'R'},
63 fprintf(stderr, "\t\t\tdts - device tree source text\n"); 61 {"space", a_argument, NULL, 'S'},
64 fprintf(stderr, "\t\t\tdtb - device tree blob\n"); 62 {"pad", a_argument, NULL, 'p'},
65 fprintf(stderr, "\t\t\tfs - /proc/device-tree style directory\n"); 63 {"boot-cpu", a_argument, NULL, 'b'},
66 fprintf(stderr, "\t-o <output file>\n"); 64 {"force", no_argument, NULL, 'f'},
67 fprintf(stderr, "\t-O <output format>\n"); 65 {"include", a_argument, NULL, 'i'},
68 fprintf(stderr, "\t\tOutput formats are:\n"); 66 {"sort", no_argument, NULL, 's'},
69 fprintf(stderr, "\t\t\tdts - device tree source text\n"); 67 {"phandle", a_argument, NULL, 'H'},
70 fprintf(stderr, "\t\t\tdtb - device tree blob\n"); 68 {"warning", a_argument, NULL, 'W'},
71 fprintf(stderr, "\t\t\tasm - assembler source\n"); 69 {"error", a_argument, NULL, 'E'},
72 fprintf(stderr, "\t-V <output version>\n"); 70 {"help", no_argument, NULL, 'h'},
73 fprintf(stderr, "\t\tBlob version to produce, defaults to %d (relevant for dtb\n\t\tand asm output only)\n", DEFAULT_FDT_VERSION); 71 {"version", no_argument, NULL, 'v'},
74 fprintf(stderr, "\t-d <output dependency file>\n"); 72 {NULL, no_argument, NULL, 0x0},
75 fprintf(stderr, "\t-R <number>\n"); 73};
76 fprintf(stderr, "\t\tMake space for <number> reserve map entries (relevant for \n\t\tdtb and asm output only)\n"); 74static const char * const usage_opts_help[] = {
77 fprintf(stderr, "\t-S <bytes>\n"); 75 "\n\tQuiet: -q suppress warnings, -qq errors, -qqq all",
78 fprintf(stderr, "\t\tMake the blob at least <bytes> long (extra space)\n"); 76 "\n\tInput formats are:\n"
79 fprintf(stderr, "\t-p <bytes>\n"); 77 "\t\tdts - device tree source text\n"
80 fprintf(stderr, "\t\tAdd padding to the blob of <bytes> long (extra space)\n"); 78 "\t\tdtb - device tree blob\n"
81 fprintf(stderr, "\t-b <number>\n"); 79 "\t\tfs - /proc/device-tree style directory",
82 fprintf(stderr, "\t\tSet the physical boot cpu\n"); 80 "\n\tOutput file",
83 fprintf(stderr, "\t-f\n"); 81 "\n\tOutput formats are:\n"
84 fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n"); 82 "\t\tdts - device tree source text\n"
85 fprintf(stderr, "\t-i\n"); 83 "\t\tdtb - device tree blob\n"
86 fprintf(stderr, "\t\tAdd a path to search for include files\n"); 84 "\t\tasm - assembler source",
87 fprintf(stderr, "\t-s\n"); 85 "\n\tBlob version to produce, defaults to %d (for dtb and asm output)", //, DEFAULT_FDT_VERSION);
88 fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n"); 86 "\n\tOutput dependency file",
89 fprintf(stderr, "\t-v\n"); 87 "\n\ttMake space for <number> reserve map entries (for dtb and asm output)",
90 fprintf(stderr, "\t\tPrint DTC version and exit\n"); 88 "\n\tMake the blob at least <bytes> long (extra space)",
91 fprintf(stderr, "\t-H <phandle format>\n"); 89 "\n\tAdd padding to the blob of <bytes> long (extra space)",
92 fprintf(stderr, "\t\tphandle formats are:\n"); 90 "\n\tSet the physical boot cpu",
93 fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n"); 91 "\n\tTry to produce output even if the input tree has errors",
94 fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n"); 92 "\n\tAdd a path to search for include files",
95 fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n"); 93 "\n\tSort nodes and properties before outputting (useful for comparing trees)",
96 fprintf(stderr, "\t-W [no-]<checkname>\n"); 94 "\n\tValid phandle formats are:\n"
97 fprintf(stderr, "\t-E [no-]<checkname>\n"); 95 "\t\tlegacy - \"linux,phandle\" properties only\n"
98 fprintf(stderr, "\t\t\tenable or disable warnings and errors\n"); 96 "\t\tepapr - \"phandle\" properties only\n"
99 exit(3); 97 "\t\tboth - Both \"linux,phandle\" and \"phandle\" properties",
100} 98 "\n\tEnable/disable warnings (prefix with \"no-\")",
99 "\n\tEnable/disable errors (prefix with \"no-\")",
100 "\n\tPrint this help and exit",
101 "\n\tPrint version and exit",
102 NULL,
103};
101 104
102int main(int argc, char *argv[]) 105int main(int argc, char *argv[])
103{ 106{
@@ -118,8 +121,7 @@ int main(int argc, char *argv[])
118 minsize = 0; 121 minsize = 0;
119 padsize = 0; 122 padsize = 0;
120 123
121 while ((opt = getopt(argc, argv, "hI:O:o:V:d:R:S:p:fqb:i:vH:sW:E:")) 124 while ((opt = util_getopt_long()) != EOF) {
122 != EOF) {
123 switch (opt) { 125 switch (opt) {
124 case 'I': 126 case 'I':
125 inform = optarg; 127 inform = optarg;
@@ -158,8 +160,7 @@ int main(int argc, char *argv[])
158 srcfile_add_search_path(optarg); 160 srcfile_add_search_path(optarg);
159 break; 161 break;
160 case 'v': 162 case 'v':
161 printf("Version: %s\n", DTC_VERSION); 163 util_version();
162 exit(0);
163 case 'H': 164 case 'H':
164 if (streq(optarg, "legacy")) 165 if (streq(optarg, "legacy"))
165 phandle_format = PHANDLE_LEGACY; 166 phandle_format = PHANDLE_LEGACY;
@@ -185,13 +186,14 @@ int main(int argc, char *argv[])
185 break; 186 break;
186 187
187 case 'h': 188 case 'h':
189 usage(NULL);
188 default: 190 default:
189 usage(); 191 usage("unknown option");
190 } 192 }
191 } 193 }
192 194
193 if (argc > (optind+1)) 195 if (argc > (optind+1))
194 usage(); 196 usage("missing files");
195 else if (argc < (optind+1)) 197 else if (argc < (optind+1))
196 arg = "-"; 198 arg = "-";
197 else 199 else
@@ -201,9 +203,6 @@ int main(int argc, char *argv[])
201 if (minsize && padsize) 203 if (minsize && padsize)
202 die("Can't set both -p and -S\n"); 204 die("Can't set both -p and -S\n");
203 205
204 if (minsize)
205 fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n");
206
207 if (depname) { 206 if (depname) {
208 depfile = fopen(depname, "w"); 207 depfile = fopen(depname, "w");
209 if (!depfile) 208 if (!depfile)
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h
index 3e42a071070e..264a20cf66a8 100644
--- a/scripts/dtc/dtc.h
+++ b/scripts/dtc/dtc.h
@@ -66,7 +66,6 @@ typedef uint32_t cell_t;
66#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0) 66#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
67 67
68#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) 68#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
69#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
70 69
71/* Data blobs */ 70/* Data blobs */
72enum markertype { 71enum markertype {
diff --git a/scripts/dtc/srcpos.c b/scripts/dtc/srcpos.c
index 246ab4bc0d9d..c20bc5315bc1 100644
--- a/scripts/dtc/srcpos.c
+++ b/scripts/dtc/srcpos.c
@@ -297,9 +297,9 @@ srcpos_verror(struct srcpos *pos, char const *fmt, va_list va)
297 297
298 srcstr = srcpos_string(pos); 298 srcstr = srcpos_string(pos);
299 299
300 fprintf(stdout, "Error: %s ", srcstr); 300 fprintf(stderr, "Error: %s ", srcstr);
301 vfprintf(stdout, fmt, va); 301 vfprintf(stderr, fmt, va);
302 fprintf(stdout, "\n"); 302 fprintf(stderr, "\n");
303} 303}
304 304
305void 305void
diff --git a/scripts/dtc/update-dtc-source.sh b/scripts/dtc/update-dtc-source.sh
new file mode 100755
index 000000000000..feb01ef26be4
--- /dev/null
+++ b/scripts/dtc/update-dtc-source.sh
@@ -0,0 +1,54 @@
1#!/bin/sh
2# Simple script to update the version of DTC carried by the Linux kernel
3#
4# This script assumes that the dtc and the linux git trees are in the
5# same directory. After building dtc in the dtc directory, it copies the
6# source files and generated source files into the scripts/dtc directory
7# in the kernel and creates a git commit updating them to the new
8# version.
9#
10# Usage: from the top level Linux source tree, run:
11# $ ./scripts/dtc/update-dtc-source.sh
12#
13# The script will change into the dtc tree, build and test dtc, copy the
14# relevant files into the kernel tree and create a git commit. The commit
15# message will need to be modified to reflect the version of DTC being
16# imported
17#
18# TODO:
19# This script is pretty basic, but it is seldom used so a few manual tasks
20# aren't a big deal. If anyone is interested in making it more robust, the
21# the following would be nice:
22# * Actually fail to complete if any testcase fails.
23# - The dtc "make check" target needs to return a failure
24# * Extract the version number from the dtc repo for the commit message
25# * Build dtc in the kernel tree
26# * run 'make check" on dtc built from the kernel tree
27
28set -ev
29
30DTC_UPSTREAM_PATH=`pwd`/../dtc
31DTC_LINUX_PATH=`pwd`/scripts/dtc
32
33DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \
34 srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \
35 dtc-lexer.l dtc-parser.y"
36DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h"
37
38# Build DTC
39cd $DTC_UPSTREAM_PATH
40make clean
41make check
42
43# Copy the files into the Linux tree
44cd $DTC_LINUX_PATH
45for f in $DTC_SOURCE; do
46 cp ${DTC_UPSTREAM_PATH}/${f} ${f}
47 git add ${f}
48done
49for f in $DTC_GENERATED; do
50 cp ${DTC_UPSTREAM_PATH}/$f ${f}_shipped
51 git add ${f}_shipped
52done
53
54git commit -e -v -m "scripts/dtc: Update to upstream version [CHANGEME]"
diff --git a/scripts/dtc/util.c b/scripts/dtc/util.c
index 2422c34e11df..3055c16e980d 100644
--- a/scripts/dtc/util.c
+++ b/scripts/dtc/util.c
@@ -34,6 +34,7 @@
34 34
35#include "libfdt.h" 35#include "libfdt.h"
36#include "util.h" 36#include "util.h"
37#include "version_gen.h"
37 38
38char *xstrdup(const char *s) 39char *xstrdup(const char *s)
39{ 40{
@@ -72,7 +73,7 @@ char *join_path(const char *path, const char *name)
72int util_is_printable_string(const void *data, int len) 73int util_is_printable_string(const void *data, int len)
73{ 74{
74 const char *s = data; 75 const char *s = data;
75 const char *ss; 76 const char *ss, *se;
76 77
77 /* zero length is not */ 78 /* zero length is not */
78 if (len == 0) 79 if (len == 0)
@@ -82,13 +83,19 @@ int util_is_printable_string(const void *data, int len)
82 if (s[len - 1] != '\0') 83 if (s[len - 1] != '\0')
83 return 0; 84 return 0;
84 85
85 ss = s; 86 se = s + len;
86 while (*s && isprint(*s))
87 s++;
88 87
89 /* not zero, or not done yet */ 88 while (s < se) {
90 if (*s != '\0' || (s + 1 - ss) < len) 89 ss = s;
91 return 0; 90 while (s < se && *s && isprint(*s))
91 s++;
92
93 /* not zero, or not done yet */
94 if (*s != '\0' || s == ss)
95 return 0;
96
97 s++;
98 }
92 99
93 return 1; 100 return 1;
94} 101}
@@ -191,7 +198,7 @@ char get_escape_char(const char *s, int *i)
191 return val; 198 return val;
192} 199}
193 200
194int utilfdt_read_err(const char *filename, char **buffp) 201int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len)
195{ 202{
196 int fd = 0; /* assume stdin */ 203 int fd = 0; /* assume stdin */
197 char *buf = NULL; 204 char *buf = NULL;
@@ -206,12 +213,12 @@ int utilfdt_read_err(const char *filename, char **buffp)
206 } 213 }
207 214
208 /* Loop until we have read everything */ 215 /* Loop until we have read everything */
209 buf = malloc(bufsize); 216 buf = xmalloc(bufsize);
210 do { 217 do {
211 /* Expand the buffer to hold the next chunk */ 218 /* Expand the buffer to hold the next chunk */
212 if (offset == bufsize) { 219 if (offset == bufsize) {
213 bufsize *= 2; 220 bufsize *= 2;
214 buf = realloc(buf, bufsize); 221 buf = xrealloc(buf, bufsize);
215 if (!buf) { 222 if (!buf) {
216 ret = ENOMEM; 223 ret = ENOMEM;
217 break; 224 break;
@@ -232,13 +239,20 @@ int utilfdt_read_err(const char *filename, char **buffp)
232 free(buf); 239 free(buf);
233 else 240 else
234 *buffp = buf; 241 *buffp = buf;
242 *len = bufsize;
235 return ret; 243 return ret;
236} 244}
237 245
238char *utilfdt_read(const char *filename) 246int utilfdt_read_err(const char *filename, char **buffp)
247{
248 off_t len;
249 return utilfdt_read_err_len(filename, buffp, &len);
250}
251
252char *utilfdt_read_len(const char *filename, off_t *len)
239{ 253{
240 char *buff; 254 char *buff;
241 int ret = utilfdt_read_err(filename, &buff); 255 int ret = utilfdt_read_err_len(filename, &buff, len);
242 256
243 if (ret) { 257 if (ret) {
244 fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename, 258 fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename,
@@ -249,6 +263,12 @@ char *utilfdt_read(const char *filename)
249 return buff; 263 return buff;
250} 264}
251 265
266char *utilfdt_read(const char *filename)
267{
268 off_t len;
269 return utilfdt_read_len(filename, &len);
270}
271
252int utilfdt_write_err(const char *filename, const void *blob) 272int utilfdt_write_err(const char *filename, const void *blob)
253{ 273{
254 int fd = 1; /* assume stdout */ 274 int fd = 1; /* assume stdout */
@@ -329,3 +349,100 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size)
329 return -1; 349 return -1;
330 return 0; 350 return 0;
331} 351}
352
353void utilfdt_print_data(const char *data, int len)
354{
355 int i;
356 const char *p = data;
357 const char *s;
358
359 /* no data, don't print */
360 if (len == 0)
361 return;
362
363 if (util_is_printable_string(data, len)) {
364 printf(" = ");
365
366 s = data;
367 do {
368 printf("\"%s\"", s);
369 s += strlen(s) + 1;
370 if (s < data + len)
371 printf(", ");
372 } while (s < data + len);
373
374 } else if ((len % 4) == 0) {
375 const uint32_t *cell = (const uint32_t *)data;
376
377 printf(" = <");
378 for (i = 0; i < len; i += 4)
379 printf("0x%08x%s", fdt32_to_cpu(cell[i]),
380 i < (len - 4) ? " " : "");
381 printf(">");
382 } else {
383 printf(" = [");
384 for (i = 0; i < len; i++)
385 printf("%02x%s", *p++, i < len - 1 ? " " : "");
386 printf("]");
387 }
388}
389
390void util_version(void)
391{
392 printf("Version: %s\n", DTC_VERSION);
393 exit(0);
394}
395
396void util_usage(const char *errmsg, const char *synopsis,
397 const char *short_opts, struct option const long_opts[],
398 const char * const opts_help[])
399{
400 FILE *fp = errmsg ? stderr : stdout;
401 const char a_arg[] = "<arg>";
402 size_t a_arg_len = strlen(a_arg) + 1;
403 size_t i;
404 int optlen;
405
406 fprintf(fp,
407 "Usage: %s\n"
408 "\n"
409 "Options: -[%s]\n", synopsis, short_opts);
410
411 /* prescan the --long opt length to auto-align */
412 optlen = 0;
413 for (i = 0; long_opts[i].name; ++i) {
414 /* +1 is for space between --opt and help text */
415 int l = strlen(long_opts[i].name) + 1;
416 if (long_opts[i].has_arg == a_argument)
417 l += a_arg_len;
418 if (optlen < l)
419 optlen = l;
420 }
421
422 for (i = 0; long_opts[i].name; ++i) {
423 /* helps when adding new applets or options */
424 assert(opts_help[i] != NULL);
425
426 /* first output the short flag if it has one */
427 if (long_opts[i].val > '~')
428 fprintf(fp, " ");
429 else
430 fprintf(fp, " -%c, ", long_opts[i].val);
431
432 /* then the long flag */
433 if (long_opts[i].has_arg == no_argument)
434 fprintf(fp, "--%-*s", optlen, long_opts[i].name);
435 else
436 fprintf(fp, "--%s %s%*s", long_opts[i].name, a_arg,
437 (int)(optlen - strlen(long_opts[i].name) - a_arg_len), "");
438
439 /* finally the help text */
440 fprintf(fp, "%s\n", opts_help[i]);
441 }
442
443 if (errmsg) {
444 fprintf(fp, "\nError: %s\n", errmsg);
445 exit(EXIT_FAILURE);
446 } else
447 exit(EXIT_SUCCESS);
448}
diff --git a/scripts/dtc/util.h b/scripts/dtc/util.h
index c8eb45d9f04b..8f40b4499359 100644
--- a/scripts/dtc/util.h
+++ b/scripts/dtc/util.h
@@ -2,6 +2,7 @@
2#define _UTIL_H 2#define _UTIL_H
3 3
4#include <stdarg.h> 4#include <stdarg.h>
5#include <getopt.h>
5 6
6/* 7/*
7 * Copyright 2011 The Chromium Authors, All Rights Reserved. 8 * Copyright 2011 The Chromium Authors, All Rights Reserved.
@@ -23,7 +24,9 @@
23 * USA 24 * USA
24 */ 25 */
25 26
26static inline void __attribute__((noreturn)) die(char * str, ...) 27#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
28
29static inline void __attribute__((noreturn)) die(const char *str, ...)
27{ 30{
28 va_list ap; 31 va_list ap;
29 32
@@ -57,12 +60,14 @@ extern char *xstrdup(const char *s);
57extern char *join_path(const char *path, const char *name); 60extern char *join_path(const char *path, const char *name);
58 61
59/** 62/**
60 * Check a string of a given length to see if it is all printable and 63 * Check a property of a given length to see if it is all printable and
61 * has a valid terminator. 64 * has a valid terminator. The property can contain either a single string,
65 * or multiple strings each of non-zero length.
62 * 66 *
63 * @param data The string to check 67 * @param data The string to check
64 * @param len The string length including terminator 68 * @param len The string length including terminator
65 * @return 1 if a valid printable string, 0 if not */ 69 * @return 1 if a valid printable string, 0 if not
70 */
66int util_is_printable_string(const void *data, int len); 71int util_is_printable_string(const void *data, int len);
67 72
68/* 73/*
@@ -83,6 +88,13 @@ char get_escape_char(const char *s, int *i);
83char *utilfdt_read(const char *filename); 88char *utilfdt_read(const char *filename);
84 89
85/** 90/**
91 * Like utilfdt_read(), but also passes back the size of the file read.
92 *
93 * @param len If non-NULL, the amount of data we managed to read
94 */
95char *utilfdt_read_len(const char *filename, off_t *len);
96
97/**
86 * Read a device tree file into a buffer. Does not report errors, but only 98 * Read a device tree file into a buffer. Does not report errors, but only
87 * returns them. The value returned can be passed to strerror() to obtain 99 * returns them. The value returned can be passed to strerror() to obtain
88 * an error message for the user. 100 * an error message for the user.
@@ -93,6 +105,12 @@ char *utilfdt_read(const char *filename);
93 */ 105 */
94int utilfdt_read_err(const char *filename, char **buffp); 106int utilfdt_read_err(const char *filename, char **buffp);
95 107
108/**
109 * Like utilfdt_read_err(), but also passes back the size of the file read.
110 *
111 * @param len If non-NULL, the amount of data we managed to read
112 */
113int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len);
96 114
97/** 115/**
98 * Write a device tree buffer to a file. This will report any errors on 116 * Write a device tree buffer to a file. This will report any errors on
@@ -148,6 +166,85 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size);
148#define USAGE_TYPE_MSG \ 166#define USAGE_TYPE_MSG \
149 "<type>\ts=string, i=int, u=unsigned, x=hex\n" \ 167 "<type>\ts=string, i=int, u=unsigned, x=hex\n" \
150 "\tOptional modifier prefix:\n" \ 168 "\tOptional modifier prefix:\n" \
151 "\t\thh or b=byte, h=2 byte, l=4 byte (default)\n"; 169 "\t\thh or b=byte, h=2 byte, l=4 byte (default)";
170
171/**
172 * Print property data in a readable format to stdout
173 *
174 * Properties that look like strings will be printed as strings. Otherwise
175 * the data will be displayed either as cells (if len is a multiple of 4
176 * bytes) or bytes.
177 *
178 * If len is 0 then this function does nothing.
179 *
180 * @param data Pointers to property data
181 * @param len Length of property data
182 */
183void utilfdt_print_data(const char *data, int len);
184
185/**
186 * Show source version and exit
187 */
188void util_version(void) __attribute__((noreturn));
189
190/**
191 * Show usage and exit
192 *
193 * This helps standardize the output of various utils. You most likely want
194 * to use the usage() helper below rather than call this.
195 *
196 * @param errmsg If non-NULL, an error message to display
197 * @param synopsis The initial example usage text (and possible examples)
198 * @param short_opts The string of short options
199 * @param long_opts The structure of long options
200 * @param opts_help An array of help strings (should align with long_opts)
201 */
202void util_usage(const char *errmsg, const char *synopsis,
203 const char *short_opts, struct option const long_opts[],
204 const char * const opts_help[]) __attribute__((noreturn));
205
206/**
207 * Show usage and exit
208 *
209 * If you name all your usage variables with usage_xxx, then you can call this
210 * help macro rather than expanding all arguments yourself.
211 *
212 * @param errmsg If non-NULL, an error message to display
213 */
214#define usage(errmsg) \
215 util_usage(errmsg, usage_synopsis, usage_short_opts, \
216 usage_long_opts, usage_opts_help)
217
218/**
219 * Call getopt_long() with standard options
220 *
221 * Since all util code runs getopt in the same way, provide a helper.
222 */
223#define util_getopt_long() getopt_long(argc, argv, usage_short_opts, \
224 usage_long_opts, NULL)
225
226/* Helper for aligning long_opts array */
227#define a_argument required_argument
228
229/* Helper for usage_short_opts string constant */
230#define USAGE_COMMON_SHORT_OPTS "hV"
231
232/* Helper for usage_long_opts option array */
233#define USAGE_COMMON_LONG_OPTS \
234 {"help", no_argument, NULL, 'h'}, \
235 {"version", no_argument, NULL, 'V'}, \
236 {NULL, no_argument, NULL, 0x0}
237
238/* Helper for usage_opts_help array */
239#define USAGE_COMMON_OPTS_HELP \
240 "Print this help and exit", \
241 "Print version and exit", \
242 NULL
243
244/* Helper for getopt case statements */
245#define case_USAGE_COMMON_FLAGS \
246 case 'h': usage(NULL); \
247 case 'V': util_version(); \
248 case '?': usage("unknown option");
152 249
153#endif /* _UTIL_H */ 250#endif /* _UTIL_H */
diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h
index 6158b867df99..54d4e904433a 100644
--- a/scripts/dtc/version_gen.h
+++ b/scripts/dtc/version_gen.h
@@ -1 +1 @@
#define DTC_VERSION "DTC 1.2.0-g37c0b6a0" #define DTC_VERSION "DTC 1.4.0-dirty"