summaryrefslogtreecommitdiff
path: root/src/soc/intel/baytrail/refcode.c
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2015-05-15 23:39:23 -0500
committerPatrick Georgi <pgeorgi@google.com>2015-06-02 14:09:31 +0200
commit899d13d0dff9e7495eb17950f19431e9bd344b2f (patch)
tree8901845fc299126a7125ff19fe1f7bde17e3f305 /src/soc/intel/baytrail/refcode.c
parent68bdd00799c7b2b25f265fa9e31beb709c877eb6 (diff)
downloadcoreboot-899d13d0dff9e7495eb17950f19431e9bd344b2f.tar.xz
cbfs: new API and better program loading
A new CBFS API is introduced to allow making CBFS access easier for providing multiple CBFS sources. That is achieved by decoupling the cbfs source from a CBFS file. A CBFS source is described by a descriptor. It contains the necessary properties for walking a CBFS to locate a file. The CBFS file is then decoupled from the CBFS descriptor in that it's no longer needed to access the contents of the file. All of this is accomplished using the regions infrastructure by repsenting CBFS sources and files as region_devices. Because region_devices can be chained together forming subregions this allows one to decouple a CBFS source from a file. This also allows one to provide CBFS files that came from other sources for payload and/or stage loading. The program loading takes advantage of those very properties by allowing multiple sources for locating a program. Because of this we can reduce the overhead of loading programs because it's all done in the common code paths. Only locating the program is per source. Change-Id: I339b84fce95f03d1dbb63a0f54a26be5eb07f7c8 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/9134 Tested-by: build bot (Jenkins) Tested-by: Raptor Engineering Automated Test Stand <noreply@raptorengineeringinc.com> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/soc/intel/baytrail/refcode.c')
-rw-r--r--src/soc/intel/baytrail/refcode.c67
1 files changed, 11 insertions, 56 deletions
diff --git a/src/soc/intel/baytrail/refcode.c b/src/soc/intel/baytrail/refcode.c
index 53da81dfc2..0c49a800a6 100644
--- a/src/soc/intel/baytrail/refcode.c
+++ b/src/soc/intel/baytrail/refcode.c
@@ -26,9 +26,6 @@
#include <program_loading.h>
#include <rmodule.h>
#include <stage_cache.h>
-#if IS_ENABLED(CONFIG_CHROMEOS)
-#include <vendorcode/google/chromeos/vboot_handoff.h>
-#endif
#include <soc/ramstage.h>
#include <soc/efi_wrapper.h>
@@ -49,58 +46,10 @@ static efi_wrapper_entry_t load_refcode_from_cache(void)
return (efi_wrapper_entry_t)prog_entry(&refcode);
}
-static void cache_refcode(const struct rmod_stage_load *rsl)
-{
- stage_cache_add(STAGE_REFCODE, rsl->prog);
-}
-
-#if IS_ENABLED(CONFIG_CHROMEOS)
-static int load_refcode_from_vboot(struct rmod_stage_load *refcode)
-{
- struct vboot_handoff *vboot_handoff;
- const struct firmware_component *fwc;
- struct cbfs_stage *stage;
-
- vboot_handoff = cbmem_find(CBMEM_ID_VBOOT_HANDOFF);
- fwc = &vboot_handoff->components[CONFIG_VBOOT_REFCODE_INDEX];
-
- if (vboot_handoff == NULL ||
- vboot_handoff->selected_firmware == VB_SELECT_FIRMWARE_READONLY ||
- CONFIG_VBOOT_REFCODE_INDEX >= MAX_PARSED_FW_COMPONENTS ||
- fwc->size == 0 || fwc->address == 0)
- return -1;
-
- printk(BIOS_DEBUG, "refcode loading from vboot rw area.\n");
- stage = (void *)(uintptr_t)fwc->address;
-
- if (rmodule_stage_load(refcode, stage)) {
- printk(BIOS_DEBUG, "Error loading reference code.\n");
- return -1;
- }
- return 0;
-}
-#else
-static int load_refcode_from_vboot(struct rmod_stage_load *refcode)
-{
- return -1;
-}
-#endif
-
-static int load_refcode_from_cbfs(struct rmod_stage_load *refcode)
-{
- printk(BIOS_DEBUG, "refcode loading from cbfs.\n");
-
- if (rmodule_stage_load_from_cbfs(refcode)) {
- printk(BIOS_DEBUG, "Error loading reference code.\n");
- return -1;
- }
-
- return 0;
-}
-
static efi_wrapper_entry_t load_reference_code(void)
{
struct prog prog = {
+ .type = PROG_REFCODE,
.name = CONFIG_CBFS_PREFIX "/refcode",
};
struct rmod_stage_load refcode = {
@@ -112,12 +61,18 @@ static efi_wrapper_entry_t load_reference_code(void)
return load_refcode_from_cache();
}
- if (load_refcode_from_vboot(&refcode) &&
- load_refcode_from_cbfs(&refcode))
- return NULL;
+ if (prog_locate(&prog)) {
+ printk(BIOS_DEBUG, "Couldn't locate reference code.\n");
+ return NULL;
+ }
+
+ if (rmodule_stage_load(&refcode)) {
+ printk(BIOS_DEBUG, "Error loading reference code.\n");
+ return NULL;
+ }
/* Cache loaded reference code. */
- cache_refcode(&refcode);
+ stage_cache_add(STAGE_REFCODE, &prog);
return prog_entry(&prog);
}