Patrick Georgi (pgeorgi@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11325
-gerrit
commit 1173588efb92d22c155edaa1837c46e1c70aa8f8 Author: Patrick Georgi patrick@georgi-clan.de Date: Tue Aug 25 15:53:52 2015 +0200
cbfstool: pass cbfs_file header into "compress" functions
These functions can do all kinds of things, such as converting an ELF image into SELF, or (in the future) compress or checksum entire files. This may require changing or adding fields to the header, so they need to have access to it.
The header_size parameter that was provided (but never used) is equivalent to cbfs_file's offset field.
Change-Id: I7c10ab15f3dff4412461103e9763a1d78b7be7bb Signed-off-by: Patrick Georgi patrick@georgi-clan.de --- util/cbfstool/cbfstool.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index bf51956..8672362 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -116,7 +116,7 @@ static unsigned convert_to_from_top_aligned(const struct buffer *region, }
typedef int (*convert_buffer_t)(struct buffer *buffer, uint32_t *offset, - uint32_t *header_size); + struct cbfs_file *header);
static int cbfs_add_integer_component(const char *name, uint64_t u64val, @@ -204,7 +204,7 @@ static int cbfs_add_component(const char *filename,
uint32_t header_size = cbfs_calculate_file_header_size(name);
- if (convert && convert(&buffer, &offset, &header_size) != 0) { + if (convert && convert(&buffer, &offset, NULL) != 0) { ERROR("Failed to parse file '%s'.\n", filename); buffer_delete(&buffer); return 1; @@ -226,7 +226,7 @@ static int cbfs_add_component(const char *filename, }
static int cbfstool_convert_mkstage(struct buffer *buffer, uint32_t *offset, - unused uint32_t *header_size) + struct cbfs_file *header) { struct buffer output; int ret; @@ -237,11 +237,13 @@ static int cbfstool_convert_mkstage(struct buffer *buffer, uint32_t *offset, buffer_delete(buffer); // direct assign, no dupe. memcpy(buffer, &output, sizeof(*buffer)); + if (header) + header->len = htonl(output.size); return 0; }
static int cbfstool_convert_mkpayload(struct buffer *buffer, - unused uint32_t *offset, unused uint32_t *header_size) + unused uint32_t *offset, struct cbfs_file *header) { struct buffer output; int ret; @@ -267,11 +269,13 @@ static int cbfstool_convert_mkpayload(struct buffer *buffer, buffer_delete(buffer); // direct assign, no dupe. memcpy(buffer, &output, sizeof(*buffer)); + if (header) + header->len = htonl(output.size); return 0; }
static int cbfstool_convert_mkflatpayload(struct buffer *buffer, - unused uint32_t *offset, unused uint32_t *header_size) + unused uint32_t *offset, struct cbfs_file *header) { struct buffer output; if (parse_flat_binary_to_payload(buffer, &output, @@ -283,6 +287,8 @@ static int cbfstool_convert_mkflatpayload(struct buffer *buffer, buffer_delete(buffer); // direct assign, no dupe. memcpy(buffer, &output, sizeof(*buffer)); + if (header) + header->len = htonl(output.size); return 0; }