smmstorev2: Load the communication buffer at SMM setup

This removes the runtime SMI call to set up the communication buffer
for SMMSTORE in favor of setting this buffer up during the installation
of the smihandler.

The reason is that it's less code in the handler and a time costly SMI
is also avoided in ramstage.

Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Change-Id: I94dce77711f37f87033530f5ae48cb850a39341b
Reviewed-on: https://review.coreboot.org/c/coreboot/+/79738
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Rudolph <patrick.rudolph@9elements.com>
diff --git a/src/drivers/smmstore/store.c b/src/drivers/smmstore/store.c
index bc3dcdc..fd9cdf5 100644
--- a/src/drivers/smmstore/store.c
+++ b/src/drivers/smmstore/store.c
@@ -1,11 +1,12 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
 #include <boot_device.h>
-#include <fmap.h>
-#include <fmap_config.h>
 #include <commonlib/helpers.h>
 #include <commonlib/region.h>
 #include <console/console.h>
+#include <cpu/x86/smm.h>
+#include <fmap.h>
+#include <fmap_config.h>
 #include <smmstore.h>
 #include <types.h>
 
@@ -283,14 +284,10 @@
 
 /* Implementation of Version 2 */
 
-static bool store_initialized;
 static struct region_device mdev_com_buf;
 
 static int smmstore_rdev_chain(struct region_device *rdev)
 {
-	if (!store_initialized)
-		return -1;
-
 	return rdev_chain_full(rdev, &mdev_com_buf);
 }
 
@@ -303,13 +300,11 @@
 	if (!buf || len < SMM_BLOCK_SIZE)
 		return -1;
 
-	if (store_initialized)
+	if (smm_points_to_smram(buf, len))
 		return -1;
 
 	rdev_chain_mem_rw(&mdev_com_buf, buf, len);
 
-	store_initialized = true;
-
 	return 0;
 }