Patrick Georgi (pgeorgi@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11213
-gerrit
commit 2aedc88b9e64ecca4462d609daf8c43eb822e82e Author: Patrick Georgi pgeorgi@google.com Date: Tue Aug 11 14:54:24 2015 +0200
cbfstool: allow passing a precalculated header size into cbfs_add_entry()
This is in preparation of creating the cbfs_file header much earlier in the process. For now, size is enough because lots of things need to move before it makes sense to deal with cbfs_file at a higher level.
Change-Id: I47589247c3011cb828170eaa10ef4a1e0f85ab84 Signed-off-by: Patrick Georgi pgeorgi@google.com --- util/cbfstool/cbfs_image.c | 8 +++++--- util/cbfstool/cbfs_image.h | 3 ++- util/cbfstool/cbfstool.c | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index e095187..e78ee40 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -533,7 +533,8 @@ static int cbfs_add_entry_at(struct cbfs_image *image, }
int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer, - const char *name, uint32_t type, uint32_t content_offset) + const char *name, uint32_t type, uint32_t content_offset, + uint32_t header_size) { assert(image); assert(buffer); @@ -544,9 +545,10 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer, uint32_t entry_type; uint32_t addr, addr_next; struct cbfs_file *entry, *next; - uint32_t header_size, need_size, new_size; + uint32_t need_size, new_size;
- header_size = cbfs_calculate_file_header_size(name); + if (header_size == 0) + header_size = cbfs_calculate_file_header_size(name);
need_size = header_size + buffer->size; DEBUG("cbfs_add_entry('%s'@0x%x) => need_size = %u+%zu=%u\n", diff --git a/util/cbfstool/cbfs_image.h b/util/cbfstool/cbfs_image.h index cb2935b..907be61 100644 --- a/util/cbfstool/cbfs_image.h +++ b/util/cbfstool/cbfs_image.h @@ -93,7 +93,8 @@ int cbfs_export_entry(struct cbfs_image *image, const char *entry_name, * Never pass this function a top-aligned address: convert it to an offset. * Returns 0 on success, otherwise non-zero. */ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer, - const char *name, uint32_t type, uint32_t content_offset); + const char *name, uint32_t type, uint32_t content_offset, + uint32_t header_size);
/* Removes an entry from CBFS image. Returns 0 on success, otherwise non-zero. */ int cbfs_remove_entry(struct cbfs_image *image, const char *name); diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 6a89476..80e3895 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -150,8 +150,8 @@ static int cbfs_add_integer_component(const char *name, offset = convert_to_from_top_aligned(param.image_region, -offset);
- if (cbfs_add_entry(&image, &buffer, name, CBFS_COMPONENT_RAW, offset) != - 0) { + if (cbfs_add_entry(&image, &buffer, name, CBFS_COMPONENT_RAW, + offset, 0) != 0) { ERROR("Failed to add %llu into ROM image as '%s'.\n", (long long unsigned)u64val, name); goto done; @@ -211,7 +211,7 @@ static int cbfs_add_component(const char *filename, offset = convert_to_from_top_aligned(param.image_region, -offset);
- if (cbfs_add_entry(&image, &buffer, name, type, offset) != 0) { + if (cbfs_add_entry(&image, &buffer, name, type, offset, 0) != 0) { ERROR("Failed to add '%s' into ROM image.\n", filename); buffer_delete(&buffer); return 1;