aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2017-03-27.travis.yml: Add builds with and without Python library prerequisitesDavid Gibson1-0/+11
To make sure the Makefile behaves in both cases, make Travis matrix builds with and without swig installed. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-27pylibfdt: Use package_dir to set the package directorySimon Glass2-2/+4
At present we manually move _libfdt.so into the correct place. Provide a package directory so we can avoid needing to do this. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-27pylibfdt: Use environment to pass C flags and filesSimon Glass2-11/+8
At present setup.py adjusts its command line when running, so that the C flags and file list can be passed as arguments. Pass them in environment variables instead, so we can avoid this messiness. It also allows us to support the 'install' command. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-27pylibfdt: Allow pkg-config to be supplied in the environmentSimon Glass1-1/+2
Some build systems have their own version of the pkg-config tool. Use a variable for this instead of hard-coding it, to allow for this. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Mike Frysinger <vapier@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-22Correct typo: s/pylibgfdt/pylibfdt/David Gibson1-1/+1
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-21Build pylibfdt as part of the normal build processSimon Glass2-2/+60
If swig and the Python are available, build pylibfdt automatically. Adjust the tests to run Python tests too in this case. Signed-off-by: Simon Glass <sjg@chromium.org> [dwg: Make error message clearer that missing swig or python-dev isn't fatal to the whole build] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-21Adjust libfdt.h to work with swigSimon Glass1-1/+20
There are a few places where libfdt.h cannot be used as is with swig: - macros like fdt_totalsize() have to be defined as C declarations - fdt_offset_ptr() and fdt_getprop_namelen() need special treatment due to a TODO in the wrapper for fdt_getprop(). However they are not useful to Python so can be removed Add #ifdefs to work around these problem. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-21Mention pylibfdt in the documentationSimon Glass1-0/+47
Add a note about pylibfdt in the README. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-21Add tests for pylibfdtSimon Glass1-0/+288
Add a set of tests to cover the functionality in pylibfdt. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-21Add an initial Python library for libfdtSimon Glass5-0/+488
Add Python bindings for a bare-bones set of libfdt functions. These allow navigating the tree and reading node names and properties. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-21checks: Warn on node name unit-addresses with '0x' or leading 0sRob Herring4-0/+51
Node name unit-addresses should generally never begin with 0x or leading 0s. Add warnings to check for these cases, but only for nodes without a known bus type as there should be better bus specific checks of the unit address in those cases. Any unit addresses that don't follow the general rule will need to add a new bus type. There aren't any known ones ATM. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-21checks: Add bus checks for simple-bus busesRob Herring1-0/+70
Add checks to identify simple-bus bus types and checks for child devices. Simple-bus type is generally identified by "simple-bus" compatible string. We also treat the root as a simple-bus, but only for child nodes with reg property. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-21checks: Add bus checks for PCI busesRob Herring2-0/+141
Add PCI bridge and device node checks. We identify PCI bridges with 'device_type = "pci"' as only PCI bridges should set that property. For bridges, check that node name is pci or pcie, ranges and bus-range are present, and #address-cells and #size-cells are correct. For devices, check the reg property fields are correct for the first element (the config address). Check that the unit address is formatted corectly based on the reg property. Device unit addresses are in the form DD or DD,F where DD is the device 0-0x1f and F is the function 0-7. Also, check that the bus number is within the expected range defined by bridge's bus-ranges. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Rob Herring <robh@kernel.org> [dwg: Added a missing check dependency] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-10dtc: Bump version to v1.4.4v1.4.4David Gibson1-1/+1
Preparing for yet another release, due to a build bug in v1.4.3. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06fdtput: Remove star from value_len documentationNicolas Iooss1-1/+1
When clang checks the documentation tags (with -Wdocumentation flag), it reports the following warning: fdtput.c:70:11: error: parameter '*value_len' not found in the function declaration [-Werror,-Wdocumentation] * @param *value_len Returns length of value encoded ^~~~~~~~~~ fdtput.c:70:11: note: did you mean 'value_len'? * @param *value_len Returns length of value encoded ^~~~~~~~~~ value_len As this sounds reasonable, remove the star from the documentation tag. Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06fdtget: Use @return to document the return valueNicolas Iooss1-1/+1
Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06tests: Make realloc_fdt() really allocate *fdtNicolas Iooss1-2/+2
This bug has been found by using clang Static Analyzer: it reported that the value stored to fdt was never read. Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06libfdt: overlay: Check the value of the right variableNicolas Iooss1-1/+1
overlay_update_local_node_references() saves the result of fdt_subnode_offset() into variable tree_child but checks for variable ret afterwards. As this does not make sense, check tree_child instead of ret. This bug has been found by compiling with clang. The compiler reported the following warning: libfdt/fdt_overlay.c:275:7: error: variable 'ret' may be uninitialized when used here [-Werror,-Wconditional-uninitialized] if (ret == -FDT_ERR_NOTFOUND) ^~~ libfdt/fdt_overlay.c:210:9: note: initialize the variable 'ret' to silence this warning int ret; ^ = 0 Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06dtc: Simplify asm_emit_string() implementationNicolas Iooss1-15/+7
Using %.*s format helps making asm_emit_string() not modify its "str" parameter. While at it, constify the "str" parameter of bin_emit_string() and asm_emit_string(), as these function no longer modify it. Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06libfdt: Change names of sparse helper macrosDavid Gibson1-13/+13
The default libfdt_env.h (for POSIXish userland builds) supports sparse checking. It has a couple of helper macros, __force and __bitwise which expand the relevant sparse attributes to enable checking for incorrect or missing endian conversions. Those are bad names: for one, leading underscores are supposed to be reserved for the system libraries, and worse, some systems (including RHEL7) do define those names already. So change them to FDT_FORCE and FDT_BITWISE which are far less likely to have collisions. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06Fix assorted sparse warningsDavid Gibson25-67/+71
This fixes a great many sparse warnings on the fdt and libfdt sources. These are mostly due to incorrect mixing of endian annotated and native integer types. This includes fixing a couple of quasi-bugs where we had endian conversions the wrong way around (this will have the right effect in practice, but is certainly conceptually incorrect). This doesn't make the whole tree sparse clean: there are many warnings in bison and lex generated code, and there are a handful of other remaining warnings that are (for now) more trouble than they're worth to fix (and are not genuine bugs). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06Clean up gcc attributesDavid Gibson5-35/+22
We have a number of explicit __GNUC__ conditionals to tell if we want to use some gcc extensions for extra warnings. This cleans this up to use a single conditional, defining convenience macros for those attributes. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06dtc: Don't abuse struct fdt_reserve_entryDavid Gibson5-22/+21
struct fdt_reserve_entry is defined in fdt.h to exactly mirror the in-memory layout of a reserve entry in the flattened tree. Since that is always big-endian, it uses fdt64_t elements, which have sparse annotations marking them as not native endian. However, in dtc, we also use struct fdt_reserve_entry inside struct reserve_info, and use it with native endian values. This will cause sparse errors. This stops this abuse, making struct reserve_info have its own native endian fields for the same information. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-28dtc: Bump version to v1.4.3v1.4.3David Gibson1-1/+1
Preparing for new release. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-28Add printf format attributesDavid Gibson2-1/+19
When compiling with gcc, we already include the attribute on check_msg() to give compiler warnings about mismatches between printf() like format strings and the corresponding arguments. This patch adds similar attributes for lexical_error() and die(). Suggested-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-28Correct some broken printf() like format mismatchesDavid Gibson2-2/+2
Fix two places where a printf()-style format string does not match the arguments passed. Reported-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-24libfdt: Add fdt_setprop_empty()David Gibson2-1/+31
Device trees can contain empty (zero length) properties, which are often used as boolean flags. These can already be created using fdt_setprop() passing a length of zero and a pointer which is ignored. It is safe to pass NULL, but that may not be obvious from the interface. To make it clearer, add an fdt_setprop_empty() helper macro. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-24libfdt: Remove undefined behaviour setting empty propertiesDavid Gibson1-1/+2
The standard way of setting an empty property using libfdt is: fdt_setprop(fdt, nodeoffset, propname, NULL, 0); However, the implementation of this includes an unconditional: memcpy(prop->data, NULL, 0); Which although it will be a no-op (which is what we want) on many platforms is technically undefined behaviour. Correct this, so that when passing a 0 length, passing a NULL pointer as the value to fdt_setprop() is definitely safe. This should quiet static checkers which complain about this. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-23Print output filename as part of warning messagesIan Campbell3-40/+46
For example: src/arm/at91-ariag25.dtb: Warning (unit_address_vs_reg): Node /memory has a reg or ranges property, but no unit name If output is to stdout then the prefix is "<stdout>: ". This helps to direct the developer to where to look when multiple files are being compiled in parallel. Signed-off-by: Ian Campbell <ijc@hellion.org.uk> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-13dtc: Use streq() in preference to strcmp()David Gibson2-3/+3
dtc defines a streq() (string equality) macro to avoid the easy confusion of the sense of strcmp() comparison for equality. A few places where we don't use it have slipped in, so remove them. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-13checks: Add Warning for stricter node name character checkingRob Herring1-0/+12
While '#', '?', '.', '+', '*', and '_' are considered valid characters, their use is discouraged in recommended practices. Testing this found a few cases of '.'. The majority of the warnings were all from underscores. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-13checks: Add Warning for stricter property name character checkingRob Herring1-0/+35
While '?', '.', '+', '*', and '_' are considered valid characters their use is discouraged in recommended practices. '#' is also only recommended to be used at the beginning of property names. Testing this found one typo error with '.' used instead of ','. The rest of the warnings were all from underscores. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-08dtc: pos parameter to srcpos_string() can't be NULLDavid Gibson1-1/+1
None of the callers ever pass a NULL to srcpos_string(), so the check for it is not necessary. Furthermore, checking it make Coverity complain about the raw dereferences which follow later in the function. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-08livetree.c: Fix memory leakJean-Christophe Dubois1-0/+2
When running coverity on dtc source code the following error is reported. ========================================================================== *** CID 1370967: Resource leaks (RESOURCE_LEAK) /tools/dtc/livetree.c: 850 in add_fixup_entry() 844 if (strchr(node->fullpath, ':') || strchr(prop->name, ':')) 845 die("arguments should not contain ':'\n"); 846 847 xasprintf(&entry, "%s:%s:%u", 848 node->fullpath, prop->name, m->offset); 849 append_to_property(fn, m->ref, entry, strlen(entry) + 1); >>> CID 1370967: Resource leaks (RESOURCE_LEAK) >>> Variable "entry" going out of scope leaks the storage it points to. 850 } ========================================================================== Fix the leak. Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-01-31dtc: Fix NULL pointer use in dtlabel + dtref caseStephen Boyd3-3/+13
If we have a construct like this: label: &handle { ... }; Running dtc on it will cause a segfault, because we use 'target' when it could be NULL. Move the add_label() call into the if statement to fix this potentially bad use of a NULL pointer. Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-01-30manual: Fix typo it -> inStephen Boyd1-1/+1
Two its in a row can't be right. Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-01-30Makefile: Add tags ruleStephen Boyd1-0/+6
It's useful to have some tags to jump around sources. We don't include test sources in the toplevel Makefile because they probably aren't useful to main program development. Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-27dtc: fdtdump: check fdt if not in scanning modeHeinrich Schuchardt1-8/+19
Running fdtdump without scan mode for an invalid file often results in a segmentation fault because the fdt header is not checked. With the patch the header is checked both in scanning as well as in non-scanning mode. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> [dwg: Removed unnecessary inline, changed type from int to bool] Reviewed-by: Simon Glass <sjg@chromium.org>
2016-12-12dtc: Fix memory leak in character literal parsingGabriel Smith1-8/+8
The data struct used for parsing character literals was never freed resulting in a few bytes leaked for every character. Signed-off-by: Gabriel Smith <ga29smith@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09Rename boot_infoDavid Gibson8-148/+147
struct boot_info is named that for historical reasons, and isn't particularly meaningful. Essentially it contains all the information - in "live" form from a single dts or dtb file. As we move towards support for dynamic dt overlays, that name will become increasingly bad. So, in preparation, rename it to dt_info. At the same time rename the 'the_boot_info' global to 'parser_output' since that's its actual purpose. Unfortunately we do need the global unless we switch to bison's re-entrant parser extensions, which would introduce its own complications. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09dtc: Clean up /dts-v1/ and /plugin/ handling in grammarDavid Gibson1-18/+17
First remove the non-terminal name 'versioninfo' - /plugin/ doesn't really indicate a "version" per se, and version could be confused with the dtb output version. Second allow the /dts-v1/; /plugin/; sequence to be repeated, for easier use of include files - but ensure that all copies match, so you can't include a file declaring /plugin/ in one that doesn't, or vice versa. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09dtc: Don't always generate __symbols__ for pluginsDavid Gibson2-9/+2
At the moment we generate a __symbols__ node if -@ is specified OR if the dts has the /plugin/ tag. That difference in behaviour from handling base trees is unnecessary and slightly confusing. It also means it's impossible to create a plugin without symbols. Since symbols in a plugin are only useful in the case of stacked plugins - and libfdt doesn't even support merging plugin symbols as part of overlay application yet - that's a thing that might be useful. So make __symbols__ generation depend only on -@. We also remove remove the testcases that checked explicitly for this not very useful behaviour. Instead we don't use -@ for our basic overlay testcase, and check that symbols are not generated. At some point in the future we should add support for symbol merging to libfdt and add testcases for stacked overlay application. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09tests: Don't use -@ on plugin de/recompile testsDavid Gibson1-2/+2
Using -@ again here obscures what's going on, because at the end we can't know which run actually generated the symbols node. We should just generate the symbols on the first run and leave it at that. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09tests: Remove "suppression of fixups" testsDavid Gibson2-28/+0
I think these were for an additional command line option which got dropped during development. At this point all they're testing is that fixups don't get generated for a non /plugin/ tree, which is already tested with one of the simpler cases previously. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09tests: Clarify dtc overlay testsDavid Gibson2-11/+14
This changes the names of the testfiles for a number of the testcases of the dtc overlay generation functionality to make them shorter and a bit cleaerer what's going on. In addition we move some of the check_path sanity checks closer to the dtc commands they verify. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09tests: More thorough tests of libfdt overlay application without dtcDavid Gibson4-2/+161
At the moment we have some rudimentary tests of the fdt_overlay_apply() function which don't rely on overlay generation support in dtc. This is done by avoiding any external references in the sample overlay, in particularly using the 'target-path' syntax instead of 'target' to avoid needing external references in the fragment targets. Thus this test case doesn't exercise libfdt's processing of the __fixups__ node at all. We do test that somewhat in combination with dtc's overlay support. However, in the interests of being able to quickly determine which side a bug is on, it would be nice to exercise this without requiring the dtc support. This adds testcases to do so, by making some examples with manually constructed __symbols__ and __fixups__ nodes. In addition we rename some of the test data files and add some extra check_path tests to make it a bit clearer what's going on here. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09tests: Correct fdt handling of overlays without fixups and base trees ↵David Gibson1-1/+6
without symbols The fdt_overlay_apply() function purports to support the edge cases where an overlay has no fixups to be applied, or a base tree which has no symbols (the latter can only work if the former is also true). However it gets it wrong in a couple of small ways: * In the no fixups case, it doesn't fail immediately, but will attempt fdt_for_each_property_offset() giving -FDT_ERR_NOTFOUND as the node offset, which will fail. Instead it should succeed immediately, since there's nothing to do. * In the case of no symbols, it again doesn't fail immediately. However if there is an actual fixup it will fail with an unexpected error, because -FDT_ERR_NOTFOUND is passed to fdt_getprop() when attempting to look up the symbols. We should instead return -FDT_ERR_NOTFOUND directly. Both of these errors lead to the code returning misleading error codes in failing cases. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09tests: Fix double expansion bugs in test codeDavid Gibson2-4/+6
Two test programs - check_path and overlay - define a CHECK() helper macro in such a way that in the case of an error it will re-execute the checked code fragment, instead of using the return value from the initial call. This can lead to misreporting errors, because the code may fail in a different way the second time around due to changes made during the first failing call. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09tests: Split overlay tests into those with do/don't exercise dtc plugin ↵David Gibson1-10/+16
generation The various tests for overlay/plugin support are currently lumped together in the overlay_tests shell function, which is executed by libfdt_tests. However, this includes both tests designed primarily to exercise libfdt's overlay application, and tests designed to exercise dtc's overlay generation. Split these up for improved clarity. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09tests: Test auto-alias generation on base tree, not overlayDavid Gibson1-5/+5
The current testcases for the -A "auto alias generation" option operate on a "plugin" tree. Although not technically wrong, this is an odd approach, since a plugin will almost certainly need the __symbols__ and/or __fixups__ syntax instead of aliases. On the other hand -A may be useful simply for generating aliases on a tree which is not using the overlay / plugin mechanism at all. Therefore change the tests to operate on a base tree example instead of a plugin. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>