cbfs: add cbfs_locate_file()

cbfs_locate_file() can be used to locate the data within the
cbfs file. Based on the offset and length of the file it can
then be read into any address without bringing the contents
into another buffer (platforms without memory-mapped access
to entire contents of cbfs at once).

BUG=chrome-os-partner:29922
BRANCH=None
TEST=Built and booted rush into romstage (stage load still works).

Change-Id: I2932f66478c74511ec1c876b09794d9a22a526b3
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206000
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
Aaron Durbin 2014-06-27 15:06:02 -05:00 committed by chrome-internal-fetch
commit 56c958facd
2 changed files with 66 additions and 29 deletions

View file

@ -226,6 +226,13 @@ struct cbfs_media {
int (*close)(struct cbfs_media *media);
};
/*
* Locate file by name and fill in cbfs_file in host byte order. Returns
* < 0 on error, else the offset of the file data.
*/
ssize_t cbfs_locate_file(struct cbfs_media *media, struct cbfs_file *file,
const char *name);
/* returns pointer to a file entry inside CBFS or NULL */
struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name);