lib/smbios: Improve Type9
[coreboot2.git] / src / drivers / intel / fsp1_1 / fsp_relocate.c
blob875fcf218fc559f0adbbd3b018014747c5ed5dc0
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <cbfs.h>
5 #include <cbmem.h>
6 #include <commonlib/fsp.h>
7 #include <fsp/util.h>
9 int fsp_relocate(struct prog *fsp_relocd)
11 void *fih;
12 ssize_t fih_offset;
13 size_t size;
15 void *new_loc = cbfs_cbmem_alloc(prog_name(fsp_relocd),
16 CBMEM_ID_REFCODE, &size);
17 if (new_loc == NULL) {
18 printk(BIOS_ERR, "Unable to load FSP into memory.\n");
19 return -1;
22 fih_offset = fsp1_1_relocate((uintptr_t)new_loc, new_loc, size);
24 if (fih_offset <= 0) {
25 printk(BIOS_ERR, "FSP relocation failure.\n");
26 return -1;
29 fih = (void *)((uint8_t *)new_loc + fih_offset);
31 prog_set_area(fsp_relocd, new_loc, size);
32 prog_set_entry(fsp_relocd, fih, NULL);
34 return 0;