Commit graph

258 commits

Author SHA1 Message Date
David Gibson
6b8e05626a dtc: Make eval_literal() static
eval_literal() is used only in the parser, so make it a static
function.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23 08:00:33 -05:00
David Gibson
b2de518b80 dtc: Make -I dtb mode use fill_fullpaths()
At present -I dts and -I fs modes both use the fill_fullpaths() helper
function to fill in the fullpath and basenamelen fields of struct
node, which are useful in later parts of the code.  -I dtb mode,
however, fills these in itself.

This patch simplifies flattree.c by making -I dtb mode use
fill_fullpaths() like the others.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23 08:00:33 -05:00
David Gibson
5ac97df149 dtc: Use for_each_marker_of_type in asm_emit_data()
For no good reason, asm_emit_data() open-codes the equivalent of the
for_each_marker_of_type macro.  Use the macro instead.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23 08:00:33 -05:00
David Gibson
a266e5c1e1 dtc: Test and fix conversion to/from old dtb versions
This patch adds testcases which test dtc when used to convert between
different dtb versions.  These tests uncovered a couple of bugs
handling old dtb versions, which are also fixed.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23 08:00:33 -05:00
David Gibson
d028e84140 dtc: Strip redundant "name" properties
If an input device tree has "name" properties which are correct, then
they are redundant (because they can be derived from the unit name).
Therefore, extend the checking code for correctness of "name"
properties to remove them if they are correct.  dtc will still insert
name properties in the output if that's of a sufficiently old version
to require them.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23 08:00:33 -05:00
David Gibson
2b3a96761a dtc: Fix indentation of fixup_phandle_references
Somehow the indentation of this function is messed up - 7 spaces
instead of 1 tab (probably a bad copy paste from a patch file).  This
patch fixes it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23 08:00:33 -05:00
David Gibson
fa5b520ccb dtc: Implement checks for the format of node and property names
This patch adds checks to the checking framework to verify that node
and property names contain only legal characters, and in the case of
node names there is at most one '@'.

At present when coming from dts input, this is mostly already ensured
by the grammer, however putting the check later means its easier to
generate helpful error messages rather than just "syntax error".  For
dtb input, these checks replace the older similar check built into
flattree.c.

Testcases for the checks are also implemented.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23 08:00:32 -05:00
David Gibson
7c635dcb2f dtc: Fix error reporting in push_input_file()
Error reporting in push_input_file() is a mess.  One error results in
a message and exit(1), others result in a message and return 0 - which
is turned into an exit(1) at one callsite.  The other callsite doesn't
check errors, but probably should.  One of the error conditions gives
a message, but can only be the result of an internal programming
error, not a user error.

So.  Clean that up by making push_input_file() a void function, using
die() to report errors and quit.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23 08:00:32 -05:00
David Gibson
2512a7eb5c libfdt: Remove no longer used code from fdt_node_offset_by_compatible()
Since fdt_node_offset_by_compatible() was converted to the new
fdt_next_node() iterator, a chunk of initialization code became
redundant, but was not removed by oversight.  This patch cleans it up.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-02-18 08:29:01 -06:00
David Gibson
8a4e75049d libfdt: Trivial cleanup for CHECK_HEADER)
Currently the CHECK_HEADER() macro is defined local to fdt_ro.c.
However, there are a handful of functions (fdt_move, rw_check_header,
fdt_open_into) from other files which could also use it (currently
they open-code something more-or-less identical).  Therefore, this
patch moves CHECK_HEADER() to libfdt_internal.h and uses it in those
places.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-02-18 08:27:13 -06:00
David Gibson
a90b5905fe libfdt: More tests of NOP handling behaviour
In light of the recently discovered bug with NOP handling, this adds
some more testcases for NOP handling.  Specifically, it adds a helper
program which will add a NOP tag after every existing tag in a dtb,
and runs the standard battery of tests over trees mangled in this way.

