summaryrefslogtreecommitdiff
path: root/checks.c
Commit message (Collapse)AuthorAgeFilesLines
* dtc: Add ability to delete nodes and propertiesStephen Warren2012-09-061-2/+6
| | | | | | | | | | | | | | | | | | | 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>
* Allow toggling of semantic checksDavid Gibson2012-07-081-3/+81
| | | | | | | This patch adds -W and -E options to dtc which allow toggling on and off of the various built in semantic checks on the tree. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Re-work level setting on checks codeDavid Gibson2012-07-081-55/+62
| | | | | | | | | | | | | Currently each of the semantic checks in checks.c has a "level" between IGNORE and ERROR. This single level makes it awkward to implement the semantics we want for toggling the checks on the command line. This patch reworks the code to instead have separate boolean flags for warning and error. At present having both flags set will have the same effect as having just the error flag set, but this can change in the future. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Allow multiple labels on nodes and propertiesDavid Gibson2010-02-241-4/+7
| | | | | | | | | | | | | | | | | 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>
* Disallow re-use of the same label within a dts fileDavid Gibson2010-02-231-0/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, nothing will stop you from re-using the same label string multiple times in a dts, e.g.: / { samelabel: prop1 = "foo"; samelabel: prop2 = "bar"; }; or / { samelabel: prop1 = "foo"; samelabel: subnode { }; }; When using node references by label, this could lead to confusing results (with no warning), and in -Oasm mode will result in output which the assembler will complain about (since it too will have duplicate labels). This patch, therefore, adds code to checks.c to give errors if you attempt to re-use the same label. It treats all labels (node, property, and value) as residing in the same namespace, since the assembler will treat them so for -Oasm mode. Testcases for the new code are also added. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Support ePAPR compliant phandle propertiesDavid Gibson2009-11-261-14/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the Linux kernel, libfdt and dtc, when using flattened device trees encode a node's phandle into a property named "linux,phandle". The ePAPR specification, however - aiming as it is to not be a Linux specific spec - requires that phandles be encoded in a property named simply "phandle". This patch adds support for this newer approach to dtc and libfdt. Specifically: - fdt_get_phandle() will now return the correct phandle if it is supplied in either of these properties - fdt_node_offset_by_phandle() will correctly find a node with the given phandle encoded in either property. - By default, when auto-generating phandles, dtc will encode it into both properties for maximum compatibility. A new -H option allows either only old-style or only new-style properties to be generated. - If phandle properties are explicitly supplied in the dts file, dtc will not auto-generate ones in the alternate format. - If both properties are supplied, dtc will check that they have the same value. - Some existing testcases are updated to use a mix of old and new-style phandles, partially testing the changes. - A new phandle_format test further tests the libfdt support, and the -H option. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Handle linux,phandle properties which self-referenceDavid Gibson2008-11-171-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, dtc will generate phandles for nodes which are referenced elsewhere in the tree. phandles can also be explicitly assigned by defining the linux,phandle property. However, there is no way, currently to tell dtc to generate a phandle for a node if it is not referenced elsewhere. This is inconvenient when it's expected that later processing on the flat tree might add nodes which _will_ the node in question. One way one might attempt to do this is with the construct: mynode: mynode { linux,phandle = <&mynode>; /* ... */ }; Though it's a trifle odd, there's really only one sensible meaning which can be assigned to this construct: allocate a unique phandle to "mynode" and put that in its linux,phandle property (as always). Currently, however, dtc will choke on this self-reference. This patch corrects this, making the construct above give the expected results. It also ensures a more meaningful error message is given if you attempt to process the nonsensical construct: mynode: mynode { linux,phandle = <&someothernode>; /* ... */ }; The 'references' testcase is extended to cover this case, as well. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Run relevant checks on dtb input as well as dtsDavid Gibson2008-07-141-7/+9
| | | | | | | | | | | | | | | | | | | | | | This patch adjusts the testsuite to run most of the tests for the tree checking code on input in dtb form as well as dts form. Some checks which only make sense for dts input (like reference handling) are excluded, as are those which currently take dtb input because they rely on things which cannot be lexically constructed in a dts file. This shows up two small bugs in dtc, which are also corrected. First, the name_properties test which was is supposed to remove correctly formed 'name' properties (because they can be reconstructed from tne node name) was instead removing 'name' properties even if they weren't correct. Secondly, when using dtb or fs input, the runtime tree in dtc did not have the parent pointer initialized propertly because.built internally. The appropriate initialization is added to the add_child() function. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Use the same endian-conversion functions as libfdtDavid Gibson2008-07-141-1/+1
| | | | | | | | | | | | | | | | Currently both libfdt and dtc define a set of endian conversion macros for accessing the device tree blob which is always big-endian. libfdt uses names like cpu_to_fdt32() and dtc uses names like cpu_to_be32 (as the Linux kernel). This patch switches dtc over to using the libfdt macros (including libfdt_env.h to supply them). This has a couple of small advantages: - Removes some code duplication - Will make conversion a bit easier if we ever need to produce little-endian device tree blobs. - dtc no longer needs to pull in netinet/in.h simply for the ntohs() and ntohl() functions Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Strip redundant "name" propertiesDavid Gibson2008-03-231-2/+13
| | | | | | | | | | | 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>
* dtc: Fix indentation of fixup_phandle_referencesDavid Gibson2008-03-231-17/+17
| | | | | | | | 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>
* dtc: Implement checks for the format of node and property namesDavid Gibson2008-03-231-0/+37
| | | | | | | | | | | | | | | | 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>
* dtc: Remove remaining old-style checksDavid Gibson2007-12-181-214/+1
| | | | | | | | | | | | | | | | | 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>
* dtc: Allow gcc format warnings for check_msg()David Gibson2007-12-071-0/+3
| | | | | | | 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>
* dtc: Convert check for obsolete /chosen propertyDavid Gibson2007-12-071-22/+18
| | | | | | | | | 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>
* dtc: Convert #address-cells and #size-cells related checksDavid Gibson2007-12-071-50/+131
| | | | | | | | | | | | | | | | | 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).
* dtc: Remove obsolete check_properties() functionDavid Gibson2007-12-061-45/+3
| | | | | | | | | | | | | | 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>
* dtc: Migrate "string property" checks to new frameworkDavid Gibson2007-12-061-13/+5
| | | | | | | | 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>
* dtc: Migrate "one cell" checks to new frameworkDavid Gibson2007-12-061-14/+26
| | | | | | | | | | | | 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>
* dtc: Implement path referencesDavid Gibson2007-12-051-1/+26
| | | | | | | | | | | | 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: Convert "name" property checking to new infrastructureDavid Gibson2007-12-051-15/+39
| | | | | | | | | | | | | | | 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>
* dtc: Fix FAIL() macro varargsDavid Gibson2007-12-051-2/+2
| | | | | | | | 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>
* dtc: Fix uninitialized use of structure_okDavid Gibson2007-12-041-1/+15
| | | | | | | | | | 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>
* dtc: Merge refs and labels into single "markers" list (v2)David Gibson2007-11-261-12/+8
| | | | | | | | | | | | | | | | | | | | | 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 (v2)David Gibson2007-11-261-61/+250
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* dtc: Add testcases for tree checksDavid Gibson2007-11-201-1/+1
| | | | | | | | | | | | | | 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>
* dtc: Move tree checking code to checks.cDavid Gibson2007-11-011-0/+460
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>