Vladimir Serbinenko has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/81899?usp=email )
Change subject: libpayload: Support choosing fmap partitions ......................................................................
libpayload: Support choosing fmap partitions
Change-Id: Ie191b7003a2d9a2220bc27712ea9cb9434cf8d28 Signed-off-by: Vladimir Serbinenko phcoder@gmail.com --- M payloads/libpayload/include/cbfs.h M payloads/libpayload/libcbfs/cbfs.c 2 files changed, 24 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/99/81899/1
diff --git a/payloads/libpayload/include/cbfs.h b/payloads/libpayload/include/cbfs.h index 9420cb0..382eed6 100644 --- a/payloads/libpayload/include/cbfs.h +++ b/payloads/libpayload/include/cbfs.h @@ -45,6 +45,7 @@
void *_cbfs_unverified_area_load(const char *area, const char *name, void *buf, size_t *size_inout); +enum cb_err _cbfs_choose_fmap_partition(const char *fmapname);
/********************************************************************************************** * INLINE IMPLEMENTATIONS * diff --git a/payloads/libpayload/libcbfs/cbfs.c b/payloads/libpayload/libcbfs/cbfs.c index 0cee914..bd61bc2 100644 --- a/payloads/libpayload/libcbfs/cbfs.c +++ b/payloads/libpayload/libcbfs/cbfs.c @@ -13,6 +13,26 @@ #include <lzma.h> #include <string.h> #include <sysinfo.h> +#include <fmap.h> + +static struct cbfs_boot_device chosen_bootdevice; +static int has_chosen_bootdevice; + +enum cb_err _cbfs_choose_fmap_partition(const char *fmapname) +{ + size_t offset; + size_t size; + enum cb_err err = fmap_locate_area(fmapname, &offset, &size); + + if (err) + return err; + + chosen_bootdevice.dev.offset = offset; + chosen_bootdevice.dev.size = size; + has_chosen_bootdevice = 1; + + return 0; +}
static const struct cbfs_boot_device *cbfs_get_boot_device(bool force_ro) @@ -21,6 +41,9 @@ static struct cbfs_boot_device rw;
if (!force_ro) { + if (has_chosen_bootdevice) { + return &chosen_bootdevice; + } if (!rw.dev.size) { rw.dev.offset = lib_sysinfo.cbfs_offset; rw.dev.size = lib_sysinfo.cbfs_size;