summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2015-12-15 13:33:51 -0600
committerAaron Durbin <adurbin@chromium.org>2016-01-06 01:11:19 +0100
commit295d58bda85ce30724a3fff87d60b323373f6e5f (patch)
tree7bdd1cf6a886bc11ab313d9b235aa5cb00bdaf8d /src/lib
parent990ab7efe5d0eddb96542042bf5106811365e34a (diff)
commonlib: Add common cbfs parsing logic to coreboot and cbfstool.
To continue sharing more code between the tools and coreboot proper provide cbfs parsing logic in commonlib. A cbfs_for_each_file() function was added to allow one to act on each file found within a cbfs. cbfs_locate() was updated to use that logic. BUG=chrome-os-partner:48412 BUG=chromium:445938 BRANCH=None TEST=Utilized and booted on glados. Change-Id: I1f23841583e78dc3686f106de9eafe1adbef8c9f Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/12783 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cbfs.c72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index d68aa39cc5..55a8536a36 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -68,78 +68,6 @@ void *cbfs_boot_map_with_leak(const char *name, uint32_t type, size_t *size)
return rdev_mmap(&fh.data, 0, fsize);
}
-int cbfs_locate(struct cbfsf *fh, const struct region_device *cbfs,
- const char *name, uint32_t *type)
-{
- size_t offset = 0;
-
- LOG("Locating '%s'\n", name);
-
- /* Try to scan the entire cbfs region looking for file name. */
- while (1) {
- struct cbfs_file file;
- const size_t fsz = sizeof(file);
- char *fname;
- int name_match;
- size_t datasz;
-
- DEBUG("Checking offset %zx\n", offset);
-
- /* Can't read file. Nothing else to do but bail out. */
- if (rdev_readat(cbfs, &file, offset, fsz) != fsz)
- break;
-
- if (memcmp(file.magic, CBFS_FILE_MAGIC, sizeof(file.magic))) {
- offset++;
- offset = ALIGN_UP(offset, CBFS_ALIGNMENT);
- continue;
- }
-
- file.len = ntohl(file.len);
- file.type = ntohl(file.type);
- file.offset = ntohl(file.offset);
-
- /* See if names match. */
- fname = rdev_mmap(cbfs, offset + fsz, file.offset - fsz);
-
- if (fname == NULL)
- break;
-
- name_match = !strcmp(fname, name);
- rdev_munmap(cbfs, fname);
-
- if (!name_match) {
- DEBUG(" Unmatched '%s' at %zx\n", fname, offset);
- offset += file.offset + file.len;
- offset = ALIGN_UP(offset, CBFS_ALIGNMENT);
- continue;
- }
-
- if (type != NULL && *type != file.type) {
- DEBUG(" Unmatched type %x at %zx\n", file.type, offset);
- offset += file.offset + file.len;
- offset = ALIGN_UP(offset, CBFS_ALIGNMENT);
- continue;
- }
-
- LOG("Found @ offset %zx size %x\n", offset, file.len);
- /* File and type match. Keep track of both the metadata and
- * the data for the file. */
- if (rdev_chain(&fh->metadata, cbfs, offset, file.offset))
- break;
- offset += file.offset;
- datasz = file.len;
- if (rdev_chain(&fh->data, cbfs, offset, datasz))
- break;
-
- /* Success. */
- return 0;
- }
-
- LOG("'%s' not found.\n", name);
- return -1;
-}
-
static size_t inflate(void *src, void *dst)
{
if (ENV_BOOTBLOCK || ENV_VERSTAGE)