Alexandru Gagniuc (mr.nuke.me@gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13336
-gerrit
commit f692aecc92c94a6ec34aa65d68a73eac6a816279 Author: Alexandru Gagniuc alexandrux.gagniuc@intel.com Date: Tue Nov 3 16:54:43 2015 -0800
driver/intel/fsp2_0: Add utility to load an FSP binary to memory
Since FSP 2.0 is split into several binaries, implement a common function to load such binaries into memory.
Change-Id: Id4a9024163034d8f53eff6fa2f28a7078d690bdc Signed-off-by: Alexandru Gagniuc alexandrux.gagniuc@intel.com --- src/drivers/intel/fsp2_0/include/fsp/util.h | 21 ++++++++++++++++++ src/drivers/intel/fsp2_0/util.c | 34 ++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/src/drivers/intel/fsp2_0/include/fsp/util.h b/src/drivers/intel/fsp2_0/include/fsp/util.h new file mode 100644 index 0000000..abdbcf0 --- /dev/null +++ b/src/drivers/intel/fsp2_0/include/fsp/util.h @@ -0,0 +1,21 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2015 Intel Corp. + * (Written by Alexandru Gagniuc alexandrux.gagniuc@intel.com for Intel Corp.) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef _FSP2_0_UTIL_H_ +#define _FSP2_0_UTIL_H_ + +#include <fsp/info_header.h> + +/* Load an FSP binary into CBFS, and fill the associated fsp_header struct */ +enum cb_err fsp_load_binary(struct fsp_header *hdr, const char *name); + +#endif /* _FSP2_0_UTIL_H_ */ diff --git a/src/drivers/intel/fsp2_0/util.c b/src/drivers/intel/fsp2_0/util.c index e1b77a8..405021b 100644 --- a/src/drivers/intel/fsp2_0/util.c +++ b/src/drivers/intel/fsp2_0/util.c @@ -3,6 +3,7 @@ * * Copyright (C) 2015 Intel Corp. * (Written by Alexandru Gagniuc alexandrux.gagniuc@intel.com for Intel Corp.) + * (Written by Andrey Petrov andrey.petrov@intel.com for Intel Corp.) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -11,8 +12,9 @@ */
#include <arch/io.h> +#include <cbfs.h> #include <console/console.h> -#include <fsp/info_header.h> +#include <fsp/util.h> #include <lib.h> #include <string.h>
@@ -68,3 +70,33 @@ void fsp_print_header_info(const struct fsp_header *hdr) hdr->silicon_init_entry_offset, hdr->notify_phase_entry_offset); } + +enum cb_err fsp_load_binary(struct fsp_header *hdr, const char *name) +{ + struct cbfsf file_desc; + struct region_device file_data; + size_t fsp_load_size; + void *membase; + + if (cbfs_boot_locate(&file_desc, name, NULL)) { + printk(BIOS_ERR, "Could not locate %s in CBFS\n", name); + return CB_ERR; + } + + cbfs_file_data(&file_data, &file_desc); + + /* Map just enough of the file to be able to parse the header. */ + membase = rdev_mmap(&file_data, 0, FSP_HDR_OFFSET + FSP_HDR_LEN); + if (fsp_identify(hdr, membase) != CB_SUCCESS) { + printk(BIOS_ERR, "%s did not have a valid FSP header\n", name); + return CB_ERR; + } + + fsp_print_header_info(hdr); + + /* Load binary into memory. */ + fsp_load_size = MIN(hdr->image_size, file_data.region.size); + rdev_readat(&file_data, (void *)hdr->image_base, 0, fsp_load_size); + + return CB_SUCCESS; +}