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>
This commit is contained in:
parent
3432e556f5
commit
dd2d3f933a
|
@ -546,7 +546,7 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer,
|
||||||
uint32_t entry_type;
|
uint32_t entry_type;
|
||||||
uint32_t addr, addr_next;
|
uint32_t addr, addr_next;
|
||||||
struct cbfs_file *entry, *next;
|
struct cbfs_file *entry, *next;
|
||||||
uint32_t need_size, new_size;
|
uint32_t need_size;
|
||||||
|
|
||||||
if (header_size == 0)
|
if (header_size == 0)
|
||||||
header_size = cbfs_calculate_file_header_size(name);
|
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
|
// TODO there are more few tricky cases that we may
|
||||||
// want to fit by altering offset.
|
// want to fit by altering offset.
|
||||||
|
|
||||||
// Can we simply put object here?
|
if (content_offset == 0) {
|
||||||
if (!content_offset || content_offset == addr + header_size) {
|
// we tested every condition earlier under which
|
||||||
DEBUG("Filling new entry data (%zd bytes).\n",
|
// placing the file there might fail
|
||||||
buffer->size);
|
content_offset = addr + header_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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG("section 0x%x+0x%x for content_offset 0x%x.\n",
|
DEBUG("section 0x%x+0x%x for content_offset 0x%x.\n",
|
||||||
|
|
Loading…
Reference in New Issue