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> Reviewed-on: https://review.coreboot.org/12583 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
16c7e0f56c
commit
03688ec1da
|
@ -107,11 +107,8 @@ static int get_cbfs_range(uint32_t *offset, uint32_t *cbfs_end,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* read offset and size from cbfs master header */
|
||||||
* If sysinfo doesn't have offset or size, we read them from
|
DEBUG("Read CBFS offset & size from master header\n");
|
||||||
* a master header.
|
|
||||||
*/
|
|
||||||
DEBUG("CBFS offset & size not found in sysinfo\n");
|
|
||||||
header = cbfs_get_header(media);
|
header = cbfs_get_header(media);
|
||||||
if (header == CBFS_HEADER_INVALID_ADDRESS)
|
if (header == CBFS_HEADER_INVALID_ADDRESS)
|
||||||
return -1;
|
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_file file, *file_ptr;
|
||||||
struct cbfs_media default_media;
|
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) {
|
if (media == CBFS_DEFAULT_MEDIA) {
|
||||||
media = &default_media;
|
media = &default_media;
|
||||||
if (init_default_cbfs_media(media) != 0) {
|
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("CBFS location: 0x%x~0x%x\n", offset, cbfs_end);
|
||||||
DEBUG("Looking for '%s' starting from 0x%x.\n", name, offset);
|
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,
|
void *cbfs_get_file_content(struct cbfs_media *media, const char *name,
|
||||||
int type, size_t *sz)
|
int type, size_t *sz)
|
||||||
{
|
{
|
||||||
struct cbfs_media default_media;
|
/*
|
||||||
|
* get file (possibly compressed) data. we pass through 'media' to
|
||||||
if (media == CBFS_DEFAULT_MEDIA) {
|
* cbfs_get_file (don't call init_default_cbfs_media) here so that
|
||||||
media = &default_media;
|
* cbfs_get_file can see whether the call is for CBFS_DEFAULT_MEDIA
|
||||||
if (init_default_cbfs_media(media) != 0) {
|
* or not. Therefore, we don't (can't) unmap the file but it's caused
|
||||||
ERROR("Failed to initialize default media.\n");
|
* by a pre-existing inherent problem with cbfs_get_file (and all
|
||||||
return NULL;
|
* callers are suffering from it).
|
||||||
}
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
struct cbfs_file *file = cbfs_get_file(media, name);
|
struct cbfs_file *file = cbfs_get_file(media, name);
|
||||||
|
|
||||||
if (sz)
|
|
||||||
*sz = 0;
|
|
||||||
|
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
ERROR("Could not find file '%s'.\n", name);
|
ERROR("Could not find file '%s'.\n", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sz)
|
||||||
|
*sz = 0;
|
||||||
|
|
||||||
if (ntohl(file->type) != type) {
|
if (ntohl(file->type) != type) {
|
||||||
ERROR("File '%s' is of type %x, but we requested %x.\n", name,
|
ERROR("File '%s' is of type %x, but we requested %x.\n", name,
|
||||||
ntohl(file->type), type);
|
ntohl(file->type), type);
|
||||||
|
@ -264,11 +259,9 @@ void *cbfs_get_file_content(struct cbfs_media *media, const char *name,
|
||||||
if (sz)
|
if (sz)
|
||||||
*sz = final_size;
|
*sz = final_size;
|
||||||
|
|
||||||
media->unmap(media, file);
|
|
||||||
return dst;
|
return dst;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
media->unmap(media, file);
|
|
||||||
free(dst);
|
free(dst);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue