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>
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>
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>
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).
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>
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>
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>
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>
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>
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>
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>
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: 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>
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>
This patch moves the dtc code for checking the device tree its
processing into a new checks.c. The tree accessor functions from
livetree.c which the checks use are exported and added to dtc.h.
Another small step towards a flexible checking architecture.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
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>
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>
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>
It is not an error for /chosen (or any of its children) to be missing.
It is not a requirement that the output of dtc be a complete, valid
device tree, as it may be intended that the dtb be passed through boot
code that will complete it. Thus, do not complain.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
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>
Remove warning for missing interrupt-controller property
under /chosen. There is consensus that this
property does not belong here.
Also, add a warning if interrupt-controller _is_ found
under /chosen.
Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
Signed-off-by: Jon Loeliger <jdl@freescale.com>
dtc allows nodes to have labels, which at present are just re-emitted
as symbols at the appropriate places when using asm-mode output. It
also allows "references" where the notation &/path/to/node in a cell
list will be replaced with the phandle of the referenced node.
This patch extends the reference syntax to allow references to labels
instead of just full device paths. This allows nodes deep within the
tree to be referenced with a shorter more convenient name. References
to labels are distinguished from reference to paths by the fact that
paths must start with a /, but labels can never start with a /.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Jon Loeliger <jdl@freescale.com>
At present, the tree checking code in dtc will die with an assertion
failure if given a tree which has the invalid value 0 or -1 in a
property which should contain a phandle. This patch fixes the check
to die more gracefully with an error message indicating the invalid
phandle value.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
The linux,platform property in /chosen was obsolete almost as soon as
it was invented. Remove the check for it from dtc, which just tends
to lead to irritating spurious failures.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
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>