1*af0dd31fSDavid Chisnall$FreeBSD$ 2*af0dd31fSDavid Chisnall 3*af0dd31fSDavid ChisnallNotes for people hacking on dtc 4*af0dd31fSDavid Chisnall=============================== 5*af0dd31fSDavid Chisnall 6*af0dd31fSDavid ChisnallThis file contains some notes for people wishing to hack on dtc. 7*af0dd31fSDavid Chisnall 8*af0dd31fSDavid ChisnallUpstreaming 9*af0dd31fSDavid Chisnall----------- 10*af0dd31fSDavid Chisnall 11*af0dd31fSDavid ChisnallThis code is developed in the FreeBSD svn repository: 12*af0dd31fSDavid Chisnall 13*af0dd31fSDavid Chisnallhttps://svn.freebsd.org/base/head/usr.bin/dtc 14*af0dd31fSDavid Chisnall 15*af0dd31fSDavid ChisnallIf you got the source from anywhere else and wish to make changes, please 16*af0dd31fSDavid Chisnallensure that you are working against the latest version, or you may end up 17*af0dd31fSDavid Chisnallfixing bugs that are already fixed upstream. Although the license makes no 18*af0dd31fSDavid Chisnallrequirement that you share any improvements that you make, patches are very 19*af0dd31fSDavid Chisnallwelcome. 20*af0dd31fSDavid Chisnall 21*af0dd31fSDavid ChisnallC++11 22*af0dd31fSDavid Chisnall----- 23*af0dd31fSDavid Chisnall 24*af0dd31fSDavid ChisnallThis project currently aims to compile with g++ 4.2.1 and so doesn't make any 25*af0dd31fSDavid Chisnalluse of C++11 features. It would be a good idea to relax this restriction once 26*af0dd31fSDavid Chisnallclang is the default compiler for ARM, MIPS and PowerPC. 27*af0dd31fSDavid Chisnall 28*af0dd31fSDavid ChisnallThis code makes use of a lot of iterator loops, which would be cleaner using 29*af0dd31fSDavid Chisnallthe new syntax in C++11. It also explicitly deletes a lot of objects held in 30*af0dd31fSDavid Chisnallcollections in destructors that have these collections as their members. This 31*af0dd31fSDavid Chisnallcould be simplified by using `shared_ptr`. 32*af0dd31fSDavid Chisnall 33*af0dd31fSDavid ChisnallThe code does make use of `static_assert()`, but uses a macro in utility.hh to 34*af0dd31fSDavid Chisnallremove these if they are not supported. The FreeBSD standard headers also 35*af0dd31fSDavid Chisnalldefine a compatibility macro the implements static asserts in terms of an array 36*af0dd31fSDavid Chisnallwith 1 element on success and -1 elements on failure. 37*af0dd31fSDavid Chisnall 38*af0dd31fSDavid ChisnallAdding New Checks 39*af0dd31fSDavid Chisnall----------------- 40*af0dd31fSDavid Chisnall 41*af0dd31fSDavid ChisnallCurrently, the biggest weakness of this version of the tool is that it lacks 42*af0dd31fSDavid Chisnallmost of the semantic checkers that can be implemented by simply reading the 43*af0dd31fSDavid ChisnallePAPR spec. The `checker` class provides a simple superclass for implementing 44*af0dd31fSDavid Chisnallthese quite easily. There are also helper methods on `device_tree` for finding 45*af0dd31fSDavid Chisnallspecific nodes, for checks that require some understanding of the structure of 46*af0dd31fSDavid Chisnallthe tree. 47*af0dd31fSDavid Chisnall 48*af0dd31fSDavid ChisnallWe should probably add a parent pointer to the `node` class for easily walking 49*af0dd31fSDavid Chisnallup the tree. 50*af0dd31fSDavid Chisnall 51*af0dd31fSDavid ChisnallAdding Direct C Output 52*af0dd31fSDavid Chisnall---------------------- 53*af0dd31fSDavid Chisnall 54*af0dd31fSDavid ChisnallThe FreeBSD build system currently uses dtc to generate a blob and then 55*af0dd31fSDavid Chisnallconverts this to C source code. A new `output_writer` subclass could easily 56*af0dd31fSDavid Chisnallgenerate the C directly. 57*af0dd31fSDavid Chisnall 58*af0dd31fSDavid ChisnallParser Improvements 59*af0dd31fSDavid Chisnall------------------- 60*af0dd31fSDavid Chisnall 61*af0dd31fSDavid ChisnallThere are a few FIXME lines in the parser for some corner cases that are not 62*af0dd31fSDavid Chisnallcurrently used by FreeBSD. These are mainly related to labels in the middle of 63*af0dd31fSDavid Chisnallvalues. These can be fixed by creating a new `property_value` with the 64*af0dd31fSDavid Chisnallspecified label, starting at the location of the label. Don't forget to remove 65*af0dd31fSDavid Chisnallthe associated comments from the BUGS section of the man page if you fix this. 66