Commit graph

21 commits

Author SHA1 Message Date
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
92cb9a25b1 dtc: Add many const qualifications
This adds 'const' qualifiers to many variables and functions.  In
particular it's now used for passing names to the tree accesor
functions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-04 07:54:03 -06:00
David Gibson
2d72816ccf dtc: Fix uninitialized use of structure_ok
My rework of the tree checking code introduced a potentially nasty bug
- it uses the structure_ok variable uninitialized.  This patch fixes
the problem.  It's a fairly ugly bandaid approach, but the ugly will
disappear once future patches have folded the semantic checks into the
new framework.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-04 07:27:08 -06:00
Kumar Gala
2b7dc8dce5 Add an option to pad the blob that is generated
There are times when we need extra space in the blob and just want
to have it added on w/o know the exact size to make it.

The padding and min size options are mutually exclusive.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2007-12-04 07:26:47 -06:00
David Gibson
b16a2bd89d dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure

Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.

In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables.  Each
check can (in principle) be individually switched off or on (as either
a warning or error).  Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.

For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism.  The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.

At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.

Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-26 16:00:08 -06:00
David Gibson
0d6ade2547 dtc: Add testcases for tree checks
This patch adds a group of testcases to check that dtc correctly
rejects trees with various structural errors.

To make things easier to test, we change dtc so that failing checks
(as opposed to other errors) result in exit code 2.

This patch also fixes an embarrasing bug uncovered by these new tests:
check_phandles() worked out if the tree's phandles were valid, then
throws that information away and returns success always.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-20 09:03:51 -06:00
David Gibson
169f0b183d dtc: Disable semantic checks by default
At present, dtc makes a lot of semantic checks on the device tree by
default, and will refuse to produce output if they fail.  This means
people tend to need -f to force output despite failing semantic checks
rather a lot.

This patch splits the device tree checks into structural checks (no
bad or duplicate names or phandles) and semantic checks (everything
else).  By default, only the structural checks are performed, and are
fatal.  -f will force output even with structural errors (using this
in -Idts mode would essentially always be a bad idea, but it might be
useful in -Idtb mode for examining a malformed dtb).

Semantic checks are only performed if the new -c command line option
is supplied, and are always warnings only.  Semantic checks will never
be performed on a tree with structural errors.

This patch is only a stopgap before implementing proper fine-grained
error/warning handling, but it should at least get rid of the
far-too-frequent need for -f for the time being.

This patch removes the -f from the dtc testcases now that it's no
longer necessary.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-22 09:53:15 -05:00
David Gibson
fb7c7acf5a dtc: Use libfdt/fdt.h instead of flat_dt.h
In the dtc tree, both flat_dt.h and libfdt/fdt.h have structures and
constants relating to the flattened device tree format derived from
asm-powerpc/prom.h in the kernel.  The former is used in dtc, the
latter in libfdt.

libfdt/fdt.h is the more recent, revised version, so use that
throughout, removing flat_dt.h.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-09-27 08:21:18 -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
David Gibson
bf94497031 dtc: Optimise by default, fix warnings thus uncovered
This patch turns on optimisation in the Makefile by default.  With the
optimizer on, some uninitialized variable warnings (one real, two
bogus) are now generated.  This patch also squashes those again.
2007-08-31 08:34:18 -05:00
Jon Loeliger
a657ce8fb7 Add DTC release version information.
Adopted the version information and implementation
from of the Linux Kernel Makefiles.

Signed-off-by: Jon Loeliger <jdl@jdl.com>
2007-07-07 13:52:25 -05:00
Jerry Van Baren
4f5370a138 Add -o <output file> to the usage message.
Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2007-04-19 17:17:51 -05:00
Jerry Van Baren
4384b23454 Implement the -R option and add a -S option.
Implement the -R <number> option to add memory reserve slots.
Add a -S <size> option makes the blob at least this number of bytes.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-04-05 09:57:55 -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
Jerry Van Baren
cd1da87116 Improve options, #define default version.
Add -h option for help
Add -q quiet option to reduce or suppress the whining
Create #define for the default version value.

Signed-off-by: vanbaren@cideas.com <vanbaren@cideas.com>
2007-03-19 08:54:40 -05:00
David Gibson
46c88dfcca Add support for flat device tree format version 17
libfdt defined a new version of the flattened device tree format,
version 17.  It is backwards compatible with version 16, just adding
an extra header field giving the size of the blob's structure blob.

This patch adds support to dtc allowing it to read and write version
17 blobs.  It also makes version 17 the default output version for
blobs.

At the same time we change the code to consistently using decimal
numbers for versions.  Previously we sometimes used 16 and sometimes
0x10 to refer to version 16.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-03-14 15:36:37 -05:00
Kim Phillips
f016882f91 Change default output blob version from 3 to 16
Signed-off-by: Kim Phillips <Kim.Phillips@freescale.com>
Signed-off-by: Jon Loeliger <jdl@freescale.com>
2006-11-01 08:15:18 -06:00
Michael Neuling
38e8f8fd88 dtc: add setting of physical boot cpu
dtc always sets the physical boot CPU to 0xfeedbeef.  Add a -b option to
set this.    Also add warnings when using the wrong property with the
wrong blob version.

Signed-off-by: Michael Neuling <mikey@neuling.org>
2006-06-07 09:42:15 -05:00
David Gibson
712e52e438 Use names for output functions in the form dt_to_*() instead of
write_dt_*() for consistency with the dt_from_*() input functions.
2005-10-26 16:56:26 +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
fc14dad769 Initial commit 2005-06-08 17:18:34 +10:00