Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/gpl2/dtc/dist initial import of Device Tree Compile...
details: https://anonhg.NetBSD.org/src/rev/4a1f626671ce
branches: trunk
changeset: 342064:4a1f626671ce
user: macallan <macallan%NetBSD.org@localhost>
date: Fri Dec 04 12:30:05 2015 +0000
description:
initial import of Device Tree Compiler and related tools
diffstat:
external/gpl2/dtc/dist/.gitignore | 17 +
external/gpl2/dtc/dist/.travis.yml | 5 +
external/gpl2/dtc/dist/Documentation/dtc-paper.bib | 43 +
external/gpl2/dtc/dist/Documentation/dtc-paper.tex | 597 +++
external/gpl2/dtc/dist/Documentation/dts-format.txt | 122 +
external/gpl2/dtc/dist/Documentation/manual.txt | 658 +++
external/gpl2/dtc/dist/GPL | 340 ++
external/gpl2/dtc/dist/Makefile | 278 +
external/gpl2/dtc/dist/Makefile.convert-dtsv0 | 13 +
external/gpl2/dtc/dist/Makefile.dtc | 18 +
external/gpl2/dtc/dist/Makefile.utils | 24 +
external/gpl2/dtc/dist/README | 20 +
external/gpl2/dtc/dist/README.license | 56 +
external/gpl2/dtc/dist/TODO | 8 +
external/gpl2/dtc/dist/checks.c | 760 ++++
external/gpl2/dtc/dist/convert-dtsv0-lexer.l | 247 +
external/gpl2/dtc/dist/data.c | 269 +
external/gpl2/dtc/dist/dtc-lexer.l | 289 +
external/gpl2/dtc/dist/dtc-parser.y | 477 ++
external/gpl2/dtc/dist/dtc.c | 319 +
external/gpl2/dtc/dist/dtc.h | 269 +
external/gpl2/dtc/dist/dtdiff | 38 +
external/gpl2/dtc/dist/fdtdump.c | 227 +
external/gpl2/dtc/dist/fdtget.c | 360 ++
external/gpl2/dtc/dist/fdtput.c | 475 ++
external/gpl2/dtc/dist/flattree.c | 933 +++++
external/gpl2/dtc/dist/fstree.c | 91 +
external/gpl2/dtc/dist/libfdt/Makefile.libfdt | 11 +
external/gpl2/dtc/dist/libfdt/TODO | 3 +
external/gpl2/dtc/dist/libfdt/fdt.c | 250 +
external/gpl2/dtc/dist/libfdt/fdt.h | 111 +
external/gpl2/dtc/dist/libfdt/fdt_addresses.c | 96 +
external/gpl2/dtc/dist/libfdt/fdt_empty_tree.c | 84 +
external/gpl2/dtc/dist/libfdt/fdt_ro.c | 679 ++++
external/gpl2/dtc/dist/libfdt/fdt_rw.c | 494 ++
external/gpl2/dtc/dist/libfdt/fdt_strerror.c | 96 +
external/gpl2/dtc/dist/libfdt/fdt_sw.c | 288 +
external/gpl2/dtc/dist/libfdt/fdt_wip.c | 118 +
external/gpl2/dtc/dist/libfdt/libfdt.h | 1653 ++++++++++
external/gpl2/dtc/dist/libfdt/libfdt_env.h | 111 +
external/gpl2/dtc/dist/libfdt/libfdt_internal.h | 95 +
external/gpl2/dtc/dist/libfdt/version.lds | 67 +
external/gpl2/dtc/dist/livetree.c | 711 ++++
external/gpl2/dtc/dist/scripts/kup-dtc | 31 +
external/gpl2/dtc/dist/scripts/setlocalversion | 22 +
external/gpl2/dtc/dist/srcpos.c | 321 +
external/gpl2/dtc/dist/srcpos.h | 119 +
external/gpl2/dtc/dist/tests/.gitignore | 59 +
external/gpl2/dtc/dist/tests/Makefile.tests | 84 +
external/gpl2/dtc/dist/tests/add_subnode_with_nops.c | 84 +
external/gpl2/dtc/dist/tests/addr_size_cells.c | 64 +
external/gpl2/dtc/dist/tests/addresses.dts | 15 +
external/gpl2/dtc/dist/tests/aliases.dts | 25 +
external/gpl2/dtc/dist/tests/appendprop.dts | 8 +
external/gpl2/dtc/dist/tests/appendprop1.c | 70 +
external/gpl2/dtc/dist/tests/appendprop2.c | 64 +
external/gpl2/dtc/dist/tests/asm_tree_dump.c | 61 +
external/gpl2/dtc/dist/tests/bad-empty-ranges.dts | 11 +
external/gpl2/dtc/dist/tests/bad-name-property.dts | 7 +
external/gpl2/dtc/dist/tests/bad-ncells.dts | 7 +
external/gpl2/dtc/dist/tests/bad-reg-ranges.dts | 12 +
external/gpl2/dtc/dist/tests/bad-size-cells.dts | 12 +
external/gpl2/dtc/dist/tests/bad-string-props.dts | 7 +
external/gpl2/dtc/dist/tests/base01.asm | 175 +
external/gpl2/dtc/dist/tests/base01.cmd | 1 +
external/gpl2/dtc/dist/tests/base01.dts | 33 +
external/gpl2/dtc/dist/tests/base01.stderr | 6 +
external/gpl2/dtc/dist/tests/boot-cpuid.c | 47 +
external/gpl2/dtc/dist/tests/boot-cpuid.dts | 16 +
external/gpl2/dtc/dist/tests/char_literal.c | 49 +
external/gpl2/dtc/dist/tests/char_literal.dts | 5 +
external/gpl2/dtc/dist/tests/comments-cmp.dts | 16 +
external/gpl2/dtc/dist/tests/comments.dts | 39 +
external/gpl2/dtc/dist/tests/data.S | 3 +
external/gpl2/dtc/dist/tests/default-addr-size.dts | 7 +
external/gpl2/dtc/dist/tests/del_node.c | 123 +
external/gpl2/dtc/dist/tests/del_property.c | 90 +
external/gpl2/dtc/dist/tests/delete_reinstate_multilabel.dts | 37 +
external/gpl2/dtc/dist/tests/delete_reinstate_multilabel_ref.dts | 9 +
external/gpl2/dtc/dist/tests/dependencies.cmp | 1 +
external/gpl2/dtc/dist/tests/dependencies.dts | 6 +
external/gpl2/dtc/dist/tests/deps_inc1.dtsi | 1 +
external/gpl2/dtc/dist/tests/deps_inc2.dtsi | 1 +
external/gpl2/dtc/dist/tests/dtb_reverse.c | 163 +
external/gpl2/dtc/dist/tests/dtbs_equal_ordered.c | 173 +
external/gpl2/dtc/dist/tests/dtbs_equal_unordered.c | 223 +
external/gpl2/dtc/dist/tests/dtc-checkfails.sh | 44 +
external/gpl2/dtc/dist/tests/dtc-fails.sh | 30 +
external/gpl2/dtc/dist/tests/dtc-fatal.sh | 14 +
external/gpl2/dtc/dist/tests/dumptrees.c | 69 +
external/gpl2/dtc/dist/tests/dup-nodename.dts | 8 +
external/gpl2/dtc/dist/tests/dup-phandle.dts | 10 +
external/gpl2/dtc/dist/tests/dup-propname.dts | 6 +
external/gpl2/dtc/dist/tests/embedded_nul.dts | Bin
external/gpl2/dtc/dist/tests/embedded_nul_equiv.dts | 6 +
external/gpl2/dtc/dist/tests/empty.dts | 4 +
external/gpl2/dtc/dist/tests/escapes.dts | 7 +
external/gpl2/dtc/dist/tests/extra-terminating-null.c | 58 +
external/gpl2/dtc/dist/tests/extra-terminating-null.dts | 11 +
external/gpl2/dtc/dist/tests/fdtdump-runtest.sh | 30 +
external/gpl2/dtc/dist/tests/fdtdump.dts | 38 +
external/gpl2/dtc/dist/tests/fdtget-runtest.sh | 24 +
external/gpl2/dtc/dist/tests/fdtput-runtest.sh | 39 +
external/gpl2/dtc/dist/tests/find_property.c | 41 +
external/gpl2/dtc/dist/tests/get_alias.c | 57 +
external/gpl2/dtc/dist/tests/get_mem_rsv.c | 48 +
external/gpl2/dtc/dist/tests/get_name.c | 82 +
external/gpl2/dtc/dist/tests/get_path.c | 92 +
external/gpl2/dtc/dist/tests/get_phandle.c | 57 +
external/gpl2/dtc/dist/tests/getprop.c | 42 +
external/gpl2/dtc/dist/tests/incbin.bin | 1 +
external/gpl2/dtc/dist/tests/incbin.c | 75 +
external/gpl2/dtc/dist/tests/incbin.dts | 6 +
external/gpl2/dtc/dist/tests/include0.dts | 1 +
external/gpl2/dtc/dist/tests/include1.dts | 32 +
external/gpl2/dtc/dist/tests/include2.dts | 1 +
external/gpl2/dtc/dist/tests/include3.dts | 1 +
external/gpl2/dtc/dist/tests/include4.dts | 1 +
external/gpl2/dtc/dist/tests/include5.dts | 1 +
external/gpl2/dtc/dist/tests/include5a.dts | 1 +
external/gpl2/dtc/dist/tests/include6.dts | 1 +
external/gpl2/dtc/dist/tests/include7.dts | 13 +
external/gpl2/dtc/dist/tests/include8.dts | 2 +
external/gpl2/dtc/dist/tests/integer-expressions.c | 116 +
external/gpl2/dtc/dist/tests/label01.dts | 63 +
external/gpl2/dtc/dist/tests/label_repeated.dts | 15 +
external/gpl2/dtc/dist/tests/line_directives.dts | 21 +
external/gpl2/dtc/dist/tests/lorem.txt | 35 +
external/gpl2/dtc/dist/tests/mangle-layout.c | 164 +
external/gpl2/dtc/dist/tests/mangle-layout.supp | 7 +
external/gpl2/dtc/dist/tests/minusone-phandle.dts | 7 +
external/gpl2/dtc/dist/tests/move_and_save.c | 75 +
external/gpl2/dtc/dist/tests/multilabel.dts | 44 +
external/gpl2/dtc/dist/tests/multilabel_merge.dts | 70 +
external/gpl2/dtc/dist/tests/node_check_compatible.c | 62 +
external/gpl2/dtc/dist/tests/node_offset_by_compatible.c | 85 +
external/gpl2/dtc/dist/tests/node_offset_by_phandle.c | 63 +
external/gpl2/dtc/dist/tests/node_offset_by_prop_value.c | 110 +
external/gpl2/dtc/dist/tests/nonexist-label-ref.dts | 8 +
external/gpl2/dtc/dist/tests/nonexist-node-ref.dts | 8 +
external/gpl2/dtc/dist/tests/nonexist-node-ref2.dts | 10 +
external/gpl2/dtc/dist/tests/nop_node.c | 104 +
external/gpl2/dtc/dist/tests/nop_property.c | 70 +
external/gpl2/dtc/dist/tests/nopulate.c | 105 +
external/gpl2/dtc/dist/tests/notfound.c | 70 +
external/gpl2/dtc/dist/tests/obsolete-chosen-interrupt-controller.dts | 13 +
external/gpl2/dtc/dist/tests/open_pack.c | 71 +
external/gpl2/dtc/dist/tests/open_pack.supp | 7 +
external/gpl2/dtc/dist/tests/parent_offset.c | 90 +
external/gpl2/dtc/dist/tests/path-references.c | 98 +
external/gpl2/dtc/dist/tests/path-references.dts | 15 +
external/gpl2/dtc/dist/tests/path_offset.c | 137 +
external/gpl2/dtc/dist/tests/path_offset_aliases.c | 58 +
external/gpl2/dtc/dist/tests/phandle_format.c | 77 +
external/gpl2/dtc/dist/tests/prop-after-subnode.dts | 9 +
external/gpl2/dtc/dist/tests/propname_escapes.c | 42 +
external/gpl2/dtc/dist/tests/propname_escapes.dts | 6 +
external/gpl2/dtc/dist/tests/references.c | 127 +
external/gpl2/dtc/dist/tests/references.dts | 36 +
external/gpl2/dtc/dist/tests/reg-ranges-root.dts | 8 +
external/gpl2/dtc/dist/tests/reuse-label.dts | 15 +
external/gpl2/dtc/dist/tests/reuse-label1.dts | 10 +
external/gpl2/dtc/dist/tests/reuse-label2.dts | 6 +
external/gpl2/dtc/dist/tests/reuse-label3.dts | 9 +
external/gpl2/dtc/dist/tests/reuse-label4.dts | 5 +
external/gpl2/dtc/dist/tests/reuse-label5.dts | 6 +
external/gpl2/dtc/dist/tests/reuse-label6.dts | 6 +
external/gpl2/dtc/dist/tests/root_node.c | 52 +
external/gpl2/dtc/dist/tests/run_tests.sh | 713 ++++
external/gpl2/dtc/dist/tests/rw_tree1.c | 95 +
external/gpl2/dtc/dist/tests/search_dir/search_test.dtsi | 4 +
external/gpl2/dtc/dist/tests/search_dir/search_test2.dtsi | 3 +
external/gpl2/dtc/dist/tests/search_dir_b/search_paths_subdir.dts | 6 +
external/gpl2/dtc/dist/tests/search_dir_b/search_test_b.dtsi | 4 +
external/gpl2/dtc/dist/tests/search_dir_b/search_test_b2.dtsi | 5 +
external/gpl2/dtc/dist/tests/search_dir_b/search_test_c.dtsi | 2 +
external/gpl2/dtc/dist/tests/search_paths.dts | 6 +
external/gpl2/dtc/dist/tests/search_paths_b.dts | 6 +
external/gpl2/dtc/dist/tests/set_name.c | 90 +
external/gpl2/dtc/dist/tests/setprop.c | 95 +
external/gpl2/dtc/dist/tests/setprop_inplace.c | 87 +
external/gpl2/dtc/dist/tests/sized_cells.c | 83 +
external/gpl2/dtc/dist/tests/sized_cells.dts | 11 +
external/gpl2/dtc/dist/tests/sourceoutput.dts | 14 +
external/gpl2/dtc/dist/tests/string_escapes.c | 43 +
external/gpl2/dtc/dist/tests/stringlist.c | 154 +
external/gpl2/dtc/dist/tests/stringlist.dts | 12 +
external/gpl2/dtc/dist/tests/subnode_iterate.c | 94 +
external/gpl2/dtc/dist/tests/subnode_iterate.dts | 44 +
external/gpl2/dtc/dist/tests/subnode_offset.c | 98 +
external/gpl2/dtc/dist/tests/supernode_atdepth_offset.c | 145 +
external/gpl2/dtc/dist/tests/sw_tree1.c | 174 +
external/gpl2/dtc/dist/tests/sw_tree1.supp | 18 +
external/gpl2/dtc/dist/tests/test01.asm | 294 +
external/gpl2/dtc/dist/tests/test01.dts | 57 +
external/gpl2/dtc/dist/tests/test01.stderr | 4 +
external/gpl2/dtc/dist/tests/test_kernel_dts | 86 +
external/gpl2/dtc/dist/tests/test_tree1.dts | 3 +
external/gpl2/dtc/dist/tests/test_tree1_body.dtsi | 43 +
external/gpl2/dtc/dist/tests/test_tree1_delete.dts | 68 +
external/gpl2/dtc/dist/tests/test_tree1_label_noderef.dts | 55 +
external/gpl2/dtc/dist/tests/test_tree1_merge.dts | 51 +
external/gpl2/dtc/dist/tests/test_tree1_merge_labelled.dts | 49 +
external/gpl2/dtc/dist/tests/test_tree1_merge_path.dts | 49 +
external/gpl2/dtc/dist/tests/test_tree1_wrong1.dts | 43 +
external/gpl2/dtc/dist/tests/test_tree1_wrong2.dts | 43 +
external/gpl2/dtc/dist/tests/test_tree1_wrong3.dts | 43 +
external/gpl2/dtc/dist/tests/test_tree1_wrong4.dts | 41 +
external/gpl2/dtc/dist/tests/test_tree1_wrong5.dts | 44 +
external/gpl2/dtc/dist/tests/test_tree1_wrong6.dts | 45 +
external/gpl2/dtc/dist/tests/test_tree1_wrong7.dts | 46 +
external/gpl2/dtc/dist/tests/test_tree1_wrong8.dts | 44 +
external/gpl2/dtc/dist/tests/test_tree1_wrong9.dts | 45 +
external/gpl2/dtc/dist/tests/testdata.h | 36 +
external/gpl2/dtc/dist/tests/tests.h | 129 +
external/gpl2/dtc/dist/tests/tests.sh | 62 +
external/gpl2/dtc/dist/tests/testutils.c | 202 +
external/gpl2/dtc/dist/tests/trees.S | 211 +
external/gpl2/dtc/dist/tests/truncated_property.c | 47 +
external/gpl2/dtc/dist/tests/utilfdt_test.c | 127 +
external/gpl2/dtc/dist/tests/value-labels.c | 127 +
external/gpl2/dtc/dist/tests/value-labels.dts | 8 +
external/gpl2/dtc/dist/tests/zero-phandle.dts | 7 +
external/gpl2/dtc/dist/treesource.c | 284 +
external/gpl2/dtc/dist/util.c | 444 ++
external/gpl2/dtc/dist/util.h | 252 +
226 files changed, 22390 insertions(+), 0 deletions(-)
diffs (truncated from 23294 to 300 lines):
diff -r 7c22ebb1365b -r 4a1f626671ce external/gpl2/dtc/dist/.gitignore
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/gpl2/dtc/dist/.gitignore Fri Dec 04 12:30:05 2015 +0000
@@ -0,0 +1,17 @@
+*.o
+*.d
+*.a
+*.patch
+*.so
+*~
+*.tab.[ch]
+lex.yy.c
+*.lex.c
+/dtc
+/fdtdump
+/convert-dtsv0
+/version_gen.h
+/fdtget
+/fdtput
+/patches
+/.pc
diff -r 7c22ebb1365b -r 4a1f626671ce external/gpl2/dtc/dist/.travis.yml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/gpl2/dtc/dist/.travis.yml Fri Dec 04 12:30:05 2015 +0000
@@ -0,0 +1,5 @@
+language: c
+
+script:
+ - make
+ - make check
diff -r 7c22ebb1365b -r 4a1f626671ce external/gpl2/dtc/dist/Documentation/dtc-paper.bib
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/gpl2/dtc/dist/Documentation/dtc-paper.bib Fri Dec 04 12:30:05 2015 +0000
@@ -0,0 +1,43 @@
+@STRING{pub-IEEE = "IEEE Computer Society"}
+@STRING{pub-IEEE:adr = "345 E. 47th St, New York, NY 10017, USA"}
+
+@BOOK{IEEE1275,
+ key = "IEEE1275",
+ title = "{IEEE} {S}tandard for {B}oot ({I}nitialization {C}onfiguration) {F}irmware: {C}ore {R}equirements and {P}ractices",
+ publisher = pub-IEEE,
+ address = pub-IEEE:adr,
+ series = "IEEE Std 1275-1994",
+ year = 1994,
+}
+
+@BOOK{IEEE1275-pci,
+ key = "IEEE1275-pci",
+ title = "{PCI} {B}us {B}inding to: {IEEE} {S}td 1275-1994 {S}tandard for {B}oot ({I}nitialization {C}onfiguration) {F}irmware",
+ publisher = pub-IEEE,
+ address = pub-IEEE:adr,
+ note = "Revision 2.1",
+ year = 1998,
+}
+
+@MISC{noof1,
+ author = "Benjamin Herrenschmidt",
+ title = "Booting the {L}inux/ppc kernel without {O}pen {F}irmware",
+ month = may,
+ year = 2005,
+ note = "v0.1, \url{http://ozlabs.org/pipermail/linuxppc64-dev/2005-May/004073.html}",
+}
+
+@MISC{noof5,
+ author = "Benjamin Herrenschmidt",
+ title = "Booting the {L}inux/ppc kernel without {O}pen {F}irmware",
+ month = nov,
+ year = 2005,
+ note = "v0.5, \url{http://ozlabs.org/pipermail/linuxppc64-dev/2005-December/006994.html}",
+}
+
+@MISC{dtcgit,
+ author = "David Gibson et al.",
+ title = "\dtc{}",
+ howpublished = "git tree",
+ note = "\url{http://ozlabs.org/~dgibson/dtc/dtc.git}",
+}
diff -r 7c22ebb1365b -r 4a1f626671ce external/gpl2/dtc/dist/Documentation/dtc-paper.tex
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/gpl2/dtc/dist/Documentation/dtc-paper.tex Fri Dec 04 12:30:05 2015 +0000
@@ -0,0 +1,597 @@
+\documentclass[a4paper,twocolumn]{article}
+
+\usepackage{abstract}
+\usepackage{xspace}
+\usepackage{amssymb}
+\usepackage{latexsym}
+\usepackage{tabularx}
+\usepackage[T1]{fontenc}
+\usepackage{calc}
+\usepackage{listings}
+\usepackage{color}
+\usepackage{url}
+
+\title{Device trees everywhere}
+
+\author{David Gibson \texttt{<{dwg}{@}{au1.ibm.com}>}\\
+ Benjamin Herrenschmidt \texttt{<{benh}{@}{kernel.crashing.org}>}\\
+ \emph{OzLabs, IBM Linux Technology Center}}
+
+\newcommand{\R}{\textsuperscript{\textregistered}\xspace}
+\newcommand{\tm}{\textsuperscript{\texttrademark}\xspace}
+\newcommand{\tge}{$\geqslant$}
+%\newcommand{\ditto}{\textquotedbl\xspace}
+
+\newcommand{\fixme}[1]{$\bigstar$\emph{\textbf{\large #1}}$\bigstar$\xspace}
+
+\newcommand{\ppc}{\mbox{PowerPC}\xspace}
+\newcommand{\of}{Open Firmware\xspace}
+\newcommand{\benh}{Ben Herrenschmidt\xspace}
+\newcommand{\kexec}{\texttt{kexec()}\xspace}
+\newcommand{\dtbeginnode}{\texttt{OF\_DT\_BEGIN\_NODE\xspace}}
+\newcommand{\dtendnode}{\texttt{OF\_DT\_END\_NODE\xspace}}
+\newcommand{\dtprop}{\texttt{OF\_DT\_PROP\xspace}}
+\newcommand{\dtend}{\texttt{OF\_DT\_END\xspace}}
+\newcommand{\dtc}{\texttt{dtc}\xspace}
+\newcommand{\phandle}{\texttt{linux,phandle}\xspace}
+\begin{document}
+
+\maketitle
+
+\begin{abstract}
+ We present a method for booting a \ppc{}\R Linux\R kernel on an
+ embedded machine. To do this, we supply the kernel with a compact
+ flattened-tree representation of the system's hardware based on the
+ device tree supplied by Open Firmware on IBM\R servers and Apple\R
+ Power Macintosh\R machines.
+
+ The ``blob'' representing the device tree can be created using \dtc
+ --- the Device Tree Compiler --- that turns a simple text
+ representation of the tree into the compact representation used by
+ the kernel. The compiler can produce either a binary ``blob'' or an
+ assembler file ready to be built into a firmware or bootwrapper
+ image.
+
+ This flattened-tree approach is now the only supported method of
+ booting a \texttt{ppc64} kernel without Open Firmware, and we plan
+ to make it the only supported method for all \texttt{powerpc}
+ kernels in the future.
+\end{abstract}
+
+\section{Introduction}
+
+\subsection{OF and the device tree}
+
+Historically, ``everyday'' \ppc machines have booted with the help of
+\of (OF), a firmware environment defined by IEEE1275 \cite{IEEE1275}.
+Among other boot-time services, OF maintains a device tree that
+describes all of the system's hardware devices and how they're
+connected. During boot, before taking control of memory management,
+the Linux kernel uses OF calls to scan the device tree and transfer it
+to an internal representation that is used at run time to look up
+various device information.
+
+The device tree consists of nodes representing devices or
+buses\footnote{Well, mostly. There are a few special exceptions.}.
+Each node contains \emph{properties}, name--value pairs that give
+information about the device. The values are arbitrary byte strings,
+and for some properties, they contain tables or other structured
+information.
+
+\subsection{The bad old days}
+
+Embedded systems, by contrast, usually have a minimal firmware that
+might supply a few vital system parameters (size of RAM and the like),
+but nothing as detailed or complete as the OF device tree. This has
+meant that the various 32-bit \ppc embedded ports have required a
+variety of hacks spread across the kernel to deal with the lack of
+device tree. These vary from specialised boot wrappers to parse
+parameters (which are at least reasonably localised) to
+CONFIG-dependent hacks in drivers to override normal probe logic with
+hardcoded addresses for a particular board. As well as being ugly of
+itself, such CONFIG-dependent hacks make it hard to build a single
+kernel image that supports multiple embedded machines.
+
+Until relatively recently, the only 64-bit \ppc machines without OF
+were legacy (pre-POWER5\R) iSeries\R machines. iSeries machines often
+only have virtual IO devices, which makes it quite simple to work
+around the lack of a device tree. Even so, the lack means the iSeries
+boot sequence must be quite different from the pSeries or Macintosh,
+which is not ideal.
+
+The device tree also presents a problem for implementing \kexec. When
+the kernel boots, it takes over full control of the system from OF,
+even re-using OF's memory. So, when \kexec comes to boot another
+kernel, OF is no longer around for the second kernel to query.
+
+\section{The Flattened Tree}
+
+In May 2005 \benh implemented a new approach to handling the device
+tree that addresses all these problems. When booting on OF systems,
+the first thing the kernel runs is a small piece of code in
+\texttt{prom\_init.c}, which executes in the context of OF. This code
+walks the device tree using OF calls, and transcribes it into a
+compact, flattened format. The resulting device tree ``blob'' is then
+passed to the kernel proper, which eventually unflattens the tree into
+its runtime form. This blob is the only data communicated between the
+\texttt{prom\_init.c} bootstrap and the rest of the kernel.
+
+When OF isn't available, either because the machine doesn't have it at
+all or because \kexec has been used, the kernel instead starts
+directly from the entry point taking a flattened device tree. The
+device tree blob must be passed in from outside, rather than generated
+by part of the kernel from OF. For \kexec, the userland
+\texttt{kexec} tools build the blob from the runtime device tree
+before invoking the new kernel. For embedded systems the blob can
+come either from the embedded bootloader, or from a specialised
+version of the \texttt{zImage} wrapper for the system in question.
+
+\subsection{Properties of the flattened tree}
+
+The flattened tree format should be easy to handle, both for the
+kernel that parses it and the bootloader that generates it. In
+particular, the following properties are desirable:
+
+\begin{itemize}
+\item \emph{relocatable}: the bootloader or kernel should be able to
+ move the blob around as a whole, without needing to parse or adjust
+ its internals. In practice that means we must not use pointers
+ within the blob.
+\item \emph{insert and delete}: sometimes the bootloader might want to
+ make tweaks to the flattened tree, such as deleting or inserting a
+ node (or whole subtree). It should be possible to do this without
+ having to effectively regenerate the whole flattened tree. In
+ practice this means limiting the use of internal offsets in the blob
+ that need recalculation if a section is inserted or removed with
+ \texttt{memmove()}.
+\item \emph{compact}: embedded systems are frequently short of
+ resources, particularly RAM and flash memory space. Thus, the tree
+ representation should be kept as small as conveniently possible.
+\end{itemize}
+
+\subsection{Format of the device tree blob}
+\label{sec:format}
+
+\begin{figure}[htb!]
+ \centering
+ \footnotesize
+ \begin{tabular}{r|c|l}
+ \multicolumn{1}{r}{\textbf{Offset}}& \multicolumn{1}{c}{\textbf{Contents}} \\\cline{2-2}
+ \texttt{0x00} & \texttt{0xd00dfeed} & magic number \\\cline{2-2}
+ \texttt{0x04} & \emph{totalsize} \\\cline{2-2}
+ \texttt{0x08} & \emph{off\_struct} & \\\cline{2-2}
+ \texttt{0x0C} & \emph{off\_strs} & \\\cline{2-2}
+ \texttt{0x10} & \emph{off\_rsvmap} & \\\cline{2-2}
+ \texttt{0x14} & \emph{version} \\\cline{2-2}
+ \texttt{0x18} & \emph{last\_comp\_ver} & \\\cline{2-2}
+ \texttt{0x1C} & \emph{boot\_cpu\_id} & \tge v2 only\\\cline{2-2}
+ \texttt{0x20} & \emph{size\_strs} & \tge v3 only\\\cline{2-2}
+ \multicolumn{1}{r}{\vdots} & \multicolumn{1}{c}{\vdots} & \\\cline{2-2}
+ \emph{off\_rsvmap} & \emph{address0} & memory reserve \\
+ + \texttt{0x04} & ...& table \\\cline{2-2}
+ + \texttt{0x08} & \emph{len0} & \\
+ + \texttt{0x0C} & ...& \\\cline{2-2}
+ \vdots & \multicolumn{1}{c|}{\vdots} & \\\cline{2-2}
+ & \texttt{0x00000000}- & end marker\\
+ & \texttt{00000000} & \\\cline{2-2}
+ & \texttt{0x00000000}- & \\
+ & \texttt{00000000} & \\\cline{2-2}
+ \multicolumn{1}{r}{\vdots} & \multicolumn{1}{c}{\vdots} & \\\cline{2-2}
+ \emph{off\_strs} & \texttt{'n' 'a' 'm' 'e'} & strings block \\
+ + \texttt{0x04} & \texttt{~0~ 'm' 'o' 'd'} & \\
+ + \texttt{0x08} & \texttt{'e' 'l' ~0~ \makebox[\widthof{~~~}]{\textrm{...}}} & \\
+ \vdots & \multicolumn{1}{c|}{\vdots} & \\\cline{2-2}
+ \multicolumn{1}{r}{+ \emph{size\_strs}} \\
+ \multicolumn{1}{r}{\vdots} & \multicolumn{1}{c}{\vdots} & \\\cline{2-2}
+ \emph{off\_struct} & \dtbeginnode & structure block \\\cline{2-2}
+ + \texttt{0x04} & \texttt{'/' ~0~ ~0~ ~0~} & root node\\\cline{2-2}
+ + \texttt{0x08} & \dtprop & \\\cline{2-2}
+ + \texttt{0x0C} & \texttt{0x00000005} & ``\texttt{model}''\\\cline{2-2}
+ + \texttt{0x10} & \texttt{0x00000008} & \\\cline{2-2}
+ + \texttt{0x14} & \texttt{'M' 'y' 'B' 'o'} & \\
+ + \texttt{0x18} & \texttt{'a' 'r' 'd' ~0~} & \\\cline{2-2}
+ \vdots & \multicolumn{1}{c|}{\vdots} & \\\cline{2-2}
+ & \texttt{\dtendnode} \\\cline{2-2}
+ & \texttt{\dtend} \\\cline{2-2}
+ \multicolumn{1}{r}{\vdots} & \multicolumn{1}{c}{\vdots} & \\\cline{2-2}
+ \multicolumn{1}{r}{\emph{totalsize}} \\
+ \end{tabular}
+ \caption{Device tree blob layout}
+ \label{fig:blob-layout}
+\end{figure}
+
+The format for the blob we devised, was first described on the
+\texttt{linuxppc64-dev} mailing list in \cite{noof1}. The format has
+since evolved through various revisions, and the current version is
+included as part of the \dtc (see \S\ref{sec:dtc}) git tree,
+\cite{dtcgit}.
+
+Figure \ref{fig:blob-layout} shows the layout of the blob of data
+containing the device tree. It has three sections of variable size:
+the \emph{memory reserve table}, the \emph{structure block} and the
+\emph{strings block}. A small header gives the blob's size and
+version and the locations of the three sections, plus a handful of
+vital parameters used during early boot.
+
+The memory reserve map section gives a list of regions of memory that
+the kernel must not use\footnote{Usually such ranges contain some data
+structure initialised by the firmware that must be preserved by the
+kernel.}. The list is represented as a simple array of (address,
Home |
Main Index |
Thread Index |
Old Index