Commit graph

79 commits

Author SHA1 Message Date
Scott Wood
910efac4b4 Look for include files in the directory of the including file.
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>
2008-01-04 08:20:10 -06:00
Scott Wood
f77fe6a20e Add yyerrorf() for formatted error messages.
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-01-04 08:04:15 -06:00
David Gibson
efbbef8e4f dtc: Implement path references
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>
2007-12-05 08:28:44 -06:00
David Gibson
c048102f5b dtc: Generate useful error message for properties after subnodes
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>
2007-12-05 08:27:46 -06:00
David Gibson
dc941774e2 dtc: Merge refs and labels into single "markers" list (v2)
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>
2007-11-26 16:00:19 -06:00
David Gibson
9138db565a dtc: Switch dtc to C-style literals
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>
2007-11-08 11:14:07 -06:00
David Gibson
9ed27a2aac dtc: Simplify lexing/parsing of literals vs. node/property names
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>
2007-11-08 11:14:07 -06:00
David Gibson
f7497dc6be dtc: Don't force alignment of cell list data
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>
2007-11-05 08:42:10 -06:00
Jon Loeliger
7b3fb789d2 DTC: Remove the need for the GLR Parser.
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>
2007-10-25 11:13:29 -05:00
Jon Loeliger
7dfba39a23 DTC: Remove an unneeded %token definition.
Signed-off-by: Jon Loeliger <jdl@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-23 09:37:09 -05:00
Jon Loeliger
5641289a46 DTC: Minor grammar rule shuffle.
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>
2007-10-23 09:35:36 -05:00
Jon Loeliger
30807ca1ce Reformat grammar rules to not mix language syntax and yacc syntax.
Use consistent indenting on all rule actions.

Signed-off-by: Jon Loeliger <jdl@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-22 11:40:51 -05:00
David Gibson
63dc9c7113 dtc: Whitespace cleanup
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>
2007-09-18 09:43:26 -05:00
Milton Miller
6a99b13132 dtc: implement labels on property data
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>
2007-07-07 10:13:31 -05:00
Milton Miller
d429033851 dtc: implement labels on memory reserve slots
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>
2007-07-07 10:09:31 -05:00
Milton Miller
85ab5cc6ec dtc: complain about unparsed digits in cell lists
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>
2007-07-07 10:07:44 -05:00
Milton Miller
6d7b222430 dtc: move declaration of yyerror
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>
2007-07-07 10:07:27 -05:00
Jon Loeliger
e45e6fd274 DTC: Add support for a C-like #include "file" mechanism.
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>
2007-03-26 08:36:07 -05:00
Jon Loeliger
3948849fd0 Moved data_convert_cell() out of data.c to the parser.
It constructs a cell_t, not data objects.
Renamed it to cell_from_string() as well.

Signed-off-by: Jon Loeliger <jdl@freescale.com>
2007-02-16 09:33:54 -06:00
Jon Loeliger
af0278a3a0 Add support for decimal, octal and binary based cell values.
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>
2007-02-15 10:59:27 -06:00
David Gibson
32da475af1 Allow multipart property values
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>
2007-02-08 17:26:41 -06:00
David Gibson
f040d95b84 Rework tracking of reserve entries during processing. This is initial work
to allow more powerful handling of reserve entries.
2005-10-24 18:18:38 +10:00
David Gibson
86dbcbd1e4 Rudimentary support for reporting the line number of syntax errors. 2005-10-19 16:00:31 +10:00
David Gibson
f0517db250 Support for specifying memreserve ranges in the source format, based on
a patch by Jon Loeliger <jdl AT freescale.com>, although tweaked
substantially.
2005-07-15 17:14:24 +10:00
David Gibson
03a9b9dcdc Use u8 instead of uint8_t, as we do with the other size types. 2005-07-11 16:49:52 +10:00
David Gibson
9ad4587c90 Remove build_empty_property(). It wasn't useful. 2005-06-17 14:32:32 +10:00
David Gibson
81f2e89c75 Rudimentary phandle reference support. 2005-06-16 17:04:00 +10:00
David Gibson
4102d840d9 Initial label support. Also switch to glr-parser mode and get rid of
hacks that were necessary without it.
2005-06-16 14:36:37 +10:00
David Gibson
fc14dad769 Initial commit 2005-06-08 17:18:34 +10:00