Patrick Georgi (pgeorgi@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11326
-gerrit
commit cb9b779f637aab119e5acaa89730ff5e97433783 Author: Patrick Georgi patrick@georgi-clan.de Date: Tue Aug 25 13:48:10 2015 +0200
cbfstool: move cbfs_file header creation further up the call chain
The header is now created before the "converters" are run. Adding new capabilities (and fields to the header) will happen there, so we're close.
Change-Id: I0556df724bd93816b435efff7d931293dbed918f Signed-off-by: Patrick Georgi patrick@georgi-clan.de --- util/cbfstool/cbfs_image.c | 8 ++------ util/cbfstool/cbfs_image.h | 2 +- util/cbfstool/cbfstool.c | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index 84f4be6..8297cf1 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -533,12 +533,13 @@ 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, - uint32_t header_size) + void *header, uint32_t header_size) { assert(image); assert(buffer); assert(buffer->data); assert(name); + type = type; assert(!IS_TOP_ALIGNED_ADDRESS(content_offset));
uint32_t entry_type; @@ -607,16 +608,11 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer, DEBUG("section 0x%x+0x%x for content_offset 0x%x.\n", addr, addr_next - addr, content_offset);
- struct cbfs_file *header = - cbfs_create_file_header(type, buffer->size, name); - if (cbfs_add_entry_at(image, entry, buffer->data, content_offset, header, header_size) == 0) { - free(header); return 0; } - free(header); break; }
diff --git a/util/cbfstool/cbfs_image.h b/util/cbfstool/cbfs_image.h index 432ea72..c1df911 100644 --- a/util/cbfstool/cbfs_image.h +++ b/util/cbfstool/cbfs_image.h @@ -94,7 +94,7 @@ int cbfs_export_entry(struct cbfs_image *image, const char *entry_name, * 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, - uint32_t header_size); + void *header, 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 8672362..cad8004 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -123,6 +123,7 @@ static int cbfs_add_integer_component(const char *name, uint32_t offset, uint32_t headeroffset) { struct cbfs_image image; + struct cbfs_file *header = NULL; struct buffer buffer; int i, ret = 1;
@@ -151,8 +152,11 @@ static int cbfs_add_integer_component(const char *name, offset = convert_to_from_top_aligned(param.image_region, -offset);
+ header = cbfs_create_file_header(CBFS_COMPONENT_RAW, + buffer.size, name); + uint32_t header_size = cbfs_calculate_file_header_size(name); if (cbfs_add_entry(&image, &buffer, name, CBFS_COMPONENT_RAW, - offset, 0) != 0) { + offset, header, header_size) != 0) { ERROR("Failed to add %llu into ROM image as '%s'.\n", (long long unsigned)u64val, name); goto done; @@ -161,6 +165,8 @@ static int cbfs_add_integer_component(const char *name, ret = 0;
done: + if (header) + free(header); buffer_delete(&buffer); return ret; } @@ -202,9 +208,11 @@ static int cbfs_add_component(const char *filename, return 1; }
+ struct cbfs_file *header = + cbfs_create_file_header(type, buffer.size, name); uint32_t header_size = cbfs_calculate_file_header_size(name);
- if (convert && convert(&buffer, &offset, NULL) != 0) { + if (convert && convert(&buffer, &offset, header) != 0) { ERROR("Failed to parse file '%s'.\n", filename); buffer_delete(&buffer); return 1; @@ -214,13 +222,16 @@ 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, header_size) + if (cbfs_add_entry(&image, &buffer, name, type, offset, + header, header_size) != 0) { ERROR("Failed to add '%s' into ROM image.\n", filename); + free(header); buffer_delete(&buffer); return 1; }
+ free(header); buffer_delete(&buffer); return 0; }