Marc Jones (marc.jones@se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8181
-gerrit
commit 0053795fb7cb35e0d97f2b9b6c6cebdb54aba1e7 Author: Aaron Durbin adurbin@chromium.org Date: Fri Jun 27 15:28:39 2014 -0500
cbfs: add cbfs_read()
Allow for reading from cbfs media without having a handle to a non-CBFS_DEFAULT_MEDIA cbfs_media. In conjunction with cbfs_locate_file() one can locate and cbfs_read() a file without bringing the entire file through a potentially temporary buffer (non-memory-mappable cbfs media platforms).
BUG=chrome-os-partner:29922 BRANCH=None TEST=Built.
Original-Change-Id: Ib5d965334bce1267650fc23c9e9f496675cf8450 Original-Signed-off-by: Aaron Durbin adurbin@chromium.org Original-Reviewed-on: https://chromium-review.googlesource.com/205991 Original-Reviewed-by: Furquan Shaikh furquan@chromium.org (cherry picked from commit 85200f28863e5ea8888322f5787dc6de9a2999f0) Signed-off-by: Marc Jones marc.jones@se-eng.com
Change-Id: I25e3221beefd0155305ad63da6be9f47e756f7d0 --- src/include/cbfs_core.h | 4 ++++ src/lib/cbfs_core.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+)
diff --git a/src/include/cbfs_core.h b/src/include/cbfs_core.h index 3cef903..b01a307 100644 --- a/src/include/cbfs_core.h +++ b/src/include/cbfs_core.h @@ -224,6 +224,10 @@ struct cbfs_media { ssize_t cbfs_locate_file(struct cbfs_media *media, struct cbfs_file *file, const char *name);
+/* Read count bytes at offset into dest. Return number of bytes read. */ +size_t cbfs_read(struct cbfs_media *media, void *dest, size_t offset, + size_t count); + /* returns pointer to a file entry inside CBFS or NULL */ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name);
diff --git a/src/lib/cbfs_core.c b/src/lib/cbfs_core.c index 24e5998..6455a07 100644 --- a/src/lib/cbfs_core.c +++ b/src/lib/cbfs_core.c @@ -194,6 +194,22 @@ ssize_t cbfs_locate_file(struct cbfs_media *media, struct cbfs_file *file, return -1; }
+size_t cbfs_read(struct cbfs_media *media, void *dest, size_t offset, + size_t count) +{ + struct cbfs_media default_media; + size_t nread; + + if (init_media(&media, &default_media)) + return 0; + + media->open(media); + nread = media->read(media, dest, offset, count); + media->close(media); + + return nread; +} + struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name) { struct cbfs_media default_media;