1245803Stheraven$FreeBSD$
2245803Stheraven
3245803StheravenNotes for people hacking on dtc
4245803Stheraven===============================
5245803Stheraven
6245803StheravenThis file contains some notes for people wishing to hack on dtc.
7245803Stheraven
8245803StheravenUpstreaming
9245803Stheraven-----------
10245803Stheraven
11245803StheravenThis code is developed in the FreeBSD svn repository:
12245803Stheraven
13245803Stheravenhttps://svn.freebsd.org/base/head/usr.bin/dtc
14245803Stheraven
15245803StheravenIf you got the source from anywhere else and wish to make changes, please
16245803Stheravenensure that you are working against the latest version, or you may end up
17245803Stheravenfixing bugs that are already fixed upstream.  Although the license makes no
18245803Stheravenrequirement that you share any improvements that you make, patches are very
19245803Stheravenwelcome.
20245803Stheraven
21245803StheravenC++11
22245803Stheraven-----
23245803Stheraven
24245803StheravenThis project currently aims to compile with g++ 4.2.1 and so doesn't make any
25245803Stheravenuse of C++11 features.  It would be a good idea to relax this restriction once
26245803Stheravenclang is the default compiler for ARM, MIPS and PowerPC.
27245803Stheraven
28245803StheravenThis code makes use of a lot of iterator loops, which would be cleaner using
29245803Stheraventhe new syntax in C++11.  It also explicitly deletes a lot of objects held in
30245803Stheravencollections in destructors that have these collections as their members.  This
31245803Stheravencould be simplified by using `shared_ptr`.
32245803Stheraven
33245803StheravenThe code does make use of `static_assert()`, but uses a macro in utility.hh to
34245803Stheravenremove these if they are not supported.  The FreeBSD standard headers also
35245803Stheravendefine a compatibility macro the implements static asserts in terms of an array
36245803Stheravenwith 1 element on success and -1 elements on failure.
37245803Stheraven
38245803StheravenAdding New Checks
39245803Stheraven-----------------
40245803Stheraven
41245803StheravenCurrently, the biggest weakness of this version of the tool is that it lacks
42245803Stheravenmost of the semantic checkers that can be implemented by simply reading the
43245803StheravenePAPR spec.  The `checker` class provides a simple superclass for implementing
44245803Stheraventhese quite easily.  There are also helper methods on `device_tree` for finding
45245803Stheravenspecific nodes, for checks that require some understanding of the structure of
46245803Stheraventhe tree.
47245803Stheraven
48245803StheravenWe should probably add a parent pointer to the `node` class for easily walking
49245803Stheravenup the tree.
50245803Stheraven
51245803StheravenAdding Direct C Output
52245803Stheraven----------------------
53245803Stheraven
54245803StheravenThe FreeBSD build system currently uses dtc to generate a blob and then
55245803Stheravenconverts this to C source code.  A new `output_writer` subclass could easily
56245803Stheravengenerate the C directly.
57245803Stheraven
58245803StheravenParser Improvements
59245803Stheraven-------------------
60245803Stheraven
61245803StheravenThere are a few FIXME lines in the parser for some corner cases that are not
62245803Stheravencurrently used by FreeBSD.  These are mainly related to labels in the middle of
63245803Stheravenvalues.  These can be fixed by creating a new `property_value` with the
64245803Stheravenspecified label, starting at the location of the label.  Don't forget to remove
65245803Stheraventhe associated comments from the BUGS section of the man page if you fix this.
66