FSG-3 receives kernel commandline from Redboot. Commandline contains
information about HDD partition that contains root filesystem. It is in
style kernel 2.4 (I guess because Freecom recovery ramdisk image is kernel
2.4).

This patch fixes it at boot time for kernel 2.6 and adds OpenWrt specific
"init=/etc/preinit". Therefore there is no need to change Redboot
configuration.

Signed-off-by: Zintis Petersons <[email protected]>

diff -ruN linux-2.6.28.5.orig/arch/arm/mach-ixp4xx/fsg-setup.c
linux-2.6.28.5/arch/arm/mach-ixp4xx/fsg-setup.c
--- linux-2.6.28.5.orig/arch/arm/mach-ixp4xx/fsg-setup.c        2009-02-12
19:51:15.000000000 +0200
+++ linux-2.6.28.5/arch/arm/mach-ixp4xx/fsg-setup.c     2009-03-14
13:11:56.000000000 +0200
@@ -29,6 +29,7 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/flash.h>
 #include <asm/gpio.h>
+#include <asm/setup.h>
 
 static struct flash_platform_data fsg_flash_data = {
        .map_name               = "cfi_probe",
@@ -263,6 +264,70 @@
 
 }
 
+void __init openwrt_fixup(struct machine_desc *mdesc, struct tag *t,
+                           char **from, struct meminfo *meminfo)
+{
+       static char openwrt_init_tag[] __initdata = " init=/etc/preinit";
+       static char default_command_line[COMMAND_LINE_SIZE] __initdata =
CONFIG_CMDLINE;
+       char *p = NULL;
+
+       for (; t->hdr.size; t = tag_next(t)){
+               /* Locate the Freecom cmdline */
+               if (t->hdr.tag == ATAG_CMDLINE) {
+                       p = t->u.cmdline.cmdline;
+                       u32 size = t->hdr.size;
+
+                       /* Swap command line because redboot is big endian.
*/
+                       if (--size > 0) {
+                               const u32 *from = (const u32*)p;
+                               u32 *to = (u32*)default_command_line;
+
+                               if (size > COMMAND_LINE_SIZE/4)
+                                       size = COMMAND_LINE_SIZE/4;
+
+                               while (size-- > 0)
+                               #ifdef CONFIG_CPU_BIG_ENDIAN
+                                       to[size] = from[size];
+                               #else
+                                       to[size] = swab32(from[size]);
+                               #endif
+
+                               default_command_line[COMMAND_LINE_SIZE-1] =
0;
+
+                               /* Boot always from sda. */
+                               char *pp = strstr(default_command_line,
"root=/dev/");
+                               if(pp) {
+                                       *(pp+10) = 's';
+                                       *(pp+14) = 0; /* drop
"mem=...@0x00000000" */
+                               }
+                       }
+               }
+       }
+
+       printk("%s(%d): End of table at 0x%0lx\n", __FUNCTION__, __LINE__,
t);
+
+       /* Overwrite the end of the table with a new cmdline tag. */ 
+       t->hdr.tag = ATAG_CMDLINE;
+       t->hdr.size =
+               (sizeof (struct tag_header) +
+                strlen(p) + strlen(openwrt_init_tag) + 1 + 4) >> 2;
+
+       strlcpy(t->u.cmdline.cmdline, default_command_line,
COMMAND_LINE_SIZE);
+       strlcpy(t->u.cmdline.cmdline + strlen(default_command_line),
openwrt_init_tag,
+               COMMAND_LINE_SIZE - strlen(default_command_line));
+
+       printk("%s(%d): New cmdline '%s' at 0x%0lx\n",
+              __FUNCTION__, __LINE__,
+              t->u.cmdline.cmdline, (unsigned long)t->u.cmdline.cmdline);
+
+       t = tag_next(t);
+
+       printk("%s(%d): New end of table at 0x%0lx\n", __FUNCTION__,
__LINE__, t);
+
+       t->hdr.tag = ATAG_NONE;
+       t->hdr.size = 0;
+}
+
 MACHINE_START(FSG, "Freecom FSG-3")
        /* Maintainer: www.nslu2-linux.org */
        .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
@@ -272,5 +337,6 @@
        .timer          = &ixp4xx_timer,
        .boot_params    = 0x0100,
        .init_machine   = fsg_init,
+       .fixup          = openwrt_fixup,
 MACHINE_END


_______________________________________________
openwrt-devel mailing list
[email protected]
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to