In some cases we don't won't to load devicetree some where in free ram area, it is easier to keep it withing allocated area of barebox and then give the pointer to the kernel. Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> --- common/bootm.c | 39 +++++++++++++++++++++++++++++++++------ include/bootm.h | 1 + 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/common/bootm.c b/common/bootm.c index 5ff6683fe..a9d18fb57 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -320,20 +320,17 @@ static int bootm_open_oftree_uimage(struct image_data *data, size_t *size, } /* - * bootm_load_devicetree() - load devicetree + * bootm_get_devicetree() - get devicetree * * @data: image data context - * @load_address: The address where the devicetree should be loaded to * - * This loads the devicetree to a RAM location. load_address must be a valid - * address. The resulting devicetree will be found at data->oftree. + * Prepare devicetree for later use by boot handler. * * Return: 0 on success, negative error code otherwise */ -int bootm_load_devicetree(struct image_data *data, unsigned long load_address) +int bootm_get_devicetree(struct image_data *data) { enum filetype type; - int fdt_size; struct fdt_header *oftree; int ret; @@ -410,6 +407,36 @@ int bootm_load_devicetree(struct image_data *data, unsigned long load_address) if (!oftree) return -EINVAL; + data->oftree = oftree; + + return 0; +} + +/* + * bootm_load_devicetree() - load devicetree + * + * @data: image data context + * @load_address: The address where the devicetree should be loaded to + * + * This loads the devicetree to a RAM location. load_address must be a valid + * address. The resulting devicetree will be found at data->oftree. + * + * Return: 0 on success, negative error code otherwise + */ + +int bootm_load_devicetree(struct image_data *data, unsigned long load_address) +{ + struct fdt_header *oftree; + int fdt_size; + int ret; + + ret = bootm_get_devicetree(data); + if (ret) + return ret; + + oftree = data->oftree; + + fdt_size = be32_to_cpu(oftree->totalsize); data->oftree_res = request_sdram_region("oftree", load_address, diff --git a/include/bootm.h b/include/bootm.h index 62951d605..410b42cde 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -126,6 +126,7 @@ int bootm_load_os(struct image_data *data, unsigned long load_address); bool bootm_has_initrd(struct image_data *data); int bootm_load_initrd(struct image_data *data, unsigned long load_address); +int bootm_get_devicetree(struct image_data *data); int bootm_load_devicetree(struct image_data *data, unsigned long load_address); int bootm_get_os_size(struct image_data *data); -- 2.17.1 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox