X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libfdt%2Ffdt_wip.c;h=2d39aabe1fe9872c2a9e5e441979426244e063fd;hb=9675ee7208ab965d13ea8d8262d77ac4160ef549;hp=261b9b0dc9379f714fd00ea2a0806d065a269336;hpb=c8f228016202aff5ff09cdeeabe8cffd8d898510;p=u-boot diff --git a/libfdt/fdt_wip.c b/libfdt/fdt_wip.c index 261b9b0dc9..2d39aabe1f 100644 --- a/libfdt/fdt_wip.c +++ b/libfdt/fdt_wip.c @@ -16,6 +16,9 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" +#if CONFIG_OF_LIBFDT + #include "libfdt_env.h" #include @@ -110,3 +113,30 @@ int fdt_nop_node(void *fdt, int nodeoffset) nop_region(fdt_offset_ptr(fdt, nodeoffset, 0), endoffset - nodeoffset); return 0; } + +/* + * Replace a reserve map entry in the nth slot. + */ +int fdt_replace_reservemap_entry(void *fdt, int n, uint64_t addr, uint64_t size) +{ + struct fdt_reserve_entry *re; + int used; + int total; + int err; + + err = fdt_num_reservemap(fdt, &used, &total); + if (err != 0) + return err; + + if (n >= total) + return -FDT_ERR_NOSPACE; + re = (struct fdt_reserve_entry *) + (fdt + fdt_off_mem_rsvmap(fdt) + + (n * sizeof(struct fdt_reserve_entry))); + re->address = cpu_to_fdt64(addr); + re->size = cpu_to_fdt64(size); + + return 0; +} + +#endif /* CONFIG_OF_LIBFDT */