Lines Matching defs:fdt

31 #include <fdt.h>
37 static int _fdt_sw_check_header(void *fdt)
39 if (fdt_magic(fdt) != FDT_SW_MAGIC)
45 #define FDT_SW_CHECK_HEADER(fdt) \
48 if ((err = _fdt_sw_check_header(fdt)) != 0) \
52 static void *_fdt_grab_space(void *fdt, size_t len)
54 int offset = fdt_size_dt_struct(fdt);
57 spaceleft = fdt_totalsize(fdt) - fdt_off_dt_struct(fdt)
58 - fdt_size_dt_strings(fdt);
63 fdt_set_size_dt_struct(fdt, offset + len);
64 return _fdt_offset_ptr_w(fdt, offset);
69 void *fdt = buf;
76 fdt_set_magic(fdt, FDT_SW_MAGIC);
77 fdt_set_version(fdt, FDT_LAST_SUPPORTED_VERSION);
78 fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION);
79 fdt_set_totalsize(fdt, bufsize);
81 fdt_set_off_mem_rsvmap(fdt, FDT_ALIGN(sizeof(struct fdt_header),
83 fdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt));
84 fdt_set_off_dt_strings(fdt, bufsize);
89 int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)
94 FDT_SW_CHECK_HEADER(fdt);
96 if (fdt_size_dt_struct(fdt))
99 offset = fdt_off_dt_struct(fdt);
100 if ((offset + sizeof(*re)) > fdt_totalsize(fdt))
103 re = (struct fdt_reserve_entry *)((char *)fdt + offset);
107 fdt_set_off_dt_struct(fdt, offset + sizeof(*re));
112 int fdt_finish_reservemap(void *fdt)
114 return fdt_add_reservemap_entry(fdt, 0, 0);
117 int fdt_begin_node(void *fdt, const char *name)
122 FDT_SW_CHECK_HEADER(fdt);
124 nh = _fdt_grab_space(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));
133 int fdt_end_node(void *fdt)
137 FDT_SW_CHECK_HEADER(fdt);
139 en = _fdt_grab_space(fdt, FDT_TAGSIZE);
147 static int _fdt_find_add_string(void *fdt, const char *s)
149 char *strtab = (char *)fdt + fdt_totalsize(fdt);
151 int strtabsize = fdt_size_dt_strings(fdt);
161 struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
162 if (fdt_totalsize(fdt) + offset < struct_top)
166 fdt_set_size_dt_strings(fdt, strtabsize + len);
170 int fdt_property(void *fdt, const char *name, const void *val, int len)
175 FDT_SW_CHECK_HEADER(fdt);
177 nameoff = _fdt_find_add_string(fdt, name);
181 prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
192 int fdt_finish(void *fdt)
194 char *p = (char *)fdt;
200 FDT_SW_CHECK_HEADER(fdt);
203 end = _fdt_grab_space(fdt, sizeof(*end));
209 oldstroffset = fdt_totalsize(fdt) - fdt_size_dt_strings(fdt);
210 newstroffset = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
211 memmove(p + newstroffset, p + oldstroffset, fdt_size_dt_strings(fdt));
212 fdt_set_off_dt_strings(fdt, newstroffset);
216 while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) {
219 _fdt_offset_ptr_w(fdt, offset);
223 nameoff += fdt_size_dt_strings(fdt);
232 fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt));
233 fdt_set_magic(fdt, FDT_MAGIC);