scripts/dtc: Update to upstream version 1.4.1

Includes the new localfixups format.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>

scripts/dtc: Fix UMR causing corrupt dtbo overlay files

struct fixup_entry is allocated from the heap but it's member
local_fixup_generated was never initialized. This lead to
corrupted dtbo files.

Fix this by initializing local_fixup_generated to false.

Signed-off-by: Matthias Reichl <hias@horus.com>

scripts/dtc: Only emit local fixups for overlays

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
This commit is contained in:
Phil Elwell
2015-08-10 09:49:15 +01:00
committed by popcornmix
parent 9d454add6c
commit aefac30cfd
10 changed files with 1078 additions and 703 deletions

View File

@@ -482,6 +482,8 @@ static void fixup_phandle_references(struct check *c, struct node *dt,
struct node *node, struct property *prop) struct node *node, struct property *prop)
{ {
struct marker *m = prop->val.markers; struct marker *m = prop->val.markers;
struct fixup *f, **fp;
struct fixup_entry *fe, **fep;
struct node *refnode; struct node *refnode;
cell_t phandle; cell_t phandle;
@@ -490,11 +492,70 @@ static void fixup_phandle_references(struct check *c, struct node *dt,
refnode = get_node_by_ref(dt, m->ref); refnode = get_node_by_ref(dt, m->ref);
if (! refnode) { if (! refnode) {
FAIL(c, "Reference to non-existent node or label \"%s\"\n", if (!dt->is_plugin) {
m->ref); FAIL(c, "Reference to non-existent node or label \"%s\"\n",
m->ref);
continue;
}
/* allocate fixup entry */
fe = xmalloc(sizeof(*fe));
fe->node = node;
fe->prop = prop;
fe->offset = m->offset;
fe->next = NULL;
/* search for an already existing fixup */
for_each_fixup(dt, f)
if (strcmp(f->ref, m->ref) == 0)
break;
/* no fixup found, add new */
if (f == NULL) {
f = xmalloc(sizeof(*f));
f->ref = m->ref;
f->entries = NULL;
f->next = NULL;
/* add it to the tree */
fp = &dt->fixups;
while (*fp)
fp = &(*fp)->next;
*fp = f;
}
/* and now append fixup entry */
fep = &f->entries;
while (*fep)
fep = &(*fep)->next;
*fep = fe;
/* mark the entry as unresolved */
*((cell_t *)(prop->val.val + m->offset)) =
cpu_to_fdt32(0xdeadbeef);
continue; continue;
} }
/* if it's a local reference, we need to record it */
if (symbol_fixup_support && dt->is_plugin) {
/* allocate a new local fixup entry */
fe = xmalloc(sizeof(*fe));
fe->node = node;
fe->prop = prop;
fe->offset = m->offset;
fe->next = NULL;
fe->local_fixup_generated = false;
/* append it to the local fixups */
fep = &dt->local_fixups;
while (*fep)
fep = &(*fep)->next;
*fep = fe;
}
phandle = get_node_phandle(dt, refnode); phandle = get_node_phandle(dt, refnode);
*((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
} }
@@ -676,6 +737,45 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c,
} }
TREE_WARNING(obsolete_chosen_interrupt_controller, NULL); TREE_WARNING(obsolete_chosen_interrupt_controller, NULL);
static void check_auto_label_phandles(struct check *c, struct node *dt,
struct node *node)
{
struct label *l;
struct symbol *s, **sp;
int has_label;
if (!symbol_fixup_support)
return;
has_label = 0;
for_each_label(node->labels, l) {
has_label = 1;
break;
}
if (!has_label)
return;
/* force allocation of a phandle for this node */
(void)get_node_phandle(dt, node);
/* add the symbol */
for_each_label(node->labels, l) {
s = xmalloc(sizeof(*s));
s->label = l;
s->node = node;
s->next = NULL;
/* add it to the symbols list */
sp = &dt->symbols;
while (*sp)
sp = &((*sp)->next);
*sp = s;
}
}
NODE_WARNING(auto_label_phandles, NULL);
static struct check *check_table[] = { static struct check *check_table[] = {
&duplicate_node_names, &duplicate_property_names, &duplicate_node_names, &duplicate_property_names,
&node_name_chars, &node_name_format, &property_name_chars, &node_name_chars, &node_name_format, &property_name_chars,
@@ -696,6 +796,8 @@ static struct check *check_table[] = {
&avoid_default_addr_size, &avoid_default_addr_size,
&obsolete_chosen_interrupt_controller, &obsolete_chosen_interrupt_controller,
&auto_label_phandles,
&always_fail, &always_fail,
}; };

View File

@@ -121,6 +121,11 @@ static void lexical_error(const char *fmt, ...);
return DT_V1; return DT_V1;
} }
<*>"/plugin/" {
DPRINT("Keyword: /plugin/\n");
return DT_PLUGIN;
}
<*>"/memreserve/" { <*>"/memreserve/" {
DPRINT("Keyword: /memreserve/\n"); DPRINT("Keyword: /memreserve/\n");
BEGIN_DEFAULT(); BEGIN_DEFAULT();

View File

@@ -9,7 +9,7 @@
#define FLEX_SCANNER #define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 39 #define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0 #if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA #define FLEX_BETA
#endif #endif
@@ -162,12 +162,7 @@ typedef unsigned int flex_uint32_t;
typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif #endif
#ifndef YY_TYPEDEF_YY_SIZE_T extern int yyleng;
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
extern yy_size_t yyleng;
extern FILE *yyin, *yyout; extern FILE *yyin, *yyout;
@@ -176,7 +171,6 @@ extern FILE *yyin, *yyout;
#define EOB_ACT_LAST_MATCH 2 #define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n) #define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */ /* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \ #define yyless(n) \
@@ -194,6 +188,11 @@ extern FILE *yyin, *yyout;
#define unput(c) yyunput( c, (yytext_ptr) ) #define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE #ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state struct yy_buffer_state
@@ -211,7 +210,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB /* Number of characters read into yy_ch_buf, not including EOB
* characters. * characters.
*/ */
yy_size_t yy_n_chars; int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it, /* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to * and can realloc() it to grow it, and should free() it to
@@ -281,8 +280,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* yy_hold_char holds the character lost when yytext is formed. */ /* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char; static char yy_hold_char;
static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ static int yy_n_chars; /* number of characters read into yy_ch_buf */
yy_size_t yyleng; int yyleng;
/* Points to current character in buffer. */ /* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0; static char *yy_c_buf_p = (char *) 0;
@@ -310,7 +309,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
void *yyalloc (yy_size_t ); void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t ); void *yyrealloc (void *,yy_size_t );
@@ -342,7 +341,7 @@ void yyfree (void * );
/* Begin user sect3 */ /* Begin user sect3 */
#define yywrap() 1 #define yywrap(n) 1
#define YY_SKIP_YYWRAP #define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR; typedef unsigned char YY_CHAR;
@@ -373,8 +372,8 @@ static void yy_fatal_error (yyconst char msg[] );
*yy_cp = '\0'; \ *yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp; (yy_c_buf_p) = yy_cp;
#define YY_NUM_RULES 30 #define YY_NUM_RULES 31
#define YY_END_OF_BUFFER 31 #define YY_END_OF_BUFFER 32
/* This struct is not used in this scanner, /* This struct is not used in this scanner,
but its presence is necessary. */ but its presence is necessary. */
struct yy_trans_info struct yy_trans_info
@@ -382,25 +381,26 @@ struct yy_trans_info
flex_int32_t yy_verify; flex_int32_t yy_verify;
flex_int32_t yy_nxt; flex_int32_t yy_nxt;
}; };
static yyconst flex_int16_t yy_accept[159] = static yyconst flex_int16_t yy_accept[166] =
{ 0, { 0,
0, 0, 0, 0, 0, 0, 0, 0, 31, 29, 0, 0, 0, 0, 0, 0, 0, 0, 32, 30,
18, 18, 29, 29, 29, 29, 29, 29, 29, 29, 19, 19, 30, 30, 30, 30, 30, 30, 30, 30,
29, 29, 29, 29, 29, 29, 15, 16, 16, 29, 30, 30, 30, 30, 30, 30, 16, 17, 17, 30,
16, 10, 10, 18, 26, 0, 3, 0, 27, 12, 17, 11, 11, 19, 27, 0, 3, 0, 28, 13,
0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0,
21, 23, 25, 24, 22, 0, 9, 28, 0, 0, 0, 22, 24, 26, 25, 23, 0, 10, 29, 0,
0, 14, 14, 16, 16, 16, 10, 10, 10, 0, 0, 0, 15, 15, 17, 17, 17, 11, 11, 11,
12, 0, 11, 0, 0, 0, 20, 0, 0, 0, 0, 13, 0, 12, 0, 0, 0, 21, 0, 0,
0, 0, 0, 0, 0, 16, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 17, 11, 11,
13, 19, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 14, 20, 0, 0, 0, 0, 0, 0,
0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0,
0, 16, 6, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 17, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0,
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 18, 0, 0, 5, 2,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5, 8, 0, 0, 0, 0, 7, 0 0, 0, 1, 0, 0, 0, 0, 6, 9, 0,
0, 0, 0, 8, 0
} ; } ;
static yyconst flex_int32_t yy_ec[256] = static yyconst flex_int32_t yy_ec[256] =
@@ -416,9 +416,9 @@ static yyconst flex_int32_t yy_ec[256] =
22, 22, 22, 22, 24, 22, 22, 25, 22, 22, 22, 22, 22, 22, 24, 22, 22, 25, 22, 22,
1, 26, 27, 1, 22, 1, 21, 28, 29, 30, 1, 26, 27, 1, 22, 1, 21, 28, 29, 30,
31, 21, 22, 22, 32, 22, 22, 33, 34, 35, 31, 21, 32, 22, 33, 22, 22, 34, 35, 36,
36, 37, 22, 38, 39, 40, 41, 42, 22, 25, 37, 38, 22, 39, 40, 41, 42, 43, 22, 25,
43, 22, 44, 45, 46, 1, 1, 1, 1, 1, 44, 22, 45, 46, 47, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -435,163 +435,165 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1 1, 1, 1, 1, 1
} ; } ;
static yyconst flex_int32_t yy_meta[47] = static yyconst flex_int32_t yy_meta[48] =
{ 0, { 0,
1, 1, 1, 1, 1, 1, 2, 3, 1, 2, 1, 1, 1, 1, 1, 1, 2, 3, 1, 2,
2, 2, 4, 5, 5, 5, 6, 1, 1, 1, 2, 2, 4, 5, 5, 5, 6, 1, 1, 1,
7, 8, 8, 8, 8, 1, 1, 7, 7, 7, 7, 8, 8, 8, 8, 1, 1, 7, 7, 7,
7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 3, 1, 4 8, 8, 8, 8, 3, 1, 4
} ; } ;
static yyconst flex_int16_t yy_base[173] = static yyconst flex_int16_t yy_base[180] =
{ 0, { 0,
0, 383, 34, 382, 65, 381, 37, 105, 387, 391, 0, 393, 35, 392, 66, 391, 38, 107, 397, 401,
54, 111, 367, 110, 109, 109, 112, 41, 366, 104, 55, 113, 377, 112, 111, 111, 114, 42, 376, 106,
367, 338, 124, 117, 0, 144, 391, 0, 121, 0, 377, 347, 126, 120, 0, 147, 401, 0, 124, 0,
135, 155, 140, 179, 391, 160, 391, 379, 391, 0, 137, 158, 170, 163, 401, 153, 401, 389, 401, 0,
368, 141, 391, 167, 370, 376, 346, 103, 342, 345, 378, 120, 401, 131, 380, 386, 355, 139, 351, 355,
391, 391, 391, 391, 391, 358, 391, 391, 175, 342, 351, 401, 401, 401, 401, 401, 367, 401, 401, 185,
338, 391, 355, 0, 185, 339, 184, 347, 346, 0, 350, 346, 401, 364, 0, 185, 347, 189, 356, 355,
0, 322, 175, 357, 175, 363, 352, 324, 330, 323, 0, 0, 330, 180, 366, 141, 372, 361, 332, 338,
332, 326, 201, 324, 329, 322, 391, 333, 181, 309, 331, 341, 334, 326, 205, 331, 337, 329, 401, 341,
391, 341, 340, 313, 320, 338, 178, 311, 146, 317, 167, 316, 401, 349, 348, 320, 328, 346, 180, 318,
314, 315, 335, 331, 303, 300, 309, 299, 308, 188, 324, 209, 324, 320, 322, 342, 338, 309, 306, 315,
336, 335, 391, 305, 320, 281, 283, 271, 203, 288, 305, 315, 312, 192, 342, 341, 401, 293, 306, 282,
281, 271, 266, 264, 245, 242, 208, 104, 391, 391, 268, 252, 255, 203, 285, 282, 272, 268, 252, 233,
244, 218, 204, 219, 206, 224, 201, 212, 204, 229, 232, 239, 208, 107, 401, 401, 238, 211, 401, 211,
215, 208, 207, 200, 219, 391, 233, 221, 200, 181, 212, 208, 228, 203, 215, 207, 233, 222, 212, 211,
391, 391, 149, 122, 86, 41, 391, 391, 245, 251, 203, 227, 401, 237, 225, 204, 185, 401, 401, 149,
259, 263, 267, 273, 280, 284, 292, 300, 304, 310, 128, 88, 42, 401, 401, 253, 259, 267, 271, 275,
318, 326 281, 288, 292, 300, 308, 312, 318, 326, 334
} ; } ;
static yyconst flex_int16_t yy_def[173] = static yyconst flex_int16_t yy_def[180] =
{ 0, { 0,
158, 1, 1, 3, 158, 5, 1, 1, 158, 158, 165, 1, 1, 3, 165, 5, 1, 1, 165, 165,
158, 158, 158, 159, 160, 161, 158, 158, 158, 158, 165, 165, 165, 166, 167, 168, 165, 165, 165, 165,
162, 158, 158, 158, 163, 162, 158, 164, 165, 164, 169, 165, 165, 165, 170, 169, 165, 171, 172, 171,
164, 158, 158, 158, 158, 159, 158, 159, 158, 166, 171, 165, 165, 165, 165, 166, 165, 166, 165, 173,
158, 161, 158, 161, 167, 168, 158, 158, 158, 158, 165, 168, 165, 168, 174, 175, 165, 165, 165, 165,
158, 158, 158, 158, 158, 162, 158, 158, 158, 158, 165, 165, 165, 165, 165, 165, 169, 165, 165, 165,
158, 158, 162, 164, 165, 164, 158, 158, 158, 169, 165, 165, 165, 169, 171, 172, 171, 165, 165, 165,
166, 170, 161, 167, 167, 168, 158, 158, 158, 158, 176, 173, 177, 168, 174, 174, 175, 165, 165, 165,
158, 158, 158, 158, 158, 164, 158, 158, 169, 170, 165, 165, 165, 165, 165, 165, 165, 171, 165, 165,
158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 176, 177, 165, 165, 165, 165, 165, 165, 165, 165,
158, 164, 158, 158, 158, 158, 158, 158, 158, 171, 165, 165, 165, 165, 171, 165, 165, 165, 165, 165,
158, 164, 158, 158, 158, 158, 158, 158, 171, 158, 165, 165, 165, 178, 165, 171, 165, 165, 165, 165,
171, 158, 158, 158, 158, 158, 158, 158, 158, 158, 165, 165, 165, 178, 165, 178, 165, 165, 165, 165,
158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
172, 158, 158, 158, 172, 158, 172, 158, 158, 158, 165, 165, 165, 165, 165, 165, 165, 179, 165, 165,
158, 158, 158, 158, 158, 158, 158, 0, 158, 158, 165, 179, 165, 179, 165, 165, 165, 165, 165, 165,
158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 165, 165, 165, 165, 0, 165, 165, 165, 165, 165,
158, 158 165, 165, 165, 165, 165, 165, 165, 165, 165
} ; } ;
static yyconst flex_int16_t yy_nxt[438] = static yyconst flex_int16_t yy_nxt[449] =
{ 0, { 0,
10, 11, 12, 11, 13, 14, 10, 15, 16, 10, 10, 11, 12, 11, 13, 14, 10, 15, 16, 10,
10, 10, 17, 10, 10, 10, 10, 18, 19, 20, 10, 10, 17, 10, 10, 10, 10, 18, 19, 20,
21, 21, 21, 21, 21, 10, 10, 21, 21, 21, 21, 21, 21, 21, 21, 10, 10, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 10, 22, 10, 24, 25, 25, 25, 21, 21, 21, 21, 10, 22, 10, 24, 25, 25,
32, 33, 33, 157, 26, 34, 34, 34, 51, 52, 25, 32, 33, 33, 164, 26, 34, 34, 34, 52,
27, 26, 26, 26, 26, 10, 11, 12, 11, 13, 53, 27, 26, 26, 26, 26, 10, 11, 12, 11,
14, 28, 15, 16, 28, 28, 28, 24, 28, 28, 13, 14, 28, 15, 16, 28, 28, 28, 24, 28,
28, 10, 18, 19, 20, 29, 29, 29, 29, 29, 28, 28, 10, 18, 19, 20, 29, 29, 29, 29,
30, 10, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 10, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 10, 22, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
10, 23, 34, 34, 34, 37, 39, 43, 32, 33, 10, 22, 10, 23, 34, 34, 34, 37, 39, 43,
33, 45, 54, 55, 46, 59, 45, 64, 156, 46, 32, 33, 33, 45, 55, 56, 46, 60, 43, 45,
64, 64, 64, 79, 44, 38, 59, 57, 134, 47, 65, 163, 46, 65, 65, 65, 44, 38, 60, 74,
135, 48, 80, 49, 47, 50, 48, 99, 61, 43, 58, 47, 141, 48, 142, 44, 49, 47, 50, 48,
50, 110, 41, 67, 67, 67, 60, 63, 63, 63, 76, 51, 62, 94, 50, 41, 44, 51, 37, 61,
57, 155, 68, 69, 63, 37, 44, 66, 67, 67, 64, 64, 64, 58, 34, 34, 34, 64, 162, 80,
67, 63, 63, 63, 63, 73, 59, 68, 69, 70, 67, 68, 68, 68, 64, 64, 64, 64, 38, 81,
34, 34, 34, 43, 75, 38, 154, 92, 83, 83, 69, 70, 71, 68, 68, 68, 60, 161, 43, 69,
83, 64, 44, 120, 64, 64, 64, 67, 67, 67, 70, 65, 69, 70, 65, 65, 65, 125, 85, 85,
44, 57, 99, 68, 69, 107, 68, 69, 120, 127, 85, 58, 68, 68, 68, 44, 102, 110, 125, 133,
108, 153, 152, 121, 83, 83, 83, 133, 133, 133, 102, 69, 70, 111, 114, 160, 159, 126, 85, 85,
146, 133, 133, 133, 146, 140, 140, 140, 121, 141, 85, 140, 140, 140, 140, 140, 140, 153, 126, 147,
140, 140, 140, 151, 141, 158, 150, 149, 148, 144, 147, 147, 153, 148, 147, 147, 147, 158, 148, 165,
147, 143, 142, 139, 147, 36, 36, 36, 36, 36, 157, 156, 155, 151, 150, 149, 146, 154, 145, 144,
36, 36, 36, 40, 138, 137, 136, 40, 40, 42, 143, 139, 154, 36, 36, 36, 36, 36, 36, 36,
42, 42, 42, 42, 42, 42, 42, 56, 56, 56, 36, 40, 138, 137, 136, 40, 40, 42, 42, 42,
56, 62, 132, 62, 64, 131, 130, 64, 129, 64, 42, 42, 42, 42, 42, 57, 57, 57, 57, 63,
64, 65, 128, 158, 65, 65, 65, 65, 71, 127, 135, 63, 65, 134, 165, 65, 133, 65, 65, 66,
71, 71, 74, 74, 74, 74, 74, 74, 74, 74, 132, 131, 66, 66, 66, 66, 72, 130, 72, 72,
76, 76, 76, 76, 76, 76, 76, 76, 89, 126, 75, 75, 75, 75, 75, 75, 75, 75, 77, 77,
89, 90, 125, 90, 90, 124, 90, 90, 119, 119, 77, 77, 77, 77, 77, 77, 91, 129, 91, 92,
119, 119, 119, 119, 119, 119, 145, 145, 145, 145, 128, 92, 92, 127, 92, 92, 124, 124, 124, 124,
145, 145, 145, 145, 123, 122, 59, 59, 118, 117, 124, 124, 124, 124, 152, 152, 152, 152, 152, 152,
116, 115, 114, 113, 45, 112, 108, 111, 109, 106, 152, 152, 60, 60, 123, 122, 121, 120, 119, 118,
105, 104, 46, 103, 91, 87, 102, 101, 100, 98, 117, 45, 116, 111, 115, 113, 112, 109, 108, 107,
97, 96, 95, 94, 93, 77, 75, 91, 88, 87, 46, 106, 93, 89, 105, 104, 103, 101, 100, 99,
86, 57, 85, 84, 57, 82, 81, 78, 77, 75, 98, 97, 96, 95, 78, 76, 93, 90, 89, 88,
72, 158, 58, 57, 53, 35, 158, 31, 23, 23, 58, 87, 86, 58, 84, 83, 82, 79, 78, 76,
9, 158, 158, 158, 158, 158, 158, 158, 158, 158, 73, 165, 59, 58, 54, 35, 165, 31, 23, 23,
158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 9, 165, 165, 165, 165, 165, 165, 165, 165, 165,
158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
158, 158, 158, 158, 158, 158, 158 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
165, 165, 165, 165, 165, 165, 165, 165
} ; } ;
static yyconst flex_int16_t yy_chk[438] = static yyconst flex_int16_t yy_chk[449] =
{ 0, { 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
7, 7, 7, 156, 3, 11, 11, 11, 18, 18, 3, 7, 7, 7, 163, 3, 11, 11, 11, 18,
3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 18, 3, 3, 3, 3, 3, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 8, 12, 12, 12, 14, 15, 16, 8, 8, 5, 5, 5, 8, 12, 12, 12, 14, 15, 16,
8, 17, 20, 20, 17, 23, 24, 29, 155, 24, 8, 8, 8, 17, 20, 20, 17, 23, 42, 24,
29, 29, 29, 48, 16, 14, 31, 29, 128, 17, 29, 162, 24, 29, 29, 29, 16, 14, 31, 44,
128, 17, 48, 17, 24, 17, 24, 99, 24, 42, 29, 17, 134, 17, 134, 42, 17, 24, 17, 24,
24, 99, 15, 33, 33, 33, 23, 26, 26, 26, 76, 17, 24, 76, 24, 15, 44, 24, 36, 23,
26, 154, 33, 33, 26, 36, 42, 31, 32, 32, 26, 26, 26, 26, 34, 34, 34, 26, 161, 48,
32, 26, 26, 26, 26, 44, 59, 32, 32, 32, 31, 32, 32, 32, 26, 26, 26, 26, 36, 48,
34, 34, 34, 73, 75, 36, 153, 75, 59, 59, 32, 32, 32, 33, 33, 33, 60, 160, 74, 91,
59, 65, 44, 110, 65, 65, 65, 67, 67, 67, 91, 66, 33, 33, 66, 66, 66, 114, 60, 60,
73, 65, 83, 89, 89, 97, 67, 67, 119, 127, 60, 66, 68, 68, 68, 74, 85, 99, 124, 133,
97, 150, 149, 110, 83, 83, 83, 133, 133, 133, 102, 68, 68, 99, 102, 157, 156, 114, 85, 85,
141, 127, 127, 127, 145, 136, 136, 136, 119, 136, 85, 133, 133, 133, 140, 140, 140, 148, 124, 143,
140, 140, 140, 148, 140, 147, 144, 143, 142, 139, 143, 143, 152, 143, 147, 147, 147, 155, 147, 154,
141, 138, 137, 135, 145, 159, 159, 159, 159, 159, 151, 150, 149, 146, 145, 144, 142, 148, 141, 138,
159, 159, 159, 160, 134, 132, 131, 160, 160, 161, 137, 132, 152, 166, 166, 166, 166, 166, 166, 166,
161, 161, 161, 161, 161, 161, 161, 162, 162, 162, 166, 167, 131, 130, 129, 167, 167, 168, 168, 168,
162, 163, 126, 163, 164, 125, 124, 164, 123, 164, 168, 168, 168, 168, 168, 169, 169, 169, 169, 170,
164, 165, 122, 121, 165, 165, 165, 165, 166, 120, 128, 170, 171, 127, 126, 171, 125, 171, 171, 172,
166, 166, 167, 167, 167, 167, 167, 167, 167, 167, 123, 122, 172, 172, 172, 172, 173, 121, 173, 173,
168, 168, 168, 168, 168, 168, 168, 168, 169, 118, 174, 174, 174, 174, 174, 174, 174, 174, 175, 175,
169, 170, 117, 170, 170, 116, 170, 170, 171, 171, 175, 175, 175, 175, 175, 175, 176, 120, 176, 177,
171, 171, 171, 171, 171, 171, 172, 172, 172, 172, 119, 177, 177, 118, 177, 177, 178, 178, 178, 178,
172, 172, 172, 172, 115, 114, 112, 111, 109, 108, 178, 178, 178, 178, 179, 179, 179, 179, 179, 179,
107, 106, 105, 104, 103, 102, 101, 100, 98, 96, 179, 179, 116, 115, 113, 112, 111, 110, 109, 108,
95, 94, 93, 92, 90, 88, 86, 85, 84, 82, 107, 106, 105, 104, 103, 101, 100, 98, 97, 96,
81, 80, 79, 78, 77, 76, 74, 72, 69, 68, 95, 94, 92, 90, 88, 87, 86, 84, 83, 82,
66, 63, 61, 60, 56, 50, 49, 47, 46, 45, 81, 80, 79, 78, 77, 75, 73, 70, 69, 67,
64, 62, 61, 57, 51, 50, 49, 47, 46, 45,
41, 38, 22, 21, 19, 13, 9, 6, 4, 2, 41, 38, 22, 21, 19, 13, 9, 6, 4, 2,
158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
158, 158, 158, 158, 158, 158, 158 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
165, 165, 165, 165, 165, 165, 165, 165
} ; } ;
static yy_state_type yy_last_accepting_state; static yy_state_type yy_last_accepting_state;
@@ -662,7 +664,7 @@ static int dts_version = 1;
static void push_input_file(const char *filename); static void push_input_file(const char *filename);
static bool pop_input_file(void); static bool pop_input_file(void);
static void lexical_error(const char *fmt, ...); static void lexical_error(const char *fmt, ...);
#line 666 "dtc-lexer.lex.c" #line 668 "dtc-lexer.lex.c"
#define INITIAL 0 #define INITIAL 0
#define BYTESTRING 1 #define BYTESTRING 1
@@ -704,7 +706,7 @@ FILE *yyget_out (void );
void yyset_out (FILE * out_str ); void yyset_out (FILE * out_str );
yy_size_t yyget_leng (void ); int yyget_leng (void );
char *yyget_text (void ); char *yyget_text (void );
@@ -853,6 +855,10 @@ YY_DECL
register char *yy_cp, *yy_bp; register char *yy_cp, *yy_bp;
register int yy_act; register int yy_act;
#line 68 "dtc-lexer.l"
#line 861 "dtc-lexer.lex.c"
if ( !(yy_init) ) if ( !(yy_init) )
{ {
(yy_init) = 1; (yy_init) = 1;
@@ -879,11 +885,6 @@ YY_DECL
yy_load_buffer_state( ); yy_load_buffer_state( );
} }
{
#line 68 "dtc-lexer.l"
#line 886 "dtc-lexer.lex.c"
while ( 1 ) /* loops until end-of-file is reached */ while ( 1 ) /* loops until end-of-file is reached */
{ {
yy_cp = (yy_c_buf_p); yy_cp = (yy_c_buf_p);
@@ -901,7 +902,7 @@ YY_DECL
yy_match: yy_match:
do do
{ {
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
if ( yy_accept[yy_current_state] ) if ( yy_accept[yy_current_state] )
{ {
(yy_last_accepting_state) = yy_current_state; (yy_last_accepting_state) = yy_current_state;
@@ -910,13 +911,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 159 ) if ( yy_current_state >= 166 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp; ++yy_cp;
} }
while ( yy_current_state != 158 ); while ( yy_current_state != 165 );
yy_cp = (yy_last_accepting_cpos); yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state); yy_current_state = (yy_last_accepting_state);
@@ -951,39 +952,31 @@ case 2:
YY_RULE_SETUP YY_RULE_SETUP
#line 75 "dtc-lexer.l" #line 75 "dtc-lexer.l"
{ {
char *line, *fnstart, *fnend; char *line, *tmp, *fn;
struct data fn;
/* skip text before line # */ /* skip text before line # */
line = yytext; line = yytext;
while (!isdigit((unsigned char)*line)) while (!isdigit((unsigned char)*line))
line++; line++;
/* skip digits in line # */
/* regexp ensures that first and list " tmp = line;
* in the whole yytext are those at while (!isspace((unsigned char)*tmp))
* beginning and end of the filename string */ tmp++;
fnstart = memchr(yytext, '"', yyleng); /* "NULL"-terminate line # */
for (fnend = yytext + yyleng - 1; *tmp = '\0';
*fnend != '"'; fnend--) /* start of filename */
; fn = strchr(tmp + 1, '"') + 1;
assert(fnstart && fnend && (fnend > fnstart)); /* strip trailing " from filename */
tmp = strchr(fn, '"');
fn = data_copy_escape_string(fnstart + 1, *tmp = 0;
fnend - fnstart - 1);
/* Don't allow nuls in filenames */
if (memchr(fn.val, '\0', fn.len - 1))
lexical_error("nul in line number directive");
/* -1 since #line is the number of the next line */ /* -1 since #line is the number of the next line */
srcpos_set_line(xstrdup(fn.val), atoi(line) - 1); srcpos_set_line(xstrdup(fn), atoi(line) - 1);
data_free(fn);
} }
YY_BREAK YY_BREAK
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(BYTESTRING): case YY_STATE_EOF(BYTESTRING):
case YY_STATE_EOF(PROPNODENAME): case YY_STATE_EOF(PROPNODENAME):
case YY_STATE_EOF(V1): case YY_STATE_EOF(V1):
#line 104 "dtc-lexer.l" #line 96 "dtc-lexer.l"
{ {
if (!pop_input_file()) { if (!pop_input_file()) {
yyterminate(); yyterminate();
@@ -993,7 +986,7 @@ case YY_STATE_EOF(V1):
case 3: case 3:
/* rule 3 can match eol */ /* rule 3 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 110 "dtc-lexer.l" #line 102 "dtc-lexer.l"
{ {
DPRINT("String: %s\n", yytext); DPRINT("String: %s\n", yytext);
yylval.data = data_copy_escape_string(yytext+1, yylval.data = data_copy_escape_string(yytext+1,
@@ -1003,7 +996,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 117 "dtc-lexer.l" #line 109 "dtc-lexer.l"
{ {
DPRINT("Keyword: /dts-v1/\n"); DPRINT("Keyword: /dts-v1/\n");
dts_version = 1; dts_version = 1;
@@ -1013,25 +1006,33 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 124 "dtc-lexer.l" #line 116 "dtc-lexer.l"
{
DPRINT("Keyword: /plugin/\n");
return DT_PLUGIN;
}
YY_BREAK
case 6:
YY_RULE_SETUP
#line 121 "dtc-lexer.l"
{ {
DPRINT("Keyword: /memreserve/\n"); DPRINT("Keyword: /memreserve/\n");
BEGIN_DEFAULT(); BEGIN_DEFAULT();
return DT_MEMRESERVE; return DT_MEMRESERVE;
} }
YY_BREAK YY_BREAK
case 6: case 7:
YY_RULE_SETUP YY_RULE_SETUP
#line 130 "dtc-lexer.l" #line 127 "dtc-lexer.l"
{ {
DPRINT("Keyword: /bits/\n"); DPRINT("Keyword: /bits/\n");
BEGIN_DEFAULT(); BEGIN_DEFAULT();
return DT_BITS; return DT_BITS;
} }
YY_BREAK YY_BREAK
case 7: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 136 "dtc-lexer.l" #line 133 "dtc-lexer.l"
{ {
DPRINT("Keyword: /delete-property/\n"); DPRINT("Keyword: /delete-property/\n");
DPRINT("<PROPNODENAME>\n"); DPRINT("<PROPNODENAME>\n");
@@ -1039,9 +1040,9 @@ YY_RULE_SETUP
return DT_DEL_PROP; return DT_DEL_PROP;
} }
YY_BREAK YY_BREAK
case 8: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 143 "dtc-lexer.l" #line 140 "dtc-lexer.l"
{ {
DPRINT("Keyword: /delete-node/\n"); DPRINT("Keyword: /delete-node/\n");
DPRINT("<PROPNODENAME>\n"); DPRINT("<PROPNODENAME>\n");
@@ -1049,9 +1050,9 @@ YY_RULE_SETUP
return DT_DEL_NODE; return DT_DEL_NODE;
} }
YY_BREAK YY_BREAK
case 9: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 150 "dtc-lexer.l" #line 147 "dtc-lexer.l"
{ {
DPRINT("Label: %s\n", yytext); DPRINT("Label: %s\n", yytext);
yylval.labelref = xstrdup(yytext); yylval.labelref = xstrdup(yytext);
@@ -1059,9 +1060,9 @@ YY_RULE_SETUP
return DT_LABEL; return DT_LABEL;
} }
YY_BREAK YY_BREAK
case 10: case 11:
YY_RULE_SETUP YY_RULE_SETUP
#line 157 "dtc-lexer.l" #line 154 "dtc-lexer.l"
{ {
char *e; char *e;
DPRINT("Integer Literal: '%s'\n", yytext); DPRINT("Integer Literal: '%s'\n", yytext);
@@ -1069,10 +1070,7 @@ YY_RULE_SETUP
errno = 0; errno = 0;
yylval.integer = strtoull(yytext, &e, 0); yylval.integer = strtoull(yytext, &e, 0);
if (*e && e[strspn(e, "UL")]) { assert(!(*e) || !e[strspn(e, "UL")]);
lexical_error("Bad integer literal '%s'",
yytext);
}
if (errno == ERANGE) if (errno == ERANGE)
lexical_error("Integer literal '%s' out of range", lexical_error("Integer literal '%s' out of range",
@@ -1084,10 +1082,10 @@ YY_RULE_SETUP
return DT_LITERAL; return DT_LITERAL;
} }
YY_BREAK YY_BREAK
case 11: case 12:
/* rule 11 can match eol */ /* rule 12 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 179 "dtc-lexer.l" #line 173 "dtc-lexer.l"
{ {
struct data d; struct data d;
DPRINT("Character literal: %s\n", yytext); DPRINT("Character literal: %s\n", yytext);
@@ -1109,18 +1107,18 @@ YY_RULE_SETUP
return DT_CHAR_LITERAL; return DT_CHAR_LITERAL;
} }
YY_BREAK YY_BREAK
case 12: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 200 "dtc-lexer.l" #line 194 "dtc-lexer.l"
{ /* label reference */ { /* label reference */
DPRINT("Ref: %s\n", yytext+1); DPRINT("Ref: %s\n", yytext+1);
yylval.labelref = xstrdup(yytext+1); yylval.labelref = xstrdup(yytext+1);
return DT_REF; return DT_REF;
} }
YY_BREAK YY_BREAK
case 13: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 206 "dtc-lexer.l" #line 200 "dtc-lexer.l"
{ /* new-style path reference */ { /* new-style path reference */
yytext[yyleng-1] = '\0'; yytext[yyleng-1] = '\0';
DPRINT("Ref: %s\n", yytext+2); DPRINT("Ref: %s\n", yytext+2);
@@ -1128,27 +1126,27 @@ YY_RULE_SETUP
return DT_REF; return DT_REF;
} }
YY_BREAK YY_BREAK
case 14: case 15:
YY_RULE_SETUP YY_RULE_SETUP
#line 213 "dtc-lexer.l" #line 207 "dtc-lexer.l"
{ {
yylval.byte = strtol(yytext, NULL, 16); yylval.byte = strtol(yytext, NULL, 16);
DPRINT("Byte: %02x\n", (int)yylval.byte); DPRINT("Byte: %02x\n", (int)yylval.byte);
return DT_BYTE; return DT_BYTE;
} }
YY_BREAK YY_BREAK
case 15: case 16:
YY_RULE_SETUP YY_RULE_SETUP
#line 219 "dtc-lexer.l" #line 213 "dtc-lexer.l"
{ {
DPRINT("/BYTESTRING\n"); DPRINT("/BYTESTRING\n");
BEGIN_DEFAULT(); BEGIN_DEFAULT();
return ']'; return ']';
} }
YY_BREAK YY_BREAK
case 16: case 17:
YY_RULE_SETUP YY_RULE_SETUP
#line 225 "dtc-lexer.l" #line 219 "dtc-lexer.l"
{ {
DPRINT("PropNodeName: %s\n", yytext); DPRINT("PropNodeName: %s\n", yytext);
yylval.propnodename = xstrdup((yytext[0] == '\\') ? yylval.propnodename = xstrdup((yytext[0] == '\\') ?
@@ -1157,75 +1155,75 @@ YY_RULE_SETUP
return DT_PROPNODENAME; return DT_PROPNODENAME;
} }
YY_BREAK YY_BREAK
case 17: case 18:
YY_RULE_SETUP YY_RULE_SETUP
#line 233 "dtc-lexer.l" #line 227 "dtc-lexer.l"
{ {
DPRINT("Binary Include\n"); DPRINT("Binary Include\n");
return DT_INCBIN; return DT_INCBIN;
} }
YY_BREAK YY_BREAK
case 18:
/* rule 18 can match eol */
YY_RULE_SETUP
#line 238 "dtc-lexer.l"
/* eat whitespace */
YY_BREAK
case 19: case 19:
/* rule 19 can match eol */ /* rule 19 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 239 "dtc-lexer.l" #line 232 "dtc-lexer.l"
/* eat C-style comments */ /* eat whitespace */
YY_BREAK YY_BREAK
case 20: case 20:
/* rule 20 can match eol */ /* rule 20 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 240 "dtc-lexer.l" #line 233 "dtc-lexer.l"
/* eat C++-style comments */ /* eat C-style comments */
YY_BREAK YY_BREAK
case 21: case 21:
/* rule 21 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 242 "dtc-lexer.l" #line 234 "dtc-lexer.l"
{ return DT_LSHIFT; }; /* eat C++-style comments */
YY_BREAK YY_BREAK
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
#line 243 "dtc-lexer.l" #line 236 "dtc-lexer.l"
{ return DT_RSHIFT; }; { return DT_LSHIFT; };
YY_BREAK YY_BREAK
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 244 "dtc-lexer.l" #line 237 "dtc-lexer.l"
{ return DT_LE; }; { return DT_RSHIFT; };
YY_BREAK YY_BREAK
case 24: case 24:
YY_RULE_SETUP YY_RULE_SETUP
#line 245 "dtc-lexer.l" #line 238 "dtc-lexer.l"
{ return DT_GE; }; { return DT_LE; };
YY_BREAK YY_BREAK
case 25: case 25:
YY_RULE_SETUP YY_RULE_SETUP
#line 246 "dtc-lexer.l" #line 239 "dtc-lexer.l"
{ return DT_EQ; }; { return DT_GE; };
YY_BREAK YY_BREAK
case 26: case 26:
YY_RULE_SETUP YY_RULE_SETUP
#line 247 "dtc-lexer.l" #line 240 "dtc-lexer.l"
{ return DT_NE; }; { return DT_EQ; };
YY_BREAK YY_BREAK
case 27: case 27:
YY_RULE_SETUP YY_RULE_SETUP
#line 248 "dtc-lexer.l" #line 241 "dtc-lexer.l"
{ return DT_AND; }; { return DT_NE; };
YY_BREAK YY_BREAK
case 28: case 28:
YY_RULE_SETUP YY_RULE_SETUP
#line 249 "dtc-lexer.l" #line 242 "dtc-lexer.l"
{ return DT_OR; }; { return DT_AND; };
YY_BREAK YY_BREAK
case 29: case 29:
YY_RULE_SETUP YY_RULE_SETUP
#line 251 "dtc-lexer.l" #line 243 "dtc-lexer.l"
{ return DT_OR; };
YY_BREAK
case 30:
YY_RULE_SETUP
#line 245 "dtc-lexer.l"
{ {
DPRINT("Char: %c (\\x%02x)\n", yytext[0], DPRINT("Char: %c (\\x%02x)\n", yytext[0],
(unsigned)yytext[0]); (unsigned)yytext[0]);
@@ -1241,12 +1239,12 @@ YY_RULE_SETUP
return yytext[0]; return yytext[0];
} }
YY_BREAK YY_BREAK
case 30: case 31:
YY_RULE_SETUP YY_RULE_SETUP
#line 266 "dtc-lexer.l" #line 260 "dtc-lexer.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1250 "dtc-lexer.lex.c" #line 1248 "dtc-lexer.lex.c"
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
{ {
@@ -1376,7 +1374,6 @@ ECHO;
"fatal flex scanner internal error--no action found" ); "fatal flex scanner internal error--no action found" );
} /* end of action switch */ } /* end of action switch */
} /* end of scanning one token */ } /* end of scanning one token */
} /* end of user's declarations */
} /* end of yylex */ } /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer /* yy_get_next_buffer - try to read in a new buffer
@@ -1432,21 +1429,21 @@ static int yy_get_next_buffer (void)
else else
{ {
yy_size_t num_to_read = int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 ) while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */ { /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */ /* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
int yy_c_buf_p_offset = int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf); (int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer ) if ( b->yy_is_our_buffer )
{ {
yy_size_t new_size = b->yy_buf_size * 2; int new_size = b->yy_buf_size * 2;
if ( new_size <= 0 ) if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8; b->yy_buf_size += b->yy_buf_size / 8;
@@ -1477,7 +1474,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */ /* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), num_to_read ); (yy_n_chars), (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
} }
@@ -1539,7 +1536,7 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 159 ) if ( yy_current_state >= 166 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1567,13 +1564,13 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 159 ) if ( yy_current_state >= 166 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 158); yy_is_jam = (yy_current_state == 165);
return yy_is_jam ? 0 : yy_current_state; return yy_is_jam ? 0 : yy_current_state;
} }
#ifndef YY_NO_INPUT #ifndef YY_NO_INPUT
@@ -1600,7 +1597,7 @@ static int yy_get_next_buffer (void)
else else
{ /* need more input */ { /* need more input */
yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); int offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p); ++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) ) switch ( yy_get_next_buffer( ) )
@@ -1874,7 +1871,7 @@ void yypop_buffer_state (void)
*/ */
static void yyensure_buffer_stack (void) static void yyensure_buffer_stack (void)
{ {
yy_size_t num_to_alloc; int num_to_alloc;
if (!(yy_buffer_stack)) { if (!(yy_buffer_stack)) {
@@ -1971,12 +1968,12 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
* *
* @return the newly allocated buffer state object. * @return the newly allocated buffer state object.
*/ */
YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
{ {
YY_BUFFER_STATE b; YY_BUFFER_STATE b;
char *buf; char *buf;
yy_size_t n; yy_size_t n;
yy_size_t i; int i;
/* Get memory for full buffer, including space for trailing EOB's. */ /* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2; n = _yybytes_len + 2;
@@ -2058,7 +2055,7 @@ FILE *yyget_out (void)
/** Get the length of the current token. /** Get the length of the current token.
* *
*/ */
yy_size_t yyget_leng (void) int yyget_leng (void)
{ {
return yyleng; return yyleng;
} }
@@ -2206,7 +2203,7 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables" #define YYTABLES_NAME "yytables"
#line 265 "dtc-lexer.l" #line 260 "dtc-lexer.l"

File diff suppressed because it is too large Load Diff

View File

@@ -46,26 +46,27 @@ extern int yydebug;
enum yytokentype enum yytokentype
{ {
DT_V1 = 258, DT_V1 = 258,
DT_MEMRESERVE = 259, DT_PLUGIN = 259,
DT_LSHIFT = 260, DT_MEMRESERVE = 260,
DT_RSHIFT = 261, DT_LSHIFT = 261,
DT_LE = 262, DT_RSHIFT = 262,
DT_GE = 263, DT_LE = 263,
DT_EQ = 264, DT_GE = 264,
DT_NE = 265, DT_EQ = 265,
DT_AND = 266, DT_NE = 266,
DT_OR = 267, DT_AND = 267,
DT_BITS = 268, DT_OR = 268,
DT_DEL_PROP = 269, DT_BITS = 269,
DT_DEL_NODE = 270, DT_DEL_PROP = 270,
DT_PROPNODENAME = 271, DT_DEL_NODE = 271,
DT_LITERAL = 272, DT_PROPNODENAME = 272,
DT_CHAR_LITERAL = 273, DT_LITERAL = 273,
DT_BYTE = 274, DT_CHAR_LITERAL = 274,
DT_STRING = 275, DT_BYTE = 275,
DT_LABEL = 276, DT_STRING = 276,
DT_REF = 277, DT_LABEL = 277,
DT_INCBIN = 278 DT_REF = 278,
DT_INCBIN = 279
}; };
#endif #endif
@@ -74,7 +75,7 @@ extern int yydebug;
typedef union YYSTYPE YYSTYPE; typedef union YYSTYPE YYSTYPE;
union YYSTYPE union YYSTYPE
{ {
#line 38 "dtc-parser.y" /* yacc.c:1909 */ #line 39 "dtc-parser.y" /* yacc.c:1909 */
char *propnodename; char *propnodename;
char *labelref; char *labelref;
@@ -92,8 +93,9 @@ union YYSTYPE
struct node *nodelist; struct node *nodelist;
struct reserve_info *re; struct reserve_info *re;
uint64_t integer; uint64_t integer;
bool is_plugin;
#line 97 "dtc-parser.tab.h" /* yacc.c:1909 */ #line 99 "dtc-parser.tab.h" /* yacc.c:1909 */
}; };
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1

View File

@@ -19,6 +19,7 @@
*/ */
%{ %{
#include <stdio.h> #include <stdio.h>
#include <inttypes.h>
#include "dtc.h" #include "dtc.h"
#include "srcpos.h" #include "srcpos.h"
@@ -52,9 +53,11 @@ extern bool treesource_error;
struct node *nodelist; struct node *nodelist;
struct reserve_info *re; struct reserve_info *re;
uint64_t integer; uint64_t integer;
bool is_plugin;
} }
%token DT_V1 %token DT_V1
%token DT_PLUGIN
%token DT_MEMRESERVE %token DT_MEMRESERVE
%token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ DT_NE DT_AND DT_OR %token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ DT_NE DT_AND DT_OR
%token DT_BITS %token DT_BITS
@@ -71,6 +74,7 @@ extern bool treesource_error;
%type <data> propdata %type <data> propdata
%type <data> propdataprefix %type <data> propdataprefix
%type <is_plugin> plugindecl
%type <re> memreserve %type <re> memreserve
%type <re> memreserves %type <re> memreserves
%type <array> arrayprefix %type <array> arrayprefix
@@ -101,10 +105,22 @@ extern bool treesource_error;
%% %%
sourcefile: sourcefile:
DT_V1 ';' memreserves devicetree DT_V1 ';' plugindecl memreserves devicetree
{ {
the_boot_info = build_boot_info($3, $4, $5->is_plugin = $3;
guess_boot_cpuid($4)); the_boot_info = build_boot_info($4, $5,
guess_boot_cpuid($5));
}
;
plugindecl:
/* empty */
{
$$ = false;
}
| DT_PLUGIN ';'
{
$$ = true;
} }
; ;

View File

@@ -31,6 +31,7 @@ int reservenum; /* Number of memory reservation slots */
int minsize; /* Minimum blob size */ int minsize; /* Minimum blob size */
int padsize; /* Additional padding to blob */ int padsize; /* Additional padding to blob */
int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */ int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */
int symbol_fixup_support = 0;
static void fill_fullpaths(struct node *tree, const char *prefix) static void fill_fullpaths(struct node *tree, const char *prefix)
{ {
@@ -53,7 +54,7 @@ static void fill_fullpaths(struct node *tree, const char *prefix)
#define FDT_VERSION(version) _FDT_VERSION(version) #define FDT_VERSION(version) _FDT_VERSION(version)
#define _FDT_VERSION(version) #version #define _FDT_VERSION(version) #version
static const char usage_synopsis[] = "dtc [options] <input file>"; static const char usage_synopsis[] = "dtc [options] <input file>";
static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv"; static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:@hv";
static struct option const usage_long_opts[] = { static struct option const usage_long_opts[] = {
{"quiet", no_argument, NULL, 'q'}, {"quiet", no_argument, NULL, 'q'},
{"in-format", a_argument, NULL, 'I'}, {"in-format", a_argument, NULL, 'I'},
@@ -71,6 +72,7 @@ static struct option const usage_long_opts[] = {
{"phandle", a_argument, NULL, 'H'}, {"phandle", a_argument, NULL, 'H'},
{"warning", a_argument, NULL, 'W'}, {"warning", a_argument, NULL, 'W'},
{"error", a_argument, NULL, 'E'}, {"error", a_argument, NULL, 'E'},
{"symbols", no_argument, NULL, '@'},
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'}, {"version", no_argument, NULL, 'v'},
{NULL, no_argument, NULL, 0x0}, {NULL, no_argument, NULL, 0x0},
@@ -101,6 +103,7 @@ static const char * const usage_opts_help[] = {
"\t\tboth - Both \"linux,phandle\" and \"phandle\" properties", "\t\tboth - Both \"linux,phandle\" and \"phandle\" properties",
"\n\tEnable/disable warnings (prefix with \"no-\")", "\n\tEnable/disable warnings (prefix with \"no-\")",
"\n\tEnable/disable errors (prefix with \"no-\")", "\n\tEnable/disable errors (prefix with \"no-\")",
"\n\tEnable symbols/fixup support",
"\n\tPrint this help and exit", "\n\tPrint this help and exit",
"\n\tPrint version and exit", "\n\tPrint version and exit",
NULL, NULL,
@@ -233,7 +236,9 @@ int main(int argc, char *argv[])
case 'E': case 'E':
parse_checks_option(false, true, optarg); parse_checks_option(false, true, optarg);
break; break;
case '@':
symbol_fixup_support = 1;
break;
case 'h': case 'h':
usage(NULL); usage(NULL);
default: default:

View File

@@ -54,6 +54,7 @@ extern int reservenum; /* Number of memory reservation slots */
extern int minsize; /* Minimum blob size */ extern int minsize; /* Minimum blob size */
extern int padsize; /* Additional padding to blob */ extern int padsize; /* Additional padding to blob */
extern int phandle_format; /* Use linux,phandle or phandle properties */ extern int phandle_format; /* Use linux,phandle or phandle properties */
extern int symbol_fixup_support;/* enable symbols & fixup support */
#define PHANDLE_LEGACY 0x1 #define PHANDLE_LEGACY 0x1
#define PHANDLE_EPAPR 0x2 #define PHANDLE_EPAPR 0x2
@@ -132,6 +133,26 @@ struct label {
struct label *next; struct label *next;
}; };
struct fixup_entry {
int offset;
struct node *node;
struct property *prop;
struct fixup_entry *next;
bool local_fixup_generated;
};
struct fixup {
char *ref;
struct fixup_entry *entries;
struct fixup *next;
};
struct symbol {
struct label *label;
struct node *node;
struct symbol *next;
};
struct property { struct property {
bool deleted; bool deleted;
char *name; char *name;
@@ -158,6 +179,13 @@ struct node {
int addr_cells, size_cells; int addr_cells, size_cells;
struct label *labels; struct label *labels;
struct symbol *symbols;
struct fixup_entry *local_fixups;
bool emit_local_fixup_node;
bool is_plugin;
struct fixup *fixups;
}; };
#define for_each_label_withdel(l0, l) \ #define for_each_label_withdel(l0, l) \
@@ -181,6 +209,18 @@ struct node {
for_each_child_withdel(n, c) \ for_each_child_withdel(n, c) \
if (!(c)->deleted) if (!(c)->deleted)
#define for_each_fixup(n, f) \
for ((f) = (n)->fixups; (f); (f) = (f)->next)
#define for_each_fixup_entry(f, fe) \
for ((fe) = (f)->entries; (fe); (fe) = (fe)->next)
#define for_each_symbol(n, s) \
for ((s) = (n)->symbols; (s); (s) = (s)->next)
#define for_each_local_fixup_entry(n, fe) \
for ((fe) = (n)->local_fixups; (fe); (fe) = (fe)->next)
void add_label(struct label **labels, char *label); void add_label(struct label **labels, char *label);
void delete_labels(struct label **labels); void delete_labels(struct label **labels);

View File

@@ -255,6 +255,204 @@ static int stringtable_insert(struct data *d, const char *str)
return i; return i;
} }
static void emit_local_fixups(struct node *tree, struct emitter *emit,
void *etarget, struct data *strbuf, struct version_info *vi,
struct node *node)
{
struct fixup_entry *fe, *fen;
struct node *child;
int nameoff, count;
cell_t *buf;
struct data d;
if (node->emit_local_fixup_node) {
/* emit the external fixups (do not emit /) */
if (node != tree) {
emit->beginnode(etarget, NULL);
emit->string(etarget, node->name, 0);
emit->align(etarget, sizeof(cell_t));
}
for_each_local_fixup_entry(tree, fe) {
if (fe->node != node || fe->local_fixup_generated)
continue;
/* count the number of fixup entries */
count = 0;
for_each_local_fixup_entry(tree, fen) {
if (fen->prop != fe->prop)
continue;
fen->local_fixup_generated = true;
count++;
}
/* allocate buffer */
buf = xmalloc(count * sizeof(cell_t));
/* collect all the offsets in buffer */
count = 0;
for_each_local_fixup_entry(tree, fen) {
if (fen->prop != fe->prop)
continue;
fen->local_fixup_generated = true;
buf[count++] = cpu_to_fdt32(fen->offset);
}
d = empty_data;
d.len = count * sizeof(cell_t);
d.val = (char *)buf;
nameoff = stringtable_insert(strbuf, fe->prop->name);
emit->property(etarget, fe->prop->labels);
emit->cell(etarget, count * sizeof(cell_t));
emit->cell(etarget, nameoff);
if ((vi->flags & FTF_VARALIGN) &&
(count * sizeof(cell_t)) >= 8)
emit->align(etarget, 8);
emit->data(etarget, d);
emit->align(etarget, sizeof(cell_t));
free(buf);
}
}
for_each_child(node, child)
emit_local_fixups(tree, emit, etarget, strbuf, vi, child);
if (node->emit_local_fixup_node && node != tree)
emit->endnode(etarget, tree->labels);
}
static void emit_symbols_node(struct node *tree, struct emitter *emit,
void *etarget, struct data *strbuf,
struct version_info *vi)
{
struct symbol *sym;
int nameoff, vallen;
/* do nothing if no symbols */
if (!tree->symbols)
return;
emit->beginnode(etarget, NULL);
emit->string(etarget, "__symbols__", 0);
emit->align(etarget, sizeof(cell_t));
for_each_symbol(tree, sym) {
vallen = strlen(sym->node->fullpath);
nameoff = stringtable_insert(strbuf, sym->label->label);
emit->property(etarget, NULL);
emit->cell(etarget, vallen + 1);
emit->cell(etarget, nameoff);
if ((vi->flags & FTF_VARALIGN) && vallen >= 8)
emit->align(etarget, 8);
emit->string(etarget, sym->node->fullpath,
strlen(sym->node->fullpath));
emit->align(etarget, sizeof(cell_t));
}
emit->endnode(etarget, NULL);
}
static void emit_local_fixups_node(struct node *tree, struct emitter *emit,
void *etarget, struct data *strbuf,
struct version_info *vi)
{
struct fixup_entry *fe;
struct node *node;
/* do nothing if no local fixups */
if (!tree->local_fixups)
return;
/* mark all nodes that need a local fixup generated (and parents) */
for_each_local_fixup_entry(tree, fe) {
node = fe->node;
while (node != NULL && !node->emit_local_fixup_node) {
node->emit_local_fixup_node = true;
node = node->parent;
}
}
/* emit the local fixups node now */
emit->beginnode(etarget, NULL);
emit->string(etarget, "__local_fixups__", 0);
emit->align(etarget, sizeof(cell_t));
emit_local_fixups(tree, emit, etarget, strbuf, vi, tree);
emit->endnode(etarget, tree->labels);
}
static void emit_fixups_node(struct node *tree, struct emitter *emit,
void *etarget, struct data *strbuf,
struct version_info *vi)
{
struct fixup *f;
struct fixup_entry *fe;
char *name, *s;
const char *fullpath;
int namesz, nameoff, vallen;
/* do nothing if no fixups */
if (!tree->fixups)
return;
/* emit the external fixups */
emit->beginnode(etarget, NULL);
emit->string(etarget, "__fixups__", 0);
emit->align(etarget, sizeof(cell_t));
for_each_fixup(tree, f) {
namesz = 0;
for_each_fixup_entry(f, fe) {
fullpath = fe->node->fullpath;
if (fullpath[0] == '\0')
fullpath = "/";
namesz += strlen(fullpath) + 1;
namesz += strlen(fe->prop->name) + 1;
namesz += 32; /* space for :<number> + '\0' */
}
name = xmalloc(namesz);
s = name;
for_each_fixup_entry(f, fe) {
fullpath = fe->node->fullpath;
if (fullpath[0] == '\0')
fullpath = "/";
snprintf(s, name + namesz - s, "%s:%s:%d", fullpath,
fe->prop->name, fe->offset);
s += strlen(s) + 1;
}
nameoff = stringtable_insert(strbuf, f->ref);
vallen = s - name - 1;
emit->property(etarget, NULL);
emit->cell(etarget, vallen + 1);
emit->cell(etarget, nameoff);
if ((vi->flags & FTF_VARALIGN) && vallen >= 8)
emit->align(etarget, 8);
emit->string(etarget, name, vallen);
emit->align(etarget, sizeof(cell_t));
free(name);
}
emit->endnode(etarget, tree->labels);
}
static void flatten_tree(struct node *tree, struct emitter *emit, static void flatten_tree(struct node *tree, struct emitter *emit,
void *etarget, struct data *strbuf, void *etarget, struct data *strbuf,
struct version_info *vi) struct version_info *vi)
@@ -310,6 +508,10 @@ static void flatten_tree(struct node *tree, struct emitter *emit,
flatten_tree(child, emit, etarget, strbuf, vi); flatten_tree(child, emit, etarget, strbuf, vi);
} }
emit_symbols_node(tree, emit, etarget, strbuf, vi);
emit_local_fixups_node(tree, emit, etarget, strbuf, vi);
emit_fixups_node(tree, emit, etarget, strbuf, vi);
emit->endnode(etarget, tree->labels); emit->endnode(etarget, tree->labels);
} }

View File

@@ -1 +1 @@
#define DTC_VERSION "DTC 1.4.1-g53bf130b" #define DTC_VERSION "DTC 1.4.1-g25efc119"