Commit f5fab57d authored by Grant Likely's avatar Grant Likely

Merge branch 'devicetree/dtc' into devicetree/next

Branch to upgrade DTC toolchain to version 1.4.0
parents 38dbfb59 c8a3e6a8
/* A Bison parser, made by GNU Bison 2.5. */ /* A Bison parser, made by GNU Bison 2.7.12-4996. */
/* Bison implementation for Yacc-like parsers in C /* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#define YYBISON 1 #define YYBISON 1
/* Bison version. */ /* Bison version. */
#define YYBISON_VERSION "2.5" #define YYBISON_VERSION "2.7.12-4996"
/* Skeleton name. */ /* Skeleton name. */
#define YYSKELETON_NAME "yacc.c" #define YYSKELETON_NAME "yacc.c"
...@@ -58,14 +58,11 @@ ...@@ -58,14 +58,11 @@
/* Pull parsers. */ /* Pull parsers. */
#define YYPULL 1 #define YYPULL 1
/* Using locations. */
#define YYLSP_NEEDED 0
/* Copy the first part of user declarations. */ /* Copy the first part of user declarations. */
/* Line 371 of yacc.c */
/* Line 268 of yacc.c */
#line 21 "dtc-parser.y" #line 21 "dtc-parser.y"
#include <stdio.h> #include <stdio.h>
...@@ -85,14 +82,16 @@ extern int treesource_error; ...@@ -85,14 +82,16 @@ extern int treesource_error;
static unsigned long long eval_literal(const char *s, int base, int bits); static unsigned long long eval_literal(const char *s, int base, int bits);
static unsigned char eval_char_literal(const char *s); static unsigned char eval_char_literal(const char *s);
/* Line 371 of yacc.c */
#line 87 "dtc-parser.tab.c"
/* Line 268 of yacc.c */ # ifndef YY_NULL
#line 91 "dtc-parser.tab.c" # if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULL nullptr
/* Enabling traces. */ # else
#ifndef YYDEBUG # define YY_NULL 0
# define YYDEBUG 0 # endif
#endif # endif
/* Enabling verbose error messages. */ /* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE #ifdef YYERROR_VERBOSE
...@@ -102,11 +101,17 @@ static unsigned char eval_char_literal(const char *s); ...@@ -102,11 +101,17 @@ static unsigned char eval_char_literal(const char *s);
# define YYERROR_VERBOSE 0 # define YYERROR_VERBOSE 0
#endif #endif
/* Enabling the token table. */ /* In a future release of Bison, this section will be replaced
#ifndef YYTOKEN_TABLE by #include "dtc-parser.tab.h". */
# define YYTOKEN_TABLE 0 #ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED
# define YY_YY_DTC_PARSER_TAB_H_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif #endif
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
...@@ -140,12 +145,10 @@ static unsigned char eval_char_literal(const char *s); ...@@ -140,12 +145,10 @@ static unsigned char eval_char_literal(const char *s);
#endif #endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
{ {
/* Line 387 of yacc.c */
/* Line 293 of yacc.c */
#line 40 "dtc-parser.y" #line 40 "dtc-parser.y"
char *propnodename; char *propnodename;
...@@ -168,21 +171,36 @@ typedef union YYSTYPE ...@@ -168,21 +171,36 @@ typedef union YYSTYPE
uint64_t integer; uint64_t integer;
/* Line 387 of yacc.c */
/* Line 293 of yacc.c */ #line 176 "dtc-parser.tab.c"
#line 174 "dtc-parser.tab.c"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
#endif #endif
extern YYSTYPE yylval;
/* Copy the second part of user declarations. */ #ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */
/* Copy the second part of user declarations. */
/* Line 343 of yacc.c */ /* Line 390 of yacc.c */
#line 186 "dtc-parser.tab.c" #line 204 "dtc-parser.tab.c"
#ifdef short #ifdef short
# undef short # undef short
...@@ -235,24 +253,33 @@ typedef short int yytype_int16; ...@@ -235,24 +253,33 @@ typedef short int yytype_int16;
# if defined YYENABLE_NLS && YYENABLE_NLS # if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS # if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid) # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif # endif
# endif # endif
# ifndef YY_ # ifndef YY_
# define YY_(msgid) msgid # define YY_(Msgid) Msgid
# endif
#endif
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if (! defined __GNUC__ || __GNUC__ < 2 \
|| (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
# define __attribute__(Spec) /* empty */
# endif # endif
#endif #endif
/* Suppress unused-variable warnings by "using" E. */ /* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__ #if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e)) # define YYUSE(E) ((void) (E))
#else #else
# define YYUSE(e) /* empty */ # define YYUSE(E) /* empty */
#endif #endif
/* Identity function, used to suppress warnings about constant conditions. */ /* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint #ifndef lint
# define YYID(n) (n) # define YYID(N) (N)
#else #else
#if (defined __STDC__ || defined __C99__FUNC__ \ #if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
...@@ -288,6 +315,7 @@ YYID (yyi) ...@@ -288,6 +315,7 @@ YYID (yyi)
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS # ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0 # define EXIT_SUCCESS 0
# endif # endif
...@@ -379,19 +407,19 @@ union yyalloc ...@@ -379,19 +407,19 @@ union yyalloc
#endif #endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from FROM to TO. The source and destination do /* Copy COUNT objects from SRC to DST. The source and destination do
not overlap. */ not overlap. */
# ifndef YYCOPY # ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__ # if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(To, From, Count) \ # define YYCOPY(Dst, Src, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From))) __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
# else # else
# define YYCOPY(To, From, Count) \ # define YYCOPY(Dst, Src, Count) \
do \ do \
{ \ { \
YYSIZE_T yyi; \ YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \ for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \ (Dst)[yyi] = (Src)[yyi]; \
} \ } \
while (YYID (0)) while (YYID (0))
# endif # endif
...@@ -513,7 +541,7 @@ static const yytype_uint16 yyrline[] = ...@@ -513,7 +541,7 @@ static const yytype_uint16 yyrline[] =
}; };
#endif #endif
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE #if YYDEBUG || YYERROR_VERBOSE || 0
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] = static const char *const yytname[] =
...@@ -530,7 +558,7 @@ static const char *const yytname[] = ...@@ -530,7 +558,7 @@ static const char *const yytname[] =
"integer_expr", "integer_trinary", "integer_or", "integer_and", "integer_expr", "integer_trinary", "integer_or", "integer_and",
"integer_bitor", "integer_bitxor", "integer_bitand", "integer_eq", "integer_bitor", "integer_bitxor", "integer_bitand", "integer_eq",
"integer_rela", "integer_shift", "integer_add", "integer_mul", "integer_rela", "integer_shift", "integer_add", "integer_mul",
"integer_unary", "bytestring", "subnodes", "subnode", 0 "integer_unary", "bytestring", "subnodes", "subnode", YY_NULL
}; };
#endif #endif
...@@ -655,10 +683,10 @@ static const yytype_uint8 yytable[] = ...@@ -655,10 +683,10 @@ static const yytype_uint8 yytable[] =
137, 0, 73, 139 137, 0, 73, 139
}; };
#define yypact_value_is_default(yystate) \ #define yypact_value_is_default(Yystate) \
((yystate) == (-78)) (!!((Yystate) == (-78)))
#define yytable_value_is_error(yytable_value) \ #define yytable_value_is_error(Yytable_value) \
YYID (0) YYID (0)
static const yytype_int16 yycheck[] = static const yytype_int16 yycheck[] =
...@@ -729,11 +757,12 @@ static const yytype_uint8 yystos[] = ...@@ -729,11 +757,12 @@ static const yytype_uint8 yystos[] =
#define YYBACKUP(Token, Value) \ #define YYBACKUP(Token, Value) \
do \ do \
if (yychar == YYEMPTY && yylen == 1) \ if (yychar == YYEMPTY) \
{ \ { \
yychar = (Token); \ yychar = (Token); \
yylval = (Value); \ yylval = (Value); \
YYPOPSTACK (1); \ YYPOPSTACK (yylen); \
yystate = *yyssp; \
goto yybackup; \ goto yybackup; \
} \ } \
else \ else \
...@@ -743,46 +772,18 @@ do \ ...@@ -743,46 +772,18 @@ do \
} \ } \
while (YYID (0)) while (YYID (0))
/* Error token number */
#define YYTERROR 1 #define YYTERROR 1
#define YYERRCODE 256 #define YYERRCODE 256
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (YYID (N)) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
while (YYID (0))
#endif
/* This macro is provided for backward compatibility. */ /* This macro is provided for backward compatibility. */
#ifndef YY_LOCATION_PRINT #ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0) # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif #endif
/* YYLEX -- calling `yylex' with the right arguments. */ /* YYLEX -- calling `yylex' with the right arguments. */
#ifdef YYLEX_PARAM #ifdef YYLEX_PARAM
# define YYLEX yylex (YYLEX_PARAM) # define YYLEX yylex (YYLEX_PARAM)
#else #else
...@@ -832,6 +833,8 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep) ...@@ -832,6 +833,8 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep)
YYSTYPE const * const yyvaluep; YYSTYPE const * const yyvaluep;
#endif #endif
{ {
FILE *yyo = yyoutput;
YYUSE (yyo);
if (!yyvaluep) if (!yyvaluep)
return; return;
# ifdef YYPRINT # ifdef YYPRINT
...@@ -840,11 +843,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep) ...@@ -840,11 +843,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep)
# else # else
YYUSE (yyoutput); YYUSE (yyoutput);
# endif # endif
switch (yytype) YYUSE (yytype);
{
default:
break;
}
} }
...@@ -1083,12 +1082,11 @@ static int ...@@ -1083,12 +1082,11 @@ static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken) yytype_int16 *yyssp, int yytoken)
{ {
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
YYSIZE_T yysize = yysize0; YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */ /* Internationalized format string. */
const char *yyformat = 0; const char *yyformat = YY_NULL;
/* Arguments of yyformat. */ /* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per /* Number of reported tokens (one for the "unexpected", one per
...@@ -1148,7 +1146,8 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, ...@@ -1148,7 +1146,8 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
break; break;
} }
yyarg[yycount++] = yytname[yyx]; yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]); {
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
if (! (yysize <= yysize1 if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM)) && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2; return 2;
...@@ -1156,6 +1155,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, ...@@ -1156,6 +1155,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
} }
} }
} }
}
switch (yycount) switch (yycount)
{ {
...@@ -1172,10 +1172,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, ...@@ -1172,10 +1172,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
# undef YYCASE_ # undef YYCASE_
} }
yysize1 = yysize + yystrlen (yyformat); {
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2; return 2;
yysize = yysize1; yysize = yysize1;
}
if (*yymsg_alloc < yysize) if (*yymsg_alloc < yysize)
{ {
...@@ -1231,36 +1233,26 @@ yydestruct (yymsg, yytype, yyvaluep) ...@@ -1231,36 +1233,26 @@ yydestruct (yymsg, yytype, yyvaluep)
yymsg = "Deleting"; yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
switch (yytype) YYUSE (yytype);
{
default:
break;
}
} }
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
/* The lookahead symbol. */ /* The lookahead symbol. */
int yychar; int yychar;
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
/* The semantic value of the lookahead symbol. */ /* The semantic value of the lookahead symbol. */
YYSTYPE yylval; YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
/* Number of syntax errors so far. */ /* Number of syntax errors so far. */
int yynerrs; int yynerrs;
...@@ -1300,7 +1292,7 @@ yyparse () ...@@ -1300,7 +1292,7 @@ yyparse ()
`yyss': related to states. `yyss': related to states.
`yyvs': related to semantic values. `yyvs': related to semantic values.
Refer to the stacks thru separate pointers, to allow yyoverflow Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */ to reallocate them elsewhere. */
/* The state stack. */ /* The state stack. */
...@@ -1318,7 +1310,7 @@ yyparse () ...@@ -1318,7 +1310,7 @@ yyparse ()
int yyn; int yyn;
int yyresult; int yyresult;
/* Lookahead token as an internal (translated) token number. */ /* Lookahead token as an internal (translated) token number. */
int yytoken; int yytoken = 0;
/* The variables used to return semantic value and location from the /* The variables used to return semantic value and location from the
action routines. */ action routines. */
YYSTYPE yyval; YYSTYPE yyval;
...@@ -1336,9 +1328,8 @@ yyparse () ...@@ -1336,9 +1328,8 @@ yyparse ()
Keep to zero when no symbol should be popped. */ Keep to zero when no symbol should be popped. */
int yylen = 0; int yylen = 0;
yytoken = 0; yyssp = yyss = yyssa;
yyss = yyssa; yyvsp = yyvs = yyvsa;
yyvs = yyvsa;
yystacksize = YYINITDEPTH; yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n")); YYDPRINTF ((stderr, "Starting parse\n"));
...@@ -1347,14 +1338,6 @@ yyparse () ...@@ -1347,14 +1338,6 @@ yyparse ()
yyerrstatus = 0; yyerrstatus = 0;
yynerrs = 0; yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */ yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;
goto yysetstate; goto yysetstate;
/*------------------------------------------------------------. /*------------------------------------------------------------.
...@@ -1495,7 +1478,9 @@ yybackup: ...@@ -1495,7 +1478,9 @@ yybackup:
yychar = YYEMPTY; yychar = YYEMPTY;
yystate = yyn; yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval; *++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
goto yynewstate; goto yynewstate;
...@@ -1532,8 +1517,7 @@ yyreduce: ...@@ -1532,8 +1517,7 @@ yyreduce:
switch (yyn) switch (yyn)
{ {
case 2: case 2:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 110 "dtc-parser.y" #line 110 "dtc-parser.y"
{ {
the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node),
...@@ -1542,8 +1526,7 @@ yyreduce: ...@@ -1542,8 +1526,7 @@ yyreduce:
break; break;
case 3: case 3:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 118 "dtc-parser.y" #line 118 "dtc-parser.y"
{ {
(yyval.re) = NULL; (yyval.re) = NULL;
...@@ -1551,8 +1534,7 @@ yyreduce: ...@@ -1551,8 +1534,7 @@ yyreduce:
break; break;
case 4: case 4:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 122 "dtc-parser.y" #line 122 "dtc-parser.y"
{ {
(yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re));
...@@ -1560,8 +1542,7 @@ yyreduce: ...@@ -1560,8 +1542,7 @@ yyreduce:
break; break;
case 5: case 5:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 129 "dtc-parser.y" #line 129 "dtc-parser.y"
{ {
(yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer)); (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer));
...@@ -1569,8 +1550,7 @@ yyreduce: ...@@ -1569,8 +1550,7 @@ yyreduce:
break; break;
case 6: case 6:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 133 "dtc-parser.y" #line 133 "dtc-parser.y"
{ {
add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref)); add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref));
...@@ -1579,8 +1559,7 @@ yyreduce: ...@@ -1579,8 +1559,7 @@ yyreduce:
break; break;
case 7: case 7:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 141 "dtc-parser.y" #line 141 "dtc-parser.y"
{ {
(yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); (yyval.node) = name_node((yyvsp[(2) - (2)].node), "");
...@@ -1588,8 +1567,7 @@ yyreduce: ...@@ -1588,8 +1567,7 @@ yyreduce:
break; break;
case 8: case 8:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 145 "dtc-parser.y" #line 145 "dtc-parser.y"
{ {
(yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
...@@ -1597,8 +1575,7 @@ yyreduce: ...@@ -1597,8 +1575,7 @@ yyreduce:
break; break;
case 9: case 9:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 149 "dtc-parser.y" #line 149 "dtc-parser.y"
{ {
struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref)); struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref));
...@@ -1612,8 +1589,7 @@ yyreduce: ...@@ -1612,8 +1589,7 @@ yyreduce:
break; break;
case 10: case 10:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 159 "dtc-parser.y" #line 159 "dtc-parser.y"
{ {
struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref)); struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref));
...@@ -1628,8 +1604,7 @@ yyreduce: ...@@ -1628,8 +1604,7 @@ yyreduce:
break; break;
case 11: case 11:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 173 "dtc-parser.y" #line 173 "dtc-parser.y"
{ {
(yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist));
...@@ -1637,8 +1612,7 @@ yyreduce: ...@@ -1637,8 +1612,7 @@ yyreduce:
break; break;
case 12: case 12:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 180 "dtc-parser.y" #line 180 "dtc-parser.y"
{ {
(yyval.proplist) = NULL; (yyval.proplist) = NULL;
...@@ -1646,8 +1620,7 @@ yyreduce: ...@@ -1646,8 +1620,7 @@ yyreduce:
break; break;
case 13: case 13:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 184 "dtc-parser.y" #line 184 "dtc-parser.y"
{ {
(yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist));
...@@ -1655,8 +1628,7 @@ yyreduce: ...@@ -1655,8 +1628,7 @@ yyreduce:
break; break;
case 14: case 14:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 191 "dtc-parser.y" #line 191 "dtc-parser.y"
{ {
(yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data)); (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data));
...@@ -1664,8 +1636,7 @@ yyreduce: ...@@ -1664,8 +1636,7 @@ yyreduce:
break; break;
case 15: case 15:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 195 "dtc-parser.y" #line 195 "dtc-parser.y"
{ {
(yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data);
...@@ -1673,8 +1644,7 @@ yyreduce: ...@@ -1673,8 +1644,7 @@ yyreduce:
break; break;
case 16: case 16:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 199 "dtc-parser.y" #line 199 "dtc-parser.y"
{ {
(yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename)); (yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename));
...@@ -1682,8 +1652,7 @@ yyreduce: ...@@ -1682,8 +1652,7 @@ yyreduce:
break; break;
case 17: case 17:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 203 "dtc-parser.y" #line 203 "dtc-parser.y"
{ {
add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref)); add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref));
...@@ -1692,8 +1661,7 @@ yyreduce: ...@@ -1692,8 +1661,7 @@ yyreduce:
break; break;
case 18: case 18:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 211 "dtc-parser.y" #line 211 "dtc-parser.y"
{ {
(yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data));
...@@ -1701,8 +1669,7 @@ yyreduce: ...@@ -1701,8 +1669,7 @@ yyreduce:
break; break;
case 19: case 19:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 215 "dtc-parser.y" #line 215 "dtc-parser.y"
{ {
(yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data); (yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data);
...@@ -1710,8 +1677,7 @@ yyreduce: ...@@ -1710,8 +1677,7 @@ yyreduce:
break; break;
case 20: case 20:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 219 "dtc-parser.y" #line 219 "dtc-parser.y"
{ {
(yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
...@@ -1719,8 +1685,7 @@ yyreduce: ...@@ -1719,8 +1685,7 @@ yyreduce:
break; break;
case 21: case 21:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 223 "dtc-parser.y" #line 223 "dtc-parser.y"
{ {
(yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref)); (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref));
...@@ -1728,8 +1693,7 @@ yyreduce: ...@@ -1728,8 +1693,7 @@ yyreduce:
break; break;
case 22: case 22:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 227 "dtc-parser.y" #line 227 "dtc-parser.y"
{ {
FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL); FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL);
...@@ -1750,8 +1714,7 @@ yyreduce: ...@@ -1750,8 +1714,7 @@ yyreduce:
break; break;
case 23: case 23:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 244 "dtc-parser.y" #line 244 "dtc-parser.y"
{ {
FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL); FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL);
...@@ -1765,8 +1728,7 @@ yyreduce: ...@@ -1765,8 +1728,7 @@ yyreduce:
break; break;
case 24: case 24:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 254 "dtc-parser.y" #line 254 "dtc-parser.y"
{ {
(yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
...@@ -1774,8 +1736,7 @@ yyreduce: ...@@ -1774,8 +1736,7 @@ yyreduce:
break; break;
case 25: case 25:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 261 "dtc-parser.y" #line 261 "dtc-parser.y"
{ {
(yyval.data) = empty_data; (yyval.data) = empty_data;
...@@ -1783,8 +1744,7 @@ yyreduce: ...@@ -1783,8 +1744,7 @@ yyreduce:
break; break;
case 26: case 26:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 265 "dtc-parser.y" #line 265 "dtc-parser.y"
{ {
(yyval.data) = (yyvsp[(1) - (2)].data); (yyval.data) = (yyvsp[(1) - (2)].data);
...@@ -1792,8 +1752,7 @@ yyreduce: ...@@ -1792,8 +1752,7 @@ yyreduce:
break; break;
case 27: case 27:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 269 "dtc-parser.y" #line 269 "dtc-parser.y"
{ {
(yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
...@@ -1801,8 +1760,7 @@ yyreduce: ...@@ -1801,8 +1760,7 @@ yyreduce:
break; break;
case 28: case 28:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 276 "dtc-parser.y" #line 276 "dtc-parser.y"
{ {
(yyval.array).data = empty_data; (yyval.array).data = empty_data;
...@@ -1821,8 +1779,7 @@ yyreduce: ...@@ -1821,8 +1779,7 @@ yyreduce:
break; break;
case 29: case 29:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 291 "dtc-parser.y" #line 291 "dtc-parser.y"
{ {
(yyval.array).data = empty_data; (yyval.array).data = empty_data;
...@@ -1831,8 +1788,7 @@ yyreduce: ...@@ -1831,8 +1788,7 @@ yyreduce:
break; break;
case 30: case 30:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 296 "dtc-parser.y" #line 296 "dtc-parser.y"
{ {
if ((yyvsp[(1) - (2)].array).bits < 64) { if ((yyvsp[(1) - (2)].array).bits < 64) {
...@@ -1856,8 +1812,7 @@ yyreduce: ...@@ -1856,8 +1812,7 @@ yyreduce:
break; break;
case 31: case 31:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 316 "dtc-parser.y" #line 316 "dtc-parser.y"
{ {
uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits); uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits);
...@@ -1875,8 +1830,7 @@ yyreduce: ...@@ -1875,8 +1830,7 @@ yyreduce:
break; break;
case 32: case 32:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 330 "dtc-parser.y" #line 330 "dtc-parser.y"
{ {
(yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref)); (yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref));
...@@ -1884,8 +1838,7 @@ yyreduce: ...@@ -1884,8 +1838,7 @@ yyreduce:
break; break;
case 33: case 33:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 337 "dtc-parser.y" #line 337 "dtc-parser.y"
{ {
(yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); (yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64);
...@@ -1893,8 +1846,7 @@ yyreduce: ...@@ -1893,8 +1846,7 @@ yyreduce:
break; break;
case 34: case 34:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 341 "dtc-parser.y" #line 341 "dtc-parser.y"
{ {
(yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal)); (yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal));
...@@ -1902,8 +1854,7 @@ yyreduce: ...@@ -1902,8 +1854,7 @@ yyreduce:
break; break;
case 35: case 35:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 345 "dtc-parser.y" #line 345 "dtc-parser.y"
{ {
(yyval.integer) = (yyvsp[(2) - (3)].integer); (yyval.integer) = (yyvsp[(2) - (3)].integer);
...@@ -1911,162 +1862,139 @@ yyreduce: ...@@ -1911,162 +1862,139 @@ yyreduce:
break; break;
case 38: case 38:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 356 "dtc-parser.y" #line 356 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); } { (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); }
break; break;
case 40: case 40:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 361 "dtc-parser.y" #line 361 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); }
break; break;
case 42: case 42:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 366 "dtc-parser.y" #line 366 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); }
break; break;
case 44: case 44:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 371 "dtc-parser.y" #line 371 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); }
break; break;
case 46: case 46:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 376 "dtc-parser.y" #line 376 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); }
break; break;
case 48: case 48:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 381 "dtc-parser.y" #line 381 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); }
break; break;
case 50: case 50:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 386 "dtc-parser.y" #line 386 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); }
break; break;
case 51: case 51:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 387 "dtc-parser.y" #line 387 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); }
break; break;
case 53: case 53:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 392 "dtc-parser.y" #line 392 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); }
break; break;
case 54: case 54:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 393 "dtc-parser.y" #line 393 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); }
break; break;
case 55: case 55:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 394 "dtc-parser.y" #line 394 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); }
break; break;
case 56: case 56:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 395 "dtc-parser.y" #line 395 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); }
break; break;
case 57: case 57:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 399 "dtc-parser.y" #line 399 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); }
break; break;
case 58: case 58:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 400 "dtc-parser.y" #line 400 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); }
break; break;
case 60: case 60:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 405 "dtc-parser.y" #line 405 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); }
break; break;
case 61: case 61:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 406 "dtc-parser.y" #line 406 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); }
break; break;
case 63: case 63:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 411 "dtc-parser.y" #line 411 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); }
break; break;
case 64: case 64:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 412 "dtc-parser.y" #line 412 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); }
break; break;
case 65: case 65:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 413 "dtc-parser.y" #line 413 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); } { (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); }
break; break;
case 68: case 68:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 419 "dtc-parser.y" #line 419 "dtc-parser.y"
{ (yyval.integer) = -(yyvsp[(2) - (2)].integer); } { (yyval.integer) = -(yyvsp[(2) - (2)].integer); }
break; break;
case 69: case 69:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 420 "dtc-parser.y" #line 420 "dtc-parser.y"
{ (yyval.integer) = ~(yyvsp[(2) - (2)].integer); } { (yyval.integer) = ~(yyvsp[(2) - (2)].integer); }
break; break;
case 70: case 70:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 421 "dtc-parser.y" #line 421 "dtc-parser.y"
{ (yyval.integer) = !(yyvsp[(2) - (2)].integer); } { (yyval.integer) = !(yyvsp[(2) - (2)].integer); }
break; break;
case 71: case 71:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 426 "dtc-parser.y" #line 426 "dtc-parser.y"
{ {
(yyval.data) = empty_data; (yyval.data) = empty_data;
...@@ -2074,8 +2002,7 @@ yyreduce: ...@@ -2074,8 +2002,7 @@ yyreduce:
break; break;
case 72: case 72:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 430 "dtc-parser.y" #line 430 "dtc-parser.y"
{ {
(yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte));
...@@ -2083,8 +2010,7 @@ yyreduce: ...@@ -2083,8 +2010,7 @@ yyreduce:
break; break;
case 73: case 73:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 434 "dtc-parser.y" #line 434 "dtc-parser.y"
{ {
(yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
...@@ -2092,8 +2018,7 @@ yyreduce: ...@@ -2092,8 +2018,7 @@ yyreduce:
break; break;
case 74: case 74:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 441 "dtc-parser.y" #line 441 "dtc-parser.y"
{ {
(yyval.nodelist) = NULL; (yyval.nodelist) = NULL;
...@@ -2101,8 +2026,7 @@ yyreduce: ...@@ -2101,8 +2026,7 @@ yyreduce:
break; break;
case 75: case 75:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 445 "dtc-parser.y" #line 445 "dtc-parser.y"
{ {
(yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist));
...@@ -2110,8 +2034,7 @@ yyreduce: ...@@ -2110,8 +2034,7 @@ yyreduce:
break; break;
case 76: case 76:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 449 "dtc-parser.y" #line 449 "dtc-parser.y"
{ {
print_error("syntax error: properties must precede subnodes"); print_error("syntax error: properties must precede subnodes");
...@@ -2120,8 +2043,7 @@ yyreduce: ...@@ -2120,8 +2043,7 @@ yyreduce:
break; break;
case 77: case 77:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 457 "dtc-parser.y" #line 457 "dtc-parser.y"
{ {
(yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename));
...@@ -2129,8 +2051,7 @@ yyreduce: ...@@ -2129,8 +2051,7 @@ yyreduce:
break; break;
case 78: case 78:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 461 "dtc-parser.y" #line 461 "dtc-parser.y"
{ {
(yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename)); (yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename));
...@@ -2138,8 +2059,7 @@ yyreduce: ...@@ -2138,8 +2059,7 @@ yyreduce:
break; break;
case 79: case 79:
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */
#line 465 "dtc-parser.y" #line 465 "dtc-parser.y"
{ {
add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref)); add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref));
...@@ -2148,9 +2068,8 @@ yyreduce: ...@@ -2148,9 +2068,8 @@ yyreduce:
break; break;
/* Line 1787 of yacc.c */
/* Line 1806 of yacc.c */ #line 2073 "dtc-parser.tab.c"
#line 2154 "dtc-parser.tab.c"
default: break; default: break;
} }
/* User semantic actions sometimes alter yychar, and that requires /* User semantic actions sometimes alter yychar, and that requires
...@@ -2313,7 +2232,9 @@ yyerrlab1: ...@@ -2313,7 +2232,9 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp); YY_STACK_PRINT (yyss, yyssp);
} }
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval; *++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Shift the error token. */ /* Shift the error token. */
...@@ -2337,7 +2258,7 @@ yyabortlab: ...@@ -2337,7 +2258,7 @@ yyabortlab:
yyresult = 1; yyresult = 1;
goto yyreturn; goto yyreturn;
#if !defined(yyoverflow) || YYERROR_VERBOSE #if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------. /*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. | | yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/ `-------------------------------------------------*/
...@@ -2379,8 +2300,7 @@ yyreturn: ...@@ -2379,8 +2300,7 @@ yyreturn:
} }
/* Line 2050 of yacc.c */
/* Line 2067 of yacc.c */
#line 471 "dtc-parser.y" #line 471 "dtc-parser.y"
...@@ -2444,4 +2364,3 @@ static unsigned char eval_char_literal(const char *s) ...@@ -2444,4 +2364,3 @@ static unsigned char eval_char_literal(const char *s)
return c; return c;
} }
/* A Bison parser, made by GNU Bison 2.5. */ /* A Bison parser, made by GNU Bison 2.7.12-4996. */
/* Bison interface for Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -30,6 +30,15 @@ ...@@ -30,6 +30,15 @@
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
#ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED
# define YY_YY_DTC_PARSER_TAB_H_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
...@@ -63,12 +72,10 @@ ...@@ -63,12 +72,10 @@
#endif #endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
{ {
/* Line 2053 of yacc.c */
/* Line 2068 of yacc.c */
#line 40 "dtc-parser.y" #line 40 "dtc-parser.y"
char *propnodename; char *propnodename;
...@@ -91,9 +98,8 @@ typedef union YYSTYPE ...@@ -91,9 +98,8 @@ typedef union YYSTYPE
uint64_t integer; uint64_t integer;
/* Line 2053 of yacc.c */
/* Line 2068 of yacc.c */ #line 103 "dtc-parser.tab.h"
#line 97 "dtc-parser.tab.h"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
...@@ -102,4 +108,18 @@ typedef union YYSTYPE ...@@ -102,4 +108,18 @@ typedef union YYSTYPE
extern YYSTYPE yylval; extern YYSTYPE yylval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "dtc.h" #include "dtc.h"
#include "srcpos.h" #include "srcpos.h"
#include "version_gen.h"
/* /*
* Command line options * Command line options
*/ */
...@@ -49,55 +47,60 @@ static void fill_fullpaths(struct node *tree, const char *prefix) ...@@ -49,55 +47,60 @@ static void fill_fullpaths(struct node *tree, const char *prefix)
fill_fullpaths(child, tree->fullpath); fill_fullpaths(child, tree->fullpath);
} }
static void __attribute__ ((noreturn)) usage(void) /* Usage related data. */
{ static const char usage_synopsis[] = "dtc [options] <input file>";
fprintf(stderr, "Usage:\n"); static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv";
fprintf(stderr, "\tdtc [options] <input file>\n"); static struct option const usage_long_opts[] = {
fprintf(stderr, "\nOptions:\n"); {"quiet", no_argument, NULL, 'q'},
fprintf(stderr, "\t-h\n"); {"in-format", a_argument, NULL, 'I'},
fprintf(stderr, "\t\tThis help text\n"); {"out", a_argument, NULL, 'o'},
fprintf(stderr, "\t-q\n"); {"out-format", a_argument, NULL, 'O'},
fprintf(stderr, "\t\tQuiet: -q suppress warnings, -qq errors, -qqq all\n"); {"out-version", a_argument, NULL, 'V'},
fprintf(stderr, "\t-I <input format>\n"); {"out-dependency", a_argument, NULL, 'd'},
fprintf(stderr, "\t\tInput formats are:\n"); {"reserve", a_argument, NULL, 'R'},
fprintf(stderr, "\t\t\tdts - device tree source text\n"); {"space", a_argument, NULL, 'S'},
fprintf(stderr, "\t\t\tdtb - device tree blob\n"); {"pad", a_argument, NULL, 'p'},
fprintf(stderr, "\t\t\tfs - /proc/device-tree style directory\n"); {"boot-cpu", a_argument, NULL, 'b'},
fprintf(stderr, "\t-o <output file>\n"); {"force", no_argument, NULL, 'f'},
fprintf(stderr, "\t-O <output format>\n"); {"include", a_argument, NULL, 'i'},
fprintf(stderr, "\t\tOutput formats are:\n"); {"sort", no_argument, NULL, 's'},
fprintf(stderr, "\t\t\tdts - device tree source text\n"); {"phandle", a_argument, NULL, 'H'},
fprintf(stderr, "\t\t\tdtb - device tree blob\n"); {"warning", a_argument, NULL, 'W'},
fprintf(stderr, "\t\t\tasm - assembler source\n"); {"error", a_argument, NULL, 'E'},
fprintf(stderr, "\t-V <output version>\n"); {"help", no_argument, NULL, 'h'},
fprintf(stderr, "\t\tBlob version to produce, defaults to %d (relevant for dtb\n\t\tand asm output only)\n", DEFAULT_FDT_VERSION); {"version", no_argument, NULL, 'v'},
fprintf(stderr, "\t-d <output dependency file>\n"); {NULL, no_argument, NULL, 0x0},
fprintf(stderr, "\t-R <number>\n"); };
fprintf(stderr, "\t\tMake space for <number> reserve map entries (relevant for \n\t\tdtb and asm output only)\n"); static const char * const usage_opts_help[] = {
fprintf(stderr, "\t-S <bytes>\n"); "\n\tQuiet: -q suppress warnings, -qq errors, -qqq all",
fprintf(stderr, "\t\tMake the blob at least <bytes> long (extra space)\n"); "\n\tInput formats are:\n"
fprintf(stderr, "\t-p <bytes>\n"); "\t\tdts - device tree source text\n"
fprintf(stderr, "\t\tAdd padding to the blob of <bytes> long (extra space)\n"); "\t\tdtb - device tree blob\n"
fprintf(stderr, "\t-b <number>\n"); "\t\tfs - /proc/device-tree style directory",
fprintf(stderr, "\t\tSet the physical boot cpu\n"); "\n\tOutput file",
fprintf(stderr, "\t-f\n"); "\n\tOutput formats are:\n"
fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n"); "\t\tdts - device tree source text\n"
fprintf(stderr, "\t-i\n"); "\t\tdtb - device tree blob\n"
fprintf(stderr, "\t\tAdd a path to search for include files\n"); "\t\tasm - assembler source",
fprintf(stderr, "\t-s\n"); "\n\tBlob version to produce, defaults to %d (for dtb and asm output)", //, DEFAULT_FDT_VERSION);
fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n"); "\n\tOutput dependency file",
fprintf(stderr, "\t-v\n"); "\n\ttMake space for <number> reserve map entries (for dtb and asm output)",
fprintf(stderr, "\t\tPrint DTC version and exit\n"); "\n\tMake the blob at least <bytes> long (extra space)",
fprintf(stderr, "\t-H <phandle format>\n"); "\n\tAdd padding to the blob of <bytes> long (extra space)",
fprintf(stderr, "\t\tphandle formats are:\n"); "\n\tSet the physical boot cpu",
fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n"); "\n\tTry to produce output even if the input tree has errors",
fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n"); "\n\tAdd a path to search for include files",
fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n"); "\n\tSort nodes and properties before outputting (useful for comparing trees)",
fprintf(stderr, "\t-W [no-]<checkname>\n"); "\n\tValid phandle formats are:\n"
fprintf(stderr, "\t-E [no-]<checkname>\n"); "\t\tlegacy - \"linux,phandle\" properties only\n"
fprintf(stderr, "\t\t\tenable or disable warnings and errors\n"); "\t\tepapr - \"phandle\" properties only\n"
exit(3); "\t\tboth - Both \"linux,phandle\" and \"phandle\" properties",
} "\n\tEnable/disable warnings (prefix with \"no-\")",
"\n\tEnable/disable errors (prefix with \"no-\")",
"\n\tPrint this help and exit",
"\n\tPrint version and exit",
NULL,
};
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
...@@ -118,8 +121,7 @@ int main(int argc, char *argv[]) ...@@ -118,8 +121,7 @@ int main(int argc, char *argv[])
minsize = 0; minsize = 0;
padsize = 0; padsize = 0;
while ((opt = getopt(argc, argv, "hI:O:o:V:d:R:S:p:fqb:i:vH:sW:E:")) while ((opt = util_getopt_long()) != EOF) {
!= EOF) {
switch (opt) { switch (opt) {
case 'I': case 'I':
inform = optarg; inform = optarg;
...@@ -158,8 +160,7 @@ int main(int argc, char *argv[]) ...@@ -158,8 +160,7 @@ int main(int argc, char *argv[])
srcfile_add_search_path(optarg); srcfile_add_search_path(optarg);
break; break;
case 'v': case 'v':
printf("Version: %s\n", DTC_VERSION); util_version();
exit(0);
case 'H': case 'H':
if (streq(optarg, "legacy")) if (streq(optarg, "legacy"))
phandle_format = PHANDLE_LEGACY; phandle_format = PHANDLE_LEGACY;
...@@ -185,13 +186,14 @@ int main(int argc, char *argv[]) ...@@ -185,13 +186,14 @@ int main(int argc, char *argv[])
break; break;
case 'h': case 'h':
usage(NULL);
default: default:
usage(); usage("unknown option");
} }
} }
if (argc > (optind+1)) if (argc > (optind+1))
usage(); usage("missing files");
else if (argc < (optind+1)) else if (argc < (optind+1))
arg = "-"; arg = "-";
else else
...@@ -201,9 +203,6 @@ int main(int argc, char *argv[]) ...@@ -201,9 +203,6 @@ int main(int argc, char *argv[])
if (minsize && padsize) if (minsize && padsize)
die("Can't set both -p and -S\n"); die("Can't set both -p and -S\n");
if (minsize)
fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n");
if (depname) { if (depname) {
depfile = fopen(depname, "w"); depfile = fopen(depname, "w");
if (!depfile) if (!depfile)
......
...@@ -66,7 +66,6 @@ typedef uint32_t cell_t; ...@@ -66,7 +66,6 @@ typedef uint32_t cell_t;
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0) #define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
/* Data blobs */ /* Data blobs */
enum markertype { enum markertype {
......
...@@ -297,9 +297,9 @@ srcpos_verror(struct srcpos *pos, char const *fmt, va_list va) ...@@ -297,9 +297,9 @@ srcpos_verror(struct srcpos *pos, char const *fmt, va_list va)
srcstr = srcpos_string(pos); srcstr = srcpos_string(pos);
fprintf(stdout, "Error: %s ", srcstr); fprintf(stderr, "Error: %s ", srcstr);
vfprintf(stdout, fmt, va); vfprintf(stderr, fmt, va);
fprintf(stdout, "\n"); fprintf(stderr, "\n");
} }
void void
......
#!/bin/sh
# Simple script to update the version of DTC carried by the Linux kernel
#
# This script assumes that the dtc and the linux git trees are in the
# same directory. After building dtc in the dtc directory, it copies the
# source files and generated source files into the scripts/dtc directory
# in the kernel and creates a git commit updating them to the new
# version.
#
# Usage: from the top level Linux source tree, run:
# $ ./scripts/dtc/update-dtc-source.sh
#
# The script will change into the dtc tree, build and test dtc, copy the
# relevant files into the kernel tree and create a git commit. The commit
# message will need to be modified to reflect the version of DTC being
# imported
#
# TODO:
# This script is pretty basic, but it is seldom used so a few manual tasks
# aren't a big deal. If anyone is interested in making it more robust, the
# the following would be nice:
# * Actually fail to complete if any testcase fails.
# - The dtc "make check" target needs to return a failure
# * Extract the version number from the dtc repo for the commit message
# * Build dtc in the kernel tree
# * run 'make check" on dtc built from the kernel tree
set -ev
DTC_UPSTREAM_PATH=`pwd`/../dtc
DTC_LINUX_PATH=`pwd`/scripts/dtc
DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \
srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \
dtc-lexer.l dtc-parser.y"
DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h"
# Build DTC
cd $DTC_UPSTREAM_PATH
make clean
make check
# Copy the files into the Linux tree
cd $DTC_LINUX_PATH
for f in $DTC_SOURCE; do
cp ${DTC_UPSTREAM_PATH}/${f} ${f}
git add ${f}
done
for f in $DTC_GENERATED; do
cp ${DTC_UPSTREAM_PATH}/$f ${f}_shipped
git add ${f}_shipped
done
git commit -e -v -m "scripts/dtc: Update to upstream version [CHANGEME]"
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "libfdt.h" #include "libfdt.h"
#include "util.h" #include "util.h"
#include "version_gen.h"
char *xstrdup(const char *s) char *xstrdup(const char *s)
{ {
...@@ -72,7 +73,7 @@ char *join_path(const char *path, const char *name) ...@@ -72,7 +73,7 @@ char *join_path(const char *path, const char *name)
int util_is_printable_string(const void *data, int len) int util_is_printable_string(const void *data, int len)
{ {
const char *s = data; const char *s = data;
const char *ss; const char *ss, *se;
/* zero length is not */ /* zero length is not */
if (len == 0) if (len == 0)
...@@ -82,14 +83,20 @@ int util_is_printable_string(const void *data, int len) ...@@ -82,14 +83,20 @@ int util_is_printable_string(const void *data, int len)
if (s[len - 1] != '\0') if (s[len - 1] != '\0')
return 0; return 0;
se = s + len;
while (s < se) {
ss = s; ss = s;
while (*s && isprint(*s)) while (s < se && *s && isprint(*s))
s++; s++;
/* not zero, or not done yet */ /* not zero, or not done yet */
if (*s != '\0' || (s + 1 - ss) < len) if (*s != '\0' || s == ss)
return 0; return 0;
s++;
}
return 1; return 1;
} }
...@@ -191,7 +198,7 @@ char get_escape_char(const char *s, int *i) ...@@ -191,7 +198,7 @@ char get_escape_char(const char *s, int *i)
return val; return val;
} }
int utilfdt_read_err(const char *filename, char **buffp) int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len)
{ {
int fd = 0; /* assume stdin */ int fd = 0; /* assume stdin */
char *buf = NULL; char *buf = NULL;
...@@ -206,12 +213,12 @@ int utilfdt_read_err(const char *filename, char **buffp) ...@@ -206,12 +213,12 @@ int utilfdt_read_err(const char *filename, char **buffp)
} }
/* Loop until we have read everything */ /* Loop until we have read everything */
buf = malloc(bufsize); buf = xmalloc(bufsize);
do { do {
/* Expand the buffer to hold the next chunk */ /* Expand the buffer to hold the next chunk */
if (offset == bufsize) { if (offset == bufsize) {
bufsize *= 2; bufsize *= 2;
buf = realloc(buf, bufsize); buf = xrealloc(buf, bufsize);
if (!buf) { if (!buf) {
ret = ENOMEM; ret = ENOMEM;
break; break;
...@@ -232,13 +239,20 @@ int utilfdt_read_err(const char *filename, char **buffp) ...@@ -232,13 +239,20 @@ int utilfdt_read_err(const char *filename, char **buffp)
free(buf); free(buf);
else else
*buffp = buf; *buffp = buf;
*len = bufsize;
return ret; return ret;
} }
char *utilfdt_read(const char *filename) int utilfdt_read_err(const char *filename, char **buffp)
{
off_t len;
return utilfdt_read_err_len(filename, buffp, &len);
}
char *utilfdt_read_len(const char *filename, off_t *len)
{ {
char *buff; char *buff;
int ret = utilfdt_read_err(filename, &buff); int ret = utilfdt_read_err_len(filename, &buff, len);
if (ret) { if (ret) {
fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename, fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename,
...@@ -249,6 +263,12 @@ char *utilfdt_read(const char *filename) ...@@ -249,6 +263,12 @@ char *utilfdt_read(const char *filename)
return buff; return buff;
} }
char *utilfdt_read(const char *filename)
{
off_t len;
return utilfdt_read_len(filename, &len);
}
int utilfdt_write_err(const char *filename, const void *blob) int utilfdt_write_err(const char *filename, const void *blob)
{ {
int fd = 1; /* assume stdout */ int fd = 1; /* assume stdout */
...@@ -329,3 +349,100 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size) ...@@ -329,3 +349,100 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size)
return -1; return -1;
return 0; return 0;
} }
void utilfdt_print_data(const char *data, int len)
{
int i;
const char *p = data;
const char *s;
/* no data, don't print */
if (len == 0)
return;
if (util_is_printable_string(data, len)) {
printf(" = ");
s = data;
do {
printf("\"%s\"", s);
s += strlen(s) + 1;
if (s < data + len)
printf(", ");
} while (s < data + len);
} else if ((len % 4) == 0) {
const uint32_t *cell = (const uint32_t *)data;
printf(" = <");
for (i = 0; i < len; i += 4)
printf("0x%08x%s", fdt32_to_cpu(cell[i]),
i < (len - 4) ? " " : "");
printf(">");
} else {
printf(" = [");
for (i = 0; i < len; i++)
printf("%02x%s", *p++, i < len - 1 ? " " : "");
printf("]");
}
}
void util_version(void)
{
printf("Version: %s\n", DTC_VERSION);
exit(0);
}
void util_usage(const char *errmsg, const char *synopsis,
const char *short_opts, struct option const long_opts[],
const char * const opts_help[])
{
FILE *fp = errmsg ? stderr : stdout;
const char a_arg[] = "<arg>";
size_t a_arg_len = strlen(a_arg) + 1;
size_t i;
int optlen;
fprintf(fp,
"Usage: %s\n"
"\n"
"Options: -[%s]\n", synopsis, short_opts);
/* prescan the --long opt length to auto-align */
optlen = 0;
for (i = 0; long_opts[i].name; ++i) {
/* +1 is for space between --opt and help text */
int l = strlen(long_opts[i].name) + 1;
if (long_opts[i].has_arg == a_argument)
l += a_arg_len;
if (optlen < l)
optlen = l;
}
for (i = 0; long_opts[i].name; ++i) {
/* helps when adding new applets or options */
assert(opts_help[i] != NULL);
/* first output the short flag if it has one */
if (long_opts[i].val > '~')
fprintf(fp, " ");
else
fprintf(fp, " -%c, ", long_opts[i].val);
/* then the long flag */
if (long_opts[i].has_arg == no_argument)
fprintf(fp, "--%-*s", optlen, long_opts[i].name);
else
fprintf(fp, "--%s %s%*s", long_opts[i].name, a_arg,
(int)(optlen - strlen(long_opts[i].name) - a_arg_len), "");
/* finally the help text */
fprintf(fp, "%s\n", opts_help[i]);
}
if (errmsg) {
fprintf(fp, "\nError: %s\n", errmsg);
exit(EXIT_FAILURE);
} else
exit(EXIT_SUCCESS);
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define _UTIL_H #define _UTIL_H
#include <stdarg.h> #include <stdarg.h>
#include <getopt.h>
/* /*
* Copyright 2011 The Chromium Authors, All Rights Reserved. * Copyright 2011 The Chromium Authors, All Rights Reserved.
...@@ -23,7 +24,9 @@ ...@@ -23,7 +24,9 @@
* USA * USA
*/ */
static inline void __attribute__((noreturn)) die(char * str, ...) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
static inline void __attribute__((noreturn)) die(const char *str, ...)
{ {
va_list ap; va_list ap;
...@@ -57,12 +60,14 @@ extern char *xstrdup(const char *s); ...@@ -57,12 +60,14 @@ extern char *xstrdup(const char *s);
extern char *join_path(const char *path, const char *name); extern char *join_path(const char *path, const char *name);
/** /**
* Check a string of a given length to see if it is all printable and * Check a property of a given length to see if it is all printable and
* has a valid terminator. * has a valid terminator. The property can contain either a single string,
* or multiple strings each of non-zero length.
* *
* @param data The string to check * @param data The string to check
* @param len The string length including terminator * @param len The string length including terminator
* @return 1 if a valid printable string, 0 if not */ * @return 1 if a valid printable string, 0 if not
*/
int util_is_printable_string(const void *data, int len); int util_is_printable_string(const void *data, int len);
/* /*
...@@ -82,6 +87,13 @@ char get_escape_char(const char *s, int *i); ...@@ -82,6 +87,13 @@ char get_escape_char(const char *s, int *i);
*/ */
char *utilfdt_read(const char *filename); char *utilfdt_read(const char *filename);
/**
* Like utilfdt_read(), but also passes back the size of the file read.
*
* @param len If non-NULL, the amount of data we managed to read
*/
char *utilfdt_read_len(const char *filename, off_t *len);
/** /**
* Read a device tree file into a buffer. Does not report errors, but only * Read a device tree file into a buffer. Does not report errors, but only
* returns them. The value returned can be passed to strerror() to obtain * returns them. The value returned can be passed to strerror() to obtain
...@@ -93,6 +105,12 @@ char *utilfdt_read(const char *filename); ...@@ -93,6 +105,12 @@ char *utilfdt_read(const char *filename);
*/ */
int utilfdt_read_err(const char *filename, char **buffp); int utilfdt_read_err(const char *filename, char **buffp);
/**
* Like utilfdt_read_err(), but also passes back the size of the file read.
*
* @param len If non-NULL, the amount of data we managed to read
*/
int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len);
/** /**
* Write a device tree buffer to a file. This will report any errors on * 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,6 +166,85 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size);
#define USAGE_TYPE_MSG \ #define USAGE_TYPE_MSG \
"<type>\ts=string, i=int, u=unsigned, x=hex\n" \ "<type>\ts=string, i=int, u=unsigned, x=hex\n" \
"\tOptional modifier prefix:\n" \ "\tOptional modifier prefix:\n" \
"\t\thh or b=byte, h=2 byte, l=4 byte (default)\n"; "\t\thh or b=byte, h=2 byte, l=4 byte (default)";
/**
* Print property data in a readable format to stdout
*
* Properties that look like strings will be printed as strings. Otherwise
* the data will be displayed either as cells (if len is a multiple of 4
* bytes) or bytes.
*
* If len is 0 then this function does nothing.
*
* @param data Pointers to property data
* @param len Length of property data
*/
void utilfdt_print_data(const char *data, int len);
/**
* Show source version and exit
*/
void util_version(void) __attribute__((noreturn));
/**
* Show usage and exit
*
* This helps standardize the output of various utils. You most likely want
* to use the usage() helper below rather than call this.
*
* @param errmsg If non-NULL, an error message to display
* @param synopsis The initial example usage text (and possible examples)
* @param short_opts The string of short options
* @param long_opts The structure of long options
* @param opts_help An array of help strings (should align with long_opts)
*/
void util_usage(const char *errmsg, const char *synopsis,
const char *short_opts, struct option const long_opts[],
const char * const opts_help[]) __attribute__((noreturn));
/**
* Show usage and exit
*
* If you name all your usage variables with usage_xxx, then you can call this
* help macro rather than expanding all arguments yourself.
*
* @param errmsg If non-NULL, an error message to display
*/
#define usage(errmsg) \
util_usage(errmsg, usage_synopsis, usage_short_opts, \
usage_long_opts, usage_opts_help)
/**
* Call getopt_long() with standard options
*
* Since all util code runs getopt in the same way, provide a helper.
*/
#define util_getopt_long() getopt_long(argc, argv, usage_short_opts, \
usage_long_opts, NULL)
/* Helper for aligning long_opts array */
#define a_argument required_argument
/* Helper for usage_short_opts string constant */
#define USAGE_COMMON_SHORT_OPTS "hV"
/* Helper for usage_long_opts option array */
#define USAGE_COMMON_LONG_OPTS \
{"help", no_argument, NULL, 'h'}, \
{"version", no_argument, NULL, 'V'}, \
{NULL, no_argument, NULL, 0x0}
/* Helper for usage_opts_help array */
#define USAGE_COMMON_OPTS_HELP \
"Print this help and exit", \
"Print version and exit", \
NULL
/* Helper for getopt case statements */
#define case_USAGE_COMMON_FLAGS \
case 'h': usage(NULL); \
case 'V': util_version(); \
case '?': usage("unknown option");
#endif /* _UTIL_H */ #endif /* _UTIL_H */
#define DTC_VERSION "DTC 1.2.0-g37c0b6a0" #define DTC_VERSION "DTC 1.4.0-dirty"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment