Commit graph

168 commits

Author SHA1 Message Date
David Gibson
333542fabf libfdt: Add functions for handling the "compatible" property
This patch adds functions for dealing with the compatible property.
fdt_node_check_compatible() can be used to determine whether a node is
compatible with a given string and fdt_node_offset_by_compatible()
locates nodes with a given compatible string.

Testcases for these functions are also included.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-16 07:41:37 -05:00
David Gibson
6f8b7710c9 libfdt: libfdt_env.h must be included first
libfdt.h currently includes fdt.h, then libfdt_env.h.  This is
incorrect, because depending on the environment into which libfdt is
embedded, libfdt_env.h may be needed to define datatypes used in
fdt.h.  This patch corrects the problem.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-16 07:22:50 -05:00
David Gibson
fd1bf3a5ae libfdt: Add functions to get/add/delete memory reservemap entries
This patch adds functions to libfdt for accessing the memory
reservation map section of a device tree blob.  fdt_num_mem_rsv()
retreives the number of reservation entries in a dtb, and
fdt_get_mem_rsv() retreives a specific reservation entry.
fdt_add_mem_rsv() adds a new entry, and fdt_del_mem_rsv() removes a
specific numbered entry.

Testcases for these new functions are also included.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-15 08:31:52 -05:00
David Gibson
ad9593f229 dtc: Refactor Makefiles
This patch makes a number of Makefile cleanups and improvements:
	- We use more generic rules to invoke flex and bison, which is
useful for some of the other changes.
	- We use the name dtc-lexer.lex.c for the flex output, instead
of the default lex.yy.c.  That means less potential for confusion if
dtc is embedded into other projects (e.g. the kernel).
	- We separate out a Makefile.dtc designed for embedding into
other projects, analagous to Makefile.libfdt.
	- Makefile.libfdt is cleaned up to be more useful based on
some actual trial runs of embedding libfdt in the kernel bootwrapper.
	- Versioning related rules and variables are collected into
one place in the Makefile.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-15 08:28:07 -05:00
David Gibson
d2a9da0458 libfdt: Make unit address optional for finding nodes
At present, the fdt_subnode_offset() and fdt_path_offset() functions
in libfdt require the exact name of the nodes in question be passed,
including unit address.

This is contrary to traditional OF-like finddevice() behaviour, which
allows the unit address to be omitted (which is useful when the device
name is unambiguous without the address).

This patch introduces similar behaviour to
fdt_subnode_offset_namelen(), and hence to fdt_subnode_offset() and
fdt_path_offset() which are implemented in terms of the former.  The
unit address can be omitted from the given node name.  If this is
ambiguous, the first such node in the flattened tree will be selected
(this behaviour is consistent with IEEE1275 which specifies only that
an arbitrary node matching the given information be selected).

This very small change is then followed by many more diffs which
change the test examples and testcases to exercise this behaviour.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-15 08:27:24 -05:00
David Gibson
63dc9c7113 dtc: Whitespace cleanup
This large patch removes all trailing whitespace from dtc (including
libfdt, the testsuite and documentation).  It also removes a handful
of redundant blank lines (at the end of functions, or when there are
two blank lines together for no particular reason).

As well as anything else, this means that quilt won't whinge when I go
to convert the whole of libfdt into a patch to apply to the kernel.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-09-18 09:43:26 -05:00
David Gibson
ae1454b311 libfdt: Add fdt_node_offset_by_prop_value()
This patch adds a function to libfdt to locate nodes containing a
property with a specific value.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-09-17 13:18:09 -05:00
David Gibson
592ea5888c dtc: Assume properties preced subnodes in the flattened tree
With kernel commit eff2ebd207af9f501af0ef667a7d14befcb36c1b, we
clarified that in the flattened tree format, a particular nodes
properties are required to precede its subdnodes.

At present however, both dtc and libfdt will process trees which don't
meet this condition.  This patch simplifies the code for
fdt_get_property() based on assuming that constraint.  dtc continues
to be able to handle such an invalid tree - on the grounds that it's
useful for dtc to be able to correct such a broken tree - but this
patch adds a warning when this condition is not met while reading a
flattened tree.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-09-05 13:17:14 -05:00
David Gibson
e2b3bb3227 libfdt: Fix use of uninitialized variable in fdt_get_path()
My recent implemenetation of fdt_get_path() had a bug - the while loop
tested offset which was unitialized on the first iteration.  Depending
on code surrounding the call, this could cause fdt_get_path() to
return incorrect results.

