summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2022-02-16 07:51:36 +0100
committerLean Sheng Tan <sheng.tan@9elements.com>2023-02-12 08:20:08 +0000
commit4e00f155921a57af32bdaaaac6a9f1e5c184488b (patch)
tree8a1e19ecff79ec6c73293cea2a9c693c81686490
parent21975e4a49ed8ee6d639808bae574b301fa3a389 (diff)
drivers/smmstore: Expose region device
Allow other drivers to use the SMMSTORE region device. Change-Id: I6316b703829590bd6f41c3d4013b4a4660b9cbab Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/62014 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
-rw-r--r--src/drivers/smmstore/Makefile.inc2
-rw-r--r--src/drivers/smmstore/store.c24
-rw-r--r--src/include/smmstore.h2
3 files changed, 27 insertions, 1 deletions
diff --git a/src/drivers/smmstore/Makefile.inc b/src/drivers/smmstore/Makefile.inc
index 6d9a9d6a2f..03f85c5130 100644
--- a/src/drivers/smmstore/Makefile.inc
+++ b/src/drivers/smmstore/Makefile.inc
@@ -1,4 +1,4 @@
-ramstage-$(CONFIG_SMMSTORE) += store.c
+all-$(CONFIG_SMMSTORE) += store.c
ifeq ($(CONFIG_SMMSTORE),y)
$(call src-to-obj,ramstage,$(dir)/store.c) : $(obj)/fmap_config.h
diff --git a/src/drivers/smmstore/store.c b/src/drivers/smmstore/store.c
index 96cb761e40..e0f0f57097 100644
--- a/src/drivers/smmstore/store.c
+++ b/src/drivers/smmstore/store.c
@@ -88,6 +88,30 @@ static int lookup_store(struct region_device *rstore)
return rdev_chain(rstore, rdev, 0, region_device_sz(rdev));
}
+ /* this function is non reentrant */
+int smmstore_lookup_region(struct region_device *rstore)
+{
+ static int done;
+ static int ret;
+ static struct region_device rdev;
+
+ if (!done) {
+
+ done = 1;
+
+ if (fmap_locate_area_as_rdev_rw(SMMSTORE_REGION, &rdev)) {
+ printk(BIOS_WARNING,
+ "smm store: Unable to find SMM store FMAP region '%s'\n",
+ SMMSTORE_REGION);
+ ret = -1;
+ } else {
+ ret = 0;
+ }
+ }
+
+ *rstore = rdev;
+ return ret;
+}
/*
* Read entire store into user provided buffer
*
diff --git a/src/include/smmstore.h b/src/include/smmstore.h
index dfd9336c4d..d3940abc3f 100644
--- a/src/include/smmstore.h
+++ b/src/include/smmstore.h
@@ -115,6 +115,8 @@ int smmstore_rawclear_region(uint32_t block_id);
#if ENV_RAMSTAGE
int smmstore_get_info(struct smmstore_params_info *info);
#endif
+struct region_device;
+int smmstore_lookup_region(struct region_device *rstore);
/* Advertise SMMSTORE v2 support */
struct lb_header;