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