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>
This commit is contained in:
parent
19c80b2391
commit
056f6a1f80
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue