summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorPatrick Georgi <patrick@georgi-clan.de>2015-08-25 15:53:52 +0200
committerPatrick Georgi <pgeorgi@google.com>2015-08-26 12:21:49 +0000
commit056f6a1f80952d91e0aa41d379ae9f08032595cf (patch)
tree24a7c8b41e8751d66ec00c39d14c935866662f25 /util
parent19c80b23914caa0162a9d76b749fc0362ad7d17e (diff)
downloadcoreboot-056f6a1f80952d91e0aa41d379ae9f08032595cf.tar.gz
coreboot-056f6a1f80952d91e0aa41d379ae9f08032595cf.tar.bz2
coreboot-056f6a1f80952d91e0aa41d379ae9f08032595cf.zip
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> Reviewed-on: http://review.coreboot.org/11325 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/cbfstool/cbfstool.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index bf51956578f8..8672362cfb93 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;
}