diff options
author | Clement Leger <clement.leger@bootlin.com> | 2022-01-17 23:19:11 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-01-18 09:07:27 +0100 |
commit | 129fd6b6cdfd067ed315f558409df03beb2a4533 (patch) | |
tree | a4dab6e6bc39a5b091226967485c12fbbf142f73 /arch/kvx | |
parent | a01f05e69f7ccf5cbc3a8244ff8e8f7267f5deea (diff) | |
download | barebox-129fd6b6cdfd067ed315f558409df03beb2a4533.tar.gz barebox-129fd6b6cdfd067ed315f558409df03beb2a4533.tar.xz |
kvx: enable FITIMAGE support
Enable FITIMAGE support in kvx defconfig and add code to handle fit boot
from bootm command. This is rather a simple addition and it allow to boot
a fit image containing an ELF file as the kernel.
Signed-off-by: Clement Leger <clement.leger@bootlin.com>
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
Link: https://lore.barebox.org/20220117221917.26970-6-jmaselbas@kalray.eu
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/kvx')
-rw-r--r-- | arch/kvx/Kconfig | 1 | ||||
-rw-r--r-- | arch/kvx/lib/bootm.c | 32 |
2 files changed, 32 insertions, 1 deletions
diff --git a/arch/kvx/Kconfig b/arch/kvx/Kconfig index 0934440880..100a945761 100644 --- a/arch/kvx/Kconfig +++ b/arch/kvx/Kconfig @@ -10,6 +10,7 @@ config KVX select COMMON_CLK_OF_PROVIDER select ELF select FLEXIBLE_BOOTARGS + select FITIMAGE select GENERIC_FIND_NEXT_BIT select HAS_ARCH_SJLJ select HAS_CACHE diff --git a/arch/kvx/lib/bootm.c b/arch/kvx/lib/bootm.c index 3e9772c458..4c77f676ec 100644 --- a/arch/kvx/lib/bootm.c +++ b/arch/kvx/lib/bootm.c @@ -94,7 +94,7 @@ static int do_boot_elf(struct image_data *data, struct elf_image *elf) goto err_free_fdt; } - entry = (boot_func_entry) data->os_address; + entry = (boot_func_entry) elf->entry; ret = do_boot_entry(data, entry, fdt); @@ -104,6 +104,27 @@ err_free_fdt: return ret; } +static int do_bootm_fit(struct image_data *data) +{ + int ret; + struct elf_image *elf; + + elf = elf_open_binary((void *) data->fit_kernel); + if (IS_ERR(elf)) + return PTR_ERR(data->elf); + + ret = elf_load(elf); + if (ret) + goto close_elf; + + ret = do_boot_elf(data, elf); + +close_elf: + elf_close(elf); + + return ret; +} + static int do_bootm_elf(struct image_data *data) { int ret; @@ -121,6 +142,12 @@ static struct image_handler elf_handler = { .filetype = filetype_elf, }; +static struct image_handler fit_handler = { + .name = "FIT", + .bootm = do_bootm_fit, + .filetype = filetype_oftree, +}; + static struct binfmt_hook binfmt_elf_hook = { .type = filetype_elf, .exec = "bootm", @@ -130,6 +157,9 @@ static int kvx_register_image_handler(void) { register_image_handler(&elf_handler); + if (IS_ENABLED(CONFIG_FITIMAGE)) + register_image_handler(&fit_handler); + binfmt_register(&binfmt_elf_hook); return 0; |