~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/scripts/dtc/dtc-parser.y

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /scripts/dtc/dtc-parser.y (Architecture alpha) and /scripts/dtc/dtc-parser.y (Architecture sparc64)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*                                                  2 /*
  3  * (C) Copyright David Gibson <dwg@au1.ibm.com>      3  * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation.  2005.
  4  */                                                 4  */
  5 %locations                                          5 %locations
  6                                                     6 
  7 %{                                                  7 %{
  8 #include <stdio.h>                                  8 #include <stdio.h>
  9 #include <inttypes.h>                               9 #include <inttypes.h>
 10                                                    10 
 11 #include "dtc.h"                                   11 #include "dtc.h"
 12 #include "srcpos.h"                                12 #include "srcpos.h"
 13                                                    13 
 14 extern int yylex(void);                            14 extern int yylex(void);
 15 extern void yyerror(char const *s);                15 extern void yyerror(char const *s);
 16 #define ERROR(loc, ...) \                          16 #define ERROR(loc, ...) \
 17         do { \                                     17         do { \
 18                 srcpos_error((loc), "Error", _     18                 srcpos_error((loc), "Error", __VA_ARGS__); \
 19                 treesource_error = true; \         19                 treesource_error = true; \
 20         } while (0)                                20         } while (0)
 21                                                    21 
 22 #define YYERROR_CALL(msg) yyerror(msg)             22 #define YYERROR_CALL(msg) yyerror(msg)
 23                                                    23 
 24 extern struct dt_info *parser_output;              24 extern struct dt_info *parser_output;
 25 extern bool treesource_error;                      25 extern bool treesource_error;
 26                                                    26 
 27 static bool is_ref_relative(const char *ref)       27 static bool is_ref_relative(const char *ref)
 28 {                                                  28 {
 29         return ref[0] != '/' && strchr(&ref[1]     29         return ref[0] != '/' && strchr(&ref[1], '/');
 30 }                                                  30 }
 31                                                    31 
 32 %}                                                 32 %}
 33                                                    33 
 34 %union {                                           34 %union {
 35         char *propnodename;                        35         char *propnodename;
 36         char *labelref;                            36         char *labelref;
 37         uint8_t byte;                              37         uint8_t byte;
 38         struct data data;                          38         struct data data;
 39                                                    39 
 40         struct {                                   40         struct {
 41                 struct data     data;              41                 struct data     data;
 42                 int             bits;              42                 int             bits;
 43         } array;                                   43         } array;
 44                                                    44 
 45         struct property *prop;                     45         struct property *prop;
 46         struct property *proplist;                 46         struct property *proplist;
 47         struct node *node;                         47         struct node *node;
 48         struct node *nodelist;                     48         struct node *nodelist;
 49         struct reserve_info *re;                   49         struct reserve_info *re;
 50         uint64_t integer;                          50         uint64_t integer;
 51         unsigned int flags;                        51         unsigned int flags;
 52 }                                                  52 }
 53                                                    53 
 54 %token DT_V1                                       54 %token DT_V1
 55 %token DT_PLUGIN                                   55 %token DT_PLUGIN
 56 %token DT_MEMRESERVE                               56 %token DT_MEMRESERVE
 57 %token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ D     57 %token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ DT_NE DT_AND DT_OR
 58 %token DT_BITS                                     58 %token DT_BITS
 59 %token DT_DEL_PROP                                 59 %token DT_DEL_PROP
 60 %token DT_DEL_NODE                                 60 %token DT_DEL_NODE
 61 %token DT_OMIT_NO_REF                              61 %token DT_OMIT_NO_REF
 62 %token <propnodename> DT_PROPNODENAME              62 %token <propnodename> DT_PROPNODENAME
 63 %token <integer> DT_LITERAL                        63 %token <integer> DT_LITERAL
 64 %token <integer> DT_CHAR_LITERAL                   64 %token <integer> DT_CHAR_LITERAL
 65 %token <byte> DT_BYTE                              65 %token <byte> DT_BYTE
 66 %token <data> DT_STRING                            66 %token <data> DT_STRING
 67 %token <labelref> DT_LABEL                         67 %token <labelref> DT_LABEL
 68 %token <labelref> DT_LABEL_REF                     68 %token <labelref> DT_LABEL_REF
 69 %token <labelref> DT_PATH_REF                      69 %token <labelref> DT_PATH_REF
 70 %token DT_INCBIN                                   70 %token DT_INCBIN
 71                                                    71 
 72 %type <data> propdata                              72 %type <data> propdata
 73 %type <data> propdataprefix                        73 %type <data> propdataprefix
 74 %type <flags> header                               74 %type <flags> header
 75 %type <flags> headers                              75 %type <flags> headers
 76 %type <re> memreserve                              76 %type <re> memreserve
 77 %type <re> memreserves                             77 %type <re> memreserves
 78 %type <array> arrayprefix                          78 %type <array> arrayprefix
 79 %type <data> bytestring                            79 %type <data> bytestring
 80 %type <prop> propdef                               80 %type <prop> propdef
 81 %type <proplist> proplist                          81 %type <proplist> proplist
 82 %type <labelref> dt_ref                            82 %type <labelref> dt_ref
 83                                                    83 
 84 %type <node> devicetree                            84 %type <node> devicetree
 85 %type <node> nodedef                               85 %type <node> nodedef
 86 %type <node> subnode                               86 %type <node> subnode
 87 %type <nodelist> subnodes                          87 %type <nodelist> subnodes
 88                                                    88 
 89 %type <integer> integer_prim                       89 %type <integer> integer_prim
 90 %type <integer> integer_unary                      90 %type <integer> integer_unary
 91 %type <integer> integer_mul                        91 %type <integer> integer_mul
 92 %type <integer> integer_add                        92 %type <integer> integer_add
 93 %type <integer> integer_shift                      93 %type <integer> integer_shift
 94 %type <integer> integer_rela                       94 %type <integer> integer_rela
 95 %type <integer> integer_eq                         95 %type <integer> integer_eq
 96 %type <integer> integer_bitand                     96 %type <integer> integer_bitand
 97 %type <integer> integer_bitxor                     97 %type <integer> integer_bitxor
 98 %type <integer> integer_bitor                      98 %type <integer> integer_bitor
 99 %type <integer> integer_and                        99 %type <integer> integer_and
100 %type <integer> integer_or                        100 %type <integer> integer_or
101 %type <integer> integer_trinary                   101 %type <integer> integer_trinary
102 %type <integer> integer_expr                      102 %type <integer> integer_expr
103                                                   103 
104 %%                                                104 %%
105                                                   105 
106 sourcefile:                                       106 sourcefile:
107           headers memreserves devicetree          107           headers memreserves devicetree
108                 {                                 108                 {
109                         parser_output = build_    109                         parser_output = build_dt_info($1, $2, $3,
110                                                   110                                                       guess_boot_cpuid($3));
111                 }                                 111                 }
112         ;                                         112         ;
113                                                   113 
114 header:                                           114 header:
115           DT_V1 ';'                               115           DT_V1 ';'
116                 {                                 116                 {
117                         $$ = DTSF_V1;             117                         $$ = DTSF_V1;
118                 }                                 118                 }
119         | DT_V1 ';' DT_PLUGIN ';'                 119         | DT_V1 ';' DT_PLUGIN ';'
120                 {                                 120                 {
121                         $$ = DTSF_V1 | DTSF_PL    121                         $$ = DTSF_V1 | DTSF_PLUGIN;
122                 }                                 122                 }
123         ;                                         123         ;
124                                                   124 
125 headers:                                          125 headers:
126           header                                  126           header
127         | header headers                          127         | header headers
128                 {                                 128                 {
129                         if ($2 != $1)             129                         if ($2 != $1)
130                                 ERROR(&@2, "He    130                                 ERROR(&@2, "Header flags don't match earlier ones");
131                         $$ = $1;                  131                         $$ = $1;
132                 }                                 132                 }
133         ;                                         133         ;
134                                                   134 
135 memreserves:                                      135 memreserves:
136           /* empty */                             136           /* empty */
137                 {                                 137                 {
138                         $$ = NULL;                138                         $$ = NULL;
139                 }                                 139                 }
140         | memreserve memreserves                  140         | memreserve memreserves
141                 {                                 141                 {
142                         $$ = chain_reserve_ent    142                         $$ = chain_reserve_entry($1, $2);
143                 }                                 143                 }
144         ;                                         144         ;
145                                                   145 
146 memreserve:                                       146 memreserve:
147           DT_MEMRESERVE integer_prim integer_p    147           DT_MEMRESERVE integer_prim integer_prim ';'
148                 {                                 148                 {
149                         $$ = build_reserve_ent    149                         $$ = build_reserve_entry($2, $3);
150                 }                                 150                 }
151         | DT_LABEL memreserve                     151         | DT_LABEL memreserve
152                 {                                 152                 {
153                         add_label(&$2->labels,    153                         add_label(&$2->labels, $1);
154                         $$ = $2;                  154                         $$ = $2;
155                 }                                 155                 }
156         ;                                         156         ;
157                                                   157 
158 dt_ref: DT_LABEL_REF | DT_PATH_REF;               158 dt_ref: DT_LABEL_REF | DT_PATH_REF;
159                                                   159 
160 devicetree:                                       160 devicetree:
161           '/' nodedef                             161           '/' nodedef
162                 {                                 162                 {
163                         $$ = name_node($2, "")    163                         $$ = name_node($2, "");
164                 }                                 164                 }
165         | devicetree '/' nodedef                  165         | devicetree '/' nodedef
166                 {                                 166                 {
167                         $$ = merge_nodes($1, $    167                         $$ = merge_nodes($1, $3);
168                 }                                 168                 }
169         | dt_ref nodedef                          169         | dt_ref nodedef
170                 {                                 170                 {
171                         /*                        171                         /*
172                          * We rely on the rule    172                          * We rely on the rule being always:
173                          *   versioninfo plugi    173                          *   versioninfo plugindecl memreserves devicetree
174                          * so $-1 is what we w    174                          * so $-1 is what we want (plugindecl)
175                          */                       175                          */
176                         if (!($<flags>-1 & DTS    176                         if (!($<flags>-1 & DTSF_PLUGIN))
177                                 ERROR(&@2, "La    177                                 ERROR(&@2, "Label or path %s not found", $1);
178                         else if (is_ref_relati    178                         else if (is_ref_relative($1))
179                                 ERROR(&@2, "La    179                                 ERROR(&@2, "Label-relative reference %s not supported in plugin", $1);
180                         $$ = add_orphan_node(     180                         $$ = add_orphan_node(
181                                         name_n    181                                         name_node(build_node(NULL, NULL, NULL),
182                                                   182                                                   ""),
183                                         $2, $1    183                                         $2, $1);
184                 }                                 184                 }
185         | devicetree DT_LABEL dt_ref nodedef      185         | devicetree DT_LABEL dt_ref nodedef
186                 {                                 186                 {
187                         struct node *target =     187                         struct node *target = get_node_by_ref($1, $3);
188                                                   188 
189                         if (($<flags>-1 & DTSF    189                         if (($<flags>-1 & DTSF_PLUGIN) && is_ref_relative($3))
190                                 ERROR(&@2, "La    190                                 ERROR(&@2, "Label-relative reference %s not supported in plugin", $3);
191                                                   191 
192                         if (target) {             192                         if (target) {
193                                 add_label(&tar    193                                 add_label(&target->labels, $2);
194                                 merge_nodes(ta    194                                 merge_nodes(target, $4);
195                         } else                    195                         } else
196                                 ERROR(&@3, "La    196                                 ERROR(&@3, "Label or path %s not found", $3);
197                         $$ = $1;                  197                         $$ = $1;
198                 }                                 198                 }
199         | devicetree DT_PATH_REF nodedef          199         | devicetree DT_PATH_REF nodedef
200                 {                                 200                 {
201                         /*                        201                         /*
202                          * We rely on the rule    202                          * We rely on the rule being always:
203                          *   versioninfo plugi    203                          *   versioninfo plugindecl memreserves devicetree
204                          * so $-1 is what we w    204                          * so $-1 is what we want (plugindecl)
205                          */                       205                          */
206                         if ($<flags>-1 & DTSF_    206                         if ($<flags>-1 & DTSF_PLUGIN) {
207                                 if (is_ref_rel    207                                 if (is_ref_relative($2))
208                                         ERROR(    208                                         ERROR(&@2, "Label-relative reference %s not supported in plugin", $2);
209                                 add_orphan_nod    209                                 add_orphan_node($1, $3, $2);
210                         } else {                  210                         } else {
211                                 struct node *t    211                                 struct node *target = get_node_by_ref($1, $2);
212                                                   212 
213                                 if (target)       213                                 if (target)
214                                         merge_    214                                         merge_nodes(target, $3);
215                                 else              215                                 else
216                                         ERROR(    216                                         ERROR(&@2, "Label or path %s not found", $2);
217                         }                         217                         }
218                         $$ = $1;                  218                         $$ = $1;
219                 }                                 219                 }
220         | devicetree DT_LABEL_REF nodedef         220         | devicetree DT_LABEL_REF nodedef
221                 {                                 221                 {
222                         struct node *target =     222                         struct node *target = get_node_by_ref($1, $2);
223                                                   223 
224                         if (target) {             224                         if (target) {
225                                 merge_nodes(ta    225                                 merge_nodes(target, $3);
226                         } else {                  226                         } else {
227                                 /*                227                                 /*
228                                  * We rely on     228                                  * We rely on the rule being always:
229                                  *   versionin    229                                  *   versioninfo plugindecl memreserves devicetree
230                                  * so $-1 is w    230                                  * so $-1 is what we want (plugindecl)
231                                  */               231                                  */
232                                 if ($<flags>-1    232                                 if ($<flags>-1 & DTSF_PLUGIN)
233                                         add_or    233                                         add_orphan_node($1, $3, $2);
234                                 else              234                                 else
235                                         ERROR(    235                                         ERROR(&@2, "Label or path %s not found", $2);
236                         }                         236                         }
237                         $$ = $1;                  237                         $$ = $1;
238                 }                                 238                 }
239         | devicetree DT_DEL_NODE dt_ref ';'       239         | devicetree DT_DEL_NODE dt_ref ';'
240                 {                                 240                 {
241                         struct node *target =     241                         struct node *target = get_node_by_ref($1, $3);
242                                                   242 
243                         if (target)               243                         if (target)
244                                 delete_node(ta    244                                 delete_node(target);
245                         else                      245                         else
246                                 ERROR(&@3, "La    246                                 ERROR(&@3, "Label or path %s not found", $3);
247                                                   247 
248                                                   248 
249                         $$ = $1;                  249                         $$ = $1;
250                 }                                 250                 }
251         | devicetree DT_OMIT_NO_REF dt_ref ';'    251         | devicetree DT_OMIT_NO_REF dt_ref ';'
252                 {                                 252                 {
253                         struct node *target =     253                         struct node *target = get_node_by_ref($1, $3);
254                                                   254 
255                         if (target)               255                         if (target)
256                                 omit_node_if_u    256                                 omit_node_if_unused(target);
257                         else                      257                         else
258                                 ERROR(&@3, "La    258                                 ERROR(&@3, "Label or path %s not found", $3);
259                                                   259 
260                                                   260 
261                         $$ = $1;                  261                         $$ = $1;
262                 }                                 262                 }
263         ;                                         263         ;
264                                                   264 
265 nodedef:                                          265 nodedef:
266           '{' proplist subnodes '}' ';'           266           '{' proplist subnodes '}' ';'
267                 {                                 267                 {
268                         $$ = build_node($2, $3    268                         $$ = build_node($2, $3, &@$);
269                 }                                 269                 }
270         ;                                         270         ;
271                                                   271 
272 proplist:                                         272 proplist:
273           /* empty */                             273           /* empty */
274                 {                                 274                 {
275                         $$ = NULL;                275                         $$ = NULL;
276                 }                                 276                 }
277         | proplist propdef                        277         | proplist propdef
278                 {                                 278                 {
279                         $$ = chain_property($2    279                         $$ = chain_property($2, $1);
280                 }                                 280                 }
281         ;                                         281         ;
282                                                   282 
283 propdef:                                          283 propdef:
284           DT_PROPNODENAME '=' propdata ';'        284           DT_PROPNODENAME '=' propdata ';'
285                 {                                 285                 {
286                         $$ = build_property($1    286                         $$ = build_property($1, $3, &@$);
287                         free($1);                 287                         free($1);
288                 }                                 288                 }
289         | DT_PROPNODENAME ';'                     289         | DT_PROPNODENAME ';'
290                 {                                 290                 {
291                         $$ = build_property($1    291                         $$ = build_property($1, empty_data, &@$);
292                         free($1);                 292                         free($1);
293                 }                                 293                 }
294         | DT_DEL_PROP DT_PROPNODENAME ';'         294         | DT_DEL_PROP DT_PROPNODENAME ';'
295                 {                                 295                 {
296                         $$ = build_property_de    296                         $$ = build_property_delete($2);
297                         free($2);                 297                         free($2);
298                 }                                 298                 }
299         | DT_LABEL propdef                        299         | DT_LABEL propdef
300                 {                                 300                 {
301                         add_label(&$2->labels,    301                         add_label(&$2->labels, $1);
302                         $$ = $2;                  302                         $$ = $2;
303                 }                                 303                 }
304         ;                                         304         ;
305                                                   305 
306 propdata:                                         306 propdata:
307           propdataprefix DT_STRING                307           propdataprefix DT_STRING
308                 {                                 308                 {
309                         $$ = data_merge($1, $2    309                         $$ = data_merge($1, $2);
310                 }                                 310                 }
311         | propdataprefix arrayprefix '>'          311         | propdataprefix arrayprefix '>'
312                 {                                 312                 {
313                         $$ = data_merge($1, $2    313                         $$ = data_merge($1, $2.data);
314                 }                                 314                 }
315         | propdataprefix '[' bytestring ']'       315         | propdataprefix '[' bytestring ']'
316                 {                                 316                 {
317                         $$ = data_merge($1, $3    317                         $$ = data_merge($1, $3);
318                 }                                 318                 }
319         | propdataprefix dt_ref                   319         | propdataprefix dt_ref
320                 {                                 320                 {
321                         $1 = data_add_marker($    321                         $1 = data_add_marker($1, TYPE_STRING, $2);
322                         $$ = data_add_marker($    322                         $$ = data_add_marker($1, REF_PATH, $2);
323                 }                                 323                 }
324         | propdataprefix DT_INCBIN '(' DT_STRI    324         | propdataprefix DT_INCBIN '(' DT_STRING ',' integer_prim ',' integer_prim ')'
325                 {                                 325                 {
326                         FILE *f = srcfile_rela    326                         FILE *f = srcfile_relative_open($4.val, NULL);
327                         struct data d;            327                         struct data d;
328                                                   328 
329                         if ($6 != 0)              329                         if ($6 != 0)
330                                 if (fseek(f, $    330                                 if (fseek(f, $6, SEEK_SET) != 0)
331                                         die("C    331                                         die("Couldn't seek to offset %llu in \"%s\": %s",
332                                             (u    332                                             (unsigned long long)$6, $4.val,
333                                             st    333                                             strerror(errno));
334                                                   334 
335                         d = data_copy_file(f,     335                         d = data_copy_file(f, $8);
336                                                   336 
337                         $$ = data_merge($1, d)    337                         $$ = data_merge($1, d);
338                         fclose(f);                338                         fclose(f);
339                 }                                 339                 }
340         | propdataprefix DT_INCBIN '(' DT_STRI    340         | propdataprefix DT_INCBIN '(' DT_STRING ')'
341                 {                                 341                 {
342                         FILE *f = srcfile_rela    342                         FILE *f = srcfile_relative_open($4.val, NULL);
343                         struct data d = empty_    343                         struct data d = empty_data;
344                                                   344 
345                         d = data_copy_file(f,     345                         d = data_copy_file(f, -1);
346                                                   346 
347                         $$ = data_merge($1, d)    347                         $$ = data_merge($1, d);
348                         fclose(f);                348                         fclose(f);
349                 }                                 349                 }
350         | propdata DT_LABEL                       350         | propdata DT_LABEL
351                 {                                 351                 {
352                         $$ = data_add_marker($    352                         $$ = data_add_marker($1, LABEL, $2);
353                 }                                 353                 }
354         ;                                         354         ;
355                                                   355 
356 propdataprefix:                                   356 propdataprefix:
357           /* empty */                             357           /* empty */
358                 {                                 358                 {
359                         $$ = empty_data;          359                         $$ = empty_data;
360                 }                                 360                 }
361         | propdata ','                            361         | propdata ','
362                 {                                 362                 {
363                         $$ = $1;                  363                         $$ = $1;
364                 }                                 364                 }
365         | propdataprefix DT_LABEL                 365         | propdataprefix DT_LABEL
366                 {                                 366                 {
367                         $$ = data_add_marker($    367                         $$ = data_add_marker($1, LABEL, $2);
368                 }                                 368                 }
369         ;                                         369         ;
370                                                   370 
371 arrayprefix:                                      371 arrayprefix:
372         DT_BITS DT_LITERAL '<'                    372         DT_BITS DT_LITERAL '<'
373                 {                                 373                 {
374                         unsigned long long bit    374                         unsigned long long bits;
375                         enum markertype type =    375                         enum markertype type = TYPE_UINT32;
376                                                   376 
377                         bits = $2;                377                         bits = $2;
378                                                   378 
379                         switch (bits) {           379                         switch (bits) {
380                         case 8: type = TYPE_UI    380                         case 8: type = TYPE_UINT8; break;
381                         case 16: type = TYPE_U    381                         case 16: type = TYPE_UINT16; break;
382                         case 32: type = TYPE_U    382                         case 32: type = TYPE_UINT32; break;
383                         case 64: type = TYPE_U    383                         case 64: type = TYPE_UINT64; break;
384                         default:                  384                         default:
385                                 ERROR(&@2, "Ar    385                                 ERROR(&@2, "Array elements must be"
386                                       " 8, 16,    386                                       " 8, 16, 32 or 64-bits");
387                                 bits = 32;        387                                 bits = 32;
388                         }                         388                         }
389                                                   389 
390                         $$.data = data_add_mar    390                         $$.data = data_add_marker(empty_data, type, NULL);
391                         $$.bits = bits;           391                         $$.bits = bits;
392                 }                                 392                 }
393         | '<'                                     393         | '<'
394                 {                                 394                 {
395                         $$.data = data_add_mar    395                         $$.data = data_add_marker(empty_data, TYPE_UINT32, NULL);
396                         $$.bits = 32;             396                         $$.bits = 32;
397                 }                                 397                 }
398         | arrayprefix integer_prim                398         | arrayprefix integer_prim
399                 {                                 399                 {
400                         if ($1.bits < 64) {       400                         if ($1.bits < 64) {
401                                 uint64_t mask     401                                 uint64_t mask = (1ULL << $1.bits) - 1;
402                                 /*                402                                 /*
403                                  * Bits above     403                                  * Bits above mask must either be all zero
404                                  * (positive w    404                                  * (positive within range of mask) or all one
405                                  * (negative a    405                                  * (negative and sign-extended). The second
406                                  * condition i    406                                  * condition is true if when we set all bits
407                                  * within the     407                                  * within the mask to one (i.e. | in the
408                                  * mask), all     408                                  * mask), all bits are one.
409                                  */               409                                  */
410                                 if (($2 > mask    410                                 if (($2 > mask) && (($2 | mask) != -1ULL)) {
411                                         char *    411                                         char *loc = srcpos_string(&@2);
412                                         fprint    412                                         fprintf(stderr,
413                                                   413                                                 "WARNING: %s: Value 0x%016" PRIx64
414                                                   414                                                 " truncated to 0x%0*" PRIx64 "\n",
415                                                   415                                                 loc, $2, $1.bits / 4, ($2 & mask));
416                                         free(l    416                                         free(loc);
417                                 }                 417                                 }
418                         }                         418                         }
419                                                   419 
420                         $$.data = data_append_    420                         $$.data = data_append_integer($1.data, $2, $1.bits);
421                 }                                 421                 }
422         | arrayprefix dt_ref                      422         | arrayprefix dt_ref
423                 {                                 423                 {
424                         uint64_t val = ~0ULL >    424                         uint64_t val = ~0ULL >> (64 - $1.bits);
425                                                   425 
426                         if ($1.bits == 32)        426                         if ($1.bits == 32)
427                                 $1.data = data    427                                 $1.data = data_add_marker($1.data,
428                                                   428                                                           REF_PHANDLE,
429                                                   429                                                           $2);
430                         else                      430                         else
431                                 ERROR(&@2, "Re    431                                 ERROR(&@2, "References are only allowed in "
432                                             "a    432                                             "arrays with 32-bit elements.");
433                                                   433 
434                         $$.data = data_append_    434                         $$.data = data_append_integer($1.data, val, $1.bits);
435                 }                                 435                 }
436         | arrayprefix DT_LABEL                    436         | arrayprefix DT_LABEL
437                 {                                 437                 {
438                         $$.data = data_add_mar    438                         $$.data = data_add_marker($1.data, LABEL, $2);
439                 }                                 439                 }
440         ;                                         440         ;
441                                                   441 
442 integer_prim:                                     442 integer_prim:
443           DT_LITERAL                              443           DT_LITERAL
444         | DT_CHAR_LITERAL                         444         | DT_CHAR_LITERAL
445         | '(' integer_expr ')'                    445         | '(' integer_expr ')'
446                 {                                 446                 {
447                         $$ = $2;                  447                         $$ = $2;
448                 }                                 448                 }
449         ;                                         449         ;
450                                                   450 
451 integer_expr:                                     451 integer_expr:
452         integer_trinary                           452         integer_trinary
453         ;                                         453         ;
454                                                   454 
455 integer_trinary:                                  455 integer_trinary:
456           integer_or                              456           integer_or
457         | integer_or '?' integer_expr ':' inte    457         | integer_or '?' integer_expr ':' integer_trinary { $$ = $1 ? $3 : $5; }
458         ;                                         458         ;
459                                                   459 
460 integer_or:                                       460 integer_or:
461           integer_and                             461           integer_and
462         | integer_or DT_OR integer_and { $$ =     462         | integer_or DT_OR integer_and { $$ = $1 || $3; }
463         ;                                         463         ;
464                                                   464 
465 integer_and:                                      465 integer_and:
466           integer_bitor                           466           integer_bitor
467         | integer_and DT_AND integer_bitor { $    467         | integer_and DT_AND integer_bitor { $$ = $1 && $3; }
468         ;                                         468         ;
469                                                   469 
470 integer_bitor:                                    470 integer_bitor:
471           integer_bitxor                          471           integer_bitxor
472         | integer_bitor '|' integer_bitxor { $    472         | integer_bitor '|' integer_bitxor { $$ = $1 | $3; }
473         ;                                         473         ;
474                                                   474 
475 integer_bitxor:                                   475 integer_bitxor:
476           integer_bitand                          476           integer_bitand
477         | integer_bitxor '^' integer_bitand {     477         | integer_bitxor '^' integer_bitand { $$ = $1 ^ $3; }
478         ;                                         478         ;
479                                                   479 
480 integer_bitand:                                   480 integer_bitand:
481           integer_eq                              481           integer_eq
482         | integer_bitand '&' integer_eq { $$ =    482         | integer_bitand '&' integer_eq { $$ = $1 & $3; }
483         ;                                         483         ;
484                                                   484 
485 integer_eq:                                       485 integer_eq:
486           integer_rela                            486           integer_rela
487         | integer_eq DT_EQ integer_rela { $$ =    487         | integer_eq DT_EQ integer_rela { $$ = $1 == $3; }
488         | integer_eq DT_NE integer_rela { $$ =    488         | integer_eq DT_NE integer_rela { $$ = $1 != $3; }
489         ;                                         489         ;
490                                                   490 
491 integer_rela:                                     491 integer_rela:
492           integer_shift                           492           integer_shift
493         | integer_rela '<' integer_shift { $$     493         | integer_rela '<' integer_shift { $$ = $1 < $3; }
494         | integer_rela '>' integer_shift { $$     494         | integer_rela '>' integer_shift { $$ = $1 > $3; }
495         | integer_rela DT_LE integer_shift { $    495         | integer_rela DT_LE integer_shift { $$ = $1 <= $3; }
496         | integer_rela DT_GE integer_shift { $    496         | integer_rela DT_GE integer_shift { $$ = $1 >= $3; }
497         ;                                         497         ;
498                                                   498 
499 integer_shift:                                    499 integer_shift:
500           integer_shift DT_LSHIFT integer_add     500           integer_shift DT_LSHIFT integer_add { $$ = ($3 < 64) ? ($1 << $3) : 0; }
501         | integer_shift DT_RSHIFT integer_add     501         | integer_shift DT_RSHIFT integer_add { $$ = ($3 < 64) ? ($1 >> $3) : 0; }
502         | integer_add                             502         | integer_add
503         ;                                         503         ;
504                                                   504 
505 integer_add:                                      505 integer_add:
506           integer_add '+' integer_mul { $$ = $    506           integer_add '+' integer_mul { $$ = $1 + $3; }
507         | integer_add '-' integer_mul { $$ = $    507         | integer_add '-' integer_mul { $$ = $1 - $3; }
508         | integer_mul                             508         | integer_mul
509         ;                                         509         ;
510                                                   510 
511 integer_mul:                                      511 integer_mul:
512           integer_mul '*' integer_unary { $$ =    512           integer_mul '*' integer_unary { $$ = $1 * $3; }
513         | integer_mul '/' integer_unary           513         | integer_mul '/' integer_unary
514                 {                                 514                 {
515                         if ($3 != 0) {            515                         if ($3 != 0) {
516                                 $$ = $1 / $3;     516                                 $$ = $1 / $3;
517                         } else {                  517                         } else {
518                                 ERROR(&@$, "Di    518                                 ERROR(&@$, "Division by zero");
519                                 $$ = 0;           519                                 $$ = 0;
520                         }                         520                         }
521                 }                                 521                 }
522         | integer_mul '%' integer_unary           522         | integer_mul '%' integer_unary
523                 {                                 523                 {
524                         if ($3 != 0) {            524                         if ($3 != 0) {
525                                 $$ = $1 % $3;     525                                 $$ = $1 % $3;
526                         } else {                  526                         } else {
527                                 ERROR(&@$, "Di    527                                 ERROR(&@$, "Division by zero");
528                                 $$ = 0;           528                                 $$ = 0;
529                         }                         529                         }
530                 }                                 530                 }
531         | integer_unary                           531         | integer_unary
532         ;                                         532         ;
533                                                   533 
534 integer_unary:                                    534 integer_unary:
535           integer_prim                            535           integer_prim
536         | '-' integer_unary { $$ = -$2; }         536         | '-' integer_unary { $$ = -$2; }
537         | '~' integer_unary { $$ = ~$2; }         537         | '~' integer_unary { $$ = ~$2; }
538         | '!' integer_unary { $$ = !$2; }         538         | '!' integer_unary { $$ = !$2; }
539         ;                                         539         ;
540                                                   540 
541 bytestring:                                       541 bytestring:
542           /* empty */                             542           /* empty */
543                 {                                 543                 {
544                         $$ = data_add_marker(e    544                         $$ = data_add_marker(empty_data, TYPE_UINT8, NULL);
545                 }                                 545                 }
546         | bytestring DT_BYTE                      546         | bytestring DT_BYTE
547                 {                                 547                 {
548                         $$ = data_append_byte(    548                         $$ = data_append_byte($1, $2);
549                 }                                 549                 }
550         | bytestring DT_LABEL                     550         | bytestring DT_LABEL
551                 {                                 551                 {
552                         $$ = data_add_marker($    552                         $$ = data_add_marker($1, LABEL, $2);
553                 }                                 553                 }
554         ;                                         554         ;
555                                                   555 
556 subnodes:                                         556 subnodes:
557           /* empty */                             557           /* empty */
558                 {                                 558                 {
559                         $$ = NULL;                559                         $$ = NULL;
560                 }                                 560                 }
561         | subnode subnodes                        561         | subnode subnodes
562                 {                                 562                 {
563                         $$ = chain_node($1, $2    563                         $$ = chain_node($1, $2);
564                 }                                 564                 }
565         | subnode propdef                         565         | subnode propdef
566                 {                                 566                 {
567                         ERROR(&@2, "Properties    567                         ERROR(&@2, "Properties must precede subnodes");
568                         YYERROR;                  568                         YYERROR;
569                 }                                 569                 }
570         ;                                         570         ;
571                                                   571 
572 subnode:                                          572 subnode:
573           DT_PROPNODENAME nodedef                 573           DT_PROPNODENAME nodedef
574                 {                                 574                 {
575                         $$ = name_node($2, $1)    575                         $$ = name_node($2, $1);
576                         free($1);                 576                         free($1);
577                 }                                 577                 }
578         | DT_DEL_NODE DT_PROPNODENAME ';'         578         | DT_DEL_NODE DT_PROPNODENAME ';'
579                 {                                 579                 {
580                         $$ = name_node(build_n    580                         $$ = name_node(build_node_delete(&@$), $2);
581                         free($2);                 581                         free($2);
582                 }                                 582                 }
583         | DT_OMIT_NO_REF subnode                  583         | DT_OMIT_NO_REF subnode
584                 {                                 584                 {
585                         $$ = omit_node_if_unus    585                         $$ = omit_node_if_unused($2);
586                 }                                 586                 }
587         | DT_LABEL subnode                        587         | DT_LABEL subnode
588                 {                                 588                 {
589                         add_label(&$2->labels,    589                         add_label(&$2->labels, $1);
590                         $$ = $2;                  590                         $$ = $2;
591                 }                                 591                 }
592         ;                                         592         ;
593                                                   593 
594 %%                                                594 %%
595                                                   595 
596 void yyerror(char const *s)                       596 void yyerror(char const *s)
597 {                                                 597 {
598         ERROR(&yylloc, "%s", s);                  598         ERROR(&yylloc, "%s", s);
599 }                                                 599 }
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php