Commit graph

131 commits

Author SHA1 Message Date
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
Jon Loeliger
5cb1fbdd7c DTC 1.0.0
For better or worse, it's about damned time!

Signed-off-by: Jon Loeliger <jdl@jdl.com>
2007-08-09 19:31:32 -05:00
Jon Loeliger
9d7e7380ac Merge branch 'doc' 2007-08-09 16:01:07 -05:00
Jon Loeliger
1dc6ca5edc Add initial Device Tree Compiler manual
This is the new location for technical descriptions of the DTC.
Derived from the kernel's Documentation/powerpc/booting-without-of.txt.
The booting-without-of.txt that was here was very old and out of date.

Signed-off-by: Jon Loeliger <jdl@freescale.com>
2007-08-09 15:58:47 -05:00
Jon Loeliger
74ce242bf3 Make release 1.0.0-rc1!
Signed-off-by: Jon Loeliger
2007-07-25 10:53:42 -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
Jon Loeliger
fdd2e6f945 Reorganized Makefile into better top-down structure.
Also removed a generic "LD" target that wasn't actually used.

Signed-off-by: Jon Loeliger <jdl@jdl.com>
2007-07-07 14:18:02 -05:00
Jon Loeliger
a657ce8fb7 Add DTC release version information.
Adopted the version information and implementation
from of the Linux Kernel Makefiles.

Signed-off-by: Jon Loeliger <jdl@jdl.com>
2007-07-07 13:52:25 -05:00
Jon Loeliger
74e6d21284 Add a note to the build about the expected parser warnings.
Signed-off-by: Jon Loeliger
2007-07-07 10:38:27 -05:00
Milton Miller
445d55d2cc dtc: format memory reserve as pairs on two lines
When writing the memory reserve table in assembly output,
emit both halves of each 64 bit number on a single .long
statement.  This results in two lines per memory reserve
slot instead of four, each line contains one field (start
or size).

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:14:42 -05:00
Milton Miller
7f45666273 dtc: align header comments in asm output
Insert tabs to align the comments describing the fields of the
boot parameters header struct.

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:14:26 -05:00
Milton Miller
9670eed1bc dtc: add a testcase with labels
Create a source file with labels for use as a testcase
to check parsing dts files.

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:14:15 -05:00
Milton Miller
43a68c63e4 dtc: store labels in ascending order
When adding a label, walk to the end of the list since the
label reflects the end of the data.

Since merging data buffers already preserved the order, this
will cause the labels to be emitted in order when writing
assembly output.

It should also aid emiting labels when writing dts output
should that be added in the future (data formatting would
need to break at each label).

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:14:12 -05:00
Milton Miller
6a99b13132 dtc: implement labels on property data
Extend the parser grammer to allow labels before or after any
property data (string, cell list, or byte list), and any
byte or cell within the property data.

Store the labels using the same linked list structure as node
references, but using a parallel list.

When writing assembly output emit global labels as offsets from
the start of the definition of the data.

Note that the alignment for a cell list is done as part of the
opening < delimiter, not the = or , before it.  To label a cell
after a string or byte list put the label inside the cell list.

For example,
	prop = zero: [ aa bb ], two: < four: 1234 > eight: ;
will produce labels with offsets 0, 2, 4, and 8 bytes from
the beginning of the data for property prop.

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:13:31 -05:00
Milton Miller
ac6a5e26b4 dtc: allow a label: in any dts context
Change the lexer to recognise a label in any context.  Place
before other celldata and bytestrings to avoid the initial
characters being stolen by other matches.

A label is a character sequence starting with an alphabetic
or underscore optinally followed by the same plus digits and
terminating in a colon.

The included terminating colon will prevent matching hex numbers.

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:10:12 -05:00
Milton Miller
46779e8f8e dtc: clean up grow_data_for()
Change the grow_data_for function to copy struct data and
modifiy the fields it is updating instead of storing all
fields individually to a stack allocated struct.

This reduces maintence for future enhancements as now all
instances of struct data are created by modifying a copy
of an existing struct data or directly copying empty_data.

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:09:36 -05:00
Milton Miller
d429033851 dtc: implement labels on memory reserve slots
Allow a label to be placed on a memory reserve entry.
Change the parser to recognize and store them.  Emit
them when writing assembly output.

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:09:31 -05:00
Milton Miller
85ab5cc6ec dtc: complain about unparsed digits in cell lists
Check that strtoul() parsed the complete string.

