Skip to contentSkip to conversation

cmdbootz

PATCH New Robert Schwebel 3 participants 4 messages May 13, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmdbootz

[Note: command number assumes that the cmdximg patch was added before, please re-adapt otherwhise]

ChageLog:

* Patch by Holger Schurig, Robert Schwebel, 13 May 2004:
Add a 'bootz' command to boot normal Linux zImages in case you don't need the features of U-Boot's uImage.

Robert

Signature · 176 lines
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hornemannstra?e 12,  31137 Hildesheim, Germany
    Phone: +49-5121-28619-0 |  Fax: +49-5121-28619-4
-------------- next part --------------
# 
# Author:	Robert Schwebel <[email protected]>
# 
# Description:	Changelog Entry:
#
#		* Patch by Holger Schurig, Robert Schwebel, 13 May 2004:
#		  Add a 'bootz' command to boot normal Linux zImages in
#		  case you don't need the features of U-Boot's uImage. 
#
# State:	2004-05-13: submit
#

#
# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
#

--- /dev/null	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-maintainance1/include/cmd_bootz.h	2004-05-13 08:35:03.000000000 +0200
@@ -0,0 +1,38 @@
+/*
+ * (C) Copyright 2003
+ * Holger Schurig, M&N Logistik-Loesungen Online GmbH, <h.schurig@mn...>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Linux zImage Boot support
+ */
+#ifndef       _CMD_BOOTZ_H
+#define       _CMD_BOOTZ_H
+int do_bootz(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]);
+
+#define       CMD_TBL_BOOTZ   MK_CMD_TBL_ENTRY(				\
+      "bootz",        5,      CFG_MAXARGS,    1,      do_bootz,               \
+      "bootz   - boot Linux zImage from memory\n",                            \
+      "[addr [arg ...]]\n    - boot zImage stored in memory\n"                \
+      "        passing arguments 'arg ...'\n"                                 \
+),
+
+#endif				/* _CMD_BOOTZ_H */
--- u-boot-maintainance1/include/cmd_confdefs.h~cmdbootz	2004-05-13 08:31:20.000000000 +0200
+++ u-boot-maintainance1/include/cmd_confdefs.h	2004-05-13 08:33:54.000000000 +0200
@@ -90,6 +90,7 @@
 #define CFG_CMD_REISER  0x0100000000000000U     /* Reiserfs support		*/
 #define CFG_CMD_CDP	0x0200000000000000U	/* Cisco Discovery Protocol 	*/
 #define CFG_CMD_XIMG	0x0400000000000000U	/* Load part of Multi Image     */
+#define CFG_CMD_BOOTZ	0x0800000000000000U	/* directly boot Linux zImage   */
 
 #define CFG_CMD_ALL	0xFFFFFFFFFFFFFFFFU	/* ALL commands			*/
 
