[coreboot-gerrit] New patch to review for coreboot: ACPI S3: Split support for HAVE_ACPI_RESUME

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Sat Jun 18 12:39:40 CEST 2016


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15242

-gerrit

commit 48f833f3ce502b768e8ea9ebc1cf3d87c17fba08
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Sat Jun 18 09:19:18 2016 +0300

    ACPI S3: Split support for HAVE_ACPI_RESUME
    
    Some of the support functions will be built for romstage
    once HIGH_MEMORY_SAVE is removed.
    
    Change-Id: I43ed9067cf6b2152a354088c1dcb02d374eb6efe
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/arch/x86/Makefile.inc |   2 +
 src/arch/x86/acpi.c       | 130 ---------------------------------------
 src/arch/x86/acpi_s3.c    | 153 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 155 insertions(+), 130 deletions(-)

diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 28bb8ea..be50db1 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -331,6 +331,7 @@ ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
 romstage-$(CONFIG_POSTCAR_STAGE) += postcar_loader.c
 romstage-y += cbmem.c
 romstage-y += boot.c
+romstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
 
 romstage-y += cbfs_and_run.c
 romstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += cpu_common.c
@@ -355,6 +356,7 @@ ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c
 ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c
 ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen.c
 ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi_device.c
+ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
 ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S
 
 ramstage-y += c_start.S
diff --git a/src/arch/x86/acpi.c b/src/arch/x86/acpi.c
index c81c0ec..3661297 100644
--- a/src/arch/x86/acpi.c
+++ b/src/arch/x86/acpi.c
@@ -41,12 +41,9 @@
 #include <arch/acpigen.h>
 #include <device/pci.h>
 #include <cbmem.h>
-#include <cpu/x86/lapic.h>
 #include <cpu/x86/lapic_def.h>
 #include <cpu/cpu.h>
 #include <cbfs.h>
-#include <timestamp.h>
-#include <romstage_handoff.h>
 
 u8 acpi_checksum(u8 *table, u32 length)
 {
@@ -960,99 +957,6 @@ unsigned long write_acpi_tables(unsigned long start)
 	return current;
 }
 
