diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-03-22 14:39:10 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-03-23 12:16:26 +0100 |
commit | 15fc6ffd0274f72282761ed0e6ae4b097be23f97 (patch) | |
tree | fb5942c29cac12e461a6aec24bacdb261fc0f932 | |
parent | cbb44501dc3e8c90714c8296669bdf28f2ec4f98 (diff) | |
download | barebox-15fc6ffd0274f72282761ed0e6ae4b097be23f97.tar.gz barebox-15fc6ffd0274f72282761ed0e6ae4b097be23f97.tar.xz |
filetype: detect RISC-V images
We still have no boot support for RISC-V, take the first step by
enabling barebox to detect both a RISC-V Linux kernel and barebox image.
The header format is aligned with that of arm64, but they differ
in the signature magic.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | common/filetype.c | 6 | ||||
-rw-r--r-- | include/filetype.h | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/common/filetype.c b/common/filetype.c index 539c96b745..0cae00abaa 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -61,6 +61,8 @@ static const struct filetype_str filetype_str[] = { [filetype_kwbimage_v1] = { "MVEBU kwbimage (v1)", "kwb1" }, [filetype_android_sparse] = { "Android sparse image", "sparse" }, [filetype_arm64_linux_image] = { "ARM aarch64 Linux image", "aarch64-linux" }, + [filetype_riscv_linux_image] = { "RISC-V Linux image", "riscv-linux" }, + [filetype_riscv_barebox_image] = { "RISC-V barebox image", "riscv-barebox" }, [filetype_elf] = { "ELF", "elf" }, [filetype_imx_image_v1] = { "i.MX image (v1)", "imx-image-v1" }, [filetype_imx_image_v2] = { "i.MX image (v2)", "imx-image-v2" }, @@ -303,6 +305,10 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize) return filetype_bpk; if (le32_to_cpu(buf[14]) == 0x644d5241) return filetype_arm64_linux_image; + if (le32_to_cpu(buf[14]) == 0x05435352) + return filetype_riscv_linux_image; + if (le32_to_cpu(buf[14]) == 0x56435352 && !memcmp(&buf[12], "barebox", 8)) + return filetype_riscv_barebox_image; if ((buf8[0] == 0x5a || buf8[0] == 0x69 || buf8[0] == 0x78 || buf8[0] == 0x8b || buf8[0] == 0x9c) && buf8[0x1] == 0 && buf8[0x2] == 0 && buf8[0x3] == 0 && diff --git a/include/filetype.h b/include/filetype.h index 3019dda6ed..fd339f9564 100644 --- a/include/filetype.h +++ b/include/filetype.h @@ -43,6 +43,8 @@ enum filetype { filetype_kwbimage_v1, filetype_android_sparse, filetype_arm64_linux_image, + filetype_riscv_linux_image, + filetype_riscv_barebox_image, filetype_elf, filetype_imx_image_v1, filetype_imx_image_v2, |