cbfs: expose init_backing_media()

I broke cbfs loading with commit 358901. As multiple
functions are being reused one needs to ensure there is
always a cbfs media object allocated on the stack and
initialized. Ya for no common writable globals.

TEST=Ran qemu-armv7. CBFS loading works again.

Change-Id: Ibd047af7dcd8575e6203651471079fc2042da282
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/8973
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: Aaron Durbin <adurbin@google.com>
Tested-by: build bot (Jenkins)
Tested-by: Raptor Engineering Automated Test Stand <noreply@raptorengineeringinc.com>
This commit is contained in:
Aaron Durbin
2015-03-24 15:50:45 -05:00
committed by Aaron Durbin
parent d0f9f74223
commit 12d45b2f8a
3 changed files with 13 additions and 4 deletions

View File

@ -76,6 +76,10 @@ void *cbfs_load_optionrom(struct cbfs_media *media, uint16_t vendor,
void *cbfs_load_stage_by_offset(struct cbfs_media *media, ssize_t offset)
{
struct cbfs_stage stage;
struct cbfs_media backing_store;
if (init_backing_media(&media, &backing_store))
return (void *)-1;
if (cbfs_read(media, &stage, offset, sizeof(stage)) != sizeof(stage)) {
ERROR("ERROR: failed to read stage header\n");
@ -116,6 +120,10 @@ void *cbfs_load_stage(struct cbfs_media *media, const char *name)
{
struct cbfs_file file;
ssize_t offset;
struct cbfs_media backing_store;
if (init_backing_media(&media, &backing_store))
return (void *)-1;
offset = cbfs_locate_file(media, &file, name);
if (offset < 0 || file.type != CBFS_TYPE_STAGE)