58static int _fdt_nodename_eq(
const void *fdt,
int offset,
59 const char *s,
int len)
67 if (memcmp(p, s, len) != 0)
72 else if (!memchr(s,
'@', len) && (p[len] ==
'@'))
83static int _fdt_string_eq(
const void *fdt,
int stroffset,
84 const char *s,
int len)
88 return (strlen(p) == len) && (memcmp(p, s, len) == 0);
95 *
size = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->
size);
103 while (fdt64_to_cpu(_fdt_mem_rsv(fdt, i)->
size) != 0)
108static int _nextprop(
const void *fdt,
int offset)
133 const char *name,
int namelen)
140 (offset >= 0) && (depth >= 0);
143 && _fdt_nodename_eq(fdt, offset, name, namelen))
159 const char *end = path + strlen(path);
160 const char *p = path;
167 const char *q = strchr(path,
'/');
211 *len = strlen(nh->
name);
228 return _nextprop(fdt, offset);
236 return _nextprop(fdt, offset);
252 prop = _fdt_offset_ptr(fdt, offset);
255 *lenp = fdt32_to_cpu(prop->
len);
263 int namelen,
int *lenp)
274 if (_fdt_string_eq(fdt, fdt32_to_cpu(prop->
nameoff),
286 const char *name,
int *lenp)
293 const char *name,
int namelen,
int *lenp)
305 const char **namep,
int *lenp)
318 const char *name,
int *lenp)
331 if (!php || (
len !=
sizeof(*php))) {
333 if (!php || (
len !=
sizeof(*php)))
337 return fdt32_to_cpu(*php);
341 const char *name,
int namelen)
357int fdt_get_path(
const void *fdt,
int nodeoffset,
char *buf,
int buflen)
359 int pdepth = 0, p = 0;
360 int offset, depth, namelen;
368 for (offset = 0, depth = 0;
369 (offset >= 0) && (offset <= nodeoffset);
371 while (pdepth > depth) {
374 }
while (buf[p-1] !=
'/');
378 if (pdepth >= depth) {
382 if ((p + namelen + 1) <= buflen) {
383 memcpy(buf + p, name, namelen);
390 if (offset == nodeoffset) {
391 if (pdepth < (depth + 1))
410 int supernodedepth,
int *nodedepth)
417 if (supernodedepth < 0)
420 for (offset = 0, depth = 0;
421 (offset >= 0) && (offset <= nodeoffset);
423 if (depth == supernodedepth)
424 supernodeoffset = offset;
426 if (offset == nodeoffset) {
430 if (supernodedepth > depth)
433 return supernodeoffset;
463 nodedepth - 1,
NULL);
467 const char *propname,
468 const void *propval,
int proplen)
485 if (
val && (
len == proplen)
486 && (memcmp(
val, propval,
len) == 0))
497 if ((phandle == 0) || (phandle == -1))
518static int _fdt_stringlist_contains(
const char *strlist,
int listlen,
524 while (listlen >=
len) {
525 if (memcmp(
str, strlist,
len+1) == 0)
527 p = memchr(strlist,
'\0', listlen);
530 listlen -= (p-strlist) + 1;
537 const char *compatible)
545 if (_fdt_stringlist_contains(prop,
len, compatible))
552 const char *compatible)
int fdt_check_header(const void *fdt)
const void * fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
int fdt_next_node(const void *fdt, int offset, int *depth)
int _fdt_check_node_offset(const void *fdt, int offset)
int _fdt_check_prop_offset(const void *fdt, int offset)
uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
const char * fdt_get_alias_namelen(const void *fdt, const char *name, int namelen)
int fdt_path_offset(const void *fdt, const char *path)
int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name)
int fdt_parent_offset(const void *fdt, int nodeoffset)
int fdt_node_depth(const void *fdt, int nodeoffset)
const void * fdt_getprop_namelen(const void *fdt, int nodeoffset, const char *name, int namelen, int *lenp)
const char * fdt_get_name(const void *fdt, int nodeoffset, int *len)
int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
const struct fdt_property * fdt_get_property_namelen(const void *fdt, int offset, const char *name, int namelen, int *lenp)
int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
int fdt_subnode_offset_namelen(const void *fdt, int offset, const char *name, int namelen)
const char * fdt_get_alias(const void *fdt, const char *name)
int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset, int supernodedepth, int *nodedepth)
int fdt_num_mem_rsv(const void *fdt)
int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
const struct fdt_property * fdt_get_property(const void *fdt, int nodeoffset, const char *name, int *lenp)
int fdt_node_offset_by_compatible(const void *fdt, int startoffset, const char *compatible)
const void * fdt_getprop(const void *fdt, int nodeoffset, const char *name, int *lenp)
int fdt_node_offset_by_prop_value(const void *fdt, int startoffset, const char *propname, const void *propval, int proplen)
const struct fdt_property * fdt_get_property_by_offset(const void *fdt, int offset, int *lenp)
const char * fdt_string(const void *fdt, int stroffset)
int fdt_first_property_offset(const void *fdt, int nodeoffset)
int fdt_next_property_offset(const void *fdt, int offset)
const void * fdt_getprop_by_offset(const void *fdt, int offset, const char **namep, int *lenp)
int fdt_node_check_compatible(const void *fdt, int nodeoffset, const char *compatible)
#define FDT_ERR_BADPHANDLE
#define FDT_ERR_BADOFFSET
#define fdt_off_dt_strings(fdt)
#define FDT_ERR_BADSTRUCTURE
#define FDT_CHECK_HEADER(fdt)