[coreboot-gerrit] New patch to review for coreboot: cbfstool: start moving cbfs_file header creation up the call chain

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Tue Aug 25 16:01:15 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/11320

-gerrit

commit 2e4974da46f54874ea5147ddb9de9445eee2b79c
Author: Patrick Georgi <patrick at georgi-clan.de>
Date:   Tue Aug 25 12:55:33 2015 +0200

    cbfstool: start moving cbfs_file header creation up the call chain
    
    Up to now cbfstool creates the cbfs_file header at the latest possible
    time, which is unsuitable when the idea is to add further fields to it
    that need to be configured earlier.
    
    Thus, have it ripple up the call chain.
    
    Change-Id: I7c160681c31818bc550ed2098008146043d0ee01
    Signed-off-by: Patrick Georgi <patrick at georgi-clan.de>
---
 util/cbfstool/cbfs_image.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 0fb780d..525547d 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -456,10 +456,11 @@ int cbfs_image_delete(struct cbfs_image *image)
 static int cbfs_add_entry_at(struct cbfs_image *image,
 			     struct cbfs_file *entry,
 			     uint32_t size,
-			     const char *name,
-			     uint32_t type,
+			     const char *name unused,
+			     uint32_t type unused,
 			     const void *data,
 			     uint32_t content_offset,
+			     const void *header_data,
 			     uint32_t header_size)
 {
 	struct cbfs_file *next = cbfs_find_next_entry(image, entry);
@@ -489,7 +490,7 @@ static int cbfs_add_entry_at(struct cbfs_image *image,
 	}
 
 	len = size + (content_offset - addr - header_size);
-	cbfs_create_empty_entry(entry, type, len, name);
+	memcpy(entry, header_data, header_size);
 	if (len != size) {
 		DEBUG("|..|header|content|... <use offset to create entry>\n");
 		DEBUG("before: offset=0x%x, len=0x%x\n",
@@ -609,11 +610,16 @@ 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->size, name, type,
-				      buffer->data, content_offset,
+				      buffer->data, content_offset, header,
 				      header_size) == 0) {
+			free(header);
 			return 0;
 		}
+		free(header);
 		break;
 	}
 



More information about the coreboot-gerrit mailing list