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