Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11324
-gerrit
commit 8c97dd6b76c2c20da19d2731e11168d48fc1ab00
Author: Patrick Georgi <patrick(a)georgi-clan.de>
Date: Tue Aug 25 13:16:04 2015 +0200
cbfstool: drop size argument to cbfs_add_entry_at
It's sole use was comparing it to the header's "len" field.
Change-Id: Ic3657a709dee0d2b9288373757345a1a56124f37
Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de>
---
util/cbfstool/cbfs_image.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index acf68ce..84f4be6 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -455,7 +455,6 @@ int cbfs_image_delete(struct cbfs_image *image)
/* Tries to add an entry with its data (CBFS_SUBHEADER) at given offset. */
static int cbfs_add_entry_at(struct cbfs_image *image,
struct cbfs_file *entry,
- uint32_t size,
const void *data,
uint32_t content_offset,
const void *header_data,
@@ -502,13 +501,12 @@ static int cbfs_add_entry_at(struct cbfs_image *image,
}
// Ready to fill data into entry.
- assert(ntohl(entry->len) == size);
DEBUG("content_offset: 0x%x, entry location: %x\n",
content_offset, (int)((char*)CBFS_SUBHEADER(entry) -
image->buffer.data));
assert((char*)CBFS_SUBHEADER(entry) - image->buffer.data ==
(ptrdiff_t)content_offset);
- memcpy(CBFS_SUBHEADER(entry), data, size);
+ memcpy(CBFS_SUBHEADER(entry), data, ntohl(entry->len));
if (verbose > 1) cbfs_print_entry_info(image, entry, stderr);
// Process buffer AFTER entry.
@@ -612,7 +610,7 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer,
struct cbfs_file *header =
cbfs_create_file_header(type, buffer->size, name);
- if (cbfs_add_entry_at(image, entry, buffer->size,
+ if (cbfs_add_entry_at(image, entry,
buffer->data, content_offset, header,
header_size) == 0) {
free(header);
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11323
-gerrit
commit 02c6a52c91cb9abc60a85ec8b792ce60568cc15d
Author: Patrick Georgi <patrick(a)georgi-clan.de>
Date: Tue Aug 25 13:11:28 2015 +0200
cbfstool: cut down on the debug output
Change-Id: I9a0aad42e4eb67a07c939d7cfa0d2d80838412bb
Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de>
---
util/cbfstool/cbfs_image.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index a08bb2f..acf68ce 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -495,12 +495,10 @@ static int cbfs_add_entry_at(struct cbfs_image *image,
* to file data.
*/
DEBUG("|..|header|content|... <use offset to create entry>\n");
- DEBUG("before: offset=0x%x, len=0x%x\n",
- ntohl(entry->offset), ntohl(entry->len));
+ DEBUG("before: offset=0x%x\n", ntohl(entry->offset));
// TODO reset expanded name buffer to 0xFF.
entry->offset = htonl(ntohl(entry->offset) + len);
- DEBUG("after: offset=0x%x, len=0x%x\n",
- ntohl(entry->offset), ntohl(entry->len));
+ DEBUG("after: offset=0x%x\n", ntohl(entry->len));
}
// Ready to fill data into entry.
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11322
-gerrit
commit 5897ac4d8aca1131f4165c3a64cfc212aa88c80b
Author: Patrick Georgi <patrick(a)georgi-clan.de>
Date: Tue Aug 25 13:00:04 2015 +0200
cbfstool: Don't patch cbfs_file->len, it's already set correctly
->len used to be set to the file data length plus the size of the
padding used for the cbfs_file header. This isn't the case anymore,
so no patching of this field is necessary anymore.
->offset still needs to be patched in that case because its final
value can only be determined when the file's actual location is known.
Change-Id: I1037885f81b4ed3b68898dd7d0e515cf7a9c90a8
Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de>
---
util/cbfstool/cbfs_image.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 8662158..a08bb2f 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -487,15 +487,18 @@ static int cbfs_add_entry_at(struct cbfs_image *image,
addr = cbfs_get_entry_addr(image, entry);
}
- len = size + (content_offset - addr - header_size);
+ len = content_offset - addr - header_size;
memcpy(entry, header_data, header_size);
- if (len != size) {
+ if (len != 0) {
+ /* the header moved backwards a bit to accomodate cbfs_file
+ * alignment requirements, so patch up ->offset to still point
+ * to file data.
+ */
DEBUG("|..|header|content|... <use offset to create entry>\n");
DEBUG("before: offset=0x%x, len=0x%x\n",
ntohl(entry->offset), ntohl(entry->len));
// TODO reset expanded name buffer to 0xFF.
- entry->offset = htonl(ntohl(entry->offset) + (len - size));
- entry->len = htonl(size);
+ entry->offset = htonl(ntohl(entry->offset) + len);
DEBUG("after: offset=0x%x, len=0x%x\n",
ntohl(entry->offset), ntohl(entry->len));
}
Patrick Georgi (pgeorgi(a)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(a)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(a)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;
}