mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* ARM: cleanup boot commands
@ 2011-04-04 14:31 Sascha Hauer
  2011-04-04 14:31 ` [PATCH 1/5] ARM: Add missing parameter name in armlinux_set_serial Sascha Hauer
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-04 14:31 UTC (permalink / raw)
  To: barebox

The arm linux start code has some common code which can be shared between
functions. Also, the different boot commands are seperated to different
files to easily compile support for them without ifdefs.

Sascha Hauer (5):
      ARM: Add missing parameter name in armlinux_set_serial
      ARM: factor out a start_linux function
      ARM: move bootm code to its own file
      ARM: move bootz code to its own file
      ARM: move bootu code to its own file

 arch/arm/Kconfig                |    5 +
 arch/arm/include/asm/armlinux.h |    6 +-
 arch/arm/lib/Makefile           |    5 +-
 arch/arm/lib/armlinux.c         |  215 +--------------------------------------
 arch/arm/lib/bootm.c            |   92 +++++++++++++++++
 arch/arm/lib/bootu.c            |   38 +++++++
 arch/arm/lib/bootz.c            |  100 ++++++++++++++++++
 7 files changed, 248 insertions(+), 213 deletions(-)
 create mode 100644 arch/arm/lib/bootm.c
 create mode 100644 arch/arm/lib/bootu.c
 create mode 100644 arch/arm/lib/bootz.c

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] ARM: Add missing parameter name in armlinux_set_serial
  2011-04-04 14:31 ARM: cleanup boot commands Sascha Hauer
@ 2011-04-04 14:31 ` Sascha Hauer
  2011-04-04 14:31 ` [PATCH 2/5] ARM: factor out a start_linux function Sascha Hauer
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-04 14:31 UTC (permalink / raw)
  To: barebox

Also, make it a static inline function if compiled without
arm linux support.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/include/asm/armlinux.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/include/asm/armlinux.h b/arch/arm/include/asm/armlinux.h
index ce74cfc..0d9d4e9 100644
--- a/arch/arm/include/asm/armlinux.h
+++ b/arch/arm/include/asm/armlinux.h
@@ -25,7 +25,7 @@ static inline void armlinux_set_revision(unsigned int rev)
 {
 }
 
-void armlinux_set_serial(u64)
+static inline void armlinux_set_serial(u64 serial)
 {
 }
 #endif
-- 
1.7.2.3


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/5] ARM: factor out a start_linux function
  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
  2011-04-04 14:31 ` [PATCH 3/5] ARM: move bootm code to its own file Sascha Hauer
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-04 14:31 UTC (permalink / raw)
  To: barebox

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/5] ARM: move bootm code to its own file
  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
  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
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-04 14:31 UTC (permalink / raw)
  To: barebox

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/5] ARM: move bootz code to its own file
  2011-04-04 14:31 ARM: cleanup boot commands Sascha Hauer
                   ` (2 preceding siblings ...)
  2011-04-04 14:31 ` [PATCH 3/5] ARM: move bootm code to its own file Sascha Hauer
@ 2011-04-04 14:31 ` Sascha Hauer
  2011-04-04 14:31 ` [PATCH 5/5] ARM: move bootu " Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-04 14:31 UTC (permalink / raw)
  To: barebox

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

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index bb1c202..8165aea 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -1,5 +1,6 @@
 obj-$(CONFIG_ARM_LINUX)	+= armlinux.o
 obj-$(CONFIG_CMD_BOOTM)	+= bootm.o
+obj-$(CONFIG_CMD_BOOTZ)	+= bootz.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 a37f710..bb4bcd3 100644
--- a/arch/arm/lib/armlinux.c
+++ b/arch/arm/lib/armlinux.c
@@ -232,101 +232,6 @@ void start_linux(void *adr, int swap, struct image_data *data)
 	kernel(0, armlinux_architecture, armlinux_bootparams);
 }
 
