summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/cbfs.h30
-rw-r--r--src/lib/cbfs.c59
-rw-r--r--src/security/vboot/vboot_common.h2
-rw-r--r--src/security/vboot/vboot_loader.c7
4 files changed, 7 insertions, 91 deletions
diff --git a/src/include/cbfs.h b/src/include/cbfs.h
index 7a984b8570..2d16aa761a 100644
--- a/src/include/cbfs.h
+++ b/src/include/cbfs.h
@@ -59,36 +59,8 @@ size_t cbfs_prog_stage_section(struct prog *pstage, uintptr_t *base);
/* Load stage into memory filling in prog. Return 0 on success. < 0 on error. */
int cbfs_prog_stage_load(struct prog *prog);
-/*****************************************************************
- * Support structures and functions. Direct field access should *
- * only be done by implementers of cbfs regions -- Not the above *
- * API. *
- *****************************************************************/
-
-/* The cbfs_props struct describes the properties associated with a CBFS. */
-struct cbfs_props {
- /* CBFS starts at the following offset within the boot region. */
- size_t offset;
- /* CBFS size. */
- size_t size;
-};
-
-/* Default CBFS locator .locate() callback that locates "COREBOOT" region. This
- function is exposed to reduce code duplication in other parts of the code
- base. To obtain the correct region device the selection process is required
- by way of cbfs_boot_region_device(). */
-int cbfs_default_region_device(struct region_device *rdev);
-
-/* Select the boot region device from the cbfs locators.
+/* Returns the region device of the currently active CBFS.
Return < 0 on error, 0 on success. */
int cbfs_boot_region_device(struct region_device *rdev);
-/* Object used to identify location of current cbfs to use for cbfs_boot_*
- * operations. It's used by cbfs_boot_region_properties(). */
-struct cbfs_locator {
- const char *name;
- /* Returns 0 on successful fill of cbfs properties. */
- int (*locate)(struct region_device *rdev);
-};
-
#endif
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index 636ff70de8..e31c7cc925 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -27,6 +27,7 @@
#include <timestamp.h>
#include <fmap.h>
#include <security/vboot/vboot_crtm.h>
+#include <security/vboot/vboot_common.h>
#define ERROR(x...) printk(BIOS_ERR, "CBFS: " x)
#define LOG(x...) printk(BIOS_INFO, "CBFS: " x)
@@ -279,63 +280,9 @@ out:
return 0;
}
-/* The default locator to find the CBFS in the "COREBOOT" FMAP region. */
-int cbfs_default_region_device(struct region_device *rdev)
-{
- if (fmap_locate_area_as_rdev("COREBOOT", rdev))
- return -1;
-
- printk(BIOS_SPEW, "CBFS @ %zx size %zx\n",
- region_device_offset(rdev), region_device_sz(rdev));
-
- return 0;
-}
-
-/* This struct is marked as weak to allow a particular platform to
- * override the master header logic. This implementation should work for most
- * devices. */
-const struct cbfs_locator __weak cbfs_default_locator = {
- .name = "COREBOOT Locator",
- .locate = cbfs_default_region_device,
-};
-
-extern const struct cbfs_locator vboot_locator;
-
-static const struct cbfs_locator *locators[] = {
-#if CONFIG(VBOOT)
- /*
- * NOTE: Does not link in SMM, as the vboot_locator isn't compiled.
- * ATM there's no need for VBOOT functionality in SMM and it's not
- * a problem.
- */
- &vboot_locator,
-#endif
- &cbfs_default_locator,
-};
-
int cbfs_boot_region_device(struct region_device *rdev)
{
- int i;
-
boot_device_init();
-
- for (i = 0; i < ARRAY_SIZE(locators); i++) {
- const struct cbfs_locator *ops;
-
- ops = locators[i];
-
- if (ops->locate == NULL)
- continue;
-
- if (ops->locate(rdev))
- continue;
-
- LOG("'%s' located CBFS at [%zx:%zx)\n",
- ops->name, region_device_offset(rdev),
- region_device_end(rdev));
-
- return 0;
- }
-
- return -1;
+ return vboot_locate_cbfs(rdev) &&
+ fmap_locate_area_as_rdev("COREBOOT", rdev);
}
diff --git a/src/security/vboot/vboot_common.h b/src/security/vboot/vboot_common.h
index d296574eaf..976c26a70b 100644
--- a/src/security/vboot/vboot_common.h
+++ b/src/security/vboot/vboot_common.h
@@ -71,6 +71,7 @@ int vboot_recovery_mode_enabled(void);
int vboot_recovery_mode_memory_retrain(void);
int vboot_can_enable_udc(void);
void vboot_run_logic(void);
+int vboot_locate_cbfs(struct region_device *rdev);
#else /* !CONFIG_VBOOT */
static inline int vboot_developer_mode_enabled(void) { return 0; }
static inline int vboot_recovery_mode_enabled(void) { return 0; }
@@ -78,6 +79,7 @@ static inline int vboot_recovery_mode_memory_retrain(void) { return 0; }
/* If VBOOT is not enabled, we are okay enabling USB device controller (UDC). */
static inline int vboot_can_enable_udc(void) { return 1; }
static inline void vboot_run_logic(void) {}
+static inline int vboot_locate_cbfs(struct region_device *rdev) { return -1; }
#endif
void vboot_save_nvdata_only(struct vb2_context *ctx);
diff --git a/src/security/vboot/vboot_loader.c b/src/security/vboot/vboot_loader.c
index b72c82ba4a..7e637759ce 100644
--- a/src/security/vboot/vboot_loader.c
+++ b/src/security/vboot/vboot_loader.c
@@ -70,7 +70,7 @@ void vboot_run_logic(void)
}
}
-static int vboot_locate(struct region_device *rdev)
+int vboot_locate_cbfs(struct region_device *rdev)
{
struct vb2_context *ctx;
@@ -85,8 +85,3 @@ static int vboot_locate(struct region_device *rdev)
return vboot_locate_firmware(ctx, rdev);
}
-
-const struct cbfs_locator vboot_locator = {
- .name = "VBOOT",
- .locate = vboot_locate,
-};