summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2015-08-12 12:29:20 +0200
committerPatrick Georgi <pgeorgi@google.com>2015-08-13 16:10:53 +0200
commitdd2d3f933a45a2fa48af344bd8ab50bb06c212de (patch)
treece416889b8c36b9302db5afbde917012371bab5b /util
parent3432e556f548c0e61c714b880ce04bf1f3f687bd (diff)
downloadcoreboot-dd2d3f933a45a2fa48af344bd8ab50bb06c212de.tar.xz
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@google.com> Reviewed-on: http://review.coreboot.org/11222 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/cbfstool/cbfs_image.c37
1 files changed, 5 insertions, 32 deletions
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 19281eeaaa..7d6239ac86 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",