For now, this does not add a NOP at the very beginning of the
structure block.  This causes problems for libfdt at present, because
we assume in many places that the root node's BEGIN_NODE tag is at
offset 0.  I'm still contemplating what to do about this (with one
option being simply to declare such dtbs invalid).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-02-18 08:21:52 -06:00
David Gibson
d8b6942666 dtc: Fold comment handling test into testsuite
For ages dtc has included a sample dts, comment-test.dts, for checking
various lexical corner cases in comment processing.  In fact, it
predates the automated testsuite, and has never been integrated into
it.  This patch addresses this oversight, folding the comment handling
test in with the rest of the testsuite.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-02-15 08:10:14 -06:00
David Gibson
089adb9964 libfdt: Fix NOP handling bug in fdt_add_subnode_namelen()
fdt_add_subnode_namelen() has a bug if asked to add a subnode to a
node which has NOP tags interspersed with its properties.  In this
case fdt_add_subnode_namelen() will put the new subnode before the
first NOP tag, even if there are properties after it, which will
result in an invalid blob.

This patch fixes the bug, and adds a testcase for it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-02-14 08:02:41 -06:00
David Gibson
fc9769ac2b libfdt: Add and use a node iteration helper function.
This patch adds an fdt_next_node() function which can be used to
iterate through nodes of the tree while keeping track of depth.  This
function is used to simplify the iteration code in a lot of other
functions, and is also exported for use by library users.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-02-12 09:11:40 -06:00
Jon Loeliger
202863e4dd Tag Version 1.1.0
Signed-off-by: Jon Loeliger <jdl@jdl.com>
2008-01-24 10:16:07 -06:00
Scott Wood
0f635df874 Remove const from dtc_file::dir.
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-01-11 13:23:37 -06:00
David Gibson
82b327d380 libfdt: Add fdt_set_name() function
This patch adds an fdt_set_name() function to libfdt, mirroring
fdt_get_name().  This is a r/w function which alters the name of a
given device tree node.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-01-11 07:40:40 -06:00
Jon Loeliger
7364cc79b5 Tag Version 1.1.0-rc1
Signed-off-by: Jon Loeliger <jdl@jdl.com>
2008-01-10 09:09:44 -06:00
Scott Wood
b1a6719aa6 Preserve scanner state when /include/ing.
This allows /include/s to work when in non-default states,
such as PROPNODECHAR.

We may want to use state stacks to get rid of BEGIN_DEFAULT() altogether...

Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-01-10 07:43:33 -06:00
Scott Wood
42107f8bba Convert malloc() uses to xmalloc().
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-01-07 14:36:41 -06:00
Scott Wood
3c3ecaacda Remove \n from yyerror() call.
The \n is provided by yyerror().

Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-01-07 09:20:29 -06:00
Scott Wood
5695e99d5f Handle absolute pathnames correctly in dtc_open_file.
Also, free file->dir when freeing file.

Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-01-07 09:20:21 -06:00
David Gibson
7d24bd0a72 dtc/libfdt: Add README clarifying licensing
The fact that the dtc and libfdt are distributed together, but have
different licenses, can be a bit confusing.  Several people have
enquired as to what the deal is with the libfdt licensing, so this
patch adds a README clarifying the situation with a rationale.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jon Loeliger <jdl@jdl.com>
2008-01-04 08:37:36 -06:00
Scott Wood
ad4f54ae2b Return a non-zero exit code if an error occurs during dts parsing.
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>
2008-01-04 08:21:54 -06:00
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
3bb78bfd97 dtc: Remove header information dumping
Currently, when used in -Idtb mode, dtc will dump information about
the input blob's header fields to stderr.  This is kind of ugly, and
can get in the way of dtc's real output.

