aboutsummaryrefslogtreecommitdiff
path: root/libfdt
AgeCommit message (Collapse)AuthorFilesLines
2009-04-01Fix 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-04-01libfdt: 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-04-01libfdt: 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>
2008-12-13Fix FIT and FDT support to have CONFIG_OF_LIBFDT and CONFIG_FIT independentJean-Christophe PLAGNIOL-VILLARD1-2/+6
FDT support is used for both FIT style images and for architectures that can pass a fdt blob to an OS (ppc, m68k, sparc). For other architectures and boards which do not pass a fdt blob to an OS but want to use the new uImage format, we just need FIT support. Now we can have the 4 following configurations : 1) FIT only CONFIG_FIT 2) fdt blob only CONFIG_OF_LIBFDT 3) both CONFIG_OF_LIBFDT & CONFIG_FIT 4) none none Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-10-30libfdt: Fix bug in fdt_subnode_offset_namelen()David Gibson1-4/+7
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. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-10-02libfdt: Add function to explicitly expand aliasesDavid Gibson1-7/+19
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-10-01Fix an overflow case in fdt_offset_ptr() detected by GCC 4.3.Jon Loeliger1-1/+1
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-10-01libfdt: Fix bugs in fdt_get_path()David Gibson1-12/+11
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-24libfdt: Add support for using aliases in fdt_path_offset()Kumar Gala1-2/+19
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> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
2008-08-24libfdt: Implement fdt_get_property_namelen() and fdt_getprop_namelen()David Gibson1-7/+30
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-24libfdt: 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-08-24libfdt: 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-08-24dtc: Enable and fix -Wcast-qual warningsDavid Gibson3-6/+7
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> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
2008-08-24dtc: Enable and fix -Wpointer-arith warningsDavid Gibson6-30/+35
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. Also add necessary definition of uintptr_t needed by David Gibson's changeset "dtc: Enable and fix -Wpointer-arith warnings" (the definition comes from stdint.h, which u-boot doesn't have). -- gvb Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2008-06-09libfdt: 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-21Big white-space cleanup.Wolfgang Denk2-3/+3
This commit gets rid of a huge amount of silly white-space issues. Especially, all sequences of SPACEs followed by TAB characters get removed (unless they appear in print statements). Also remove all embedded "vim:" and "vi:" statements which hide indentation problems. Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-03-26Merge branch 'new-image' of git://www.denx.de/git/u-boot-testingBartlomiej Sieka5-0/+20
Conflicts: common/cmd_bootm.c cpu/mpc8xx/cpu.c Signed-off-by: Bartlomiej Sieka <tur@semihalf.com>
2008-03-18libfdt: Remove no longer used code from fdt_node_offset_by_compatible()David Gibson1-11/+1
Since fdt_node_offset_by_compatible() was converted to the new fdt_next_node() iterator, a chunk of initialization code became redundant, but was not removed by oversight. This patch cleans it up. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-18libfdt: Trivial cleanup for CHECK_HEADER)David Gibson4-17/+10
Currently the CHECK_HEADER() macro is defined local to fdt_ro.c. However, there are a handful of functions (fdt_move, rw_check_header, fdt_open_into) from other files which could also use it (currently they open-code something more-or-less identical). Therefore, this patch moves CHECK_HEADER() to libfdt_internal.h and uses it in those places. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-18libfdt: Fix NOP handling bug in fdt_add_subnode_namelen()David Gibson1-1/+1
fdt_add_subnode_namelen() has a bug if asked to add a subnode to a node which has NOP tags interspersed with its properties. In this case fdt_add_subnode_namelen() will put the new subnode before the first NOP tag, even if there are properties after it, which will result in an invalid blob. This patch fixes the bug, and adds a testcase for it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-18libfdt: Add and use a node iteration helper function.David Gibson2-174/+125
This patch adds an fdt_next_node() function which can be used to iterate through nodes of the tree while keeping track of depth. This function is used to simplify the iteration code in a lot of other functions, and is also exported for use by library users. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-03-18libfdt: Add fdt_set_name() functionDavid Gibson1-0/+24
This patch adds an fdt_set_name() function to libfdt, mirroring fdt_get_name(). This is a r/w function which alters the name of a given device tree node. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-02-29libfdt: Add and use a node iteration helper function.David Gibson2-174/+125
This patch adds an fdt_next_node() function which can be used to iterate through nodes of the tree while keeping track of depth. This function is used to simplify the iteration code in a lot of other functions, and is also exported for use by library users. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-02-29[new uImage] Add libfdt support to mkimageBartlomiej Sieka5-0/+20
Signed-off-by: Bartlomiej Sieka <tur@semihalf.com>
2008-01-08LIBFDT: use memmove() instead of memcpy()Gerald Van Baren1-3/+3
This is partial patch from the DTC/libfdt commit 67b6b33b9b413a450a72135b5dc59c0a1e33e647 Author: David Gibson <david@gibson.dropbear.id.au> Date: Wed Nov 21 11:56:14 2007 +1100 The patch also fixes one genuine bug caught by valgrind - _packblocks() in fdt_rw.c was using memcpy() where it should have been using memmove(). Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-11-21Update libfdt from device tree compiler (dtc)Kumar Gala7-386/+895
Update libfdt to commit 8eaf5e358366017aa2e846c5038d1aa19958314e from the device tree compiler (dtc) project. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2007-11-21Removed some nonused fdt functions and moved fdt_find_and_setprop out of libfdtKumar Gala2-138/+0
Removed: fdt_node_is_compatible fdt_find_node_by_type fdt_find_compatible_node To ease merge of newer libfdt as we aren't using them anywhere at this time. Also moved fdt_find_and_setprop out of libfdt into fdt_support.c for the same reason. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2007-11-21[BUILD] conditionally compile libfdt/*.c in libfdt/MakefileKumar Gala7-31/+1
Modify libfdt/Makefile to conditionally compile the *.c files based on the board config. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2007-11-15Build: split COBJS value into multiple linesGrant Likely1-2/+2
This change is in preparation for condtitionial compile support in the build system. By spliting them all into seperate lines now, subsequent patches that change 'COBJS-y += ' into 'COBJS-$(CONFIG_<blah>) += ' will be less invasive and easier to review Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2007-09-06libfdt: add convenience function fdt_find_and_setprop()Grant Likely1-0/+26
Given the path to a node, fdt_find_and_setprop() allows a property value to be set directly. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2007-08-13Minor coding style cleanup. Update CHANGELOG.Wolfgang Denk1-1/+0
Signed-off-by: Wolfgang Denk <wd@denx.de>
2007-08-10For fdt_find_node_by_path(), handle the root path properly.Gerald Van Baren1-0/+4
Also removes the special case root path detection in cmd_fdt.c since it is no longer necessary. Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-08-10Add fdt_find_node_by_type() and fdt_find_compatible_node() to LIBFDTGerald Van Baren1-18/+143
Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
2007-08-10Replace fdt_node_offset() with fdt_find_node_by_path().Gerald Van Baren1-1/+1
The new name matches more closely the kernel's name, which is also a much better description. Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
2007-08-10libfdt: Conditionally compile based on CONFIG_OF_LIBFDTGerald Van Baren6-0/+31
This is the way u-boot reduces configured-out code. At Wolfgang Grandegger and Wolfgang Denk's request, make libfdt conform. Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-04-18Clenaup, update CHANGELOGWolfgang Denk2-2/+0
Signed-off-by: Wolfgang Denk <wd@denx.de>
2007-04-14Add some utilities to manipulate the reserved memory map.Gerald Van Baren2-0/+98
2007-04-06libfdt: Make fdt_check_header() publicGerald Van Baren3-5/+5
Changed _fdt_check_header() to fdt_check_header() and made it part of the interface - it is a useful routine. Also did some asthetics cleanup to the include files (headers).
2007-04-04Minor cleanup.Wolfgang Denk2-10/+7
2007-03-31Fix some minor whitespace violations.Gerald Van Baren1-2/+2
2007-03-31libfdt: Enhanced and published fdt_next_tag()Gerald Van Baren6-52/+116
Enhanced the formerly private function _fdt_next_tag() to allow stepping through the tree, used to produce a human-readable dump, and made it part of the published interface. Also added some comments.
2007-03-31libfdt: Customizations for use by u-boot.Gerald Van Baren1-76/+35
Changes to David Gibson's original source to fit into u-boot's environment. No functionality changes.
2007-03-31libfdt: Import libfdt source (2 of 2)Gerald Van Baren4-0/+860
This adds the applicable libfdt source files (unmodified) and a README to explain where the source came from.
2007-03-31libfdt: Import libfdt source (1 of 2)Gerald Van Baren5-0/+340
This adds the applicable libfdt source files (unmodified) and a README to explain where the source came from.