Vladimir Serbinenko has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/81507?usp=email )
Change subject: Support smmstore in RW_LEGACY ......................................................................
Support smmstore in RW_LEGACY
When creating hybrid image with dual-boot we can't add a new fmap for smmstore. Use a file in RW_LEGACY instead
Change-Id: I86a617782f187adcce4429ea41ac40a9df58d6d3 Signed-off-by: Vladimir Serbinenko phcoder@gmail.com --- M src/drivers/smmstore/store.c 1 file changed, 26 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/07/81507/1
diff --git a/src/drivers/smmstore/store.c b/src/drivers/smmstore/store.c index bc3dcdc..e7b8b48 100644 --- a/src/drivers/smmstore/store.c +++ b/src/drivers/smmstore/store.c @@ -8,16 +8,21 @@ #include <console/console.h> #include <smmstore.h> #include <types.h> +#include <commonlib/bsd/cbfs_private.h>
#define SMMSTORE_REGION "SMMSTORE"
+#ifdef FMAP_SECTION_SMMSTORE_START + _Static_assert(IS_ALIGNED(FMAP_SECTION_SMMSTORE_START, SMM_BLOCK_SIZE), "SMMSTORE FMAP region not aligned to 64K");
_Static_assert(SMM_BLOCK_SIZE <= FMAP_SECTION_SMMSTORE_SIZE, "SMMSTORE FMAP region must be at least 64K");
+#endif + /* * The region format is still not finalized, but so far it looks like this: * ( @@ -42,14 +47,26 @@
static enum cb_err lookup_store_region(struct region *region) { - if (fmap_locate_area(SMMSTORE_REGION, region)) { - printk(BIOS_WARNING, - "smm store: Unable to find SMM store FMAP region '%s'\n", - SMMSTORE_REGION); - return CB_ERR; + struct region rw_legacy; + struct region_device rw_legacy_rdev; + union cbfs_mdata mdata; + size_t data_offset; + + if (fmap_locate_area(SMMSTORE_REGION, region) == 0) + return CB_SUCCESS; + + if (fmap_locate_area("RW_LEGACY", &rw_legacy) == 0 + && boot_device_ro_subregion(&rw_legacy, &rw_legacy_rdev) == 0 + && cbfs_lookup(&rw_legacy_rdev, "smmstore.bin", &mdata, &data_offset, NULL) == 0) { + region->offset = rw_legacy.offset + data_offset; + region->size = be32toh(mdata.h.len); + return CB_SUCCESS; }
- return CB_SUCCESS; + printk(BIOS_WARNING, + "smm store: Unable to find SMM store FMAP region '%s'\n", + SMMSTORE_REGION); + return CB_ERR; }
/* @@ -99,7 +116,9 @@
done = 1;
- if (fmap_locate_area_as_rdev_rw(SMMSTORE_REGION, &rdev)) { + struct region ar; + + if (lookup_store_region(&ar) || boot_device_rw_subregion(&ar, &rdev)) { printk(BIOS_WARNING, "smm store: Unable to find SMM store FMAP region '%s'\n", SMMSTORE_REGION);