12#define FDT_FIRST_SUPPORTED_VERSION 0x02
13#define FDT_LAST_SUPPORTED_VERSION 0x11
16#define FDT_ERR_NOTFOUND 1
18#define FDT_ERR_EXISTS 2
21#define FDT_ERR_NOSPACE 3
28#define FDT_ERR_BADOFFSET 4
32#define FDT_ERR_BADPATH 5
36#define FDT_ERR_BADPHANDLE 6
41#define FDT_ERR_BADSTATE 7
47#define FDT_ERR_TRUNCATED 8
51#define FDT_ERR_BADMAGIC 9
55#define FDT_ERR_BADVERSION 10
60#define FDT_ERR_BADSTRUCTURE 11
64#define FDT_ERR_BADLAYOUT 12
72#define FDT_ERR_INTERNAL 13
78#define FDT_ERR_BADNCELLS 14
82#define FDT_ERR_BADVALUE 15
87#define FDT_ERR_BADOVERLAY 16
92#define FDT_ERR_NOPHANDLES 17
96#define FDT_ERR_BADFLAGS 18
100#define FDT_ERR_MAX 18
103#define FDT_MAX_PHANDLE 0xfffffffe
111const void *fdt_offset_ptr(
const void *fdt,
int offset,
unsigned int checklen);
113static inline void *fdt_offset_ptr_w(
void *fdt,
int offset,
int checklen)
115 return (
void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
118uint32_t fdt_next_tag(
const void *fdt,
int offset,
int *nextoffset);
127static inline uint32_t fdt32_ld(
const fdt32_t *
p)
129 const uint8_t *bp = (
const uint8_t *)
p;
131 return ((uint32_t)bp[0] << 24)
132 | ((uint32_t)bp[1] << 16)
133 | ((uint32_t)bp[2] << 8)
137static inline void fdt32_st(
void *property, uint32_t value)
139 uint8_t *bp = (uint8_t *)property;
142 bp[1] = (value >> 16) & 0xff;
143 bp[2] = (value >> 8) & 0xff;
144 bp[3] = value & 0xff;
147static inline uint64_t fdt64_ld(
const fdt64_t *
p)
149 const uint8_t *bp = (
const uint8_t *)
p;
151 return ((uint64_t)bp[0] << 56)
152 | ((uint64_t)bp[1] << 48)
153 | ((uint64_t)bp[2] << 40)
154 | ((uint64_t)bp[3] << 32)
155 | ((uint64_t)bp[4] << 24)
156 | ((uint64_t)bp[5] << 16)
157 | ((uint64_t)bp[6] << 8)
161static inline void fdt64_st(
void *property, uint64_t value)
163 uint8_t *bp = (uint8_t *)property;
166 bp[1] = (value >> 48) & 0xff;
167 bp[2] = (value >> 40) & 0xff;
168 bp[3] = (value >> 32) & 0xff;
169 bp[4] = (value >> 24) & 0xff;
170 bp[5] = (value >> 16) & 0xff;
171 bp[6] = (value >> 8) & 0xff;
172 bp[7] = value & 0xff;
179int fdt_next_node(
const void *fdt,
int offset,
int *depth);
188int fdt_first_subnode(
const void *fdt,
int offset);
201int fdt_next_subnode(
const void *fdt,
int offset);
226#define fdt_for_each_subnode(node, fdt, parent) \
227 for (node = fdt_first_subnode(fdt, parent); \
229 node = fdt_next_subnode(fdt, node))
234#define fdt_get_header(fdt, field) \
235 (fdt32_ld(&((const struct fdt_header *)(fdt))->field))
236#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
237#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))
238#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))
239#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings))
240#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap))
241#define fdt_version(fdt) (fdt_get_header(fdt, version))
242#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version))
243#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys))
244#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))
245#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))
247#define fdt_set_hdr_(name) \
248 static inline void fdt_set_##name(void *fdt, uint32_t val) \
250 struct fdt_header *fdth = (struct fdt_header *)fdt; \
251 fdth->name = cpu_to_fdt32(val); \
254fdt_set_hdr_(totalsize);
255fdt_set_hdr_(off_dt_struct);
256fdt_set_hdr_(off_dt_strings);
257fdt_set_hdr_(off_mem_rsvmap);
258fdt_set_hdr_(version);
259fdt_set_hdr_(last_comp_version);
260fdt_set_hdr_(boot_cpuid_phys);
261fdt_set_hdr_(size_dt_strings);
262fdt_set_hdr_(size_dt_struct);
269size_t fdt_header_size(
const void *fdt);
274size_t fdt_header_size_(uint32_t version);
293int fdt_check_header(
const void *fdt);
314int fdt_move(
const void *fdt,
void *buf,
int bufsize);
320int fdt_check_full(
const void *fdt,
size_t bufsize);
336const char *fdt_get_string(
const void *fdt,
int stroffset,
int *lenp);
350const char *fdt_string(
const void *fdt,
int stroffset);
364int fdt_find_max_phandle(
const void *fdt, uint32_t *phandle);
381static inline uint32_t fdt_get_max_phandle(
const void *fdt)
386 err = fdt_find_max_phandle(fdt, &phandle);
406int fdt_generate_phandle(
const void *fdt, uint32_t *phandle);
419int fdt_num_mem_rsv(
const void *fdt);
436int fdt_get_mem_rsv(
const void *fdt,
int n, uint64_t *address, uint64_t *
size);
451int fdt_subnode_offset_namelen(
const void *fdt,
int parentoffset,
452 const char *name,
int namelen);
478int fdt_subnode_offset(
const void *fdt,
int parentoffset,
const char *name);
490int fdt_path_offset_namelen(
const void *fdt,
const char *path,
int namelen);
516int fdt_path_offset(
const void *fdt,
const char *path);
541const char *fdt_get_name(
const void *fdt,
int nodeoffset,
int *lenp);
561int fdt_first_property_offset(
const void *fdt,
int nodeoffset);
582int fdt_next_property_offset(
const void *fdt,
int offset);
606#define fdt_for_each_property_offset(property, fdt, node) \
607 for (property = fdt_first_property_offset(fdt, node); \
609 property = fdt_next_property_offset(fdt, property))
638const struct fdt_property *fdt_get_property_by_offset(
const void *fdt,
654const struct fdt_property *fdt_get_property_namelen(
const void *fdt,
657 int namelen,
int *lenp);
688const struct fdt_property *fdt_get_property(
const void *fdt,
int nodeoffset,
689 const char *name,
int *lenp);
690static inline struct fdt_property *fdt_get_property_w(
void *fdt,
int nodeoffset,
695 fdt_get_property(fdt, nodeoffset, name, lenp);
730const void *fdt_getprop_by_offset(
const void *fdt,
int offset,
731 const char **namep,
int *lenp);
746const void *fdt_getprop_namelen(
const void *fdt,
int nodeoffset,
747 const char *name,
int namelen,
int *lenp);
748static inline void *fdt_getprop_namelen_w(
void *fdt,
int nodeoffset,
749 const char *name,
int namelen,
752 return (
void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
785const void *fdt_getprop(
const void *fdt,
int nodeoffset,
786 const char *name,
int *lenp);
787static inline void *fdt_getprop_w(
void *fdt,
int nodeoffset,
788 const char *name,
int *lenp)
790 return (
void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp);
805uint32_t fdt_get_phandle(
const void *fdt,
int nodeoffset);
817const char *fdt_get_alias_namelen(
const void *fdt,
818 const char *name,
int namelen);
833const char *fdt_get_alias(
const void *fdt,
const char *name);
860int fdt_get_path(
const void *fdt,
int nodeoffset,
char *buf,
int buflen);
892int fdt_supernode_atdepth_offset(
const void *fdt,
int nodeoffset,
893 int supernodedepth,
int *nodedepth);
914int fdt_node_depth(
const void *fdt,
int nodeoffset);
937int fdt_parent_offset(
const void *fdt,
int nodeoffset);
977int fdt_node_offset_by_prop_value(
const void *fdt,
int startoffset,
978 const char *propname,
979 const void *propval,
int proplen);
1000int fdt_node_offset_by_phandle(
const void *fdt, uint32_t phandle);
1024int fdt_node_check_compatible(
const void *fdt,
int nodeoffset,
1025 const char *compatible);
1061int fdt_node_offset_by_compatible(
const void *fdt,
int startoffset,
1062 const char *compatible);
1076int fdt_stringlist_contains(
const char *strlist,
int listlen,
const char *str);
1088int fdt_stringlist_count(
const void *fdt,
int nodeoffset,
const char *property);
1109int fdt_stringlist_search(
const void *fdt,
int nodeoffset,
const char *property,
1110 const char *
string);
1136const char *fdt_stringlist_get(
const void *fdt,
int nodeoffset,
1137 const char *property,
int index,
1153#define FDT_MAX_NCELLS 4
1173int fdt_address_cells(
const void *fdt,
int nodeoffset);
1194int fdt_size_cells(
const void *fdt,
int nodeoffset);
1218int fdt_setprop_inplace_namelen_partial(
void *fdt,
int nodeoffset,
1219 const char *name,
int namelen,
1220 uint32_t idx,
const void *val,
1253int fdt_setprop_inplace(
void *fdt,
int nodeoffset,
const char *name,
1254 const void *val,
int len);
1285static inline int fdt_setprop_inplace_u32(
void *fdt,
int nodeoffset,
1286 const char *name, uint32_t val)
1288 fdt32_t tmp = cpu_to_fdt32(val);
1289 return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1320static inline int fdt_setprop_inplace_u64(
void *fdt,
int nodeoffset,
1321 const char *name, uint64_t val)
1323 fdt64_t tmp = cpu_to_fdt64(val);
1324 return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1332static inline int fdt_setprop_inplace_cell(
void *fdt,
int nodeoffset,
1333 const char *name, uint32_t val)
1335 return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val);
1362int fdt_nop_property(
void *fdt,
int nodeoffset,
const char *name);
1386int fdt_nop_node(
void *fdt,
int nodeoffset);
1393#define FDT_CREATE_FLAG_NO_NAME_DEDUP 0x1
1398#define FDT_CREATE_FLAGS_ALL (FDT_CREATE_FLAG_NO_NAME_DEDUP)
1416int fdt_create_with_flags(
void *buf,
int bufsize, uint32_t flags);
1429int fdt_create(
void *buf,
int bufsize);
1431int fdt_resize(
void *fdt,
void *buf,
int bufsize);
1432int fdt_add_reservemap_entry(
void *fdt, uint64_t addr, uint64_t
size);
1433int fdt_finish_reservemap(
void *fdt);
1434int fdt_begin_node(
void *fdt,
const char *name);
1435int fdt_property(
void *fdt,
const char *name,
const void *val,
int len);
1436static inline int fdt_property_u32(
void *fdt,
const char *name, uint32_t val)
1438 fdt32_t tmp = cpu_to_fdt32(val);
1441static inline int fdt_property_u64(
void *fdt,
const char *name, uint64_t val)
1443 fdt64_t tmp = cpu_to_fdt64(val);
1448static inline int fdt_property_cell(
void *fdt,
const char *name, uint32_t val)
1450 return fdt_property_u32(fdt, name, val);
1467int fdt_property_placeholder(
void *fdt,
const char *name,
int len,
void **valp);
1469#define fdt_property_string(fdt, name, str) \
1470 fdt_property(fdt, name, str, strlen(str)+1)
1471int fdt_end_node(
void *fdt);
1472int fdt_finish(
void *fdt);
1478int fdt_create_empty_tree(
void *buf,
int bufsize);
1479int fdt_open_into(
const void *fdt,
void *buf,
int bufsize);
1480int fdt_pack(
void *fdt);
1504int fdt_add_mem_rsv(
void *fdt, uint64_t address, uint64_t
size);
1528int fdt_del_mem_rsv(
void *fdt,
int n);
1554int fdt_set_name(
void *fdt,
int nodeoffset,
const char *name);
1584int fdt_setprop(
void *fdt,
int nodeoffset,
const char *name,
1585 const void *val,
int len);
1615int fdt_setprop_placeholder(
void *fdt,
int nodeoffset,
const char *name,
1616 int len,
void **prop_data);
1646static inline int fdt_setprop_u32(
void *fdt,
int nodeoffset,
const char *name,
1649 fdt32_t tmp = cpu_to_fdt32(val);
1650 return fdt_setprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1681static inline int fdt_setprop_u64(
void *fdt,
int nodeoffset,
const char *name,
1684 fdt64_t tmp = cpu_to_fdt64(val);
1685 return fdt_setprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1693static inline int fdt_setprop_cell(
void *fdt,
int nodeoffset,
const char *name,
1696 return fdt_setprop_u32(fdt, nodeoffset, name, val);
1727#define fdt_setprop_string(fdt, nodeoffset, name, str) \
1728 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
1757#define fdt_setprop_empty(fdt, nodeoffset, name) \
1758 fdt_setprop((fdt), (nodeoffset), (name), NULL, 0)
1787int fdt_appendprop(
void *fdt,
int nodeoffset,
const char *name,
1788 const void *val,
int len);
1818static inline int fdt_appendprop_u32(
void *fdt,
int nodeoffset,
1819 const char *name, uint32_t val)
1821 fdt32_t tmp = cpu_to_fdt32(val);
1822 return fdt_appendprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1853static inline int fdt_appendprop_u64(
void *fdt,
int nodeoffset,
1854 const char *name, uint64_t val)
1856 fdt64_t tmp = cpu_to_fdt64(val);
1857 return fdt_appendprop(fdt, nodeoffset, name, &tmp,
sizeof(tmp));
1865static inline int fdt_appendprop_cell(
void *fdt,
int nodeoffset,
1866 const char *name, uint32_t val)
1868 return fdt_appendprop_u32(fdt, nodeoffset, name, val);
1898#define fdt_appendprop_string(fdt, nodeoffset, name, str) \
1899 fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
1935int fdt_appendprop_addrrange(
void *fdt,
int parent,
int nodeoffset,
1936 const char *name, uint64_t addr, uint64_t
size);
1960int fdt_delprop(
void *fdt,
int nodeoffset,
const char *name);
1975int fdt_add_subnode_namelen(
void *fdt,
int parentoffset,
1976 const char *name,
int namelen);
2010int fdt_add_subnode(
void *fdt,
int parentoffset,
const char *name);
2033int fdt_del_node(
void *fdt,
int nodeoffset);
2064int fdt_overlay_apply(
void *fdt,
void *fdto);
2070const char *fdt_strerror(
int errval);
unsigned size
Definition: tte.h:1
unsigned p
Definition: tte.h:17