cbfstool: Use converted buffer size for do_cbfs_locate()
The whole point of moving do_cbfs_locate() later (CB:59877) was that it could use the file size that is actually going to be inserted into CBFS, rather than the on-disk file size. Unfortunately, after all that work I forgot to actually make it do that. This patch fixes that. Since there is no more use case for do_cbfs_locate() having to figure out the file size on its own, and that generally seems to be a bad idea (as the original issue shows), also remove that part of it completely and make the data_size parameter mandatory. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I1af35e8e388f78aae3593c029afcfb4e510d2b8f Reviewed-on: https://review.coreboot.org/c/coreboot/+/60084 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Raul Rangel <rrangel@chromium.org>
This commit is contained in:
parent
58ea2819ba
commit
772714d3b3
|
@ -511,11 +511,6 @@ static int do_cbfs_locate(uint32_t *cbfs_addr, size_t data_size)
|
||||||
{
|
{
|
||||||
uint32_t metadata_size = 0;
|
uint32_t metadata_size = 0;
|
||||||
|
|
||||||
if (!param.filename) {
|
|
||||||
ERROR("You need to specify -f/--filename.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!param.name) {
|
if (!param.name) {
|
||||||
ERROR("You need to specify -n/--name.\n");
|
ERROR("You need to specify -n/--name.\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -530,16 +525,9 @@ static int do_cbfs_locate(uint32_t *cbfs_addr, size_t data_size)
|
||||||
WARN("'%s' already in CBFS.\n", param.name);
|
WARN("'%s' already in CBFS.\n", param.name);
|
||||||
|
|
||||||
if (!data_size) {
|
if (!data_size) {
|
||||||
struct buffer buffer;
|
ERROR("File '%s' is empty?\n", param.name);
|
||||||
if (buffer_from_file(&buffer, param.filename) != 0) {
|
|
||||||
ERROR("Cannot load %s.\n", param.filename);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
data_size = buffer.size;
|
|
||||||
buffer_delete(&buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG("File size is %zd (0x%zx)\n", data_size, data_size);
|
|
||||||
|
|
||||||
/* Compute required page size */
|
/* Compute required page size */
|
||||||
if (param.force_pow2_pagesize) {
|
if (param.force_pow2_pagesize) {
|
||||||
|
@ -571,8 +559,8 @@ static int do_cbfs_locate(uint32_t *cbfs_addr, size_t data_size)
|
||||||
param.alignment, metadata_size);
|
param.alignment, metadata_size);
|
||||||
|
|
||||||
if (address < 0) {
|
if (address < 0) {
|
||||||
ERROR("'%s' can't fit in CBFS for page-size %#x, align %#x.\n",
|
ERROR("'%s'(%u + %zu) can't fit in CBFS for page-size %#x, align %#x.\n",
|
||||||
param.name, param.pagesize, param.alignment);
|
param.name, metadata_size, data_size, param.pagesize, param.alignment);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -917,7 +905,7 @@ static int cbfs_add_component(const char *filename,
|
||||||
|
|
||||||
/* This needs to run after convert() to take compression into account. */
|
/* This needs to run after convert() to take compression into account. */
|
||||||
if (!offset && param.alignment)
|
if (!offset && param.alignment)
|
||||||
if (do_cbfs_locate(&offset, 0))
|
if (do_cbfs_locate(&offset, buffer_size(&buffer)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* This needs to run after convert() to hash the actual final file data. */
|
/* This needs to run after convert() to hash the actual final file data. */
|
||||||
|
@ -1076,7 +1064,7 @@ static int cbfstool_convert_fsp(struct buffer *buffer,
|
||||||
if (param.stage_xip) {
|
if (param.stage_xip) {
|
||||||
if (!param.baseaddress_assigned) {
|
if (!param.baseaddress_assigned) {
|
||||||
param.alignment = 4*1024;
|
param.alignment = 4*1024;
|
||||||
if (do_cbfs_locate(offset, 0))
|
if (do_cbfs_locate(offset, buffer_size(buffer)))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
assert(!IS_HOST_SPACE_ADDRESS(*offset));
|
assert(!IS_HOST_SPACE_ADDRESS(*offset));
|
||||||
|
|
Loading…
Reference in New Issue