diff mbox series

[07/19] sandbox: image: Allow sandbox to load any image

Message ID 20210315051124.1940496-6-sjg@chromium.org
State Accepted
Commit e2734d647e9c86f46083b29224fc7b41a46e1858
Delegated to: Simon Glass
Headers show
Series sandbox: Preparation for running vboot from coreboot | expand

Commit Message

Simon Glass March 15, 2021, 5:11 a.m. UTC
Sandbox is special in that it is used for testing and it does not match
any particular target architecture. Allow it to load an image from any
architecture, so that 'bootm' can be used as needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/image-fit.c | 4 ++++
 include/image.h    | 5 +++++
 2 files changed, 9 insertions(+)

Comments

Simon Glass March 27, 2021, 3:20 a.m. UTC | #1
On Mon, 15 Mar 2021 at 18:12, Simon Glass <sjg@chromium.org> wrote:
>
> Sandbox is special in that it is used for testing and it does not match
> any particular target architecture. Allow it to load an image from any
> architecture, so that 'bootm' can be used as needed.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  common/image-fit.c | 4 ++++
>  include/image.h    | 5 +++++
>  2 files changed, 9 insertions(+)

Applied to u-boot-dm/next
diff mbox series

Patch

diff --git a/common/image-fit.c b/common/image-fit.c
index 28b3d2b1911..2d0ece61815 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1512,6 +1512,10 @@  int fit_image_check_arch(const void *fit, int noffset, uint8_t arch)
 	uint8_t image_arch;
 	int aarch32_support = 0;
 
+	/* Let's assume that sandbox can load any architecture */
+	if (IS_ENABLED(CONFIG_SANDBOX))
+		return true;
+
 	if (IS_ENABLED(CONFIG_ARM64_SUPPORT_AARCH32))
 		aarch32_support = 1;
 
diff --git a/include/image.h b/include/image.h
index 138c83dd28d..bcd126d262d 100644
--- a/include/image.h
+++ b/include/image.h
@@ -886,6 +886,11 @@  static inline int image_check_type(const image_header_t *hdr, uint8_t type)
 }
 static inline int image_check_arch(const image_header_t *hdr, uint8_t arch)
 {
+#ifndef USE_HOSTCC
+	/* Let's assume that sandbox can load any architecture */
+	if (IS_ENABLED(CONFIG_SANDBOX))
+		return true;
+#endif
 	return (image_get_arch(hdr) == arch) ||
 		(image_get_arch(hdr) == IH_ARCH_ARM && arch == IH_ARCH_ARM64);
 }