summaryrefslogtreecommitdiff
path: root/dtc-parser.y
Commit message (Collapse)AuthorAgeFilesLines
* dtc: Add ability to delete nodes and propertiesStephen Warren2012-09-061-0/+21
| | | | | | | | | | | | | | | | | | | dtc currently allows the contents of properties to be changed, and the contents of nodes to be added to. There are situations where removing properties or nodes may be useful. This change implements the following syntax to do that: / { /delete-property/ propname; /delete-node/ nodename; }; or: /delete-node/ &noderef; Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Basic integer expressionsStephen Warren2012-04-091-24/+132
| | | | | | | | | | | Written by David Gibson <david@gibson.dropbear.id.au>. Additions by me: * Ported to ToT dtc. * Renamed cell to integer throughout. * Implemented value range checks. * Allow U/L/UL/LL/ULL suffix on literals. * Enabled the commented test. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
* dtc: Add support for variable sized elementsAnton Staaf2011-10-111-22/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Elements of size 8, 16, 32, and 64 bits are supported. The new /bits/ syntax was selected so as to not pollute the reserved keyword space with uint8/uint16/... type names. With this patch the following property assignment: property = /bits/ 16 <0x1234 0x5678 0x0 0xffff>; is equivalent to: property = <0x12345678 0x0000ffff>; It is now also possible to directly specify a 64 bit literal in a cell list, also known as an array using: property = /bits/ 64 <0xdeadbeef00000000>; It is an error to attempt to store a literal into an element that is too small to hold the literal, and the compiler will generate an error when it detects this. For instance: property = /bits/ 8 <256>; Will fail to compile. It is also an error to attempt to place a reference in a non 32-bit element. The documentation has been changed to reflect that the cell list is now an array of elements that can be of sizes other than the default 32-bit cell size. The sized_cells test tests the creation and access of 8, 16, 32, and 64-bit sized elements. It also tests that the creation of two properties, one with 16 bit elements and one with 32 bit elements result in the same property contents. Signed-off-by: Anton Staaf <robotboy@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Support character literals in cell listsAnton Staaf2011-09-221-0/+32
| | | | | | | | | | | | | With this patch the following property assignment: property = <0x12345678 'a' '\r' 100>; is equivalent to: property = <0x12345678 0x00000061 0x0000000D 0x00000064> Signed-off-by: Anton Staaf <robotboy@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* Allow nodes to be referenced by path at the top level.John Bonesio2010-11-131-3/+2
| | | | | | | | | When nodes are modified by merging device trees, nodes to be updated/merged can be specified by a label. Specifying nodes by full path (instead of label) doesn't quite work. This patch fixes that. Signed-off-by: John Bonesio <bones@secretlab.ca> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* Create new and use new print_error that uses printf style formatting.John Bonesio2010-10-201-10/+18
| | | | | | | | | | | | yyerror is meant to be called by the parser internal code, and it's interface is limited. Instead create and call a new error message routine that allows formatted strings to be used. yyerror uses the new routine so error formatting remains consistent. Signed-of-by: John Bonesio <bones@secretlab.ca> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
* Add merging of labelled subnodes. This patch allows the followingDavid Gibson2010-09-211-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | syntax: / { child { label: subchild { }; }; }; &label { prop = "value"; }; which will result in the following tree: / { child { label: subchild { prop = "value"; }; }; }; Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
* Allow device tree to be modified by additonal device tree sectionsGrant Likely2010-02-251-1/+13
| | | | | | | | | | | | | | | | | | | | | | | This patch allows the following construct: / { property-a = "old"; property-b = "does not change"; }; / { property-a = "changed"; property-c = "new"; node-a { }; }; Where the later device tree overrides the properties found in the earlier tree. This is useful for laying down a template device tree in an include file and modifying it for a specific board without having to clone the entire tree. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
* dtc: Allow multiple labels on nodes and propertiesDavid Gibson2010-02-241-20/+23
| | | | | | | | | | | | | | | | | At present, both the grammar and our internal data structures mean that there can be only one label on a node or property. This is a fairly arbitrary constraint, given that any number of value labels can appear at the same point, and that in C you can have any number of labels on the same statement. This is pretty much a non-issue now, but it may become important with some of the extensions that Grant and I have in mind. It's not that hard to change, so this patch does so, allowing an arbitrary number of labels on any given node or property. As usual a testcase is added too. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Grant Likely <grant.likely@secretlab.ca>
* dtc: Automatically pick a sensible boot_cpuid_physDavid Gibson2010-02-191-1/+2
| | | | | | | | | | | | | | | | | | | | | Currently, when in -Idts -Odtb or -Ifs -Odtb modes, dtc always defaults to using 0 as the value for the boot_cpuid_phys header field. That's correct quite often, but there are some systems where there is no CPU with hardware ID of 0, or where we don't want to use the CPU with hardware ID 0 at all (e.g. for AMP-style partitioning). The only way to override this default currently, is with the -b command line option. This patch improves dtc to instead base the default boot_cpuid_phys value on the reg property of the first listed subnode of /cpus. This means that dtc will get boot_cpuid_phys correct by default in a greater proportion of cases (since the boot cpu is usually listed first, and this way at least the boot_cpuid_phys default will match some existing cpu node). If the node doesn't exist or has an invalid 'reg' property (missing or not 4 bytes in length), then boot_cpuid_phys is set to 0. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Modification of lexer and parser, improving dtc portability.Lukasz Wojcik2010-02-081-2/+2
| | | | | | | This mod allows successful build of dtc using both bison/flex and yacc/lex. Signed-off-by: Lukasz Wojcik <zbr@semihalf.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Simpler interface to source file managementDavid Gibson2010-01-141-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | This patch cleans up our handling of input files, particularly dts source files, but also (to an extent) other input files such as those used by /incbin/ and those used in -I dtb and -I fs modes. We eliminate the current clunky mechanism which combines search paths (which we don't actually use at present) with the open relative to current source file behaviour, which we do. Instead there's a single srcfile_relative_open() entry point for callers which opens a new input file relative to the current source file (which the srcpos code tracks internally). It doesn't currently do search paths, but we can add that later without messing with the callers, by drawing the search path from a global (which makes sense anyway, rather than shuffling it around the rest of the processing code). That suffices for non-dts input files. For the actual dts files, srcfile_push() and srcfile_pop() wrappers open the file while also keeping track of it as the current source file for future opens. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Use yylloc instead of yylocDavid Gibson2009-11-111-1/+1
| | | | | | | yylloc is the correct way to get token positioning information. yyloc is a bison internal variable that only works by accident. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Remove support for the legacy DTS source file format.Jon Loeliger2008-10-031-46/+0
| | | | | | | | | | | | | Now that all in-kernel-tree DTS files are properly /dts-v1/, remove direct support for the older, un-numbered DTS source file format. Convert existing tests to /dts-v1/ and remove support for the conversion tests themselves. For now, though, the conversion tool still exists. Signed-off-by: Jon Loeliger <jdl@freescale.com>
* Enhance source position implementation.Jon Loeliger2008-10-031-21/+8
| | | | | | | | | Implemented some print and copy routines. Made empty srcpos objects that will be used later. Protected .h file from multiple #include's. Added srcpos_error() and srcpos_warn(). Signed-off-by: Jon Loeliger <jdl@freescale.com>
* dtc: Use stdint.h types throughout dtcDavid Gibson2008-07-141-2/+2
| | | | | | | | | Currently, dtc defines Linux-like names for various fixed-size integer types. There's no good reason to do this; even Linux itself doesn't use these names for externally visible things any more. This patch replaces these with the C99 standardized type names from stdint.h. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Add support for binary includes.David Gibson2008-06-191-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Wed, Jun 04, 2008 at 09:26:23AM -0500, Jon Loeliger wrote: > David Gibson wrote: > >> But as I said that can be dealt with in the future without breaking >> compatibility. Objection withdrawn. >> > > And on that note, I officially implore Scott to > re-submit his binary include patch! Scott's original patch does still have some implementation details I didn't like. So in the interests of saving time, I've addressed some of those, added a testcase, and and now resubmitting my revised version of Scott's patch. dtc: Add support for binary includes. A property's data can be populated with a file's contents as follows: node { prop = /incbin/("path/to/data"); }; A subset of a file can be included by passing start and size parameters. For example, to include bytes 8 through 23: node { prop = /incbin/("path/to/data", 8, 16); }; As with /include/, non-absolute paths are looked for in the directory of the source file that includes them. Implementation revised, and a testcase added by David Gibson Signed-off-by: Scott Wood <scottwood@freescale.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Scott Wood <scottwood@freescale.com>
* dtc: Rework handling of boot_cpuid_physDavid Gibson2008-05-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, dtc will put the nonsense value 0xfeedbeef into the boot_cpuid_phys field of an output blob, unless explicitly given another value with the -b command line option. As well as being a totally unuseful default value, this also means that dtc won't properly preserve the boot_cpuid_phys field in -I dtb -O dtb mode. This patch reworks things to improve the boot_cpuid handling. The new semantics are that the output's boot_cpuid_phys value is: the value given on the command line if -b is used otherwise the value from the input, if in -I dtb mode otherwise 0 Implementation-wise we do the following: - boot_cpuid_phys is added to struct boot_info, so that structure now contains all of the blob's semantic information. - dt_to_blob() and dt_to_asm() output the cpuid given in boot_info - dt_from_blob() fills in boot_info based on the input blob - The other dt_from_*() functions just record 0, but we can change this easily if e.g. we invent a way of specifying the boot cpu in the source format. - main() overrides the cpuid in the boot_info between input and output if -b is given We add some testcases to check this new behaviour. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Make eval_literal() staticDavid Gibson2008-03-231-3/+3
| | | | | | | eval_literal() is used only in the parser, so make it a static function. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Remove \n from yyerror() call.Scott Wood2008-01-071-1/+1
| | | | | | The \n is provided by yyerror(). Signed-off-by: Scott Wood <scottwood@freescale.com>
* Return a non-zero exit code if an error occurs during dts parsing.Scott Wood2008-01-041-0/+2
| | | | | | | | Previously, only failure to parse caused the reading of the tree to fail; semantic errors that called yyerror() but not YYERROR only emitted a message, without signalling make to stop the build. Signed-off-by: Scott Wood <scottwood@freescale.com>
* Look for include files in the directory of the including file.Scott Wood2008-01-041-1/+1
| | | | | | | | | | | Looking in the diretory dtc is invoked from is not very useful behavior. As part of the code reorganization to implement this, I removed the uniquifying of name storage -- it seemed a rather dubious optimization given likely usage, and some aspects of it would have been mildly awkward to integrate with the new code. Signed-off-by: Scott Wood <scottwood@freescale.com>
* Add yyerrorf() for formatted error messages.Scott Wood2008-01-041-3/+13
| | | | Signed-off-by: Scott Wood <scottwood@freescale.com>
* dtc: Implement path referencesDavid Gibson2007-12-051-0/+4
| | | | | | | | | | | | This patch extends dtc syntax to allow references (&label, or &{/full/path}) directly within property definitions, rather than inside a cell list. Such references are expanded to the full path of the referenced node, as a string, instead of to a phandle as references within cell lists are evaluated. A testcase is also included. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Generate useful error message for properties after subnodesDavid Gibson2007-12-051-0/+5
| | | | | | | | | | | On several occasions, I've accidentally put properties after subnodes in a dts file. I've then spent ages thinking that the resulting syntax error was because of something else. This patch arranges for this specific syntax error to generate a more specific and useful error message. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Merge refs and labels into single "markers" list (v2)David Gibson2007-11-261-5/+6
| | | | | | | | | | | | | | | | | | | | | Currently, every 'data' object, used to represent property values, has two lists of fixup structures - one for labels and one for references. Sometimes we want to look at them separately, but other times we need to consider both types of fixup. I'm planning to implement string references, where a full path rather than a phandle is substituted into a property value. Adding yet another list of fixups for that would start to get silly. So, this patch merges the "refs" and "labels" lists into a single list of "markers", each of which has a type field indicating if it represents a label or a phandle reference. String references or any other new type of in-data marker will then just need a new type value - merging data blocks and other common manipulations will just work. While I was at it I made some cleanups to the handling of fixups which simplify things further. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Switch dtc to C-style literalsDavid Gibson2007-11-081-2/+36
| | | | | | | | | | | | | dtc: Switch dtc to C-style literals This patch introduces a new version of dts file, distinguished from older files by starting with the special token /dts-v1/. dts files in the new version take C-style literals instead of the old bare hex or OF-style base notation. In addition, the "range" for of memreserve entries (/memreserve/ f0000-fffff) is no longer recognized in the new format. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Jon Loeliger <jdl@freescale.com>
* dtc: Simplify lexing/parsing of literals vs. node/property namesDavid Gibson2007-11-081-68/+56
| | | | | | | | | | | | The current scheme of having CELLDATA and MEMRESERVE states to recognize hex literals instead of node or property names is arse-backwards. The patch switches things around so that literals are lexed in normal states, and property/node names are only recognized in the special PROPNODENAME state, which is only entered after a { or a ;, and is left as soon as we scan a property/node name or a keyword. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Jon Loeliger <jdl@freescale.com>
* dtc: Don't force alignment of cell list dataDavid Gibson2007-11-051-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | At present, defining a property as, say: foo = [abcd], <ffffffff>; Will cause dtc to insert 2 bytes of zeros between the abcd and the ffffffff, to align the cell form data. Doing so seemed like a good idea at the time, but I don't believe there are any users who actually rely on this behaviour. Segher claims that OF has some defined bindings which include properties an unaligned subsection of which is interpreted as 32-bit ints (i.e. like cell data). Worse, this alignment will cause nothing but pain when we add expression support to dtc (when celldata is included in a larger bytestring expession, we won't know the size of the preceding chunk of the expression until it's evaluated, so we would have to carry alignment fixup information right through the expression evaluation process). Therefore, this patch kills off this alignment behaviour. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* DTC: Remove the need for the GLR Parser.Jon Loeliger2007-10-251-3/+2
| | | | | | | | | | | | | Previously, there were a few shift/reduce and reduce/reduce errors in the grammar that were being handled by the not-so-popular GLR Parser technique. Flip a right-recursive stack-abusing rule into a left-recursive stack-friendly rule and clear up three messes in one shot: No more conflicts, no need for the GLR parser, and friendlier stackness. Compensate by reversing the property list on the node. Signed-off-by: Jon Loeliger <jdl@freescale.com>
* DTC: Remove an unneeded %token definition.Jon Loeliger2007-10-231-1/+0
| | | | | Signed-off-by: Jon Loeliger <jdl@freescale.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* DTC: Minor grammar rule shuffle.Jon Loeliger2007-10-231-31/+31
| | | | | | | | | I like to see the basis cases established early in the rule sets, so place "empty" reduction first. Purely cosmetic. Signed-off-by: Jon Loeliger <jdl@freescale.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* Reformat grammar rules to not mix language syntax and yacc syntax.Jon Loeliger2007-10-221-34/+118
| | | | | | | Use consistent indenting on all rule actions. Signed-off-by: Jon Loeliger <jdl@freescale.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Whitespace cleanupDavid Gibson2007-09-181-6/+6
| | | | | | | | | | | | This large patch removes all trailing whitespace from dtc (including libfdt, the testsuite and documentation). It also removes a handful of redundant blank lines (at the end of functions, or when there are two blank lines together for no particular reason). As well as anything else, this means that quilt won't whinge when I go to convert the whole of libfdt into a patch to apply to the kernel. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: implement labels on property dataMilton Miller2007-07-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | Extend the parser grammer to allow labels before or after any property data (string, cell list, or byte list), and any byte or cell within the property data. Store the labels using the same linked list structure as node references, but using a parallel list. When writing assembly output emit global labels as offsets from the start of the definition of the data. Note that the alignment for a cell list is done as part of the opening < delimiter, not the = or , before it. To label a cell after a string or byte list put the label inside the cell list. For example, prop = zero: [ aa bb ], two: < four: 1234 > eight: ; will produce labels with offsets 0, 2, 4, and 8 bytes from the beginning of the data for property prop. Signed-off-by: Milton Miller <miltonm@bga.com>
* dtc: implement labels on memory reserve slotsMilton Miller2007-07-071-4/+4
| | | | | | | | Allow a label to be placed on a memory reserve entry. Change the parser to recognize and store them. Emit them when writing assembly output. Signed-off-by: Milton Miller <miltonm@bga.com>
* dtc: complain about unparsed digits in cell listsMilton Miller2007-07-071-3/+11
| | | | | | | | | Check that strtoul() parsed the complete string. As with the number overflow case, write a non-fatal error message to stdout. Signed-off-by: Milton Miller <miltonm@bga.com>
* dtc: move declaration of yyerrorMilton Miller2007-07-071-1/+0
| | | | | | | yyerror() is used by both dtc-parser.y and dtc-lexer.l, so move the declaration to srcpos.h. Signed-off-by: Milton Miller <miltonm@bga.com>
* DTC: Add support for a C-like #include "file" mechanism.Jon Loeliger2007-03-261-1/+8
| | | | | | | | | | | | Keeps track of open files in a stack, and assigns a filenum to source positions for each lexical token. Modified error reporting to show source file as well. No policy on file directory basis has been decided. Still handles stdin. Tested on all arch/powerpc/boot/dts DTS files Signed-off-by: Jon Loeliger <jdl@freescale.com>
* Moved data_convert_cell() out of data.c to the parser.Jon Loeliger2007-02-161-3/+27
| | | | | | | It constructs a cell_t, not data objects. Renamed it to cell_from_string() as well. Signed-off-by: Jon Loeliger <jdl@freescale.com>
* Add support for decimal, octal and binary based cell values.Jon Loeliger2007-02-151-2/+14
| | | | | | | New syntax d#, b#, o# and h# allow for an explicit prefix on cell values to specify their base. Eg: <d# 123> Signed-off-by: Jon Loeliger <jdl@freescale.com>
* Allow multipart property valuesDavid Gibson2007-02-081-3/+10
| | | | | | | | | | | | | | | | | | | | At present each property definition in a dts file must give as the value either a string ("abc..."), a bytestring ([12abcd...]) or a cell list (<1 2 3 ...>). This patch allows a property value to be given as several of these, comma-separated. The final property value is just the components appended together. So a property could have a list of cells followed by a string, or a bytestring followed by some cells. Cells are always aligned, so if cells are given following a string or bytestring which is not a multiple of 4 bytes long, zero bytes are inserted to align the following cells. The primary motivation for this feature, however, is to allow defining a property as a list of several strings. This is what's needed for defining OF 'compatible' properties, and is less ugly and fiddly than using embedded \0s in the strings. Signed-off-by: David Gibson <dwg@au1.ibm.com> Signed-off-by: Jon Loeliger <jdl@freescale.com>
* Rework tracking of reserve entries during processing. This is initial workDavid Gibson2005-10-241-10/+7
| | | | to allow more powerful handling of reserve entries.
* Rudimentary support for reporting the line number of syntax errors.David Gibson2005-10-191-3/+4
|
* Support for specifying memreserve ranges in the source format, based onDavid Gibson2005-07-151-4/+35
| | | | | a patch by Jon Loeliger <jdl AT freescale.com>, although tweaked substantially.
* Use u8 instead of uint8_t, as we do with the other size types.David Gibson2005-07-111-1/+1
|
* Remove build_empty_property(). It wasn't useful.David Gibson2005-06-171-1/+1
|
* Rudimentary phandle reference support.David Gibson2005-06-161-0/+4
|
* Initial label support. Also switch to glr-parser mode and get rid ofDavid Gibson2005-06-161-6/+19
| | | | hacks that were necessary without it.
* Initial commitDavid Gibson2005-06-081-0/+116