Add items to Devicetree Source Format chapter
PATCH v2 1/1 Add items to Devicetree Source Format chapter
From: Frank Rowand <[email protected]>
Add items to Devicetree Source Format chapter
- Add naming convention for DTS files and DTS include files
- Add /include/ compiler directive
- Add ";" to end of node definition
- Add /delete-node/ and /delete-property/
- Add arithmetic, bitwise, logical, and ternary expressions
Note that cpp directives are not included in this patch, and are not yet specified in this appendix.
---
changes in v2
- arithmetic operators "and", "or" were incorrectly listed as as bitwise
- thus bitwise operators "and", "or" were incorrectly shown
- "exclusive or" operator added
- logical and arithmetic "not" operators added
- ternary operator added
- moved shift operators from arithmetic to bitwise
source/source-language.rst | 70 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-)
source/source-language.rst +69 -1
@@ -9,6 +9,19 @@ devicetree in the form expected by the k not a formal syntax definition of DTS, but describes the basic constructs used to represent devicetrees. +The name of DTS files should end with ".dts". + +Compiler directives +------------------- + +Other source files can be included from a DTS file. The name of include +files should end with ".dtsi". Included files can in turn include +additional files. + +:: + + /include/ "FILE" + Node and property definitions -----------------------------
@@ -21,11 +34,18 @@ preceded by a label. [label:] node-name[@unit-address] { [properties definitions] [child nodes] - } + }; Nodes may contain property definitions and/or child node definitions. If both are present, properties shall come before child nodes. +Previously defined nodes may be deleted. + +:: + + /delete-node/ node-name; + /delete-node/ &label; + Property definitions are name value pairs in the form: ::
@@ -39,6 +59,12 @@ form: [label:] property-name; +Previously defined properties may be deleted. + +:: + + /delete-property/ property-name; + Property values may be defined as an array of 32-bit integer cells, as null-terminated strings, as bytestrings or a combination of these.
@@ -48,6 +74,48 @@ null-terminated strings, as bytestrings :: interrupts = <17 0xc>; +- values may be represented as arithmetic, bitwise, or logical expressions + within parenthesis. + +:: + + Arithmetic operators + + + add + - subtract + * multiply + / divide + +:: + + Bitwise operators + + & and + | or + ^ exclusive or + ~ not + << left shift + >> right shift + +:: + + Logical operators + + < less than + > greater than + <= less than or equal + >= greater than or equal + == equal + != not equal + && and + || or + ! not + +:: + + Ternary operators + + ?: (condition ? value_if_true : value_if_false) - A 64-bit value is represented with two 32-bit cells. Example:
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 115 lines · Frank Rowand
From: Frank Rowand <[email protected]>
Add items to Devicetree Source Format chapter
- Add naming convention for DTS files and DTS include files
- Add /include/ compiler directive
- Add ";" to end of node definition
- Add /delete-node/ and /delete-property/
- Add arithmetic, bitwise, logical, and ternary expressionsNote that cpp directives are not included in this patch, and are not yet specified in this appendix.
Signed-off-by Frank Rowand <[email protected]>---
changes in v2
- arithmetic operators "and", "or" were incorrectly listed as as bitwise
- thus bitwise operators "and", "or" were incorrectly shown
- "exclusive or" operator added
- logical and arithmetic "not" operators added
- ternary operator added
- moved shift operators from arithmetic to bitwisesource/source-language.rst | 70 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-)Index:
b/source/source-language.rst
===================================================================source/source-language.rst +53
-1@@ -9,6 +9,19 @@ devicetree in the form expected by the k not a formal syntax definition of DTS, but describes the basic constructs used to represent devicetrees. +The name of DTS files should end with ".dts". + +Compiler directives +------------------- + +Other source files can be included from a DTS file. The name of include +files should end with ".dtsi". Included files can in turn include +additional files. + +:: + + /include/ "FILE" + Node and property definitions -----------------------------@@ -21,11 +34,18 @@ preceded by a label. [label:] node-name[@unit-address] { [properties definitions] [child nodes] - } + }; Nodes may contain property definitions and/or child node definitions. If both are present, properties shall come before child nodes. +Previously defined nodes may be deleted. + +:: + + /delete-node/ node-name; + /delete-node/ &label; + Property definitions are name value pairs in the form: ::@@ -39,6 +59,12 @@ form: [label:] property-name; +Previously defined properties may be deleted. + +:: + + /delete-property/ property-name; + Property values may be defined as an array of 32-bit integer cells, as null-terminated strings, as bytestrings or a combination of these.@@ -48,6 +74,48 @@ null-terminated strings, as bytestrings :: interrupts = <17 0xc>; +- values may be represented as arithmetic, bitwise, or logical expressions + within parenthesis. + +:: + + Arithmetic operators + + + add + - subtract + * multiply + / divide + +:: + + Bitwise operators + + & and + | or + ^ exclusive or + ~ not + << left shift + >> right shift + +:: + + Logical operators
source/source-language.rst null-terminated strings, as bytestrings · line 112
Quoted 10 lines
source/source-language.rst +10
-0+ + < less than + > greater than + <= less than or equal + >= greater than or equal + == equal + != not equal + && and + || or + ! not
Fwiw, I think &&, || and ! usually get classified as "logical operators" but <, > etc. get classified as "relational operators" rather than putting them in the same category.
Hrm.. given that you're listing them all here, I wonder if it would make sense to do so in precedence order (should be the same as for C).
Quoted 9 lines
source/source-language.rst +5
-0+:: + + Ternary operators + + ?: (condition ? value_if_true : value_if_false) - A 64-bit value is represented with two 32-bit cells. Example:
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 34 lines · David Gibson
Quoted 33 lines · Frank Rowand
From: Frank Rowand <[email protected]>
Add items to Devicetree Source Format chapter
- Add naming convention for DTS files and DTS include files
- Add /include/ compiler directive
- Add ";" to end of node definition
- Add /delete-node/ and /delete-property/
- Add arithmetic, bitwise, logical, and ternary expressionsNote that cpp directives are not included in this patch, and are not yet specified in this appendix.
Signed-off-by Frank Rowand <[email protected]>---
changes in v2
- arithmetic operators "and", "or" were incorrectly listed as as bitwise
- thus bitwise operators "and", "or" were incorrectly shown
- "exclusive or" operator added
- logical and arithmetic "not" operators added
- ternary operator added
- moved shift operators from arithmetic to bitwisesource/source-language.rst | 70 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-)Index:
b/source/source-language.rst
===================================================================source/source-language.rst +0
-0@@ -9,6 +9,19 @@ devicetree in the form expected by the k
< snip >
Quoted 12 lines
source/source-language.rst null-terminated strings, as bytestrings · line 112
Quoted 11 lines
source/source-language.rst +11
-0+ Logical operators + + < less than + > greater than + <= less than or equal + >= greater than or equal + == equal + != not equal + && and + || or + ! not
Quoted 3 lines
Fwiw, I think &&, || and ! usually get classified as "logical operators" but <, > etc. get classified as "relational operators" rather than putting them in the same category.
Good point. I'll send v3 with that change.
Quoted 2 lines
Hrm.. given that you're listing them all here, I wonder if it would make sense to do so in precedence order (should be the same as for C).
That seems like a good idea, so I tried it. The result is a lot less readable to me.
< snip >