~ [ 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 (Version linux-6.12-rc7) and /scripts/dtc/dtc-parser.y (Version linux-5.4.285)


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

~ [ 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