HACKING revision 289996
1188943Sthompsa$FreeBSD: head/usr.bin/dtc/HACKING 289996 2015-10-26 11:02:57Z theraven $
2188943Sthompsa
3188943SthompsaNotes for people hacking on dtc
4188943Sthompsa===============================
5188943Sthompsa
6188943SthompsaThis file contains some notes for people wishing to hack on dtc.
7188943Sthompsa
8188943SthompsaUpstreaming
9188943Sthompsa-----------
10188943Sthompsa
11188943SthompsaThis code is developed in the FreeBSD svn repository:
12188943Sthompsa
13188943Sthompsahttps://svn.freebsd.org/base/head/usr.bin/dtc
14188943Sthompsa
15188943SthompsaIf you got the source from anywhere else and wish to make changes, please
16188943Sthompsaensure that you are working against the latest version, or you may end up
17188943Sthompsafixing bugs that are already fixed upstream.  Although the license makes no
18188943Sthompsarequirement that you share any improvements that you make, patches are very
19188943Sthompsawelcome.
20188943Sthompsa
21188943SthompsaC++11
22188943Sthompsa-----
23188943Sthompsa
24188943SthompsaThis project uses C++11, as the goal for FreeBSD 11 is to require C/C++11 as a
25188943Sthompsaminimum, either from clang or an external toolchain.  In particular, it uses
26188943Sthompsa`std::unique_ptr` extensively for memory management within the tree.  Unique
27188943Sthompsapointers are also used in several other places to track ownership.
28188943Sthompsa
29188943SthompsaMost iterator loops use the new loop syntax and the `auto` type for type
30188943Sthompsadeduction.  Range-based `for` loops generally improve the readability of the
31188943Sthompsacode, though `auto` should only be used in places where the type can be deduced
32188943Sthompsaas easily by the reader as by the compiler.
33188943Sthompsa
34188943SthompsaThe code also makes use of `static_assert()` to track compile-time invariants.
35188943Sthompsa
36188943SthompsaAdding 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