summaryrefslogtreecommitdiff
path: root/util/cbfstool/cbfstool.c
diff options
context:
space:
mode:
authorPatrick Georgi <patrick@georgi-clan.de>2015-08-25 13:48:10 +0200
committerPatrick Georgi <pgeorgi@google.com>2015-08-26 12:22:14 +0000
commit3ba501b86daaec299e9bf5b4e13934036ea5f696 (patch)
tree9878df17e75f5788f2ac829ff5d683f6c15d13c9 /util/cbfstool/cbfstool.c
parent056f6a1f80952d91e0aa41d379ae9f08032595cf (diff)
cbfstool: move cbfs_file header creation further up the call chain
The header is now created before the "converters" are run. Adding new capabilities (and fields to the header) will happen there, so we're close. Change-Id: I0556df724bd93816b435efff7d931293dbed918f Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/11326 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util/cbfstool/cbfstool.c')
-rw-r--r--util/cbfstool/cbfstool.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 8672362cfb..abb812a8c5 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -123,6 +123,7 @@ static int cbfs_add_integer_component(const char *name,
uint32_t offset,
uint32_t headeroffset) {
struct cbfs_image image;
+ struct cbfs_file *header = NULL;
struct buffer buffer;
int i, ret = 1;
@@ -151,8 +152,11 @@ static int cbfs_add_integer_component(const char *name,
offset = convert_to_from_top_aligned(param.image_region,
-offset);
+ header = cbfs_create_file_header(CBFS_COMPONENT_RAW,
+ buffer.size, name);
+ uint32_t header_size = cbfs_calculate_file_header_size(name);
if (cbfs_add_entry(&image, &buffer, name, CBFS_COMPONENT_RAW,
- offset, 0) != 0) {
+ offset, header, header_size) != 0) {
ERROR("Failed to add %llu into ROM image as '%s'.\n",
(long long unsigned)u64val, name);
goto done;
@@ -161,6 +165,7 @@ static int cbfs_add_integer_component(const char *name,
ret = 0;
done:
+ free(header);
buffer_delete(&buffer);
return ret;
}
@@ -202,9 +207,11 @@ static int cbfs_add_component(const char *filename,
return 1;
}
+ struct cbfs_file *header =
+ cbfs_create_file_header(type, buffer.size, name);
uint32_t header_size = cbfs_calculate_file_header_size(name);
- if (convert && convert(&buffer, &offset, NULL) != 0) {
+ if (convert && convert(&buffer, &offset, header) != 0) {
ERROR("Failed to parse file '%s'.\n", filename);
buffer_delete(&buffer);
return 1;
@@ -214,13 +221,16 @@ static int cbfs_add_component(const char *filename,
offset = convert_to_from_top_aligned(param.image_region,
-offset);
- if (cbfs_add_entry(&image, &buffer, name, type, offset, header_size)
+ if (cbfs_add_entry(&image, &buffer, name, type, offset,
+ header, header_size)
!= 0) {
ERROR("Failed to add '%s' into ROM image.\n", filename);
+ free(header);
buffer_delete(&buffer);
return 1;
}
+ free(header);
buffer_delete(&buffer);
return 0;
}