Lines Matching +full:directory +full:- +full:based
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Parse RedBoot-style Flash Image System (FIS) tables and
7 * Copyright © 2001-2010 David Woodhouse <dwmw2@infradead.org>
26 unsigned char _pad[256 - (16 + 7 * sizeof(u32))];
36 static int directory = CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK; variable
37 module_param(directory, int, 0);
60 ret = of_property_read_u32(npart, "fis-index-block", &dirblock); in parse_redboot_of()
67 * directory block pointer. in parse_redboot_of()
69 directory = dirblock; in parse_redboot_of()
94 if (directory < 0) { in parse_redboot_partitions()
95 offset = master->size + directory * master->erasesize; in parse_redboot_partitions()
99 pr_notice("Failed to find a non-bad block to check for RedBoot partition table\n"); in parse_redboot_partitions()
100 return -EIO; in parse_redboot_partitions()
102 offset -= master->erasesize; in parse_redboot_partitions()
105 offset = (unsigned long) directory * master->erasesize; in parse_redboot_partitions()
107 offset += master->erasesize; in parse_redboot_partitions()
108 if (offset == master->size) in parse_redboot_partitions()
112 buf = vmalloc(master->erasesize); in parse_redboot_partitions()
115 return -ENOMEM; in parse_redboot_partitions()
118 master->name, offset); in parse_redboot_partitions()
120 ret = mtd_read(master, offset, master->erasesize, &retlen, in parse_redboot_partitions()
126 if (retlen != master->erasesize) { in parse_redboot_partitions()
127 ret = -EIO; in parse_redboot_partitions()
131 numslots = (master->erasesize / sizeof(struct fis_image_desc)); in parse_redboot_partitions()
133 if (!memcmp(buf[i].name, "FIS directory", 14)) { in parse_redboot_partitions()
134 /* This is apparently the FIS directory entry for the in parse_redboot_partitions()
135 * FIS directory itself. The FIS directory size is in parse_redboot_partitions()
138 * a byte swapped FIS directory - swap all the entries! in parse_redboot_partitions()
143 /* RedBoot can combine the FIS directory and in parse_redboot_partitions()
145 we assume wrong-endian if either the swapped in parse_redboot_partitions()
149 if (swab32(buf[i].size) == master->erasesize || in parse_redboot_partitions()
150 (buf[i].size > master->erasesize in parse_redboot_partitions()
151 && swab32(buf[i].size) < master->erasesize)) { in parse_redboot_partitions()
153 /* Update numslots based on actual FIS directory size */ in parse_redboot_partitions()
178 } else if (buf[i].size < master->erasesize) { in parse_redboot_partitions()
179 /* Update numslots based on actual FIS directory size */ in parse_redboot_partitions()
188 master->name); in parse_redboot_partitions()
209 ret = -ENOMEM; in parse_redboot_partitions()
212 new_fl->img = &buf[i]; in parse_redboot_partitions()
213 if (data && data->origin) in parse_redboot_partitions()
214 buf[i].flash_base -= data->origin; in parse_redboot_partitions()
216 buf[i].flash_base &= master->size - 1; in parse_redboot_partitions()
222 while (*prev && (*prev)->img->flash_base < new_fl->img->flash_base) in parse_redboot_partitions()
223 prev = &(*prev)->next; in parse_redboot_partitions()
224 new_fl->next = *prev; in parse_redboot_partitions()
230 if (fl->img->flash_base) { in parse_redboot_partitions()
235 for (tmp_fl = fl; tmp_fl->next; tmp_fl = tmp_fl->next) { in parse_redboot_partitions()
236 …if (tmp_fl->img->flash_base + tmp_fl->img->size + master->erasesize <= tmp_fl->next->img->flash_ba… in parse_redboot_partitions()
245 ret = -ENOMEM; in parse_redboot_partitions()
259 if (fl->img->flash_base) { in parse_redboot_partitions()
261 parts[0].size = fl->img->flash_base; in parse_redboot_partitions()
267 parts[i].size = fl->img->size; in parse_redboot_partitions()
268 parts[i].offset = fl->img->flash_base; in parse_redboot_partitions()
271 strcpy(names, fl->img->name); in parse_redboot_partitions()
275 !memcmp(names, "FIS directory", 14)) { in parse_redboot_partitions()
282 …if (fl->next && fl->img->flash_base + fl->img->size + master->erasesize <= fl->next->img->flash_ba… in parse_redboot_partitions()
284 parts[i].offset = parts[i - 1].size + parts[i - 1].offset; in parse_redboot_partitions()
285 parts[i].size = fl->next->img->flash_base - parts[i].offset; in parse_redboot_partitions()
290 fl = fl->next; in parse_redboot_partitions()
299 fl = fl->next; in parse_redboot_partitions()
307 { .compatible = "redboot-fis" },