diff options
author | Gabe Black <gabeblack@chromium.org> | 2013-07-01 04:57:37 -0700 |
---|---|---|
committer | Patrick Georgi <patrick@georgi-clan.de> | 2013-08-15 20:10:39 +0200 |
commit | 0c605a5a6cf0b5a7bdaa6068168581dc8fb24d22 (patch) | |
tree | 3c975a327806f6a2f1fdeea66708cc5c74b6aa20 /src/lib/cbfs.c | |
parent | f31eacca62bb9fda9ed05be941a336163f1ce146 (diff) | |
download | coreboot-0c605a5a6cf0b5a7bdaa6068168581dc8fb24d22.tar.xz |
CBFS: Change the signature of cbfs_decompress.
Instead of returning 0 on success and -1 on error, return the decompressed
size of the data on success and 0 on error. The decompressed size is useful
information to have that was being thrown away in that function.
Change-Id: If787201aa61456b1e47feaf3a0071c753fa299a3
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Reviewed-on: http://review.coreboot.org/3578
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
Diffstat (limited to 'src/lib/cbfs.c')
-rw-r--r-- | src/lib/cbfs.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index aba1bcccf0..400b8a5f9d 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -112,7 +112,7 @@ void *cbfs_load_optionrom(struct cbfs_media *media, uint16_t vendor, if (! dest) return src; - if (cbfs_decompress(ntohl(orom->compression), + if (!cbfs_decompress(ntohl(orom->compression), src, dest, ntohl(orom->len))) @@ -204,8 +204,8 @@ static void *load_stage_from_cbfs(struct cbfs_media *media, const char *name, LOG("Decompressing stage %s @ 0x%p (%d bytes)\n", name, &ramstage_region[rmodule_offset], stage->memlen); - if (cbfs_decompress(stage->compression, &stage[1], - &ramstage_region[rmodule_offset], stage->len)) + if (!cbfs_decompress(stage->compression, &stage[1], + &ramstage_region[rmodule_offset], stage->len)) return (void *) -1; if (rmodule_parse(&ramstage_region[rmodule_offset], &ramstage)) @@ -259,6 +259,7 @@ void * cbfs_load_stage(struct cbfs_media *media, const char *name) /* this is a mess. There is no ntohll. */ /* for now, assume compatible byte order until we solve this. */ uint32_t entry; + uint32_t final_size; if (stage == NULL) return (void *) -1; @@ -270,11 +271,12 @@ void * cbfs_load_stage(struct cbfs_media *media, const char *name) /* Stages rely the below clearing so that the bss is initialized. */ memset((void *) (uint32_t) stage->load, 0, stage->memlen); - if (cbfs_decompress(stage->compression, - ((unsigned char *) stage) + - sizeof(struct cbfs_stage), - (void *) (uint32_t) stage->load, - stage->len)) + final_size = cbfs_decompress(stage->compression, + ((unsigned char *) stage) + + sizeof(struct cbfs_stage), + (void *) (uint32_t) stage->load, + stage->len); + if (!final_size) return (void *) -1; DEBUG("stage loaded.\n"); |