This patch, therefore, removes this.  So that there's still a way of
getting this information for debugging purposes, it places something
similar to the removed code into ftdump, replacing the couple of
header fields it currently prints with a complete header dump.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-01-03 07:46:29 -06:00
David Gibson
3e516d961a dtc: Update TODO files
This patch makes a bunch of updates to the TODO files for dtc and
libfdt, some of them rather overdue.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-19 08:20:26 -06:00
David Gibson
08c0be206d dtc: Add missing copyright notice for dumptrees.c
When I released libfdt, I forgot to add a copyright notice to
dumptrees.c (probably because the program is so trivial).  Apparently
the lack causes trouble for Debian, so this patch adds one.  I've gone
through the git history and double checked that no-one has touched
this file except me (and I barely have myself since its initial
commit).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-19 08:18:08 -06:00
David Gibson
376ab6f2ed dtc: Remove remaining old-style checks
The remaining old-style tree checking code: check_root(), check_cpus()
and check_memory() really aren't that useful.  They mostly check for
the presence of particular nodes and properties.  That's inherently
prone to false-positives, because we could be dealing with an
artificial tree (like many of the testcases) or it could be expected
that the missing properties are filled in by a bootloader or other
agent.

If any of these checks really turns out to be useful, we can
reimplement them later in a better conceived way on top of the new
checking infrastructure.  For now, just get rid of them, removing the
last vestiges of the old-style checking code (hoorah).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-18 07:54:30 -06:00
David Gibson
d6f9b62fe1 dtc: Don't build tests as part of "all"
Currently "make all" for dtc will build (but not run) the testcase
binaries.  This is a problem for cross compiles, because building the
tests will attempt to run the dumptrees utility on the host system,
which won't work if it's cross-compiled of course.

Although it would be possible to separately build host binaries,
there's not a lot of value in doing so since we don't have a facility
for cross-executing the testsuite anyway.

Therefore, remove the tests from the "all" target.  It will still, of
course, be build as a prerequisite to "make check" which will run the
testsuite.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-17 07:41:13 -06:00
David Gibson
30f7fbfbe9 libfdt: Add more documentation (patch the seventh)
This patch adds more documenting comments to libfdt.h.  Specifically,
these document the read/write functions (not including fdt_open_into()
and fdt_pack(), for now).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-17 07:39:33 -06:00
David Gibson
f819a4e21d libfdt: Add more documentation (patch the sixth)
This patch adds some more documenting comments to libfdt.h.
Specifically this documents all the write-in-place functions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-17 07:38:42 -06:00
David Gibson
a68cbc09ff dtc: Fix silly typo in dtc-checkfails.sh
Too much C coding makes for dumb errors in shell.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-07 07:47:45 -06:00
David Gibson
b7c5eaf3ee dtc: Allow gcc format warnings for check_msg()
check_msg() takes printf() like arguments, so tell gcc to produce
printf() like warnings for it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-07 07:47:15 -06:00
David Gibson
0d9d10184b dtc: Make dtc-checfails.sh script catch deaths-by-signal
Since commit 5ba0086bfd, the
dtc-checkfails.sh script does not check the return code from dtc.
That's reasonable, since depending on the checks we're testing, dtc
could either complete succesfully or return an error.

However, it's never right for dtc to SEGV or otherwise be killed by a
signal.  So the script should catch that, and fail the testcase if it
happens.  This patch implements this behaviour.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-07 07:45:44 -06:00
David Gibson
3476f9608b dtc: Reinstate full old-style reference-to-path for v0 dts files
Commit 7c44c2f9cb broke backwards
compatibility more badly than I realised.  Contrary to what I thought
there are in-kernel, in-use dts files which relied on
references-to-path with paths including a comma, which no longer
compile after that commit.

So, this patch reinstates full support for bare references-to-path in
dts-v0 input.  This means there will be some rather surprising lexical
corner cases when using path-expanded references in v0 files.  But,
since path-expanded references are new, v0 files shouldn't typically
be using them anyway.  If the corner cases cause a problem, you can
always convert to dts-v1 which handles the lexical issues here more
nicely.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-07 07:44:45 -06:00
David Gibson
e4ffc1443d dtc: Convert check for obsolete /chosen property
This converts the test for the obsolete "interrupt-controller"
property in /chosen to the new framework.  That was the only thing
left in the old-style check_chosen() function, so that function is
removed, too.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-07 07:43:53 -06:00
David Gibson
7e089d9473 dtc: Convert #address-cells and #size-cells related checks
This patch converts checks related to #address-cells and #size-cells
to the new framework.  Specifically, it reimplements the check that
"reg" properties have a valid size based on the relevant
#address-cells and #size-cells values.  The new implementation uses
the correct default value, unlike the old-style check which assumed
the values were inherited by default.

