From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Likely Subject: Re: [PATCH 8/9 V3] Add documentation for the new DTS language. Date: Tue, 30 Sep 2008 08:55:37 -0600 Message-ID: <20080930145537.GJ18313@secretlab.ca> References: <1222460748-20127-1-git-send-email-jdl@jdl.com> <1222460748-20127-2-git-send-email-jdl@jdl.com> <1222460748-20127-3-git-send-email-jdl@jdl.com> <1222460748-20127-4-git-send-email-jdl@jdl.com> <1222460748-20127-5-git-send-email-jdl@jdl.com> <1222460748-20127-6-git-send-email-jdl@jdl.com> <1222460748-20127-7-git-send-email-jdl@jdl.com> <1222460748-20127-8-git-send-email-jdl@jdl.com> <1222460748-20127-9-git-send-email-jdl@jdl.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1222460748-20127-9-git-send-email-jdl-CYoMK+44s/E@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-mnsaURCQ41sdnm+yROfE0A@public.gmane.org Errors-To: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-mnsaURCQ41sdnm+yROfE0A@public.gmane.org To: Jon Loeliger Cc: devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org List-Id: devicetree@vger.kernel.org On Fri, Sep 26, 2008 at 03:25:47PM -0500, Jon Loeliger wrote: > From: Jon Loeliger > > Signed-off-by: Jon Loeliger > --- > Documentation/manual.txt | 500 ++++++++++++++++++++++++++++++++++++++++++---- > 1 files changed, 463 insertions(+), 37 deletions(-) Hey Jon, I don't yet have fully formed thoughts about this stuff so I've held off on making comments. But FWIW, here are my initial thoughts. I'm not convinced about the approach of interleaving the executable and data syntaxes. The whole design of the existing syntax is to represent the data structure. Adding additional syntax to define executable elements doesn't feel right to me. I think many people will find the resulting file structure to be confusing. I'm also not convinced that it is a good idea to implement a new interpreted language. Any new language is a new thing that needs to be maintained and a new thing for users to learn. I'd prefer to make use of an existing language with a library of support routines for maintaining an internal representation of the data and building up a device tree programmatically with the ability to import and manipulate 'stock' nodes for existing parts. However, I haven't spent enough brain cell cycles on this to make any recommendations on a specific language or to figure out if that will just result in even more complexity for users. As I said, these are just initial thoughts. My opinion could be swayed. g. > > diff --git a/Documentation/manual.txt b/Documentation/manual.txt > index b957662..ac56309 100644 > --- a/Documentation/manual.txt > +++ b/Documentation/manual.txt > @@ -105,13 +105,21 @@ Options: > -q > Quiet: -q suppress warnings, -qq errors, -qqq all > > + -D > + -D = > + Introduce a constant definition for symbol with > + possible initial value given by . The RHS > + should be a literal number or string value. > + > + -p > + Add at least additional space to the DTB image. > + > -R > Make space for reserve map entries > Relevant for dtb and asm output only. > > -S > - Ensure the blob at least long, adding additional > - space if needed. > + Deprecated option. > > -v > Print DTC version and exit. > @@ -131,47 +139,338 @@ Additionally, dtc performs various sanity checks on the tree. > > 4) Device Tree Source file > > -4.1) Overview > > -Here is a very rough overview of the layout of a DTS source file: > +4.1) DTS Lexical Components > + > +Property and node names [a-zA-Z0-9,._+*#?@-]+ > +Identifiers \\[a-zA-Z_][a-zA-Z0-9_]* > +Labels [a-zA-Z_][a-zA-Z0-9_]* > +Strings > +Comments Both /* ... */ and // style are supported > +Numeric literals > +Bytes [0-9a-fA-F][0-9a-fA-F] > + > +Keywords: > + else > + for > + if > + in > + return > + void > + /const/ > + /define/ > + /incbin/ > + > +C-style expression operators: > + << > + >> > + <= > + >= > + == > + != > + && > + || > + + > + - > + * > + / > + % > + > +Additional tokens: > + .. > + := > + { > + } > + , > + & > + > + > +These constructs are handled and eliminated purely at the > +lexical level and do not appear in the grammar proper: > + > + - Source files included using the syntax: > + > + /include/ "filename" > + > + - Both classic C style and C++ style comments are supported. > + Comments don't nest. > + For example, given: > + > + 1 /* > + 2 * asdasdasd // asdasdad > + 3 // */ > + 4 asasd > + 5 */ > + The // comment on line 3 is not effective and is ignored. > + The original /* comment ends on line 3. Line 5 is in error. > + > + And given: > + > + 1 // /* > + 2 * asdasdasd // asdasdad > + 3 */ > + > + The // comment on line 1 hides the opening /*. > + Line 2 is in error. > + > + > +4.2) DTS Grammar > + > +Here is a very rough overview of the grammar of a DTS source file: > + > + > + sourcefile: > + '/dts-v1/' ';' possibly_empty_list_of_declarations devicetree > + > + declaration: > + memreserve > + | constdef > + | funcdef > + > + memreserve: label '/memreserve/' addr addr ';' > + > + constdef: '/const/' identifier '=' expr ';' > + > + funcdef: '/define/' propnodename paramdecls statement_block > + > + paramdecls: '(' possibly_empty_paramdecl_list ')' > + > + paramdecl: identifier > + > + devicetree: '/' statement_block > + > + statement_block: '{' possibly_empty_list_of_statements '}' > + > + statement: > + subnode > + | for_statement > + | if_statement > + | return_statement > + | assign_statement > + | property_definition > + | statement_block > + | ';' > + > + subnode: > + node_label expr statement_block ';' > + | label expr statement_block ';' > + | expr statement_block ';' > + > + for_statement: > + 'for' identifier 'in' expr '..' expr statement_block > + > + if_statement: > + 'if' '(' expr ')' statement_block > + | 'if' '(' expr ')' statement_block 'else' statement_block > + > + return_statement: 'return' expr ';' > + > + assign_statement: identifier ':=' expr ';' > + > + property_definition: > + optional_label expr ';' > + | optional_label expr '=' list_of_property_data_and_labels ';' > > + list_of_property_data_and_labels: > + STRING > + | '<' possibly_empty_list_of_cell_values_and_labels '>' > + | '[' possibly_empty_list_of_byte_values_and_labels ']' > + | label > + | '/incbin/' '(' expr ')' > + | '/incbin/' '(' expr ',' expr ',' expr ')' > > - sourcefile: list_of_memreserve devicetree > + cell_value: > + expr_primary > + | '&' '(' expr ')' > + | '&' phandle_reference > + | label > > - memreserve: label 'memreserve' ADDR ADDR ';' > - | label 'memreserve' ADDR '-' ADDR ';' > > - devicetree: '/' nodedef > + expr: > + expr_primary > + | expr '?' expr ':' expr > + | expr expr_oper expr > > - nodedef: '{' list_of_property list_of_subnode '}' ';' > + expr_oper: > + || > + && > + | > + ^ > + & > + == > + < | > | <= | >= > + << | >> > + + | - > + * | / | % > + - | ~ | ! > + '(' ')' | '(' non_empty_list_of_param_exprs ')' > > - property: label PROPNAME '=' propdata ';' > + expr_primary: > + literal > + | string > + | propnodename > + | identifier > + | '(' expr ')' > > - propdata: STRING > - | '<' list_of_cells '>' > - | '[' list_of_bytes ']' > + addr: expr > > - subnode: label nodename nodedef > + node_label: expr ':' > > -That structure forms a hierarchical layout of nodes and properties > -rooted at an initial node as: > + propnodename: <1275-property-name> > + > + identifier: '\'- > + > + literal: > + byte: > + string: > + label: '&'-