summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Tag Version 1.4.0HEADv1.4.0masterJon Loeliger2013-06-221-1/+1
| | | | Signed-off-by: Jon Loeliger <jdl@jdl.com>
* dtc: ensure #line directives don't consume data from the next lineStephen Warren2013-06-032-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>
* Add missing test binary to .gitignoreDavid Gibson2013-05-291-0/+1
| | | | | | The subnode_iterate test binary was missing from .gitignore, this fixes it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* fdtput: expand fdt if value does not fitSrinivas Kandagatla2013-05-292-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>
* Remove some tests for misfeaturesDavid Gibson2013-05-291-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>
* Use shorten_echo for wrap_testsDavid Gibson2013-05-291-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>
* fdtdump: add a debug modeMike Frysinger2013-05-241-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>
* util: add common ARRAY_SIZE defineMike Frysinger2013-05-243-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>
* util: drop "long" from usage helpersMike Frysinger2013-05-247-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>
* dtc/fdt{get, put}/convert-dtsv0-lexer: convert to new usage helpersMike Frysinger2013-05-245-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>
* fdtdump: add a --scan optionMike Frysinger2013-05-241-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>
* fdtdump: make usage a bit more friendlyMike Frysinger2013-05-243-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>
* libfdt: Add fdt_next_subnode() to permit easy subnode iterationSimon Glass2013-04-286-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>
* utilfdt_read: pass back up the length of data readMike Frysinger2013-04-222-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>
* Revert "utilfdt_read: pass back up the length of data read"Jon Loeliger2013-04-225-12/+8
| | | | | This reverts commit cc2c178727cdeca4eb9756637c2e09e50e0856e7. It was the wrong version of the patch.
* util_version: new helper for displaying version infoMike Frysinger2013-04-213-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>
* die: constify format string argMike Frysinger2013-04-211-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>
* utilfdt_read: pass back up the length of data readMike Frysinger2013-04-215-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>
* utilfdt_read_err: use xmalloc funcsMike Frysinger2013-04-211-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>
* Added license header to dtc/libfdt/fdt.h and libfdt_env.hJustin Sobota2013-02-182-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>
* Fix typoFrançois Revol2013-02-031-1/+1
| | | | Signed-off-by: François Revol <revol@free.fr>
* Export fdt_stringlist_contains()Simon Glass2013-01-272-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>
* .gitignore: Add rule for *.patchSimon Glass2013-01-271-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>
* Move property-printing into utilSimon Glass2013-01-273-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>
* Adjust util_is_printable_string() comment and fix testSimon Glass2013-01-272-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>
* fdtget-runtest.sh: use printf instead of /bin/echo -eStephen Warren2013-01-061-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>
* dtc: Drop the '-S is deprecated' warningKRONSTORFER Horst2013-01-061-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>
* dtc/libfdt: sparse fixesKim Phillips2013-01-066-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>
* dtc/libfdt: introduce fdt types for annotation by endian checkersKim Phillips2013-01-062-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>
* dtc/fdtdump: include libfdt_env.h prior to fdt.hKim Phillips2013-01-061-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>
* dtc/tests: don't include fdt.h prior to libfdt.hKim Phillips2013-01-0653-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>
* Fix util_is_printable_stringPantelis Antoniou2013-01-061-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>
* fdtdump: properly handle multi-string propertiesPantelis Antoniou2013-01-061-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>
* Add documentation on how to submit patchesMichael Ellerman2012-10-161-0/+5
| | | | | Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: srcpos_verror() should print to stderrMichael Ellerman2012-10-161-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>
* dtc: fix for_each_*() to skip first object if deletedStephen Warren2012-10-084-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>
* libfdt: Added missing functions to shared libraryAnders Hedlund2012-10-031-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>
* dtc: zero out new label objectsStephen Warren2012-09-281-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>
* dtc: cpp co-existence: add support for #line directivesStephen Warren2012-09-285-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>
* dtc: cpp co-existence: allow names starting with # to be escapedStephen Warren2012-09-286-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>
* dtc: Add ability to delete nodes and propertiesStephen Warren2012-09-0610-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>
* dtc/libfdt: install missing headerYann E. MORIN2012-08-221-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>
* fdtput: Add -p option to create subnodes along entire pathSimon Glass2012-07-122-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>
* fdtput: Adjust report_error() to use name, namelen paramsSimon Glass2012-07-121-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>
* fdtput: Add -c option to create nodesSimon Glass2012-07-122-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>
* fdtput: Prepare to support multiple operationsSimon Glass2012-07-121-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>
* fdtput: Fix nit in help messageSimon Glass2012-07-111-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>
* Allow toggling of semantic checksDavid Gibson2012-07-086-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>
* Re-work level setting on checks codeDavid Gibson2012-07-082-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>
* Add test for re-defining an identical labelStephen Warren2012-07-082-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>