--- /dev/null	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-maintainance1/common/cmd_bootz.c	2004-05-13 08:34:29.000000000 +0200
@@ -0,0 +1,100 @@
+/*
+ * (C) Copyright 2003
+ * Holger Schurig, M&N Logistik-Loesungen Online GmbH, <h.schurig@mn...>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Linux zImage boot support
+ */
+#include <common.h>
+#include <command.h>
+#include <tag.h>
+#include <asm/byteorder.h>
+
+#define DEBUG
+
+#ifdef CONFIG_SHOW_BOOT_PROGRESS
+# include <status_led.h>
+# define SHOW_BOOT_PROGRESS(arg)        show_boot_progress(arg)
+#else
+# define SHOW_BOOT_PROGRESS(arg)
+#endif
+
+#define CONFIG_KERNEL_RAM_BASE 0x40000
+
+int
+do_bootz(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+	ulong addr = 0x40000;
+	ulong initrd_start = 0;
+	ulong initrd_end = 0;
+	ulong data;
+	void (*theKernel) (int zero, int arch, struct tag * params);
+	bd_t *bd = gd->bd;
+#ifdef CONFIG_CMDLINE_TAG
+	char *commandline = getenv("bootargs");
+#endif
+	addr = simple_strtoul(argv[1], NULL, 16);
+
+	theKernel = (void (*)(int, int, struct tag *)) addr;
+
+	SHOW_BOOT_PROGRESS(14);
+
+#ifdef DEBUG
+	printf("## Transferring control to Linux (at address %08lx) ...\n",
+	       (ulong) theKernel);
+#endif
+
+#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
+    defined (CONFIG_CMDLINE_TAG) || \
+    defined (CONFIG_INITRD_TAG) || \
+    defined (CONFIG_VFD)
+	setup_start_tag(bd);
+#ifdef CONFIG_SETUP_MEMORY_TAGS
+	setup_memory_tags(bd);
+#endif
+#ifdef CONFIG_CMDLINE_TAG
+	setup_commandline_tag(bd, commandline);
+#endif
+#ifdef CONFIG_INITRD_TAG
+	setup_initrd_tag(bd, initrd_start, initrd_end);
+#endif
+#if 0
+	setup_ramdisk_tag(bd);
+#endif
+#if defined (CONFIG_VFD)
+	setup_videolfb_tag(gd);
+#endif
+	setup_end_tag(bd);
+#endif
+
+	/* we assume that the kernel is in place */
+	printf("\nStarting kernel ...\n\n");
+
+	cleanup_before_linux();
+
+	theKernel(0, bd->bi_arch_number, params);
+
+	printf("ERROR: we should never come to this place ...\n\n");
+	return 0;
+}
#1 lore raw

PATCH 1/1 cmdbootz

Quoted 4 lines · In message <[email protected]> you wrote:

* Patch by Holger Schurig, Robert Schwebel, 13 May 2004:
Add a 'bootz' command to boot normal Linux zImages in case you don't need the features of U-Boot's uImage.

I reject this patch.

The newly added code is not added to any Makefile, so it does not get compiled at all.

If you add it, you will see that it is highly unportable; for example on a PowerPC system you get:

cmd_bootz.c:29:17: tag.h: No such file or directory

Most of the code seems to be for ARM only (functions like
setup_*_tag() don't exist for PowerPC or MIPS or ...).

Please make this code usable for other architectures as well and resubmit.

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
In accord with UNIX philosophy, Perl gives you enough  rope  to  hang
yourself.              - L. Wall & R. L. Schwartz, _Programming Perl_
#2 lore raw

PATCH 1/1 cmdbootz

Quoted 2 lines · Wolfgang Denk

Please make this code usable for other architectures as well and resubmit.

I've attached a version that tries to encapsulate the ARM specific stuff into CONFIG_ARM ifdefs; as I don't have any PowerPC toolchains here, could somebody with access to one and better knowledge about PPC kernel start mechanisms have a look at how things had to be done there?

Robert

Signature · 271 lines
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hornemannstra?e 12,  31137 Hildesheim, Germany
    Phone: +49-5121-28619-0 |  Fax: +49-5121-28619-4
-------------- next part --------------
# 
# Author:	Robert Schwebel <[email protected]>
# 
# Description:	Changelog Entry:
#
#		* Patch by Holger Schurig, Robert Schwebel, 13 May 2004:
#		  Add a 'bootz' command to boot normal Linux zImages in
#		  case you don't need the features of U-Boot's uImage. 
#
# State:	2004-05-13: submitted
#		
#		2004-05-13: 
#
#		WD: "The newly added code is not added to any Makefile, 
#		so it does not get compiled at all. If you add it, you 
#		will see that it is highly unportable; for example on 
#		a PowerPC system you get: cmd_bootz.c:29:17: tag.h: 
#		No such file or directory. Most of the code seems to be for
#		ARM only (functions like setup_*_tag() don't exist for 
#		PowerPC or MIPS or ...). Please make this code usable for 
#		other architectures as well and resubmit."
#

#
# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
#

--- /dev/null	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-maintainance1/include/cmd_bootz.h	2004-05-13 19:05:42.000000000 +0200
@@ -0,0 +1,38 @@
+/*
+ * (C) Copyright 2003
+ * Holger Schurig, M&N Logistik-Loesungen Online GmbH, <h.schurig@mn...>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Linux zImage Boot support
+ */
+#ifndef       _CMD_BOOTZ_H
+#define       _CMD_BOOTZ_H
+int do_bootz(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]);
+
+#define       CMD_TBL_BOOTZ   MK_CMD_TBL_ENTRY(				\
+      "bootz",        5,      CFG_MAXARGS,    1,      do_bootz,               \
+      "bootz   - boot Linux zImage from memory\n",                            \
+      "[addr [arg ...]]\n    - boot zImage stored in memory\n"                \
+      "        passing arguments 'arg ...'\n"                                 \
+),
+
+#endif				/* _CMD_BOOTZ_H */
--- u-boot-maintainance1/include/cmd_confdefs.h~cmdbootz	2004-05-13 19:05:33.000000000 +0200
+++ u-boot-maintainance1/include/cmd_confdefs.h	2004-05-13 19:05:42.000000000 +0200
@@ -90,6 +90,7 @@
 #define CFG_CMD_REISER  0x0100000000000000U     /* Reiserfs support		*/
 #define CFG_CMD_CDP	0x0200000000000000U	/* Cisco Discovery Protocol 	*/
 #define CFG_CMD_XIMG	0x0400000000000000U	/* Load part of Multi Image     */
