mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/5] ARM: move bootm code to its own file
Date: Mon,  4 Apr 2011 16:31:03 +0200	[thread overview]
Message-ID: <1301927465-23717-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1301927465-23717-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/lib/Makefile   |    1 +
 arch/arm/lib/armlinux.c |   80 ----------------------------------------
 arch/arm/lib/bootm.c    |   92 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+), 80 deletions(-)
 create mode 100644 arch/arm/lib/bootm.c

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 899c391..bb1c202 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_ARM_LINUX)	+= armlinux.o
+obj-$(CONFIG_CMD_BOOTM)	+= bootm.o
 obj-y	+= div0.o
 obj-y	+= findbit.o
 obj-y	+= arm.o
diff --git a/arch/arm/lib/armlinux.c b/arch/arm/lib/armlinux.c
index 15b92f9..a37f710 100644
--- a/arch/arm/lib/armlinux.c
+++ b/arch/arm/lib/armlinux.c
@@ -232,86 +232,6 @@ void start_linux(void *adr, int swap, struct image_data *data)
 	kernel(0, armlinux_architecture, armlinux_bootparams);
 }
 
-#ifdef CONFIG_CMD_BOOTM
-static int do_bootm_linux(struct image_data *data)
-{
-	void (*theKernel)(int zero, int arch, void *params);
-	image_header_t *os_header = &data->os->header;
-
-	if (image_get_type(os_header) == IH_TYPE_MULTI) {
-		printf("Multifile images not handled at the moment\n");
-		return -1;
-	}
-
-	if (armlinux_architecture == 0) {
-		printf("arm architecture not set. Please specify with -a option\n");
-		return -1;
-	}
-
-	if (!armlinux_bootparams) {
-		printf("Bootparams not set. Please fix your board code\n");
-		return -1;
-	}
-
-	theKernel = (void *)image_get_ep(os_header);
-
-	debug("## Transferring control to Linux (at address 0x%p) ...\n",
-	       theKernel);
-
-	if (relocate_image(data->os, (void *)image_get_load(os_header)))
-		return -1;
-
-	if (data->initrd)
-		if (relocate_image(data->initrd, (void *)image_get_load(&data->initrd->header)))
-			return -1;
-
-	/* we assume that the kernel is in place */
-	printf("\nStarting kernel %s...\n\n", data->initrd ? "with initrd " : "");
-
-	start_linux(theKernel, 0, data);
-
-	return -1;
-}
-
-static int image_handle_cmdline_parse(struct image_data *data, int opt,
-		char *optarg)
-{
-	int ret = 1;
-
-	switch (opt) {
-	case 'a':
-		armlinux_architecture = simple_strtoul(optarg, NULL, 0);
-		ret = 0;
-		break;
-	case 'R':
-		system_rev = simple_strtoul(optarg, NULL, 0);
-		ret = 0;
-		break;
-	default:
-		break;
-	}
-
-	return ret;
-}
-
-static struct image_handler handler = {
-	.cmdline_options = "a:R:",
-	.cmdline_parse = image_handle_cmdline_parse,
-	.help_string = " -a <arch>        use architecture number <arch>\n"
-		       " -R <system_rev>  use system revison <system_rev>\n",
-
-	.bootm = do_bootm_linux,
-	.image_type = IH_OS_LINUX,
-};
-
-static int armlinux_register_image_handler(void)
-{
-	return register_image_handler(&handler);
-}
-
-late_initcall(armlinux_register_image_handler);
-#endif /* CONFIG_CMD_BOOTM */
-
 #ifdef CONFIG_CMD_BOOTZ
 struct zimage_header {
 	u32	unused[9];
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
new file mode 100644
index 0000000..b09fe70
--- /dev/null
+++ b/arch/arm/lib/bootm.c
@@ -0,0 +1,92 @@
+#include <boot.h>
+#include <common.h>
+#include <command.h>
+#include <driver.h>
+#include <environment.h>
+#include <image.h>
+#include <zlib.h>
+#include <init.h>
+#include <fs.h>
+#include <linux/list.h>
+#include <xfuncs.h>
+#include <malloc.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include <asm/byteorder.h>
+#include <asm/global_data.h>
+#include <asm/setup.h>
+#include <asm/barebox-arm.h>
+#include <asm/armlinux.h>
+#include <asm/system.h>
+
+static int do_bootm_linux(struct image_data *data)
+{
+	void (*theKernel)(int zero, int arch, void *params);
+	image_header_t *os_header = &data->os->header;
+
+	if (image_get_type(os_header) == IH_TYPE_MULTI) {
+		printf("Multifile images not handled at the moment\n");
+		return -1;
+	}
+
+	theKernel = (void *)image_get_ep(os_header);
+
+	debug("## Transferring control to Linux (at address 0x%p) ...\n",
+	       theKernel);
+
+	if (relocate_image(data->os, (void *)image_get_load(os_header)))
+		return -1;
+
+	if (data->initrd)
+		if (relocate_image(data->initrd, (void *)image_get_load(&data->initrd->header)))
+			return -1;
+
+	/* we assume that the kernel is in place */
+	printf("\nStarting kernel %s...\n\n", data->initrd ? "with initrd " : "");
+
+	start_linux(theKernel, 0, data);
+
+	return -1;
+}
+
+static int image_handle_cmdline_parse(struct image_data *data, int opt,
+		char *optarg)
+{
+	int ret = 1;
+	int no;
+
+	switch (opt) {
+	case 'a':
+		no = simple_strtoul(optarg, NULL, 0);
+		armlinux_set_architecture(no);
+		ret = 0;
+		break;
+	case 'R':
+		no = simple_strtoul(optarg, NULL, 0);
+		armlinux_set_revision(no);
+		ret = 0;
+		break;
+	default:
+		break;
+	}
+
+	return ret;
+}
+
+static struct image_handler handler = {
+	.cmdline_options = "a:R:",
+	.cmdline_parse = image_handle_cmdline_parse,
+	.help_string = " -a <arch>        use architecture number <arch>\n"
+		       " -R <system_rev>  use system revison <system_rev>\n",
+
+	.bootm = do_bootm_linux,
+	.image_type = IH_OS_LINUX,
+};
+
+static int armlinux_register_image_handler(void)
+{
+	return register_image_handler(&handler);
+}
+
+late_initcall(armlinux_register_image_handler);
-- 
1.7.2.3


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

  parent reply	other threads:[~2011-04-04 14:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-04 14:31 ARM: cleanup boot commands Sascha Hauer
2011-04-04 14:31 ` [PATCH 1/5] ARM: Add missing parameter name in armlinux_set_serial Sascha Hauer
2011-04-04 14:31 ` [PATCH 2/5] ARM: factor out a start_linux function Sascha Hauer
2011-04-04 14:31 ` Sascha Hauer [this message]
2011-04-04 14:31 ` [PATCH 4/5] ARM: move bootz code to its own file Sascha Hauer
2011-04-04 14:31 ` [PATCH 5/5] ARM: move bootu " 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=1301927465-23717-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@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