As with the number overflow case, write a non-fatal error
message to stdout.

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:07:44 -05:00
Milton Miller
6d7b222430 dtc: move declaration of yyerror
yyerror() is used by both dtc-parser.y and dtc-lexer.l, so move
the declaration to srcpos.h.

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:07:27 -05:00
Milton Miller
81fda8a6f1 dtc: fix asm for version 17
The version 17 flat device tree format added struct size.  When
writing version 17 assembly output the field must be emitted.

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:07:04 -05:00
Josh Boyer
8cd4196ee3 dtc: Add install makefile target
Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
2007-07-02 08:44:37 -05:00
David Gibson
6936273aa4 dtc: Remove bogus break statement
Commit 0738774fcc introduced some
incorrect indentation / bracketing in unflatten_tree().  By luck, the
extra break statement intended to be within an if block, but actually
afterwards has no semantic effect.  Still, this patch gets rid of it
for cleanliness.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-07-02 08:30:57 -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
0c7cd1a087 dtc: Count testcases and results in the dtc/libfdt testsuite
There are quite a lot of testcases in the dtc testsuite (recently
imported from libfdt).  It can be easy to miss a stray FAIL result in
the midst of all the rest.  To improve this, this patch adds a summary
to the end of the testsuite results giving the total number of tests
along with the number of PASSes FAILs and other results.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-06-25 21:43:03 -05:00
David Gibson
0738774fcc dtc: Accept NOPs in dtb input regardless of version
Since Milton's patch, dtc will accept (and, correctly, ignore) NOP
tags when given dtb input v16 or later.  However, although NOPs
weren't defined in earlier versions, they're not ambiguous, so should
be accepted there as well.  This patch does so, printing a mere
warning when finding NOPs in a too-early dtb version.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-06-25 21:39:26 -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
400bd98a3a Merge ../libfdt into dtc-libfdt-merge 2007-06-14 12:21:33 +10:00
David Gibson
23cdf2379f Move everything into a subdirectory in preparation for merge into dtc. 2007-06-14 11:58:35 +10:00
David Gibson
9481605208 libfdt: Switch to dual GPL/BSD license
Change the license information at the top of each file from LGPL to
dual-GPL/BSD.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-06-13 16:30:48 +10:00
David Gibson
a6c76f923d libfdt: More thorough use of constification
As a read-only functions, which take a const pointer to the fdt, treat
fdt_get_property() and fdt_getprop() as returning const pointers to
within the blob.  fdt_get_property_w() and fdt_getprop_w() versions
are supplied which take a non-const fdt pointer and return a non-const
pointer for the benefit of callers wishing to alter the device tree
contents.

Likewise the lower-level fdt_offset_ptr() and _fdt_offset_ptr()
functions are changed to return const pointers, with *_w() versions
supplied.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-06-13 14:18:10 +10:00
Milton Miller
ce243227f1 dtc: parse NOP in dtb input
Version 16 and later of the flat device tree format allow NOPs
to be placed in the tree.  When processing dtb input, dtc must
recognise them.

Previously it would produce the error message
FATAL ERROR: Invalid opcode word 00000004 in device tree blob

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-06-11 08:40:00 -05:00
David Gibson
41eecd4c2a dtc: Fix recognition of whitespace characters
At present, the lexer in dtc recognizes only space, tab and newline as
whitespace characters.  This is broken; in particular this means that
dtc will get syntax errors on files with DOS-style (CR-LF) newlines.

This patch fixes the problem, using flex's built-int [:space:]
character class.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-06-06 21:51:49 -05:00
Jerry Van Baren
7ea144f4c0 Fix the -S to modify the totalsize properly.
With the last improvement to pad out the blob, I broke the blob
header totalsize adjustment.  The adjustment was moved up in the
code before the memory image of the blob is created.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-04-20 08:43:45 -05:00
Jerry Van Baren
86c01ee6df Assemble the blob in memory before writing it out.
This makes padding out the blob if the user requested extra size much
easer.  The assembly and writing to the file is more straight forward too.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2007-04-19 17:24:52 -05:00
Jerry Van Baren
ca25e54ddd Fix reserve map output for asm format.
Add extra reserve map slots output for asm format (previously done for dtb
  output).

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-04-19 17:19:57 -05:00
Jerry Van Baren
4f5370a138 Add -o <output file> to the usage message.
Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2007-04-19 17:17:51 -05:00
Jerry Van Baren
4384b23454 Implement the -R option and add a -S option.
Implement the -R <number> option to add memory reserve slots.
Add a -S <size> option makes the blob at least this number of bytes.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-04-05 09:57:55 -05:00
Jon Loeliger
ce34ae3b23 DTC: Incorporate some review suggestions.
- Change include syntax to:  /include/ "filename"
    - Move private functions directly into dtc-lexer.l
    - Define YYID for some older parser templates

