From b6585481e8cb30ed04a1673b170af3df9e0e4320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Mon, 1 Jun 2020 15:11:14 +0300 Subject: arch/x86: Create helper for APM_CNT SMI triggers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Attempts to write to APM_CNT IO port should always be guarded with a test to verify SMI handler has been installed. Immediate followup removes redundant HAVE_SMI_HANDLER tests. Change-Id: If3fb0f1a8b32076f1d9f3fea9f817dd4b093ad98 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/41971 Reviewed-by: Angel Pons Reviewed-by: Patrick Rudolph Tested-by: build bot (Jenkins) --- src/cpu/x86/smm/Makefile.inc | 1 + src/cpu/x86/smm/smi_trigger.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/cpu/x86/smm/smi_trigger.c (limited to 'src/cpu/x86') diff --git a/src/cpu/x86/smm/Makefile.inc b/src/cpu/x86/smm/Makefile.inc index 500f169edb..dbe567a8a2 100644 --- a/src/cpu/x86/smm/Makefile.inc +++ b/src/cpu/x86/smm/Makefile.inc @@ -1,6 +1,7 @@ ## SPDX-License-Identifier: GPL-2.0-only ramstage-y += smm_module_loader.c +ramstage-y += smi_trigger.c ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) $(eval $(call create_class_compiler,smm,x86_32)) diff --git a/src/cpu/x86/smm/smi_trigger.c b/src/cpu/x86/smm/smi_trigger.c new file mode 100644 index 0000000000..f1031a00f6 --- /dev/null +++ b/src/cpu/x86/smm/smi_trigger.c @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include + +int apm_control(u8 cmd) +{ + if (!CONFIG(HAVE_SMI_HANDLER)) + return -1; + + switch (cmd) { + case APM_CNT_CST_CONTROL: + break; + case APM_CNT_PST_CONTROL: + break; + case APM_CNT_ACPI_DISABLE: + printk(BIOS_DEBUG, "Disabling ACPI via APMC.\n"); + break; + case APM_CNT_ACPI_ENABLE: + printk(BIOS_DEBUG, "Enabling ACPI via APMC.\n"); + break; + case APM_CNT_GNVS_UPDATE: + break; + case APM_CNT_FINALIZE: + printk(BIOS_DEBUG, "Finalizing SMM.\n"); + break; + case APM_CNT_ELOG_GSMI: + break; + case APM_CNT_SMMSTORE: + break; + case APM_CNT_SMMINFO: + break; + default: + break; + } + + /* Now raise the SMI. */ + outb(cmd, APM_CNT); + + printk(BIOS_DEBUG, "APMC done.\n"); + return 0; +} -- cgit v1.2.3