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