-#ifdef CONFIG_CMD_BOOTZ
-struct zimage_header {
-	u32	unused[9];
-	u32	magic;
-	u32	start;
-	u32	end;
-};
-
-#define ZIMAGE_MAGIC 0x016F2818
-
-static int do_bootz(struct command *cmdtp, int argc, char *argv[])
-{
-	void (*theKernel)(int zero, int arch, void *params);
-	int fd, ret, swap = 0;
-	struct zimage_header header;
-	void *zimage;
-	u32 end;
-
-	if (argc != 2) {
-		barebox_cmd_usage(cmdtp);
-		return 1;
-	}
-
-	fd = open(argv[1], O_RDONLY);
-	if (fd < 0) {
-		perror("open");
-		return 1;
-	}
-
-	ret = read(fd, &header, sizeof(header));
-	if (ret < sizeof(header)) {
-		printf("could not read %s\n", argv[1]);
-		goto err_out;
-	}
-
-	switch (header.magic) {
-#ifdef CONFIG_BOOT_ENDIANNESS_SWITCH
-	case swab32(ZIMAGE_MAGIC):
-		swap = 1;
-		/* fall through */
-#endif
-	case ZIMAGE_MAGIC:
-		break;
-	default:
-		printf("invalid magic 0x%08x\n", header.magic);
-		goto err_out;
-	}
-
-	end = header.end;
-
-	if (swap)
-		end = swab32(end);
-
-	zimage = xmalloc(end);
-	memcpy(zimage, &header, sizeof(header));
-
-	ret = read(fd, zimage + sizeof(header), end - sizeof(header));
-	if (ret < end - sizeof(header)) {
-		printf("could not read %s\n", argv[1]);
-		goto err_out1;
-	}
-
-	if (swap) {
-		void *ptr;
-		for (ptr = zimage; ptr < zimage + end; ptr += 4)
-			*(u32 *)ptr = swab32(*(u32 *)ptr);
-	}
-
-	theKernel = zimage;
-
-	printf("loaded zImage from %s with size %d\n", argv[1], end);
-
-	start_linux(theKernel, swap, NULL);
-
-	return 0;
-
-err_out1:
-	free(zimage);
-err_out:
-	close(fd);
-
-	return 1;
-}
-
-static const __maybe_unused char cmd_bootz_help[] =
-"Usage: bootz [FILE]\n"
-"Boot a Linux zImage\n";
-
-BAREBOX_CMD_START(bootz)
-	.cmd            = do_bootz,
-	.usage          = "bootz - start a zImage",
-	BAREBOX_CMD_HELP(cmd_bootz_help)
-BAREBOX_CMD_END
-#endif /* CONFIG_CMD_BOOTZ */
-
 #ifdef CONFIG_CMD_BOOTU
 static int do_bootu(struct command *cmdtp, int argc, char *argv[])
 {
diff --git a/arch/arm/lib/bootz.c b/arch/arm/lib/bootz.c
new file mode 100644
index 0000000..cd8f495
--- /dev/null
+++ b/arch/arm/lib/bootz.c
@@ -0,0 +1,100 @@
+#include <common.h>
+#include <command.h>
+#include <fs.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <malloc.h>
+#include <asm/byteorder.h>
+#include <asm/armlinux.h>
+#include <asm/system.h>
+
+struct zimage_header {
+	u32	unused[9];
+	u32	magic;
+	u32	start;
+	u32	end;
+};
+
+#define ZIMAGE_MAGIC 0x016F2818
+
+static int do_bootz(struct command *cmdtp, int argc, char *argv[])
+{
+	int fd, ret, swap = 0;
+	struct zimage_header header;
+	void *zimage;
+	u32 end;
+
+	if (argc != 2) {
+		barebox_cmd_usage(cmdtp);
+		return 1;
+	}
+
+	fd = open(argv[1], O_RDONLY);
+	if (fd < 0) {
+		perror("open");
+		return 1;
+	}
+
+	ret = read(fd, &header, sizeof(header));
+	if (ret < sizeof(header)) {
+		printf("could not read %s\n", argv[1]);
+		goto err_out;
+	}
+
+	switch (header.magic) {
+#ifdef CONFIG_BOOT_ENDIANNESS_SWITCH
+	case swab32(ZIMAGE_MAGIC):
+		swap = 1;
+		/* fall through */
+#endif
+	case ZIMAGE_MAGIC:
+		break;
+	default:
+		printf("invalid magic 0x%08x\n", header.magic);
+		goto err_out;
+	}
+
+	end = header.end;
+
+	if (swap)
+		end = swab32(end);
+
+	zimage = xmalloc(end);
+	memcpy(zimage, &header, sizeof(header));
+
+	ret = read(fd, zimage + sizeof(header), end - sizeof(header));
+	if (ret < end - sizeof(header)) {
+		printf("could not read %s\n", argv[1]);
+		goto err_out1;
+	}
+
+	if (swap) {
+		void *ptr;
+		for (ptr = zimage; ptr < zimage + end; ptr += 4)
+			*(u32 *)ptr = swab32(*(u32 *)ptr);
+	}
+
+	printf("loaded zImage from %s with size %d\n", argv[1], end);
+
+	start_linux(zimage, swap, NULL);
+
+	return 0;
+
+err_out1:
+	free(zimage);
+err_out:
+	close(fd);
+
+	return 1;
+}
+
+static const __maybe_unused char cmd_bootz_help[] =
+"Usage: bootz [FILE]\n"
+"Boot a Linux zImage\n";
+
+BAREBOX_CMD_START(bootz)
+	.cmd            = do_bootz,
+	.usage          = "bootz - start a zImage",
+	BAREBOX_CMD_HELP(cmd_bootz_help)
+BAREBOX_CMD_END
+
-- 
1.7.2.3


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 5/5] ARM: move bootu code to its own file
  2011-04-04 14:31 ARM: cleanup boot commands Sascha Hauer
                   ` (3 preceding siblings ...)
  2011-04-04 14:31 ` [PATCH 4/5] ARM: move bootz " Sascha Hauer
@ 2011-04-04 14:31 ` Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-04 14:31 UTC (permalink / raw)
  To: barebox

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

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 8165aea..9383ae1 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -1,6 +1,7 @@
 obj-$(CONFIG_ARM_LINUX)	+= armlinux.o
 obj-$(CONFIG_CMD_BOOTM)	+= bootm.o
 obj-$(CONFIG_CMD_BOOTZ)	+= bootz.o
+obj-$(CONFIG_CMD_BOOTU)	+= bootu.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 bb4bcd3..ce1cc6b 100644
--- a/arch/arm/lib/armlinux.c
+++ b/arch/arm/lib/armlinux.c
@@ -231,36 +231,3 @@ void start_linux(void *adr, int swap, struct image_data *data)
 
 	kernel(0, armlinux_architecture, armlinux_bootparams);
 }
-
-#ifdef CONFIG_CMD_BOOTU
-static int do_bootu(struct command *cmdtp, int argc, char *argv[])
-{
-	void (*theKernel)(int zero, int arch, void *params) = NULL;
-	int fd;
-
-	if (argc != 2) {
-		barebox_cmd_usage(cmdtp);
-		return 1;
-	}
-
-	fd = open(argv[1], O_RDONLY);
-	if (fd > 0)
-		theKernel = (void *)memmap(fd, PROT_READ);
-
-	if (!theKernel)
-		theKernel = (void *)simple_strtoul(argv[1], NULL, 0);
-
-	start_linux(theKernel, 0, NULL);
-
-	return 1;
-}
-
-static const __maybe_unused char cmd_bootu_help[] =
-"Usage: bootu <address>\n";
-
-BAREBOX_CMD_START(bootu)
-	.cmd            = do_bootu,
-	.usage          = "bootu - start a raw linux image",
-	BAREBOX_CMD_HELP(cmd_bootu_help)
-BAREBOX_CMD_END
-#endif /* CONFIG_CMD_BOOTU */
diff --git a/arch/arm/lib/bootu.c b/arch/arm/lib/bootu.c
new file mode 100644
index 0000000..e97ded0
--- /dev/null
+++ b/arch/arm/lib/bootu.c
@@ -0,0 +1,38 @@
+#include <common.h>
+#include <command.h>
+#include <fs.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <asm/armlinux.h>
+
+static int do_bootu(struct command *cmdtp, int argc, char *argv[])
+{
+	int fd;
+	void *kernel = NULL;
+
+	if (argc != 2) {
+		barebox_cmd_usage(cmdtp);
+		return 1;
+	}
+
+	fd = open(argv[1], O_RDONLY);
+	if (fd > 0)
+		kernel = (void *)memmap(fd, PROT_READ);
+
+	if (!kernel)
+		kernel = (void *)simple_strtoul(argv[1], NULL, 0);
+
+	start_linux(kernel, 0, NULL);
+
+	return 1;
+}
+
+static const __maybe_unused char cmd_bootu_help[] =
+"Usage: bootu <address>\n";
+
+BAREBOX_CMD_START(bootu)
+	.cmd            = do_bootu,
+	.usage          = "bootu - start a raw linux image",
+	BAREBOX_CMD_HELP(cmd_bootu_help)
+BAREBOX_CMD_END
+
-- 
1.7.2.3


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-04-04 14:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox