Patrick Georgi (pgeorgi@google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12583
-gerrit
commit 37b7850da4d7742f3716494d57b48cce58b7f787 Author: Daisuke Nojiri dnojiri@chromium.org Date: Thu Nov 19 09:10:41 2015 -0800
libpayload: get cbfs offset & size for default media from lib_sysinfo
This change revives the path which was made inert by CL:308520. When media == CBFS_DEFAULT_MEDIA, cbfs_get_file replaces it with a pointer to a default media. Thus, get_cbfs_range does not set cbfs offset & size from lib_sysinfo.
BUG=chrome-os-partner:47772 BRANCH=tot TEST=Tested on Jerry and Glados
Change-Id: I012f7871336dd24b8eada5c96c4d72117921b0d2 Signed-off-by: Patrick Georgi pgeorgi@chromium.org Original-Commit-Id: 279ba344788b4ba85f500e6cfcca8199af6d0a89 Original-Change-Id: I7f0798881519026a23d0801d0a790332ab878ff0 Original-Signed-off-by: Daisuke Nojiri dnojiri@chromium.org Original-Reviewed-on: https://chromium-review.googlesource.com/313205 Original-Reviewed-by: Aaron Durbin adurbin@chromium.org Original-Reviewed-by: Julius Werner jwerner@chromium.org --- payloads/libpayload/libcbfs/cbfs_core.c | 43 ++++++++++++++------------------- 1 file changed, 18 insertions(+), 25 deletions(-)
diff --git a/payloads/libpayload/libcbfs/cbfs_core.c b/payloads/libpayload/libcbfs/cbfs_core.c index 14a2001..ddf0da5 100644 --- a/payloads/libpayload/libcbfs/cbfs_core.c +++ b/payloads/libpayload/libcbfs/cbfs_core.c @@ -107,11 +107,8 @@ static int get_cbfs_range(uint32_t *offset, uint32_t *cbfs_end, return 0; }
- /* - * If sysinfo doesn't have offset or size, we read them from - * a master header. - */ - DEBUG("CBFS offset & size not found in sysinfo\n"); + /* read offset and size from cbfs master header */ + DEBUG("Read CBFS offset & size from master header\n"); header = cbfs_get_header(media); if (header == CBFS_HEADER_INVALID_ADDRESS) return -1; @@ -143,6 +140,11 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name) struct cbfs_file file, *file_ptr; struct cbfs_media default_media;
+ if (get_cbfs_range(&offset, &cbfs_end, media)) { + ERROR("Failed to find cbfs range\n"); + return NULL; + } + if (media == CBFS_DEFAULT_MEDIA) { media = &default_media; if (init_default_cbfs_media(media) != 0) { @@ -151,11 +153,6 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name) } }
- if (get_cbfs_range(&offset, &cbfs_end, media)) { - ERROR("Failed to find cbfs range\n"); - return NULL; - } - DEBUG("CBFS location: 0x%x~0x%x\n", offset, cbfs_end); DEBUG("Looking for '%s' starting from 0x%x.\n", name, offset);
@@ -212,26 +209,24 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name) void *cbfs_get_file_content(struct cbfs_media *media, const char *name, int type, size_t *sz) { - struct cbfs_media default_media; - - if (media == CBFS_DEFAULT_MEDIA) { - media = &default_media; - if (init_default_cbfs_media(media) != 0) { - ERROR("Failed to initialize default media.\n"); - return NULL; - } - } - + /* + * get file (possibly compressed) data. we pass through 'media' to + * cbfs_get_file (don't call init_default_cbfs_media) here so that + * cbfs_get_file can see whether the call is for CBFS_DEFAULT_MEDIA + * or not. Therefore, we don't (can't) unmap the file but it's caused + * by a pre-existing inherent problem with cbfs_get_file (and all + * callers are suffering from it). + */ struct cbfs_file *file = cbfs_get_file(media, name);
- if (sz) - *sz = 0; - if (file == NULL) { ERROR("Could not find file '%s'.\n", name); return NULL; }
+ if (sz) + *sz = 0; + if (ntohl(file->type) != type) { ERROR("File '%s' is of type %x, but we requested %x.\n", name, ntohl(file->type), type); @@ -264,11 +259,9 @@ void *cbfs_get_file_content(struct cbfs_media *media, const char *name, if (sz) *sz = final_size;
- media->unmap(media, file); return dst;
err: - media->unmap(media, file); free(dst); return NULL; }