boot: arm: riscv: sandbox: Add a format for the booti file
Arm invented a new format for arm64 and something similar is also used
with RISC-V. Add this to the list of supported formats and provide a way
for the format to be detected on both architectures.
Update the genimg_get_format() function to support this.
Fix up switch() statements which don't currently mention this format.
Booti does not support a ramdisk, so this can be ignored.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/arch/arm/lib/image.c b/arch/arm/lib/image.c
index 1f672ee..d78d704 100644
--- a/arch/arm/lib/image.c
+++ b/arch/arm/lib/image.c
@@ -28,6 +28,13 @@
uint32_t res5;
};
+bool booti_is_valid(const void *img)
+{
+ const struct Image_header *ih = img;
+
+ return ih->magic == le32_to_cpu(LINUX_ARM64_IMAGE_MAGIC);
+}
+
int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
bool force_reloc)
{
@@ -39,7 +46,7 @@
ih = (struct Image_header *)map_sysmem(image, 0);
- if (ih->magic != le32_to_cpu(LINUX_ARM64_IMAGE_MAGIC)) {
+ if (!booti_is_valid(ih)) {
puts("Bad Linux ARM64 Image magic!\n");
return 1;
}
diff --git a/arch/riscv/lib/image.c b/arch/riscv/lib/image.c
index a82f48e..859326c 100644
--- a/arch/riscv/lib/image.c
+++ b/arch/riscv/lib/image.c
@@ -32,6 +32,13 @@
uint32_t res4; /* reserved */
};
+bool booti_is_valid(const void *img)
+{
+ const struct linux_image_h *lhdr = img;
+
+ return lhdr->magic == LINUX_RISCV_IMAGE_MAGIC;
+}
+
int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
bool force_reloc)
{
@@ -39,7 +46,7 @@
lhdr = (struct linux_image_h *)map_sysmem(image, 0);
- if (lhdr->magic != LINUX_RISCV_IMAGE_MAGIC) {
+ if (!booti_is_valid(lhdr)) {
puts("Bad Linux RISCV Image magic!\n");
return -EINVAL;
}
diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
index 44ba8b5..8ed9237 100644
--- a/arch/sandbox/lib/bootm.c
+++ b/arch/sandbox/lib/bootm.c
@@ -89,3 +89,8 @@
return 1;
}
+
+bool booti_is_valid(const void *img)
+{
+ return false;
+}