[coreboot-gerrit] New patch to review for coreboot: ACPI S3: Add common recovery code

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Sat Jun 18 12:39:44 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/15243

-gerrit

commit 62d805129861df328eb287b984ce6287c64ae73c
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Thu Jun 16 15:16:20 2016 +0300

    ACPI S3: Add common recovery code
    
    There is nothing to backup with RELOCATABLE_RAMSTAGE.
    
    Change-Id: I780a71e48d23e202fb0e9c70e34420066fa0e5b5
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/arch/x86/acpi_s3.c           | 22 ++++++++++++++++++++++
 src/arch/x86/include/arch/acpi.h |  2 ++
 src/cpu/intel/haswell/romstage.c | 19 ++-----------------
 3 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/src/arch/x86/acpi_s3.c b/src/arch/x86/acpi_s3.c
index 015f5e2..7f81791 100644
--- a/src/arch/x86/acpi_s3.c
+++ b/src/arch/x86/acpi_s3.c
@@ -102,7 +102,24 @@ void acpi_fail_wakeup(void)
 	if (acpi_slp_type == 3 || acpi_slp_type == 2)
 		acpi_slp_type = 0;
 }
+#endif /* ENV_RAMSTAGE */
+
+#if IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE)
+void acpi_prepare_for_resume(void) { };
+void acpi_prepare_resume_backup(void) { };
+
+#else
 
+#if ENV_ROMSTAGE
+void acpi_prepare_for_resume(void)
+{
+	/* Back up the OS-controlled memory where ramstage will be loaded. */
+	void *src = (void *)CONFIG_RAMBASE;
+	void *dest = cbmem_find(CBMEM_ID_RESUME);
+	if (dest != NULL)
+		memcpy(dest, src, HIGH_MEMORY_SAVE);
+}
+#elif ENV_RAMSTAGE
 void acpi_prepare_resume_backup(void)
 {
 	if (!acpi_s3_resume_allowed())
@@ -116,6 +133,11 @@ void acpi_prepare_resume_backup(void)
 	if (HIGH_MEMORY_SAVE)
 		cbmem_add(CBMEM_ID_RESUME, HIGH_MEMORY_SAVE);
 }
+#endif
+
+#endif
+
+#if ENV_RAMSTAGE
 
 #define WAKEUP_BASE 0x600
 
diff --git a/src/arch/x86/include/arch/acpi.h b/src/arch/x86/include/arch/acpi.h
index 30c888c..ff0672e 100644
--- a/src/arch/x86/include/arch/acpi.h
+++ b/src/arch/x86/include/arch/acpi.h
@@ -637,12 +637,14 @@ int acpi_is_wakeup(void);
 int acpi_is_wakeup_s3(void);
 int acpi_is_wakeup_s4(void);
 #endif
+void acpi_prepare_for_resume(void);
 
 #else
 #define acpi_slp_type 0
 static inline int acpi_is_wakeup(void) { return 0; }
 static inline int acpi_is_wakeup_s3(void) { return 0; }
 static inline int acpi_is_wakeup_s4(void) { return 0; }
+static inline void acpi_prepare_for_resume(void) { }
 #endif
 
 static inline uintptr_t acpi_align_current(uintptr_t current)
diff --git a/src/cpu/intel/haswell/romstage.c b/src/cpu/intel/haswell/romstage.c
index b8ce5d6..c7e765a 100644
--- a/src/cpu/intel/haswell/romstage.c
+++ b/src/cpu/intel/haswell/romstage.c
@@ -273,29 +273,14 @@ void romstage_common(const struct romstage_params *params)
 	}
 }
 
-static inline void prepare_for_resume(struct romstage_handoff *handoff)
-{
-/* Only need to save memory when ramstage isn't relocatable. */
-#if !CONFIG_RELOCATABLE_RAMSTAGE
-#if CONFIG_HAVE_ACPI_RESUME
-	/* Back up the OS-controlled memory where ramstage will be loaded. */
-	if (handoff != NULL && handoff->s3_resume) {
-		void *src = (void *)CONFIG_RAMBASE;
-		void *dest = cbmem_find(CBMEM_ID_RESUME);
-		if (dest != NULL)
-			memcpy(dest, src, HIGH_MEMORY_SAVE);
-	}
-#endif
-#endif
-}
-
 void romstage_after_car(void)
 {
 	struct romstage_handoff *handoff;
 
 	handoff = romstage_handoff_find_or_add();
 
-	prepare_for_resume(handoff);
+	if (handoff != NULL && handoff->s3_resume)
+		acpi_prepare_for_resume();
 
 	/* Load the ramstage. */
 	copy_and_run();



More information about the coreboot-gerrit mailing list