summaryrefslogtreecommitdiff
path: root/src/cpu/x86/smi_trigger.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu/x86/smi_trigger.c')
-rw-r--r--src/cpu/x86/smi_trigger.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/cpu/x86/smi_trigger.c b/src/cpu/x86/smi_trigger.c
new file mode 100644
index 0000000000..e4c6dc9417
--- /dev/null
+++ b/src/cpu/x86/smi_trigger.c
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <arch/io.h>
+#include <console/console.h>
+#include <cpu/x86/smm.h>
+
+static void apmc_log(const char *fn, u8 cmd)
+{
+ switch (cmd) {
+ case APM_CNT_ACPI_DISABLE:
+ printk(BIOS_DEBUG, "%s: Disabling ACPI.\n", fn);
+ break;
+ case APM_CNT_ACPI_ENABLE:
+ printk(BIOS_DEBUG, "%s: Enabling ACPI.\n", fn);
+ break;
+ case APM_CNT_FINALIZE:
+ printk(BIOS_DEBUG, "%s: Finalizing SMM.\n", fn);
+ break;
+ case APM_CNT_ELOG_GSMI:
+ break;
+ case APM_CNT_SMMSTORE:
+ break;
+ case APM_CNT_SMMINFO:
+ break;
+ default:
+ printk(BIOS_DEBUG, "%s: Unknown APMC 0x%02x.\n", fn, cmd);
+ break;
+ }
+}
+
+int apm_control(u8 cmd)
+{
+ /* Never proceed inside SMI handler or without one. */
+ if (ENV_SMM || !CONFIG(HAVE_SMI_HANDLER))
+ return -1;
+
+ apmc_log(__func__, cmd);
+
+ /* Now raise the SMI. */
+ outb(cmd, APM_CNT);
+
+ printk(BIOS_DEBUG, "APMC done.\n");
+ return 0;
+}
+
+u8 apm_get_apmc(void)
+{
+ /* Emulate B2 register as the FADT / Linux expects it */
+ u8 cmd = inb(APM_CNT);
+
+ apmc_log("SMI#", cmd);
+ return cmd;
+}