pax_global_header00006660000000000000000000000064143711421770014521gustar00rootroot0000000000000052 comment=039a99414e778332d8f9c04cbd3072e1dcc62798 device-tree-compiler-1.7.0/000077500000000000000000000000001437114217700155325ustar00rootroot00000000000000device-tree-compiler-1.7.0/.cirrus.yml000066400000000000000000000006251437114217700176450ustar00rootroot00000000000000env: CIRRUS_CLONE_DEPTH: 1 freebsd_13_task: freebsd_instance: image: freebsd-13-0-release-amd64 install_script: pkg install -y bison gmake pkgconf build_script: gmake test_script: gmake check linux_gcc_task: container: image: gcc:latest install_script: - apt-get update - apt-get -y install bison flex build_script: - make test_script: - make check device-tree-compiler-1.7.0/.editorconfig000066400000000000000000000010621437114217700202060ustar00rootroot00000000000000# EditorConfig is a file format and collection of text editor plugins # for maintaining consistent coding styles between different editors # and IDEs. Most popular editors support this either natively or via # plugin. # # Check https://editorconfig.org for details. root = true [*] end_of_line = lf insert_final_newline = true charset = utf-8 indent_style = space [Makefile*] indent_style = tab indent_size = 8 file_type_emacs = makefile [*.[ch]] indent_style = tab indent_size = 8 [*.py] indent_size = 4 [meson.build] indent_style = space indent_size = 2 device-tree-compiler-1.7.0/.gitignore000066400000000000000000000003231437114217700175200ustar00rootroot00000000000000*.o *.d *.a *.patch *.so *~ *.bak *.tab.[ch] lex.yy.c *.lex.c .*.swp /dtc /fdtdump /convert-dtsv0 /version_gen.h /fdtget /fdtput /fdtoverlay /patches /.pc # cscope files cscope.* ncscope.* .eggs/ build/ dist/ device-tree-compiler-1.7.0/.travis.yml000066400000000000000000000026521437114217700176500ustar00rootroot00000000000000language: c # Coverity Scan uploads env: global: # COVERITY_SCAN_TOKEN (dgibson/dtc) - secure: "vlHvXe618//IM9LQaKzqsrUbjs7ng0L9UCST4kJbJnFQDXvVe5JiSmJGd4ef7mm0NUv5bMRl2W3xCiu6BYAu/NvU3tMNHoLG+JgCJs0+wLJXbWOwji/NmH7olqgJG+CmpaCMXjARF6+nrTnBYHJL6cYyf4KVoV4B0I/hLUW91+s=" matrix: include: - addons: apt: packages: - swig - python-dev - valgrind - libyaml-0-2 coverity_scan: project: name: dtc description: Device Tree Compiler notification_email: david@gibson.dropbear.id.au build_command: make branch_pattern: coverity_scan script: - make - make check && make checkm # Check it builds properly without optional packages: # python, valgrind, libyaml - script: - make - make check - arch: arm64 addons: apt_packages: - swig - python-dev - valgrind - libyaml-0-2 script: - make - make check checkm - arch: ppc64le addons: apt_packages: - swig - python-dev - libyaml-0-2 script: - make - make check - arch: s390x addons: apt_packages: - swig - python-dev - valgrind - libyaml-0-2 script: - make - make check checkm device-tree-compiler-1.7.0/BSD-2-Clause000066400000000000000000000031511437114217700174360ustar00rootroot00000000000000Valid-License-Identifier: BSD-2-Clause SPDX-URL: https://spdx.org/licenses/BSD-2-Clause.html Usage-Guide: To use the BSD 2-clause "Simplified" License put the following SPDX tag/value pair into a comment according to the placement guidelines in the licensing rules documentation: SPDX-License-Identifier: BSD-2-Clause License-Text: Copyright (c) . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. device-tree-compiler-1.7.0/CONTRIBUTING.md000066400000000000000000000066011437114217700177660ustar00rootroot00000000000000# Contributing to dtc or libfdt There are two ways to submit changes for dtc or libfdt: * Post patches directly to the the [devicetree-compiler](mailto:devicetree-compiler@vger.kernel.org) mailing list. * Submit pull requests via [Github](https://github.com/dgibson/dtc/pulls) ## Adding a new function to libfdt.h The shared library uses `libfdt/version.lds` to list the exported functions, so add your new function there. Check that your function works with pylibfdt. If it cannot be supported, put the declaration in `libfdt.h` behind `#ifndef SWIG` so that swig ignores it. ## Tests Test files are kept in the `tests/` directory. Use `make check` to build and run all tests. If you want to adjust a test file, be aware that `tree_tree1.dts` is compiled and checked against a binary tree from assembler macros in `trees.S`. So if you change that file you must change `tree.S` also. ## Developer's Certificate of Origin Like many other projects, dtc and libfdt have adopted the "Developer's Certificate of Origin" (Signed-off-by) process created by the Linux kernel community to improve tracking of who did what. Here's how it works (this is a very slight modification of the description from `Documentation/process/submitting-patches.rst` in the kernel tree): The sign-off is a simple line at the end of the explanation for the patch, which certifies that you wrote it or otherwise have the right to pass it on as an open-source patch. The rules are pretty simple: if you can certify the below: Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. then you just add a line saying:: Signed-off-by: Random J Developer using your real name (sorry, no pseudonyms or anonymous contributions.) This will be done for you automatically if you use `git commit -s`. Reverts should also include "Signed-off-by". `git revert -s` does that for you. Any further SoBs (Signed-off-by:'s) following the author's SoB are from people handling and transporting the patch, but were not involved in its development. SoB chains should reflect the **real** route a patch took as it was propagated to the maintainers, with the first SoB entry signalling primary authorship of a single author. device-tree-compiler-1.7.0/Documentation/000077500000000000000000000000001437114217700203435ustar00rootroot00000000000000device-tree-compiler-1.7.0/Documentation/dt-object-internal.txt000066400000000000000000000212011437114217700245650ustar00rootroot00000000000000Device Tree Dynamic Object format internals ------------------------------------------- The Device Tree for most platforms is a static representation of the hardware capabilities. This is insufficient for platforms that need to dynamically insert Device Tree fragments into the live tree. This document explains the the Device Tree object format and modifications made to the Device Tree compiler, which make it possible. 1. Simplified Problem Definition -------------------------------- Assume we have a platform which boots using following simplified Device Tree. ---- foo.dts ----------------------------------------------------------------- /* FOO platform */ / { compatible = "corp,foo"; /* shared resources */ res: res { }; /* On chip peripherals */ ocp: ocp { /* peripherals that are always instantiated */ peripheral1 { ... }; }; }; ---- foo.dts ----------------------------------------------------------------- We have a number of peripherals that after probing (using some undefined method) should result in different Device Tree configuration. We cannot boot with this static tree because due to the configuration of the foo platform there exist multiple conficting peripherals DT fragments. So for the bar peripheral we would have this: ---- foo+bar.dts ------------------------------------------------------------- /* FOO platform + bar peripheral */ / { compatible = "corp,foo"; /* shared resources */ res: res { }; /* On chip peripherals */ ocp: ocp { /* peripherals that are always instantiated */ peripheral1 { ... }; /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ }; }; }; ---- foo+bar.dts ------------------------------------------------------------- While for the baz peripheral we would have this: ---- foo+baz.dts ------------------------------------------------------------- /* FOO platform + baz peripheral */ / { compatible = "corp,foo"; /* shared resources */ res: res { /* baz resources */ baz_res: res_baz { ... }; }; /* On chip peripherals */ ocp: ocp { /* peripherals that are always instantiated */ peripheral1 { ... }; /* baz peripheral */ baz { compatible = "corp,baz"; /* reference to another point in the tree */ ref-to-res = <&baz_res>; ... /* various properties and child nodes */ }; }; }; ---- foo+baz.dts ------------------------------------------------------------- We note that the baz case is more complicated, since the baz peripheral needs to reference another node in the DT tree. 2. Device Tree Object Format Requirements ----------------------------------------- Since the Device Tree is used for booting a number of very different hardware platforms it is imperative that we tread very carefully. 2.a) No changes to the Device Tree binary format for the base tree. We cannot modify the tree format at all and all the information we require should be encoded using Device Tree itself. We can add nodes that can be safely ignored by both bootloaders and the kernel. The plugin dtbs are optionally tagged with a different magic number in the header but otherwise they're simple blobs. 2.b) Changes to the DTS source format should be absolutely minimal, and should only be needed for the DT fragment definitions, and not the base boot DT. 2.c) An explicit option should be used to instruct DTC to generate the required information needed for object resolution. Platforms that don't use the dynamic object format can safely ignore it. 2.d) Finally, DT syntax changes should be kept to a minimum. It should be possible to express everything using the existing DT syntax. 3. Implementation ----------------- The basic unit of addressing in Device Tree is the phandle. Turns out it's relatively simple to extend the way phandles are generated and referenced so that it's possible to dynamically convert symbolic references (labels) to phandle values. This is a valid assumption as long as the author uses reference syntax and does not assign phandle values manually (which might be a problem with decompiled source files). We can roughly divide the operation into two steps. 3.a) Compilation of the base board DTS file using the '-@' option generates a valid DT blob with an added __symbols__ node at the root node, containing a list of all nodes that are marked with a label. Using the foo.dts file above the following node will be generated; $ dtc -@ -O dtb -o foo.dtb -b 0 foo.dts $ fdtdump foo.dtb ... / { ... res { ... phandle = <0x00000001>; ... }; ocp { ... phandle = <0x00000002>; ... }; __symbols__ { res="/res"; ocp="/ocp"; }; }; Notice that all the nodes that had a label have been recorded, and that phandles have been generated for them. This blob can be used to boot the board normally, the __symbols__ node will be safely ignored both by the bootloader and the kernel (the only loss will be a few bytes of memory and disk space). We generate a __symbols__ node to record nodes that had labels in the base tree (or subsequent loaded overlays) so that they can be matched up with references made to them in Device Tree objects. 3.b) The Device Tree fragments must be compiled with the same option but they must also have a tag (/plugin/) that allows undefined references to nodes that are not present at compilation time to be recorded so that the runtime loader can fix them. So the bar peripheral's DTS format would be of the form: /dts-v1/; /plugin/; /* allow undefined references and record them */ / { .... /* various properties for loader use; i.e. part id etc. */ fragment@0 { target = <&ocp>; __overlay__ { /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ } }; }; }; Note that there's a target property that specifies the location where the contents of the overlay node will be placed, and it references the node in the foo.dts file. $ dtc -@ -O dtb -o bar.dtbo -b 0 bar.dts $ fdtdump bar.dtbo ... / { ... /* properties */ fragment@0 { target = <0xffffffff>; __overlay__ { bar { compatible = "corp,bar"; ... /* various properties and child nodes */ } }; }; __fixups__ { ocp = "/fragment@0:target:0"; }; }; No __symbols__ node has been generated (no label in bar.dts). Note that the target's ocp label is undefined, so the phandle value is filled with the illegal value '0xffffffff', while a __fixups__ node has been generated, which marks the location in the tree where the label lookup should store the runtime phandle value of the ocp node. The format of the __fixups__ node entry is