2005-06-08 15:18:34 +08:00
|
|
|
/*
|
|
|
|
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
2005-10-19 14:00:31 +08:00
|
|
|
%glr-parser
|
|
|
|
%locations
|
|
|
|
|
2005-06-08 15:18:34 +08:00
|
|
|
%{
|
|
|
|
#include "dtc.h"
|
|
|
|
|
|
|
|
int yylex (void);
|
|
|
|
void yyerror (char const *);
|
|
|
|
|
2005-07-15 15:14:24 +08:00
|
|
|
extern struct boot_info *the_boot_info;
|
2005-06-08 15:18:34 +08:00
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
%union {
|
|
|
|
cell_t cval;
|
2007-02-16 00:59:27 +08:00
|
|
|
unsigned int cbase;
|
2005-07-11 14:49:52 +08:00
|
|
|
u8 byte;
|
2005-06-08 15:18:34 +08:00
|
|
|
char *str;
|
|
|
|
struct data data;
|
|
|
|
struct property *prop;
|
|
|
|
struct property *proplist;
|
|
|
|
struct node *node;
|
|
|
|
struct node *nodelist;
|
|
|
|
int datalen;
|
|
|
|
int hexlen;
|
2005-07-15 15:14:24 +08:00
|
|
|
u64 addr;
|
2005-10-24 16:18:38 +08:00
|
|
|
struct reserve_info *re;
|
2005-06-08 15:18:34 +08:00
|
|
|
}
|
|
|
|
|
2005-07-15 15:14:24 +08:00
|
|
|
%token DT_MEMRESERVE
|
|
|
|
%token <addr> DT_ADDR
|
2005-06-08 15:18:34 +08:00
|
|
|
%token <str> DT_PROPNAME
|
|
|
|
%token <str> DT_NODENAME
|
2007-02-16 00:59:27 +08:00
|
|
|
%token <cbase> DT_BASE
|
|
|
|
%token <str> DT_CELL
|
2005-06-08 15:18:34 +08:00
|
|
|
%token <byte> DT_BYTE
|
|
|
|
%token <data> DT_STRING
|
|
|
|
%token <str> DT_UNIT
|
2005-06-16 12:36:37 +08:00
|
|
|
%token <str> DT_LABEL
|
2005-06-16 15:04:00 +08:00
|
|
|
%token <str> DT_REF
|
2005-06-08 15:18:34 +08:00
|
|
|
|
|
|
|
%type <data> propdata
|
2007-02-07 13:37:50 +08:00
|
|
|
%type <data> propdataprefix
|
2005-07-15 15:14:24 +08:00
|
|
|
%type <re> memreserve
|
2005-10-24 16:18:38 +08:00
|
|
|
%type <re> memreserves
|
2007-02-16 00:59:27 +08:00
|
|
|
%type <cbase> opt_cell_base
|
2005-06-08 15:18:34 +08:00
|
|
|
%type <data> celllist
|
|
|
|
%type <data> bytestring
|
|
|
|
%type <prop> propdef
|
|
|
|
%type <proplist> proplist
|
|
|
|
|
2005-07-15 15:14:24 +08:00
|
|
|
%type <node> devicetree
|
2005-06-08 15:18:34 +08:00
|
|
|
%type <node> nodedef
|
|
|
|
%type <node> subnode
|
|
|
|
%type <nodelist> subnodes
|
2005-06-16 12:36:37 +08:00
|
|
|
%type <str> label
|
|
|
|
%type <str> nodename
|
|
|
|
|
2005-06-08 15:18:34 +08:00
|
|
|
%%
|
|
|
|
|
2005-07-15 15:14:24 +08:00
|
|
|
sourcefile: memreserves devicetree {
|
|
|
|
the_boot_info = build_boot_info($1, $2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2005-10-24 16:18:38 +08:00
|
|
|
memreserves: memreserve memreserves {
|
|
|
|
$$ = chain_reserve_entry($1, $2);
|
2005-07-15 15:14:24 +08:00
|
|
|
}
|
|
|
|
| /* empty */ {
|
2005-10-24 16:18:38 +08:00
|
|
|
$$ = NULL;
|
2005-07-15 15:14:24 +08:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
memreserve: DT_MEMRESERVE DT_ADDR DT_ADDR ';' {
|
2005-10-24 16:18:38 +08:00
|
|
|
$$ = build_reserve_entry($2, $3, NULL);
|
2005-07-15 15:14:24 +08:00
|
|
|
}
|
|
|
|
| DT_MEMRESERVE DT_ADDR '-' DT_ADDR ';' {
|
2005-10-24 16:18:38 +08:00
|
|
|
$$ = build_reserve_entry($2, $4 - $2 + 1, NULL);
|
2005-07-15 15:14:24 +08:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
devicetree: '/' nodedef {
|
|
|
|
$$ = name_node($2, "", NULL);
|
|
|
|
}
|
2005-06-08 15:18:34 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
nodedef: '{' proplist subnodes '}' ';' {
|
|
|
|
$$ = build_node($2, $3);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
proplist: propdef proplist {
|
|
|
|
$$ = chain_property($1, $2);
|
|
|
|
}
|
|
|
|
| /* empty */ {
|
|
|
|
$$ = NULL;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2005-06-16 12:36:37 +08:00
|
|
|
propdef: label DT_PROPNAME '=' propdata ';' {
|
|
|
|
$$ = build_property($2, $4, $1);
|
2005-06-08 15:18:34 +08:00
|
|
|
}
|
2005-06-16 12:36:37 +08:00
|
|
|
| label DT_PROPNAME ';' {
|
2005-06-17 12:32:32 +08:00
|
|
|
$$ = build_property($2, empty_data, $1);
|
2005-06-08 15:18:34 +08:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2007-02-07 13:37:50 +08:00
|
|
|
propdata: propdataprefix DT_STRING { $$ = data_merge($1, $2); }
|
|
|
|
| propdataprefix '<' celllist '>' {
|
|
|
|
$$ = data_merge(data_append_align($1, sizeof(cell_t)), $3);
|
|
|
|
}
|
|
|
|
| propdataprefix '[' bytestring ']' { $$ = data_merge($1, $3); }
|
|
|
|
;
|
|
|
|
|
|
|
|
propdataprefix: propdata ',' { $$ = $1; }
|
|
|
|
| /* empty */ { $$ = empty_data; }
|
2005-06-08 15:18:34 +08:00
|
|
|
;
|
|
|
|
|
2007-02-16 00:59:27 +08:00
|
|
|
opt_cell_base:
|
|
|
|
/* empty */
|
|
|
|
{ $$ = 16; }
|
|
|
|
| DT_BASE
|
|
|
|
;
|
|
|
|
|
|
|
|
celllist: celllist opt_cell_base DT_CELL {
|
|
|
|
$$ = data_append_cell($1,
|
|
|
|
data_convert_cell($3, $2));
|
|
|
|
}
|
2005-06-16 15:04:00 +08:00
|
|
|
| celllist DT_REF {
|
|
|
|
$$ = data_append_cell(data_add_fixup($1, $2), -1);
|
|
|
|
}
|
2005-06-08 15:18:34 +08:00
|
|
|
| /* empty */ { $$ = empty_data; }
|
|
|
|
;
|
|
|
|
|
|
|
|
bytestring: bytestring DT_BYTE { $$ = data_append_byte($1, $2); }
|
|
|
|
| /* empty */ { $$ = empty_data; }
|
|
|
|
;
|
|
|
|
|
|
|
|
subnodes: subnode subnodes {
|
|
|
|
$$ = chain_node($1, $2);
|
|
|
|
}
|
|
|
|
| /* empty */ { $$ = NULL; }
|
|
|
|
;
|
|
|
|
|
2005-06-16 12:36:37 +08:00
|
|
|
subnode: label nodename nodedef { $$ = name_node($3, $2, $1); }
|
|
|
|
;
|
|
|
|
|
|
|
|
nodename: DT_NODENAME { $$ = $1; }
|
|
|
|
| DT_PROPNAME { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
|
|
|
label: DT_LABEL { $$ = $1; }
|
|
|
|
| /* empty */ { $$ = NULL; }
|
2005-06-08 15:18:34 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
void yyerror (char const *s)
|
|
|
|
{
|
2005-10-19 14:00:31 +08:00
|
|
|
fprintf (stderr, "%s at line %d\n", s, yylloc.first_line);
|
2005-06-08 15:18:34 +08:00
|
|
|
}
|