mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Subject: [RFC 08/10] bootm: add kexec ELF support
Date: Tue, 15 Apr 2014 11:38:32 +0400	[thread overview]
Message-ID: <1397547514-19925-9-git-send-email-antonynpavlov@gmail.com> (raw)
In-Reply-To: <1397547514-19925-1-git-send-email-antonynpavlov@gmail.com>

Also introduce reboot() for starting already loaded
via kexec ELF segments.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 include/linux/reboot.h      | 14 ++++++++++++++
 lib/kexec/Makefile          |  1 +
 lib/kexec/kexec-bootm-elf.c | 36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 include/linux/reboot.h
 create mode 100644 lib/kexec/kexec-bootm-elf.c

diff --git a/include/linux/reboot.h b/include/linux/reboot.h
new file mode 100644
index 0000000..454ed33
--- /dev/null
+++ b/include/linux/reboot.h
@@ -0,0 +1,14 @@
+#ifndef _LINUX_REBOOT_H
+#define _LINUX_REBOOT_H
+
+/*
+ * Commands accepted by the _reboot() system call.
+ *
+ * KEXEC       Restart system using a previously loaded Linux kernel
+ */
+
+#define	LINUX_REBOOT_CMD_KEXEC		0x45584543
+
+extern int reboot(int cmd);
+
+#endif /* _LINUX_REBOOT_H */
diff --git a/lib/kexec/Makefile b/lib/kexec/Makefile
index 8febef1..2f3dc1d 100644
--- a/lib/kexec/Makefile
+++ b/lib/kexec/Makefile
@@ -1,3 +1,4 @@
 obj-y	+= kexec.o
 obj-y	+= kexec-elf.o
 obj-y	+= kexec-elf-exec.o
+obj-y	+= kexec-bootm-elf.o
diff --git a/lib/kexec/kexec-bootm-elf.c b/lib/kexec/kexec-bootm-elf.c
new file mode 100644
index 0000000..6c8071a
--- /dev/null
+++ b/lib/kexec/kexec-bootm-elf.c
@@ -0,0 +1,36 @@
+#include <boot.h>
+#include <init.h>
+#include <binfmt.h>
+#include <errno.h>
+#include <linux/reboot.h>
+
+#include "kexec.h"
+
+static int do_bootm_elf(struct image_data *data)
+{
+	kexec_load_file(data->os_file, 0);
+	setenv("global.bootm.image", data->os_file);
+	reboot(LINUX_REBOOT_CMD_KEXEC);
+
+	return -ERESTARTSYS;
+}
+
+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 elf_register_image_handler(void)
+{
+	register_image_handler(&elf_handler);
+	binfmt_register(&binfmt_elf_hook);
+
+	return 0;
+}
+late_initcall(elf_register_image_handler);
-- 
1.9.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-04-15  7:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-15  7:38 [RFC 00/10] MIPS: use kexec to load ELF linux images Antony Pavlov
2014-04-15  7:38 ` [RFC 01/10] MIPS: add initial cache support for R4000-class CPUs Antony Pavlov
2014-04-15  7:38 ` [RFC 02/10] MIPS: introduce arch_shutdown() Antony Pavlov
2014-04-15  7:38 ` [RFC 03/10] MIPS: use arch_shutdown() for flushing caches Antony Pavlov
2014-04-23  8:43   ` Sascha Hauer
2014-04-15  7:38 ` [RFC 04/10] MIPS: add virt_to_phys() and phys_to_virt() Antony Pavlov
2014-04-15  7:38 ` [RFC 05/10] resource: add create_resource() helper function Antony Pavlov
2014-04-23  8:46   ` Sascha Hauer
2014-04-15  7:38 ` [RFC 06/10] import initial kexec stuff Antony Pavlov
2014-04-15  7:38 ` [RFC 07/10] filetype: add ELF type Antony Pavlov
2014-04-15  7:38 ` Antony Pavlov [this message]
2014-04-23  9:15   ` [RFC 08/10] bootm: add kexec ELF support Sascha Hauer
2014-04-15  7:38 ` [RFC 09/10] MIPS: add " Antony Pavlov
2014-04-15  7:38 ` [RFC 10/10] MIPS: mach-malta: add kexec-capable reboot() Antony Pavlov

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=1397547514-19925-9-git-send-email-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.com \
    --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