From: Andrew F. Davis <afd@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] image: Add FIT image loadable section custom processing
Date: Mon, 21 Nov 2016 14:14:45 -0600 [thread overview]
Message-ID: <20161121201447.814-2-afd@ti.com> (raw)
In-Reply-To: <20161121201447.814-1-afd@ti.com>
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>
---
common/image.c | 33 +++++++++++++++++++++++++++++++++
include/image.h | 11 +++++++++++
2 files changed, 44 insertions(+)
diff --git a/common/image.c b/common/image.c
index 7604494..2aac90d 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:
diff --git a/include/image.h b/include/image.h
index 2b1296c..a8b81b5 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1263,4 +1263,15 @@ int board_fit_config_name_match(const char *name);
void board_fit_image_post_process(void **p_image, size_t *p_size);
#endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */
+struct fit_loadable_tbl {
+ int type;
+ void (*handler)(ulong data, size_t size);
+};
+
+#define U_BOOT_FIT_LOADABLE_HANDLER(_type, _handler) \
+ ll_entry_declare(struct fit_loadable_tbl, _function, fit_loadable) = { \
+ .type = _type, \
+ .handler = _handler, \
+ }
+
#endif /* __IMAGE_H__ */
--
2.10.2
next prev parent reply other threads:[~2016-11-21 20:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-21 20:14 [U-Boot] [PATCH 0/3] Add FIT loadable custom processing Andrew F. Davis
2016-11-21 20:14 ` Andrew F. Davis [this message]
2016-11-24 2:20 ` [U-Boot] [PATCH 1/3] image: Add FIT image loadable section " Simon Glass
2016-11-29 16:51 ` Andrew F. Davis
2016-11-21 20:14 ` [U-Boot] [PATCH 2/3] image: Add Trusted Execution Environment image type Andrew F. Davis
2016-11-24 2:20 ` Simon Glass
2016-11-21 20:14 ` [U-Boot] [PATCH 3/3] RFC: board: ti: dra7xx: add FIT image TEE processing Andrew F. Davis
2016-11-24 2:20 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161121201447.814-2-afd@ti.com \
--to=afd@ti.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.