summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2013-06-22Tag Version 1.4.0HEADv1.4.0masterJon Loeliger1-1/+1
Signed-off-by: Jon Loeliger <jdl@jdl.com>
2013-06-03dtc: ensure #line directives don't consume data from the next lineStephen Warren2-1/+11
Previously, the #line parsing regex ended with ({WS}+[0-9]+)?. The {WS} could match line-break characters. If the #line directive did not contain the optional flags field at the end, this could cause any integer data on the next line to be consumed as part of the #line directive parsing. This could cause syntax errors (i.e. #line parsing consuming the leading 0 from a hex literal 0x1234, leaving x1234 to be parsed as cell data, which is a syntax error), or invalid compilation results (i.e. simply consuming literal 1234 as part of the #line processing, thus removing it from the cell data). Fix this by replacing {WS} with [ \t] so that it can't match line-breaks. Convert all instances of {WS}, even though the other instances should be irrelevant for any well-formed #line directive. This is done for consistency and ultimate safety. Reported-by: Ian Campbell <Ian.Campbell@citrix.com> Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-29Add missing test binary to .gitignoreDavid Gibson1-0/+1
The subnode_iterate test binary was missing from .gitignore, this fixes it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-29fdtput: expand fdt if value does not fitSrinivas Kandagatla2-15/+65
If you try to insert a new node or extend a property with large value, using fdtput you will notice that it always fails. example: fdtput -v -p -ts ./tst.dtb "/node-1" "property-1" "value-1 Error at 'node-1': FDT_ERR_NOSPACE or fdtput -v -c ./tst.dtb "/node-1" Error at 'node-1': FDT_ERR_NOSPACE or fdtput -v -ts ./tst.dtb "/node" "property" "very big value" Decoding value: string: 'very big value' Value size 15 Error at 'property': FDT_ERR_NOSPACE All these error are returned from libfdt, as the size of the fdt passed has no space to accomdate these new properties. This patch adds realloc functions in fdtput to allocate new space in fdt when it detects a shortage in space for new value or node. With this patch, fdtput can insert a new node or property or extend a property with new value greater than original size. Also it packs the final blob to clean up any extra padding. Without this patch fdtput tool complains with FDT_ERR_NOSPACE when we try to add a node/property or extend the value of a property. Testcases for the new behaviour added by David Gibson. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-29Remove some tests for misfeaturesDavid Gibson1-4/+0
There are a couple of fdtput related tests which are rather pointless - they explicitly test for the presence of an undesirable limitation in fdtput, which will cause test failures when we fix it. This patch removes the tests. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-29Use shorten_echo for wrap_testsDavid Gibson1-1/+1
We have certain tests which generate extremely long command lines, which are shortened in the testsuite output with the 'shorten_echo' function. Currently that is used in run_fdtput_test and run_wrap_test, this patch uses it for run_wrap_test as well, allowing more general tests with long command lines. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-24fdtdump: add a debug modeMike Frysinger1-4/+37
When hacking raw fdt files, it's useful to know the actual offsets into the file each node appears. Add a --debug mode that includes this. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-24util: add common ARRAY_SIZE defineMike Frysinger3-3/+2
I want to use this in more places, so put it in util.h rather than copying & pasting it into another file. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-24util: drop "long" from usage helpersMike Frysinger7-24/+24
Now that all utils have converted to the new usage framework, we can rename to just plain "usage()" and avoid naming conflicts. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-24dtc/fdt{get, put}/convert-dtsv0-lexer: convert to new usage helpersMike Frysinger5-127/+131
This helps standardize the flag processing and the usage screens. Only lightly tested; would be great if someone who uses these utils could double check. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-24fdtdump: add a --scan optionMike Frysinger1-2/+44
Often times, fdts get embedded in other larger files. Rather than force people to `dd` the blob out themselves, make the fdtdump file smarter. It can now scan the blob looking for the fdt magic. Once locate, it does a little validation on the main struct to make sure we didn't hit random binary data. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-24fdtdump: make usage a bit more friendlyMike Frysinger3-8/+138
This starts a new usage framework and then cuts fdtdump over to it. Now we can do `fdtdump -h` and get something useful back. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-04-28libfdt: Add fdt_next_subnode() to permit easy subnode iterationSimon Glass6-1/+193
Iterating through subnodes with libfdt is a little painful to write as we need something like this: for (depth = 0, count = 0, offset = fdt_next_node(fdt, parent_offset, &depth); (offset >= 0) && (depth > 0); offset = fdt_next_node(fdt, offset, &depth)) { if (depth == 1) { /* code body */ } } Using fdt_next_subnode() we can instead write this, which is shorter and easier to get right: for (offset = fdt_first_subnode(fdt, parent_offset); offset >= 0; offset = fdt_next_subnode(fdt, offset)) { /* code body */ } Also, it doesn't require two levels of indentation for the loop body. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-04-22utilfdt_read: pass back up the length of data readMike Frysinger2-3/+29
For a follow up commit, we want to be able to scan the buffer that was returned to us. In order to do that safely, we need to know how big the buffer actually is, so create a new set of funcs to pass that back. Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-04-22Revert "utilfdt_read: pass back up the length of data read"Jon Loeliger5-12/+8
This reverts commit cc2c178727cdeca4eb9756637c2e09e50e0856e7. It was the wrong version of the patch.
2013-04-21util_version: new helper for displaying version infoMike Frysinger3-4/+13
This is so all utilities can have this flag and not just dtc. Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-04-21die: constify format string argMike Frysinger1-1/+1
We only display this string, so there's no need for it to be writable. Constify away! Acked-by: David Gibson <David@gibson.dropbear.id.au> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-04-21utilfdt_read: pass back up the length of data readMike Frysinger5-8/+12
For a follow up commit, we want to be able to scan the buffer that was returned to us. In order to do that safely, we need to know how big the buffer actually is, so pass that back if requested. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-04-21utilfdt_read_err: use xmalloc funcsMike Frysinger1-2/+2
We've got these handy helpers, so let's use them. Acked-by: David Gibson <David@gibson.dropbear.id.au> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-02-18Added license header to dtc/libfdt/fdt.h and libfdt_env.hJustin Sobota2-0/+102
This commit adds a license header to fdt.h and libfdt_env.h because the license was omitted. Signed-off-by: Justin Sobota <jsobota@ti.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-02-03Fix typoFrançois Revol1-1/+1
Signed-off-by: François Revol <revol@free.fr>
2013-01-27Export fdt_stringlist_contains()Simon Glass2-3/+16
This function is useful outside libfdt, so export it. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-27.gitignore: Add rule for *.patchSimon Glass1-0/+1
Ignore any patch files that we find, since these are likely to be used when sending patches upstream. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-27Move property-printing into utilSimon Glass3-36/+52
The function that prints a property can be useful to other programs, so move it into util. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-27Adjust util_is_printable_string() comment and fix testSimon Glass2-4/+7
This commit which changed the behaviour of this function broke one of the tests. Also the comment should be updated to reflect its new behaviour. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-06fdtget-runtest.sh: use printf instead of /bin/echo -eStephen Warren1-1/+1
Not all /bin/echo implementations support the -e option. Instead, use printf, which appears to be more widely available than /bin/echo -e. See commit eaec1db "fdtget-runtest.sh: Fix failures when /bin/sh isn't bash" for history. I have tested this on Ubuntu 10.04 with /bin/sh pointing to both dash and bash. Reported-by: Mike Frysinger <vapier@gentoo.org> # and implemented-by Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-06dtc: Drop the '-S is deprecated' warningKRONSTORFER Horst1-3/+0
The 'deprecated' warning is in there for more than 4 years now and nobody seemed to be confused enough to vote it out. Let's drop the warning then. This reverts commit 315c5d095ebdf29f1912186e76ab9f95e694b18a. Signed-off-by: Horst Kronstorfer <hkronsto@frequentis.com>
2013-01-06dtc/libfdt: sparse fixesKim Phillips6-23/+23
libfdt/fdt.c:104:28: warning: incorrect type in argument 1 (different base types) libfdt/fdt.c:104:28: expected restricted fdt32_t [usertype] x libfdt/fdt.c:104:28: got unsigned int const [unsigned] [usertype] <noident> libfdt/fdt.c:124:40: warning: incorrect type in argument 1 (different base types) libfdt/fdt.c:124:40: expected restricted fdt32_t [usertype] x libfdt/fdt.c:124:40: got unsigned int const [unsigned] [usertype] <noident> libfdt/fdt_ro.c:337:29: warning: incorrect type in argument 1 (different base types) libfdt/fdt_ro.c:337:29: expected restricted fdt32_t [usertype] x libfdt/fdt_ro.c:337:29: got unsigned int const [unsigned] [usertype] <noident> libfdt/fdt_rw.c:370:17: warning: incorrect type in assignment (different base types) libfdt/fdt_rw.c:370:17: expected unsigned int [unsigned] [usertype] <noident> libfdt/fdt_rw.c:370:17: got restricted fdt32_t libfdt/fdt_sw.c:164:13: warning: incorrect type in assignment (different base types) libfdt/fdt_sw.c:164:13: expected unsigned int [unsigned] [usertype] <noident> libfdt/fdt_sw.c:164:13: got restricted fdt32_t libfdt/fdt_sw.c:227:14: warning: incorrect type in assignment (different base types) libfdt/fdt_sw.c:227:14: expected unsigned int [unsigned] [usertype] <noident> libfdt/fdt_sw.c:227:14: got restricted fdt32_t libfdt/fdt_wip.c:80:20: warning: incorrect type in assignment (different base types) libfdt/fdt_wip.c:80:20: expected unsigned int [unsigned] [usertype] <noident> libfdt/fdt_wip.c:80:20: got restricted fdt32_t libfdt/libfdt.h:1001:13: warning: incorrect type in assignment (different base types) libfdt/libfdt.h:1001:13: expected unsigned long [unsigned] [usertype] val libfdt/libfdt.h:1001:13: got restricted fdt64_t libfdt/libfdt.h:1157:13: warning: incorrect type in assignment (different base types) libfdt/libfdt.h:1157:13: expected unsigned int [unsigned] [usertype] val libfdt/libfdt.h:1157:13: got restricted fdt32_t libfdt/libfdt.h:1192:13: warning: incorrect type in assignment (different base types) libfdt/libfdt.h:1192:13: expected unsigned long [unsigned] [usertype] val libfdt/libfdt.h:1192:13: got restricted fdt64_t libfdt/libfdt.h:1299:13: warning: incorrect type in assignment (different base types) libfdt/libfdt.h:1299:13: expected unsigned int [unsigned] [usertype] val libfdt/libfdt.h:1299:13: got restricted fdt32_t libfdt/libfdt.h:1334:13: warning: incorrect type in assignment (different base types) libfdt/libfdt.h:1334:13: expected unsigned long [unsigned] [usertype] val libfdt/libfdt.h:1334:13: got restricted fdt64_t libfdt/libfdt.h:885:13: warning: incorrect type in assignment (different base types) libfdt/libfdt.h:885:13: expected unsigned int [unsigned] [usertype] val libfdt/libfdt.h:885:13: got restricted fdt32_t libfdt/libfdt.h:920:13: warning: incorrect type in assignment (different base types) libfdt/libfdt.h:920:13: expected unsigned long [unsigned] [usertype] val libfdt/libfdt.h:920:13: got restricted fdt64_t libfdt/libfdt.h:996:13: warning: incorrect type in assignment (different base types) libfdt/libfdt.h:996:13: expected unsigned int [unsigned] [usertype] val libfdt/libfdt.h:996:13: got restricted fdt32_t Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
2013-01-06dtc/libfdt: introduce fdt types for annotation by endian checkersKim Phillips2-32/+63
Projects such as linux and u-boot run sparse on libfdt. libfdt contains the notion of endianness via usage of endian conversion functions such as fdt32_to_cpu. As such, in order to pass endian checks, libfdt has to annotate its fdt variables such that sparse can warn when mixing bitwise and regular integers. This patch adds these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse defines), includes the bitwise annotation. Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-06dtc/fdtdump: include libfdt_env.h prior to fdt.hKim Phillips1-1/+1
in order to get the upcoming fdt type definitions. Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-06dtc/tests: don't include fdt.h prior to libfdt.hKim Phillips53-54/+0
tests will need fdt type definitions provided in a subsequent patch to libfdt_env.h. Since libfdt.h includes libfdt_env.h in the right order anyway, just remove the fdt.h include. Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-06Fix util_is_printable_stringPantelis Antoniou1-7/+13
The method used did not account for multi-part strings. Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-06fdtdump: properly handle multi-string propertiesPantelis Antoniou1-1/+11
Device tree can store multiple strings in a single property. We didn't handle that case properly. Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-10-16Add documentation on how to submit patchesMichael Ellerman1-0/+5
Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-10-16dtc: srcpos_verror() should print to stderrMichael Ellerman1-3/+3
Errors should go to stderr. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-10-08dtc: fix for_each_*() to skip first object if deletedStephen Warren4-34/+59
The previous definition of for_each_*() would always include the very first object within the list, irrespective of whether it was marked deleted, since the deleted flag was not checked on the first object, but only on any "next" object. Fix for_each_*() to check the deleted flag in the loop body every iteration to correct this. Incidentally, this change is why commit 45013d8 dtc: "Add ability to delete nodes and properties" only caused two "make checkm" failures; only two tests actually use multiple labels on the same property or node. With this current change applied, but commit 317a5d9 "dtc: zero out new label objects" reverted, "make checkm" fails 29 times; i.e. for every test that uses any labels at all. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-10-03libfdt: Added missing functions to shared libraryAnders Hedlund1-0/+6
Some API function symbols were set as 'local' causing linking errors, now they are set as global (external). Signed-off-by: Anders Hedlund <anders.hedlund@windriver.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-09-28dtc: zero out new label objectsStephen Warren1-0/+1
Without this, new->deleted may be left set to some random value, which may then cause future label references to fail to locate the label. The code that allocates properties and nodes already contains the equivalent memset(). Signed-off-by: Stephen Warren <swarren@nvidia.com>
2012-09-28dtc: cpp co-existence: add support for #line directivesStephen Warren5-0/+42
Line control directives of the following formats are supported: #line LINE "FILE" # LINE "FILE" [FLAGS] This allows dtc to consume the output of pre-processors, and to provide error messages that refer to the original filename, including taking into account any #include directives that the pre-processor may have performed. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-09-28dtc: cpp co-existence: allow names starting with # to be escapedStephen Warren6-3/+57
The device tree language as currently defined conflicts with the C pre- processor in one aspect - when a property or node name begins with a # character, a pre-processor would attempt to interpret it as a directive, fail, and most likely error out. This change allows a property/node name to be prefixed with \. This prevents a pre-processor from seeing # as the first non-whitespace character on the line, and hence prevents the conflict. \ was previously an illegal character in property/node names, so this change is backwards compatible. The \ is stripped from the name during parsing by dtc. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-09-06dtc: Add ability to delete nodes and propertiesStephen Warren10-52/+312
dtc currently allows the contents of properties to be changed, and the contents of nodes to be added to. There are situations where removing properties or nodes may be useful. This change implements the following syntax to do that: / { /delete-property/ propname; /delete-node/ nodename; }; or: /delete-node/ &noderef; Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-08-22dtc/libfdt: install missing headerYann E. MORIN1-1/+1
Previously, only two headers were installed: libfdt.h and fdt.h. But libfdt.h also #includes libfdt_env.h, which was not installed. Install this missing header too. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-07-12fdtput: Add -p option to create subnodes along entire pathSimon Glass2-4/+68
This option mimics mkdir's -p option. It automatically creates nodes as needed along the path provided. If the node already exists, no error is given. Signed-off-by: Simon Glass <sjg@chromium.org>
2012-07-12fdtput: Adjust report_error() to use name, namelen paramsSimon Glass1-7/+18
As with many fdt functions, report_error() should permit a namelen to be specified, thus obviating the need for nul termination in strings passed to it. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-07-12fdtput: Add -c option to create nodesSimon Glass2-1/+64
This option allows the creation of new nodes in a dtb file. The syntax is: fdtput -c <dtb_file> <node_path> The node_path contains the path of the node to be created. All path components up to the final one must exist already. The final one must not exist already. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-07-12fdtput: Prepare to support multiple operationsSimon Glass1-11/+26
We want to add new options to this tool. In preparation for this, add the concept of a current operation. Signed-off-by: Simon Glass <sjg@chromium.org>
2012-07-11fdtput: Fix nit in help messageSimon Glass1-1/+1
There was an extra < in the help message, so fix it. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-07-08Allow toggling of semantic checksDavid Gibson6-6/+154
This patch adds -W and -E options to dtc which allow toggling on and off of the various built in semantic checks on the tree. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-07-08Re-work level setting on checks codeDavid Gibson2-55/+63
Currently each of the semantic checks in checks.c has a "level" between IGNORE and ERROR. This single level makes it awkward to implement the semantics we want for toggling the checks on the command line. This patch reworks the code to instead have separate boolean flags for warning and error. At present having both flags set will have the same effect as having just the error flag set, but this can change in the future. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-07-08Add test for re-defining an identical labelStephen Warren2-0/+17
When merging one device tree over the top of a previous tree, it is possible to define a duplicate label that has the same name and points to the same property or node. This is currently allowed by the duplicate label checking code. However, alternative duplicate label checking algorithms might not allow this. Add an explicit test to ensure this capability is maintained. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-06-27Fix compilation warning/error in setprop_inplace.cStephen Warren1-4/+5
When compiling the current code-base with gcc 4.6.1, the following warning is raised, which is interpreted as an error: cc1: warnings being treated as errors tests/setprop_inplace.c: In function ‘main’: tests/setprop_inplace.c:62: error: format ‘%016llx’ expects type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ tests/setprop_inplace.c:68: error: format ‘%016llx’ expects type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ Use printf format specifiers from <inttypes.h> to solve this. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-06-03libfdt: Add helper function to create a trivial, empty treeDavid Gibson4-12/+87
The libfdt read/write functions are now usable enough that it's become a moderately common pattern to use them to build and manipulate a device tree from scratch. For example, we do so ourself in our rw_tree1 testcase, and qemu is starting to use this model when building device trees for some targets such as e500. However, the read/write functions require some sort of valid tree to begin with, so this necessitates either having a trivial canned dtb to begin with or, more commonly, creating an empty tree using the serial-write functions first. This patch adds a helper function which uses the serial-write functions to create a trivial, empty but complete and valid tree in a supplied buffer, ready for manipulation with the read/write functions. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-06-03libfdt: Add helpers for 64-bit integer propertiesDavid Gibson17-25/+229
In device trees in the world, properties consisting of a single 64-bit integer are not as common as those consisting of a single 32-bit, cell sized integer, but they're common enough that they're worth including convenience functions for. This patch adds helper wrappers of fdt_setprop_inplace(), fdt_setprop() and fdt_appendprop() for handling 64-bit integer quantities in properties. For better consistency with the names of these new *_u64() functions we also add *_u32() functions as alternative names for the existing *_cell() functions handling 32-bit integers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-06-03Remove test_tree1_dts0 testcasesDavid Gibson2-41/+0
The testcases based on test_tree1_dts0.dts were added purely to test dtc's backwards compatibility handling of the old dts-v0 format. Since that support has been removed, the dts has been updated to use the current dts-v1 syntax, which makes the testcases pass, but be completely useless. This patch removes the now obsolete testcases. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-04-19Add integer expressions files to .gitignoreSimon Glass1-1/+2
Several files were added, and should be in .gitignore. The *.test.dts pattern should catch future source files which are generated by tests. It also subsumes the old *.dtb.test.dts pattern. Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-19dtc: Adjust .gitignore to be in alphabetical orderSimon Glass1-2/+2
This is the intent, so correct it. Signed-off-by: Simon Glass <sjg@chromium.org>
2012-04-14dtc: Remove spurious output on stderrSimon Glass1-3/+0
Outputing to stderr is best avoided unless there is an error or warning to display. At present dtc always displays the name of the file it is compiling and the input/output formats. For example: DTC: dts->dts on file "-" This can cause problems in some build systems. For example, U-Boot shows build errors for any boards which use dtc at present. It is typically the only message output during such a build. The C compiler does not output anything in general. The current dtc behaviour makes it difficult to provide a silent build in the normal case where nothing went wrong. Remove the message entirely. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-04-10Remove invalid macro starting with _ from libfdt_env.hBert Kenward1-6/+6
libfdt_env.h in the device tree compiler currently defines a _B() macro. This is in the namespace reserved for the implementation, and Cygwin's ctype.h actually defines a macro with this name. This renames _B to EXTRACT_BYTE. Signed-off-by: Bert Kenward <bert.kenward@broadcom.com>
2012-04-09dtc: Basic integer expressionsStephen Warren5-26/+266
Written by David Gibson <david@gibson.dropbear.id.au>. Additions by me: * Ported to ToT dtc. * Renamed cell to integer throughout. * Implemented value range checks. * Allow U/L/UL/LL/ULL suffix on literals. * Enabled the commented test. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
2012-03-31fdtget-runtest.sh: Fix failures when /bin/sh isn't bashStephen Warren1-1/+1
On Ubuntu, /bin/sh is dash (at least by default), and dash's echo doesn't accept the -e option. This means that fdtget-runtest.sh's EXPECT file will contain "-e foo" rather than just "foo", which causes a test failure. To work around this, run /bin/echo instead of (builtin) echo, which has more chance of supporting the -e option. Another possible fix is to change all the #! lines to /bin/bash rather than /bin/sh, and change run_tests.sh to invoke sub-scripts using $SHELL instead of just "sh". However, that would require bash specifically, which may not be desirable. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-03-18dtc: Add -i option to support search pathsSimon Glass12-8/+168
It is often inconvenient to place device tree files in the same directory as their includes, or to specify the full path to include files. An example of this is in U-Boot where we have a .dtsi file for each SOC type, and this is included by the board .dts file. We need to either use a mechanism like: /include/ ARCH_CPU_DTS with sed or cpp to perform the replacement with the correct path, or we must specify the full path in the file: /include/ "../../arch/arm/dts/tegra20.dtsi" The first option is not desirable since it requires anyone compiling the file to first pre-process it. The second is not desirable since it introduces a path which is project-specific into a file which is supposed to be a hardware description. For example Linux and U-Boot are unlikely to put these include files in the same place. It is much more convenient to specify the search patch on the command line as is done with C pre-processors, for example. Introduce a -i option to add to the list of search paths used to find source and include files. We cannot use -I as it is already in use. Other suggestions welcome. Signed-off-by: Simon Glass <sjg@chromium.org>
2012-03-07fdtget: Add -d to provide a default valueSimon Glass2-3/+23
Sometimes the requested node or property is not present in the device tree. This option provides a way of reporting a default value in this case, rather than halting with an error. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-03-07fdtget: Add -l to list the subnodes of a nodeSimon Glass1-12/+84
This option lists the subnodes of each node given as a parameter, one subnode per line. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-03-07fdtget: Add -p to list the properties of a nodeSimon Glass1-6/+60
This option lists the properties of each node given as a parameter, one property per line. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-03-07fdtget: Fix multiple arg bug and add test for itSimon Glass3-4/+7
There is a rather unfortunate bug in fdtget in that if multiple argument sets are provided, it just repeats displaying the first set ones for each set. Fix this bug and add a test for it. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-16dtc: Fix zero-length input segfaultHorst Kronstorfer1-0/+2
This patch fixes a segmentation fault caused by dereferencing a NULL pointer (pos->file aka yylloc.file) in srcpos_string when the input length is 0 (fe 'dtc </dev/null'.) Reason: yylloc.file is initialized with 0 and the tokenizer, which updates yylloc.file via srcpos_update doesn't get a chance to run on zero-length input. Signed-off-by: Horst Kronstorfer <hkronsto@frequentis.com>
2012-02-03Fix uninitialized access bug in utilfdt_decode_typeDavid Gibson1-1/+4
I just found this little bug with valgrind. strchr() will return true if the given character is '\0'. This meant that utilfdt_decode_type() could take a path which accesses uninitialized data when given the (invalid) format string "L". Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03Generate test data for fdtput more sensiblyDavid Gibson2-26/+41
Currently run_tests.sh generates several files of text test data. The procedure it uses for this is somewhat torturous and has several problems: * Since the test data is derived from a dts file, a cursory glance at the test output suggests something is wrong with the processing of that dts. This is misleading since in fact it's just being used as an arbirary string. * Since the base input has linefeeds removed, the head and sort commands used later have no effect. * Although an attempt is made to get rid of characters which the shell will mangle, it's not thorough enough. Specifically it leaves in \ which means that some string escapes found in the input data can get expanded somewhere along the line in some shells. This patch, therefore, replaces this generation of test data with a pre-canned "Lorem ipsum" of approximately 2k. On my system, where /bin/sh is dash, this fixes a test failure due to the aforementioned string escapes being evaluated on one but not the other of the two comparison paths (I haven't tracked down exactly where the expansion is happening). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03Don't use diff to check fdt{get,put} resultsDavid Gibson2-12/+14
Currently the fdt{get,put}-runtest.sh scripts invoke diff to check if fdt{get,put} did the right thing. This isn't great though: it's not obvious from the diff output which is the expected and which is the actual result; diff's line by line behaviour is useless here, since all the results are a single line and finally, when there is a difference it always prints information even when the tests are supposed to be running in quiet mode. This patch uses cmp instead, and explicitly prints the expected results, when running in verbose mode (the invocation of fdtget itself will have already displayed the actual results in this mode. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03Clean up invocation of fdt{get,put} testsDavid Gibson4-86/+104
This patch cleans up how the fdtget and fdtput tests are invoked. Specifically we no longer hide the full command lines with a wrapper function - this makes it possible to distinguish fdtget from similar fdtput tests and makes it easier to work out how to manually invoke an individual failing test. In addition, we remove the testing for errors from the fdt{get,put}-runtest.sh script, instead using an internal wrapper analagous to run_wrap_test which can test for any program invocation that's expected to return an error. For a couple of the fdtput tests this would result in printing out ludicrously large command lines. Therefore we introduce a new mechanism to cut those down to something reasonable. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03Factor signal checks out of test scriptsDavid Gibson4-16/+13
Several test scripts now have some code to check for a program returning a signal, and reporting a suitable failure. This patch moves this duplicated code into a helper function in tests.sh. At the same time we remove a bashism found in the current copies (using the non portablr $[ ] construct for arithmetic). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03Remove bashism from run_tests.shDavid Gibson1-1/+1
The patches introducing fdtget and fdtput inserted a peculiar bashism to run_tests.sh using non-portable assignment within an (( )) expression. This patch fixes it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03Use 'trap' builtin to clean up temporaries in test scriptsDavid Gibson3-16/+10
Some of the test scripts create temporary files, which we remove at the end. Except that we usually forgot to remove them on some exit paths. To avoid this problem in future, this modifies the scripts to use the shell's trap 0 functionality to automatically remove the temporaries on any exit. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03Remove unused variable from test scriptsDavid Gibson3-3/+3
Several of the test scripts remove $TMPFILE, without ever having set the TMPFILE variable. This patch fixes it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03Trivial style fixupDavid Gibson1-2/+2
Having braces on an if branch but not the else branch, or vice versa is ugly and can trick you when reading the code. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03Add quilt files to .gitignoreDavid Gibson1-0/+2
For the benefit of quilt users (such as myself, sometimes) have git ignore the quilt control and patches files. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03Update .gitignore for testsDavid Gibson1-0/+3
We've add some test (generated) binaries that aren't currently listed in .gitignore, in addition more scripts now generate various tmp.* files during operation. This adds them all to .gitignore. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-01-21Introduce ${TESTS_BIN} in Makefiles to identify tested executables.Jon Loeliger2-3/+9
2012-01-21Add fdtput utility to write property values to a device treeSimon Glass7-1/+375
This simple utility allows writing of values into a device tree from the command line. It aimes to be the opposite of fdtget. What is it for: - Updating fdt values when a binary blob already exists (even though source may be available it might be easier to use this utility rather than sed, etc.) - Writing machine-specific fdt values within a build system To use it, specify the fdt binary file on command line followed by the node and property to set. Then, provide a list of values to put into that property. Often there will be just one, but fdtput also supports arrays and string lists. fdtput does not try to guess the type of the property based on looking at the arguments. Instead it always assumes that an integer is provided. To indicate that you want to write a string, use -ts. You can also provide hex values with -tx. The command line arguments are joined together into a single value. For strings, a nul terminator is placed between each string when it is packed into the property. To avoid this, pass the string as a single argument. Usage: fdtput <options> <dt file> <<node> <property> [<value>...] Options: -t <type> Type of data -v Verbose: display each value decoded from command line -h Print this help <type> s=string, i=int, u=unsigned, x=hex Optional modifier prefix: hh or b=byte, h=2 byte, l=4 byte (default) To read from stdin and write to stdout, use - as the file. So you can do: cat somefile.dtb | fdtput -ts - /node prop "My string value" > newfile.dtb This commit also adds basic tests to verify the major features. Signed-off-by: Simon Glass <sjg@chromium.org>
2012-01-21Add fdtget utility to read property values from a device treeSimon Glass8-1/+326
This simply utility makes it easy for scripts to read values from the device tree. It is written in C and uses the same libfdt as the rest of the dtc package. What is it for: - Reading fdt values from scripts - Extracting fdt information within build systems - Looking at particular values without having to dump the entire tree To use it, specify the fdt binary file on command line followed by a list of node, property pairs. The utility then looks up each node, finds the property and displays the value. Each value is printed on a new line. fdtget tries to guess the type of each property based on its contents. This is not always reliable, so you can use the -t option to force fdtget to decode the value as a string, or byte, etc. To read from stdin, use - as the file. Usage: fdtget <options> <dt file> [<node> <property>]... Options: -t <type> Type of data -h Print this help <type> s=string, i=int, u=unsigned, x=hex Optional modifier prefix: hh or b=byte, h=2 byte, l=4 byte (default) Signed-off-by: Simon Glass <sjg@chromium.org>
2012-01-13dtc: Implement -d option to write out a dependency fileStephen Warren9-1/+40
This will allow callers to rebuild .dtb files when any of the /include/d .dtsi files are modified, not just the top-level .dts file. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-01-11libfdt: Activate testcase for appending propertiesDavid Gibson2-0/+5
Commit a31e3ef83bfce62d07695355e5f06cd4d0e44b86 introduced new libfdt functions to append to existing properties. It also included a test case for this, but neglected to update the Makefile and run_tests.sh script to actually build and execute this testcase. This patch corrects the oversight. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2011-12-05libfdt: Add support for appending the values to a existing propertyMinghuan Lian5-0/+263
Some properties may contain multiple values, these values may need to be added to the property respectively. this patch provides this functionality. The main purpose of fdt_append_prop() is to append the values to a existing property, or create a new property if it dose not exist. Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2011-10-26fdtdump: rename from ftdumpMike Frysinger5-13/+13
The freetype package already installs a binary named "ftdump", so the dtc package conflicts with that. So rename the newer dtc tool to "fdtdump". This even makes a bit more sense: ftdump: [F]lat device [T]ree [dump] fdtdump: [F]lat [D]evice [T]ree [dump] Signed-off-by: Mike Frysinger <vapier@gentoo.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-10-11dtc: Add support for variable sized elementsAnton Staaf8-33/+177
Elements of size 8, 16, 32, and 64 bits are supported. The new /bits/ syntax was selected so as to not pollute the reserved keyword space with uint8/uint16/... type names. With this patch the following property assignment: property = /bits/ 16 <0x1234 0x5678 0x0 0xffff>; is equivalent to: property = <0x12345678 0x0000ffff>; It is now also possible to directly specify a 64 bit literal in a cell list, also known as an array using: property = /bits/ 64 <0xdeadbeef00000000>; It is an error to attempt to store a literal into an element that is too small to hold the literal, and the compiler will generate an error when it detects this. For instance: property = /bits/ 8 <256>; Will fail to compile. It is also an error to attempt to place a reference in a non 32-bit element. The documentation has been changed to reflect that the cell list is now an array of elements that can be of sizes other than the default 32-bit cell size. The sized_cells test tests the creation and access of 8, 16, 32, and 64-bit sized elements. It also tests that the creation of two properties, one with 16 bit elements and one with 32 bit elements result in the same property contents. Signed-off-by: Anton Staaf <robotboy@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-10-11dtc: Add data_append_integer functionAnton Staaf2-7/+33
This function deals with appending integers of various sizes (8, 16 32, and 64 bit currently). It handles endianess conversions. If the integer will not fit in the requested number of bits of storage it will have it's high bits ignored. This patch also rewrites data_append_cell and data_append_addr to use data_append_integer. Signed-off-by: Anton Staaf <robotboy@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-10-11libfdt: Add fdt16_to_cpu utility functionAnton Staaf1-0/+6
This utility routine will be used in the variable size cell literal append code. It is a straightforward adaptation of the fdt32_to_cpu function. Signed-off-by: Anton Staaf <robotboy@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-09-22ftdump: use utilfdt to read blobSimon Glass1-28/+4
Now that we have utilfdt_read(), ftdump should use it too. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-09-22Make testutils use utilfdtSimon Glass2-50/+14
The load_blob() and save_blob() functions are very similar to the utilfdt versions. This removes the duplicated code. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-09-22Add fdt read/write utility functionsSimon Glass7-20/+352
This adds higher-level libfdt operations for reading/writing an fdt blob from/to a file, as well as a function to decode a data type string as will be used by fdtget, fdtput. This also adds a few tests for the simple type argument supported by utilfdt_decode_type. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-09-22Create Makefile.utils and move ftdump into itSimon Glass3-14/+11
We want to avoid a separate Makefile include for each utility, so this sets up a general one for utilities. Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Simon Glass <sjg@chromium.org>
2011-09-22dtc: Support character literals in cell listsAnton Staaf9-1/+107
With this patch the following property assignment: property = <0x12345678 'a' '\r' 100>; is equivalent to: property = <0x12345678 0x00000061 0x0000000D 0x00000064> Signed-off-by: Anton Staaf <robotboy@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-09-17dtc: Remove gcc 4.6 "set but not used" warningsDavid Gibson3-8/+10
A number of the dtc testcases trigger the new "variable set but not used" warning from gcc 4.6. That is they have variables which are assigned, but then never read after that point. In a couple of cases this is just because the variables aren't needed, so this patch removes them. In subnode_offset.c, it's because one pair of variables we clearly intended to test we don't actually test. This patch also adds this missing check. This patch makes the testsuite compile clean with gcc 4.6. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2011-09-09dtc: Refactor character literal parsing codeAnton Staaf3-81/+111
Move the parsing of hex, octal and escaped characters from data.c to util.c where it can be used for character literal parsing within strings as well as for stand alone C style character literals. Signed-off-by: Anton Staaf <robotboy@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-07-17Add missing tests to .gitignoreSimon Glass1-0/+2
Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-07-17Split out is_printable_string() into util.cSimon Glass4-26/+44
This useful function is split out so it will be available to programs other than ftdump. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-07-17dtc: Remove unused variable in flat_read_mem_reserveJosh Boyer1-2/+0
The *p variable is declared and used to save inb->ptr, however p is later never used. This has been the case since commit 6c0f3676 and can lead to build failures with -Werror=unused-but-set-variable: flattree.c: In function 'flat_read_mem_reserve': flattree.c:700:14: error: variable 'p' set but not used [-Werror=unused-but-set-variable] cc1: all warnings being treated as errors make: *** [flattree.o] Error 1 Remove the variable. Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-07-17dtc: Remove unused check variableJosh Boyer1-5/+2
Commit 376ab6f2 removed the old style check functionality from DTC, however the check option and variable were not removed. This leads to build failures when -Werror=unused-but-set-variable is specified: dtc.c: In function 'main': dtc.c:102:17: error: variable 'check' set but not used [-Werror=unused-but-set-variable] cc1: all warnings being treated as errors make: *** [dtc.o] Error 1 make: *** Waiting for unfinished jobs.... Remove the check variable. Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-05-08Tag Version 1.3.0v1.3.0Jon Loeliger1-1/+1
Signed-off-by: Jon Loeliger <jdl@jdl.com>
2011-04-29libfdt: include version number in sonamePaolo Bonzini2-4/+6
The libfdt shared library is only installed by its unversioned name. Including it properly in a distribution requires installation of both the versioned name (used in the binary-only package) and the unversioned name (used in the development package). The latter is just a symbolic link, so you need to change the soname in turn to include the version. While at it, use Makefile variables to shorten some lines and avoid cut-and-paste typos; and clean up remnants of when shared libraries were not supported on Darwin. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-11-13dtc: Add code to make diffing trees easierDavid Gibson6-4/+196
This patch adds a "dtdiff" script to do a useful form diff of two device trees. This automatically converts the tree to dts form (if it's not already) and uses a new "-s" option in dtc to "sort" the tree. That is, it sorts the reserve entries, it sorts the properties within each node by name, and it sorts nodes by name within their parent. This gives a pretty sensible diff between the trees, which will ignore semantically null internal rearrangements (directly diffing the dts files can give a lot of noise due to the order changes). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-11-13Allow nodes to be referenced by path at the top level.John Bonesio4-4/+46
When nodes are modified by merging device trees, nodes to be updated/merged can be specified by a label. Specifying nodes by full path (instead of label) doesn't quite work. This patch fixes that. Signed-off-by: John Bonesio <bones@secretlab.ca> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2010-10-20Create new and use new print_error that uses printf style formatting.John Bonesio3-18/+33
yyerror is meant to be called by the parser internal code, and it's interface is limited. Instead create and call a new error message routine that allows formatted strings to be used. yyerror uses the new routine so error formatting remains consistent. Signed-of-by: John Bonesio <bones@secretlab.ca> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2010-09-21Add merging of labelled subnodes. This patch allows the followingDavid Gibson7-17/+73
syntax: / { child { label: subchild { }; }; }; &label { prop = "value"; }; which will result in the following tree: / { child { label: subchild { prop = "value"; }; }; }; Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2010-09-20Remove another bashism from run_tests.shDavid Gibson1-3/+3
Current we check for various error codes with [ $x == "NN" ]. However '==' is not actually a correct operator for the [ (test) command. It should be either '=' for string comparison or '-eq' for integer comparison. It appears that the bash builtin version of test implements '==' though, so we were getting away with it, as long as /bin/sh was bash - or the testsuite generated no errors. This patch fixes the usage of test so that it should work on non-bash shells. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-07-14Fix a filehandle leakMartin Ettl1-0/+1
During a check of the current git head of the linux kernel with the static code analysis tool cppcheck (http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page) the tool discovered a resource leak in linux-2.6/scripts/dtc/fstree.c. Please refer the attached patch, that fixes the issue. Fixes https://bugzilla.kernel.org/show_bug.cgi?id=15363 Signed-off-by: Martin Ettl <ettl.martin@gmx.de> Signed-off-by: Michal Marek <mmarek@suse.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-04-30dtc: Extend and better test dtbs_equal utility programs (resend)David Gibson14-32/+812
The dtbs_equal_ordered test program is used to implement a number of testcases. However, the test program itself has never been particularly well tested. In addition there are testcases coming in future for which it would be useful to have a corresponding "dtbs_equal_unordered" which checks for equality of device trees, not considering the internal ordering of elements. Finally, for some tests we may want it would be useful to check trees for equality with the PASS case being when they are *not* equal. This patch addresses all of the above. A dtbs_equal_unordered is added, and both it and the existing dtbs_equal_ordered program now take a -n option to make the PASS case be where the trees are not equal. A number of example trees with slight modifications from test_tree1 are used to verify that both these programs correctly identify when the tree is altered, and a dtb_reverse program is used to verify that the unordered version does not depend on internal ordering. These new testcases for the equality testing programs are split out into a new test group in run_tests.sh. dtbs_equal_unordered uses the new property iteration functions, and so this also acts as further testing for those functions. dtbs_equal_unordered will be useful for further testing the recently added tree-merging code and its upcoming extensions. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-04-30dtc: Add -Wredundant-decls (resend)David Gibson3-3/+3
We are almost clean already with the -Wredundant-decls warning. The only exception is a declaration for isatty() inside the flex-generated code. This can be removed by using flex's "never-interactive" option, which we probably should be using anyway, since we never parse interactively in the sense that this option implies. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-03-10libfdt: Implement property iteration functionsDavid Gibson4-36/+200
For ages, we've been talking about adding functions to libfdt to allow iteration through properties. So, finally, here are some. I got bogged down on this for a long time because I didn't want to expose offsets directly to properties to the callers. But without that, attempting to make reasonable iteration functions just became horrible. So eventually, I settled on an interface which does now expose property offsets. fdt_first_property_offset() and fdt_next_property_offset() are used to step through the offsets of the properties starting from a particularly node offset. The details of the property at each offset can then be retrieved with either fdt_get_property_by_offset() or fdt_getprop_by_offset() which have interfaces similar to fdt_get_property() and fdt_getprop() respectively. No explicit testcases are included, but we do use the new functions to reimplement the existing fdt_get_property() function. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-03-10dtc: Enable more warningsDavid Gibson5-6/+8
This patch turns on a bunch of extra gcc warnings, most of which are probably a good idea. Of the new warnings -Wnested-externs and -Wstrict-prototypes need no code changes, we're already warning-clean. The remaining one, -Wmissing-prototypes requires trivial changes in some of the tests (making functions local). This patch also rearranges the warnings flags into a separate make variable for convenience, and turns on -Werror, to really encourage people to keep the code warning-clean. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-03-03dtc: Correct headers in util.cDavid Gibson1-1/+6
Since util.c is used in programs other than full dtc, it shouldn't include the full dtc.h, just util.h which has prototypes directly relevant to it. This patch makes the change, and also adds includes of the necessary system headers which were previously included indirectly by dtc.h. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-02-25Update .gitignore filesGrant Likely2-2/+52
Filter out all the generated bits from git revision control Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2010-02-25Allow device tree to be modified by additonal device tree sectionsGrant Likely7-6/+214
This patch allows the following construct: / { property-a = "old"; property-b = "does not change"; }; / { property-a = "changed"; property-c = "new"; node-a { }; }; Where the later device tree overrides the properties found in the earlier tree. This is useful for laying down a template device tree in an include file and modifying it for a specific board without having to clone the entire tree. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2010-02-24dtc: Audit and fix valgrind errorsDavid Gibson2-3/+6
The somewhat embarrasing bug in the first version of my previous patch would have been detected by valgrind. Thus reminded, I've run the testsuite under valgrind and fixed any errors I found. This turned out to be just some uninitialized buffers in test programs. The fragments of uninitialized data aren't particularly important, but we might as well squash the valgrind warnings, so that future valgrind errors will stand out. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-02-24dtc: Allow multiple labels on nodes and propertiesDavid Gibson9-89/+157
At present, both the grammar and our internal data structures mean that there can be only one label on a node or property. This is a fairly arbitrary constraint, given that any number of value labels can appear at the same point, and that in C you can have any number of labels on the same statement. This is pretty much a non-issue now, but it may become important with some of the extensions that Grant and I have in mind. It's not that hard to change, so this patch does so, allowing an arbitrary number of labels on any given node or property. As usual a testcase is added too. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Grant Likely <grant.likely@secretlab.ca>
2010-02-23Remove obsolete references_dts0 testDavid Gibson2-29/+0
The only purpose of the dtc_references_dts0 testcase was to check handling of references in the old dts v0 syntax. Since we no longer support the old syntax, and the references_dts0.dts has been converted to the new format, it's entirely redundant. This patch removes it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-02-23Disallow re-use of the same label within a dts fileDavid Gibson11-0/+175
Currently, nothing will stop you from re-using the same label string multiple times in a dts, e.g.: / { samelabel: prop1 = "foo"; samelabel: prop2 = "bar"; }; or / { samelabel: prop1 = "foo"; samelabel: subnode { }; }; When using node references by label, this could lead to confusing results (with no warning), and in -Oasm mode will result in output which the assembler will complain about (since it too will have duplicate labels). This patch, therefore, adds code to checks.c to give errors if you attempt to re-use the same label. It treats all labels (node, property, and value) as residing in the same namespace, since the assembler will treat them so for -Oasm mode. Testcases for the new code are also added. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-02-19dtc: Automatically pick a sensible boot_cpuid_physDavid Gibson6-8/+64
Currently, when in -Idts -Odtb or -Ifs -Odtb modes, dtc always defaults to using 0 as the value for the boot_cpuid_phys header field. That's correct quite often, but there are some systems where there is no CPU with hardware ID of 0, or where we don't want to use the CPU with hardware ID 0 at all (e.g. for AMP-style partitioning). The only way to override this default currently, is with the -b command line option. This patch improves dtc to instead base the default boot_cpuid_phys value on the reg property of the first listed subnode of /cpus. This means that dtc will get boot_cpuid_phys correct by default in a greater proportion of cases (since the boot cpu is usually listed first, and this way at least the boot_cpuid_phys default will match some existing cpu node). If the node doesn't exist or has an invalid 'reg' property (missing or not 4 bytes in length), then boot_cpuid_phys is set to 0. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-02-08Modification of lexer and parser, improving dtc portability.Lukasz Wojcik2-2/+3
This mod allows successful build of dtc using both bison/flex and yacc/lex. Signed-off-by: Lukasz Wojcik <zbr@semihalf.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2010-01-14dtc: Cleanup YYLTYPE and YYLLOC_DEFAULT declarationsDavid Gibson2-56/+38
This patch makes some small cleanups to the declaration of YYLTYPE, YYLLOC_DEFAULT and related things. - We used to use undocumented magic #defines for bison, YYLTYPE_IS_DECLARED and YYLTYPE_IS_TRIVIAL. This may not be portable across bison versions. Instead define YYLTYPE as a macro in terms of struct srcpos, as the info pages suggest. - Our kernel-derived coding style discourages typedefed structures. So use 'struct srcpos' instead of 'srcpos' throughout'. - Indent the YYLLOC_DEFAULT macro according to our coding style (it was in GNU indent style, since it was taken from the example in the bison info). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-01-14dtc: Cleanup srcpos_string()David Gibson1-29/+16
There are several small problems with the current srcpos_string(). - The code unnecessarily uses a temp buffer and two rounds of *printf(); a single asprintf() will suffice. - With previous changes, pos->file->name can never be NULL, and the name field for a srcfile bound to stdin is already set to something sensible. - On allocation failure in asprintf() it returns a bogus result, instead of causing a fatal error like every other failed allocation. - The format for representing file/line/column is gratuitously different from the file/line format we used to use, and the format used by gcc and bison. This patch addresses all of these. There remains the problem that asprintf() is not portable, but that can wait until another patch. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-01-14dtc: Cleanup line number tracking, add column number trackingDavid Gibson3-9/+38
Our YYLTYPE current carries around first and last line and first and last column information. However, of these, on the first line information is actually filled in properly. Furthermore, filling in the line number information from yylineno is kind of clunky: we have to copy its value to the srcfile stack and back to handle include file positioning correctly. This patch cleans this up. We turn off flex's yylineno option and instead track the line and column number ourselves from YY_USER_ACTION. The line and column number are stored directly inside the srcfile_state structure, so it's automatically a per-file quantity. We now also fill in all the yylloc from YY_USER_ACTION. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2010-01-14dtc: Simpler interface to source file managementDavid Gibson11-233/+141
This patch cleans up our handling of input files, particularly dts source files, but also (to an extent) other input files such as those used by /incbin/ and those used in -I dtb and -I fs modes. We eliminate the current clunky mechanism which combines search paths (which we don't actually use at present) with the open relative to current source file behaviour, which we do. Instead there's a single srcfile_relative_open() entry point for callers which opens a new input file relative to the current source file (which the srcpos code tracks internally). It doesn't currently do search paths, but we can add that later without messing with the callers, by drawing the search path from a global (which makes sense anyway, rather than shuffling it around the rest of the processing code). That suffices for non-dts input files. For the actual dts files, srcfile_push() and srcfile_pop() wrappers open the file while also keeping track of it as the current source file for future opens. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-26Support ePAPR compliant phandle propertiesDavid Gibson13-30/+177
Currently, the Linux kernel, libfdt and dtc, when using flattened device trees encode a node's phandle into a property named "linux,phandle". The ePAPR specification, however - aiming as it is to not be a Linux specific spec - requires that phandles be encoded in a property named simply "phandle". This patch adds support for this newer approach to dtc and libfdt. Specifically: - fdt_get_phandle() will now return the correct phandle if it is supplied in either of these properties - fdt_node_offset_by_phandle() will correctly find a node with the given phandle encoded in either property. - By default, when auto-generating phandles, dtc will encode it into both properties for maximum compatibility. A new -H option allows either only old-style or only new-style properties to be generated. - If phandle properties are explicitly supplied in the dts file, dtc will not auto-generate ones in the alternate format. - If both properties are supplied, dtc will check that they have the same value. - Some existing testcases are updated to use a mix of old and new-style phandles, partially testing the changes. - A new phandle_format test further tests the libfdt support, and the -H option. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-17Assorted cleanups and extensions for ftdumpDavid Gibson1-17/+30
This patch makes a number of minor changes to the ftdump debugging tool. * There was an endian bug in one place, which this fixes. * We now use const qualifiers in a number of places where we can * ftdump can now be instructed to read from stdin by giving "-" as the filename. * The buffer into which the blob is read is increased from 16k to 64k, and is now dynamically allocated. * ftdump now emits source in dts-v1 format Since ftdump is little used these days, these fixes are arguably of little use. On the other hand, I already did the work of making the changes some time back, so I guess we might as well fold these small fixes and improvements in. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-11Fix dtc bugs for 64-bit compileDavid Gibson4-6/+11
I've just tested building dtc as an x86_64 binary on a 32-bit i386 host by using: make CC="gcc -m64" This patch fixes a handful of minor bugs thus discovered: * There is a printf() type mismatch on 64-bit in value-labels.c * For the tests which use libdl, we were using the GNU make feature where it will find libdl.so given a dependency in the form '-ldl'. But this built-in make logic doesn't know we're compiling 64-bit so finds the 32-bit version of the library. We avoid using this and instead explicitly pass -ldl to CC, which being the 64-bit version does know where to look. * To process dtc's asm output into .so files, run_tests.sh was directly invoking the (default instance of) the assembler and linker. Instead invoke these via the CC driver, and allow that to be overriden from the make environment. * The x86_64 assembler doesn't 0 fill with the .balign directive (presumably it is NOP filling). That doesn't produce strictly incorrect trees, but it is confusing and confounds are testcases which do byte-by-byte comparison of the trees produced by asm output with direct dtb output (which does 0 pad where necessary, of course). This patch uses the optional second argument to .balign to force gas to zero-fill instead. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-11Don't use echo -e in run_tests.shDavid Gibson1-8/+8
In one section, the run_tests script attempts to use the -e (interpret escapes) option to echo. This option is not portable - for example the echo built into dash, now the default /bin/sh on several distributions does not support it and will just echo "-e" literally. Since we don't actually use any of the escapes that -e enables, this patch simply removes it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-11Use yylloc instead of yylocDavid Gibson1-1/+1
yylloc is the correct way to get token positioning information. yyloc is a bison internal variable that only works by accident. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-11Fix bug in -Odts with properties containing multiple terminating nullsDavid Gibson5-15/+90
When in -Odts mode, dtc will not produce correct output for string-like properties which have more than one \0 character at the end of the property's bytestring. In fact, it generates output which is not syntactically correct. This patch fixes the bug, and adds a testcase for future regressions here. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-07-15add Mac OS X supportJean-Christophe PLAGNIOL-VILLARD1-3/+14
use dylib shared lib extention allow to specifiy os specific shared lib link option Mac OS use -dynamiclib instead of -shared, -install_name instead of -soname and does not support --version-script add HOSTOS macro to detect the current os you are Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2009-03-04libfdt: Fix C++ compile-time cast error on gnu 4.2.1Laurent Gregoire1-1/+1
Allow the inclusion of libfdt.h in C++ source. Signed-off-by: Laurent Gregoire <laurent.gregoire@tomtom.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2009-02-23Fix a possible overflow case detected by gcc 4.3.2Emil Medve1-1/+1
.../dtc/libfdt/fdt_sw.c: In function 'fdt_end_node': .../dtc/libfdt/fdt_sw.c:81: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
2009-02-17Fix libraries (static and dynamic) installationEmil Medve1-4/+3
Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
2009-02-06libfdt: Rework/cleanup fdt_next_tag()David Gibson5-47/+44
Currently, callers of fdt_next_tag() must usually follow the call with some sort of call to fdt_offset_ptr() to verify that the blob isn't truncated in the middle of the tag data they're going to process. This is a bit silly, since fdt_next_tag() generally has to call fdt_offset_ptr() on at least some of the data following the tag for its own operation. This patch alters fdt_next_tag() to always use fdt_offset_ptr() to verify the data between its starting offset and the offset it returns in nextoffset. This simplifies fdt_get_property() which no longer has to verify itself that the property data is all present. At the same time, I neaten and clarify the error handling for fdt_next_tag(). Previously, fdt_next_tag() could return -1 instead of a tag value in some circumstances - which almost none of the callers checked for. Also, fdt_next_tag() could return FDT_END either because it encountered an FDT_END tag, or because it reached the end of the structure block - no way was provided to tell between these cases. With this patch, fdt_next_tag() always returns FDT_END with a negative value in nextoffset for an error. This means the several places which loop looking for FDT_END will still work correctly - they only need to check for errors at the end. The errors which fdt_next_tag() can report are: - -FDT_ERR_TRUNCATED if it reached the end of the structure block instead of finding a tag. - -FDT_BADSTRUCTURE if a bad tag was encountered, or if the tag data couldn't be verified with fdt_offset_ptr(). This patch also updates the callers of fdt_next_tag(), where appropriate, to make use of the new error reporting. Finally, the prototype for the long gone _fdt_next_tag() is removed from libfdt_internal.h. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-02-06libfdt: Rework fdt_next_node()David Gibson3-48/+17
Currently fdt_next_node() will find the next node in the blob regardless of whether it is above, below or at the same level in the tree as the starting node - the depth parameter is updated to indicate which is the case. When a depth parameter is supplied, this patch makes it instead terminate immediately when it finds the END_NODE tag for a node at depth 0. In this case it returns the offset immediately past the END_NODE tag. This has a couple of advantages. First, this slightly simplifies fdt_subnode_offset(), which no longer needs to explicitly check that fdt_next_node()'s iteration hasn't left the starting node. Second, this allows fdt_next_node() to be used to implement _fdt_node_end_offset() considerably simplifying the latter function. The other users of fdt_next_node() either don't need to iterate out of the starting node, or don't pass a depth parameter at all. Any callers that really need to iterate out of the starting node, but keep tracking depth can do so by biasing the initial depth value. This is a semantic change, but I think it's very unlikely to break any existing library users. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-02-03dtc: Add testcases for labels within valuesDavid Gibson5-2/+142
This patch adds a testcase using asm output mode to check that labels within property values are correctly processed. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-02-03dtc: Make asm output more portable and add testcasesDavid Gibson6-39/+146
This patch adds some testcases for dtc's -Oasm mode. Specifically it checks that building the asm will result in the same device tree blob in memory as -Odtb mode would produce, for a variety of trees. This test uncovered two difficulties with our current -Oasm output, both of which are addressed in this patch as well. First, -Oasm output would only be correct if assembled for a big-endian target. Usually that would be the case, when building device trees into a firmware or similar. However this makes life inconvenient for testing on a little-endian target, and one can think up use cases where a program running on a little endian host might want to embed a device tree for a big-endian target. This patch therefore changes -Oasm output to use .byte directives instead of .long throughout in order to generate byte-for-byte identical trees regardless of the endianness of the assembler target. Second, -Oasm output emitted several #define statements which were then used in the innards of the output - i.e. it assumed the output would be processed by cpp before being assembled. That may not be convenient in all build environments, and in any case doesn't work well with the above fix. So, -Oasm output no longer needs to be preprocessed before assembling. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-01-07dtc: Move some functions to util.[ch]David Gibson3-50/+35
Now that we have a util.[ch] file shared between dtc and convert-dtsv0, move some functions which are currently duplicated in the two to util files. Specifically we move the die(), xmalloc() and xrealloc() functions. While we're at it, add standard double-include protection to util.h Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-01-07libfdt: Fix error in documentation for fdt_get_alias_namelen()David Gibson1-1/+1
Oops, screwed up the function name in the documenting comment for this function. Trivial correction in this patch. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-01-02libfdt: Introduce libfdt shared libraryJosh Boyer3-5/+15
Build a libfdt shared library in addition to the existing .a that is created. Symbol versioning is used from the libfdt/version.lds script. Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
2009-01-02libfdt: Add version.lds fileJosh Boyer1-0/+54
Add the initial symbol versioning file as groundwork for creating a libfdt shared library Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
2008-11-17dtc: Handle linux,phandle properties which self-referenceDavid Gibson6-9/+52
Currently, dtc will generate phandles for nodes which are referenced elsewhere in the tree. phandles can also be explicitly assigned by defining the linux,phandle property. However, there is no way, currently to tell dtc to generate a phandle for a node if it is not referenced elsewhere. This is inconvenient when it's expected that later processing on the flat tree might add nodes which _will_ the node in question. One way one might attempt to do this is with the construct: mynode: mynode { linux,phandle = <&mynode>; /* ... */ }; Though it's a trifle odd, there's really only one sensible meaning which can be assigned to this construct: allocate a unique phandle to "mynode" and put that in its linux,phandle property (as always). Currently, however, dtc will choke on this self-reference. This patch corrects this, making the construct above give the expected results. It also ensures a more meaningful error message is given if you attempt to process the nonsensical construct: mynode: mynode { linux,phandle = <&someothernode>; /* ... */ }; The 'references' testcase is extended to cover this case, as well. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-11-17dtc: Use noinput flex option for convert-dtsv0 to remove warningDavid Gibson1-1/+1
The convert-dtsv0 lexer doesn't use lex's input() macro/function. This can result in "defined but not used" warnings. This patch uses flex's noinput option to prevent this warning (as we already do for dtc-lexer.l). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-11-17dtc: Check return value from fwrite()David Gibson1-4/+7
There's one place in flattree.c where we currently ignore the return value from fwrite(). On some gcc/glibc versions, where fwrite() is declared with attribute warn_unused_result, this causes a warning. This patch fixes the warning, by checking the fwrite() result. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-11-05libfdt: Fix bug in fdt_subnode_offset_namelen()David Gibson9-11/+60
There's currently an off-by-one bug in fdt_subnode_offset_namelen() which causes it to keep searching after it's finished the subnodes of the given parent, and into the subnodes of siblings of the original node which come after it in the tree. This patch fixes the bug. It also extends the subnode_offset testcase (updating all of the 'test_tree1' example trees in the process) to catch it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-10-03Add conditionalized debug() print macro.Jon Loeliger1-0/+7
Signed-off-by: Jon Loeliger <jdl@freescale.com>
2008-10-03Remove support for the legacy DTS source file format.Jon Loeliger10-164/+77
Now that all in-kernel-tree DTS files are properly /dts-v1/, remove direct support for the older, un-numbered DTS source file format. Convert existing tests to /dts-v1/ and remove support for the conversion tests themselves. For now, though, the conversion tool still exists. Signed-off-by: Jon Loeliger <jdl@freescale.com>
2008-10-03Enhance source position implementation.Jon Loeliger3-32/+162
Implemented some print and copy routines. Made empty srcpos objects that will be used later. Protected .h file from multiple #include's. Added srcpos_error() and srcpos_warn(). Signed-off-by: Jon Loeliger <jdl@freescale.com>
2008-10-03Use flex's YY_USER_ACTION feature to avoid code duplicationJon Loeliger1-31/+5
Current, every lexer rule starts with some boiler plate to update the yylloc value for use by the parser. One of the rules, even mistakenly has a redundant allocation to one of the members. This patch uses the flex YY_USER_ACTION macro hook, which is executed before every rule to avoid this duplication. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-10-03Implement and use an xstrdup() functionJon Loeliger10-18/+82
Many places in dtc use strdup(), but none of them actually check the return value to see if the implied allocation succeeded. This is a potential bug, which we fix in the patch below by replacing strdup() with an xstrdup() which in analogy to xmalloc() will quit with a fatal error if the allocation fails. I felt the introduciton of util.[ch] was a better choice for utility oriented code than directly using srcpos.c for the new string function. This patch is a re-factoring of Dave Gibson's similar patch. Signed-off-by: Jon Loeliger <jdl@freescale.com>
2008-10-03Rearrange ftdump and convert-dtsv0 into sub-Makefiles.Jon Loeliger4-36/+63
Follows the model of the existing sub-Makefiles for dtc. Adjust $(BIN) definition to represent installable bin programs and use it as the list of installed programs rather than using an enumerated list in the install target. Adjust the tests/Makefile to clean up properly still. Signed-off-by: Jon Loeliger <jdl@freescale.com>
2008-10-03Some Documentation fixes and generalizations.Jon Loeliger1-6/+20
Updated a jdl.com URL reference. Generalized the new section IV to be "Utility Tools" and added a small blurb about ftdump as well. Signed-off-by: Jon Loeliger <jdl@jdl.com>
2008-10-03Install & document convert-dtsv0Niklaus Giger2-0/+21
Signed-off-by: Niklaus Giger <niklaus.giger@member.fsf.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2008-10-02libfdt: Add function to explicitly expand aliasesDavid Gibson5-7/+105
Kumar has already added alias expansion to fdt_path_offset(). However, in some circumstances it may be convenient for the user of libfdt to explicitly get the string expansion of an alias. This patch adds a function to do this, fdt_get_alias(), and uses it to implement fdt_path_offset(). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-09-25Fix an overflow case in fdt_offset_ptr() detected by GCC 4.3.Jon Loeliger2-2/+2
Using Gcc 4.3 detected this problem: ../dtc/libfdt/fdt.c: In function 'fdt_next_tag': ../dtc/libfdt/fdt.c:82: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false To fix the problem, treat the offset as an unsigned int. The problem report and proposed fix were provided by Steve Papacharalambous <stevep@freescale.com>. Signed-off-by: Jon Loeliger <jdl@freescale.com>
2008-09-25libfdt: Fix bugs in fdt_get_path()David Gibson2-15/+18
The current implementation of fdt_get_path() has a couple of bugs, fixed by this patch. First, contrary to its documentation, on success it returns the length of the node's path, rather than 0. The testcase is correspondingly wrong, and the patch fixes this as well. Second, in some circumstances, it will return -FDT_ERR_BADOFFSET instead of -FDT_ERR_NOSPACE when given insufficient buffer space. Specifically this happens when there is insufficient space even to hold the path's second last component. This behaviour is corrected, and the testcase updated to check it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-08-14libfdt: Add support for using aliases in fdt_path_offset()Kumar Gala5-3/+104
If the path doesn't start with '/' check to see if it matches some alias under "/aliases" and substitute the matching alias value in the path and retry the lookup. Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2008-08-13libfdt: Implement fdt_get_property_namelen() and fdt_getprop_namelen()David Gibson2-7/+60
As well as fdt_subnode_offset(), libfdt includes an fdt_subnode_offset_namelen() function that takes the subnode name to look up not as a NUL-terminated string, but as a string with an explicit length. This can be useful when the caller has the name as part of a longer string, such as a full path. However, we don't have corresponding 'namelen' versions for fdt_get_property() and fdt_getprop(). There are less obvious use cases for these variants on property names, but there are circumstances where they can be useful e.g. looking up property names which need to be parsed from a longer string buffer such as user input or a configuration file, or looking up an alias in a path with IEEE1275 style aliases. So, since it's very easy to implement such variants, this patch does so. The original NUL-terminated variants are, of course, implemented in terms of the namelen versions. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-08-13dtc: Make many functions 'static'David Gibson21-32/+34
This patch marks various functions not shared between c files 'static', as they should be. There are a couple of functions in dtc, and many in the testsuite. This is *almost* enough to enable the -Wmissing-prototypes warning. It's not quite enough, because there's a mess of junk in the flex generated code which triggers that warning which I'm not yet sure how to deal with. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-31dtc: give advance warning that "-S" is going away.Paul Gortmaker1-0/+3
The "-S" option allowed the specification of a minimum size for the blob, however the main reason for caring about the size is so there is enough padding to add a chosen node by u-boot or whoever. In which case, folks don't really care about the absolute size, but rather the size of the padding added for this -- which is what the "-p" option does. Having the "-S" just confuses people. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2008-07-31dtc: Remove unused lexer functionDavid Gibson1-1/+1
dtc does not use the input() function in flex. Apparently on some gcc versions the unused function will cause warnings. Therefore, this patch removes the function by using the 'noinput' option to flex. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-31libfdt: Forgot one function when cleaning the namespaceDavid Gibson1-2/+3
In commit b6d80a20fc293f3b995c3ce1a6744a5574192125, we renamed all libfdt functions to be prefixed with fdt_ or _fdt_ to minimise the chance of collisions with things from whatever package libfdt is embedded in, pulled into the libfdt build via that environment's libfdt_env.h. Except... I missed one. This patch applies the same treatment to _stringlist_contains(). While we're at it, also make it static since it's only used in the same file. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-25Tag Version 1.2.0v1.2.0Jon Loeliger1-1/+1
Signed-off-by: Jon Loeliger <jdl@jdl.com>
2008-07-23libfdt: Fix 'make install' target handling of .h files.Jon Loeliger2-1/+4
The definition of LIBFDT_INCLUDES was accidentally dropped. Put it back and add srcdir prefix handling for it. Signed-off-by: Jon Loeliger <jdl@freescale.com>
2008-07-14Tag Version 1.2.0-rc2v1.2.0-rc2Jon Loeliger1-1/+1
Signed-off-by: Jon Loeliger <jdl@jdl.com>
2008-07-14libfdt: Improve documentation in libfdt.hWolfram Sang1-14/+14
Fix a few typos and mistakes. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-14libfdt: Increase namespace-pollution paranoiaDavid Gibson7-122/+119
libfdt is supposed to easy to embed in projects all and sundry. Often, it won't be practical to separate the embedded libfdt's namespace from that of the surrounding project. Which means there can be namespace conflicts between even libfdt's internal/static functions and functions or macros coming from the surrounding project's headers via libfdt_env.h. This patch, therefore, renames a bunch of libfdt internal functions and macros and makes a few other chances to reduce the chances of namespace collisions with embedding projects. Specifically: - Internal functions (even static ones) are now named _fdt_*() - The type and (static) global for the error table in fdt_strerror() gain an fdt_ prefix - The unused macro PALIGN is removed - The memeq and streq macros are removed and open-coded in the users (they were only used once each) - Other macros gain an FDT_ prefix - To save some of the bulk from the previous change, an FDT_TAGALIGN() macro is introduced, where FDT_TAGALIGN(x) == FDT_ALIGN(x, FDT_TAGSIZE) Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-14dtc: Run relevant checks on dtb input as well as dtsDavid Gibson3-21/+32
This patch adjusts the testsuite to run most of the tests for the tree checking code on input in dtb form as well as dts form. Some checks which only make sense for dts input (like reference handling) are excluded, as are those which currently take dtb input because they rely on things which cannot be lexically constructed in a dts file. This shows up two small bugs in dtc, which are also corrected. First, the name_properties test which was is supposed to remove correctly formed 'name' properties (because they can be reconstructed from tne node name) was instead removing 'name' properties even if they weren't correct. Secondly, when using dtb or fs input, the runtime tree in dtc did not have the parent pointer initialized propertly because.built internally. The appropriate initialization is added to the add_child() function. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-14dtc: Enable and fix -Wcast-qual warningsDavid Gibson7-14/+15
Enabling -Wcast-qual warnings in dtc shows up a number of places where we are incorrectly discarding a const qualification. There are also some places where we are intentionally discarding the 'const', and we need an ugly cast through uintptr_t to suppress the warning. However, most of these are pretty well isolated with the *_w() functions. So in the interests of maximum safety with const qualifications, this patch enables the warnings and fixes the existing complaints. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-14dtc: Enable and fix -Wpointer-arith warningsDavid Gibson13-47/+52
This patch turns on the -Wpointer-arith option in the dtc Makefile, and fixes the resulting warnings due to using (void *) in pointer arithmetic. While convenient, pointer arithmetic on void * is not portable, so it's better that we avoid it, particularly in libfdt. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-14dtc: Clean up lexing of include filesDavid Gibson2-35/+21
Currently we scan the /include/ directive as two tokens, the "/include/" keyword itself, then the string giving the file name to include. We use a special scanner state to keep the two linked together, and use the scanner state stack to keep track of the original state while we're parsing the two /include/ tokens. This does mean that we need to enable the 'stack' option in flex, which results in a not-easily-suppressed warning from the flex boilerplate code. This is mildly irritating. However, this two-token scanning of the /include/ directive also has some extremely strange edge cases, because there are a variety of tokens recognized in all scanner states, including INCLUDE. For example the following strange dts file: /include/ /dts-v1/; / { /* ... */ }; Will be processed successfully with the /include/ being effectively ignored: the '/dts-v1/' and ';' are recognized even in INCLUDE state, then the ';' transitions us to PROPNODENAME state, throwing away INCLUDE, and the previous state is never popped off the stack. Or for another example this construct: foo /include/ = "somefile.dts" will be parsed as though it were: foo = /include/ "somefile.dts" Again, the '=' is scanned without leaving INCLUDE state, then the next string triggers the include logic. And finally, we use a different regexp for the string with the included filename than the normal string regexpt, which is also potentially weird. This patch, therefore, cleans up the lexical handling of the /include/ directive. Instead of the INCLUDE state, we instead scan the whole include directive, both keyword and filename as a single token. This does mean a bit more complexity in extracting the filename out of yytext, but I think it's worth it to avoid the strageness described above. It also means it's no longer possible to put a comment between the /include/ and the filename, but I'm really not very worried about breaking files using such a strange construct.
2008-07-14dtc: Address an assortment of portability problemsDavid Gibson8-45/+41
I've recently worked with a FreeBSD developer, getting dtc and libfdt working on FreeBSD. This showed up a number of portability problems in the dtc package which this patch addresses. Changes are as follows: - the parent_offset and supernode_atdepth_offset testcases used the glibc extension functions strchrnul() and strndupa(). Those are removed, using slightly longer coding with standard C functions instead. - some other testcases had a #define _GNU_SOURCE for no particular reason. This is removed. - run_tests.sh has bash specific constructs removed, and the interpreter changed to /bin/sh. This apparently now runs fine on FreeBSD's /bin/sh, and I've also tested it with both ash and dash. - convert-dtsv0-lexer.l has some extra #includes added. These must have been included indirectly with Linux and glibc, but aren't on FreeBSD. - the endian handling functions in libfdt_env.h, based on endian.h and byteswap.h are replaced with some portable open-coded versions. Unfortunately, these result in fairly crappy code when compiled, but as far as I can determine there doesn't seem to be any POSIX, SUS or de facto standard way of determining endianness at compile time, nor standard names for byteswapping functions. - some more endian handling, from testdata.h using the problematic endian.h is simply removed, since it wasn't actually being used anyway. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-14dtc: Use libfdt endian conversion functions in libfdtDavid Gibson1-31/+16
Following on from the last patch, which made dtc use the same endian conversion functions as libfdt, this patch makes ftdump use these functions as well. This brings us down to a single set of endian handling functions in all of dtc and libfdt, so just one place to fix things. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-14dtc: Use the same endian-conversion functions as libfdtDavid Gibson6-59/+38
Currently both libfdt and dtc define a set of endian conversion macros for accessing the device tree blob which is always big-endian. libfdt uses names like cpu_to_fdt32() and dtc uses names like cpu_to_be32 (as the Linux kernel). This patch switches dtc over to using the libfdt macros (including libfdt_env.h to supply them). This has a couple of small advantages: - Removes some code duplication - Will make conversion a bit easier if we ever need to produce little-endian device tree blobs. - dtc no longer needs to pull in netinet/in.h simply for the ntohs() and ntohl() functions Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-14dtc: Use stdint.h types throughout dtcDavid Gibson5-31/+28
Currently, dtc defines Linux-like names for various fixed-size integer types. There's no good reason to do this; even Linux itself doesn't use these names for externally visible things any more. This patch replaces these with the C99 standardized type names from stdint.h. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-07-14dtc: Testcase for /include/ directiveDavid Gibson10-0/+43
This patch adds a testcase for the /include/ directive. It assembles a sample dts file with many /include/ directives at a variety of different lexical / grammatical contexts. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-06-19Tag Version 1.2.0-rc1v1.2.0-rc1Jon Loeliger1-2/+2
Signed-off-by: Jon Loeliger <jdl@jdl.com>
2008-06-19dtc: Add support for binary includes.David Gibson8-6/+145
On Wed, Jun 04, 2008 at 09:26:23AM -0500, Jon Loeliger wrote: > David Gibson wrote: > >> But as I said that can be dealt with in the future without breaking >> compatibility. Objection withdrawn. >> > > And on that note, I officially implore Scott to > re-submit his binary include patch! Scott's original patch does still have some implementation details I didn't like. So in the interests of saving time, I've addressed some of those, added a testcase, and and now resubmitting my revised version of Scott's patch. dtc: Add support for binary includes. A property's data can be populated with a file's contents as follows: node { prop = /incbin/("path/to/data"); }; A subset of a file can be included by passing start and size parameters. For example, to include bytes 8 through 23: node { prop = /incbin/("path/to/data", 8, 16); }; As with /include/, non-absolute paths are looked for in the directory of the source file that includes them. Implementation revised, and a testcase added by David Gibson Signed-off-by: Scott Wood <scottwood@freescale.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Scott Wood <scottwood@freescale.com>
2008-06-02dtc: Add a testcase for 'reg' or 'ranges' in /David Gibson2-0/+9
This patch adds an extra testcase to dtc to ensure that the "reg_format" and "ranges_format" checks trigger as they should if a 'reg' or 'ranges' property appears in the root node. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-06-02dtc: Fix some printf() format warnings when compiling 64-bitDavid Gibson2-3/+6
Currently, dtc generates a few gcc build warnings if built for a 64-bit target, due to the altered type of uint64_t and size_t. This patch fixes the warnings (without generating new warnings for 32-bit). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-05-29dtc: Remove some small bashisms from test scriptsDavid Gibson3-3/+3
Some of the helper scripts used to run testcases contain some constructs that are bashisms. Or at least which don't work on dash, the minimal shell used as /bin/sh on recent Ubuntu systems. This patch removes these constructs so that the testsuite will pass "out of the box" on systems where /bin/sh is dash. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-05-29libfdt: Several cleanups to parameter checkingDavid Gibson5-55/+44
This patch makes a couple of small cleanups to parameter checking of libfdt functions. - In several functions which take a node offset, we use an idiom involving fdt_next_tag() first to check that we have indeed been given a node offset. This patch adds a helper function _fdt_check_node_offset() to encapsulate this usage of fdt_next_tag(). - In fdt_rw.c in several places we have the expanded version of the RW_CHECK_HEADER() macro for no particular reason. This patch replaces those instances with an invocation of the macro; that's what it's for. - In fdt_sw.c we rename the check_header_sw() function to sw_check_header() to match the analgous function in fdt_rw.c, and we provide an SW_CHECK_HEADER() wrapper macro as RW_CHECK_HEADER() functions in fdt_rw.c Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-05-29dtc: Remove reference to dead Makefile variablesDavid Gibson1-2/+1
Previous cleanups have removed the LIBFDT_CLEANFILES and DTC_CLEANFILES variables from the Makefiles. However, they're still referenced by the Makefile. This patch gets rid of these last vestiges. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-05-19dtc: Add program to convert dts files from v0 to v1David Gibson4-8/+297
This patch adds a new utility program, convert-dtsv0, to the dtc sources. This program will convert dts files from v0 to v1, preserving comments and spacing. It also includes some heuristics to guess an appropriate base to use in the v1 output (so it will use hex for the contents of reg properties and decimal for clock-frequency properties, for example). They're limited and imperfect, but not terrible. The guts of the converter program is a modified version of the lexer from dtc itself. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-05-19dtc: Rework handling of boot_cpuid_physDavid Gibson10-21/+88
Currently, dtc will put the nonsense value 0xfeedbeef into the boot_cpuid_phys field of an output blob, unless explicitly given another value with the -b command line option. As well as being a totally unuseful default value, this also means that dtc won't properly preserve the boot_cpuid_phys field in -I dtb -O dtb mode. This patch reworks things to improve the boot_cpuid handling. The new semantics are that the output's boot_cpuid_phys value is: the value given on the command line if -b is used otherwise the value from the input, if in -I dtb mode otherwise 0 Implementation-wise we do the following: - boot_cpuid_phys is added to struct boot_info, so that structure now contains all of the blob's semantic information. - dt_to_blob() and dt_to_asm() output the cpuid given in boot_info - dt_from_blob() fills in boot_info based on the input blob - The other dt_from_*() functions just record 0, but we can change this easily if e.g. we invent a way of specifying the boot cpu in the source format. - main() overrides the cpuid in the boot_info between input and output if -b is given We add some testcases to check this new behaviour. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-05-19dtc: Make dt_from_blob() open its own input file, like the other input formatsDavid Gibson3-22/+22
Currently, main() has a variable for the input file. It used to be that main() would open the input based on command line arguments before passing it to the dt_from_*() function. However, only dt_from_blob() uses this. dt_from_source() opens its own file, and dt_from_fs() interprets the argument as as a directory and does its own opendir() call. Furthermore, main() opened the file with dtc_open_file() but closed it with a direct call to fclose(). Therefore, to improve the interface consistency between the dt_from_*() functions, make dt_from_blob() open and close its own files like the other dt_from_*() functions. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-05-19dtc: Trivial formatting fixesDavid Gibson1-4/+3
This patch fixes some trivial indentation and brace/bracket style problems.
2008-05-19dtc: Clean up included Makefile fragmentsDavid Gibson4-29/+7
Currently the Makefile.dtc and Makefile.libfdt fragments include a number of things that seemed like they might be useful for other projects embedding the pieces, or for a make dist target. Well, we have no make dist target, it's become fairly unclear that these things would actually be useful to embedders (the kernel certainly doesn't use them), and it's a bunch of stuff with no current users. This patch, therefore, removes a bunch of unused definitions from the Makefile fragments. It also removes a dependency declared in Makefile.libfdt (of libfdt.a on the constituent .o files) which was incorrect (wrong path), and if corrected would be redundant with the similar dependency in the top-level makefile. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-05-19dtc: Simplify error handling for unparseable inputDavid Gibson4-7/+4
Currently, main() tests if it got a valid input tree from whichever dt_from_*() function it invoked and if not, die()s. For one thing, this test has, for no good reason, three different ways for those functions to communicate a failure to provide input (bi NULL, bi->dt NULL, or bi->error non-zero). For another, in every case save one, if the dt_from_*() functions are unable to provide input they will immediately die() (with a more specific error message) rather than proceeding to the test in main(). Therefore, this patch removes this test, making the one case that could have triggered it (in dt_from_source()) call die() directly instead. With this change, the error field in struct boot_info is now unused, so remove it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23dtc: Change exit code for usage messageDavid Gibson1-1/+1
If dtc's command line arguments are invalid, it prints a usage message and returns exit code 2. That's the same exit code as for a failed check, which is potentially confusing if running dtc from an automated harness. Therefore this patch changes the usage exit code to 3. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23dtc: Cleanup \nnn and \xNN string escape handlingDavid Gibson1-13/+6
Several small cleanups to the handling of octal and hex string escapes: - Use strncmp() instead dof what were essentially open-coded versions of the same, with short fixed lengths. - The call path to get_oct_char() means an empty escape is not possible. So replace the error message in this case with an assert. - Use die() instead of a non-fatal error message if get_hex_char() is given an empty escape. Change error message to close match gcc's in the same circumstance. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23dtc: Add some documentation for the dts formtaDavid Gibson1-0/+110
This patch adds a dts-format.txt in the Documentation directory, with an introduction to the dtc source format. Note that this documentation is also going into the upcoming ePAPR specification. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23dtc: Abolish asize field of struct dataDavid Gibson2-9/+0
The asize field in struct data is a hangover from the early days when a struct data was sometimes allowed to refer to a static chunk of memory rather than a malloc()ed block. That's long gone, since the lifetime issues were far more trouble than it was worth, so get rid of the asize field. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23dtc: Remove ugly include stack abuseDavid Gibson3-10/+8
Currently, dt_from_source() uses push_input_file() to set up the initial input file for the lexer. That sounds sensible - put the outermost input file at the bottom of the stack - until you realise that what it *actually* does is pushes the current, uninitialized, lexer input state onto the stack, then sets up the new lexer input. That necessitates an extra check in pop_input_file(), rather than signalling termination in the natural way when the include stack is empty, it has to check when it pops the bogus uninitialized state off the stack. Ick. With that fixed, push_input_file(), pop_input_file() and incl_file_stack itself become local to the lexer, so make them static. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23dtc: Make dtc_open_file() die() if unable to open requested fileDavid Gibson4-16/+6
All current callers of dtc_open_file() immediately die() if it returns an error. In a non-interative tool like dtc, it's hard to see what you could sensibly do to recover from a failure to open an input file in any case. Therefore, make dtc_open_file() itself die() if there's an error opening the requested file. This removes the need for error checking at the callsites, and ensures a consistent error message in all cases. While we're at it, change the rror message from fstree.c when we fail to open the input directory to match dtc_open_file()'s error message. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23dtc: Testcases for input handlingDavid Gibson2-0/+25
This patch adds some testcases checking corner cases of dtc's input file handling. Specifically it checks that dtc works correctly when given input via stdin, and it checks that dtc fails gracefully if given a nonexistent input file (or directory, in the case of -Ifs mode). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23dtc: Assorted improvements to test harnessDavid Gibson5-53/+78
This patch makes several small improvements to the test harness. * An altered way of invoking shell script testcases from run_tests.sh means scripts no longer need to me marked executable in the repository to work properly. * dtc.sh never did anything that was really dtc specific - with the exception of messages, it would work equally well for any binary that returns 0 in the successful case. Therefore, generalise dtc.sh and fold it into run_tests.sh so we don't need a separate script any more. * Tweak various things so that the valgrind options are properly propagated down to invoke dtc under valgrind when called via wrapper scripts. * Tweak the valgrind suppressions to work properly on a wider range of systems (this was necessary on my machine running Ubuntu Hardy). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23dtc: Make eval_literal() staticDavid Gibson1-3/+3
eval_literal() is used only in the parser, so make it a static function. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23dtc: Make -I dtb mode use fill_fullpaths()David Gibson5-45/+18
At present -I dts and -I fs modes both use the fill_fullpaths() helper function to fill in the fullpath and basenamelen fields of struct node, which are useful in later parts of the code. -I dtb mode, however, fills these in itself. This patch simplifies flattree.c by making -I dtb mode use fill_fullpaths() like the others. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-23dtc: Use for_each_marker_of_type in asm_emit_data()David Gibson1-7/+3
For no good reason, asm_emit_data() open-codes the equivalent of the for_each_marker_of_type macro. Use the macro instead. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>