16#define FDT_FIRST_SUPPORTED_VERSION 0x02
17#define FDT_LAST_COMPATIBLE_VERSION 0x10
18#define FDT_LAST_SUPPORTED_VERSION 0x11
21#define FDT_ERR_NOTFOUND 1
23#define FDT_ERR_EXISTS 2
26#define FDT_ERR_NOSPACE 3
33#define FDT_ERR_BADOFFSET 4
37#define FDT_ERR_BADPATH 5
41#define FDT_ERR_BADPHANDLE 6
46#define FDT_ERR_BADSTATE 7
52#define FDT_ERR_TRUNCATED 8
56#define FDT_ERR_BADMAGIC 9
60#define FDT_ERR_BADVERSION 10
65#define FDT_ERR_BADSTRUCTURE 11
69#define FDT_ERR_BADLAYOUT 12
77#define FDT_ERR_INTERNAL 13
83#define FDT_ERR_BADNCELLS 14
87#define FDT_ERR_BADVALUE 15
92#define FDT_ERR_BADOVERLAY 16
97#define FDT_ERR_NOPHANDLES 17
101#define FDT_ERR_BADFLAGS 18
105#define FDT_ERR_ALIGNMENT 19
109#define FDT_ERR_MAX 19
112#define FDT_MAX_PHANDLE 0xfffffffe
120const void *fdt_offset_ptr(
const void *fdt,
int offset,
unsigned int checklen);
122static inline void *fdt_offset_ptr_w(
void *fdt,
int offset,
int checklen)
124 return (
void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
127uint32_t fdt_next_tag(
const void *fdt,
int offset,
int *nextoffset);
134static inline uint16_t fdt16_ld(
const fdt16_t *
p)
136 const uint8_t *bp = (
const uint8_t *)
p;
138 return ((uint16_t)bp[0] << 8) | bp[1];
141static inline uint32_t fdt32_ld(
const fdt32_t *
p)
143 const uint8_t *bp = (
const uint8_t *)
p;
145 return ((uint32_t)bp[0] << 24)
146 | ((uint32_t)bp[1] << 16)
147 | ((uint32_t)bp[2] << 8)
151static inline void fdt32_st(
void *property, uint32_t value)
153 uint8_t *bp = (uint8_t *)property;
156 bp[1] = (value >> 16) & 0xff;
157 bp[2] = (value >> 8) & 0xff;
158 bp[3] = value & 0xff;
161static inline uint64_t fdt64_ld(
const fdt64_t *
p)
163 const uint8_t *bp = (
const uint8_t *)
p;
165 return ((uint64_t)bp[0] << 56)
166 | ((uint64_t)bp[1] << 48)
167 | ((uint64_t)bp[2] << 40)
168 | ((uint64_t)bp[3] << 32)
169 | ((uint64_t)bp[4] << 24)
170 | ((uint64_t)bp[5] << 16)
171 | ((uint64_t)bp[6] << 8)
175static inline void fdt64_st(
void *property, uint64_t value)
177 uint8_t *bp = (uint8_t *)property;
180 bp[1] = (value >> 48) & 0xff;
181 bp[2] = (value >> 40) & 0xff;
182 bp[3] = (value >> 32) & 0xff;
183 bp[4] = (value >> 24) & 0xff;
184 bp[5] = (value >> 16) & 0xff;
185 bp[6] = (value >> 8) & 0xff;
186 bp[7] = value & 0xff;
193int fdt_next_node(
const void *fdt,
int offset,
int *depth);
202int fdt_first_subnode(
const void *fdt,
int offset);
215int fdt_next_subnode(
const void *fdt,
int offset);
239#define fdt_for_each_subnode(node, fdt, parent) \
240 for (node = fdt_first_subnode(fdt, parent); \
242 node = fdt_next_subnode(fdt, node))
247#define fdt_get_header(fdt, field) \
248 (fdt32_ld(&((const struct fdt_header *)(fdt))->field))
249#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
250#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))
251#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))
252#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings))
253#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap))
254#define fdt_version(fdt) (fdt_get_header(fdt, version))
255#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version))
256#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys))
257#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))
258#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))
260#define fdt_set_hdr_(name) \
261 static inline void fdt_set_##name(void *fdt, uint32_t val) \
263 struct fdt_header *fdth = (struct fdt_header *)fdt; \
264 fdth->name = cpu_to_fdt32(val); \
267fdt_set_hdr_(totalsize);
268fdt_set_hdr_(off_dt_struct);
269fdt_set_hdr_(off_dt_strings);
270fdt_set_hdr_(off_mem_rsvmap);
271fdt_set_hdr_(version);
272fdt_set_hdr_(last_comp_version);
273fdt_set_hdr_(boot_cpuid_phys);
274fdt_set_hdr_(size_dt_strings);
275fdt_set_hdr_(size_dt_struct);
284size_t fdt_header_size(
const void *fdt);
292size_t fdt_header_size_(uint32_t version);
310int fdt_check_header(
const void *fdt);
331int fdt_move(
const void *fdt,
void *buf,
int bufsize);
337int fdt_check_full(
const void *fdt,
size_t bufsize);
353const char *fdt_get_string(
const void *fdt,
int stroffset,
int *lenp);
367const char *fdt_string(
const void *fdt,
int stroffset);
381int fdt_find_max_phandle(
const void *fdt, uint32_t *phandle);
398static inline uint32_t fdt_get_max_phandle(
const void *fdt)
403 err = fdt_find_max_phandle(fdt, &phandle);
422int fdt_generate_phandle(
const void *fdt, uint32_t *phandle);
435int fdt_num_mem_rsv(
const void *fdt);
454int fdt_get_mem_rsv(
const void *fdt,
int n, uint64_t *address, uint64_t *
size);
471int fdt_subnode_offset_namelen(
const void *fdt,
int parentoffset,
472 const char *name,
int namelen);
498int fdt_subnode_offset(
const void *fdt,
int parentoffset,
const char *name);
512int fdt_path_offset_namelen(
const void *fdt,
const char *path,
int namelen);
538int fdt_path_offset(
const void *fdt,
const char *path);
563const char *fdt_get_name(
const void *fdt,
int nodeoffset,
int *lenp);
583int fdt_first_property_offset(
const void *fdt,
int nodeoffset);
604int fdt_next_property_offset(
const void *fdt,
int offset);
628#define fdt_for_each_property_offset(property, fdt, node) \
629 for (property = fdt_first_property_offset(fdt, node); \
631 property = fdt_next_property_offset(fdt, property))
660const struct fdt_property *fdt_get_property_by_offset(
const void *fdt,
663static inline struct fdt_property *fdt_get_property_by_offset_w(
void *fdt,
668 fdt_get_property_by_offset(fdt, offset, lenp);
686const struct fdt_property *fdt_get_property_namelen(
const void *fdt,
689 int namelen,
int *lenp);
720const struct fdt_property *fdt_get_property(
const void *fdt,
int nodeoffset,
721 const char *name,
int *lenp);
722static inline struct fdt_property *fdt_get_property_w(
void *fdt,
int nodeoffset,
727 fdt_get_property(fdt, nodeoffset, name, lenp);
762const void *fdt_getprop_by_offset(
const void *fdt,
int offset,
763 const char **namep,
int *lenp);
780const void *fdt_getprop_namelen(
const void *fdt,
int nodeoffset,
781 const char *name,
int namelen,
int *lenp);
782static inline void *fdt_getprop_namelen_w(
void *fdt,
int nodeoffset,
783 const char *name,
int namelen,
786 return (
void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
819const void *fdt_getprop(
const void *fdt,
int nodeoffset,
820 const char *name,
int *lenp);
821static inline void *fdt_getprop_w(
void *fdt,
int nodeoffset,
822 const char *name,
int *lenp)
824 return (
void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp);
839uint32_t fdt_get_phandle(
const void *fdt,
int nodeoffset);
854const char *fdt_get_alias_namelen(
const void *fdt,
855 const char *name,
int namelen);
870const char *fdt_get_alias(
const void *fdt,
const char *name);
897int fdt_get_path(
const void *fdt,
int nodeoffset,
char *buf,
int buflen);
929int fdt_supernode_atdepth_offset(
const void *fdt,
int nodeoffset,
930 int supernodedepth,
int *nodedepth);
951int fdt_node_depth(
const void *fdt,
int nodeoffset);
974int fdt_parent_offset(
const void *fdt,
int nodeoffset);
1014int fdt_node_offset_by_prop_value(
const void *fdt,
int startoffset,
1015 const char *propname,
1016 const void *propval,
int proplen);
1037int fdt_node_offset_by_phandle(
const void *fdt, uint32_t phandle);
1060int fdt_node_check_compatible(
const void *fdt,
int nodeoffset,
1061 const char *compatible);
1097int fdt_node_offset_by_compatible(
const void *fdt,
int startoffset,
1098 const char *compatible);
1112int fdt_stringlist_contains(
const char *strlist,
int listlen,
const char *str);
1125int fdt_stringlist_count(
const void *fdt,
int nodeoffset,
const char *property);
1146int fdt_stringlist_search(
const void *fdt,
int nodeoffset,
const char *property,
1147 const char *
string);
1173const char *fdt_stringlist_get(
const void *fdt,
int nodeoffset,
1174 const char *property,
int index,
1190#define FDT_MAX_NCELLS 4
1210int fdt_address_cells(
const void *fdt,
int nodeoffset);
1231int fdt_size_cells(
const void *fdt,
int nodeoffset);
1257int fdt_setprop_inplace_namelen_partial(
void *fdt,
int nodeoffset,
1258 const char *name,
int namelen,
1259 uint32_t idx,
const void *val,
1292int fdt_setprop_inplace(
void *fdt,
int nodeoffset,
const char *name,
1293 const void *val,
int len);
1324static inline int fdt_setprop_inplace_u32(
void *fdt,
int nodeoffset,
1325 const char *name, uint32_t val)
1327 fdt32_t tmp = cpu_to_fdt32(val);
1328 return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1359static inline int fdt_setprop_inplace_u64(
void *fdt,
int nodeoffset,
1360 const char *name, uint64_t val)
1362 fdt64_t tmp = cpu_to_fdt64(val);
1363 return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1376static inline int fdt_setprop_inplace_cell(
void *fdt,
int nodeoffset,
1377 const char *name, uint32_t val)
1379 return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val);
1406int fdt_nop_property(
void *fdt,
int nodeoffset,
const char *name);
1430int fdt_nop_node(
void *fdt,
int nodeoffset);
1437#define FDT_CREATE_FLAG_NO_NAME_DEDUP 0x1
1442#define FDT_CREATE_FLAGS_ALL (FDT_CREATE_FLAG_NO_NAME_DEDUP)
1460int fdt_create_with_flags(
void *buf,
int bufsize, uint32_t flags);
1473int fdt_create(
void *buf,
int bufsize);
1475int fdt_resize(
void *fdt,
void *buf,
int bufsize);
1476int fdt_add_reservemap_entry(
void *fdt, uint64_t addr, uint64_t
size);
1477int fdt_finish_reservemap(
void *fdt);
1478int fdt_begin_node(
void *fdt,
const char *name);
1479int fdt_property(
void *fdt,
const char *name,
const void *val,
int len);
1480static inline int fdt_property_u32(
void *fdt,
const char *name, uint32_t val)
1482 fdt32_t tmp = cpu_to_fdt32(val);
1485static inline int fdt_property_u64(
void *fdt,
const char *name, uint64_t val)
1487 fdt64_t tmp = cpu_to_fdt64(val);
1492static inline int fdt_property_cell(
void *fdt,
const char *name, uint32_t val)
1494 return fdt_property_u32(fdt, name, val);
1511int fdt_property_placeholder(
void *fdt,
const char *name,
int len,
void **valp);
1513#define fdt_property_string(fdt, name, str) \
1514 fdt_property(fdt, name, str, strlen(str)+1)
1515int fdt_end_node(
void *fdt);
1516int fdt_finish(
void *fdt);
1522int fdt_create_empty_tree(
void *buf,
int bufsize);
1523int fdt_open_into(
const void *fdt,
void *buf,
int bufsize);
1524int fdt_pack(
void *fdt);
1549int fdt_add_mem_rsv(
void *fdt, uint64_t address, uint64_t
size);
1573int fdt_del_mem_rsv(
void *fdt,
int n);
1599int fdt_set_name(
void *fdt,
int nodeoffset,
const char *name);
1629int fdt_setprop(
void *fdt,
int nodeoffset,
const char *name,
1630 const void *val,
int len);
1660int fdt_setprop_placeholder(
void *fdt,
int nodeoffset,
const char *name,
1661 int len,
void **prop_data);
1691static inline int fdt_setprop_u32(
void *fdt,
int nodeoffset,
const char *name,
1694 fdt32_t tmp = cpu_to_fdt32(val);
1695 return fdt_setprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1726static inline int fdt_setprop_u64(
void *fdt,
int nodeoffset,
const char *name,
1729 fdt64_t tmp = cpu_to_fdt64(val);
1730 return fdt_setprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1744static inline int fdt_setprop_cell(
void *fdt,
int nodeoffset,
const char *name,
1747 return fdt_setprop_u32(fdt, nodeoffset, name, val);
1778#define fdt_setprop_string(fdt, nodeoffset, name, str) \
1779 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
1808#define fdt_setprop_empty(fdt, nodeoffset, name) \
1809 fdt_setprop((fdt), (nodeoffset), (name), NULL, 0)
1838int fdt_appendprop(
void *fdt,
int nodeoffset,
const char *name,
1839 const void *val,
int len);
1869static inline int fdt_appendprop_u32(
void *fdt,
int nodeoffset,
1870 const char *name, uint32_t val)
1872 fdt32_t tmp = cpu_to_fdt32(val);
1873 return fdt_appendprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1904static inline int fdt_appendprop_u64(
void *fdt,
int nodeoffset,
1905 const char *name, uint64_t val)
1907 fdt64_t tmp = cpu_to_fdt64(val);
1908 return fdt_appendprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1922static inline int fdt_appendprop_cell(
void *fdt,
int nodeoffset,
1923 const char *name, uint32_t val)
1925 return fdt_appendprop_u32(fdt, nodeoffset, name, val);
1955#define fdt_appendprop_string(fdt, nodeoffset, name, str) \
1956 fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
1992int fdt_appendprop_addrrange(
void *fdt,
int parent,
int nodeoffset,
1993 const char *name, uint64_t addr, uint64_t
size);
2017int fdt_delprop(
void *fdt,
int nodeoffset,
const char *name);
2035int fdt_add_subnode_namelen(
void *fdt,
int parentoffset,
2036 const char *name,
int namelen);
2070int fdt_add_subnode(
void *fdt,
int parentoffset,
const char *name);
2093int fdt_del_node(
void *fdt,
int nodeoffset);
2124int fdt_overlay_apply(
void *fdt,
void *fdto);
2141int fdt_overlay_target_offset(
const void *fdt,
const void *fdto,
2142 int fragment_offset,
char const **pathp);
2148const char *fdt_strerror(
int errval);
unsigned size
Definition: tte.h:1
unsigned p
Definition: tte.h:17