[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[microblaze-uclinux] [PATCH] MTD Maps: Add cramfs recognition to uclinux
Retrying again with appropriate mailing list memberships.
If you've received multiple copies of this patch please
delete them and respond to this one so all interested parties are cc'd.
This patch is relative to 2.6.30-rc6.
The PetaLinux embedded distro (for the Microblaze architecture) provides
the ability to bundle a cramfs root filesystem with the kernel. The uclinux
MTD map driver currently recognizes only romfs. This patch adds recognition
of cramfs to the map driver and provides a function that architecture
startup code can call to determine the size of a bundled filesystem.
Depending on how the bundling is accomplished, arch startup code may need
to relocate the filesystem before clearing .bss, and in that case needs
to know the filesystem length. It is desirable to have the length
determination code in one place rather than replicated in uclinux.c and
various architectures.
Signed-off-by: Steven J. Magnani <steve@xxxxxxxxxxxxxxx>
---
diff -uprN a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c
--- a/drivers/mtd/maps/uclinux.c 2009-05-20 09:18:58.000000000 -0500
+++ b/drivers/mtd/maps/uclinux.c 2009-05-20 09:55:21.000000000 -0500
@@ -13,6 +13,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/fs.h>
+#include <linux/cramfs_fs.h>
#include <linux/mm.h>
#include <linux/major.h>
#include <linux/mtd/mtd.h>
@@ -51,6 +52,23 @@ int uclinux_point(struct mtd_info *mtd,
/****************************************************************************/
+unsigned long uclinux_rootfs_len(unsigned long *addr)
+{
+#ifdef CONFIG_ROMFS_FS
+ if (memcmp(&addr[0], "-rom1fs-", 8) == 0) /* romfs */
+ return be32_to_cpu(addr[2]);
+#endif
+
+#ifdef CONFIG_CRAMFS
+ if (addr[0] == CRAMFS_MAGIC)
+ return addr[1];
+#endif
+
+ return 0;
+}
+
+/****************************************************************************/
+
static int __init uclinux_mtd_init(void)
{
struct mtd_info *mtd;
@@ -60,7 +78,7 @@ static int __init uclinux_mtd_init(void)
mapp = &uclinux_ram_map;
mapp->phys = addr;
- mapp->size = PAGE_ALIGN(ntohl(*((unsigned long *)(addr + 8))));
+ mapp->size = PAGE_ALIGN(uclinux_rootfs_len((unsigned long *)addr));
mapp->bankwidth = 4;
printk("uclinux[mtd]: RAM probe address=0x%x size=0x%x\n",
diff -uprN a/include/linux/mtd/uclinux.h b/include/linux/mtd/uclinux.h
--- a/include/linux/mtd/uclinux.h 1969-12-31 18:00:00.000000000 -0600
+++ b/include/linux/mtd/uclinux.h 2009-05-20 09:55:38.000000000 -0500
@@ -0,0 +1,33 @@
+/*
+ * Copyright(c) 2009 Digital Design Corporation. All rights reserved.
+ *
+ * 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.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+#ifndef MTD_UCLINUX_H
+#define MTD_UCLINUX_H
+
+#ifdef CONFIG_MTD_UCLINUX
+unsigned long uclinux_rootfs_len(unsigned long *addr);
+#else
+static inline unsigned long uclinux_rootfs_len(unsigned long *addr)
+ { return 0; }
+#endif
+
+#endif
+
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/