fsp2_0: Replace fspld->get_destination() callback with CBFS allocator

The Intel FSP 2.0 driver contains a custom construct that basically
serves the same purpose as the new CBFS allocator concept: a callback
function to customize placement of a loaded CBFS file whose size is
initially unknown. This patch removes the existing implementation and
replaces it with a CBFS allocator.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: I0b7b446a0d2af87ec337fb80ad54f2d404e69668
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52082
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Julius Werner
2021-03-10 17:25:01 -08:00
parent 4676ec52c2
commit 8205ce6b34
4 changed files with 27 additions and 89 deletions

View File

@ -139,65 +139,24 @@ static inline bool fspm_xip(void)
return false;
}
static void *fsp_get_dest_and_load(struct fsp_load_descriptor *fspld, size_t size,
const struct region_device *source_rdev,
uint32_t compression_algo)
{
void *dest;
if (fspld->get_destination(fspld, &dest, size, source_rdev) < 0) {
printk(BIOS_ERR, "FSP Destination not obtained.\n");
return NULL;
}
/* Don't load when executing in place. */
if (fspm_xip())
return dest;
if (cbfs_load_and_decompress(source_rdev, 0, region_device_sz(source_rdev),
dest, size, compression_algo) != size) {
printk(BIOS_ERR, "Failed to load FSP component.\n");
return NULL;
}
/* Don't allow FSP-M relocation. */
if (fspm_env())
return dest;
if (fsp_component_relocate((uintptr_t)dest, dest, size) < 0) {
printk(BIOS_ERR, "Unable to relocate FSP component!\n");
return NULL;
}
return dest;
}
/* Load the FSP component described by fsp_load_descriptor from cbfs. The FSP
* header object will be validated and filled in on successful load. */
enum cb_err fsp_load_component(struct fsp_load_descriptor *fspld, struct fsp_header *hdr)
{
struct cbfsf file_desc;
uint32_t compression_algo;
size_t output_size;
void *dest;
struct region_device source_rdev, prog_rdev;
struct region_device prog_rdev;
struct prog *fsp_prog = &fspld->fsp_prog;
if (fspld->get_destination == NULL)
dest = cbfs_alloc(prog_name(fsp_prog), fspld->alloc, fspld, &output_size);
if (!dest)
return CB_ERR;
if (cbfs_boot_locate(&file_desc, prog_name(fsp_prog), &fsp_prog->cbfs_type) < 0)
return CB_ERR;
if (cbfsf_decompression_info(&file_desc, &compression_algo, &output_size) < 0)
return CB_ERR;
cbfs_file_data(&source_rdev, &file_desc);
dest = fsp_get_dest_and_load(fspld, output_size, &source_rdev, compression_algo);
if (dest == NULL)
/* Don't allow FSP-M relocation. */
if (!fspm_env() && fsp_component_relocate((uintptr_t)dest, dest, output_size) < 0) {
printk(BIOS_ERR, "Unable to relocate FSP component!\n");
return CB_ERR;
}
prog_set_area(fsp_prog, dest, output_size);