the following patch was just integrated into master:
commit f82049793890cf615e7f7604720f3f8603aced87
Author: Patrick Georgi <pgeorgi(a)google.com>
Date: Tue Aug 11 15:16:24 2015 +0200
cbfstool: allow file data converters to modify the header size
The idea is that they can at some point add extended attributes to the header.
That also needs to be passed, but let's start simple.
Change-Id: I80359843078b149ac433ee3d739ea192592e16e7
Signed-off-by: Patrick Georgi <pgeorgi(a)google.com>
Reviewed-on: http://review.coreboot.org/11216
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin(a)chromium.org>
See http://review.coreboot.org/11216 for details.
-gerrit
the following patch was just integrated into master:
commit 4110abca7213b926b6fa08e6b0f6f613ebb7c264
Author: Patrick Georgi <pgeorgi(a)google.com>
Date: Tue Aug 11 15:10:33 2015 +0200
cbfstool: calculate header size in cbfs_add_component()
It will at some point create the header, and pass it with its size. We can
start with the size already.
Change-Id: I8f26b2335ffab99a664d1ff7bc88e33ed62cf9ca
Signed-off-by: Patrick Georgi <pgeorgi(a)google.com>
Reviewed-on: http://review.coreboot.org/11215
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin(a)chromium.org>
See http://review.coreboot.org/11215 for details.
-gerrit
the following patch was just integrated into master:
commit 11ee08f1f1505eca3589abefbf9484083cd05a19
Author: Patrick Georgi <pgeorgi(a)google.com>
Date: Tue Aug 11 15:10:02 2015 +0200
cbfstool: expose cbfs_calculate_file_header_size()
Headers vary in size soon, and more places need to be able to calculate their
size.
Change-Id: I30761bb9da0756418993dee21d8fa18cf3174c40
Signed-off-by: Patrick Georgi <pgeorgi(a)google.com>
Reviewed-on: http://review.coreboot.org/11214
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin(a)chromium.org>
See http://review.coreboot.org/11214 for details.
-gerrit
the following patch was just integrated into master:
commit e60b55a570a3bb9bf75bd344ef41460454abaef2
Author: Patrick Georgi <pgeorgi(a)google.com>
Date: Tue Aug 11 14:54:24 2015 +0200
cbfstool: allow passing a precalculated header size into cbfs_add_entry()
This is in preparation of creating the cbfs_file header much earlier
in the process. For now, size is enough because lots of things need to
move before it makes sense to deal with cbfs_file at a higher level.
Change-Id: I47589247c3011cb828170eaa10ef4a1e0f85ab84
Signed-off-by: Patrick Georgi <pgeorgi(a)google.com>
Reviewed-on: http://review.coreboot.org/11213
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin(a)chromium.org>
See http://review.coreboot.org/11213 for details.
-gerrit
the following patch was just integrated into master:
commit 4e54bf93345332fc866b6b8b798a99248edb0698
Author: Patrick Georgi <pgeorgi(a)google.com>
Date: Tue Aug 11 14:35:39 2015 +0200
cbfstool: test for duplicate files earlier
No need to read the file before bailing out.
Change-Id: Ida7226c6ec227e1105724cdb1e5a0927217a69c7
Signed-off-by: Patrick Georgi <pgeorgi(a)google.com>
Reviewed-on: http://review.coreboot.org/11212
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin(a)chromium.org>
See http://review.coreboot.org/11212 for details.
-gerrit
the following patch was just integrated into master:
commit c6a8da7f93160b5c853619e203dcfc9d5ba4a553
Author: Patrick Georgi <pgeorgi(a)chromium.org>
Date: Wed Jul 22 21:32:03 2015 +0200
cbfstool: add cbfs file attribute structure
This is a generic structure, not unlike the cbtables design, based on which we
can build specialized TLV data structures.
Change-Id: I98a75eef19f049ad67d46cdc2790949dcd155797
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
Reviewed-on: http://review.coreboot.org/10937
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin(a)chromium.org>
See http://review.coreboot.org/10937 for details.
-gerrit
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11222
-gerrit
commit 61406378f971a8cefb8c09711111d0903341f44c
Author: Patrick Georgi <pgeorgi(a)google.com>
Date: Wed Aug 12 12:29:20 2015 +0200
cbfstool: unify actual file creation
After the preparation in earlier commits, it is now possible to handle the
more general case of position independent files using the special code path
for fixed location files.
This leads to a single place where non-empty cbfs file headers are actually
written into the image, allowing us to move it up the chain more easily.
Change-Id: I8c1fca5e4e81c20971b2960c87690e982aa3e274
Signed-off-by: Patrick Georgi <pgeorgi(a)google.com>
---
util/cbfstool/cbfs_image.c | 37 +++++--------------------------------
1 file changed, 5 insertions(+), 32 deletions(-)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 19281ee..7d6239a 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -546,7 +546,7 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer,
uint32_t entry_type;
uint32_t addr, addr_next;
struct cbfs_file *entry, *next;
- uint32_t need_size, new_size;
+ uint32_t need_size;
if (header_size == 0)
header_size = cbfs_calculate_file_header_size(name);
@@ -600,37 +600,10 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer,
// TODO there are more few tricky cases that we may
// want to fit by altering offset.
- // Can we simply put object here?
- if (!content_offset || content_offset == addr + header_size) {
- DEBUG("Filling new entry data (%zd bytes).\n",
- buffer->size);
- cbfs_create_empty_entry(entry, type, buffer->size, name);
- memcpy(CBFS_SUBHEADER(entry), buffer->data, buffer->size);
- if (verbose)
- cbfs_print_entry_info(image, entry, stderr);
-
- // setup new entry
- DEBUG("Setting new empty entry.\n");
- entry = cbfs_find_next_entry(image, entry);
- new_size = (cbfs_get_entry_addr(image, next) -
- cbfs_get_entry_addr(image, entry));
-
- /* Entry was added and no space for new "empty" entry */
- if (new_size < cbfs_calculate_file_header_size("")) {
- DEBUG("No need for new \"empty\" entry\n");
- /* No need to increase the size of the just
- * stored file to extend to next file. Alignment
- * of next file takes care of this.
- */
- return 0;
- }
- new_size -= cbfs_calculate_file_header_size("");
- DEBUG("new size: %d\n", new_size);
- cbfs_create_empty_entry(entry, CBFS_COMPONENT_NULL,
- new_size, "");
- if (verbose)
- cbfs_print_entry_info(image, entry, stderr);
- return 0;
+ if (content_offset == 0) {
+ // we tested every condition earlier under which
+ // placing the file there might fail
+ content_offset = addr + header_size;
}
DEBUG("section 0x%x+0x%x for content_offset 0x%x.\n",
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11221
-gerrit
commit c69f876b62269edd456f058a0e8e2e236aebe881
Author: Patrick Georgi <pgeorgi(a)google.com>
Date: Wed Aug 12 12:05:21 2015 +0200
cbfstool: move tests for fixed-location files earlier
... and the assert is gone.
The actual action of adding a just-right file can be moved after the tests
since it's exactly the condition those tests don't continue or break on.
Change-Id: I6d0e829e0158198301136ada9a0de2f168ceee3f
Signed-off-by: Patrick Georgi <pgeorgi(a)google.com>
---
util/cbfstool/cbfs_image.c | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 1a20fba..19281ee 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -580,6 +580,26 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer,
if (addr + need_size > addr_next)
continue;
+ // Test for complicated cases
+ if (content_offset > 0) {
+ if (addr_next < content_offset) {
+ DEBUG("Not for specified offset yet");
+ continue;
+ } else if (addr > content_offset) {
+ DEBUG("Exceed specified content_offset.");
+ break;
+ } else if (addr + header_size > content_offset) {
+ ERROR("Not enough space for header.\n");
+ break;
+ } else if (content_offset + buffer->size > addr_next) {
+ ERROR("Not enough space for content.\n");
+ break;
+ }
+ }
+
+ // TODO there are more few tricky cases that we may
+ // want to fit by altering offset.
+
// Can we simply put object here?
if (!content_offset || content_offset == addr + header_size) {
DEBUG("Filling new entry data (%zd bytes).\n",
@@ -613,27 +633,6 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer,
return 0;
}
- // We need to put content here, and the case is really
- // complicated...
- assert(content_offset);
- if (content_offset > 0) {
- if (addr_next < content_offset) {
- DEBUG("Not for specified offset yet");
- continue;
- } else if (addr > content_offset) {
- DEBUG("Exceed specified content_offset.");
- break;
- } else if (addr + header_size > content_offset) {
- ERROR("Not enough space for header.\n");
- break;
- } else if (content_offset + buffer->size > addr_next) {
- ERROR("Not enough space for content.\n");
- break;
- }
- }
-
- // TODO there are more few tricky cases that we may
- // want to fit by altering offset.
DEBUG("section 0x%x+0x%x for content_offset 0x%x.\n",
addr, addr_next - addr, content_offset);
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11220
-gerrit
commit e7b011b9611dd5199aaf4203ad7f14e489a3628c
Author: Patrick Georgi <pgeorgi(a)google.com>
Date: Wed Aug 12 12:01:01 2015 +0200
cbfstool: prepare moving tests earlier
The assert() makes sure the if() holds true. But that assert won't survive for
long.
Change-Id: Iab7d2bc7bfebb3f3b3ce70dc5bd041902e14bd7a
Signed-off-by: Patrick Georgi <pgeorgi(a)google.com>
---
util/cbfstool/cbfs_image.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index ddc9cf5..1a20fba 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -616,18 +616,20 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer,
// We need to put content here, and the case is really
// complicated...
assert(content_offset);
- if (addr_next < content_offset) {
- DEBUG("Not for specified offset yet");
- continue;
- } else if (addr > content_offset) {
- DEBUG("Exceed specified content_offset.");
- break;
- } else if (addr + header_size > content_offset) {
- ERROR("Not enough space for header.\n");
- break;
- } else if (content_offset + buffer->size > addr_next) {
- ERROR("Not enough space for content.\n");
- break;
+ if (content_offset > 0) {
+ if (addr_next < content_offset) {
+ DEBUG("Not for specified offset yet");
+ continue;
+ } else if (addr > content_offset) {
+ DEBUG("Exceed specified content_offset.");
+ break;
+ } else if (addr + header_size > content_offset) {
+ ERROR("Not enough space for header.\n");
+ break;
+ } else if (content_offset + buffer->size > addr_next) {
+ ERROR("Not enough space for content.\n");
+ break;
+ }
}
// TODO there are more few tricky cases that we may
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11219
-gerrit
commit 90caf846d7ed6d5894152f4c1ed6b9933d7fff09
Author: Patrick Georgi <pgeorgi(a)google.com>
Date: Wed Aug 12 09:20:11 2015 +0200
cbfstool: factor out creating a cbfs file header
We will want to create headers that live outside the final image at some point
(eg. to build the file before we even know where to place it).
Change-Id: Ie4c0323df8d5be955aec3621b75309e8f11fae49
Signed-off-by: Patrick Georgi <pgeorgi(a)google.com>
---
util/cbfstool/cbfs_image.c | 17 +++++++++++++++--
util/cbfstool/cbfs_image.h | 5 +++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index b0c3080..ddc9cf5 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -1020,10 +1020,14 @@ int cbfs_is_valid_entry(struct cbfs_image *image, struct cbfs_file *entry)
strlen(CBFS_FILE_MAGIC));
}
-int cbfs_create_empty_entry(struct cbfs_file *entry, int type,
+struct cbfs_file *cbfs_create_file_header(int type,
size_t len, const char *name)
{
- memset(entry, CBFS_CONTENT_DEFAULT_VALUE, sizeof(*entry));
+ // assume that there won't be file names of ~1000 bytes
+ const int bufsize = 1024;
+
+ struct cbfs_file *entry = malloc(bufsize);
+ memset(entry, CBFS_CONTENT_DEFAULT_VALUE, bufsize);
memcpy(entry->magic, CBFS_FILE_MAGIC, sizeof(entry->magic));
entry->type = htonl(type);
entry->len = htonl(len);
@@ -1031,6 +1035,15 @@ int cbfs_create_empty_entry(struct cbfs_file *entry, int type,
entry->offset = htonl(cbfs_calculate_file_header_size(name));
memset(entry->filename, 0, ntohl(entry->offset) - sizeof(*entry));
strcpy(entry->filename, name);
+ return entry;
+}
+
+int cbfs_create_empty_entry(struct cbfs_file *entry, int type,
+ size_t len, const char *name)
+{
+ struct cbfs_file *tmp = cbfs_create_file_header(type, len, name);
+ memcpy(entry, tmp, ntohl(tmp->offset));
+ free(tmp);
memset(CBFS_SUBHEADER(entry), CBFS_CONTENT_DEFAULT_VALUE, len);
return 0;
}
diff --git a/util/cbfstool/cbfs_image.h b/util/cbfstool/cbfs_image.h
index ad999e3..432ea72 100644
--- a/util/cbfstool/cbfs_image.h
+++ b/util/cbfstool/cbfs_image.h
@@ -99,6 +99,11 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer,
/* Removes an entry from CBFS image. Returns 0 on success, otherwise non-zero. */
int cbfs_remove_entry(struct cbfs_image *image, const char *name);
+/* Create a new cbfs file header structure to work with.
+ Returns newly allocated memory that the caller needs to free after use. */
+struct cbfs_file *cbfs_create_file_header(int type, size_t len,
+ const char *name);
+
/* Initializes a new empty (type = NULL) entry with size and name in CBFS image.
* Returns 0 on success, otherwise (ex, not found) non-zero. */
int cbfs_create_empty_entry(struct cbfs_file *entry, int type,