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