cbfs: Remove locator concept
When vboot was first integrated into CBFS it was still part of Google vendorcode. So to not directly tie custom vendorcode into the core CBFS library, the concept of cbfs_locator was introduced to decouple core code from an arbitrary amount of platform-specific implementations that want to decide where the CBFS can be found. Nowadays vboot is a core coreboot feature itself, and the locator concept isn't used by anything else anymore. This patch simplifies the code by removing it and just calling vboot from the CBFS library directly. That should make it easier to more closely integrate vboot into CBFS in the future. Change-Id: I7b9112adc7b53aa218c58b8cb5c85982dcc1dbc0 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/38419 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
parent
029d67278b
commit
815611ef56
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue