2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
28 unsigned long long eval_literal(const char *s, int base, int bits);
30 extern struct boot_info *the_boot_info;
44 struct property *prop;
45 struct property *proplist;
47 struct node *nodelist;
48 struct reserve_info *re;
53 %token <propnodename> DT_PROPNODENAME
54 %token <literal> DT_LITERAL
55 %token <literal> DT_LEGACYLITERAL
56 %token <cbase> DT_BASE
58 %token <data> DT_STRING
59 %token <labelref> DT_LABEL
60 %token <labelref> DT_REF
63 %type <data> propdataprefix
65 %type <re> memreserves
66 %type <re> v0_memreserve
67 %type <re> v0_memreserves
70 %type <cbase> cellbase
72 %type <data> bytestring
74 %type <proplist> proplist
76 %type <node> devicetree
79 %type <nodelist> subnodes
80 %type <labelref> label
85 DT_V1 ';' memreserves devicetree
87 the_boot_info = build_boot_info($3, $4);
89 | v0_memreserves devicetree
91 the_boot_info = build_boot_info($1, $2);
100 | memreserve memreserves
102 $$ = chain_reserve_entry($1, $2);
107 label DT_MEMRESERVE addr addr ';'
109 $$ = build_reserve_entry($3, $4, $1);
118 | v0_memreserve v0_memreserves
120 $$ = chain_reserve_entry($1, $2);
129 | label DT_MEMRESERVE addr '-' addr ';'
131 $$ = build_reserve_entry($3, $5 - $3 + 1, $1);
138 $$ = eval_literal($1, 0, 64);
142 $$ = eval_literal($1, 16, 64);
149 $$ = name_node($2, "", NULL);
154 '{' proplist subnodes '}' ';'
156 $$ = build_node($2, $3);
167 $$ = chain_property($2, $1);
172 label DT_PROPNODENAME '=' propdata ';'
174 $$ = build_property($2, $4, $1);
176 | label DT_PROPNODENAME ';'
178 $$ = build_property($2, empty_data, $1);
183 propdataprefix DT_STRING
185 $$ = data_merge($1, $2);
187 | propdataprefix '<' celllist '>'
189 $$ = data_merge($1, $3);
191 | propdataprefix '[' bytestring ']'
193 $$ = data_merge($1, $3);
195 | propdataprefix DT_REF
197 $$ = data_add_marker($1, REF_PATH, $2);
201 $$ = data_add_marker($1, LABEL, $2);
214 | propdataprefix DT_LABEL
216 $$ = data_add_marker($1, LABEL, $2);
227 $$ = data_append_cell($1, $2);
231 $$ = data_append_cell(data_add_marker($1, REF_PHANDLE,
236 $$ = data_add_marker($1, LABEL, $2);
251 $$ = eval_literal($1, 0, 32);
253 | cellbase DT_LEGACYLITERAL
255 $$ = eval_literal($2, $1, 32);
266 $$ = data_append_byte($1, $2);
268 | bytestring DT_LABEL
270 $$ = data_add_marker($1, LABEL, $2);
281 $$ = chain_node($1, $2);
285 yyerror("syntax error: properties must precede subnodes\n");
291 label DT_PROPNODENAME nodedef
293 $$ = name_node($3, $2, $1);
310 void yyerror (char const *s)
312 const char *fname = srcpos_filename_for_num(yylloc.filenum);
314 if (strcmp(fname, "-") == 0)
317 fprintf(stderr, "%s:%d %s\n",
318 fname, yylloc.first_line, s);
321 unsigned long long eval_literal(const char *s, int base, int bits)
323 unsigned long long val;
327 val = strtoull(s, &e, base);
329 yyerror("bad characters in literal");
330 else if ((errno == ERANGE)
331 || ((bits < 64) && (val >= (1ULL << bits))))
332 yyerror("literal out of range");
334 yyerror("bad literal");