xref: /freebsd/usr.bin/dtc/HACKING (revision 4f8f43b06ed07e96a250855488cc531799d5b78f)
1Notes for people hacking on dtc
2===============================
3
4This file contains some notes for people wishing to hack on dtc.
5
6Upstreaming
7-----------
8
9This code is developed in the git repository:
10
11https://github.com/davidchisnall/dtc
12
13If you got the source from anywhere else and wish to make changes, please
14ensure that you are working against the latest version, or you may end up
15fixing bugs that are already fixed upstream.  Although the license makes no
16requirement that you share any improvements that you make, patches are very
17welcome.
18
19C++11
20-----
21
22This project uses C++11, as the goal for FreeBSD 11 is to require C/C++11 as a
23minimum, either from clang or an external toolchain.  In particular, it uses
24`std::unique_ptr` extensively for memory management within the tree.  Unique
25pointers are also used in several other places to track ownership.
26
27Most iterator loops use the new loop syntax and the `auto` type for type
28deduction.  Range-based `for` loops generally improve the readability of the
29code, though `auto` should only be used in places where the type can be deduced
30as easily by the reader as by the compiler.
31
32The code also makes use of `static_assert()` to track compile-time invariants.
33
34Adding New Checks
35-----------------
36
37Currently, the biggest weakness of this version of the tool is that it lacks
38most of the semantic checkers that can be implemented by simply reading the
39ePAPR spec.  The `checker` class provides a simple superclass for implementing
40these quite easily.  There are also helper methods on `device_tree` for finding
41specific nodes, for checks that require some understanding of the structure of
42the tree.
43
44We should probably add a parent pointer to the `node` class for easily walking
45up the tree.
46
47Adding Direct C Output
48----------------------
49
50The FreeBSD build system currently uses dtc to generate a blob and then
51converts this to C source code.  A new `output_writer` subclass could easily
52generate the C directly.
53
54Parser Improvements
55-------------------
56
57There are a few FIXME lines in the parser for some corner cases that are not
58currently used by FreeBSD.  These are mainly related to labels in the middle of
59values.  These can be fixed by creating a new `property_value` with the
60specified label, starting at the location of the label.  Don't forget to remove
61the associated comments from the BUGS section of the man page if you fix this.
62