Home | History | Annotate | Line # | Download | only in dist
libfdt.h revision 1.1.1.1.2.3
      1  1.1.1.1.2.3  skrll /*	$NetBSD: libfdt.h,v 1.1.1.1.2.3 2017/08/28 17:52:34 skrll Exp $	*/
      2  1.1.1.1.2.3  skrll 
      3  1.1.1.1.2.2  skrll #ifndef _LIBFDT_H
      4  1.1.1.1.2.2  skrll #define _LIBFDT_H
      5  1.1.1.1.2.2  skrll /*
      6  1.1.1.1.2.2  skrll  * libfdt - Flat Device Tree manipulation
      7  1.1.1.1.2.2  skrll  * Copyright (C) 2006 David Gibson, IBM Corporation.
      8  1.1.1.1.2.2  skrll  *
      9  1.1.1.1.2.2  skrll  * libfdt is dual licensed: you can use it either under the terms of
     10  1.1.1.1.2.2  skrll  * the GPL, or the BSD license, at your option.
     11  1.1.1.1.2.2  skrll  *
     12  1.1.1.1.2.2  skrll  *  a) This library is free software; you can redistribute it and/or
     13  1.1.1.1.2.2  skrll  *     modify it under the terms of the GNU General Public License as
     14  1.1.1.1.2.2  skrll  *     published by the Free Software Foundation; either version 2 of the
     15  1.1.1.1.2.2  skrll  *     License, or (at your option) any later version.
     16  1.1.1.1.2.2  skrll  *
     17  1.1.1.1.2.2  skrll  *     This library is distributed in the hope that it will be useful,
     18  1.1.1.1.2.2  skrll  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
     19  1.1.1.1.2.2  skrll  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20  1.1.1.1.2.2  skrll  *     GNU General Public License for more details.
     21  1.1.1.1.2.2  skrll  *
     22  1.1.1.1.2.2  skrll  *     You should have received a copy of the GNU General Public
     23  1.1.1.1.2.2  skrll  *     License along with this library; if not, write to the Free
     24  1.1.1.1.2.2  skrll  *     Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
     25  1.1.1.1.2.2  skrll  *     MA 02110-1301 USA
     26  1.1.1.1.2.2  skrll  *
     27  1.1.1.1.2.2  skrll  * Alternatively,
     28  1.1.1.1.2.2  skrll  *
     29  1.1.1.1.2.2  skrll  *  b) Redistribution and use in source and binary forms, with or
     30  1.1.1.1.2.2  skrll  *     without modification, are permitted provided that the following
     31  1.1.1.1.2.2  skrll  *     conditions are met:
     32  1.1.1.1.2.2  skrll  *
     33  1.1.1.1.2.2  skrll  *     1. Redistributions of source code must retain the above
     34  1.1.1.1.2.2  skrll  *        copyright notice, this list of conditions and the following
     35  1.1.1.1.2.2  skrll  *        disclaimer.
     36  1.1.1.1.2.2  skrll  *     2. Redistributions in binary form must reproduce the above
     37  1.1.1.1.2.2  skrll  *        copyright notice, this list of conditions and the following
     38  1.1.1.1.2.2  skrll  *        disclaimer in the documentation and/or other materials
     39  1.1.1.1.2.2  skrll  *        provided with the distribution.
     40  1.1.1.1.2.2  skrll  *
     41  1.1.1.1.2.2  skrll  *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
     42  1.1.1.1.2.2  skrll  *     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
     43  1.1.1.1.2.2  skrll  *     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     44  1.1.1.1.2.2  skrll  *     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     45  1.1.1.1.2.2  skrll  *     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     46  1.1.1.1.2.2  skrll  *     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     47  1.1.1.1.2.2  skrll  *     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     48  1.1.1.1.2.2  skrll  *     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     49  1.1.1.1.2.2  skrll  *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     50  1.1.1.1.2.2  skrll  *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     51  1.1.1.1.2.2  skrll  *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     52  1.1.1.1.2.2  skrll  *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     53  1.1.1.1.2.2  skrll  *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     54  1.1.1.1.2.2  skrll  */
     55  1.1.1.1.2.2  skrll 
     56  1.1.1.1.2.2  skrll #include <libfdt_env.h>
     57  1.1.1.1.2.2  skrll #include <fdt.h>
     58  1.1.1.1.2.2  skrll 
     59  1.1.1.1.2.2  skrll #define FDT_FIRST_SUPPORTED_VERSION	0x10
     60  1.1.1.1.2.2  skrll #define FDT_LAST_SUPPORTED_VERSION	0x11
     61  1.1.1.1.2.2  skrll 
     62  1.1.1.1.2.2  skrll /* Error codes: informative error codes */
     63  1.1.1.1.2.2  skrll #define FDT_ERR_NOTFOUND	1
     64  1.1.1.1.2.2  skrll 	/* FDT_ERR_NOTFOUND: The requested node or property does not exist */
     65  1.1.1.1.2.2  skrll #define FDT_ERR_EXISTS		2
     66  1.1.1.1.2.3  skrll 	/* FDT_ERR_EXISTS: Attempted to create a node or property which
     67  1.1.1.1.2.2  skrll 	 * already exists */
     68  1.1.1.1.2.2  skrll #define FDT_ERR_NOSPACE		3
     69  1.1.1.1.2.2  skrll 	/* FDT_ERR_NOSPACE: Operation needed to expand the device
     70  1.1.1.1.2.2  skrll 	 * tree, but its buffer did not have sufficient space to
     71  1.1.1.1.2.2  skrll 	 * contain the expanded tree. Use fdt_open_into() to move the
     72  1.1.1.1.2.2  skrll 	 * device tree to a buffer with more space. */
     73  1.1.1.1.2.2  skrll 
     74  1.1.1.1.2.2  skrll /* Error codes: codes for bad parameters */
     75  1.1.1.1.2.2  skrll #define FDT_ERR_BADOFFSET	4
     76  1.1.1.1.2.2  skrll 	/* FDT_ERR_BADOFFSET: Function was passed a structure block
     77  1.1.1.1.2.2  skrll 	 * offset which is out-of-bounds, or which points to an
     78  1.1.1.1.2.2  skrll 	 * unsuitable part of the structure for the operation. */
     79  1.1.1.1.2.2  skrll #define FDT_ERR_BADPATH		5
     80  1.1.1.1.2.2  skrll 	/* FDT_ERR_BADPATH: Function was passed a badly formatted path
     81  1.1.1.1.2.2  skrll 	 * (e.g. missing a leading / for a function which requires an
     82  1.1.1.1.2.2  skrll 	 * absolute path) */
     83  1.1.1.1.2.2  skrll #define FDT_ERR_BADPHANDLE	6
     84  1.1.1.1.2.3  skrll 	/* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle.
     85  1.1.1.1.2.3  skrll 	 * This can be caused either by an invalid phandle property
     86  1.1.1.1.2.3  skrll 	 * length, or the phandle value was either 0 or -1, which are
     87  1.1.1.1.2.3  skrll 	 * not permitted. */
     88  1.1.1.1.2.2  skrll #define FDT_ERR_BADSTATE	7
     89  1.1.1.1.2.2  skrll 	/* FDT_ERR_BADSTATE: Function was passed an incomplete device
     90  1.1.1.1.2.2  skrll 	 * tree created by the sequential-write functions, which is
     91  1.1.1.1.2.2  skrll 	 * not sufficiently complete for the requested operation. */
     92  1.1.1.1.2.2  skrll 
     93  1.1.1.1.2.2  skrll /* Error codes: codes for bad device tree blobs */
     94  1.1.1.1.2.2  skrll #define FDT_ERR_TRUNCATED	8
     95  1.1.1.1.2.2  skrll 	/* FDT_ERR_TRUNCATED: Structure block of the given device tree
     96  1.1.1.1.2.2  skrll 	 * ends without an FDT_END tag. */
     97  1.1.1.1.2.2  skrll #define FDT_ERR_BADMAGIC	9
     98  1.1.1.1.2.2  skrll 	/* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a
     99  1.1.1.1.2.2  skrll 	 * device tree at all - it is missing the flattened device
    100  1.1.1.1.2.2  skrll 	 * tree magic number. */
    101  1.1.1.1.2.2  skrll #define FDT_ERR_BADVERSION	10
    102  1.1.1.1.2.2  skrll 	/* FDT_ERR_BADVERSION: Given device tree has a version which
    103  1.1.1.1.2.2  skrll 	 * can't be handled by the requested operation.  For
    104  1.1.1.1.2.2  skrll 	 * read-write functions, this may mean that fdt_open_into() is
    105  1.1.1.1.2.2  skrll 	 * required to convert the tree to the expected version. */
    106  1.1.1.1.2.2  skrll #define FDT_ERR_BADSTRUCTURE	11
    107  1.1.1.1.2.2  skrll 	/* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt
    108  1.1.1.1.2.2  skrll 	 * structure block or other serious error (e.g. misnested
    109  1.1.1.1.2.2  skrll 	 * nodes, or subnodes preceding properties). */
    110  1.1.1.1.2.2  skrll #define FDT_ERR_BADLAYOUT	12
    111  1.1.1.1.2.2  skrll 	/* FDT_ERR_BADLAYOUT: For read-write functions, the given
    112  1.1.1.1.2.2  skrll 	 * device tree has it's sub-blocks in an order that the
    113  1.1.1.1.2.2  skrll 	 * function can't handle (memory reserve map, then structure,
    114  1.1.1.1.2.2  skrll 	 * then strings).  Use fdt_open_into() to reorganize the tree
    115  1.1.1.1.2.2  skrll 	 * into a form suitable for the read-write operations. */
    116  1.1.1.1.2.2  skrll 
    117  1.1.1.1.2.2  skrll /* "Can't happen" error indicating a bug in libfdt */
    118  1.1.1.1.2.2  skrll #define FDT_ERR_INTERNAL	13
    119  1.1.1.1.2.2  skrll 	/* FDT_ERR_INTERNAL: libfdt has failed an internal assertion.
    120  1.1.1.1.2.2  skrll 	 * Should never be returned, if it is, it indicates a bug in
    121  1.1.1.1.2.2  skrll 	 * libfdt itself. */
    122  1.1.1.1.2.2  skrll 
    123  1.1.1.1.2.2  skrll /* Errors in device tree content */
    124  1.1.1.1.2.2  skrll #define FDT_ERR_BADNCELLS	14
    125  1.1.1.1.2.2  skrll 	/* FDT_ERR_BADNCELLS: Device tree has a #address-cells, #size-cells
    126  1.1.1.1.2.2  skrll 	 * or similar property with a bad format or value */
    127  1.1.1.1.2.2  skrll 
    128  1.1.1.1.2.2  skrll #define FDT_ERR_BADVALUE	15
    129  1.1.1.1.2.2  skrll 	/* FDT_ERR_BADVALUE: Device tree has a property with an unexpected
    130  1.1.1.1.2.2  skrll 	 * value. For example: a property expected to contain a string list
    131  1.1.1.1.2.2  skrll 	 * is not NUL-terminated within the length of its value. */
    132  1.1.1.1.2.2  skrll 
    133  1.1.1.1.2.3  skrll #define FDT_ERR_BADOVERLAY	16
    134  1.1.1.1.2.3  skrll 	/* FDT_ERR_BADOVERLAY: The device tree overlay, while
    135  1.1.1.1.2.3  skrll 	 * correctly structured, cannot be applied due to some
    136  1.1.1.1.2.3  skrll 	 * unexpected or missing value, property or node. */
    137  1.1.1.1.2.3  skrll 
    138  1.1.1.1.2.3  skrll #define FDT_ERR_NOPHANDLES	17
    139  1.1.1.1.2.3  skrll 	/* FDT_ERR_NOPHANDLES: The device tree doesn't have any
    140  1.1.1.1.2.3  skrll 	 * phandle available anymore without causing an overflow */
    141  1.1.1.1.2.3  skrll 
    142  1.1.1.1.2.3  skrll #define FDT_ERR_MAX		17
    143  1.1.1.1.2.2  skrll 
    144  1.1.1.1.2.2  skrll /**********************************************************************/
    145  1.1.1.1.2.2  skrll /* Low-level functions (you probably don't need these)                */
    146  1.1.1.1.2.2  skrll /**********************************************************************/
    147  1.1.1.1.2.2  skrll 
    148  1.1.1.1.2.2  skrll const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
    149  1.1.1.1.2.2  skrll static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
    150  1.1.1.1.2.2  skrll {
    151  1.1.1.1.2.2  skrll 	return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
    152  1.1.1.1.2.2  skrll }
    153  1.1.1.1.2.2  skrll 
    154  1.1.1.1.2.2  skrll uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
    155  1.1.1.1.2.2  skrll 
    156  1.1.1.1.2.2  skrll /**********************************************************************/
    157  1.1.1.1.2.2  skrll /* Traversal functions                                                */
    158  1.1.1.1.2.2  skrll /**********************************************************************/
    159  1.1.1.1.2.2  skrll 
    160  1.1.1.1.2.2  skrll int fdt_next_node(const void *fdt, int offset, int *depth);
    161  1.1.1.1.2.2  skrll 
    162  1.1.1.1.2.2  skrll /**
    163  1.1.1.1.2.2  skrll  * fdt_first_subnode() - get offset of first direct subnode
    164  1.1.1.1.2.2  skrll  *
    165  1.1.1.1.2.2  skrll  * @fdt:	FDT blob
    166  1.1.1.1.2.2  skrll  * @offset:	Offset of node to check
    167  1.1.1.1.2.2  skrll  * @return offset of first subnode, or -FDT_ERR_NOTFOUND if there is none
    168  1.1.1.1.2.2  skrll  */
    169  1.1.1.1.2.2  skrll int fdt_first_subnode(const void *fdt, int offset);
    170  1.1.1.1.2.2  skrll 
    171  1.1.1.1.2.2  skrll /**
    172  1.1.1.1.2.2  skrll  * fdt_next_subnode() - get offset of next direct subnode
    173  1.1.1.1.2.2  skrll  *
    174  1.1.1.1.2.2  skrll  * After first calling fdt_first_subnode(), call this function repeatedly to
    175  1.1.1.1.2.2  skrll  * get direct subnodes of a parent node.
    176  1.1.1.1.2.2  skrll  *
    177  1.1.1.1.2.2  skrll  * @fdt:	FDT blob
    178  1.1.1.1.2.2  skrll  * @offset:	Offset of previous subnode
    179  1.1.1.1.2.2  skrll  * @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more
    180  1.1.1.1.2.2  skrll  * subnodes
    181  1.1.1.1.2.2  skrll  */
    182  1.1.1.1.2.2  skrll int fdt_next_subnode(const void *fdt, int offset);
    183  1.1.1.1.2.2  skrll 
    184  1.1.1.1.2.3  skrll /**
    185  1.1.1.1.2.3  skrll  * fdt_for_each_subnode - iterate over all subnodes of a parent
    186  1.1.1.1.2.3  skrll  *
    187  1.1.1.1.2.3  skrll  * @node:	child node (int, lvalue)
    188  1.1.1.1.2.3  skrll  * @fdt:	FDT blob (const void *)
    189  1.1.1.1.2.3  skrll  * @parent:	parent node (int)
    190  1.1.1.1.2.3  skrll  *
    191  1.1.1.1.2.3  skrll  * This is actually a wrapper around a for loop and would be used like so:
    192  1.1.1.1.2.3  skrll  *
    193  1.1.1.1.2.3  skrll  *	fdt_for_each_subnode(node, fdt, parent) {
    194  1.1.1.1.2.3  skrll  *		Use node
    195  1.1.1.1.2.3  skrll  *		...
    196  1.1.1.1.2.3  skrll  *	}
    197  1.1.1.1.2.3  skrll  *
    198  1.1.1.1.2.3  skrll  *	if ((node < 0) && (node != -FDT_ERR_NOT_FOUND)) {
    199  1.1.1.1.2.3  skrll  *		Error handling
    200  1.1.1.1.2.3  skrll  *	}
    201  1.1.1.1.2.3  skrll  *
    202  1.1.1.1.2.3  skrll  * Note that this is implemented as a macro and @node is used as
    203  1.1.1.1.2.3  skrll  * iterator in the loop. The parent variable be constant or even a
    204  1.1.1.1.2.3  skrll  * literal.
    205  1.1.1.1.2.3  skrll  *
    206  1.1.1.1.2.3  skrll  */
    207  1.1.1.1.2.3  skrll #define fdt_for_each_subnode(node, fdt, parent)		\
    208  1.1.1.1.2.3  skrll 	for (node = fdt_first_subnode(fdt, parent);	\
    209  1.1.1.1.2.3  skrll 	     node >= 0;					\
    210  1.1.1.1.2.3  skrll 	     node = fdt_next_subnode(fdt, node))
    211  1.1.1.1.2.3  skrll 
    212  1.1.1.1.2.2  skrll /**********************************************************************/
    213  1.1.1.1.2.2  skrll /* General functions                                                  */
    214  1.1.1.1.2.2  skrll /**********************************************************************/
    215  1.1.1.1.2.2  skrll 
    216  1.1.1.1.2.2  skrll #define fdt_get_header(fdt, field) \
    217  1.1.1.1.2.2  skrll 	(fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
    218  1.1.1.1.2.3  skrll #define fdt_magic(fdt)			(fdt_get_header(fdt, magic))
    219  1.1.1.1.2.2  skrll #define fdt_totalsize(fdt)		(fdt_get_header(fdt, totalsize))
    220  1.1.1.1.2.2  skrll #define fdt_off_dt_struct(fdt)		(fdt_get_header(fdt, off_dt_struct))
    221  1.1.1.1.2.2  skrll #define fdt_off_dt_strings(fdt)		(fdt_get_header(fdt, off_dt_strings))
    222  1.1.1.1.2.2  skrll #define fdt_off_mem_rsvmap(fdt)		(fdt_get_header(fdt, off_mem_rsvmap))
    223  1.1.1.1.2.2  skrll #define fdt_version(fdt)		(fdt_get_header(fdt, version))
    224  1.1.1.1.2.3  skrll #define fdt_last_comp_version(fdt)	(fdt_get_header(fdt, last_comp_version))
    225  1.1.1.1.2.3  skrll #define fdt_boot_cpuid_phys(fdt)	(fdt_get_header(fdt, boot_cpuid_phys))
    226  1.1.1.1.2.3  skrll #define fdt_size_dt_strings(fdt)	(fdt_get_header(fdt, size_dt_strings))
    227  1.1.1.1.2.2  skrll #define fdt_size_dt_struct(fdt)		(fdt_get_header(fdt, size_dt_struct))
    228  1.1.1.1.2.2  skrll 
    229  1.1.1.1.2.2  skrll #define __fdt_set_hdr(name) \
    230  1.1.1.1.2.2  skrll 	static inline void fdt_set_##name(void *fdt, uint32_t val) \
    231  1.1.1.1.2.2  skrll 	{ \
    232  1.1.1.1.2.3  skrll 		struct fdt_header *fdth = (struct fdt_header *)fdt; \
    233  1.1.1.1.2.2  skrll 		fdth->name = cpu_to_fdt32(val); \
    234  1.1.1.1.2.2  skrll 	}
    235  1.1.1.1.2.2  skrll __fdt_set_hdr(magic);
    236  1.1.1.1.2.2  skrll __fdt_set_hdr(totalsize);
    237  1.1.1.1.2.2  skrll __fdt_set_hdr(off_dt_struct);
    238  1.1.1.1.2.2  skrll __fdt_set_hdr(off_dt_strings);
    239  1.1.1.1.2.2  skrll __fdt_set_hdr(off_mem_rsvmap);
    240  1.1.1.1.2.2  skrll __fdt_set_hdr(version);
    241  1.1.1.1.2.2  skrll __fdt_set_hdr(last_comp_version);
    242  1.1.1.1.2.2  skrll __fdt_set_hdr(boot_cpuid_phys);
    243  1.1.1.1.2.2  skrll __fdt_set_hdr(size_dt_strings);
    244  1.1.1.1.2.2  skrll __fdt_set_hdr(size_dt_struct);
    245  1.1.1.1.2.2  skrll #undef __fdt_set_hdr
    246  1.1.1.1.2.2  skrll 
    247  1.1.1.1.2.2  skrll /**
    248  1.1.1.1.2.2  skrll  * fdt_check_header - sanity check a device tree or possible device tree
    249  1.1.1.1.2.2  skrll  * @fdt: pointer to data which might be a flattened device tree
    250  1.1.1.1.2.2  skrll  *
    251  1.1.1.1.2.2  skrll  * fdt_check_header() checks that the given buffer contains what
    252  1.1.1.1.2.2  skrll  * appears to be a flattened device tree with sane information in its
    253  1.1.1.1.2.2  skrll  * header.
    254  1.1.1.1.2.2  skrll  *
    255  1.1.1.1.2.2  skrll  * returns:
    256  1.1.1.1.2.2  skrll  *     0, if the buffer appears to contain a valid device tree
    257  1.1.1.1.2.2  skrll  *     -FDT_ERR_BADMAGIC,
    258  1.1.1.1.2.2  skrll  *     -FDT_ERR_BADVERSION,
    259  1.1.1.1.2.2  skrll  *     -FDT_ERR_BADSTATE, standard meanings, as above
    260  1.1.1.1.2.2  skrll  */
    261  1.1.1.1.2.2  skrll int fdt_check_header(const void *fdt);
    262  1.1.1.1.2.2  skrll 
    263  1.1.1.1.2.2  skrll /**
    264  1.1.1.1.2.2  skrll  * fdt_move - move a device tree around in memory
    265  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree to move
    266  1.1.1.1.2.2  skrll  * @buf: pointer to memory where the device is to be moved
    267  1.1.1.1.2.2  skrll  * @bufsize: size of the memory space at buf
    268  1.1.1.1.2.2  skrll  *
    269  1.1.1.1.2.2  skrll  * fdt_move() relocates, if possible, the device tree blob located at
    270  1.1.1.1.2.2  skrll  * fdt to the buffer at buf of size bufsize.  The buffer may overlap
    271  1.1.1.1.2.2  skrll  * with the existing device tree blob at fdt.  Therefore,
    272  1.1.1.1.2.2  skrll  *     fdt_move(fdt, fdt, fdt_totalsize(fdt))
    273  1.1.1.1.2.2  skrll  * should always succeed.
    274  1.1.1.1.2.2  skrll  *
    275  1.1.1.1.2.2  skrll  * returns:
    276  1.1.1.1.2.2  skrll  *     0, on success
    277  1.1.1.1.2.2  skrll  *     -FDT_ERR_NOSPACE, bufsize is insufficient to contain the device tree
    278  1.1.1.1.2.2  skrll  *     -FDT_ERR_BADMAGIC,
    279  1.1.1.1.2.2  skrll  *     -FDT_ERR_BADVERSION,
    280  1.1.1.1.2.2  skrll  *     -FDT_ERR_BADSTATE, standard meanings
    281  1.1.1.1.2.2  skrll  */
    282  1.1.1.1.2.2  skrll int fdt_move(const void *fdt, void *buf, int bufsize);
    283  1.1.1.1.2.2  skrll 
    284  1.1.1.1.2.2  skrll /**********************************************************************/
    285  1.1.1.1.2.2  skrll /* Read-only functions                                                */
    286  1.1.1.1.2.2  skrll /**********************************************************************/
    287  1.1.1.1.2.2  skrll 
    288  1.1.1.1.2.2  skrll /**
    289  1.1.1.1.2.2  skrll  * fdt_string - retrieve a string from the strings block of a device tree
    290  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    291  1.1.1.1.2.2  skrll  * @stroffset: offset of the string within the strings block (native endian)
    292  1.1.1.1.2.2  skrll  *
    293  1.1.1.1.2.2  skrll  * fdt_string() retrieves a pointer to a single string from the
    294  1.1.1.1.2.2  skrll  * strings block of the device tree blob at fdt.
    295  1.1.1.1.2.2  skrll  *
    296  1.1.1.1.2.2  skrll  * returns:
    297  1.1.1.1.2.2  skrll  *     a pointer to the string, on success
    298  1.1.1.1.2.2  skrll  *     NULL, if stroffset is out of bounds
    299  1.1.1.1.2.2  skrll  */
    300  1.1.1.1.2.2  skrll const char *fdt_string(const void *fdt, int stroffset);
    301  1.1.1.1.2.2  skrll 
    302  1.1.1.1.2.2  skrll /**
    303  1.1.1.1.2.3  skrll  * fdt_get_max_phandle - retrieves the highest phandle in a tree
    304  1.1.1.1.2.3  skrll  * @fdt: pointer to the device tree blob
    305  1.1.1.1.2.3  skrll  *
    306  1.1.1.1.2.3  skrll  * fdt_get_max_phandle retrieves the highest phandle in the given
    307  1.1.1.1.2.3  skrll  * device tree. This will ignore badly formatted phandles, or phandles
    308  1.1.1.1.2.3  skrll  * with a value of 0 or -1.
    309  1.1.1.1.2.3  skrll  *
    310  1.1.1.1.2.3  skrll  * returns:
    311  1.1.1.1.2.3  skrll  *      the highest phandle on success
    312  1.1.1.1.2.3  skrll  *      0, if no phandle was found in the device tree
    313  1.1.1.1.2.3  skrll  *      -1, if an error occurred
    314  1.1.1.1.2.3  skrll  */
    315  1.1.1.1.2.3  skrll uint32_t fdt_get_max_phandle(const void *fdt);
    316  1.1.1.1.2.3  skrll 
    317  1.1.1.1.2.3  skrll /**
    318  1.1.1.1.2.2  skrll  * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
    319  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    320  1.1.1.1.2.2  skrll  *
    321  1.1.1.1.2.2  skrll  * Returns the number of entries in the device tree blob's memory
    322  1.1.1.1.2.2  skrll  * reservation map.  This does not include the terminating 0,0 entry
    323  1.1.1.1.2.2  skrll  * or any other (0,0) entries reserved for expansion.
    324  1.1.1.1.2.2  skrll  *
    325  1.1.1.1.2.2  skrll  * returns:
    326  1.1.1.1.2.2  skrll  *     the number of entries
    327  1.1.1.1.2.2  skrll  */
    328  1.1.1.1.2.2  skrll int fdt_num_mem_rsv(const void *fdt);
    329  1.1.1.1.2.2  skrll 
    330  1.1.1.1.2.2  skrll /**
    331  1.1.1.1.2.2  skrll  * fdt_get_mem_rsv - retrieve one memory reserve map entry
    332  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    333  1.1.1.1.2.2  skrll  * @address, @size: pointers to 64-bit variables
    334  1.1.1.1.2.2  skrll  *
    335  1.1.1.1.2.2  skrll  * On success, *address and *size will contain the address and size of
    336  1.1.1.1.2.2  skrll  * the n-th reserve map entry from the device tree blob, in
    337  1.1.1.1.2.2  skrll  * native-endian format.
    338  1.1.1.1.2.2  skrll  *
    339  1.1.1.1.2.2  skrll  * returns:
    340  1.1.1.1.2.2  skrll  *     0, on success
    341  1.1.1.1.2.2  skrll  *     -FDT_ERR_BADMAGIC,
    342  1.1.1.1.2.2  skrll  *     -FDT_ERR_BADVERSION,
    343  1.1.1.1.2.2  skrll  *     -FDT_ERR_BADSTATE, standard meanings
    344  1.1.1.1.2.2  skrll  */
    345  1.1.1.1.2.2  skrll int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);
    346  1.1.1.1.2.2  skrll 
    347  1.1.1.1.2.2  skrll /**
    348  1.1.1.1.2.2  skrll  * fdt_subnode_offset_namelen - find a subnode based on substring
    349  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    350  1.1.1.1.2.2  skrll  * @parentoffset: structure block offset of a node
    351  1.1.1.1.2.2  skrll  * @name: name of the subnode to locate
    352  1.1.1.1.2.2  skrll  * @namelen: number of characters of name to consider
    353  1.1.1.1.2.2  skrll  *
    354  1.1.1.1.2.2  skrll  * Identical to fdt_subnode_offset(), but only examine the first
    355  1.1.1.1.2.2  skrll  * namelen characters of name for matching the subnode name.  This is
    356  1.1.1.1.2.2  skrll  * useful for finding subnodes based on a portion of a larger string,
    357  1.1.1.1.2.2  skrll  * such as a full path.
    358  1.1.1.1.2.2  skrll  */
    359  1.1.1.1.2.2  skrll int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
    360  1.1.1.1.2.2  skrll 			       const char *name, int namelen);
    361  1.1.1.1.2.2  skrll /**
    362  1.1.1.1.2.2  skrll  * fdt_subnode_offset - find a subnode of a given node
    363  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    364  1.1.1.1.2.2  skrll  * @parentoffset: structure block offset of a node
    365  1.1.1.1.2.2  skrll  * @name: name of the subnode to locate
    366  1.1.1.1.2.2  skrll  *
    367  1.1.1.1.2.2  skrll  * fdt_subnode_offset() finds a subnode of the node at structure block
    368  1.1.1.1.2.2  skrll  * offset parentoffset with the given name.  name may include a unit
    369  1.1.1.1.2.2  skrll  * address, in which case fdt_subnode_offset() will find the subnode
    370  1.1.1.1.2.2  skrll  * with that unit address, or the unit address may be omitted, in
    371  1.1.1.1.2.2  skrll  * which case fdt_subnode_offset() will find an arbitrary subnode
    372  1.1.1.1.2.2  skrll  * whose name excluding unit address matches the given name.
    373  1.1.1.1.2.2  skrll  *
    374  1.1.1.1.2.2  skrll  * returns:
    375  1.1.1.1.2.2  skrll  *	structure block offset of the requested subnode (>=0), on success
    376  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, if the requested subnode does not exist
    377  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE
    378  1.1.1.1.2.3  skrll  *		tag
    379  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADMAGIC,
    380  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    381  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    382  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
    383  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings.
    384  1.1.1.1.2.2  skrll  */
    385  1.1.1.1.2.2  skrll int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
    386  1.1.1.1.2.2  skrll 
    387  1.1.1.1.2.2  skrll /**
    388  1.1.1.1.2.2  skrll  * fdt_path_offset_namelen - find a tree node by its full path
    389  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    390  1.1.1.1.2.2  skrll  * @path: full path of the node to locate
    391  1.1.1.1.2.2  skrll  * @namelen: number of characters of path to consider
    392  1.1.1.1.2.2  skrll  *
    393  1.1.1.1.2.2  skrll  * Identical to fdt_path_offset(), but only consider the first namelen
    394  1.1.1.1.2.2  skrll  * characters of path as the path name.
    395  1.1.1.1.2.2  skrll  */
    396  1.1.1.1.2.2  skrll int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
    397  1.1.1.1.2.2  skrll 
    398  1.1.1.1.2.2  skrll /**
    399  1.1.1.1.2.2  skrll  * fdt_path_offset - find a tree node by its full path
    400  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    401  1.1.1.1.2.2  skrll  * @path: full path of the node to locate
    402  1.1.1.1.2.2  skrll  *
    403  1.1.1.1.2.2  skrll  * fdt_path_offset() finds a node of a given path in the device tree.
    404  1.1.1.1.2.2  skrll  * Each path component may omit the unit address portion, but the
    405  1.1.1.1.2.2  skrll  * results of this are undefined if any such path component is
    406  1.1.1.1.2.2  skrll  * ambiguous (that is if there are multiple nodes at the relevant
    407  1.1.1.1.2.2  skrll  * level matching the given component, differentiated only by unit
    408  1.1.1.1.2.2  skrll  * address).
    409  1.1.1.1.2.2  skrll  *
    410  1.1.1.1.2.2  skrll  * returns:
    411  1.1.1.1.2.3  skrll  *	structure block offset of the node with the requested path (>=0), on
    412  1.1.1.1.2.3  skrll  *		success
    413  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADPATH, given path does not begin with '/' or is invalid
    414  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, if the requested node does not exist
    415  1.1.1.1.2.2  skrll  *      -FDT_ERR_BADMAGIC,
    416  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    417  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    418  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
    419  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings.
    420  1.1.1.1.2.2  skrll  */
    421  1.1.1.1.2.2  skrll int fdt_path_offset(const void *fdt, const char *path);
    422  1.1.1.1.2.2  skrll 
    423  1.1.1.1.2.2  skrll /**
    424  1.1.1.1.2.2  skrll  * fdt_get_name - retrieve the name of a given node
    425  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    426  1.1.1.1.2.2  skrll  * @nodeoffset: structure block offset of the starting node
    427  1.1.1.1.2.2  skrll  * @lenp: pointer to an integer variable (will be overwritten) or NULL
    428  1.1.1.1.2.2  skrll  *
    429  1.1.1.1.2.2  skrll  * fdt_get_name() retrieves the name (including unit address) of the
    430  1.1.1.1.2.2  skrll  * device tree node at structure block offset nodeoffset.  If lenp is
    431  1.1.1.1.2.2  skrll  * non-NULL, the length of this name is also returned, in the integer
    432  1.1.1.1.2.2  skrll  * pointed to by lenp.
    433  1.1.1.1.2.2  skrll  *
    434  1.1.1.1.2.2  skrll  * returns:
    435  1.1.1.1.2.2  skrll  *	pointer to the node's name, on success
    436  1.1.1.1.2.3  skrll  *		If lenp is non-NULL, *lenp contains the length of that name
    437  1.1.1.1.2.3  skrll  *			(>=0)
    438  1.1.1.1.2.2  skrll  *	NULL, on error
    439  1.1.1.1.2.2  skrll  *		if lenp is non-NULL *lenp contains an error code (<0):
    440  1.1.1.1.2.3  skrll  *		-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
    441  1.1.1.1.2.3  skrll  *			tag
    442  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADMAGIC,
    443  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADVERSION,
    444  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADSTATE, standard meanings
    445  1.1.1.1.2.2  skrll  */
    446  1.1.1.1.2.2  skrll const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);
    447  1.1.1.1.2.2  skrll 
    448  1.1.1.1.2.2  skrll /**
    449  1.1.1.1.2.2  skrll  * fdt_first_property_offset - find the offset of a node's first property
    450  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    451  1.1.1.1.2.2  skrll  * @nodeoffset: structure block offset of a node
    452  1.1.1.1.2.2  skrll  *
    453  1.1.1.1.2.2  skrll  * fdt_first_property_offset() finds the first property of the node at
    454  1.1.1.1.2.2  skrll  * the given structure block offset.
    455  1.1.1.1.2.2  skrll  *
    456  1.1.1.1.2.2  skrll  * returns:
    457  1.1.1.1.2.2  skrll  *	structure block offset of the property (>=0), on success
    458  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, if the requested node has no properties
    459  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag
    460  1.1.1.1.2.2  skrll  *      -FDT_ERR_BADMAGIC,
    461  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    462  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    463  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
    464  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings.
    465  1.1.1.1.2.2  skrll  */
    466  1.1.1.1.2.2  skrll int fdt_first_property_offset(const void *fdt, int nodeoffset);
    467  1.1.1.1.2.2  skrll 
    468  1.1.1.1.2.2  skrll /**
    469  1.1.1.1.2.2  skrll  * fdt_next_property_offset - step through a node's properties
    470  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    471  1.1.1.1.2.2  skrll  * @offset: structure block offset of a property
    472  1.1.1.1.2.2  skrll  *
    473  1.1.1.1.2.2  skrll  * fdt_next_property_offset() finds the property immediately after the
    474  1.1.1.1.2.2  skrll  * one at the given structure block offset.  This will be a property
    475  1.1.1.1.2.2  skrll  * of the same node as the given property.
    476  1.1.1.1.2.2  skrll  *
    477  1.1.1.1.2.2  skrll  * returns:
    478  1.1.1.1.2.2  skrll  *	structure block offset of the next property (>=0), on success
    479  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, if the given property is the last in its node
    480  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag
    481  1.1.1.1.2.2  skrll  *      -FDT_ERR_BADMAGIC,
    482  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    483  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    484  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
    485  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings.
    486  1.1.1.1.2.2  skrll  */
    487  1.1.1.1.2.2  skrll int fdt_next_property_offset(const void *fdt, int offset);
    488  1.1.1.1.2.2  skrll 
    489  1.1.1.1.2.2  skrll /**
    490  1.1.1.1.2.3  skrll  * fdt_for_each_property_offset - iterate over all properties of a node
    491  1.1.1.1.2.3  skrll  *
    492  1.1.1.1.2.3  skrll  * @property_offset:	property offset (int, lvalue)
    493  1.1.1.1.2.3  skrll  * @fdt:		FDT blob (const void *)
    494  1.1.1.1.2.3  skrll  * @node:		node offset (int)
    495  1.1.1.1.2.3  skrll  *
    496  1.1.1.1.2.3  skrll  * This is actually a wrapper around a for loop and would be used like so:
    497  1.1.1.1.2.3  skrll  *
    498  1.1.1.1.2.3  skrll  *	fdt_for_each_property_offset(property, fdt, node) {
    499  1.1.1.1.2.3  skrll  *		Use property
    500  1.1.1.1.2.3  skrll  *		...
    501  1.1.1.1.2.3  skrll  *	}
    502  1.1.1.1.2.3  skrll  *
    503  1.1.1.1.2.3  skrll  *	if ((property < 0) && (property != -FDT_ERR_NOT_FOUND)) {
    504  1.1.1.1.2.3  skrll  *		Error handling
    505  1.1.1.1.2.3  skrll  *	}
    506  1.1.1.1.2.3  skrll  *
    507  1.1.1.1.2.3  skrll  * Note that this is implemented as a macro and property is used as
    508  1.1.1.1.2.3  skrll  * iterator in the loop. The node variable can be constant or even a
    509  1.1.1.1.2.3  skrll  * literal.
    510  1.1.1.1.2.3  skrll  */
    511  1.1.1.1.2.3  skrll #define fdt_for_each_property_offset(property, fdt, node)	\
    512  1.1.1.1.2.3  skrll 	for (property = fdt_first_property_offset(fdt, node);	\
    513  1.1.1.1.2.3  skrll 	     property >= 0;					\
    514  1.1.1.1.2.3  skrll 	     property = fdt_next_property_offset(fdt, property))
    515  1.1.1.1.2.3  skrll 
    516  1.1.1.1.2.3  skrll /**
    517  1.1.1.1.2.2  skrll  * fdt_get_property_by_offset - retrieve the property at a given offset
    518  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    519  1.1.1.1.2.2  skrll  * @offset: offset of the property to retrieve
    520  1.1.1.1.2.2  skrll  * @lenp: pointer to an integer variable (will be overwritten) or NULL
    521  1.1.1.1.2.2  skrll  *
    522  1.1.1.1.2.2  skrll  * fdt_get_property_by_offset() retrieves a pointer to the
    523  1.1.1.1.2.2  skrll  * fdt_property structure within the device tree blob at the given
    524  1.1.1.1.2.2  skrll  * offset.  If lenp is non-NULL, the length of the property value is
    525  1.1.1.1.2.2  skrll  * also returned, in the integer pointed to by lenp.
    526  1.1.1.1.2.2  skrll  *
    527  1.1.1.1.2.2  skrll  * returns:
    528  1.1.1.1.2.2  skrll  *	pointer to the structure representing the property
    529  1.1.1.1.2.2  skrll  *		if lenp is non-NULL, *lenp contains the length of the property
    530  1.1.1.1.2.2  skrll  *		value (>=0)
    531  1.1.1.1.2.2  skrll  *	NULL, on error
    532  1.1.1.1.2.2  skrll  *		if lenp is non-NULL, *lenp contains an error code (<0):
    533  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
    534  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADMAGIC,
    535  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADVERSION,
    536  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADSTATE,
    537  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADSTRUCTURE,
    538  1.1.1.1.2.2  skrll  *		-FDT_ERR_TRUNCATED, standard meanings
    539  1.1.1.1.2.2  skrll  */
    540  1.1.1.1.2.2  skrll const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
    541  1.1.1.1.2.2  skrll 						      int offset,
    542  1.1.1.1.2.2  skrll 						      int *lenp);
    543  1.1.1.1.2.2  skrll 
    544  1.1.1.1.2.2  skrll /**
    545  1.1.1.1.2.2  skrll  * fdt_get_property_namelen - find a property based on substring
    546  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    547  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to find
    548  1.1.1.1.2.2  skrll  * @name: name of the property to find
    549  1.1.1.1.2.2  skrll  * @namelen: number of characters of name to consider
    550  1.1.1.1.2.2  skrll  * @lenp: pointer to an integer variable (will be overwritten) or NULL
    551  1.1.1.1.2.2  skrll  *
    552  1.1.1.1.2.2  skrll  * Identical to fdt_get_property(), but only examine the first namelen
    553  1.1.1.1.2.2  skrll  * characters of name for matching the property name.
    554  1.1.1.1.2.2  skrll  */
    555  1.1.1.1.2.2  skrll const struct fdt_property *fdt_get_property_namelen(const void *fdt,
    556  1.1.1.1.2.2  skrll 						    int nodeoffset,
    557  1.1.1.1.2.2  skrll 						    const char *name,
    558  1.1.1.1.2.2  skrll 						    int namelen, int *lenp);
    559  1.1.1.1.2.2  skrll 
    560  1.1.1.1.2.2  skrll /**
    561  1.1.1.1.2.2  skrll  * fdt_get_property - find a given property in a given node
    562  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    563  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to find
    564  1.1.1.1.2.2  skrll  * @name: name of the property to find
    565  1.1.1.1.2.2  skrll  * @lenp: pointer to an integer variable (will be overwritten) or NULL
    566  1.1.1.1.2.2  skrll  *
    567  1.1.1.1.2.2  skrll  * fdt_get_property() retrieves a pointer to the fdt_property
    568  1.1.1.1.2.2  skrll  * structure within the device tree blob corresponding to the property
    569  1.1.1.1.2.2  skrll  * named 'name' of the node at offset nodeoffset.  If lenp is
    570  1.1.1.1.2.2  skrll  * non-NULL, the length of the property value is also returned, in the
    571  1.1.1.1.2.2  skrll  * integer pointed to by lenp.
    572  1.1.1.1.2.2  skrll  *
    573  1.1.1.1.2.2  skrll  * returns:
    574  1.1.1.1.2.2  skrll  *	pointer to the structure representing the property
    575  1.1.1.1.2.2  skrll  *		if lenp is non-NULL, *lenp contains the length of the property
    576  1.1.1.1.2.2  skrll  *		value (>=0)
    577  1.1.1.1.2.2  skrll  *	NULL, on error
    578  1.1.1.1.2.2  skrll  *		if lenp is non-NULL, *lenp contains an error code (<0):
    579  1.1.1.1.2.2  skrll  *		-FDT_ERR_NOTFOUND, node does not have named property
    580  1.1.1.1.2.3  skrll  *		-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
    581  1.1.1.1.2.3  skrll  *			tag
    582  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADMAGIC,
    583  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADVERSION,
    584  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADSTATE,
    585  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADSTRUCTURE,
    586  1.1.1.1.2.2  skrll  *		-FDT_ERR_TRUNCATED, standard meanings
    587  1.1.1.1.2.2  skrll  */
    588  1.1.1.1.2.2  skrll const struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset,
    589  1.1.1.1.2.2  skrll 					    const char *name, int *lenp);
    590  1.1.1.1.2.2  skrll static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
    591  1.1.1.1.2.2  skrll 						      const char *name,
    592  1.1.1.1.2.2  skrll 						      int *lenp)
    593  1.1.1.1.2.2  skrll {
    594  1.1.1.1.2.2  skrll 	return (struct fdt_property *)(uintptr_t)
    595  1.1.1.1.2.2  skrll 		fdt_get_property(fdt, nodeoffset, name, lenp);
    596  1.1.1.1.2.2  skrll }
    597  1.1.1.1.2.2  skrll 
    598  1.1.1.1.2.2  skrll /**
    599  1.1.1.1.2.2  skrll  * fdt_getprop_by_offset - retrieve the value of a property at a given offset
    600  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    601  1.1.1.1.2.2  skrll  * @ffset: offset of the property to read
    602  1.1.1.1.2.2  skrll  * @namep: pointer to a string variable (will be overwritten) or NULL
    603  1.1.1.1.2.2  skrll  * @lenp: pointer to an integer variable (will be overwritten) or NULL
    604  1.1.1.1.2.2  skrll  *
    605  1.1.1.1.2.2  skrll  * fdt_getprop_by_offset() retrieves a pointer to the value of the
    606  1.1.1.1.2.2  skrll  * property at structure block offset 'offset' (this will be a pointer
    607  1.1.1.1.2.2  skrll  * to within the device blob itself, not a copy of the value).  If
    608  1.1.1.1.2.2  skrll  * lenp is non-NULL, the length of the property value is also
    609  1.1.1.1.2.2  skrll  * returned, in the integer pointed to by lenp.  If namep is non-NULL,
    610  1.1.1.1.2.2  skrll  * the property's namne will also be returned in the char * pointed to
    611  1.1.1.1.2.2  skrll  * by namep (this will be a pointer to within the device tree's string
    612  1.1.1.1.2.2  skrll  * block, not a new copy of the name).
    613  1.1.1.1.2.2  skrll  *
    614  1.1.1.1.2.2  skrll  * returns:
    615  1.1.1.1.2.2  skrll  *	pointer to the property's value
    616  1.1.1.1.2.2  skrll  *		if lenp is non-NULL, *lenp contains the length of the property
    617  1.1.1.1.2.2  skrll  *		value (>=0)
    618  1.1.1.1.2.2  skrll  *		if namep is non-NULL *namep contiains a pointer to the property
    619  1.1.1.1.2.2  skrll  *		name.
    620  1.1.1.1.2.2  skrll  *	NULL, on error
    621  1.1.1.1.2.2  skrll  *		if lenp is non-NULL, *lenp contains an error code (<0):
    622  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
    623  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADMAGIC,
    624  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADVERSION,
    625  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADSTATE,
    626  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADSTRUCTURE,
    627  1.1.1.1.2.2  skrll  *		-FDT_ERR_TRUNCATED, standard meanings
    628  1.1.1.1.2.2  skrll  */
    629  1.1.1.1.2.2  skrll const void *fdt_getprop_by_offset(const void *fdt, int offset,
    630  1.1.1.1.2.2  skrll 				  const char **namep, int *lenp);
    631  1.1.1.1.2.2  skrll 
    632  1.1.1.1.2.2  skrll /**
    633  1.1.1.1.2.2  skrll  * fdt_getprop_namelen - get property value based on substring
    634  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    635  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to find
    636  1.1.1.1.2.2  skrll  * @name: name of the property to find
    637  1.1.1.1.2.2  skrll  * @namelen: number of characters of name to consider
    638  1.1.1.1.2.2  skrll  * @lenp: pointer to an integer variable (will be overwritten) or NULL
    639  1.1.1.1.2.2  skrll  *
    640  1.1.1.1.2.2  skrll  * Identical to fdt_getprop(), but only examine the first namelen
    641  1.1.1.1.2.2  skrll  * characters of name for matching the property name.
    642  1.1.1.1.2.2  skrll  */
    643  1.1.1.1.2.2  skrll const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
    644  1.1.1.1.2.2  skrll 				const char *name, int namelen, int *lenp);
    645  1.1.1.1.2.3  skrll static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
    646  1.1.1.1.2.3  skrll 					  const char *name, int namelen,
    647  1.1.1.1.2.3  skrll 					  int *lenp)
    648  1.1.1.1.2.3  skrll {
    649  1.1.1.1.2.3  skrll 	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
    650  1.1.1.1.2.3  skrll 						      namelen, lenp);
    651  1.1.1.1.2.3  skrll }
    652  1.1.1.1.2.2  skrll 
    653  1.1.1.1.2.2  skrll /**
    654  1.1.1.1.2.2  skrll  * fdt_getprop - retrieve the value of a given property
    655  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    656  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to find
    657  1.1.1.1.2.2  skrll  * @name: name of the property to find
    658  1.1.1.1.2.2  skrll  * @lenp: pointer to an integer variable (will be overwritten) or NULL
    659  1.1.1.1.2.2  skrll  *
    660  1.1.1.1.2.2  skrll  * fdt_getprop() retrieves a pointer to the value of the property
    661  1.1.1.1.2.2  skrll  * named 'name' of the node at offset nodeoffset (this will be a
    662  1.1.1.1.2.2  skrll  * pointer to within the device blob itself, not a copy of the value).
    663  1.1.1.1.2.2  skrll  * If lenp is non-NULL, the length of the property value is also
    664  1.1.1.1.2.2  skrll  * returned, in the integer pointed to by lenp.
    665  1.1.1.1.2.2  skrll  *
    666  1.1.1.1.2.2  skrll  * returns:
    667  1.1.1.1.2.2  skrll  *	pointer to the property's value
    668  1.1.1.1.2.2  skrll  *		if lenp is non-NULL, *lenp contains the length of the property
    669  1.1.1.1.2.2  skrll  *		value (>=0)
    670  1.1.1.1.2.2  skrll  *	NULL, on error
    671  1.1.1.1.2.2  skrll  *		if lenp is non-NULL, *lenp contains an error code (<0):
    672  1.1.1.1.2.2  skrll  *		-FDT_ERR_NOTFOUND, node does not have named property
    673  1.1.1.1.2.3  skrll  *		-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
    674  1.1.1.1.2.3  skrll  *			tag
    675  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADMAGIC,
    676  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADVERSION,
    677  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADSTATE,
    678  1.1.1.1.2.2  skrll  *		-FDT_ERR_BADSTRUCTURE,
    679  1.1.1.1.2.2  skrll  *		-FDT_ERR_TRUNCATED, standard meanings
    680  1.1.1.1.2.2  skrll  */
    681  1.1.1.1.2.2  skrll const void *fdt_getprop(const void *fdt, int nodeoffset,
    682  1.1.1.1.2.2  skrll 			const char *name, int *lenp);
    683  1.1.1.1.2.2  skrll static inline void *fdt_getprop_w(void *fdt, int nodeoffset,
    684  1.1.1.1.2.2  skrll 				  const char *name, int *lenp)
    685  1.1.1.1.2.2  skrll {
    686  1.1.1.1.2.2  skrll 	return (void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp);
    687  1.1.1.1.2.2  skrll }
    688  1.1.1.1.2.2  skrll 
    689  1.1.1.1.2.2  skrll /**
    690  1.1.1.1.2.2  skrll  * fdt_get_phandle - retrieve the phandle of a given node
    691  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    692  1.1.1.1.2.2  skrll  * @nodeoffset: structure block offset of the node
    693  1.1.1.1.2.2  skrll  *
    694  1.1.1.1.2.2  skrll  * fdt_get_phandle() retrieves the phandle of the device tree node at
    695  1.1.1.1.2.2  skrll  * structure block offset nodeoffset.
    696  1.1.1.1.2.2  skrll  *
    697  1.1.1.1.2.2  skrll  * returns:
    698  1.1.1.1.2.2  skrll  *	the phandle of the node at nodeoffset, on success (!= 0, != -1)
    699  1.1.1.1.2.2  skrll  *	0, if the node has no phandle, or another error occurs
    700  1.1.1.1.2.2  skrll  */
    701  1.1.1.1.2.2  skrll uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
    702  1.1.1.1.2.2  skrll 
    703  1.1.1.1.2.2  skrll /**
    704  1.1.1.1.2.2  skrll  * fdt_get_alias_namelen - get alias based on substring
    705  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    706  1.1.1.1.2.2  skrll  * @name: name of the alias th look up
    707  1.1.1.1.2.2  skrll  * @namelen: number of characters of name to consider
    708  1.1.1.1.2.2  skrll  *
    709  1.1.1.1.2.2  skrll  * Identical to fdt_get_alias(), but only examine the first namelen
    710  1.1.1.1.2.2  skrll  * characters of name for matching the alias name.
    711  1.1.1.1.2.2  skrll  */
    712  1.1.1.1.2.2  skrll const char *fdt_get_alias_namelen(const void *fdt,
    713  1.1.1.1.2.2  skrll 				  const char *name, int namelen);
    714  1.1.1.1.2.2  skrll 
    715  1.1.1.1.2.2  skrll /**
    716  1.1.1.1.2.3  skrll  * fdt_get_alias - retrieve the path referenced by a given alias
    717  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    718  1.1.1.1.2.2  skrll  * @name: name of the alias th look up
    719  1.1.1.1.2.2  skrll  *
    720  1.1.1.1.2.2  skrll  * fdt_get_alias() retrieves the value of a given alias.  That is, the
    721  1.1.1.1.2.2  skrll  * value of the property named 'name' in the node /aliases.
    722  1.1.1.1.2.2  skrll  *
    723  1.1.1.1.2.2  skrll  * returns:
    724  1.1.1.1.2.2  skrll  *	a pointer to the expansion of the alias named 'name', if it exists
    725  1.1.1.1.2.2  skrll  *	NULL, if the given alias or the /aliases node does not exist
    726  1.1.1.1.2.2  skrll  */
    727  1.1.1.1.2.2  skrll const char *fdt_get_alias(const void *fdt, const char *name);
    728  1.1.1.1.2.2  skrll 
    729  1.1.1.1.2.2  skrll /**
    730  1.1.1.1.2.2  skrll  * fdt_get_path - determine the full path of a node
    731  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    732  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose path to find
    733  1.1.1.1.2.2  skrll  * @buf: character buffer to contain the returned path (will be overwritten)
    734  1.1.1.1.2.2  skrll  * @buflen: size of the character buffer at buf
    735  1.1.1.1.2.2  skrll  *
    736  1.1.1.1.2.2  skrll  * fdt_get_path() computes the full path of the node at offset
    737  1.1.1.1.2.2  skrll  * nodeoffset, and records that path in the buffer at buf.
    738  1.1.1.1.2.2  skrll  *
    739  1.1.1.1.2.2  skrll  * NOTE: This function is expensive, as it must scan the device tree
    740  1.1.1.1.2.2  skrll  * structure from the start to nodeoffset.
    741  1.1.1.1.2.2  skrll  *
    742  1.1.1.1.2.2  skrll  * returns:
    743  1.1.1.1.2.2  skrll  *	0, on success
    744  1.1.1.1.2.2  skrll  *		buf contains the absolute path of the node at
    745  1.1.1.1.2.2  skrll  *		nodeoffset, as a NUL-terminated string.
    746  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
    747  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1)
    748  1.1.1.1.2.2  skrll  *		characters and will not fit in the given buffer.
    749  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
    750  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    751  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    752  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE, standard meanings
    753  1.1.1.1.2.2  skrll  */
    754  1.1.1.1.2.2  skrll int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);
    755  1.1.1.1.2.2  skrll 
    756  1.1.1.1.2.2  skrll /**
    757  1.1.1.1.2.2  skrll  * fdt_supernode_atdepth_offset - find a specific ancestor of a node
    758  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    759  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose parent to find
    760  1.1.1.1.2.2  skrll  * @supernodedepth: depth of the ancestor to find
    761  1.1.1.1.2.2  skrll  * @nodedepth: pointer to an integer variable (will be overwritten) or NULL
    762  1.1.1.1.2.2  skrll  *
    763  1.1.1.1.2.2  skrll  * fdt_supernode_atdepth_offset() finds an ancestor of the given node
    764  1.1.1.1.2.2  skrll  * at a specific depth from the root (where the root itself has depth
    765  1.1.1.1.2.2  skrll  * 0, its immediate subnodes depth 1 and so forth).  So
    766  1.1.1.1.2.2  skrll  *	fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, NULL);
    767  1.1.1.1.2.2  skrll  * will always return 0, the offset of the root node.  If the node at
    768  1.1.1.1.2.2  skrll  * nodeoffset has depth D, then:
    769  1.1.1.1.2.2  skrll  *	fdt_supernode_atdepth_offset(fdt, nodeoffset, D, NULL);
    770  1.1.1.1.2.2  skrll  * will return nodeoffset itself.
    771  1.1.1.1.2.2  skrll  *
    772  1.1.1.1.2.2  skrll  * NOTE: This function is expensive, as it must scan the device tree
    773  1.1.1.1.2.2  skrll  * structure from the start to nodeoffset.
    774  1.1.1.1.2.2  skrll  *
    775  1.1.1.1.2.2  skrll  * returns:
    776  1.1.1.1.2.2  skrll  *	structure block offset of the node at node offset's ancestor
    777  1.1.1.1.2.2  skrll  *		of depth supernodedepth (>=0), on success
    778  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
    779  1.1.1.1.2.3  skrll  *	-FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of
    780  1.1.1.1.2.3  skrll  *		nodeoffset
    781  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
    782  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    783  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    784  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE, standard meanings
    785  1.1.1.1.2.2  skrll  */
    786  1.1.1.1.2.2  skrll int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
    787  1.1.1.1.2.2  skrll 				 int supernodedepth, int *nodedepth);
    788  1.1.1.1.2.2  skrll 
    789  1.1.1.1.2.2  skrll /**
    790  1.1.1.1.2.2  skrll  * fdt_node_depth - find the depth of a given node
    791  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    792  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose parent to find
    793  1.1.1.1.2.2  skrll  *
    794  1.1.1.1.2.2  skrll  * fdt_node_depth() finds the depth of a given node.  The root node
    795  1.1.1.1.2.2  skrll  * has depth 0, its immediate subnodes depth 1 and so forth.
    796  1.1.1.1.2.2  skrll  *
    797  1.1.1.1.2.2  skrll  * NOTE: This function is expensive, as it must scan the device tree
    798  1.1.1.1.2.2  skrll  * structure from the start to nodeoffset.
    799  1.1.1.1.2.2  skrll  *
    800  1.1.1.1.2.2  skrll  * returns:
    801  1.1.1.1.2.2  skrll  *	depth of the node at nodeoffset (>=0), on success
    802  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
    803  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
    804  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    805  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    806  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE, standard meanings
    807  1.1.1.1.2.2  skrll  */
    808  1.1.1.1.2.2  skrll int fdt_node_depth(const void *fdt, int nodeoffset);
    809  1.1.1.1.2.2  skrll 
    810  1.1.1.1.2.2  skrll /**
    811  1.1.1.1.2.2  skrll  * fdt_parent_offset - find the parent of a given node
    812  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    813  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose parent to find
    814  1.1.1.1.2.2  skrll  *
    815  1.1.1.1.2.2  skrll  * fdt_parent_offset() locates the parent node of a given node (that
    816  1.1.1.1.2.2  skrll  * is, it finds the offset of the node which contains the node at
    817  1.1.1.1.2.2  skrll  * nodeoffset as a subnode).
    818  1.1.1.1.2.2  skrll  *
    819  1.1.1.1.2.2  skrll  * NOTE: This function is expensive, as it must scan the device tree
    820  1.1.1.1.2.2  skrll  * structure from the start to nodeoffset, *twice*.
    821  1.1.1.1.2.2  skrll  *
    822  1.1.1.1.2.2  skrll  * returns:
    823  1.1.1.1.2.2  skrll  *	structure block offset of the parent of the node at nodeoffset
    824  1.1.1.1.2.2  skrll  *		(>=0), on success
    825  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
    826  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
    827  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    828  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    829  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE, standard meanings
    830  1.1.1.1.2.2  skrll  */
    831  1.1.1.1.2.2  skrll int fdt_parent_offset(const void *fdt, int nodeoffset);
    832  1.1.1.1.2.2  skrll 
    833  1.1.1.1.2.2  skrll /**
    834  1.1.1.1.2.2  skrll  * fdt_node_offset_by_prop_value - find nodes with a given property value
    835  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    836  1.1.1.1.2.2  skrll  * @startoffset: only find nodes after this offset
    837  1.1.1.1.2.2  skrll  * @propname: property name to check
    838  1.1.1.1.2.2  skrll  * @propval: property value to search for
    839  1.1.1.1.2.2  skrll  * @proplen: length of the value in propval
    840  1.1.1.1.2.2  skrll  *
    841  1.1.1.1.2.2  skrll  * fdt_node_offset_by_prop_value() returns the offset of the first
    842  1.1.1.1.2.2  skrll  * node after startoffset, which has a property named propname whose
    843  1.1.1.1.2.2  skrll  * value is of length proplen and has value equal to propval; or if
    844  1.1.1.1.2.2  skrll  * startoffset is -1, the very first such node in the tree.
    845  1.1.1.1.2.2  skrll  *
    846  1.1.1.1.2.2  skrll  * To iterate through all nodes matching the criterion, the following
    847  1.1.1.1.2.2  skrll  * idiom can be used:
    848  1.1.1.1.2.2  skrll  *	offset = fdt_node_offset_by_prop_value(fdt, -1, propname,
    849  1.1.1.1.2.2  skrll  *					       propval, proplen);
    850  1.1.1.1.2.2  skrll  *	while (offset != -FDT_ERR_NOTFOUND) {
    851  1.1.1.1.2.2  skrll  *		// other code here
    852  1.1.1.1.2.2  skrll  *		offset = fdt_node_offset_by_prop_value(fdt, offset, propname,
    853  1.1.1.1.2.2  skrll  *						       propval, proplen);
    854  1.1.1.1.2.2  skrll  *	}
    855  1.1.1.1.2.2  skrll  *
    856  1.1.1.1.2.2  skrll  * Note the -1 in the first call to the function, if 0 is used here
    857  1.1.1.1.2.2  skrll  * instead, the function will never locate the root node, even if it
    858  1.1.1.1.2.2  skrll  * matches the criterion.
    859  1.1.1.1.2.2  skrll  *
    860  1.1.1.1.2.2  skrll  * returns:
    861  1.1.1.1.2.2  skrll  *	structure block offset of the located node (>= 0, >startoffset),
    862  1.1.1.1.2.2  skrll  *		 on success
    863  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, no node matching the criterion exists in the
    864  1.1.1.1.2.2  skrll  *		tree after startoffset
    865  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
    866  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
    867  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    868  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    869  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE, standard meanings
    870  1.1.1.1.2.2  skrll  */
    871  1.1.1.1.2.2  skrll int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
    872  1.1.1.1.2.2  skrll 				  const char *propname,
    873  1.1.1.1.2.2  skrll 				  const void *propval, int proplen);
    874  1.1.1.1.2.2  skrll 
    875  1.1.1.1.2.2  skrll /**
    876  1.1.1.1.2.2  skrll  * fdt_node_offset_by_phandle - find the node with a given phandle
    877  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    878  1.1.1.1.2.2  skrll  * @phandle: phandle value
    879  1.1.1.1.2.2  skrll  *
    880  1.1.1.1.2.2  skrll  * fdt_node_offset_by_phandle() returns the offset of the node
    881  1.1.1.1.2.2  skrll  * which has the given phandle value.  If there is more than one node
    882  1.1.1.1.2.2  skrll  * in the tree with the given phandle (an invalid tree), results are
    883  1.1.1.1.2.2  skrll  * undefined.
    884  1.1.1.1.2.2  skrll  *
    885  1.1.1.1.2.2  skrll  * returns:
    886  1.1.1.1.2.2  skrll  *	structure block offset of the located node (>= 0), on success
    887  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, no node with that phandle exists
    888  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1)
    889  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
    890  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    891  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    892  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE, standard meanings
    893  1.1.1.1.2.2  skrll  */
    894  1.1.1.1.2.2  skrll int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle);
    895  1.1.1.1.2.2  skrll 
    896  1.1.1.1.2.2  skrll /**
    897  1.1.1.1.2.2  skrll  * fdt_node_check_compatible: check a node's compatible property
    898  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    899  1.1.1.1.2.2  skrll  * @nodeoffset: offset of a tree node
    900  1.1.1.1.2.2  skrll  * @compatible: string to match against
    901  1.1.1.1.2.2  skrll  *
    902  1.1.1.1.2.2  skrll  *
    903  1.1.1.1.2.2  skrll  * fdt_node_check_compatible() returns 0 if the given node contains a
    904  1.1.1.1.2.2  skrll  * 'compatible' property with the given string as one of its elements,
    905  1.1.1.1.2.2  skrll  * it returns non-zero otherwise, or on error.
    906  1.1.1.1.2.2  skrll  *
    907  1.1.1.1.2.2  skrll  * returns:
    908  1.1.1.1.2.2  skrll  *	0, if the node has a 'compatible' property listing the given string
    909  1.1.1.1.2.2  skrll  *	1, if the node has a 'compatible' property, but it does not list
    910  1.1.1.1.2.2  skrll  *		the given string
    911  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, if the given node has no 'compatible' property
    912  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag
    913  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
    914  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    915  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    916  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE, standard meanings
    917  1.1.1.1.2.2  skrll  */
    918  1.1.1.1.2.2  skrll int fdt_node_check_compatible(const void *fdt, int nodeoffset,
    919  1.1.1.1.2.2  skrll 			      const char *compatible);
    920  1.1.1.1.2.2  skrll 
    921  1.1.1.1.2.2  skrll /**
    922  1.1.1.1.2.2  skrll  * fdt_node_offset_by_compatible - find nodes with a given 'compatible' value
    923  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    924  1.1.1.1.2.2  skrll  * @startoffset: only find nodes after this offset
    925  1.1.1.1.2.2  skrll  * @compatible: 'compatible' string to match against
    926  1.1.1.1.2.2  skrll  *
    927  1.1.1.1.2.2  skrll  * fdt_node_offset_by_compatible() returns the offset of the first
    928  1.1.1.1.2.2  skrll  * node after startoffset, which has a 'compatible' property which
    929  1.1.1.1.2.2  skrll  * lists the given compatible string; or if startoffset is -1, the
    930  1.1.1.1.2.2  skrll  * very first such node in the tree.
    931  1.1.1.1.2.2  skrll  *
    932  1.1.1.1.2.2  skrll  * To iterate through all nodes matching the criterion, the following
    933  1.1.1.1.2.2  skrll  * idiom can be used:
    934  1.1.1.1.2.2  skrll  *	offset = fdt_node_offset_by_compatible(fdt, -1, compatible);
    935  1.1.1.1.2.2  skrll  *	while (offset != -FDT_ERR_NOTFOUND) {
    936  1.1.1.1.2.2  skrll  *		// other code here
    937  1.1.1.1.2.2  skrll  *		offset = fdt_node_offset_by_compatible(fdt, offset, compatible);
    938  1.1.1.1.2.2  skrll  *	}
    939  1.1.1.1.2.2  skrll  *
    940  1.1.1.1.2.2  skrll  * Note the -1 in the first call to the function, if 0 is used here
    941  1.1.1.1.2.2  skrll  * instead, the function will never locate the root node, even if it
    942  1.1.1.1.2.2  skrll  * matches the criterion.
    943  1.1.1.1.2.2  skrll  *
    944  1.1.1.1.2.2  skrll  * returns:
    945  1.1.1.1.2.2  skrll  *	structure block offset of the located node (>= 0, >startoffset),
    946  1.1.1.1.2.2  skrll  *		 on success
    947  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, no node matching the criterion exists in the
    948  1.1.1.1.2.2  skrll  *		tree after startoffset
    949  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
    950  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
    951  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
    952  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
    953  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE, standard meanings
    954  1.1.1.1.2.2  skrll  */
    955  1.1.1.1.2.2  skrll int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
    956  1.1.1.1.2.2  skrll 				  const char *compatible);
    957  1.1.1.1.2.2  skrll 
    958  1.1.1.1.2.2  skrll /**
    959  1.1.1.1.2.2  skrll  * fdt_stringlist_contains - check a string list property for a string
    960  1.1.1.1.2.2  skrll  * @strlist: Property containing a list of strings to check
    961  1.1.1.1.2.2  skrll  * @listlen: Length of property
    962  1.1.1.1.2.2  skrll  * @str: String to search for
    963  1.1.1.1.2.2  skrll  *
    964  1.1.1.1.2.2  skrll  * This is a utility function provided for convenience. The list contains
    965  1.1.1.1.2.2  skrll  * one or more strings, each terminated by \0, as is found in a device tree
    966  1.1.1.1.2.2  skrll  * "compatible" property.
    967  1.1.1.1.2.2  skrll  *
    968  1.1.1.1.2.2  skrll  * @return: 1 if the string is found in the list, 0 not found, or invalid list
    969  1.1.1.1.2.2  skrll  */
    970  1.1.1.1.2.2  skrll int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
    971  1.1.1.1.2.2  skrll 
    972  1.1.1.1.2.2  skrll /**
    973  1.1.1.1.2.2  skrll  * fdt_stringlist_count - count the number of strings in a string list
    974  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    975  1.1.1.1.2.2  skrll  * @nodeoffset: offset of a tree node
    976  1.1.1.1.2.2  skrll  * @property: name of the property containing the string list
    977  1.1.1.1.2.2  skrll  * @return:
    978  1.1.1.1.2.2  skrll  *   the number of strings in the given property
    979  1.1.1.1.2.2  skrll  *   -FDT_ERR_BADVALUE if the property value is not NUL-terminated
    980  1.1.1.1.2.2  skrll  *   -FDT_ERR_NOTFOUND if the property does not exist
    981  1.1.1.1.2.2  skrll  */
    982  1.1.1.1.2.2  skrll int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property);
    983  1.1.1.1.2.2  skrll 
    984  1.1.1.1.2.2  skrll /**
    985  1.1.1.1.2.2  skrll  * fdt_stringlist_search - find a string in a string list and return its index
    986  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
    987  1.1.1.1.2.2  skrll  * @nodeoffset: offset of a tree node
    988  1.1.1.1.2.2  skrll  * @property: name of the property containing the string list
    989  1.1.1.1.2.2  skrll  * @string: string to look up in the string list
    990  1.1.1.1.2.2  skrll  *
    991  1.1.1.1.2.2  skrll  * Note that it is possible for this function to succeed on property values
    992  1.1.1.1.2.2  skrll  * that are not NUL-terminated. That's because the function will stop after
    993  1.1.1.1.2.2  skrll  * finding the first occurrence of @string. This can for example happen with
    994  1.1.1.1.2.2  skrll  * small-valued cell properties, such as #address-cells, when searching for
    995  1.1.1.1.2.2  skrll  * the empty string.
    996  1.1.1.1.2.2  skrll  *
    997  1.1.1.1.2.2  skrll  * @return:
    998  1.1.1.1.2.2  skrll  *   the index of the string in the list of strings
    999  1.1.1.1.2.2  skrll  *   -FDT_ERR_BADVALUE if the property value is not NUL-terminated
   1000  1.1.1.1.2.2  skrll  *   -FDT_ERR_NOTFOUND if the property does not exist or does not contain
   1001  1.1.1.1.2.2  skrll  *                     the given string
   1002  1.1.1.1.2.2  skrll  */
   1003  1.1.1.1.2.2  skrll int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property,
   1004  1.1.1.1.2.2  skrll 			  const char *string);
   1005  1.1.1.1.2.2  skrll 
   1006  1.1.1.1.2.2  skrll /**
   1007  1.1.1.1.2.2  skrll  * fdt_stringlist_get() - obtain the string at a given index in a string list
   1008  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1009  1.1.1.1.2.2  skrll  * @nodeoffset: offset of a tree node
   1010  1.1.1.1.2.2  skrll  * @property: name of the property containing the string list
   1011  1.1.1.1.2.2  skrll  * @index: index of the string to return
   1012  1.1.1.1.2.2  skrll  * @lenp: return location for the string length or an error code on failure
   1013  1.1.1.1.2.2  skrll  *
   1014  1.1.1.1.2.2  skrll  * Note that this will successfully extract strings from properties with
   1015  1.1.1.1.2.2  skrll  * non-NUL-terminated values. For example on small-valued cell properties
   1016  1.1.1.1.2.2  skrll  * this function will return the empty string.
   1017  1.1.1.1.2.2  skrll  *
   1018  1.1.1.1.2.2  skrll  * If non-NULL, the length of the string (on success) or a negative error-code
   1019  1.1.1.1.2.2  skrll  * (on failure) will be stored in the integer pointer to by lenp.
   1020  1.1.1.1.2.2  skrll  *
   1021  1.1.1.1.2.2  skrll  * @return:
   1022  1.1.1.1.2.2  skrll  *   A pointer to the string at the given index in the string list or NULL on
   1023  1.1.1.1.2.2  skrll  *   failure. On success the length of the string will be stored in the memory
   1024  1.1.1.1.2.2  skrll  *   location pointed to by the lenp parameter, if non-NULL. On failure one of
   1025  1.1.1.1.2.2  skrll  *   the following negative error codes will be returned in the lenp parameter
   1026  1.1.1.1.2.2  skrll  *   (if non-NULL):
   1027  1.1.1.1.2.2  skrll  *     -FDT_ERR_BADVALUE if the property value is not NUL-terminated
   1028  1.1.1.1.2.2  skrll  *     -FDT_ERR_NOTFOUND if the property does not exist
   1029  1.1.1.1.2.2  skrll  */
   1030  1.1.1.1.2.2  skrll const char *fdt_stringlist_get(const void *fdt, int nodeoffset,
   1031  1.1.1.1.2.2  skrll 			       const char *property, int index,
   1032  1.1.1.1.2.2  skrll 			       int *lenp);
   1033  1.1.1.1.2.2  skrll 
   1034  1.1.1.1.2.2  skrll /**********************************************************************/
   1035  1.1.1.1.2.2  skrll /* Read-only functions (addressing related)                           */
   1036  1.1.1.1.2.2  skrll /**********************************************************************/
   1037  1.1.1.1.2.2  skrll 
   1038  1.1.1.1.2.2  skrll /**
   1039  1.1.1.1.2.2  skrll  * FDT_MAX_NCELLS - maximum value for #address-cells and #size-cells
   1040  1.1.1.1.2.2  skrll  *
   1041  1.1.1.1.2.2  skrll  * This is the maximum value for #address-cells, #size-cells and
   1042  1.1.1.1.2.2  skrll  * similar properties that will be processed by libfdt.  IEE1275
   1043  1.1.1.1.2.2  skrll  * requires that OF implementations handle values up to 4.
   1044  1.1.1.1.2.2  skrll  * Implementations may support larger values, but in practice higher
   1045  1.1.1.1.2.2  skrll  * values aren't used.
   1046  1.1.1.1.2.2  skrll  */
   1047  1.1.1.1.2.2  skrll #define FDT_MAX_NCELLS		4
   1048  1.1.1.1.2.2  skrll 
   1049  1.1.1.1.2.2  skrll /**
   1050  1.1.1.1.2.2  skrll  * fdt_address_cells - retrieve address size for a bus represented in the tree
   1051  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1052  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node to find the address size for
   1053  1.1.1.1.2.2  skrll  *
   1054  1.1.1.1.2.2  skrll  * When the node has a valid #address-cells property, returns its value.
   1055  1.1.1.1.2.2  skrll  *
   1056  1.1.1.1.2.2  skrll  * returns:
   1057  1.1.1.1.2.2  skrll  *	0 <= n < FDT_MAX_NCELLS, on success
   1058  1.1.1.1.2.2  skrll  *      2, if the node has no #address-cells property
   1059  1.1.1.1.2.3  skrll  *      -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
   1060  1.1.1.1.2.3  skrll  *		#address-cells property
   1061  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1062  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1063  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1064  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1065  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1066  1.1.1.1.2.2  skrll  */
   1067  1.1.1.1.2.2  skrll int fdt_address_cells(const void *fdt, int nodeoffset);
   1068  1.1.1.1.2.2  skrll 
   1069  1.1.1.1.2.2  skrll /**
   1070  1.1.1.1.2.2  skrll  * fdt_size_cells - retrieve address range size for a bus represented in the
   1071  1.1.1.1.2.2  skrll  *                  tree
   1072  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1073  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node to find the address range size for
   1074  1.1.1.1.2.2  skrll  *
   1075  1.1.1.1.2.2  skrll  * When the node has a valid #size-cells property, returns its value.
   1076  1.1.1.1.2.2  skrll  *
   1077  1.1.1.1.2.2  skrll  * returns:
   1078  1.1.1.1.2.2  skrll  *	0 <= n < FDT_MAX_NCELLS, on success
   1079  1.1.1.1.2.2  skrll  *      2, if the node has no #address-cells property
   1080  1.1.1.1.2.3  skrll  *      -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
   1081  1.1.1.1.2.3  skrll  *		#size-cells property
   1082  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1083  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1084  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1085  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1086  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1087  1.1.1.1.2.2  skrll  */
   1088  1.1.1.1.2.2  skrll int fdt_size_cells(const void *fdt, int nodeoffset);
   1089  1.1.1.1.2.2  skrll 
   1090  1.1.1.1.2.2  skrll 
   1091  1.1.1.1.2.2  skrll /**********************************************************************/
   1092  1.1.1.1.2.2  skrll /* Write-in-place functions                                           */
   1093  1.1.1.1.2.2  skrll /**********************************************************************/
   1094  1.1.1.1.2.2  skrll 
   1095  1.1.1.1.2.2  skrll /**
   1096  1.1.1.1.2.3  skrll  * fdt_setprop_inplace_namelen_partial - change a property's value,
   1097  1.1.1.1.2.3  skrll  *                                       but not its size
   1098  1.1.1.1.2.3  skrll  * @fdt: pointer to the device tree blob
   1099  1.1.1.1.2.3  skrll  * @nodeoffset: offset of the node whose property to change
   1100  1.1.1.1.2.3  skrll  * @name: name of the property to change
   1101  1.1.1.1.2.3  skrll  * @namelen: number of characters of name to consider
   1102  1.1.1.1.2.3  skrll  * @idx: index of the property to change in the array
   1103  1.1.1.1.2.3  skrll  * @val: pointer to data to replace the property value with
   1104  1.1.1.1.2.3  skrll  * @len: length of the property value
   1105  1.1.1.1.2.3  skrll  *
   1106  1.1.1.1.2.3  skrll  * Identical to fdt_setprop_inplace(), but modifies the given property
   1107  1.1.1.1.2.3  skrll  * starting from the given index, and using only the first characters
   1108  1.1.1.1.2.3  skrll  * of the name. It is useful when you want to manipulate only one value of
   1109  1.1.1.1.2.3  skrll  * an array and you have a string that doesn't end with \0.
   1110  1.1.1.1.2.3  skrll  */
   1111  1.1.1.1.2.3  skrll int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
   1112  1.1.1.1.2.3  skrll 					const char *name, int namelen,
   1113  1.1.1.1.2.3  skrll 					uint32_t idx, const void *val,
   1114  1.1.1.1.2.3  skrll 					int len);
   1115  1.1.1.1.2.3  skrll 
   1116  1.1.1.1.2.3  skrll /**
   1117  1.1.1.1.2.2  skrll  * fdt_setprop_inplace - change a property's value, but not its size
   1118  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1119  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to change
   1120  1.1.1.1.2.2  skrll  * @name: name of the property to change
   1121  1.1.1.1.2.2  skrll  * @val: pointer to data to replace the property value with
   1122  1.1.1.1.2.2  skrll  * @len: length of the property value
   1123  1.1.1.1.2.2  skrll  *
   1124  1.1.1.1.2.2  skrll  * fdt_setprop_inplace() replaces the value of a given property with
   1125  1.1.1.1.2.2  skrll  * the data in val, of length len.  This function cannot change the
   1126  1.1.1.1.2.2  skrll  * size of a property, and so will only work if len is equal to the
   1127  1.1.1.1.2.2  skrll  * current length of the property.
   1128  1.1.1.1.2.2  skrll  *
   1129  1.1.1.1.2.2  skrll  * This function will alter only the bytes in the blob which contain
   1130  1.1.1.1.2.2  skrll  * the given property value, and will not alter or move any other part
   1131  1.1.1.1.2.2  skrll  * of the tree.
   1132  1.1.1.1.2.2  skrll  *
   1133  1.1.1.1.2.2  skrll  * returns:
   1134  1.1.1.1.2.2  skrll  *	0, on success
   1135  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, if len is not equal to the property's current length
   1136  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, node does not have the named property
   1137  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1138  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1139  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1140  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1141  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1142  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1143  1.1.1.1.2.2  skrll  */
   1144  1.1.1.1.2.2  skrll int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
   1145  1.1.1.1.2.2  skrll 			const void *val, int len);
   1146  1.1.1.1.2.2  skrll 
   1147  1.1.1.1.2.2  skrll /**
   1148  1.1.1.1.2.2  skrll  * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property
   1149  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1150  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to change
   1151  1.1.1.1.2.2  skrll  * @name: name of the property to change
   1152  1.1.1.1.2.2  skrll  * @val: 32-bit integer value to replace the property with
   1153  1.1.1.1.2.2  skrll  *
   1154  1.1.1.1.2.2  skrll  * fdt_setprop_inplace_u32() replaces the value of a given property
   1155  1.1.1.1.2.2  skrll  * with the 32-bit integer value in val, converting val to big-endian
   1156  1.1.1.1.2.2  skrll  * if necessary.  This function cannot change the size of a property,
   1157  1.1.1.1.2.2  skrll  * and so will only work if the property already exists and has length
   1158  1.1.1.1.2.2  skrll  * 4.
   1159  1.1.1.1.2.2  skrll  *
   1160  1.1.1.1.2.2  skrll  * This function will alter only the bytes in the blob which contain
   1161  1.1.1.1.2.2  skrll  * the given property value, and will not alter or move any other part
   1162  1.1.1.1.2.2  skrll  * of the tree.
   1163  1.1.1.1.2.2  skrll  *
   1164  1.1.1.1.2.2  skrll  * returns:
   1165  1.1.1.1.2.2  skrll  *	0, on success
   1166  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, if the property's length is not equal to 4
   1167  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, node does not have the named property
   1168  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1169  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1170  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1171  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1172  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1173  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1174  1.1.1.1.2.2  skrll  */
   1175  1.1.1.1.2.2  skrll static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
   1176  1.1.1.1.2.2  skrll 					  const char *name, uint32_t val)
   1177  1.1.1.1.2.2  skrll {
   1178  1.1.1.1.2.2  skrll 	fdt32_t tmp = cpu_to_fdt32(val);
   1179  1.1.1.1.2.2  skrll 	return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
   1180  1.1.1.1.2.2  skrll }
   1181  1.1.1.1.2.2  skrll 
   1182  1.1.1.1.2.2  skrll /**
   1183  1.1.1.1.2.2  skrll  * fdt_setprop_inplace_u64 - change the value of a 64-bit integer property
   1184  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1185  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to change
   1186  1.1.1.1.2.2  skrll  * @name: name of the property to change
   1187  1.1.1.1.2.2  skrll  * @val: 64-bit integer value to replace the property with
   1188  1.1.1.1.2.2  skrll  *
   1189  1.1.1.1.2.2  skrll  * fdt_setprop_inplace_u64() replaces the value of a given property
   1190  1.1.1.1.2.2  skrll  * with the 64-bit integer value in val, converting val to big-endian
   1191  1.1.1.1.2.2  skrll  * if necessary.  This function cannot change the size of a property,
   1192  1.1.1.1.2.2  skrll  * and so will only work if the property already exists and has length
   1193  1.1.1.1.2.2  skrll  * 8.
   1194  1.1.1.1.2.2  skrll  *
   1195  1.1.1.1.2.2  skrll  * This function will alter only the bytes in the blob which contain
   1196  1.1.1.1.2.2  skrll  * the given property value, and will not alter or move any other part
   1197  1.1.1.1.2.2  skrll  * of the tree.
   1198  1.1.1.1.2.2  skrll  *
   1199  1.1.1.1.2.2  skrll  * returns:
   1200  1.1.1.1.2.2  skrll  *	0, on success
   1201  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, if the property's length is not equal to 8
   1202  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, node does not have the named property
   1203  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1204  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1205  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1206  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1207  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1208  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1209  1.1.1.1.2.2  skrll  */
   1210  1.1.1.1.2.2  skrll static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
   1211  1.1.1.1.2.2  skrll 					  const char *name, uint64_t val)
   1212  1.1.1.1.2.2  skrll {
   1213  1.1.1.1.2.2  skrll 	fdt64_t tmp = cpu_to_fdt64(val);
   1214  1.1.1.1.2.2  skrll 	return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
   1215  1.1.1.1.2.2  skrll }
   1216  1.1.1.1.2.2  skrll 
   1217  1.1.1.1.2.2  skrll /**
   1218  1.1.1.1.2.2  skrll  * fdt_setprop_inplace_cell - change the value of a single-cell property
   1219  1.1.1.1.2.2  skrll  *
   1220  1.1.1.1.2.2  skrll  * This is an alternative name for fdt_setprop_inplace_u32()
   1221  1.1.1.1.2.2  skrll  */
   1222  1.1.1.1.2.2  skrll static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,
   1223  1.1.1.1.2.2  skrll 					   const char *name, uint32_t val)
   1224  1.1.1.1.2.2  skrll {
   1225  1.1.1.1.2.2  skrll 	return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val);
   1226  1.1.1.1.2.2  skrll }
   1227  1.1.1.1.2.2  skrll 
   1228  1.1.1.1.2.2  skrll /**
   1229  1.1.1.1.2.2  skrll  * fdt_nop_property - replace a property with nop tags
   1230  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1231  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to nop
   1232  1.1.1.1.2.2  skrll  * @name: name of the property to nop
   1233  1.1.1.1.2.2  skrll  *
   1234  1.1.1.1.2.2  skrll  * fdt_nop_property() will replace a given property's representation
   1235  1.1.1.1.2.2  skrll  * in the blob with FDT_NOP tags, effectively removing it from the
   1236  1.1.1.1.2.2  skrll  * tree.
   1237  1.1.1.1.2.2  skrll  *
   1238  1.1.1.1.2.2  skrll  * This function will alter only the bytes in the blob which contain
   1239  1.1.1.1.2.2  skrll  * the property, and will not alter or move any other part of the
   1240  1.1.1.1.2.2  skrll  * tree.
   1241  1.1.1.1.2.2  skrll  *
   1242  1.1.1.1.2.2  skrll  * returns:
   1243  1.1.1.1.2.2  skrll  *	0, on success
   1244  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, node does not have the named property
   1245  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1246  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1247  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1248  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1249  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1250  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1251  1.1.1.1.2.2  skrll  */
   1252  1.1.1.1.2.2  skrll int fdt_nop_property(void *fdt, int nodeoffset, const char *name);
   1253  1.1.1.1.2.2  skrll 
   1254  1.1.1.1.2.2  skrll /**
   1255  1.1.1.1.2.2  skrll  * fdt_nop_node - replace a node (subtree) with nop tags
   1256  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1257  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node to nop
   1258  1.1.1.1.2.2  skrll  *
   1259  1.1.1.1.2.2  skrll  * fdt_nop_node() will replace a given node's representation in the
   1260  1.1.1.1.2.2  skrll  * blob, including all its subnodes, if any, with FDT_NOP tags,
   1261  1.1.1.1.2.2  skrll  * effectively removing it from the tree.
   1262  1.1.1.1.2.2  skrll  *
   1263  1.1.1.1.2.2  skrll  * This function will alter only the bytes in the blob which contain
   1264  1.1.1.1.2.2  skrll  * the node and its properties and subnodes, and will not alter or
   1265  1.1.1.1.2.2  skrll  * move any other part of the tree.
   1266  1.1.1.1.2.2  skrll  *
   1267  1.1.1.1.2.2  skrll  * returns:
   1268  1.1.1.1.2.2  skrll  *	0, on success
   1269  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1270  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1271  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1272  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1273  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1274  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1275  1.1.1.1.2.2  skrll  */
   1276  1.1.1.1.2.2  skrll int fdt_nop_node(void *fdt, int nodeoffset);
   1277  1.1.1.1.2.2  skrll 
   1278  1.1.1.1.2.2  skrll /**********************************************************************/
   1279  1.1.1.1.2.2  skrll /* Sequential write functions                                         */
   1280  1.1.1.1.2.2  skrll /**********************************************************************/
   1281  1.1.1.1.2.2  skrll 
   1282  1.1.1.1.2.2  skrll int fdt_create(void *buf, int bufsize);
   1283  1.1.1.1.2.2  skrll int fdt_resize(void *fdt, void *buf, int bufsize);
   1284  1.1.1.1.2.2  skrll int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);
   1285  1.1.1.1.2.2  skrll int fdt_finish_reservemap(void *fdt);
   1286  1.1.1.1.2.2  skrll int fdt_begin_node(void *fdt, const char *name);
   1287  1.1.1.1.2.2  skrll int fdt_property(void *fdt, const char *name, const void *val, int len);
   1288  1.1.1.1.2.2  skrll static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)
   1289  1.1.1.1.2.2  skrll {
   1290  1.1.1.1.2.2  skrll 	fdt32_t tmp = cpu_to_fdt32(val);
   1291  1.1.1.1.2.2  skrll 	return fdt_property(fdt, name, &tmp, sizeof(tmp));
   1292  1.1.1.1.2.2  skrll }
   1293  1.1.1.1.2.2  skrll static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)
   1294  1.1.1.1.2.2  skrll {
   1295  1.1.1.1.2.2  skrll 	fdt64_t tmp = cpu_to_fdt64(val);
   1296  1.1.1.1.2.2  skrll 	return fdt_property(fdt, name, &tmp, sizeof(tmp));
   1297  1.1.1.1.2.2  skrll }
   1298  1.1.1.1.2.2  skrll static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
   1299  1.1.1.1.2.2  skrll {
   1300  1.1.1.1.2.2  skrll 	return fdt_property_u32(fdt, name, val);
   1301  1.1.1.1.2.2  skrll }
   1302  1.1.1.1.2.2  skrll #define fdt_property_string(fdt, name, str) \
   1303  1.1.1.1.2.2  skrll 	fdt_property(fdt, name, str, strlen(str)+1)
   1304  1.1.1.1.2.2  skrll int fdt_end_node(void *fdt);
   1305  1.1.1.1.2.2  skrll int fdt_finish(void *fdt);
   1306  1.1.1.1.2.2  skrll 
   1307  1.1.1.1.2.2  skrll /**********************************************************************/
   1308  1.1.1.1.2.2  skrll /* Read-write functions                                               */
   1309  1.1.1.1.2.2  skrll /**********************************************************************/
   1310  1.1.1.1.2.2  skrll 
   1311  1.1.1.1.2.2  skrll int fdt_create_empty_tree(void *buf, int bufsize);
   1312  1.1.1.1.2.2  skrll int fdt_open_into(const void *fdt, void *buf, int bufsize);
   1313  1.1.1.1.2.2  skrll int fdt_pack(void *fdt);
   1314  1.1.1.1.2.2  skrll 
   1315  1.1.1.1.2.2  skrll /**
   1316  1.1.1.1.2.2  skrll  * fdt_add_mem_rsv - add one memory reserve map entry
   1317  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1318  1.1.1.1.2.2  skrll  * @address, @size: 64-bit values (native endian)
   1319  1.1.1.1.2.2  skrll  *
   1320  1.1.1.1.2.2  skrll  * Adds a reserve map entry to the given blob reserving a region at
   1321  1.1.1.1.2.2  skrll  * address address of length size.
   1322  1.1.1.1.2.2  skrll  *
   1323  1.1.1.1.2.2  skrll  * This function will insert data into the reserve map and will
   1324  1.1.1.1.2.2  skrll  * therefore change the indexes of some entries in the table.
   1325  1.1.1.1.2.2  skrll  *
   1326  1.1.1.1.2.2  skrll  * returns:
   1327  1.1.1.1.2.2  skrll  *	0, on success
   1328  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
   1329  1.1.1.1.2.2  skrll  *		contain the new reservation entry
   1330  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1331  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1332  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1333  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1334  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1335  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1336  1.1.1.1.2.2  skrll  */
   1337  1.1.1.1.2.2  skrll int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size);
   1338  1.1.1.1.2.2  skrll 
   1339  1.1.1.1.2.2  skrll /**
   1340  1.1.1.1.2.2  skrll  * fdt_del_mem_rsv - remove a memory reserve map entry
   1341  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1342  1.1.1.1.2.2  skrll  * @n: entry to remove
   1343  1.1.1.1.2.2  skrll  *
   1344  1.1.1.1.2.2  skrll  * fdt_del_mem_rsv() removes the n-th memory reserve map entry from
   1345  1.1.1.1.2.2  skrll  * the blob.
   1346  1.1.1.1.2.2  skrll  *
   1347  1.1.1.1.2.2  skrll  * This function will delete data from the reservation table and will
   1348  1.1.1.1.2.2  skrll  * therefore change the indexes of some entries in the table.
   1349  1.1.1.1.2.2  skrll  *
   1350  1.1.1.1.2.2  skrll  * returns:
   1351  1.1.1.1.2.2  skrll  *	0, on success
   1352  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there
   1353  1.1.1.1.2.2  skrll  *		are less than n+1 reserve map entries)
   1354  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1355  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1356  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1357  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1358  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1359  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1360  1.1.1.1.2.2  skrll  */
   1361  1.1.1.1.2.2  skrll int fdt_del_mem_rsv(void *fdt, int n);
   1362  1.1.1.1.2.2  skrll 
   1363  1.1.1.1.2.2  skrll /**
   1364  1.1.1.1.2.2  skrll  * fdt_set_name - change the name of a given node
   1365  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1366  1.1.1.1.2.2  skrll  * @nodeoffset: structure block offset of a node
   1367  1.1.1.1.2.2  skrll  * @name: name to give the node
   1368  1.1.1.1.2.2  skrll  *
   1369  1.1.1.1.2.2  skrll  * fdt_set_name() replaces the name (including unit address, if any)
   1370  1.1.1.1.2.2  skrll  * of the given node with the given string.  NOTE: this function can't
   1371  1.1.1.1.2.2  skrll  * efficiently check if the new name is unique amongst the given
   1372  1.1.1.1.2.2  skrll  * node's siblings; results are undefined if this function is invoked
   1373  1.1.1.1.2.2  skrll  * with a name equal to one of the given node's siblings.
   1374  1.1.1.1.2.2  skrll  *
   1375  1.1.1.1.2.2  skrll  * This function may insert or delete data from the blob, and will
   1376  1.1.1.1.2.2  skrll  * therefore change the offsets of some existing nodes.
   1377  1.1.1.1.2.2  skrll  *
   1378  1.1.1.1.2.2  skrll  * returns:
   1379  1.1.1.1.2.2  skrll  *	0, on success
   1380  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob
   1381  1.1.1.1.2.2  skrll  *		to contain the new name
   1382  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1383  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1384  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1385  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE, standard meanings
   1386  1.1.1.1.2.2  skrll  */
   1387  1.1.1.1.2.2  skrll int fdt_set_name(void *fdt, int nodeoffset, const char *name);
   1388  1.1.1.1.2.2  skrll 
   1389  1.1.1.1.2.2  skrll /**
   1390  1.1.1.1.2.2  skrll  * fdt_setprop - create or change a property
   1391  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1392  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to change
   1393  1.1.1.1.2.2  skrll  * @name: name of the property to change
   1394  1.1.1.1.2.2  skrll  * @val: pointer to data to set the property value to
   1395  1.1.1.1.2.2  skrll  * @len: length of the property value
   1396  1.1.1.1.2.2  skrll  *
   1397  1.1.1.1.2.2  skrll  * fdt_setprop() sets the value of the named property in the given
   1398  1.1.1.1.2.2  skrll  * node to the given value and length, creating the property if it
   1399  1.1.1.1.2.2  skrll  * does not already exist.
   1400  1.1.1.1.2.2  skrll  *
   1401  1.1.1.1.2.2  skrll  * This function may insert or delete data from the blob, and will
   1402  1.1.1.1.2.2  skrll  * therefore change the offsets of some existing nodes.
   1403  1.1.1.1.2.2  skrll  *
   1404  1.1.1.1.2.2  skrll  * returns:
   1405  1.1.1.1.2.2  skrll  *	0, on success
   1406  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
   1407  1.1.1.1.2.2  skrll  *		contain the new property value
   1408  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1409  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1410  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1411  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1412  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1413  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1414  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1415  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1416  1.1.1.1.2.2  skrll  */
   1417  1.1.1.1.2.2  skrll int fdt_setprop(void *fdt, int nodeoffset, const char *name,
   1418  1.1.1.1.2.2  skrll 		const void *val, int len);
   1419  1.1.1.1.2.2  skrll 
   1420  1.1.1.1.2.2  skrll /**
   1421  1.1.1.1.2.2  skrll  * fdt_setprop_u32 - set a property to a 32-bit integer
   1422  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1423  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to change
   1424  1.1.1.1.2.2  skrll  * @name: name of the property to change
   1425  1.1.1.1.2.2  skrll  * @val: 32-bit integer value for the property (native endian)
   1426  1.1.1.1.2.2  skrll  *
   1427  1.1.1.1.2.2  skrll  * fdt_setprop_u32() sets the value of the named property in the given
   1428  1.1.1.1.2.2  skrll  * node to the given 32-bit integer value (converting to big-endian if
   1429  1.1.1.1.2.2  skrll  * necessary), or creates a new property with that value if it does
   1430  1.1.1.1.2.2  skrll  * not already exist.
   1431  1.1.1.1.2.2  skrll  *
   1432  1.1.1.1.2.2  skrll  * This function may insert or delete data from the blob, and will
   1433  1.1.1.1.2.2  skrll  * therefore change the offsets of some existing nodes.
   1434  1.1.1.1.2.2  skrll  *
   1435  1.1.1.1.2.2  skrll  * returns:
   1436  1.1.1.1.2.2  skrll  *	0, on success
   1437  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
   1438  1.1.1.1.2.2  skrll  *		contain the new property value
   1439  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1440  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1441  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1442  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1443  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1444  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1445  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1446  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1447  1.1.1.1.2.2  skrll  */
   1448  1.1.1.1.2.2  skrll static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
   1449  1.1.1.1.2.2  skrll 				  uint32_t val)
   1450  1.1.1.1.2.2  skrll {
   1451  1.1.1.1.2.2  skrll 	fdt32_t tmp = cpu_to_fdt32(val);
   1452  1.1.1.1.2.2  skrll 	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
   1453  1.1.1.1.2.2  skrll }
   1454  1.1.1.1.2.2  skrll 
   1455  1.1.1.1.2.2  skrll /**
   1456  1.1.1.1.2.2  skrll  * fdt_setprop_u64 - set a property to a 64-bit integer
   1457  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1458  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to change
   1459  1.1.1.1.2.2  skrll  * @name: name of the property to change
   1460  1.1.1.1.2.2  skrll  * @val: 64-bit integer value for the property (native endian)
   1461  1.1.1.1.2.2  skrll  *
   1462  1.1.1.1.2.2  skrll  * fdt_setprop_u64() sets the value of the named property in the given
   1463  1.1.1.1.2.2  skrll  * node to the given 64-bit integer value (converting to big-endian if
   1464  1.1.1.1.2.2  skrll  * necessary), or creates a new property with that value if it does
   1465  1.1.1.1.2.2  skrll  * not already exist.
   1466  1.1.1.1.2.2  skrll  *
   1467  1.1.1.1.2.2  skrll  * This function may insert or delete data from the blob, and will
   1468  1.1.1.1.2.2  skrll  * therefore change the offsets of some existing nodes.
   1469  1.1.1.1.2.2  skrll  *
   1470  1.1.1.1.2.2  skrll  * returns:
   1471  1.1.1.1.2.2  skrll  *	0, on success
   1472  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
   1473  1.1.1.1.2.2  skrll  *		contain the new property value
   1474  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1475  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1476  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1477  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1478  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1479  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1480  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1481  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1482  1.1.1.1.2.2  skrll  */
   1483  1.1.1.1.2.2  skrll static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
   1484  1.1.1.1.2.2  skrll 				  uint64_t val)
   1485  1.1.1.1.2.2  skrll {
   1486  1.1.1.1.2.2  skrll 	fdt64_t tmp = cpu_to_fdt64(val);
   1487  1.1.1.1.2.2  skrll 	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
   1488  1.1.1.1.2.2  skrll }
   1489  1.1.1.1.2.2  skrll 
   1490  1.1.1.1.2.2  skrll /**
   1491  1.1.1.1.2.2  skrll  * fdt_setprop_cell - set a property to a single cell value
   1492  1.1.1.1.2.2  skrll  *
   1493  1.1.1.1.2.2  skrll  * This is an alternative name for fdt_setprop_u32()
   1494  1.1.1.1.2.2  skrll  */
   1495  1.1.1.1.2.2  skrll static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
   1496  1.1.1.1.2.2  skrll 				   uint32_t val)
   1497  1.1.1.1.2.2  skrll {
   1498  1.1.1.1.2.2  skrll 	return fdt_setprop_u32(fdt, nodeoffset, name, val);
   1499  1.1.1.1.2.2  skrll }
   1500  1.1.1.1.2.2  skrll 
   1501  1.1.1.1.2.2  skrll /**
   1502  1.1.1.1.2.2  skrll  * fdt_setprop_string - set a property to a string value
   1503  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1504  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to change
   1505  1.1.1.1.2.2  skrll  * @name: name of the property to change
   1506  1.1.1.1.2.2  skrll  * @str: string value for the property
   1507  1.1.1.1.2.2  skrll  *
   1508  1.1.1.1.2.2  skrll  * fdt_setprop_string() sets the value of the named property in the
   1509  1.1.1.1.2.2  skrll  * given node to the given string value (using the length of the
   1510  1.1.1.1.2.2  skrll  * string to determine the new length of the property), or creates a
   1511  1.1.1.1.2.2  skrll  * new property with that value if it does not already exist.
   1512  1.1.1.1.2.2  skrll  *
   1513  1.1.1.1.2.2  skrll  * This function may insert or delete data from the blob, and will
   1514  1.1.1.1.2.2  skrll  * therefore change the offsets of some existing nodes.
   1515  1.1.1.1.2.2  skrll  *
   1516  1.1.1.1.2.2  skrll  * returns:
   1517  1.1.1.1.2.2  skrll  *	0, on success
   1518  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
   1519  1.1.1.1.2.2  skrll  *		contain the new property value
   1520  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1521  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1522  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1523  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1524  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1525  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1526  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1527  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1528  1.1.1.1.2.2  skrll  */
   1529  1.1.1.1.2.2  skrll #define fdt_setprop_string(fdt, nodeoffset, name, str) \
   1530  1.1.1.1.2.2  skrll 	fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
   1531  1.1.1.1.2.2  skrll 
   1532  1.1.1.1.2.3  skrll 
   1533  1.1.1.1.2.3  skrll /**
   1534  1.1.1.1.2.3  skrll  * fdt_setprop_empty - set a property to an empty value
   1535  1.1.1.1.2.3  skrll  * @fdt: pointer to the device tree blob
   1536  1.1.1.1.2.3  skrll  * @nodeoffset: offset of the node whose property to change
   1537  1.1.1.1.2.3  skrll  * @name: name of the property to change
   1538  1.1.1.1.2.3  skrll  *
   1539  1.1.1.1.2.3  skrll  * fdt_setprop_empty() sets the value of the named property in the
   1540  1.1.1.1.2.3  skrll  * given node to an empty (zero length) value, or creates a new empty
   1541  1.1.1.1.2.3  skrll  * property if it does not already exist.
   1542  1.1.1.1.2.3  skrll  *
   1543  1.1.1.1.2.3  skrll  * This function may insert or delete data from the blob, and will
   1544  1.1.1.1.2.3  skrll  * therefore change the offsets of some existing nodes.
   1545  1.1.1.1.2.3  skrll  *
   1546  1.1.1.1.2.3  skrll  * returns:
   1547  1.1.1.1.2.3  skrll  *	0, on success
   1548  1.1.1.1.2.3  skrll  *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
   1549  1.1.1.1.2.3  skrll  *		contain the new property value
   1550  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1551  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADLAYOUT,
   1552  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADMAGIC,
   1553  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADVERSION,
   1554  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADSTATE,
   1555  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1556  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADLAYOUT,
   1557  1.1.1.1.2.3  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1558  1.1.1.1.2.3  skrll  */
   1559  1.1.1.1.2.3  skrll #define fdt_setprop_empty(fdt, nodeoffset, name) \
   1560  1.1.1.1.2.3  skrll 	fdt_setprop((fdt), (nodeoffset), (name), NULL, 0)
   1561  1.1.1.1.2.3  skrll 
   1562  1.1.1.1.2.2  skrll /**
   1563  1.1.1.1.2.2  skrll  * fdt_appendprop - append to or create a property
   1564  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1565  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to change
   1566  1.1.1.1.2.2  skrll  * @name: name of the property to append to
   1567  1.1.1.1.2.2  skrll  * @val: pointer to data to append to the property value
   1568  1.1.1.1.2.2  skrll  * @len: length of the data to append to the property value
   1569  1.1.1.1.2.2  skrll  *
   1570  1.1.1.1.2.2  skrll  * fdt_appendprop() appends the value to the named property in the
   1571  1.1.1.1.2.2  skrll  * given node, creating the property if it does not already exist.
   1572  1.1.1.1.2.2  skrll  *
   1573  1.1.1.1.2.2  skrll  * This function may insert data into the blob, and will therefore
   1574  1.1.1.1.2.2  skrll  * change the offsets of some existing nodes.
   1575  1.1.1.1.2.2  skrll  *
   1576  1.1.1.1.2.2  skrll  * returns:
   1577  1.1.1.1.2.2  skrll  *	0, on success
   1578  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
   1579  1.1.1.1.2.2  skrll  *		contain the new property value
   1580  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1581  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1582  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1583  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1584  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1585  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1586  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1587  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1588  1.1.1.1.2.2  skrll  */
   1589  1.1.1.1.2.2  skrll int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
   1590  1.1.1.1.2.2  skrll 		   const void *val, int len);
   1591  1.1.1.1.2.2  skrll 
   1592  1.1.1.1.2.2  skrll /**
   1593  1.1.1.1.2.2  skrll  * fdt_appendprop_u32 - append a 32-bit integer value to a property
   1594  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1595  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to change
   1596  1.1.1.1.2.2  skrll  * @name: name of the property to change
   1597  1.1.1.1.2.2  skrll  * @val: 32-bit integer value to append to the property (native endian)
   1598  1.1.1.1.2.2  skrll  *
   1599  1.1.1.1.2.2  skrll  * fdt_appendprop_u32() appends the given 32-bit integer value
   1600  1.1.1.1.2.2  skrll  * (converting to big-endian if necessary) to the value of the named
   1601  1.1.1.1.2.2  skrll  * property in the given node, or creates a new property with that
   1602  1.1.1.1.2.2  skrll  * value if it does not already exist.
   1603  1.1.1.1.2.2  skrll  *
   1604  1.1.1.1.2.2  skrll  * This function may insert data into the blob, and will therefore
   1605  1.1.1.1.2.2  skrll  * change the offsets of some existing nodes.
   1606  1.1.1.1.2.2  skrll  *
   1607  1.1.1.1.2.2  skrll  * returns:
   1608  1.1.1.1.2.2  skrll  *	0, on success
   1609  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
   1610  1.1.1.1.2.2  skrll  *		contain the new property value
   1611  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1612  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1613  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1614  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1615  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1616  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1617  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1618  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1619  1.1.1.1.2.2  skrll  */
   1620  1.1.1.1.2.2  skrll static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
   1621  1.1.1.1.2.2  skrll 				     const char *name, uint32_t val)
   1622  1.1.1.1.2.2  skrll {
   1623  1.1.1.1.2.2  skrll 	fdt32_t tmp = cpu_to_fdt32(val);
   1624  1.1.1.1.2.2  skrll 	return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
   1625  1.1.1.1.2.2  skrll }
   1626  1.1.1.1.2.2  skrll 
   1627  1.1.1.1.2.2  skrll /**
   1628  1.1.1.1.2.2  skrll  * fdt_appendprop_u64 - append a 64-bit integer value to a property
   1629  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1630  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to change
   1631  1.1.1.1.2.2  skrll  * @name: name of the property to change
   1632  1.1.1.1.2.2  skrll  * @val: 64-bit integer value to append to the property (native endian)
   1633  1.1.1.1.2.2  skrll  *
   1634  1.1.1.1.2.2  skrll  * fdt_appendprop_u64() appends the given 64-bit integer value
   1635  1.1.1.1.2.2  skrll  * (converting to big-endian if necessary) to the value of the named
   1636  1.1.1.1.2.2  skrll  * property in the given node, or creates a new property with that
   1637  1.1.1.1.2.2  skrll  * value if it does not already exist.
   1638  1.1.1.1.2.2  skrll  *
   1639  1.1.1.1.2.2  skrll  * This function may insert data into the blob, and will therefore
   1640  1.1.1.1.2.2  skrll  * change the offsets of some existing nodes.
   1641  1.1.1.1.2.2  skrll  *
   1642  1.1.1.1.2.2  skrll  * returns:
   1643  1.1.1.1.2.2  skrll  *	0, on success
   1644  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
   1645  1.1.1.1.2.2  skrll  *		contain the new property value
   1646  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1647  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1648  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1649  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1650  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1651  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1652  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1653  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1654  1.1.1.1.2.2  skrll  */
   1655  1.1.1.1.2.2  skrll static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
   1656  1.1.1.1.2.2  skrll 				     const char *name, uint64_t val)
   1657  1.1.1.1.2.2  skrll {
   1658  1.1.1.1.2.2  skrll 	fdt64_t tmp = cpu_to_fdt64(val);
   1659  1.1.1.1.2.2  skrll 	return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
   1660  1.1.1.1.2.2  skrll }
   1661  1.1.1.1.2.2  skrll 
   1662  1.1.1.1.2.2  skrll /**
   1663  1.1.1.1.2.2  skrll  * fdt_appendprop_cell - append a single cell value to a property
   1664  1.1.1.1.2.2  skrll  *
   1665  1.1.1.1.2.2  skrll  * This is an alternative name for fdt_appendprop_u32()
   1666  1.1.1.1.2.2  skrll  */
   1667  1.1.1.1.2.2  skrll static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
   1668  1.1.1.1.2.2  skrll 				      const char *name, uint32_t val)
   1669  1.1.1.1.2.2  skrll {
   1670  1.1.1.1.2.2  skrll 	return fdt_appendprop_u32(fdt, nodeoffset, name, val);
   1671  1.1.1.1.2.2  skrll }
   1672  1.1.1.1.2.2  skrll 
   1673  1.1.1.1.2.2  skrll /**
   1674  1.1.1.1.2.2  skrll  * fdt_appendprop_string - append a string to a property
   1675  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1676  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to change
   1677  1.1.1.1.2.2  skrll  * @name: name of the property to change
   1678  1.1.1.1.2.2  skrll  * @str: string value to append to the property
   1679  1.1.1.1.2.2  skrll  *
   1680  1.1.1.1.2.2  skrll  * fdt_appendprop_string() appends the given string to the value of
   1681  1.1.1.1.2.2  skrll  * the named property in the given node, or creates a new property
   1682  1.1.1.1.2.2  skrll  * with that value if it does not already exist.
   1683  1.1.1.1.2.2  skrll  *
   1684  1.1.1.1.2.2  skrll  * This function may insert data into the blob, and will therefore
   1685  1.1.1.1.2.2  skrll  * change the offsets of some existing nodes.
   1686  1.1.1.1.2.2  skrll  *
   1687  1.1.1.1.2.2  skrll  * returns:
   1688  1.1.1.1.2.2  skrll  *	0, on success
   1689  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
   1690  1.1.1.1.2.2  skrll  *		contain the new property value
   1691  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1692  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1693  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1694  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1695  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1696  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1697  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1698  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1699  1.1.1.1.2.2  skrll  */
   1700  1.1.1.1.2.2  skrll #define fdt_appendprop_string(fdt, nodeoffset, name, str) \
   1701  1.1.1.1.2.2  skrll 	fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
   1702  1.1.1.1.2.2  skrll 
   1703  1.1.1.1.2.2  skrll /**
   1704  1.1.1.1.2.2  skrll  * fdt_delprop - delete a property
   1705  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1706  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node whose property to nop
   1707  1.1.1.1.2.2  skrll  * @name: name of the property to nop
   1708  1.1.1.1.2.2  skrll  *
   1709  1.1.1.1.2.2  skrll  * fdt_del_property() will delete the given property.
   1710  1.1.1.1.2.2  skrll  *
   1711  1.1.1.1.2.2  skrll  * This function will delete data from the blob, and will therefore
   1712  1.1.1.1.2.2  skrll  * change the offsets of some existing nodes.
   1713  1.1.1.1.2.2  skrll  *
   1714  1.1.1.1.2.2  skrll  * returns:
   1715  1.1.1.1.2.2  skrll  *	0, on success
   1716  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, node does not have the named property
   1717  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1718  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1719  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1720  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1721  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1722  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1723  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1724  1.1.1.1.2.2  skrll  */
   1725  1.1.1.1.2.2  skrll int fdt_delprop(void *fdt, int nodeoffset, const char *name);
   1726  1.1.1.1.2.2  skrll 
   1727  1.1.1.1.2.2  skrll /**
   1728  1.1.1.1.2.2  skrll  * fdt_add_subnode_namelen - creates a new node based on substring
   1729  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1730  1.1.1.1.2.2  skrll  * @parentoffset: structure block offset of a node
   1731  1.1.1.1.2.2  skrll  * @name: name of the subnode to locate
   1732  1.1.1.1.2.2  skrll  * @namelen: number of characters of name to consider
   1733  1.1.1.1.2.2  skrll  *
   1734  1.1.1.1.2.2  skrll  * Identical to fdt_add_subnode(), but use only the first namelen
   1735  1.1.1.1.2.2  skrll  * characters of name as the name of the new node.  This is useful for
   1736  1.1.1.1.2.2  skrll  * creating subnodes based on a portion of a larger string, such as a
   1737  1.1.1.1.2.2  skrll  * full path.
   1738  1.1.1.1.2.2  skrll  */
   1739  1.1.1.1.2.2  skrll int fdt_add_subnode_namelen(void *fdt, int parentoffset,
   1740  1.1.1.1.2.2  skrll 			    const char *name, int namelen);
   1741  1.1.1.1.2.2  skrll 
   1742  1.1.1.1.2.2  skrll /**
   1743  1.1.1.1.2.2  skrll  * fdt_add_subnode - creates a new node
   1744  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1745  1.1.1.1.2.2  skrll  * @parentoffset: structure block offset of a node
   1746  1.1.1.1.2.2  skrll  * @name: name of the subnode to locate
   1747  1.1.1.1.2.2  skrll  *
   1748  1.1.1.1.2.2  skrll  * fdt_add_subnode() creates a new node as a subnode of the node at
   1749  1.1.1.1.2.2  skrll  * structure block offset parentoffset, with the given name (which
   1750  1.1.1.1.2.2  skrll  * should include the unit address, if any).
   1751  1.1.1.1.2.2  skrll  *
   1752  1.1.1.1.2.2  skrll  * This function will insert data into the blob, and will therefore
   1753  1.1.1.1.2.2  skrll  * change the offsets of some existing nodes.
   1754  1.1.1.1.2.2  skrll 
   1755  1.1.1.1.2.2  skrll  * returns:
   1756  1.1.1.1.2.3  skrll  *	structure block offset of the created nodeequested subnode (>=0), on
   1757  1.1.1.1.2.3  skrll  *		success
   1758  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOTFOUND, if the requested subnode does not exist
   1759  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE
   1760  1.1.1.1.2.3  skrll  *		tag
   1761  1.1.1.1.2.2  skrll  *	-FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of
   1762  1.1.1.1.2.2  skrll  *		the given name
   1763  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE, if there is insufficient free space in the
   1764  1.1.1.1.2.2  skrll  *		blob to contain the new node
   1765  1.1.1.1.2.2  skrll  *	-FDT_ERR_NOSPACE
   1766  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT
   1767  1.1.1.1.2.2  skrll  *      -FDT_ERR_BADMAGIC,
   1768  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1769  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1770  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1771  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings.
   1772  1.1.1.1.2.2  skrll  */
   1773  1.1.1.1.2.2  skrll int fdt_add_subnode(void *fdt, int parentoffset, const char *name);
   1774  1.1.1.1.2.2  skrll 
   1775  1.1.1.1.2.2  skrll /**
   1776  1.1.1.1.2.2  skrll  * fdt_del_node - delete a node (subtree)
   1777  1.1.1.1.2.2  skrll  * @fdt: pointer to the device tree blob
   1778  1.1.1.1.2.2  skrll  * @nodeoffset: offset of the node to nop
   1779  1.1.1.1.2.2  skrll  *
   1780  1.1.1.1.2.2  skrll  * fdt_del_node() will remove the given node, including all its
   1781  1.1.1.1.2.2  skrll  * subnodes if any, from the blob.
   1782  1.1.1.1.2.2  skrll  *
   1783  1.1.1.1.2.2  skrll  * This function will delete data from the blob, and will therefore
   1784  1.1.1.1.2.2  skrll  * change the offsets of some existing nodes.
   1785  1.1.1.1.2.2  skrll  *
   1786  1.1.1.1.2.2  skrll  * returns:
   1787  1.1.1.1.2.2  skrll  *	0, on success
   1788  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
   1789  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADLAYOUT,
   1790  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADMAGIC,
   1791  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADVERSION,
   1792  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTATE,
   1793  1.1.1.1.2.2  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1794  1.1.1.1.2.2  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1795  1.1.1.1.2.2  skrll  */
   1796  1.1.1.1.2.2  skrll int fdt_del_node(void *fdt, int nodeoffset);
   1797  1.1.1.1.2.2  skrll 
   1798  1.1.1.1.2.3  skrll /**
   1799  1.1.1.1.2.3  skrll  * fdt_overlay_apply - Applies a DT overlay on a base DT
   1800  1.1.1.1.2.3  skrll  * @fdt: pointer to the base device tree blob
   1801  1.1.1.1.2.3  skrll  * @fdto: pointer to the device tree overlay blob
   1802  1.1.1.1.2.3  skrll  *
   1803  1.1.1.1.2.3  skrll  * fdt_overlay_apply() will apply the given device tree overlay on the
   1804  1.1.1.1.2.3  skrll  * given base device tree.
   1805  1.1.1.1.2.3  skrll  *
   1806  1.1.1.1.2.3  skrll  * Expect the base device tree to be modified, even if the function
   1807  1.1.1.1.2.3  skrll  * returns an error.
   1808  1.1.1.1.2.3  skrll  *
   1809  1.1.1.1.2.3  skrll  * returns:
   1810  1.1.1.1.2.3  skrll  *	0, on success
   1811  1.1.1.1.2.3  skrll  *	-FDT_ERR_NOSPACE, there's not enough space in the base device tree
   1812  1.1.1.1.2.3  skrll  *	-FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or
   1813  1.1.1.1.2.3  skrll  *		properties in the base DT
   1814  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADPHANDLE,
   1815  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOVERLAY,
   1816  1.1.1.1.2.3  skrll  *	-FDT_ERR_NOPHANDLES,
   1817  1.1.1.1.2.3  skrll  *	-FDT_ERR_INTERNAL,
   1818  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADLAYOUT,
   1819  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADMAGIC,
   1820  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADOFFSET,
   1821  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADPATH,
   1822  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADVERSION,
   1823  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADSTRUCTURE,
   1824  1.1.1.1.2.3  skrll  *	-FDT_ERR_BADSTATE,
   1825  1.1.1.1.2.3  skrll  *	-FDT_ERR_TRUNCATED, standard meanings
   1826  1.1.1.1.2.3  skrll  */
   1827  1.1.1.1.2.3  skrll int fdt_overlay_apply(void *fdt, void *fdto);
   1828  1.1.1.1.2.3  skrll 
   1829  1.1.1.1.2.2  skrll /**********************************************************************/
   1830  1.1.1.1.2.2  skrll /* Debugging / informational functions                                */
   1831  1.1.1.1.2.2  skrll /**********************************************************************/
   1832  1.1.1.1.2.2  skrll 
   1833  1.1.1.1.2.2  skrll const char *fdt_strerror(int errval);
   1834  1.1.1.1.2.2  skrll 
   1835  1.1.1.1.2.2  skrll #endif /* _LIBFDT_H */
   1836