blob: 4ef65bce9779ef49da8f1b5363d1a3b5945405db [file] [log] [blame]
David Gibson3da0f9a2006-11-27 16:21:28 +11001#ifndef _LIBFDT_H
2#define _LIBFDT_H
3/*
4 * libfdt - Flat Device Tree manipulation
5 * Copyright (C) 2006 David Gibson, IBM Corporation.
6 *
David Gibson94816052007-06-13 16:30:48 +10007 * libfdt is dual licensed: you can use it either under the terms of
8 * the GPL, or the BSD license, at your option.
David Gibson3da0f9a2006-11-27 16:21:28 +11009 *
David Gibson94816052007-06-13 16:30:48 +100010 * a) This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version.
David Gibson3da0f9a2006-11-27 16:21:28 +110014 *
David Gibson94816052007-06-13 16:30:48 +100015 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public
21 * License along with this library; if not, write to the Free
22 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
23 * MA 02110-1301 USA
24 *
25 * Alternatively,
26 *
27 * b) Redistribution and use in source and binary forms, with or
28 * without modification, are permitted provided that the following
29 * conditions are met:
30 *
31 * 1. Redistributions of source code must retain the above
32 * copyright notice, this list of conditions and the following
33 * disclaimer.
34 * 2. Redistributions in binary form must reproduce the above
35 * copyright notice, this list of conditions and the following
36 * disclaimer in the documentation and/or other materials
37 * provided with the distribution.
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
40 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
41 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
42 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
44 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
49 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
50 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
51 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
David Gibson3da0f9a2006-11-27 16:21:28 +110052 */
53
David Gibsonede25de2006-12-01 15:02:10 +110054#include <libfdt_env.h>
David Gibson6f8b7712007-10-16 13:50:34 +100055#include <fdt.h>
David Gibson3da0f9a2006-11-27 16:21:28 +110056
57#define FDT_FIRST_SUPPORTED_VERSION 0x10
David Gibsonfe92f6b2006-12-01 16:25:39 +110058#define FDT_LAST_SUPPORTED_VERSION 0x11
David Gibson3da0f9a2006-11-27 16:21:28 +110059
David Gibson3aea8282006-12-15 15:12:52 +110060/* Error codes: informative error codes */
61#define FDT_ERR_NOTFOUND 1
David Gibsoncec0c382007-10-24 17:10:58 +100062 /* FDT_ERR_NOTFOUND: The requested node or property does not exist */
David Gibson3aea8282006-12-15 15:12:52 +110063#define FDT_ERR_EXISTS 2
David Gibsoncec0c382007-10-24 17:10:58 +100064 /* FDT_ERR_EXISTS: Attemped to create a node or property which
65 * already exists */
David Gibson3aea8282006-12-15 15:12:52 +110066#define FDT_ERR_NOSPACE 3
David Gibsoncec0c382007-10-24 17:10:58 +100067 /* FDT_ERR_NOSPACE: Operation needed to expand the device
68 * tree, but its buffer did not have sufficient space to
69 * contain the expanded tree. Use fdt_open_into() to move the
70 * device tree to a buffer with more space. */
David Gibson3da0f9a2006-11-27 16:21:28 +110071
David Gibson3aea8282006-12-15 15:12:52 +110072/* Error codes: codes for bad parameters */
73#define FDT_ERR_BADOFFSET 4
David Gibsoncec0c382007-10-24 17:10:58 +100074 /* FDT_ERR_BADOFFSET: Function was passed a structure block
75 * offset which is out-of-bounds, or which points to an
76 * unsuitable part of the structure for the operation. */
David Gibson3aea8282006-12-15 15:12:52 +110077#define FDT_ERR_BADPATH 5
David Gibsoncec0c382007-10-24 17:10:58 +100078 /* FDT_ERR_BADPATH: Function was passed a badly formatted path
79 * (e.g. missing a leading / for a function which requires an
80 * absolute path) */
David Gibson3aea8282006-12-15 15:12:52 +110081#define FDT_ERR_BADSTATE 6
David Gibsoncec0c382007-10-24 17:10:58 +100082 /* FDT_ERR_BADSTATE: Function was passed an incomplete device
83 * tree created by the sequential-write functions, which is
84 * not sufficiently complete for the requested operation. */
David Gibson3aea8282006-12-15 15:12:52 +110085
86/* Error codes: codes for bad device tree blobs */
87#define FDT_ERR_TRUNCATED 7
David Gibsoncec0c382007-10-24 17:10:58 +100088 /* FDT_ERR_TRUNCATED: Structure block of the given device tree
89 * ends without an FDT_END tag. */
David Gibson3aea8282006-12-15 15:12:52 +110090#define FDT_ERR_BADMAGIC 8
David Gibsoncec0c382007-10-24 17:10:58 +100091 /* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a
92 * device tree at all - it is missing the flattened device
93 * tree magic number. */
David Gibson3aea8282006-12-15 15:12:52 +110094#define FDT_ERR_BADVERSION 9
David Gibsoncec0c382007-10-24 17:10:58 +100095 /* FDT_ERR_BADVERSION: Given device tree has a version which
96 * can't be handled by the requested operation. For
97 * read-write functions, this may mean that fdt_open_into() is
98 * required to convert the tree to the expected version. */
David Gibson3aea8282006-12-15 15:12:52 +110099#define FDT_ERR_BADSTRUCTURE 10
David Gibsoncec0c382007-10-24 17:10:58 +1000100 /* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt
101 * structure block or other serious error (e.g. misnested
102 * nodes, or subnodes preceding properties). */
David Gibson3aea8282006-12-15 15:12:52 +1100103#define FDT_ERR_BADLAYOUT 11
David Gibsoncec0c382007-10-24 17:10:58 +1000104 /* FDT_ERR_BADLAYOUT: For read-write functions, the given
105 * device tree has it's sub-blocks in an order that the
106 * function can't handle (memory reserve map, then structure,
107 * then strings). Use fdt_open_into() to reorganize the tree
108 * into a form suitable for the read-write operations. */
David Gibson3aea8282006-12-15 15:12:52 +1100109
David Gibson12482372007-08-30 14:54:04 +1000110/* "Can't happen" error indicating a bug in libfdt */
111#define FDT_ERR_INTERNAL 12
David Gibsoncec0c382007-10-24 17:10:58 +1000112 /* FDT_ERR_INTERNAL: libfdt has failed an internal assertion.
113 * Indicates a bug in libfdt itself. */
David Gibson12482372007-08-30 14:54:04 +1000114
115#define FDT_ERR_MAX 12
David Gibson3da0f9a2006-11-27 16:21:28 +1100116
David Gibsoncec0c382007-10-24 17:10:58 +1000117/**********************************************************************/
118/* Low-level functions (you probably don't need these) */
119/**********************************************************************/
David Gibson96b5fad2007-10-24 10:28:52 +1000120
121const void *fdt_offset_ptr(const void *fdt, int offset, int checklen);
122static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
123{
124 return (void *)fdt_offset_ptr(fdt, offset, checklen);
125}
126
127
128#define fdt_offset_ptr_typed(fdt, offset, var) \
129 ((typeof(var))(fdt_offset_ptr((fdt), (offset), sizeof(*(var)))))
130#define fdt_offset_ptr_typed_w(fdt, offset, var) \
131 ((typeof(var))(fdt_offset_ptr_w((fdt), (offset), sizeof(*(var)))))
132
David Gibson3c44c872007-10-24 11:06:09 +1000133uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
David Gibson96b5fad2007-10-24 10:28:52 +1000134
David Gibsoncec0c382007-10-24 17:10:58 +1000135/**********************************************************************/
136/* General functions */
137/**********************************************************************/
138
David Gibson73d60922006-12-15 15:12:47 +1100139#define fdt_get_header(fdt, field) \
David Gibsona6c76f92007-06-13 14:18:10 +1000140 (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
David Gibson73d60922006-12-15 15:12:47 +1100141#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
142#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))
143#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))
144#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings))
145#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap))
146#define fdt_version(fdt) (fdt_get_header(fdt, version))
147#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version))
148#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys))
149#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))
150#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))
David Gibsonede25de2006-12-01 15:02:10 +1100151
David Gibson9b911342007-10-25 14:29:38 +1000152#define __fdt_set_hdr(name) \
153 static inline void fdt_set_##name(void *fdt, uint32_t val) \
154 { \
155 struct fdt_header *fdth = fdt; \
156 fdth->name = cpu_to_fdt32(val); \
157 }
158__fdt_set_hdr(magic);
159__fdt_set_hdr(totalsize);
160__fdt_set_hdr(off_dt_struct);
161__fdt_set_hdr(off_dt_strings);
162__fdt_set_hdr(off_mem_rsvmap);
163__fdt_set_hdr(version);
164__fdt_set_hdr(last_comp_version);
165__fdt_set_hdr(boot_cpuid_phys);
166__fdt_set_hdr(size_dt_strings);
167__fdt_set_hdr(size_dt_struct);
168#undef __fdt_set_hdr
David Gibson73d60922006-12-15 15:12:47 +1100169
David Gibsoncec0c382007-10-24 17:10:58 +1000170/**
171 * fdt_check_header - sanity check a device tree or possible device tree
172 * @fdt: pointer to data which might be a flattened device tree
173 *
174 * fdt_check_header() checks that the given buffer contains what
175 * appears to be a flattened device tree with sane information in its
176 * header.
177 *
178 * returns:
179 * 0, if the buffer appears to contain a valid device tree
180 * -FDT_ERR_BADMAGIC,
181 * -FDT_ERR_BADVERSION,
182 * -FDT_ERR_BADSTATE, standard meanings, as above
183 */
David Gibson96b5fad2007-10-24 10:28:52 +1000184int fdt_check_header(const void *fdt);
David Gibsoncec0c382007-10-24 17:10:58 +1000185
186/**
187 * fdt_move - move a device tree around in memory
188 * @fdt: pointer to the device tree to move
189 * @buf: pointer to memory where the device is to be moved
190 * @bufsize: size of the memory space at buf
191 *
192 * fdt_move() relocates, if possible, the device tree blob located at
193 * fdt to the buffer at buf of size bufsize. The buffer may overlap
194 * with the existing device tree blob at fdt. Therefore,
195 * fdt_move(fdt, fdt, fdt_totalsize(fdt))
196 * should always succeed.
197 *
198 * returns:
199 * 0, on success
200 * -FDT_ERR_NOSPACE, bufsize is insufficient to contain the device tree
201 * -FDT_ERR_BADMAGIC,
202 * -FDT_ERR_BADVERSION,
203 * -FDT_ERR_BADSTATE, standard meanings
204 */
David Gibson73d60922006-12-15 15:12:47 +1100205int fdt_move(const void *fdt, void *buf, int bufsize);
David Gibson42369762006-12-01 15:07:19 +1100206
David Gibsoncec0c382007-10-24 17:10:58 +1000207/**********************************************************************/
208/* Read-only functions */
209/**********************************************************************/
210
211/**
212 * fdt_string - retreive a string from the strings block of a device tree
213 * @fdt: pointer to the device tree blob
214 * @stroffset: offset of the string within the strings block (native endian)
215 *
216 * fdt_string() retrieves a pointer to a single string from the
217 * strings block of the device tree blob at fdt.
218 *
219 * returns:
220 * a pointer to the string, on success
221 * NULL, if stroffset is out of bounds
222 */
David Gibson11d53022007-10-18 12:10:42 +1000223const char *fdt_string(const void *fdt, int stroffset);
David Gibson3aa4cfd2006-11-29 16:34:30 +1100224
David Gibsoncec0c382007-10-24 17:10:58 +1000225/**
226 * fdt_num_mem_rsv - retreive the number of memory reserve map entries
227 * @fdt: pointer to the device tree blob
228 *
229 * Returns the number of entries in the device tree blob's memory
230 * reservation map. This does not include the terminating 0,0 entry
231 * or any other (0,0) entries reserved for expansion.
232 *
233 * returns:
234 * the number of entries
235 */
David Gibsonfd1bf3a2007-10-10 17:12:12 +1000236int fdt_num_mem_rsv(const void *fdt);
237
David Gibsoncec0c382007-10-24 17:10:58 +1000238/**
239 * fdt_get_mem_rsv - retreive one memory reserve map entry
240 * @fdt: pointer to the device tree blob
241 * @address, @size: pointers to 64-bit variables
242 *
243 * On success, *address and *size will contain the address and size of
244 * the n-th reserve map entry from the device tree blob, in
245 * native-endian format.
246 *
247 * returns:
248 * 0, on success
249 * -FDT_ERR_BADMAGIC,
250 * -FDT_ERR_BADVERSION,
251 * -FDT_ERR_BADSTATE, standard meanings
252 */
253int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);
254
David Gibson57f99b72007-10-25 11:27:31 +1000255/**
256 * fdt_subnode_offset_namelen - find a subnode based on substring
257 * @fdt: pointer to the device tree blob
258 * @parentoffset: structure block offset of a node
259 * @name: name of the subnode to locate
260 * @namelen: number of characters of name to consider
261 *
262 * Identical to fdt_subnode_offset(), but only examine the first
263 * namelen characters of name for matching the subnode name. This is
264 * useful for finding subnodes based on a portion of a larger string,
265 * such as a full path.
266 */
David Gibson73d60922006-12-15 15:12:47 +1100267int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
David Gibson3da0f9a2006-11-27 16:21:28 +1100268 const char *name, int namelen);
David Gibson57f99b72007-10-25 11:27:31 +1000269/**
270 * fdt_subnode_offset - find a subnode of a given node
271 * @fdt: pointer to the device tree blob
272 * @parentoffset: structure block offset of a node
273 * @name: name of the subnode to locate
274 *
275 * fdt_subnode_offset() finds a subnode of the node at structure block
276 * offset parentoffset with the given name. name may include a unit
277 * address, in which case fdt_subnode_offset() will find the subnode
278 * with that unit address, or the unit address may be omitted, in
279 * which case fdt_subnode_offset() will find an arbitrary subnode
280 * whose name excluding unit address matches the given name.
281 *
282 * returns:
283 * structure block offset of the requested subnode (>=0), on success
284 * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
285 * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag
286 * -FDT_ERR_BADMAGIC,
287 * -FDT_ERR_BADVERSION,
288 * -FDT_ERR_BADSTATE,
289 * -FDT_ERR_BADSTRUCTURE,
290 * -FDT_ERR_TRUNCATED, standard meanings.
291 */
David Gibson73d60922006-12-15 15:12:47 +1100292int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
David Gibson3da0f9a2006-11-27 16:21:28 +1100293
David Gibson57f99b72007-10-25 11:27:31 +1000294/**
295 * fdt_path_offset - find a tree node by its full path
296 * @fdt: pointer to the device tree blob
297 * @path: full path of the node to locate
298 *
299 * fdt_path_offset() finds a node of a given path in the device tree.
300 * Each path component may omit the unit address portion, but the
301 * results of this are undefined if any such path component is
302 * ambiguous (that is if there are multiple nodes at the relevant
303 * level matching the given component, differentiated only by unit
304 * address).
305 *
306 * returns:
307 * structure block offset of the node with the requested path (>=0), on success
308 * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid
309 * -FDT_ERR_NOTFOUND, if the requested node does not exist
310 * -FDT_ERR_BADMAGIC,
311 * -FDT_ERR_BADVERSION,
312 * -FDT_ERR_BADSTATE,
313 * -FDT_ERR_BADSTRUCTURE,
314 * -FDT_ERR_TRUNCATED, standard meanings.
315 */
David Gibson73d60922006-12-15 15:12:47 +1100316int fdt_path_offset(const void *fdt, const char *path);
David Gibson3da0f9a2006-11-27 16:21:28 +1100317
David Gibson57f99b72007-10-25 11:27:31 +1000318/**
319 * fdt_get_name - retreive the name of a given node
320 * @fdt: pointer to the device tree blob
321 * @nodeoffset: structure block offset of the starting node
322 * @len: pointer to an intger variable (will be overwritten) or NULL
323 *
324 * fdt_get_name() retrieves the name (including unit address) of the
325 * device tree node at structure block offset nodeoffset. If len is
326 * non-NULL, the length of this name is also returned, in the integer
327 * pointed to by len.
328 *
329 * returns:
330 * pointer to the node's name, on success
331 * *len contains the length of that name (>=0)
332 * NULL, on error
333 * *len contains an error code (<0):
334 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
335 * -FDT_ERR_BADMAGIC,
336 * -FDT_ERR_BADVERSION,
337 * -FDT_ERR_BADSTATE, standard meanings
338 */
339const char *fdt_get_name(const void *fdt, int nodeoffset, int *len);
David Gibson9d26eab2007-08-30 14:54:04 +1000340
David Gibsona6c76f92007-06-13 14:18:10 +1000341const struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset,
342 const char *name, int *lenp);
343
344static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
345 const char *name,
346 int *lenp)
347{
348 return (struct fdt_property *)fdt_get_property(fdt, nodeoffset,
349 name, lenp);
350}
351
352const void *fdt_getprop(const void *fdt, int nodeoffset,
353 const char *name, int *lenp);
354static inline void *fdt_getprop_w(void *fdt, int nodeoffset,
355 const char *name, int *lenp)
356{
357 return (void *)fdt_getprop(fdt, nodeoffset, name, lenp);
358}
David Gibson3da0f9a2006-11-27 16:21:28 +1100359
David Gibson037db262007-08-30 14:54:04 +1000360int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);
361
David Gibson12482372007-08-30 14:54:04 +1000362int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
363 int supernodedepth, int *nodedepth);
364int fdt_node_depth(const void *fdt, int nodeoffset);
365int fdt_parent_offset(const void *fdt, int nodeoffset);
366
David Gibsonae1454b2007-09-17 14:28:34 +1000367int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
368 const char *propname,
369 const void *propval, int proplen);
370
David Gibson333542f2007-10-16 13:58:25 +1000371int fdt_node_check_compatible(const void *fdt, int nodeoffset,
372 const char *compatible);
373int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
374 const char *compatible);
375
David Gibsoncec0c382007-10-24 17:10:58 +1000376/**********************************************************************/
377/* Write-in-place functions */
378/**********************************************************************/
379
David Gibson73d60922006-12-15 15:12:47 +1100380int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
David Gibson3da0f9a2006-11-27 16:21:28 +1100381 const void *val, int len);
382
383#define fdt_setprop_inplace_typed(fdt, nodeoffset, name, val) \
384 ({ \
385 typeof(val) x = val; \
386 fdt_setprop_inplace(fdt, nodeoffset, name, &x, sizeof(x)); \
387 })
388
David Gibson73d60922006-12-15 15:12:47 +1100389int fdt_nop_property(void *fdt, int nodeoffset, const char *name);
390int fdt_nop_node(void *fdt, int nodeoffset);
David Gibson3da0f9a2006-11-27 16:21:28 +1100391
David Gibsoncec0c382007-10-24 17:10:58 +1000392/**********************************************************************/
393/* Sequential write functions */
394/**********************************************************************/
395
David Gibson73d60922006-12-15 15:12:47 +1100396int fdt_create(void *buf, int bufsize);
397int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);
398int fdt_finish_reservemap(void *fdt);
399int fdt_begin_node(void *fdt, const char *name);
400int fdt_property(void *fdt, const char *name, const void *val, int len);
David Gibson063693a2006-11-29 16:45:46 +1100401#define fdt_property_typed(fdt, name, val) \
402 ({ \
403 typeof(val) x = (val); \
404 fdt_property((fdt), (name), &x, sizeof(x)); \
405 })
406#define fdt_property_string(fdt, name, str) \
407 fdt_property(fdt, name, str, strlen(str)+1)
David Gibson73d60922006-12-15 15:12:47 +1100408int fdt_end_node(void *fdt);
409int fdt_finish(void *fdt);
David Gibson3da0f9a2006-11-27 16:21:28 +1100410
David Gibsoncec0c382007-10-24 17:10:58 +1000411/**********************************************************************/
412/* Read-write functions */
413/**********************************************************************/
414
David Gibsona041dcd2007-11-01 11:37:31 +1100415int fdt_open_into(const void *fdt, void *buf, int bufsize);
David Gibson73d60922006-12-15 15:12:47 +1100416int fdt_pack(void *fdt);
David Gibson7ba551f2006-12-01 16:59:43 +1100417
David Gibsonfd1bf3a2007-10-10 17:12:12 +1000418int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size);
419int fdt_del_mem_rsv(void *fdt, int n);
420
David Gibson73d60922006-12-15 15:12:47 +1100421int fdt_setprop(void *fdt, int nodeoffset, const char *name,
David Gibson7ba551f2006-12-01 16:59:43 +1100422 const void *val, int len);
423#define fdt_setprop_typed(fdt, nodeoffset, name, val) \
424 ({ \
425 typeof(val) x = (val); \
426 fdt_setprop((fdt), (nodeoffset), (name), &x, sizeof(x)); \
427 })
428#define fdt_setprop_string(fdt, nodeoffset, name, str) \
429 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
David Gibson73d60922006-12-15 15:12:47 +1100430int fdt_delprop(void *fdt, int nodeoffset, const char *name);
431int fdt_add_subnode_namelen(void *fdt, int parentoffset,
David Gibson7ba551f2006-12-01 16:59:43 +1100432 const char *name, int namelen);
David Gibson73d60922006-12-15 15:12:47 +1100433int fdt_add_subnode(void *fdt, int parentoffset, const char *name);
434int fdt_del_node(void *fdt, int nodeoffset);
David Gibson3da0f9a2006-11-27 16:21:28 +1100435
David Gibsoncec0c382007-10-24 17:10:58 +1000436/**********************************************************************/
437/* Debugging / informational functions */
438/**********************************************************************/
439
David Gibson5b344f92006-12-21 09:57:08 +1100440const char *fdt_strerror(int errval);
441
David Gibson3da0f9a2006-11-27 16:21:28 +1100442#endif /* _LIBFDT_H */