It also implements a new, similar test for "ranges" properties.

Finally, since relying on the default values of these variables is
considered not-good-practice these days, it implements a "style" check
which will give a warning if the tree ever relies on the default
values (that is if any node with either "reg" or "ranges" appears
under a parent which has no #address-cells or #size-cells property).
2007-12-07 07:43:45 -06:00
David Gibson
e110920707 dtc: Remove obsolete check_properties() function
After the last couple of patches converting various old-style semantic
checks to the new framework, the only thing that the old-style
check_properties() function still checks is that the size of "reg"
properties is a multiple of the cell size.

This patch removes check_properties() and all related code and data.
The check on the size of reg properties is folded into the existing
check for the format of "reg" properties (still old-style for the time
being).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-06 09:17:24 -06:00
David Gibson
faf037f0ef dtc: Migrate "string property" checks to new framework
This patch converts to the new tree checking framework those checks
which verify that certain properties (device_type, model) have a
string value, when present.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-06 09:16:28 -06:00
David Gibson
c21acabc40 dtc: Migrate "one cell" checks to new framework
This patch converts to the new tree checking framework those checks
which verify that certain properties (#address-cells and #size-cells)
are exactly one cell in size, when present.

We also drop the old-style check for "linux,phandle" being one cell,
since that is already implied in the the existing new-style checks on
the linux,phandle property.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-06 09:15:56 -06:00
David Gibson
5ba0086bfd dtc: More detailed testing of tree checks
This patch modifies the dtc-checkfails.sh testcase wrapper so that
instead of testing just that dtc fails with a particular error code on
the sample input, it scans dtc's stderr output looking for a message
that dtc failed a specific check or checks.  This has several advantages:
	- It means we more precisely check dtc's checking behaviour
	- It means we can check for generation of warnings using the
same script
	- It means we can test cases where dtc should generate
multiple errors or warnings from different checks

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-06 09:15:19 -06:00
David Gibson
d6060bd231 dtc: Remove space from flex command line
Author: Geoff Levand <geoffrey.levand@am.sony.com>

Apparently some versions of flex don't correctly parse the -o
parameter, if there's a space between the -o and its argument.  So,
this patch removes it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-06 09:14:12 -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
Kumar Gala
80c72a81cf Fix padding options
"Add an option to pad the blob that is generated" broke the padding
support.  We were updating the fdt header after writing it.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2007-12-05 08:27:54 -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
2b67c632df dtc: Trivial lexer cleanups
This patch applies a couple of tiny cleanups to the lexer.  The
not-very-useful 'WS' named pattern is removed, and the debugging
printf() for single character tokens is moved to the top of the
action, which results in less confusing output when LEXDEBUG is
switched on (because it goes before the printf()s for possible
resulting lexer state changes).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-05 08:27:37 -06:00
David Gibson
459c955cca dtc: Convert "name" property checking to new infrastructure
This patch removes the old-style checking code for the "name" property
- i.e. verifying that the "name" property, if present, matches the
node name.  It replaces it with a pair of more-or-less equivalent
checks in the new checking framework.

This also promotes this check to a "structural" check, or at least an
error-rather-than-warning test, since the structural/semantic
distinction doesn't really apply in the new framework.

A testcase for the check is also added.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-05 08:27:28 -06:00
David Gibson
d06cda32f6 dtc: Fix FAIL() macro varargs
The way the checking subsystem FAIL() macro is currently implemented
it must take at least one paramater after the format string.  This
patch corrects the problem.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-05 08:27:22 -06:00