libfdt: going forward for u-boot

Jerry Van Baren gerald.vanbaren at comcast.net
Thu Mar 22 11:08:23 EST 2007


Hi David,

I'm using libfdt in u-boot and getting close to pushing u-boot changes 
upstream.  I'm curious what libfdt's legal status is WRT dual licensing 
and the legal dogs you've unleashed.

One thought that occurred to me since we last discussed this is to 
relicense it LGPL.  That way it could be linked into proprietary code 
without having to maintain a dual license and the copyright assignment 
headaches that come with outside contributors.

I made some trivial changes to fdt.h and libfdt_env.h to allow libfdt to 
compiler both on linux and for u-boot.  I've attached a patch since it 
_is_ trivial.

Here is the thumbnail sketch of my current changes to use libfdt in u-boot:

Makefile
--------
* Replaced with a u-boot version, unavoidable.

fdt.h
-----
* See attached patchfile for trivial change to allow compiling under
     linux and u-boot.

libfdt_env.h
------------
* See attached patchfile for change to allow compiling under linux
     and u-boot.
* #include <asm/byteorder.h> which gives us direct byteswapping
     utilities without having to do a #if __BYTE_ORDER == __BIG_ENDIAN
#define fdt32_to_cpu(x)                (__be32_to_cpu(x))
#define cpu_to_fdt32(x)                (__cpu_to_be32(x))
#define fdt64_to_cpu(x)                (__be64_to_cpu(x))
#define cpu_to_fdt64(x)                (__cpu_to_be32(x))
    (could change the source to use __be32_to_cpu(x) and friends, but
    I was too lazy to do this).

fdt_ro.c
--------
* Added comments as I figured out how things worked... ;-)
* Added a new function to allow me to step through tags, which I needed
     to recursively print the tree/subtree.  This returns a pointer to
     the name of the next node/property (if appropriate) via **namep.
     The caller can then use the node type (return value) and the string
     to print the property or follow the node.

uint32_t fdt_next_tag(const void *fdt, int offset,
                       int *nextoffset, char **namep);

     *This is the only thing I would consider non-trivial, and that is
     seriously debatable since it is mostly a copy of _fdt_next_tag()*

     Not done: because I protected namep against NULL, the existing
     _fdt_next_tag() could be trivially rewritten to be:
     fdt_next_tag(fdt, offset, nextoffset, NULL);

* Added a (void *) typecast to the fdt_getprop() return value to get rid
     of a compiler warning.

fdt_rw.c
--------
* Nonessential improvements to fdt_open_into()
   * Validate the header (fdt_move() does the validation, but I skip
       the move if buf == fdt so I needed to add the validation)
   * Do the fdt_move() only if (buf != fdt) - I call this at times with
       a new (longer) length but don't want to actually move the blob,
       just want the longer length so I can modify the fdt in-place.  The
       current code works, but it seemed silly to do a move if I'm not
       actually moving it.

gvb
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Use-a-common-header-set-linux-u-boot.txt
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20070321/e4298c71/attachment.txt>


More information about the Linuxppc-dev mailing list