From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v4 3/3] MIPS: bootm: add ELF handler
Date: Wed, 6 Jun 2018 09:59:12 +0200 [thread overview]
Message-ID: <20180606075912.2470-4-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20180606075912.2470-1-o.rempel@pengutronix.de>
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>
---
arch/mips/lib/bootm.c | 59 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 91e7e1c68..f14540a4c 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);
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-06-06 7:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-06 7:59 [PATCH v4 0/3] MIPS: provide basic ELF support Oleksij Rempel
2018-06-06 7:59 ` [PATCH v4 1/3] filetype: add ELF type Oleksij Rempel
2018-06-06 7:59 ` [PATCH v4 2/3] add basic ELF parser Oleksij Rempel
2018-06-15 18:20 ` Alexander Kurz
2018-06-16 8:12 ` Oleksij Rempel
2018-06-06 7:59 ` Oleksij Rempel [this message]
2018-06-08 5:59 ` [PATCH v4 0/3] MIPS: provide basic ELF support Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180606075912.2470-4-o.rempel@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox