summaryrefslogtreecommitdiffstats
path: root/arch/mips/lib/bootm.c
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2018-06-06 09:59:12 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-06-18 10:02:29 +0200
commita54a47ff7710d12e5a6c88953b3da85cc162c1ea (patch)
tree07359d5046953e01db25b88776065b939a086df1 /arch/mips/lib/bootm.c
parent7c8679eebc8e4e69ba0afa370d85d3d6eb386997 (diff)
downloadbarebox-a54a47ff7710d12e5a6c88953b3da85cc162c1ea.tar.gz
barebox-a54a47ff7710d12e5a6c88953b3da85cc162c1ea.tar.xz
MIPS: bootm: add ELF handler
With this handler barebox will be able to start linux kernel as is, without additional image conversion. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/mips/lib/bootm.c')
-rw-r--r--arch/mips/lib/bootm.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 91e7e1c68a..f14540a4c4 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -10,6 +10,7 @@
#include <restart.h>
#include <asm/byteorder.h>
+#include <asm/io.h>
static int do_bootm_barebox(struct image_data *data)
{
@@ -42,11 +43,69 @@ static struct binfmt_hook binfmt_barebox_hook = {
.exec = "bootm",
};
+static int do_bootm_elf(struct image_data *data)
+{
+ void (*entry)(int, void *);
+ struct elf_image *elf;
+ void *fdt, *buf;
+ int ret = 0;
+
+ buf = read_file(data->os_file, NULL);
+ if (!buf)
+ return -EINVAL;
+
+ elf = elf_load_image(buf);
+ if (IS_ERR(elf))
+ return PTR_ERR(elf);
+
+ fdt = bootm_get_devicetree(data);
+ if (IS_ERR(fdt)) {
+ ret = PTR_ERR(fdt);
+ goto bootm_elf_done;
+ }
+
+ pr_info("Starting application at 0x%08lx, dts 0x%08lx...\n",
+ phys_to_virt(elf->entry), data->of_root_node);
+
+ if (data->dryrun)
+ goto bootm_elf_done;
+
+ shutdown_barebox();
+
+ entry = (void *)elf->entry;
+
+ entry(-2, phys_to_virt((unsigned long)fdt));
+
+ pr_err("ELF application terminated\n");
+ ret = -EINVAL;
+
+bootm_elf_done:
+ elf_release_image(elf);
+ free(fdt);
+ free(buf);
+
+ return ret;
+}
+
+static struct image_handler elf_handler = {
+ .name = "ELF",
+ .bootm = do_bootm_elf,
+ .filetype = filetype_elf,
+};
+
+static struct binfmt_hook binfmt_elf_hook = {
+ .type = filetype_elf,
+ .exec = "bootm",
+};
+
static int mips_register_image_handler(void)
{
register_image_handler(&barebox_handler);
binfmt_register(&binfmt_barebox_hook);
+ register_image_handler(&elf_handler);
+ binfmt_register(&binfmt_elf_hook);
+
return 0;
}
late_initcall(mips_register_image_handler);