summaryrefslogtreecommitdiff
path: root/util/cbfstool/cbfs_image.c
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2015-11-20 21:48:18 +0100
committerAaron Durbin <adurbin@chromium.org>2016-01-06 01:12:21 +0100
commitbd0bb23838e4718f42d74b303571d0a3f73555a4 (patch)
tree3b78b809439ddf05560187780ee7df9b7e5feb8e /util/cbfstool/cbfs_image.c
parent214e4af102ff7901998dacbd08a1c98d1693d8d2 (diff)
downloadcoreboot-bd0bb23838e4718f42d74b303571d0a3f73555a4.tar.xz
cbfstool: Adapt "cbfstool copy" to only use fmap regions.
These need to go together, so the commit became a bit larger than typial. - Add an option -R for the copy source fmap region. Use: cbfstool copy -r target-region -R source-region. - Don't generate a CBFS master header because for fmap regions, we assume that the region starts with a file header. Use cbfstool add-master-header to add it afterwards, if necessary. - Don't copy files of type "cbfs master header" (which are what cbfstool add-master-header creates) - Leave room for the master header pointer - Remove -D command line option as it's no longer used. BUG=chromium:445938 BRANCH=none TEST=Manual test on image and integration test w/ bundle_firmware changes. CQ-DEPEND=CL:313770,CL:313771 Change-Id: I2a11cda42caee96aa763f162b5f3bc11bb7992f9 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/12788 Tested-by: build bot (Jenkins)
Diffstat (limited to 'util/cbfstool/cbfs_image.c')
-rw-r--r--util/cbfstool/cbfs_image.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 25aafe941d..3820c403de 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -390,31 +390,16 @@ int cbfs_image_from_buffer(struct cbfs_image *out, struct buffer *in,
int cbfs_copy_instance(struct cbfs_image *image, struct buffer *dst)
{
assert(image);
- if (!cbfs_is_legacy_cbfs(image))
- return -1;
struct cbfs_file *src_entry, *dst_entry;
- struct cbfs_header *copy_header;
- size_t align, entry_offset;
+ size_t align;
ssize_t last_entry_size;
size_t copy_end = buffer_size(dst);
- align = image->header.align;
-
- /* This will work, let's create a copy. */
- copy_header = (struct cbfs_header *)buffer_get(dst);
- cbfs_put_header(copy_header, &image->header);
+ align = CBFS_ENTRY_ALIGNMENT;
- copy_header->bootblocksize = 0;
- /* FIXME: romsize and offset have a full-flash interpretation even
- * though they don't need to and should be region-relative (where
- * region is sufficiently specified by the master header pointer.
- * But that's for a later change. */
- copy_header->romsize = htonl(dst->offset + buffer_size(dst));
- entry_offset = align_up(sizeof(*copy_header), align);
- copy_header->offset = htonl(dst->offset + entry_offset);
- dst_entry = (struct cbfs_file *)(buffer_get(dst) + entry_offset);
+ dst_entry = (struct cbfs_file *)buffer_get(dst);
/* Copy non-empty files */
for (src_entry = cbfs_find_first_entry(image);
@@ -423,6 +408,7 @@ int cbfs_copy_instance(struct cbfs_image *image, struct buffer *dst)
size_t entry_size;
if ((src_entry->type == htonl(CBFS_COMPONENT_NULL)) ||
+ (src_entry->type == htonl(CBFS_COMPONENT_CBFSHEADER)) ||
(src_entry->type == htonl(CBFS_COMPONENT_DELETED)))
continue;
@@ -438,9 +424,12 @@ int cbfs_copy_instance(struct cbfs_image *image, struct buffer *dst)
}
}
- /* Last entry size is all the room above it. */
+ /* Last entry size is all the room above it, except for top 4 bytes
+ * which may be used by the master header pointer. This messes with
+ * the ability to stash something "top-aligned" into the region, but
+ * keeps things simpler. */
last_entry_size = copy_end - ((void *)dst_entry - buffer_get(dst))
- - cbfs_calculate_file_header_size("");
+ - cbfs_calculate_file_header_size("") - sizeof(int32_t);
if (last_entry_size < 0)
WARN("No room to create the last entry!\n")