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 2/5] ARM: factor out a start_linux function
Date: Mon,  4 Apr 2011 16:31:02 +0200	[thread overview]
Message-ID: <1301927465-23717-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1301927465-23717-1-git-send-email-s.hauer@pengutronix.de>

This can be shared between the different boot commands.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/Kconfig                |    5 +++++
 arch/arm/include/asm/armlinux.h |    4 ++++
 arch/arm/lib/Makefile           |    2 +-
 arch/arm/lib/armlinux.c         |   39 ++++++++++++++++++++-------------------
 4 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index aae0e99..4392620 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -21,6 +21,11 @@ config ARM
 config ARM_AMBA
 	bool
 
+config ARM_LINUX
+	bool
+	default y
+	depends on CMD_BOOTZ || CMD_BOOTU || CMD_BOOTM
+
 menu "System Type"
 
 choice
diff --git a/arch/arm/include/asm/armlinux.h b/arch/arm/include/asm/armlinux.h
index 0d9d4e9..3cab209 100644
--- a/arch/arm/include/asm/armlinux.h
+++ b/arch/arm/include/asm/armlinux.h
@@ -30,4 +30,8 @@ static inline void armlinux_set_serial(u64 serial)
 }
 #endif
 
+struct image_data;
+
+void start_linux(void *adr, int swap, struct image_data *data);
+
 #endif /* __ARCH_ARMLINUX_H */
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 3a01083..899c391 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -1,4 +1,4 @@
-obj-y	+= armlinux.o
+obj-$(CONFIG_ARM_LINUX)	+= armlinux.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 9927b76..15b92f9 100644
--- a/arch/arm/lib/armlinux.c
+++ b/arch/arm/lib/armlinux.c
@@ -215,6 +215,23 @@ void armlinux_set_serial(u64 serial)
 	system_serial = serial;
 }
 
+void start_linux(void *adr, int swap, struct image_data *data)
+{
+	void (*kernel)(int zero, int arch, void *params) = adr;
+
+	setup_tags(data, swap);
+
+	shutdown_barebox();
+	if (swap) {
+		u32 reg;
+		__asm__ __volatile__("mrc p15, 0, %0, c1, c0" : "=r" (reg));
+		reg ^= CR_B; /* swap big-endian flag */
+		__asm__ __volatile__("mcr p15, 0, %0, c1, c0" :: "r" (reg));
+	}
+
+	kernel(0, armlinux_architecture, armlinux_bootparams);
+}
+
 #ifdef CONFIG_CMD_BOOTM
 static int do_bootm_linux(struct image_data *data)
 {
@@ -241,8 +258,6 @@ static int do_bootm_linux(struct image_data *data)
 	debug("## Transferring control to Linux (at address 0x%p) ...\n",
 	       theKernel);
 
-	setup_tags(data, 0);
-
 	if (relocate_image(data->os, (void *)image_get_load(os_header)))
 		return -1;
 
@@ -253,8 +268,7 @@ static int do_bootm_linux(struct image_data *data)
 	/* we assume that the kernel is in place */
 	printf("\nStarting kernel %s...\n\n", data->initrd ? "with initrd " : "");
 
-	shutdown_barebox();
-	theKernel (0, armlinux_architecture, armlinux_bootparams);
+	start_linux(theKernel, 0, data);
 
 	return -1;
 }
@@ -370,17 +384,7 @@ static int do_bootz(struct command *cmdtp, int argc, char *argv[])
 
 	printf("loaded zImage from %s with size %d\n", argv[1], end);
 
-	setup_tags(NULL, swap);
-
-	shutdown_barebox();
-	if (swap) {
-		u32 reg;
-		__asm__ __volatile__("mrc p15, 0, %0, c1, c0" : "=r" (reg));
-		reg ^= CR_B; /* swap big-endian flag */
-		__asm__ __volatile__("mcr p15, 0, %0, c1, c0" :: "r" (reg));
-	}
-
-	theKernel(0, armlinux_architecture, armlinux_bootparams);
+	start_linux(theKernel, swap, NULL);
 
 	return 0;
 
@@ -421,10 +425,7 @@ static int do_bootu(struct command *cmdtp, int argc, char *argv[])
 	if (!theKernel)
 		theKernel = (void *)simple_strtoul(argv[1], NULL, 0);
 
-	setup_tags(NULL, 0);
-
-	shutdown_barebox();
-	theKernel(0, armlinux_architecture, armlinux_bootparams);
+	start_linux(theKernel, 0, NULL);
 
 	return 1;
 }
-- 
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 ` Sascha Hauer [this message]
2011-04-04 14:31 ` [PATCH 3/5] ARM: move bootm code to its own file Sascha Hauer
2011-04-04 14:31 ` [PATCH 4/5] ARM: move bootz " 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-3-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