From 9360feaf5121fb0b4b2d63e3168effe066650071 Mon Sep 17 00:00:00 2001
From: Patrick Georgi <pgeorgi@google.com>
Date: Wed, 14 Mar 2018 21:11:21 +0100
Subject: smmstore: Add a key/val store facility in flash, mediated through SMM

It exposes an interface that is as generic as possible, so payloads
and/or kernels can use it for their data.

Change-Id: I9553922f9dfa60b9d4b3576973ad4b84d3fe2fb5
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/25182
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
 src/soc/intel/common/block/smm/smihandler.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

(limited to 'src/soc/intel/common')

diff --git a/src/soc/intel/common/block/smm/smihandler.c b/src/soc/intel/common/block/smm/smihandler.c
index e4c13dd4b9..f90ac578e3 100644
--- a/src/soc/intel/common/block/smm/smihandler.c
+++ b/src/soc/intel/common/block/smm/smihandler.c
@@ -27,6 +27,7 @@
 #include <intelblocks/pmclib.h>
 #include <intelblocks/smihandler.h>
 #include <intelblocks/uart.h>
+#include <smmstore.h>
 #include <soc/nvs.h>
 #include <soc/pm.h>
 #include <soc/gpio.h>
@@ -294,6 +295,27 @@ static void southbridge_smi_gsmi(
 	save_state_ops->set_reg(io_smi, RAX, ret);
 }
 
+static void southbridge_smi_store(
+	const struct smm_save_state_ops *save_state_ops)
+{
+	u8 sub_command, ret;
+	void *io_smi;
+	uint32_t reg_ebx;
+
+	io_smi = find_save_state(save_state_ops, SMMSTORE_APM_CNT);
+	if (!io_smi)
+		return;
+	/* Command and return value in EAX */
+	sub_command = (save_state_ops->get_reg(io_smi, RAX) >> 8) & 0xff;
+
+	/* Parameter buffer in EBX */
+	reg_ebx = save_state_ops->get_reg(io_smi, RBX);
+
+	/* drivers/smmstore/smi.c */
+	ret = smmstore_exec(sub_command, (void *)reg_ebx);
+	save_state_ops->set_reg(io_smi, RAX, ret);
+}
+
 static void finalize(void)
 {
 	static int finalize_done;
@@ -366,6 +388,10 @@ void smihandler_southbridge_apmc(
 		if (IS_ENABLED(CONFIG_ELOG_GSMI))
 			southbridge_smi_gsmi(save_state_ops);
 		break;
+	case SMMSTORE_APM_CNT:
+		if (IS_ENABLED(CONFIG_SMMSTORE))
+			southbridge_smi_store(save_state_ops);
+		break;
 	case APM_CNT_FINALIZE:
 		finalize();
 		break;
-- 
cgit v1.2.3