Stefan Reinauer ([email protected]) just uploaded a new patch set to 
gerrit, which you can find at http://review.coreboot.org/2686

-gerrit

commit ae3731f6aea3404c48c3d26885b52f30431fa2e2
Author: Aaron Durbin <[email protected]>
Date:   Fri Dec 14 17:14:15 2012 -0600

    cbfstool: Add internal cbfs_find_file()
    
    Future work will require the ability to locate a named file.
    Add cbfs_find_file() to find the named file and return a struct
    cbfs_file.
    
    Change-Id: I3998c5e76c75de5672bef3f5e04a098e5e1778ed
    Signed-off-by: Aaron Durbin <[email protected]>
---
 util/cbfstool/common.c | 21 +++++++++++++++++++++
 util/cbfstool/common.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c
index 3c8dca5..0517d9a 100644
--- a/util/cbfstool/common.c
+++ b/util/cbfstool/common.c
@@ -870,3 +870,24 @@ uint32_t cbfs_find_location(const char *romfile, uint32_t 
filesize,
        free(rom);
        return ret;
 }
+
+struct cbfs_file *cbfs_find_file(const char *name)
+{
+       uint32_t current = phys_start;
+       while (current < phys_end) {
+               if (!cbfs_file_header(current)) {
+                       current += align;
+                       continue;
+               }
+               struct cbfs_file *thisfile =
+                   (struct cbfs_file *)phys_to_virt(current);
+               uint32_t length = ntohl(thisfile->len);
+               char *fname = (char *)(phys_to_virt(current) + sizeof(struct 
cbfs_file));
+               if (!strcmp(fname, name))
+                       return thisfile;
+               current =
+                   ALIGN(current + ntohl(thisfile->len) +
+                         ntohl(thisfile->offset), align);
+       }
+       return NULL;
+}
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index e197143..2a18d9c 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -130,4 +130,6 @@ void print_supported_filetypes(void);
 
 #define ARRAY_SIZE(a) (int)(sizeof(a) / sizeof((a)[0]))
 
+struct cbfs_file;
+struct cbfs_file *cbfs_find_file(const char *name);
 #endif

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to