From 9a1620f4ed5a17bde351142d3ca5489f3c95c61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Fri, 8 Jan 2021 13:27:33 +0200 Subject: cpu/x86/smm: Use common APMC logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unify the debug messages on raised SMIs. Change-Id: I34eeb41d929bfb18730ac821a63bde95ef9a0b3e Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/49248 Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) --- src/cpu/x86/smm/Makefile.inc | 1 + src/cpu/x86/smm/smi_trigger.c | 32 +++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) (limited to 'src/cpu/x86/smm') diff --git a/src/cpu/x86/smm/Makefile.inc b/src/cpu/x86/smm/Makefile.inc index 1ed018d1be..9d74558670 100644 --- a/src/cpu/x86/smm/Makefile.inc +++ b/src/cpu/x86/smm/Makefile.inc @@ -33,6 +33,7 @@ ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual endif smm-y += save_state.c +smm-y += smi_trigger.c ifeq ($(CONFIG_SMM_TSEG),y) diff --git a/src/cpu/x86/smm/smi_trigger.c b/src/cpu/x86/smm/smi_trigger.c index 7e3ddb1613..ff5eeae778 100644 --- a/src/cpu/x86/smm/smi_trigger.c +++ b/src/cpu/x86/smm/smi_trigger.c @@ -4,24 +4,23 @@ #include #include -int apm_control(u8 cmd) +static void apmc_log(const char *fn, u8 cmd) { - if (!CONFIG(HAVE_SMI_HANDLER)) - return -1; - switch (cmd) { case APM_CNT_CST_CONTROL: + printk(BIOS_DEBUG, "%s: C-state control.\n", fn); break; case APM_CNT_PST_CONTROL: + printk(BIOS_DEBUG, "%s: P-state control.\n", fn); break; case APM_CNT_ACPI_DISABLE: - printk(BIOS_DEBUG, "Disabling ACPI via APMC.\n"); + printk(BIOS_DEBUG, "%s: Disabling ACPI.\n", fn); break; case APM_CNT_ACPI_ENABLE: - printk(BIOS_DEBUG, "Enabling ACPI via APMC.\n"); + printk(BIOS_DEBUG, "%s: Enabling ACPI.\n", fn); break; case APM_CNT_FINALIZE: - printk(BIOS_DEBUG, "Finalizing SMM.\n"); + printk(BIOS_DEBUG, "%s: Finalizing SMM.\n", fn); break; case APM_CNT_ELOG_GSMI: break; @@ -30,8 +29,18 @@ int apm_control(u8 cmd) 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); @@ -39,3 +48,12 @@ int apm_control(u8 cmd) 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; +} -- cgit v1.2.3