From 134b378392a81b2a11b23fac073c306087a421ef Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Sat, 29 Feb 2020 17:10:54 +0000 Subject: [PATCH 001/118] retire in-tree GPL dtc devicetree compiler Now that we no longer have GCC 4.2.1 in the tree and can assume FreeBSD is being built with a C++11 compiler available, we can use BSDL dtc unconditionally and retire the GPL dtc. GPL dtc now has FreeBSD CI support via Cirrus-CI to help ensure it continues to build/work on FreeBSD and is available in the ports tree if needed. The copy of (copyfree licensed) libfdt that we actually use is in sys/contrib/libfdt so the extra copy under contrib/dtc/libfdt can be removed along with the rest of the GPL dtc. Reviewed by: kevans, ian, imp, manu, theraven Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23192 --- Makefile.inc1 | 8 +- UPDATING | 5 + .../dtc/Documentation/dt-object-internal.txt | 310 --- contrib/dtc/Documentation/dtc-paper.bib | 43 - contrib/dtc/Documentation/dtc-paper.tex | 597 ------ contrib/dtc/Documentation/dts-format.txt | 122 -- contrib/dtc/Documentation/manual.txt | 677 ------ contrib/dtc/GPL | 340 --- contrib/dtc/Makefile | 300 --- contrib/dtc/README | 16 - contrib/dtc/README.license | 56 - contrib/dtc/TODO | 8 - contrib/dtc/checks.c | 849 -------- contrib/dtc/data.c | 269 --- contrib/dtc/dtc-lexer.l | 324 --- contrib/dtc/dtc-parser.y | 521 ----- contrib/dtc/dtc.c | 366 ---- contrib/dtc/dtc.h | 285 --- contrib/dtc/dtdiff | 38 - contrib/dtc/fdtdump.c | 240 --- contrib/dtc/fdtget.c | 366 ---- contrib/dtc/fdtput.c | 480 ----- contrib/dtc/flattree.c | 946 --------- contrib/dtc/fstree.c | 90 - contrib/dtc/libfdt/Makefile.libfdt | 11 - contrib/dtc/libfdt/TODO | 3 - contrib/dtc/libfdt/fdt.c | 251 --- contrib/dtc/libfdt/fdt.h | 111 - contrib/dtc/libfdt/fdt_addresses.c | 96 - contrib/dtc/libfdt/fdt_empty_tree.c | 84 - contrib/dtc/libfdt/fdt_overlay.c | 676 ------ contrib/dtc/libfdt/fdt_ro.c | 703 ------- contrib/dtc/libfdt/fdt_rw.c | 491 ----- contrib/dtc/libfdt/fdt_strerror.c | 102 - contrib/dtc/libfdt/fdt_sw.c | 288 --- contrib/dtc/libfdt/fdt_wip.c | 139 -- contrib/dtc/libfdt/libfdt.h | 1833 ----------------- contrib/dtc/libfdt/libfdt_env.h | 112 - contrib/dtc/libfdt/libfdt_internal.h | 95 - contrib/dtc/libfdt/version.lds | 68 - contrib/dtc/livetree.c | 980 --------- contrib/dtc/scripts/kup-dtc | 31 - contrib/dtc/scripts/setlocalversion | 22 - contrib/dtc/srcpos.c | 302 --- contrib/dtc/srcpos.h | 118 -- contrib/dtc/treesource.c | 284 --- contrib/dtc/util.c | 473 ----- contrib/dtc/util.h | 265 --- gnu/usr.bin/Makefile | 1 - gnu/usr.bin/dtc/Makefile | 51 - gnu/usr.bin/dtc/Makefile.depend | 18 - share/mk/src.opts.mk | 1 - targets/pseudo/userland/Makefile.depend | 5 +- targets/pseudo/userland/gnu/Makefile.depend | 6 - tools/build/options/WITHOUT_GPL_DTC | 3 - tools/build/options/WITH_GPL_DTC | 3 - usr.bin/Makefile | 2 - 57 files changed, 7 insertions(+), 14877 deletions(-) delete mode 100644 contrib/dtc/Documentation/dt-object-internal.txt delete mode 100644 contrib/dtc/Documentation/dtc-paper.bib delete mode 100644 contrib/dtc/Documentation/dtc-paper.tex delete mode 100644 contrib/dtc/Documentation/dts-format.txt delete mode 100644 contrib/dtc/Documentation/manual.txt delete mode 100644 contrib/dtc/GPL delete mode 100644 contrib/dtc/Makefile delete mode 100644 contrib/dtc/README delete mode 100644 contrib/dtc/README.license delete mode 100644 contrib/dtc/TODO delete mode 100644 contrib/dtc/checks.c delete mode 100644 contrib/dtc/data.c delete mode 100644 contrib/dtc/dtc-lexer.l delete mode 100644 contrib/dtc/dtc-parser.y delete mode 100644 contrib/dtc/dtc.c delete mode 100644 contrib/dtc/dtc.h delete mode 100644 contrib/dtc/dtdiff delete mode 100644 contrib/dtc/fdtdump.c delete mode 100644 contrib/dtc/fdtget.c delete mode 100644 contrib/dtc/fdtput.c delete mode 100644 contrib/dtc/flattree.c delete mode 100644 contrib/dtc/fstree.c delete mode 100644 contrib/dtc/libfdt/Makefile.libfdt delete mode 100644 contrib/dtc/libfdt/TODO delete mode 100644 contrib/dtc/libfdt/fdt.c delete mode 100644 contrib/dtc/libfdt/fdt.h delete mode 100644 contrib/dtc/libfdt/fdt_addresses.c delete mode 100644 contrib/dtc/libfdt/fdt_empty_tree.c delete mode 100644 contrib/dtc/libfdt/fdt_overlay.c delete mode 100644 contrib/dtc/libfdt/fdt_ro.c delete mode 100644 contrib/dtc/libfdt/fdt_rw.c delete mode 100644 contrib/dtc/libfdt/fdt_strerror.c delete mode 100644 contrib/dtc/libfdt/fdt_sw.c delete mode 100644 contrib/dtc/libfdt/fdt_wip.c delete mode 100644 contrib/dtc/libfdt/libfdt.h delete mode 100644 contrib/dtc/libfdt/libfdt_env.h delete mode 100644 contrib/dtc/libfdt/libfdt_internal.h delete mode 100644 contrib/dtc/libfdt/version.lds delete mode 100644 contrib/dtc/livetree.c delete mode 100755 contrib/dtc/scripts/kup-dtc delete mode 100755 contrib/dtc/scripts/setlocalversion delete mode 100644 contrib/dtc/srcpos.c delete mode 100644 contrib/dtc/srcpos.h delete mode 100644 contrib/dtc/treesource.c delete mode 100644 contrib/dtc/util.c delete mode 100644 contrib/dtc/util.h delete mode 100644 gnu/usr.bin/dtc/Makefile delete mode 100644 gnu/usr.bin/dtc/Makefile.depend delete mode 100644 tools/build/options/WITHOUT_GPL_DTC delete mode 100644 tools/build/options/WITH_GPL_DTC diff --git a/Makefile.inc1 b/Makefile.inc1 index 80ee71f602d2..f4cee70ee15c 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -2233,12 +2233,6 @@ ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal ${_bt}-usr.bin/clang/lldb-tblgen: ${_bt}-lib/clang/libllvmminimal .endif -# Build BSDL or GPL DTC depending on GPL_DTC option. -_dtc= usr.bin/dtc -.if ${MK_GPL_DTC} != "no" -_dtc= gnu/usr.bin/dtc -.endif - .if ${MK_LOCALES} != "no" _localedef= usr.bin/localedef .endif @@ -2360,7 +2354,7 @@ bootstrap-tools: ${_bt}-links .PHONY ${_clang_tblgen} \ ${_kerberos5_bootstrap_tools} \ ${_strfile} \ - ${_dtc} \ + usr.bin/dtc \ ${_cat} \ ${_kbdcontrol} \ ${_elftoolchain_libs} \ diff --git a/UPDATING b/UPDATING index b8eb203b4224..63e26cf81b44 100644 --- a/UPDATING +++ b/UPDATING @@ -26,6 +26,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW: disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20200229: + The WITH_GPL_DTC option has been removed. The BSD-licenced device tree + compiler in usr.bin/dtc is used on all architectures which use dtc, and + the GPL dtc is available (if needed) from the sysutils/dtc port. + 20200229: The WITHOUT_LLVM_LIBUNWIND option has been removed. LLVM's libunwind is used by all supported CPU architectures. diff --git a/contrib/dtc/Documentation/dt-object-internal.txt b/contrib/dtc/Documentation/dt-object-internal.txt deleted file mode 100644 index 51d68ab93ac9..000000000000 --- a/contrib/dtc/Documentation/dt-object-internal.txt +++ /dev/null @@ -1,310 +0,0 @@ -Device 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 - -