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 2/2] MIPS: bootm: add "MIPS barebox" handler
Date: Sat, 28 Apr 2012 17:52:10 +0400	[thread overview]
Message-ID: <1335621130-935-2-git-send-email-antonynpavlov@gmail.com> (raw)
In-Reply-To: <1335621130-935-1-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/mips/lib/Makefile |    1 +
 arch/mips/lib/bootm.c  |   43 +++++++++++++++++++++++++++++++++++++++++++
 common/filetype.c      |    2 ++
 include/filetype.h     |    1 +
 4 files changed, 47 insertions(+)
 create mode 100644 arch/mips/lib/bootm.c

diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index 45fe920..85aa194 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -6,3 +6,4 @@ obj-y += ashrdi3.o
 obj-y += memory.o
 
 obj-$(CONFIG_CMD_MIPS_CPUINFO) += cpuinfo.o
+obj-$(CONFIG_CMD_BOOTM)	+= bootm.o
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
new file mode 100644
index 0000000..3d6a4ce
--- /dev/null
+++ b/arch/mips/lib/bootm.c
@@ -0,0 +1,43 @@
+#include <boot.h>
+#include <common.h>
+#include <init.h>
+#include <fs.h>
+#include <errno.h>
+#include <binfmt.h>
+
+#include <asm/byteorder.h>
+
+static int do_bootm_barebox(struct image_data *data)
+{
+	void (*barebox)(void);
+
+	barebox = read_file(data->os_file, NULL);
+	if (!barebox)
+		return -EINVAL;
+
+	shutdown_barebox();
+
+	barebox();
+
+	reset_cpu(0);
+}
+
+static struct image_handler barebox_handler = {
+	.name = "MIPS barebox",
+	.bootm = do_bootm_barebox,
+	.filetype = filetype_mips_barebox,
+};
+
+static struct binfmt_hook binfmt_barebox_hook = {
+	.type = filetype_mips_barebox,
+	.exec = "bootm",
+};
+
+static int mips_register_image_handler(void)
+{
+	register_image_handler(&barebox_handler);
+	binfmt_register(&binfmt_barebox_hook);
+
+	return 0;
+}
+late_initcall(mips_register_image_handler);
diff --git a/common/filetype.c b/common/filetype.c
index 15a3732..04d666c 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -78,6 +78,8 @@ enum filetype file_detect_type(void *_buf)
 		return filetype_oftree;
 	if (strncmp(buf8, "ANDROID!", 8) == 0)
 		return filetype_aimage;
+	if (strncmp(buf8 + 8, "barebox", 8) == 0)
+		return filetype_mips_barebox;
 
 	return filetype_unknown;
 }
diff --git a/include/filetype.h b/include/filetype.h
index 9338793..f5de8ed 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -17,6 +17,7 @@ enum filetype {
 	filetype_oftree,
 	filetype_aimage,
 	filetype_sh,
+	filetype_mips_barebox,
 };
 
 const char *file_type_to_string(enum filetype f);
-- 
1.7.10


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

  reply	other threads:[~2012-04-28 13:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-28 13:52 [RFC 1/2] MIPS: start.S: add "barebox" label at _start + 8 Antony Pavlov
2012-04-28 13:52 ` Antony Pavlov [this message]
2012-04-28 16:04 ` Antony Pavlov
2012-04-30 11:51   ` Jean-Christophe PLAGNIOL-VILLARD

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=1335621130-935-2-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