54 #include <libfdt_env.h> 57 #define FDT_FIRST_SUPPORTED_VERSION 0x02 58 #define FDT_LAST_SUPPORTED_VERSION 0x11 61 #define FDT_ERR_NOTFOUND 1 63 #define FDT_ERR_EXISTS 2 66 #define FDT_ERR_NOSPACE 3 73 #define FDT_ERR_BADOFFSET 4 77 #define FDT_ERR_BADPATH 5 81 #define FDT_ERR_BADPHANDLE 6 86 #define FDT_ERR_BADSTATE 7 92 #define FDT_ERR_TRUNCATED 8 96 #define FDT_ERR_BADMAGIC 9 100 #define FDT_ERR_BADVERSION 10 105 #define FDT_ERR_BADSTRUCTURE 11 109 #define FDT_ERR_BADLAYOUT 12 117 #define FDT_ERR_INTERNAL 13 123 #define FDT_ERR_BADNCELLS 14 127 #define FDT_ERR_BADVALUE 15 132 #define FDT_ERR_BADOVERLAY 16 137 #define FDT_ERR_NOPHANDLES 17 141 #define FDT_ERR_MAX 17 148 const void *fdt_offset_ptr(
const void *fdt,
int offset,
unsigned int checklen);
150 static inline void *fdt_offset_ptr_w(
void *fdt,
int offset,
int checklen)
152 return (
void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
155 uint32_t fdt_next_tag(
const void *fdt,
int offset,
int *nextoffset);
164 static inline uint32_t fdt32_ld(
const fdt32_t *
p)
168 memcpy(&v, p,
sizeof(v));
169 return fdt32_to_cpu(v);
172 static inline uint64_t fdt64_ld(
const fdt64_t *p)
176 memcpy(&v, p,
sizeof(v));
177 return fdt64_to_cpu(v);
184 int fdt_next_node(
const void *fdt,
int offset,
int *depth);
193 int fdt_first_subnode(
const void *fdt,
int offset);
206 int fdt_next_subnode(
const void *fdt,
int offset);
231 #define fdt_for_each_subnode(node, fdt, parent) \ 232 for (node = fdt_first_subnode(fdt, parent); \ 234 node = fdt_next_subnode(fdt, node)) 239 #define fdt_get_header(fdt, field) \ 240 (fdt32_ld(&((const struct fdt_header *)(fdt))->field)) 241 #define fdt_magic(fdt) (fdt_get_header(fdt, magic)) 242 #define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize)) 243 #define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct)) 244 #define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings)) 245 #define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap)) 246 #define fdt_version(fdt) (fdt_get_header(fdt, version)) 247 #define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version)) 248 #define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys)) 249 #define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings)) 250 #define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct)) 252 #define fdt_set_hdr_(name) \ 253 static inline void fdt_set_##name(void *fdt, uint32_t val) \ 255 struct fdt_header *fdth = (struct fdt_header *)fdt; \ 256 fdth->name = cpu_to_fdt32(val); \ 259 fdt_set_hdr_(totalsize);
260 fdt_set_hdr_(off_dt_struct);
261 fdt_set_hdr_(off_dt_strings);
262 fdt_set_hdr_(off_mem_rsvmap);
263 fdt_set_hdr_(version);
264 fdt_set_hdr_(last_comp_version);
265 fdt_set_hdr_(boot_cpuid_phys);
266 fdt_set_hdr_(size_dt_strings);
267 fdt_set_hdr_(size_dt_struct);
274 size_t fdt_header_size_(uint32_t version);
275 static inline size_t fdt_header_size(
const void *fdt)
277 return fdt_header_size_(fdt_version(fdt));
297 int fdt_check_header(
const void *fdt);
318 int fdt_move(
const void *fdt,
void *buf,
int bufsize);
324 int fdt_check_full(
const void *fdt,
size_t bufsize);
340 const char *fdt_get_string(
const void *fdt,
int stroffset,
int *lenp);
354 const char *fdt_string(
const void *fdt,
int stroffset);
369 uint32_t fdt_get_max_phandle(
const void *fdt);
382 int fdt_num_mem_rsv(
const void *fdt);
399 int fdt_get_mem_rsv(
const void *fdt,
int n, uint64_t *address, uint64_t *
size);
414 int fdt_subnode_offset_namelen(
const void *fdt,
int parentoffset,
415 const char *name,
int namelen);
441 int fdt_subnode_offset(
const void *fdt,
int parentoffset,
const char *name);
453 int fdt_path_offset_namelen(
const void *fdt,
const char *path,
int namelen);
479 int fdt_path_offset(
const void *fdt,
const char *path);
504 const char *fdt_get_name(
const void *fdt,
int nodeoffset,
int *lenp);
524 int fdt_first_property_offset(
const void *fdt,
int nodeoffset);
545 int fdt_next_property_offset(
const void *fdt,
int offset);
569 #define fdt_for_each_property_offset(property, fdt, node) \ 570 for (property = fdt_first_property_offset(fdt, node); \ 572 property = fdt_next_property_offset(fdt, property)) 601 const struct fdt_property *fdt_get_property_by_offset(
const void *fdt,
617 const struct fdt_property *fdt_get_property_namelen(
const void *fdt,
620 int namelen,
int *lenp);
651 const struct fdt_property *fdt_get_property(
const void *fdt,
int nodeoffset,
652 const char *name,
int *lenp);
653 static inline struct fdt_property *fdt_get_property_w(
void *fdt,
int nodeoffset,
658 fdt_get_property(fdt, nodeoffset, name, lenp);
693 const void *fdt_getprop_by_offset(
const void *fdt,
int offset,
694 const char **namep,
int *lenp);
709 const void *fdt_getprop_namelen(
const void *fdt,
int nodeoffset,
710 const char *name,
int namelen,
int *lenp);
711 static inline void *fdt_getprop_namelen_w(
void *fdt,
int nodeoffset,
712 const char *name,
int namelen,
715 return (
void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
748 const void *fdt_getprop(
const void *fdt,
int nodeoffset,
749 const char *name,
int *lenp);
750 static inline void *fdt_getprop_w(
void *fdt,
int nodeoffset,
751 const char *name,
int *lenp)
753 return (
void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp);
768 uint32_t fdt_get_phandle(
const void *fdt,
int nodeoffset);
780 const char *fdt_get_alias_namelen(
const void *fdt,
781 const char *name,
int namelen);
796 const char *fdt_get_alias(
const void *fdt,
const char *name);
823 int fdt_get_path(
const void *fdt,
int nodeoffset,
char *buf,
int buflen);
855 int fdt_supernode_atdepth_offset(
const void *fdt,
int nodeoffset,
856 int supernodedepth,
int *nodedepth);
877 int fdt_node_depth(
const void *fdt,
int nodeoffset);
900 int fdt_parent_offset(
const void *fdt,
int nodeoffset);
940 int fdt_node_offset_by_prop_value(
const void *fdt,
int startoffset,
941 const char *propname,
942 const void *propval,
int proplen);
963 int fdt_node_offset_by_phandle(
const void *fdt, uint32_t phandle);
987 int fdt_node_check_compatible(
const void *fdt,
int nodeoffset,
988 const char *compatible);
1024 int fdt_node_offset_by_compatible(
const void *fdt,
int startoffset,
1025 const char *compatible);
1039 int fdt_stringlist_contains(
const char *strlist,
int listlen,
const char *str);
1051 int fdt_stringlist_count(
const void *fdt,
int nodeoffset,
const char *property);
1072 int fdt_stringlist_search(
const void *fdt,
int nodeoffset,
const char *property,
1073 const char *
string);
1099 const char *fdt_stringlist_get(
const void *fdt,
int nodeoffset,
1100 const char *property,
int index,
1116 #define FDT_MAX_NCELLS 4 1136 int fdt_address_cells(
const void *fdt,
int nodeoffset);
1157 int fdt_size_cells(
const void *fdt,
int nodeoffset);
1181 int fdt_setprop_inplace_namelen_partial(
void *fdt,
int nodeoffset,
1182 const char *name,
int namelen,
1183 uint32_t idx,
const void *val,
1216 int fdt_setprop_inplace(
void *fdt,
int nodeoffset,
const char *name,
1217 const void *val,
int len);
1248 static inline int fdt_setprop_inplace_u32(
void *fdt,
int nodeoffset,
1249 const char *name, uint32_t val)
1251 fdt32_t tmp = cpu_to_fdt32(val);
1252 return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1283 static inline int fdt_setprop_inplace_u64(
void *fdt,
int nodeoffset,
1284 const char *name, uint64_t val)
1286 fdt64_t tmp = cpu_to_fdt64(val);
1287 return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1295 static inline int fdt_setprop_inplace_cell(
void *fdt,
int nodeoffset,
1296 const char *name, uint32_t val)
1298 return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val);
1325 int fdt_nop_property(
void *fdt,
int nodeoffset,
const char *name);
1349 int fdt_nop_node(
void *fdt,
int nodeoffset);
1355 int fdt_create(
void *buf,
int bufsize);
1356 int fdt_resize(
void *fdt,
void *buf,
int bufsize);
1357 int fdt_add_reservemap_entry(
void *fdt, uint64_t addr, uint64_t
size);
1358 int fdt_finish_reservemap(
void *fdt);
1359 int fdt_begin_node(
void *fdt,
const char *name);
1360 int fdt_property(
void *fdt,
const char *name,
const void *val,
int len);
1361 static inline int fdt_property_u32(
void *fdt,
const char *name, uint32_t val)
1363 fdt32_t tmp = cpu_to_fdt32(val);
1366 static inline int fdt_property_u64(
void *fdt,
const char *name, uint64_t val)
1368 fdt64_t tmp = cpu_to_fdt64(val);
1373 static inline int fdt_property_cell(
void *fdt,
const char *name, uint32_t val)
1375 return fdt_property_u32(fdt, name, val);
1392 int fdt_property_placeholder(
void *fdt,
const char *name,
int len,
void **valp);
1394 #define fdt_property_string(fdt, name, str) \ 1395 fdt_property(fdt, name, str, strlen(str)+1) 1396 int fdt_end_node(
void *fdt);
1397 int fdt_finish(
void *fdt);
1403 int fdt_create_empty_tree(
void *buf,
int bufsize);
1404 int fdt_open_into(
const void *fdt,
void *buf,
int bufsize);
1405 int fdt_pack(
void *fdt);
1429 int fdt_add_mem_rsv(
void *fdt, uint64_t address, uint64_t
size);
1453 int fdt_del_mem_rsv(
void *fdt,
int n);
1479 int fdt_set_name(
void *fdt,
int nodeoffset,
const char *name);
1509 int fdt_setprop(
void *fdt,
int nodeoffset,
const char *name,
1510 const void *val,
int len);
1540 int fdt_setprop_placeholder(
void *fdt,
int nodeoffset,
const char *name,
1541 int len,
void **prop_data);
1571 static inline int fdt_setprop_u32(
void *fdt,
int nodeoffset,
const char *name,
1574 fdt32_t tmp = cpu_to_fdt32(val);
1575 return fdt_setprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1606 static inline int fdt_setprop_u64(
void *fdt,
int nodeoffset,
const char *name,
1609 fdt64_t tmp = cpu_to_fdt64(val);
1610 return fdt_setprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1618 static inline int fdt_setprop_cell(
void *fdt,
int nodeoffset,
const char *name,
1621 return fdt_setprop_u32(fdt, nodeoffset, name, val);
1652 #define fdt_setprop_string(fdt, nodeoffset, name, str) \ 1653 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) 1682 #define fdt_setprop_empty(fdt, nodeoffset, name) \ 1683 fdt_setprop((fdt), (nodeoffset), (name), NULL, 0) 1712 int fdt_appendprop(
void *fdt,
int nodeoffset,
const char *name,
1713 const void *val,
int len);
1743 static inline int fdt_appendprop_u32(
void *fdt,
int nodeoffset,
1744 const char *name, uint32_t val)
1746 fdt32_t tmp = cpu_to_fdt32(val);
1747 return fdt_appendprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1778 static inline int fdt_appendprop_u64(
void *fdt,
int nodeoffset,
1779 const char *name, uint64_t val)
1781 fdt64_t tmp = cpu_to_fdt64(val);
1782 return fdt_appendprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1790 static inline int fdt_appendprop_cell(
void *fdt,
int nodeoffset,
1791 const char *name, uint32_t val)
1793 return fdt_appendprop_u32(fdt, nodeoffset, name, val);
1823 #define fdt_appendprop_string(fdt, nodeoffset, name, str) \ 1824 fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) 1848 int fdt_delprop(
void *fdt,
int nodeoffset,
const char *name);
1863 int fdt_add_subnode_namelen(
void *fdt,
int parentoffset,
1864 const char *name,
int namelen);
1898 int fdt_add_subnode(
void *fdt,
int parentoffset,
const char *name);
1921 int fdt_del_node(
void *fdt,
int nodeoffset);
1952 int fdt_overlay_apply(
void *fdt,
void *fdto);
1958 const char *fdt_strerror(
int errval);
unsigned p
Definition: tte.h:90
unsigned size
Definition: tte.h:74
unsigned v
Definition: tte.h:73