+#define CFG_CMD_BOOTZ	0x0800000000000000U	/* directly boot Linux zImage   */
 
 #define CFG_CMD_ALL	0xFFFFFFFFFFFFFFFFU	/* ALL commands			*/
 
--- /dev/null	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-maintainance1/common/cmd_bootz.c	2004-05-13 19:07:14.000000000 +0200
@@ -0,0 +1,109 @@
+/*
+ * (C) Copyright 2003
+ * Holger Schurig, M&N Logistik-Loesungen Online GmbH, <h.schurig@mn...>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Linux zImage boot support
+ */
+#include <common.h>
+#include <command.h>
+#include <asm/byteorder.h>
+
+#ifdef CONFIG_ARM
+#include <tag.h>
+#endif
+
+#define DEBUG
+
+#ifdef CONFIG_SHOW_BOOT_PROGRESS
+# include <status_led.h>
+# define SHOW_BOOT_PROGRESS(arg)        show_boot_progress(arg)
+#else
+# define SHOW_BOOT_PROGRESS(arg)
+#endif
+
+#define CONFIG_KERNEL_RAM_BASE 0x40000
+
+int
+do_bootz(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+	ulong addr = 0x40000;
+	ulong initrd_start = 0;
+	ulong initrd_end = 0;
+	ulong data;
+	bd_t *bd = gd->bd;
+#if defined (CONFIG_ARM) && defined (CONFIG_CMDLINE_TAG)
+	char *commandline = getenv("bootargs");
+	void (*theKernel) (int zero, int arch, struct tag * params);
+#else
+	void (*theKernel) (void);
+#endif
+	addr = simple_strtoul(argv[1], NULL, 16);
+
+	theKernel = (void (*)(int, int, struct tag *)) addr;
+
+	SHOW_BOOT_PROGRESS(14);
+
+#ifdef DEBUG
+	printf("## Transferring control to Linux (at address %08lx) ...\n",
+	       (ulong) theKernel);
+#endif
+
+#ifdef CONFIG_ARM
+#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
+    defined (CONFIG_CMDLINE_TAG) || \
+    defined (CONFIG_INITRD_TAG) || \
+    defined (CONFIG_VFD)
+	setup_start_tag(bd);
+#ifdef CONFIG_SETUP_MEMORY_TAGS
+	setup_memory_tags(bd);
+#endif
+#ifdef CONFIG_CMDLINE_TAG
+	setup_commandline_tag(bd, commandline);
+#endif
+#ifdef CONFIG_INITRD_TAG
+	setup_initrd_tag(bd, initrd_start, initrd_end);
+#endif
+#if 0
+	setup_ramdisk_tag(bd);
+#endif
+#if defined (CONFIG_VFD)
+	setup_videolfb_tag(gd);
+#endif
+	setup_end_tag(bd);
+#endif
+#endif /* CONFIG_ARM */
+
+	/* we assume that the kernel is in place */
+	printf("\nStarting kernel ...\n\n");
+	cleanup_before_linux();
+#if defined (CONFIG_ARM)
+	theKernel(0, bd->bi_arch_number, params);
+#else
+	theKernel();
+#endif
+	printf("ERROR: we should never come to this place ...\n\n");
+	
+	return 0;
+}
--- u-boot-maintainance1/common/Makefile~cmdbootz	2004-05-13 19:05:33.000000000 +0200
+++ u-boot-maintainance1/common/Makefile	2004-05-13 19:05:42.000000000 +0200
@@ -29,7 +29,7 @@
 
 COBJS	= main.o ACEX1K.o altera.o bedbug.o \
 	  cmd_ace.o cmd_autoscript.o \
