24 #include <linux/kernel.h>
25 #include <linux/slab.h>
31 #include <linux/module.h>
50 static int directory = CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK;
59 static int parse_redboot_partitions(
struct mtd_info *master,
75 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
76 static char nullstring[] =
"unallocated";
79 if ( directory < 0 ) {
84 printk(
KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n");
93 if (offset == master->
size)
102 printk(
KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n",
103 master->
name, offset);
117 for (i = 0; i < numslots; i++) {
118 if (!
memcmp(buf[i].
name,
"FIS directory", 14)) {
140 for (j = 0; j < numslots; ++
j) {
145 if (buf[j].name[0] == 0xff) {
146 if (buf[j].name[1] == 0xff) {
164 }
else if (buf[i].size < master->erasesize) {
179 for (i = 0; i < numslots; i++) {
182 if (buf[i].name[0] == 0xff) {
183 if (buf[i].name[1] == 0xff) {
189 if (!redboot_checksum(&buf[i]))
193 namelen +=
strlen(buf[i].name)+1;
198 new_fl->
img = &buf[
i];
208 while(*prev && (*prev)->
img->flash_base < new_fl->
img->flash_base)
209 prev = &(*prev)->
next;
215 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
216 if (fl->
img->flash_base) {
218 nulllen =
sizeof(nullstring);
221 for (tmp_fl = fl; tmp_fl->
next; tmp_fl = tmp_fl->next) {
222 if (tmp_fl->img->flash_base + tmp_fl->img->size + master->
erasesize <= tmp_fl->next->img->flash_base) {
224 nulllen =
sizeof(nullstring);
228 parts = kzalloc(
sizeof(*parts)*nrparts + nulllen + namelen,
GFP_KERNEL);
235 nullname = (
char *)&parts[nrparts];
236 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
238 strcpy(nullname, nullstring);
241 names = nullname + nulllen;
245 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
246 if (fl->
img->flash_base) {
247 parts[0].
name = nullname;
248 parts[0].
size = fl->
img->flash_base;
253 for ( ; i<nrparts; i++) {
256 parts[
i].
name = names;
259 #ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY
260 if (!
memcmp(names,
"RedBoot", 8) ||
261 !
memcmp(names,
"RedBoot config", 15) ||
262 !
memcmp(names,
"FIS directory", 14)) {
268 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
273 parts[
i].
name = nullname;
294 .parse_fn = parse_redboot_partitions,
301 static int __init redboot_parser_init(
void)
306 static void __exit redboot_parser_exit(
void)