diff options
author | Andrew F. Davis <afd@ti.com> | 2016-11-30 01:33:20 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-12-03 21:21:19 +0300 |
commit | d7be50921ed35e36e000a5e8daba41701a5eebb9 (patch) | |
tree | 54562749aee083bb8f3b86eb2fee34c48c7e1291 /common/image.c | |
parent | 5ca28f67ace439ee06efd310b53621526bd06468 (diff) | |
download | u-boot-d7be50921ed35e36e000a5e8daba41701a5eebb9.tar.xz |
image: Add FIT image loadable section custom processing
To help automate the loading of custom image types we add the ability
to define custom handlers for the loadable section types. When we find
a compatible type while loading a "loadable" image from a FIT image we
run its associated handlers to perform any additional steps needed for
loading this image.
Signed-off-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/image.c')
-rw-r--r-- | common/image.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/common/image.c b/common/image.c index 7604494a56..2aac90d818 100644 --- a/common/image.c +++ b/common/image.c @@ -1389,6 +1389,23 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, } #endif +static void fit_loadable_process(uint8_t img_type, + ulong img_data, + ulong img_len) +{ + int i; + const unsigned int count = + ll_entry_count(struct fit_loadable_tbl, fit_loadable); + struct fit_loadable_tbl *fit_loadable_handler = + ll_entry_start(struct fit_loadable_tbl, fit_loadable); + /* For each loadable handler */ + for (i = 0; i < count; i++, fit_loadable_handler++) + /* matching this type */ + if (fit_loadable_handler->type == img_type) + /* call that handler with this image data */ + fit_loadable_handler->handler(img_data, img_len); +} + int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images, uint8_t arch, const ulong *ld_start, ulong * const ld_len) { @@ -1407,6 +1424,7 @@ int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images, int conf_noffset; int fit_img_result; const char *uname; + uint8_t img_type; /* Check to see if the images struct has a FIT configuration */ if (!genimg_has_config(images)) { @@ -1447,6 +1465,21 @@ int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images, /* Something went wrong! */ return fit_img_result; } + + fit_img_result = fit_image_get_node(buf, uname); + if (fit_img_result < 0) { + /* Something went wrong! */ + return fit_img_result; + } + fit_img_result = fit_image_get_type(buf, + fit_img_result, + &img_type); + if (fit_img_result < 0) { + /* Something went wrong! */ + return fit_img_result; + } + + fit_loadable_process(img_type, img_data, img_len); } break; default: |