[coreboot-gerrit] New patch to review for coreboot: cbfstool: pass cbfs_file header into "compress" functions

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Tue Aug 25 16:01:21 CEST 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11325

-gerrit

commit 641ce96372a4fa310b6a6c12a3a8d71301b41ef0
Author: Patrick Georgi <patrick at 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 at georgi-clan.de>
---
 util/cbfstool/cbfstool.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index bf51956..12b3aad 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);
+	void *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, header) != 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)
+	void *header)
 {
 	struct buffer output;
 	int ret;
@@ -237,11 +237,12 @@ static int cbfstool_convert_mkstage(struct buffer *buffer, uint32_t *offset,
 	buffer_delete(buffer);
 	// direct assign, no dupe.
 	memcpy(buffer, &output, sizeof(*buffer));
+	((struct cbfs_file *)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, void *header)
 {
 	struct buffer output;
 	int ret;
@@ -267,11 +268,12 @@ static int cbfstool_convert_mkpayload(struct buffer *buffer,
 	buffer_delete(buffer);
 	// direct assign, no dupe.
 	memcpy(buffer, &output, sizeof(*buffer));
+	((struct cbfs_file *)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, void *header)
 {
 	struct buffer output;
 	if (parse_flat_binary_to_payload(buffer, &output,
@@ -283,6 +285,7 @@ static int cbfstool_convert_mkflatpayload(struct buffer *buffer,
 	buffer_delete(buffer);
 	// direct assign, no dupe.
 	memcpy(buffer, &output, sizeof(*buffer));
+	((struct cbfs_file *)header)->len = htonl(output.size);
 	return 0;
 }
 



More information about the coreboot-gerrit mailing list