-	  cmd_bdinfo.o cmd_bedbug.o cmd_bmp.o cmd_boot.o cmd_bootm.o \
+	  cmd_bdinfo.o cmd_bedbug.o cmd_bmp.o cmd_boot.o cmd_bootm.o cmd_bootz.o \
 	  cmd_cache.o cmd_console.o \
 	  cmd_date.o cmd_dcr.o cmd_diag.o cmd_doc.o cmd_dtt.o \
 	  cmd_eeprom.o cmd_elf.o \
--- /dev/null	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-maintainance1/include/tag.h	2004-05-13 19:05:42.000000000 +0200
@@ -0,0 +1,61 @@
+/*
+ * (C) Copyright 2003
+ * Holger Schurig, M&N Logistik-Loesungen Online GmbH, <h.schurig@mn...>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _TAG_H_
+#define _TAG_H_ 1
+
+#define tag_size(type)  ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)
+#define tag_next(t)     ((struct tag *)((u32 *)(t) + (t)->hdr.size))
+
+#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
+    defined (CONFIG_CMDLINE_TAG) || \
+    defined (CONFIG_INITRD_TAG) || \
+    defined (CONFIG_VFD)
+
+void setup_start_tag(bd_t * bd);
+
+# ifdef CONFIG_SETUP_MEMORY_TAGS
+void setup_memory_tags(bd_t * bd);
+# endif
+
+void setup_commandline_tag(bd_t * bd, char *commandline);
+
+#if 0
+void setup_ramdisk_tag(bd_t * bd);
+#endif
+
+# ifdef CONFIG_INITRD_TAG
+void setup_initrd_tag(bd_t * bd, ulong initrd_start, ulong initrd_end);
+# endif
+
+void setup_end_tag(bd_t * bd);
+
+# if defined (CONFIG_VFD)
+void setup_videolfb_tag(gd_t * gd);
+# endif
+
+extern struct tag *params;
+
+#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
+
+#endif /* _TAG_H_ */
#3 lore raw

PATCH 1/1 cmdbootz

Quoted 5 lines · In message <[email protected]> you wrote:

I've attached a version that tries to encapsulate the ARM specific stuff into CONFIG_ARM ifdefs; as I don't have any PowerPC toolchains here, could somebody with access to one and better knowledge about PPC kernel start mechanisms have a look at how things had to be done there?

I think this is not the right way to implement this -- as far as I can see most of this is duplicated code from "lib_arm/armlinux.c". if we continue that way and duplicate the code for other architectures as well we will and up with - well, a lot of duplicated code.

May I ask you to factor out the relevant code in "lib_arm/armlinux.c" so we have a set of functions which can be used by both the bootm and bootz commands?

And maybe we don't need to do even this - probably cmd_bootm.c can be split in a "header checking" and a "boot the image part" - so that the "bootm" command uses both, and "bootz" ignores the header checking.

Anyway - I think you get the idea: please do not duplicate lots of existing code.

Best regards,

Wolfgang Denk

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
Name one thing windows is better than unix in?
                                          Making money for Microsoft?
         -- Randal L. Schwartz in <[email protected]>