From: "LOH Chee Tim" <cheetim_loh@innomedia.com.sg>
To: <linux-mtd@lists.infradead.org>
Subject: Re: Patch for RedBoot Partition Table Parsing
Date: Fri, 26 Mar 2004 10:01:33 +0800 [thread overview]
Message-ID: <002201c412d6$610deb60$0b00a8c0@PIII1200MHzM> (raw)
In-Reply-To: 1080119708.16509.322.camel@hades.cambridge.redhat.com
[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]
On Wed, 2004-03-24 at 5:15PM, David Woodhouse wrote:
> > Also included are minor updates to:
> > 1. include nullname only if it is used
> > 2. add an option for selecting whether unallocated flash space is to be
> > included
>
> OK. I'd be a lot happier if we had already fixed up the partitioning and
> could get at a 'whole-device' MTD device reliably, but it does make
> sense.
Can you please elaborate more on the issue so that I can try to help?
> > 4. force read-only for RedBoot, RedBoot Config and FIS directory images
>
> I don't like this very much. I habitually update RedBoot from Linux. I
> have occasionally been known to change the config and FIS directory too.
>
> Perhaps we could make it optional too?
>
> Please update the Kconfig file to match what you've changed in
> Config.in.
Please find attached the new patch against mtd-snapshot-20040323 that makes
forcing read-only of RedBoot system images optional and the updated Kconfig
file to match the changes to Config.in.
Regards,
Chee Tim
Senior Engineer, Product Development
InnoMedia Pte Ltd
DID: +65 65869142
Tel: +65 68720828 ext 142
Fax: +65 68724006
http://www.innomedia.com
[-- Attachment #2: mtd-snapshot-20040323.diff --]
[-- Type: application/octet-stream, Size: 5461 bytes --]
diff -ru mtd-snapshot-20040323-orig/drivers/mtd/Config.in mtd-snapshot-20040323/drivers/mtd/Config.in
--- mtd-snapshot-20040323-orig/drivers/mtd/Config.in Sat May 24 06:00:06 2003
+++ mtd-snapshot-20040323/drivers/mtd/Config.in Thu Mar 25 00:56:44 2004
@@ -14,6 +14,10 @@
dep_tristate ' MTD partitioning support' CONFIG_MTD_PARTITIONS $CONFIG_MTD
dep_tristate ' MTD concatenating support' CONFIG_MTD_CONCAT $CONFIG_MTD
dep_tristate ' RedBoot partition table parsing' CONFIG_MTD_REDBOOT_PARTS $CONFIG_MTD_PARTITIONS
+ if [ "$CONFIG_MTD_REDBOOT_PARTS" = "y" -o "$CONFIG_MTD_REDBOOT_PARTS" = "m" ]; then
+ bool ' Include unallocated flash space' CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
+ bool ' Force read-only for RedBoot system images' CONFIG_MTD_REDBOOT_PARTS_READONLY
+ fi
dep_tristate ' Command line partition table parsing' CONFIG_MTD_CMDLINE_PARTS $CONFIG_MTD_PARTITIONS
if [ "$CONFIG_ARM" = "y" ]; then
dep_tristate ' ARM Firmware Suite partition parsing' CONFIG_MTD_AFS_PARTS $CONFIG_MTD_PARTITIONS
diff -ru mtd-snapshot-20040323-orig/drivers/mtd/Kconfig mtd-snapshot-20040323/drivers/mtd/Kconfig
--- mtd-snapshot-20040323-orig/drivers/mtd/Kconfig Thu May 29 06:00:06 2003
+++ mtd-snapshot-20040323/drivers/mtd/Kconfig Thu Mar 25 01:20:55 2004
@@ -68,6 +68,20 @@
SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for
example.
+config MTD_REDBOOT_PARTS_UNALLOCATED
+ bool " Include unallocated flash regions"
+ depends on MTD_REDBOOT_PARTS
+ help
+ If you need to register each unallocated flash region as a MTD
+ 'partition', enable this option.
+
+config MTD_REDBOOT_PARTS_READONLY
+ bool " Force read-only for RedBoot system images"
+ depends on MTD_REDBOOT_PARTS
+ help
+ If you need to force read-only for 'RedBoot', 'RedBoot Config' and
+ 'FIS directory' images, enable this option.
+
config MTD_CMDLINE_PARTS
tristate "Command line partition table parsing"
depends on MTD_PARTITIONS
diff -ru mtd-snapshot-20040323-orig/drivers/mtd/redboot.c mtd-snapshot-20040323/drivers/mtd/redboot.c
--- mtd-snapshot-20040323-orig/drivers/mtd/redboot.c Thu Jun 26 06:00:07 2003
+++ mtd-snapshot-20040323/drivers/mtd/redboot.c Thu Mar 25 00:41:32 2004
@@ -48,21 +48,24 @@
char *names;
char *nullname;
int namelen = 0;
+ int nulllen = 0;
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
static char nullstring[] = "unallocated";
+#endif
- buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ buf = kmalloc(master->erasesize, GFP_KERNEL);
if (!buf)
return -ENOMEM;
/* Read the start of the last erase block */
ret = master->read(master, master->size - master->erasesize,
- PAGE_SIZE, &retlen, (void *)buf);
+ master->erasesize, &retlen, (void *)buf);
if (ret)
goto out;
- if (retlen != PAGE_SIZE) {
+ if (retlen != master->erasesize) {
ret = -EIO;
goto out;
}
@@ -80,7 +83,7 @@
goto out;
}
- for (i = 0; i < PAGE_SIZE / sizeof(struct fis_image_desc); i++) {
+ for (i = 0; i < master->erasesize / sizeof(struct fis_image_desc); i++) {
struct fis_list *new_fl, **prev;
if (buf[i].name[0] == 0xff)
@@ -112,48 +115,69 @@
nrparts++;
}
- if (fl->img->flash_base)
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
+ if (fl->img->flash_base) {
nrparts++;
+ nulllen = sizeof(nullstring);
+ }
for (tmp_fl = fl; tmp_fl->next; tmp_fl = tmp_fl->next) {
- if (tmp_fl->img->flash_base + tmp_fl->img->size + master->erasesize < tmp_fl->next->img->flash_base)
+ if (tmp_fl->img->flash_base + tmp_fl->img->size + master->erasesize <= tmp_fl->next->img->flash_base) {
nrparts++;
+ nulllen = sizeof(nullstring);
+ }
}
- parts = kmalloc(sizeof(*parts)*nrparts + sizeof(nullstring) + namelen, GFP_KERNEL);
+#endif
+ parts = kmalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);
if (!parts) {
ret = -ENOMEM;
goto out;
}
- memset(parts, 0, sizeof(*parts)*nrparts + namelen);
+ memset(parts, 0, sizeof(*parts)*nrparts + nulllen + namelen);
- /* FIXME: Include nullname only if it's used */
nullname = (char *)&parts[nrparts];
- sprintf(nullname, nullstring);
- names = nullname + sizeof(nullstring);
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
+ if (nulllen > 0) {
+ strcpy(nullname, nullstring);
+ }
+#endif
+ names = nullname + nulllen;
i=0;
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
if (fl->img->flash_base) {
parts[0].name = nullname;
parts[0].size = fl->img->flash_base;
parts[0].offset = 0;
+ i++;
}
+#endif
for ( ; i<nrparts; i++) {
parts[i].size = fl->img->size;
parts[i].offset = fl->img->flash_base;
parts[i].name = names;
strcpy(names, fl->img->name);
+#ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY
+ if (!memcmp(names, "RedBoot", 8) ||
+ !memcmp(names, "RedBoot config", 15) ||
+ !memcmp(names, "FIS directory", 14)) {
+ parts[i].mask_flags = MTD_WRITEABLE;
+ }
+#endif
names += strlen(names)+1;
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
if(fl->next && fl->img->flash_base + fl->img->size + master->erasesize <= fl->next->img->flash_base) {
i++;
parts[i].offset = parts[i-1].size + parts[i-1].offset;
parts[i].size = fl->next->img->flash_base - parts[i].offset;
parts[i].name = nullname;
}
+#endif
tmp_fl = fl;
fl = fl->next;
kfree(tmp_fl);
prev parent reply other threads:[~2004-03-26 1:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-24 4:00 Patch for RedBoot Partition Table Parsing LOH Chee Tim
2004-03-24 9:15 ` David Woodhouse
2004-03-26 2:01 ` LOH Chee Tim [this message]
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='002201c412d6$610deb60$0b00a8c0@PIII1200MHzM' \
--to=cheetim_loh@innomedia.com.sg \
--cc=linux-mtd@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