This patch corrects the problem by applying some more correct thinking
to the loop condition.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-08-31 08:34:09 -05:00
David Gibson
1248237c7e libfdt: Add fdt_parent_offset() and supporting functions
This patch adds an fdt_parent_offset() function which returns an
offset to the parent node of a given node.  It also adds two helper
functions which are used to implement fdt_parent_offset() but are also
exported: fdt_supernode_atdepth_offset() which returns the ancestor of
a given node at a specified depth from the root of the tree, and
fdt_node_depth() which returns the depth of a given node.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-08-30 08:43:12 -05:00
David Gibson
037db263e0 libfdt: Add fdt_get_path() function
This patch adds an fdt_get_path() function to libfdt, which returns
the full path of a given node in a caller supplied buffer.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-08-30 08:43:06 -05:00
David Gibson
9d26eabdc6 libfdt: Add fdt_get_name() to retrieve a node's name
This patch adds a new fdt_get_name() function to libfdt which will
return a node's name string (including unit address, if any).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-08-30 08:42:59 -05:00
David Gibson
bd2ae2f41c libfdt: Fix handling of trailing / in fdt_path_offset()
Currently, fdt_path_offset() returns FDL_ERR_BADOFFSET if given a path
with a trailing '/'.  In particular this means that
fdt_path_offset("/") returns FDT_ERR_BADOFFSET rather than 0 as one
would expect.

This patch fixes the function to accept and ignore trailing '/'
characters.  As well as allowing fdt_path_offset("/") this means that
fdt_path_offset("/foo/") will return the same as
fdt_path_offset("/foo") which seems in keeping with the principle of
least surprise.

This also adds a testcase to ensure that fdt_path_offset("/") returns
0 as it should.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-08-30 08:42:45 -05:00
David Gibson
4f61ae1627 dtc: Improve the make install target
This patch makes various improvements to dtc's make install target:
	- libfdt is also installed.  Specifically, libfdt.a and the
two export relevant header files, fdt.h and libfdt.h are installed.
	- ftdump is no longer installed.  It was only ever a
development debugging tool and may well go away at some point.
	- In keeping with normal conventions, there is now a PREFIX
variable, allowing control of where things are installed (in /usr,
/usr/local, /opt, etc.).
	- By default, installed into the user's home directory,
instead of /usr.  This is friendlier for self-installers, package
builders can easily override PREFIX to restore the old behaviour.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-07-25 10:26:36 -05:00
David Gibson
d9d679fb96 dtc: Improve and better integrate dtc and libfdt Makefiles
This patch substantially revamps the dtc Makefiles, in particular
better integrating the Makefile for dtc proper with the Makefiles
imported from libfdt for libfdt and the shared testsuite.  Notable
changes:
	- No recursive make calls.  Instead subsidiary Makefiles are
included into the top-level Makefile so we get a complete dependency
information.
	- Common pattern rules, CFLAGS etc. shared between dtc, libfdt
and testsuite, rather than separate copies.
	- Vaguely Kbuild-like non-verbose mode used by default, which
makes warnings more prominent.
	- libfdt Makefile consists only of variable definitions and
helper rules, to make it more easily embeddable into other Makefile
systems.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-06-25 21:50:14 -05:00
David Gibson
6c65eab11e dtc: Remove redundant copy of the GPL
The dtc tree currently includes two copies of the GPL - one which was
there originally, and one imported from the libfdt tree.  This patch
gets rid of the extra copy in the libfdt tree.

In addition it renames the file containing the remaining copy from
COPYING to GPL.  Since libfdt is dual-licensed, this seems clearer.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-06-25 21:43:11 -05:00
David Gibson
12578976fe Merge libfdt into dtc.
Having pulled the libfdt repository into dtc, merge the makefiles and
testsuites so that they build together usefully.
2007-06-14 15:05:55 +10:00
David Gibson
23cdf2379f Move everything into a subdirectory in preparation for merge into dtc. 2007-06-14 11:58:35 +10:00