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>
diff --git a/src/drivers/smmstore/store.c b/src/drivers/smmstore/store.c
index 96cb761..e0f0f57 100644
--- a/src/drivers/smmstore/store.c
+++ b/src/drivers/smmstore/store.c
@@ -88,6 +88,30 @@
 	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
  *