aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-03-29Clean up LDLIBS handlingDavid Gibson1-2/+2
We currently set LDLIBS to include libyaml globally if we're using it. However only dtc itself actually needs to link with libyaml - the other tool binaries don't. Avoid that unnecessary inclusion by making LDLIBS handling per-target. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-29Rebuild libfdt shared object if versioning linker script changesDavid Gibson1-5/+5
The usable content of the shared library varies depending on the symbol versions given in the version.lds linker script, however it's not currently in the make dependencies. Correct that, and move the libfdt rules together for consistency while we're at it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-29Use Python3 by defaultDavid Gibson2-2/+2
Python2 is deprecated upstream, lets try to move forwards. Along with it generalize the .gitignore file so we ignore the .pyc files in the new location that Python3 uses. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-29libfdt: Make fdt_get_max_phandle() an inlineDavid Gibson3-14/+11
It's now a trivial wrapper around fdt_find_max_phandle() so we might as well inline it. We also remove it from the versioning linker script. Theoretically, that's a breaking ABI change except that we haven't yet released a version with it exposed in the shared object, so we can get away with it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-29libfdt: Add phandle generation helperThierry Reding8-3/+99
The new fdt_generate_phandle() function can be used to generate a new, unused phandle given a specific device tree blob. The implementation is somewhat naive in that it simply walks the entire device tree to find the highest phandle value and then returns a phandle value one higher than that. A more clever implementation might try to find holes in the current set of phandle values and fill them. But this implementation is relatively simple and works reliably. Also add a test that validates that phandles generated by this new API are indeed unique. Signed-off-by: Thierry Reding <treding@nvidia.com> Message-Id: <20190326153302.17109-3-thierry.reding@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-29libfdt: Use fdt_find_max_phandle()Thierry Reding1-1/+5
Use the fdt_find_max_phandle() function instead of the deprecated fdt_get_max_phandle() function. Signed-off-by: Thierry Reding <treding@nvidia.com> Message-Id: <20190326153302.17109-2-thierry.reding@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-29libfdt: Add new maximum phandle lookup functionThierry Reding5-15/+56
The fdt_get_max_phandle() function has some shortcomings. On one hand it returns just a uint32_t which means to check for the "negative" error code a caller has to explicitly check against the error code (uint32_t)-1. In addition, the -1 is the only error code that can be returned, so a caller cannot tell the difference between the various failures. Fix this by adding a new fdt_find_max_phandle() function that returns an error code on failure and 0 on success, just like other APIs, and stores the maximum phandle value in an output argument on success. This also refactors fdt_get_max_phandle() to use the new function. Add a note pointing out that the new fdt_find_max_phandle() function should be preferred over fdt_get_max_phandle(). Signed-off-by: Thierry Reding <treding@nvidia.com> Message-Id: <20190326153302.17109-1-thierry.reding@gmail.com> [dwg: Reword for some inaccuracies in the commit message] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-29libfdt: add fdt_append_addrrange()AKASHI Takahiro9-0/+290
This function will append an address range property using parent node's "#address-cells" and "#size-cells" properties. It will be used in implementing kdump with kexec_file_load system call at linux kernel for arm64 once it is merged into kernel tree. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Message-Id: <20190327061552.17170-2-takahiro.akashi@linaro.org> [dwg: Correct a SEGV error in the testcase] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-27checks: Do not omit nodes with labels if symbol generation is requestedChen-Yu Tsai1-0/+2
Commit 4038fd90056e ("dtc: add ability to make nodes conditional on them being referenced") added the new /omit-if-no-ref/ directive to mark nodes as eligible to be discarded if not referenced. The mechanism to process this happens before the symbol generation phase. This means even if symbol generation is requested and the node has a label, it will be discarded if there are no references to it within the same file. This is probably not what people expect. When using symbol generation to compile base device trees for applying overlays, nodes with labels could be referenced by the overlays, and therefore should be preserved. Check if the node has a label and symbol generation was requested before dropping the node. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Message-Id: <20190327035352.24036-1-wens@csie.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-25Update version.lds againDavid Gibson1-0/+4
Yet again, we've added several functions to libfdt that were supposed to be exported, but forgotten to add them to the versio.lds script. This adds them. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-25Revert "libfdt: Add phandle generation helper"David Gibson9-114/+3
This reverts commit 54ea41c22415cb0e283d22faf71202051c89400c. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-21libfdt: Add phandle generation helperThierry Reding9-3/+114
The new fdt_generate_phandle() function can be used to generate a new, unused phandle given a specific device tree blob. The implementation is somewhat naive in that it simply walks the entire device tree to find the highest phandle value and then returns a phandle value one higher than that. A more clever implementation might try to find holes in the current set of phandle values and fill them. But this implementation is relatively simple and works reliably. Also add a test that validates that phandles generated by this new API are indeed unique. Signed-off-by: Thierry Reding <treding@nvidia.com> Message-Id: <20190320151003.28941-1-thierry.reding@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-12checks: Fix spelling in check_graph_endpointLeonard Crestez1-1/+1
Should be "endpoint" rather than "endpont" Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com> Message-Id: <6fcb6e160163467b706c312ffe307ee8a5d9255d.1552328099.git.leonard.crestez@nxp.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06Bump version to v1.5.0v1.5.0David Gibson1-2/+2
We've accumulated several new features as well as a number of bugfixes, so prepare for another release. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-02-19pylibfdt:tests: Extend the way how to find a Python moduleLumir Balhar1-1/+1
Python 3 C extensions have suffix containing platform, Python version and another details in the name so the condition has to be extended. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Message-Id: <20190218164856.23861-5-frenzy@frenzy.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-02-19pylibfdt: Change how passing tests are recognizedLumir Balhar1-1/+1
When some warning appears in test result, "ok" is still at the end of the line but without three dots. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Message-Id: <20190218164856.23861-4-frenzy@frenzy.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-02-19pylibfdt: Test fdt.setprop take bytes on Python 3, add error handlingPetr Viktorin2-5/+11
Signed-off-by: Petr Viktorin <pviktori@redhat.com> Message-Id: <20190218164856.23861-3-frenzy@frenzy.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-02-19pylibfdt: check_err accepts only integer as a first argument.Lumir Balhar1-1/+1
A list passed as an argument to check_err() means that there is no error code to check and therefore it should be returned back. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Message-Id: <20190218164856.23861-2-frenzy@frenzy.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-02-19pylibfdt: Proper handling of bytes/unicode strings and octal literalsLumir Balhar2-13/+21
Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Message-Id: <20190218164856.23861-1-frenzy@frenzy.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-01-02Use PRIxPTR for printing uintptr_t valuesAndreas Schwab1-3/+3
Fixes: 49903aed77 ("use ptrdiff_t modifier for printing pointer differences") Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
2018-12-23libfdt: Fix FDT_ERR_NOTFOUND typos in documentationGeert Uytterhoeven1-2/+2
The actual error is FDT_ERR_NOTFOUND, not FDT_ERR_NOT_FOUND. Fixes: d29126c90acb0d70 ("libfdt: Add iterator over properties") Fixes: 902d0f0953d0074b ("libfdt: Add a subnodes iterator macro") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-12-22libfdt: Fix fdt_getprop_by_offset() parameter name in documentationGeert Uytterhoeven1-1/+1
The second parameter of fdt_getprop_by_offset() is called "offset", not "ffset". Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-12-15checks: Add unit address check if node is enabledKumar Gala1-2/+39
There are various SoCs that have 2 different peripheral blocks at the same register offset. However, we might have one block marked as status = "disabled" and the other status = "ok". In such cases we shouldn't warn about duplicate unit-address. Here's a cut down example that we would warning about before: /dts-v1/; / { #address-cells = <0x01>; #size-cells = <0x01>; soc { #address-cells = <0x01>; #size-cells = <0x01>; compatible = "simple-bus"; ranges; i2c0: i2c@40003000 { compatible = "nordic,nrf-i2c"; reg = <0x40003000 0x1000>; status = "ok"; }; spi0: spi@40003000 { compatible = "nordic,nrf-spi"; reg = <0x40003000 0x1000>; status = "disabled"; }; }; }; We introduce 'unique_unit_address_if_enabled' check that is disabled by default. Signed-off-by: Kumar Gala <kumar.gala@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-28checks: Fix crash with multiple source annotationsRob Herring1-1/+1
Commit 3616b9a811b6 ("checks: Use source position information for check failures") causes crashes when there's a check message with multiple source annotations. Drop the errant addition to the str pointer left over from the previous version. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-25checks: Use source position information for check failuresRob Herring1-3/+32
Now that we retain source position information of nodes and properties, make that the preferred file name (and position) to print out in check failures. This will greatly simplify finding and fixing check errors because most errors are in included source .dtsi files and they get duplicated every time the source file is included. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-25checks: Make each message output atomicRob Herring1-6/+11
Printing to stderr as we build up the check message results in interleaving of messages when multiple instances of dtc are running. Change the message output to use an intermediate buffer for constructing the message and then output the message to stderr with a single fputs. While perhaps there is no guarantee that fputs will be atomic, this gets rid of any interleaved output that previously occurred on Linux. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-25util: Add xa{v}sprintf_append functionsRob Herring2-21/+41
Add variadic and va_list functions, xa{v}sprintf, which appends a formatted string to an existing string and re-allocate the string buffer if necessary. xasprintf becomes just a special case of xasprintf_append with a NULL starting string. Rather than looping to get a big enough buffer, simply the implementation by assuming we have a C99 compliant vsnprintf implementation to return the necessary size. A side effect is glibc 2.0 support is dropped which seems unnecessary. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-24libfdt: Add a test for fdt_getprop_by_offset()Simon Glass6-1/+94
This function does not have its own test at present. Add one. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23PEP8 / Flake8 cleanups for setup.pyDavid Gibson1-6/+7
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23Remove broken objdir / srcdir supportDavid Gibson3-21/+19
The dtc makefiles have support for building into a separate directory from the sources... except that it's broken and probably always has been. Remove the pretense. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23pylibfdt: Use common PREFIX variableDavid Gibson1-1/+1
For no particularly good reason, the install target for the Python library uses a different PREFIX variable to give the installation destination to the rest of dtc & libfdt. Make it use the same one. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23Refine make tests_clean targetDavid Gibson2-4/+4
Remove some redundancy, and also clean up *.test.dt.yaml files generated during the tests. Also add the latter to gitignore. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23Refine pylibfdt_clean targetDavid Gibson2-5/+8
Move it to the subdir Makefile, generalize some of the patterns, remove the 'build' directory made by setup.py and __pycache__ directory made by Python3. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23Refine libfdt_clean targetDavid Gibson2-5/+4
Move it to the libfdt Makefile piece, use neater make syntax, and remove redundant command (already included in STD_CLEANFILES). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23tests: Use modern octal literals for PythonDavid Gibson1-2/+2
Python3 removes support for C-style octal literals, using 0oXXXX instead. Python2 also supports this form, so move to the new style. Reported-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23pylibfdt: Allow switch to Python 3 via environment variable PYTHONLumir Balhar4-7/+8
Python 2 is still the default but it can be changed by setting environment variable PYTHON before build/test. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-22libfdt: Don't use memcpy to handle unaligned reads on ARMDavid Gibson1-7/+15
6dcb8ba4 "libfdt: Add helpers for accessing unaligned words" introduced the fdt32_ld() and fdt64_ld() helpers for loading values from the FDT blob which might not be naturally aligned. This matters for ARM, where attempting a plain unaligned load will often cause an exception. However, it seems the memcpy() we used here was surprisingly expensive, making libfdt nearly 6x slower on at least some ARM platforms. This patch takes an alternative approach, using a bunch of 1-byte loads and shifts to implement the helpers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-22checks: Restructure check_msg to decrease indentationRob Herring1-14/+14
The entire check_msg function is under the if condition except for va_start/va_end. Move these and invert the if condition saving a level of indentation. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-19annotations: add the annotation functionalityJulia Lawall5-10/+170
Provide the new command-line option: --annotate (abbreviated -T) --annotate provides one or more filenames and line numbers indicating the origin of a given line. The filename is expressed relative the the filename provided on the command line. Nothing is printed for overlays, etc. -T can be repeated giving more verbose annotations. These consist of one or more tuples of: filename, starting line, starting column, ending line ending column. The full path is given for the file name. Overlays, etc are annotated with <no-file>:<no-line>. The verbose annotations may be too verbose for normal use. There are numerous changes in srcpos.c to provide the relative filenames (variables initial_path, initial_pathlen and initial_cpp, new functions set_initial_path and shorten_to_initial_path, and changes in srcfile_push and srcpos_set_line). The change in srcpos_set_line takes care of the case where cpp is used as a preprocessor. In that case the initial file name is not the one provided on the command line but the one found at the beginnning of the cpp output. shorten_to_initial_path only returns a string if it has some shortening to do. Otherwise it returns NULL and relies on the caller to use the initial string. This simplifies memory management, by making clear to the caller whether a new string is allocated. The new functions srcpos_string_comment, srcpos_string_first, and srcpos_string_last print the annotations. srcpos_string_comment is recursive to print a list of source file positions. Various changes are sprinkled throughout treesource.c to print the annotations. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-19annotations: add positionsJulia Lawall7-23/+68
Extend the parser to record positions, in build_node, build_node_delete, and build_property. srcpos structures are added to the property and node types, and to the parameter lists of the above functions that construct these types. Nodes and properties that are created by the compiler rather than from parsing source code have NULL as the srcpos value. merge_nodes, defined in livetree.c, uses srcpos_extend to combine multiple positions, resulting in a list of positions. srcpos_extend is defined in srcpos.c. New elements are added at the end. This requires the srcpos type, define in srcpos.h, to be a list structure with a next field. This next field is initialized to NULL in srcpos.h, in the macro YYLLOC_DEFAULT invoked implicitly by the generated parser code. Another change to srcpos.c is to make srcpos_copy always do a full copy, including a copy of the file substructure. This is required because when dtc is used on the output of cpp, the successive detected file names overwrite the file name in the file structure. The next field does not need to be deep copied, because it is always NULL when srcpos_copy is called; an assert checks for this. File names are only updated in uncopied position structures. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-14tests: Don't lose errors from make checkmDavid Gibson1-1/+1
For unclear reasons we had some code to copy a transcript of "make checkm" runs to a vglog.XXX file. It's not really clear why this was there, and it had the nasty side effect of discarding errors from run_tests.sh, meaning that an error on the valgrind run wouldn't show up clearly in Travis CI builds. Remove that logic so that we see errors more clearly. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-14tests: Property count valgrind errors in wrapped testsDavid Gibson1-0/+3
The logic in wrap_test() was effectively squashing valgrind errors into the "FAIL" bucket rather than their own bucket as intended. Correct it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-14srcpos: Remove srcpos_emptyDavid Gibson2-19/+0
Nothing was actually using it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-14Revert "annotations: add positions"David Gibson7-67/+23
This reverts commit baa1d2cf7894a32bf2f640ef40ebce561b2df565. Turns out this introduced memory badness. valgrind picks it up on x86, but it straight out SEGVs on x86. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-14checks: Update SPI bus check for 'spi-slave'Kumar Gala1-1/+7
If the SPI bus controller is being used for 'spi-slave' mode some of the checks we have need to change: In 'spi-slave' mode #address-cells should be 0, as any children don't have a reg property. Signed-off-by: Kumar Gala <kumar.gala@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-13annotations: add positionsJulia Lawall7-23/+67
Extend the parser to record positions, in build_node, build_node_delete, and build_property. srcpos structures are added to the property and node types, and to the parameter lists of the above functions that construct these types. Nodes and properties that are created by the compiler rather than from parsing source code have NULL as the srcpos value. merge_nodes, defined in livetree.c, uses srcpos_extend to combine multiple positions, resulting in a list of positions. srcpos_extend is defined in srcpos.c. New elements are added at the end. The srcpos type, define in srcpos.h, is now a list structure with a next field. Another change to srcpos.c is to make srcpos_copy always do a full copy, including a copy of the file substructure. This is required because when dtc is used on the output of cpp, the successive detected file names overwrite the file name in the file structure. The next field does not need to be deep copied, because it is only updated in newly copied positions and the positions to which it points have also been copied. File names are only updated in uncopied position structures. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-07Merge remote-tracking branch 'origin/pr/18'David Gibson1-5/+5
2018-11-07libfdt: return correct value if #size-cells property is not presentJohn Clarke4-6/+16
According to the device tree specification, the default value for #size-cells is 1, but fdt_size_cells() was returning 2 if this property was not present. This patch also makes fdt_address_cells() and fdt_size_cells() conform to the behaviour documented in libfdt.h. The defaults are only returned if fdt_getprop() returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned. Signed-off-by: John Clarke <johnc@kirriwa.net>
2018-10-23use ptrdiff_t modifier for printing pointer differencesDan Horák1-5/+5
Use ptrdiff_t modifier (%tx) for printing a difference between 2 pointers. Currently %zx (size_t) is used, but it fails on platforms where size_t and ptrdiff_t are defined differently (like s390). Comes from https://src.fedoraproject.org/rpms/dtc/c/f3da2d1b00d01d83fef7001d5767baa3d5a6df87?branch=master originally. Signed-off-by: Dan Horák <dan@danny.cz>
2018-10-12treesource: Fix dts output for phandles in middle of a sequence of intsRob Herring1-3/+3
If we have a phandle in the middle of a sequence of numbers and it is not bracketed (e.g. <0x1234 &phandle 0x5678>), the dts output will be corrupted due to missing a space between the phandle value and the following number. Fixes: 8c59a97ce096 ("Fix missing labels when emitting dts format") Cc: Grant Likely <grant.likely@arm.com> Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>