summaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorAntony Pavlov <antonynpavlov@gmail.com>2012-05-10 13:35:12 +0400
committerSascha Hauer <s.hauer@pengutronix.de>2012-05-11 09:05:11 +0200
commit87b302f4e2411749241fb4d13b6f1583ebbfd88a (patch)
treed6b98c57a4db5aa15f610c76f89d23cea242fa52 /arch/mips
parent2a9d94a81e8d24b519848897a68eb66a5e53fa6f (diff)
downloadbarebox-87b302f4e2411749241fb4d13b6f1583ebbfd88a.tar.gz
barebox-87b302f4e2411749241fb4d13b6f1583ebbfd88a.tar.xz
MIPS: bootm: add "MIPS barebox" handler
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/lib/Makefile1
-rw-r--r--arch/mips/lib/bootm.c43
2 files changed, 44 insertions, 0 deletions
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index 45fe920c44..85aa19418d 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 0000000000..3d6a4ce648
--- /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);