-#if CONFIG_HAVE_ACPI_RESUME
-void __attribute__((weak)) mainboard_suspend_resume(void)
-{
-}
-
-void acpi_resume(void *wake_vec)
-{
-#if CONFIG_HAVE_SMI_HANDLER
-	u32 *gnvs_address = cbmem_find(CBMEM_ID_ACPI_GNVS_PTR);
-
-	/* Restore GNVS pointer in SMM if found */
-	if (gnvs_address && *gnvs_address) {
-		printk(BIOS_DEBUG, "Restore GNVS pointer to 0x%08x\n",
-		       *gnvs_address);
-		smm_setup_structures((void *)*gnvs_address, NULL, NULL);
-	}
-#endif
-
-	/* Call mainboard resume handler first, if defined. */
-	mainboard_suspend_resume();
-
-	post_code(POST_OS_RESUME);
-	acpi_jump_to_wakeup(wake_vec);
-}
-
-/* This is filled with acpi_is_wakeup() call early in ramstage. */
-int acpi_slp_type = -1;
-
-#if IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)
-int acpi_get_sleep_type(void)
-{
-	struct romstage_handoff *handoff;
-
-	handoff = cbmem_find(CBMEM_ID_ROMSTAGE_INFO);
-
-	if (handoff == NULL) {
-		printk(BIOS_DEBUG, "Unknown boot method, assuming normal.\n");
-		return 0;
-	} else if (handoff->s3_resume) {
-		printk(BIOS_DEBUG, "S3 Resume.\n");
-		return 3;
-	} else {
-		printk(BIOS_DEBUG, "Normal boot.\n");
-		return 0;
-	}
-}
-#endif
-
-static void acpi_handoff_wakeup(void)
-{
-	if (acpi_slp_type < 0)
-		acpi_slp_type = acpi_get_sleep_type();
-}
-
-int acpi_is_wakeup(void)
-{
-	acpi_handoff_wakeup();
-	/* Both resume from S2 and resume from S3 restart at CPU reset */
-	return (acpi_slp_type == 3 || acpi_slp_type == 2);
-}
-
-int acpi_is_wakeup_s3(void)
-{
-	acpi_handoff_wakeup();
-	return (acpi_slp_type == 3);
-}
-
-int acpi_is_wakeup_s4(void)
-{
-	acpi_handoff_wakeup();
-	return (acpi_slp_type == 4);
-}
-
-void acpi_fail_wakeup(void)
-{
-	if (acpi_slp_type == 3 || acpi_slp_type == 2)
-		acpi_slp_type = 0;
-}
-
-void acpi_prepare_resume_backup(void)
-{
-	if (!acpi_s3_resume_allowed())
-		return;
-
-	/* Let's prepare the ACPI S3 Resume area now already, so we can rely on
-	 * it being there during reboot time. We don't need the pointer, nor
-	 * the result right now. If it fails, ACPI resume will be disabled.
-	 */
-
-	if (HIGH_MEMORY_SAVE)
-		cbmem_add(CBMEM_ID_RESUME, HIGH_MEMORY_SAVE);
-}
-
 static acpi_rsdp_t *valid_rsdp(acpi_rsdp_t *rsdp)
 {
 	if (strncmp((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0)
@@ -1128,40 +1032,6 @@ void *acpi_find_wakeup_vector(void)
 	return wake_vec;
 }
 
-#define WAKEUP_BASE 0x600
-
-void (*acpi_do_wakeup)(uintptr_t vector, u32 backup_source, u32 backup_target,
-       u32 backup_size) asmlinkage = (void *)WAKEUP_BASE;
-
-extern unsigned char __wakeup;
-extern unsigned int __wakeup_size;
-
-void acpi_jump_to_wakeup(void *vector)
-{
-	uintptr_t acpi_backup_memory = 0;
-
-	if (HIGH_MEMORY_SAVE && acpi_s3_resume_allowed()) {
-		acpi_backup_memory = (uintptr_t)cbmem_find(CBMEM_ID_RESUME);
-
-		if (!acpi_backup_memory) {
-			printk(BIOS_WARNING, "ACPI: Backup memory missing. "
-				"No S3 resume.\n");
-			return;
-		}
-	}
-
-	lowmem_recovery();
-
-	/* Copy wakeup trampoline in place. */
-	memcpy((void *)WAKEUP_BASE, &__wakeup, __wakeup_size);
-
-	timestamp_add_now(TS_ACPI_WAKE_JUMP);
-
-	acpi_do_wakeup((uintptr_t)vector, acpi_backup_memory, CONFIG_RAMBASE,
-		       HIGH_MEMORY_SAVE);
-}
-#endif
-
 void acpi_save_gnvs(u32 gnvs_address)
 {
 	u32 *gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS_PTR, sizeof(*gnvs));
diff --git a/src/arch/x86/acpi_s3.c b/src/arch/x86/acpi_s3.c
new file mode 100644
index 0000000..015f5e2
--- /dev/null
+++ b/src/arch/x86/acpi_s3.c
@@ -0,0 +1,153 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2005-2009 coresystems GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <console/console.h>
+#include <string.h>
+#include <arch/acpi.h>
+#include <cbmem.h>
+#include <cpu/x86/lapic.h>
+#include <cpu/cpu.h>
+#include <timestamp.h>
+#include <romstage_handoff.h>
+#include <rules.h>
+
+#if ENV_RAMSTAGE
+
+void __attribute__((weak)) mainboard_suspend_resume(void)
+{
+}
+
+void acpi_resume(void *wake_vec)
+{
+#if CONFIG_HAVE_SMI_HANDLER
+	u32 *gnvs_address = cbmem_find(CBMEM_ID_ACPI_GNVS_PTR);
+
+	/* Restore GNVS pointer in SMM if found */
+	if (gnvs_address && *gnvs_address) {
+		printk(BIOS_DEBUG, "Restore GNVS pointer to 0x%08x\n",
+		       *gnvs_address);
+		smm_setup_structures((void *)*gnvs_address, NULL, NULL);
+	}
+#endif
+
+	/* Call mainboard resume handler first, if defined. */
+	mainboard_suspend_resume();
+
+	post_code(POST_OS_RESUME);
+	acpi_jump_to_wakeup(wake_vec);
+}
+
+/* This is filled with acpi_is_wakeup() call early in ramstage. */
+int acpi_slp_type = -1;
+
+#if IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)
+int acpi_get_sleep_type(void)
+{
+	struct romstage_handoff *handoff;
+
+	handoff = cbmem_find(CBMEM_ID_ROMSTAGE_INFO);
+
+	if (handoff == NULL) {
+		printk(BIOS_DEBUG, "Unknown boot method, assuming normal.\n");
+		return 0;
+	} else if (handoff->s3_resume) {
+		printk(BIOS_DEBUG, "S3 Resume.\n");
+		return 3;
+	} else {
+		printk(BIOS_DEBUG, "Normal boot.\n");
+		return 0;
+	}
+}
+#endif
+
+static void acpi_handoff_wakeup(void)
+{
+	if (acpi_slp_type < 0)
+		acpi_slp_type = acpi_get_sleep_type();
+}
+
+int acpi_is_wakeup(void)
+{
+	acpi_handoff_wakeup();
+	/* Both resume from S2 and resume from S3 restart at CPU reset */
+	return (acpi_slp_type == 3 || acpi_slp_type == 2);
+}
+
+int acpi_is_wakeup_s3(void)
+{
+	acpi_handoff_wakeup();
+	return (acpi_slp_type == 3);
+}
+
+int acpi_is_wakeup_s4(void)
+{
+	acpi_handoff_wakeup();
+	return (acpi_slp_type == 4);
+}
+
+void acpi_fail_wakeup(void)
+{
+	if (acpi_slp_type == 3 || acpi_slp_type == 2)
+		acpi_slp_type = 0;
+}
+
+void acpi_prepare_resume_backup(void)
+{
+	if (!acpi_s3_resume_allowed())
+		return;
+
+	/* Let's prepare the ACPI S3 Resume area now already, so we can rely on
+	 * it being there during reboot time. We don't need the pointer, nor
+	 * the result right now. If it fails, ACPI resume will be disabled.
+	 */
+
+	if (HIGH_MEMORY_SAVE)
+		cbmem_add(CBMEM_ID_RESUME, HIGH_MEMORY_SAVE);
+}
+
+#define WAKEUP_BASE 0x600
+
+void (*acpi_do_wakeup)(uintptr_t vector, u32 backup_source, u32 backup_target,
+       u32 backup_size) asmlinkage = (void *)WAKEUP_BASE;
+
+extern unsigned char __wakeup;
+extern unsigned int __wakeup_size;
+
+void acpi_jump_to_wakeup(void *vector)
+{
+	uintptr_t acpi_backup_memory = 0;
+
+	if (HIGH_MEMORY_SAVE && acpi_s3_resume_allowed()) {
+		acpi_backup_memory = (uintptr_t)cbmem_find(CBMEM_ID_RESUME);
+
+		if (!acpi_backup_memory) {
+			printk(BIOS_WARNING, "ACPI: Backup memory missing. "
+				"No S3 resume.\n");
+			return;
+		}
+	}
+
+	lowmem_recovery();
+
+	/* Copy wakeup trampoline in place. */
+	memcpy((void *)WAKEUP_BASE, &__wakeup, __wakeup_size);
+
+	timestamp_add_now(TS_ACPI_WAKE_JUMP);
+
+	acpi_do_wakeup((uintptr_t)vector, acpi_backup_memory, CONFIG_RAMBASE,
+		       HIGH_MEMORY_SAVE);
+}
+
+#endif /* ENV_RAMSTAGE */



More information about the coreboot-gerrit mailing list