Also fix a #include ordering problem around YYLTPE.

Signed-off-by; Jon Loeliger <jdl@freescale.com>
Acked-by: Haiying Wang <Haiying.Wang@freescale.com>
2007-03-28 17:07:44 -05:00
Jon Loeliger
e45e6fd274 DTC: Add support for a C-like #include "file" mechanism.
Keeps track of open files in a stack, and assigns
a filenum to source positions for each lexical token.
Modified error reporting to show source file as well.
No policy on file directory basis has been decided.
Still handles stdin.

Tested on all arch/powerpc/boot/dts DTS files

Signed-off-by: Jon Loeliger <jdl@freescale.com>
2007-03-26 08:36:07 -05:00
Scott Wood
b29597d9a3 Remove bogus errors from check_chosen.
It is not an error for /chosen (or any of its children) to be missing.

It is not a requirement that the output of dtc be a complete, valid
device tree, as it may be intended that the dtb be passed through boot
code that will complete it.  Thus, do not complain.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2007-03-26 08:34:23 -05:00
David Gibson
857f54e79f libfdt: Remove #includes from fdt.h
At present fdt.h #includes stdint.h.  This makes some sense, because fdt.h
uses the standard fixed-width integer types.  However, this can make life
difficult when building in different environments which may not have a
stdint.h.  Therefore, this patch removes the #include from fdt.h, instead
requiring that users of fdt.h define the fixed-width integer types before
including fdt.h, either by themselves including stdint.h, or by any other
means.
2007-03-23 15:16:54 +11:00
Ed Swarthout
001430072f ftdump missing be32_to_cpu() on size cell. 2007-03-22 08:30:52 -05:00
Jerry Van Baren
cd1da87116 Improve options, #define default version.
Add -h option for help
Add -q quiet option to reduce or suppress the whining
Create #define for the default version value.

Signed-off-by: vanbaren@cideas.com <vanbaren@cideas.com>
2007-03-19 08:54:40 -05:00
David Gibson
b299ac76a7 Get rid of libdt.c
libdt.c was an attempt at creating a device tree handling library
within the dtc codebase.  However, it was never even close to
completion, and is entirely obsoleted by it's spiritual descendent,
libfdt (currently a separate package).  This patch, therefore, removes
libdt.c entirely, along with its only reference in the Makefile, an
unused variable.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-03-14 15:36:42 -05:00
David Gibson
46c88dfcca Add support for flat device tree format version 17
libfdt defined a new version of the flattened device tree format,
version 17.  It is backwards compatible with version 16, just adding
an extra header field giving the size of the blob's structure blob.

This patch adds support to dtc allowing it to read and write version
17 blobs.  It also makes version 17 the default output version for
blobs.

At the same time we change the code to consistently using decimal
numbers for versions.  Previously we sometimes used 16 and sometimes
0x10 to refer to version 16.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-03-14 15:36:37 -05:00
David Gibson
6ae55f9f9b Fix flat_dt_property structure
The structure in flat_dt.h defining the layout of a proprety within
the flat device tree is incorrect.  It has the offset to the
property's name, then the length when in fact (according to
booting-without-of.txt and the output of dtc) then length should come
first, followed by the name offset.

In fact, this structure is never used so the mistake doesn't break
anything, but it should still be fixed to avoid misleading people.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-02-27 08:46:55 -06:00
David Gibson
07a12a0800 libfdt: Use correct property format
Since its beginning, libfdt has used an incorrect definition of the
format for a property, putting the name offset before length, rather
than the other way around as described in booting-without-of.txt.

This corrects the error, making libfdt actually produce and use trees
which are compatible with the kernel and dtc.

Signed-of-by: David Gibson <david@gibson.dropbear.id.au>
2007-02-23 14:40:14 +11:00