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);
136 return ((
uint16_t) bp[0] << 8) | bp[1];
149 bp[1] = (
value >> 16) & 0xff;
150 bp[2] = (
value >> 8) & 0xff;
151 bp[3] =
value & 0xff;
165 bp[1] = (
value >> 48) & 0xff;
166 bp[2] = (
value >> 40) & 0xff;
167 bp[3] = (
value >> 32) & 0xff;
168 bp[4] = (
value >> 24) & 0xff;
169 bp[5] = (
value >> 16) & 0xff;
170 bp[6] = (
value >> 8) & 0xff;
171 bp[7] =
value & 0xff;
224#define fdt_for_each_subnode(node, fdt, parent) for (node = fdt_first_subnode(fdt, parent); node >= 0; node = fdt_next_subnode(fdt, node))
229#define fdt_get_header(fdt, field) (fdt32_ld(&((const struct fdt_header *) (fdt))->field))
230#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
231#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))
232#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))
233#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings))
234#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap))
235#define fdt_version(fdt) (fdt_get_header(fdt, version))
236#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version))
237#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys))
238#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))
239#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))
241#define fdt_set_hdr_(name) \
242 static inline void fdt_set_##name(void *fdt, uint32_t val) { \
243 struct fdt_header *fdth = (struct fdt_header *) fdt; \
244 fdth->name = cpu_to_fdt32(val); \
311int fdt_move(
const void *fdt,
void *buf,
int bufsize);
333const char *
fdt_get_string(
const void *fdt,
int stroffset,
int *lenp);
347const char *
fdt_string(
const void *fdt,
int stroffset);
541const char *
fdt_get_name(
const void *fdt,
int nodeoffset,
int *lenp);
606#define fdt_for_each_property_offset(property, fdt, node) for (property = fdt_first_property_offset(fdt, node); property >= 0; property = fdt_next_property_offset(fdt, property))
771const void *
fdt_getprop(
const void *fdt,
int nodeoffset,
const char *
name,
int *lenp);
845int fdt_get_path(
const void *fdt,
int nodeoffset,
char *buf,
int buflen);
1089int fdt_stringlist_search(
const void *fdt,
int nodeoffset,
const char *property,
const char *
string);
1130#define FDT_MAX_NCELLS 4
1367#define FDT_CREATE_FLAG_NO_NAME_DEDUP 0x1
1372#define FDT_CREATE_FLAGS_ALL (FDT_CREATE_FLAG_NO_NAME_DEDUP)
1405int fdt_resize(
void *fdt,
void *buf,
int bufsize);
1440#define fdt_property_string(fdt, name, str) fdt_property(fdt, name, str, strlen(str) + 1)
1696#define fdt_setprop_string(fdt, nodeoffset, name, str) fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str) + 1)
1725#define fdt_setprop_empty(fdt, nodeoffset, name) fdt_setprop((fdt), (nodeoffset), (name), NULL, 0)
1864#define fdt_appendprop_string(fdt, nodeoffset, name, str) fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str) + 1)
ul val
Definition memtester.c:33
char name[ANDR_BOOT_NAME_SIZE]
Definition bimage.c:76
char magic[ANDR_BOOT_MAGIC_SIZE]
Definition bimage.c:54
u64_t uint64_t
Definition stdint.h:16
u32_t uint32_t
Definition stdint.h:13
u8_t uint8_t
Definition stdint.h:7
u16_t uint16_t
Definition stdint.h:10
unsigned long long uintptr_t
Definition types.h:21
static uint8_t value
Definition io.h:144
int fdt_add_subnode(void *fdt, int parentoffset, const char *name)
Definition fdt_rw.c:337
static uint16_t fdt16_ld(const fdt16_t *p)
Definition libfdt.h:133
int fdt_finish_reservemap(void *fdt)
Definition fdt_sw.c:195
uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
fdt_get_phandle - retrieve the phandle of a given node @fdt: pointer to the device tree blob @nodeoff...
Definition fdt_ro.c:445
int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags)
fdt_create_with_flags - begin creation of a new fdt @buf: pointer to memory allocated where fdt will ...
Definition fdt_sw.c:102
int fdt_first_subnode(const void *fdt, int offset)
fdt_first_subnode() - get offset of first direct subnode @fdt: FDT blob @offset: Offset of node to ch...
Definition fdt.c:249
int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property, const char *string)
Definition fdt_ro.c:657
int fdt_move(const void *fdt, void *buf, int bufsize)
fdt_move - move a device tree around in memory @fdt: pointer to the device tree to move @buf: pointer...
Definition fdt.c:286
const char * fdt_stringlist_get(const void *fdt, int nodeoffset, const char *property, int index, int *lenp)
Definition fdt_ro.c:685
const char * fdt_get_alias_namelen(const void *fdt, const char *name, int namelen)
Definition fdt_ro.c:461
int fdt_path_offset(const void *fdt, const char *path)
fdt_path_offset - find a tree node by its full path @fdt: pointer to the device tree blob @path: full...
Definition fdt_ro.c:272
int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name)
Definition fdt_ro.c:224
int fdt_check_header(const void *fdt)
fdt_check_header - sanity check a device tree header @fdt: pointer to data which might be a flattened...
Definition fdt.c:81
int fdt_stringlist_contains(const char *strlist, int listlen, const char *str)
fdt_stringlist_contains - check a string list property for a string @strlist: Property containing a l...
Definition fdt_ro.c:617
uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset)
Definition fdt.c:143
int fdt_appendprop(void *fdt, int nodeoffset, const char *name, const void *val, int len)
Definition fdt_rw.c:258
static void * fdt_offset_ptr_w(void *fdt, int offset, int checklen)
Definition libfdt.h:122
int fdt_parent_offset(const void *fdt, int nodeoffset)
fdt_parent_offset - find the parent of a given node @fdt: pointer to the device tree blob @nodeoffset...
Definition fdt_ro.c:566
int fdt_node_depth(const void *fdt, int nodeoffset)
fdt_node_depth - find the depth of a given node @fdt: pointer to the device tree blob @nodeoffset: of...
Definition fdt_ro.c:556
const void * fdt_getprop_namelen(const void *fdt, int nodeoffset, const char *name, int namelen, int *lenp)
Definition fdt_ro.c:398
static int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, uint32_t val)
Definition libfdt.h:1664
static struct fdt_property * fdt_get_property_w(void *fdt, int nodeoffset, const char *name, int *lenp)
Definition libfdt.h:684
int fdt_size_cells(const void *fdt, int nodeoffset)
fdt_size_cells - retrieve address range size for a bus represented in the tree @fdt: pointer to the d...
Definition fdt_addresses.c:44
static int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, const char *name, uint32_t val)
Definition libfdt.h:1308
int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size)
fdt_add_mem_rsv - add one memory reserve map entry @fdt: pointer to the device tree blob @address: 64...
Definition fdt_rw.c:135
int fdt_del_mem_rsv(void *fdt, int n)
fdt_del_mem_rsv - remove a memory reserve map entry @fdt: pointer to the device tree blob : entry to...
Definition fdt_rw.c:151
static int fdt_appendprop_u32(void *fdt, int nodeoffset, const char *name, uint32_t val)
Definition libfdt.h:1784
static void fdt64_st(void *property, uint64_t value)
Definition libfdt.h:161
static int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name, uint32_t val)
Definition libfdt.h:1615
static int fdt_property_u64(void *fdt, const char *name, uint64_t val)
Definition libfdt.h:1414
int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
fdt_get_mem_rsv - retrieve one memory reserve map entry @fdt: pointer to the device tree blob : inde...
Definition fdt_ro.c:163
int fdt_create(void *buf, int bufsize)
fdt_create - begin creation of a new fdt @buf: pointer to memory allocated where fdt will be created ...
Definition fdt_sw.c:134
int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
fdt_node_offset_by_phandle - find the node with a given phandle @fdt: pointer to the device tree blob...
Definition fdt_ro.c:595
const char * fdt_get_alias(const void *fdt, const char *name)
Definition fdt_ro.c:471
int fdt_find_max_phandle(const void *fdt, uint32_t *phandle)
fdt_find_max_phandle - find and return the highest phandle in a tree @fdt: pointer to the device tree...
Definition fdt_ro.c:106
static int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name, uint64_t val)
Definition libfdt.h:1648
int fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset, const char *name, uint64_t addr, uint64_t size)
Definition fdt_addresses.c:54
int fdt_delprop(void *fdt, int nodeoffset, const char *name)
Definition fdt_rw.c:281
const char * fdt_get_string(const void *fdt, int stroffset, int *lenp)
fdt_get_string - retrieve a string from the strings block of a device tree @fdt: pointer to the devic...
Definition fdt_ro.c:31
int fdt_finish(void *fdt)
Definition fdt_sw.c:316
int fdt_next_node(const void *fdt, int offset, int *depth)
Definition fdt.c:211
int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, const void *val, int len)
Definition fdt_wip.c:28
int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset, int supernodedepth, int *nodedepth)
fdt_supernode_atdepth_offset - find a specific ancestor of a node @fdt: pointer to the device tree bl...
Definition fdt_ro.c:522
const void * fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen)
Definition fdt.c:125
int fdt_begin_node(void *fdt, const char *name)
Definition fdt_sw.c:205
const struct fdt_property * fdt_get_property_namelen(const void *fdt, int nodeoffset, const char *name, int namelen, int *lenp)
Definition fdt_ro.c:381
int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name, int len, void **prop_data)
Definition fdt_rw.c:229
static int fdt_appendprop_cell(void *fdt, int nodeoffset, const char *name, uint32_t val)
Definition libfdt.h:1833
int fdt_num_mem_rsv(const void *fdt)
fdt_num_mem_rsv - retrieve the number of memory reserve map entries @fdt: pointer to the device tree ...
Definition fdt_ro.c:176
int fdt_generate_phandle(const void *fdt, uint32_t *phandle)
fdt_generate_phandle - return a new, unused phandle for a device tree blob @fdt: pointer to the devic...
Definition fdt_ro.c:133
int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
fdt_get_path - determine the full path of a node @fdt: pointer to the device tree blob @nodeoffset: o...
Definition fdt_ro.c:475
const struct fdt_property * fdt_get_property(const void *fdt, int nodeoffset, const char *name, int *lenp)
Definition fdt_ro.c:394
int fdt_node_offset_by_compatible(const void *fdt, int startoffset, const char *compatible)
fdt_node_offset_by_compatible - find nodes with a given 'compatible' value @fdt: pointer to the devic...
Definition fdt_ro.c:738
int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp)
Definition fdt_sw.c:274
const void * fdt_getprop(const void *fdt, int nodeoffset, const char *name, int *lenp)
Definition fdt_ro.c:441
int fdt_subnode_offset_namelen(const void *fdt, int parentoffset, const char *name, int namelen)
Definition fdt_ro.c:210
static uint64_t fdt64_ld(const fdt64_t *p)
Definition libfdt.h:154
int fdt_pack(void *fdt)
Definition fdt_rw.c:435
int fdt_node_offset_by_prop_value(const void *fdt, int startoffset, const char *propname, const void *propval, int proplen)
fdt_node_offset_by_prop_value - find nodes with a given property value @fdt: pointer to the device tr...
Definition fdt_ro.c:574
static void * fdt_getprop_namelen_w(void *fdt, int nodeoffset, const char *name, int namelen, int *lenp)
Definition libfdt.h:738
int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property)
Definition fdt_ro.c:633
int fdt_check_full(const void *fdt, size_t bufsize)
int fdt_add_subnode_namelen(void *fdt, int parentoffset, const char *name, int namelen)
Definition fdt_rw.c:295
static int fdt_setprop_inplace_u32(void *fdt, int nodeoffset, const char *name, uint32_t val)
Definition libfdt.h:1260
int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)
Definition fdt_sw.c:176
int fdt_open_into(const void *fdt, void *buf, int bufsize)
Definition fdt_rw.c:372
const struct fdt_property * fdt_get_property_by_offset(const void *fdt, int offset, int *lenp)
fdt_get_property_by_offset - retrieve the property at a given offset @fdt: pointer to the device tree...
Definition fdt_ro.c:346
int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
fdt_path_offset_namelen - find a tree node by its full path @fdt: pointer to the device tree blob @pa...
Definition fdt_ro.c:228
const char * fdt_get_name(const void *fdt, int nodeoffset, int *lenp)
fdt_get_name - retrieve the name of a given node @fdt: pointer to the device tree blob @nodeoffset: s...
Definition fdt_ro.c:276
const char * fdt_string(const void *fdt, int stroffset)
fdt_string - retrieve a string from the strings block of a device tree @fdt: pointer to the device tr...
Definition fdt_ro.c:95
static int fdt_appendprop_u64(void *fdt, int nodeoffset, const char *name, uint64_t val)
Definition libfdt.h:1817
#define fdt_set_hdr_(name)
Definition libfdt.h:241
static void fdt32_st(void *property, uint32_t value)
Definition libfdt.h:145
int fdt_first_property_offset(const void *fdt, int nodeoffset)
fdt_first_property_offset - find the offset of a node's first property @fdt: pointer to the device tr...
Definition fdt_ro.c:312
static int fdt_setprop_inplace_u64(void *fdt, int nodeoffset, const char *name, uint64_t val)
Definition libfdt.h:1293
int fdt_address_cells(const void *fdt, int nodeoffset)
fdt_address_cells - retrieve address size for a bus represented in the tree @fdt: pointer to the devi...
Definition fdt_addresses.c:33
static uint32_t fdt32_ld(const fdt32_t *p)
Definition libfdt.h:139
int fdt_create_empty_tree(void *buf, int bufsize)
Definition fdt_empty_tree.c:13
int fdt_resize(void *fdt, void *buf, int bufsize)
Definition fdt_sw.c:138
size_t fdt_header_size_(uint32_t version)
fdt_header_size_ - internal function to get header size from a version number
Definition fdt.c:64
int fdt_nop_node(void *fdt, int nodeoffset)
fdt_nop_node - replace a node (subtree) with nop tags @fdt: pointer to the device tree blob @nodeoffs...
Definition fdt_wip.c:69
int fdt_end_node(void *fdt)
Definition fdt_sw.c:221
int fdt_next_subnode(const void *fdt, int offset)
fdt_next_subnode() - get offset of next direct subnode @fdt: FDT blob @offset: Offset of previous sub...
Definition fdt.c:259
int fdt_nop_property(void *fdt, int nodeoffset, const char *name)
Definition fdt_wip.c:48
int fdt_overlay_apply(void *fdt, void *fdto)
fdt_overlay_apply - Applies a DT overlay on a base DT @fdt: pointer to the base device tree blob @fdt...
Definition fdt_overlay.c:781
int fdt_next_property_offset(const void *fdt, int offset)
fdt_next_property_offset - step through a node's properties @fdt: pointer to the device tree blob @of...
Definition fdt_ro.c:321
int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, const char *name, int namelen, uint32_t idx, const void *val, int len)
Definition fdt_wip.c:13
const void * fdt_getprop_by_offset(const void *fdt, int offset, const char **namep, int *lenp)
fdt_getprop_by_offset - retrieve the value of a property at a given offset @fdt: pointer to the devic...
Definition fdt_ro.c:412
int fdt_del_node(void *fdt, int nodeoffset)
fdt_del_node - delete a node (subtree) @fdt: pointer to the device tree blob @nodeoffset: offset of t...
Definition fdt_rw.c:341
int fdt_set_name(void *fdt, int nodeoffset, const char *name)
Definition fdt_rw.c:208
const char * fdt_strerror(int errval)
Definition fdt_strerror.c:48
int fdt_node_check_compatible(const void *fdt, int nodeoffset, const char *compatible)
fdt_node_check_compatible - check a node's compatible property @fdt: pointer to the device tree blob ...
Definition fdt_ro.c:727
static int fdt_property_cell(void *fdt, const char *name, uint32_t val)
Definition libfdt.h:1420
static int fdt_property_u32(void *fdt, const char *name, uint32_t val)
Definition libfdt.h:1410
int fdt_setprop(void *fdt, int nodeoffset, const char *name, const void *val, int len)
Definition fdt_rw.c:245
static uint32_t fdt_get_max_phandle(const void *fdt)
fdt_get_max_phandle - retrieves the highest phandle in a tree @fdt: pointer to the device tree blob
Definition libfdt.h:378
static void * fdt_getprop_w(void *fdt, int nodeoffset, const char *name, int *lenp)
Definition libfdt.h:772
size_t fdt_header_size(const void *fdt)
fdt_header_size - return the size of the tree's header @fdt: pointer to a flattened device tree
Definition fdt.c:77
static fdt32_t cpu_to_fdt32(uint32_t x)
Definition libfdt_env.h:50
static fdt64_t cpu_to_fdt64(uint64_t x)
Definition libfdt_env.h:57
uint32_t FDT_BITWISE fdt32_t
Definition libfdt_env.h:30
uint16_t FDT_BITWISE fdt16_t
Definition libfdt_env.h:29
uint64_t FDT_BITWISE fdt64_t
Definition libfdt_env.h:31
fdt32_t len
Definition fdt.h:47
uint16_t index
Definition usb.h:3