feat(bl): add plat handler for image loading

In case of load error, platform may need to try another instance, either
from another storage, or from the same storage in case of PSA FWU. On
MTD devices such as NAND, it is required to define backup partitions.
A new function plat_setup_try_img_ops() should be called by platform
code to register handlers (plat_try_images_ops) to manage loading
other images.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Signed-off-by: Lionel Debieve <lionel.debieve@foss.st.com>
Change-Id: Ideaecaf296c0037a26fb4e6680f33e507111378a
diff --git a/common/bl_common.c b/common/bl_common.c
index d01ef92..2a9f32f 100644
--- a/common/bl_common.c
+++ b/common/bl_common.c
@@ -211,7 +211,18 @@
 {
 	int err;
 
-	err = load_auth_image_internal(image_id, image_data);
+	if ((plat_try_img_ops == NULL) || (plat_try_img_ops->next_instance == NULL)) {
+		err = load_auth_image_internal(image_id, image_data);
+	} else {
+		do {
+			err = load_auth_image_internal(image_id, image_data);
+			if (err != 0) {
+				if (plat_try_img_ops->next_instance(image_id) != 0) {
+					return err;
+				}
+			}
+		} while (err != 0);
+	}
 
 	if (err == 0) {
 		/*