From 2ca2afe760bf1f78ee410749332d85f9413a9f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Tue, 17 Jun 2014 15:41:37 +0300 Subject: ACPI S3 support: Add acpi_s3_resume_allowed() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add this to reduce the amount of preprocessor conditionals used in the source, compiler currently resolves this to a constant. Once we have gone through all #if CONFIG_HAVE_ACPI_RESUME cases, we may change the implementation to enable/disable S3 support runtime. Change-Id: I0e2d9f81e2ab87c2376a04fab38a7c951cac7a07 Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/6060 Tested-by: build bot (Jenkins) --- src/arch/x86/boot/acpi.c | 16 ++++++++-------- src/arch/x86/boot/tables.c | 14 +++++--------- src/arch/x86/include/arch/acpi.h | 5 +++++ 3 files changed, 18 insertions(+), 17 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/boot/acpi.c b/src/arch/x86/boot/acpi.c index 0e09ec58c6..6c1788d524 100644 --- a/src/arch/x86/boot/acpi.c +++ b/src/arch/x86/boot/acpi.c @@ -756,17 +756,17 @@ extern unsigned int __wakeup_size; void acpi_jump_to_wakeup(void *vector) { -#if CONFIG_RELOCATABLE_RAMSTAGE u32 acpi_backup_memory = 0; -#else - u32 acpi_backup_memory = (u32)cbmem_find(CBMEM_ID_RESUME); - if (!acpi_backup_memory) { - printk(BIOS_WARNING, "ACPI: Backup memory missing. " - "No S3 resume.\n"); - return; + if (HIGH_MEMORY_SAVE && acpi_s3_resume_allowed()) { + acpi_backup_memory = (u32)cbmem_find(CBMEM_ID_RESUME); + + if (!acpi_backup_memory) { + printk(BIOS_WARNING, "ACPI: Backup memory missing. " + "No S3 resume.\n"); + return; + } } -#endif #if CONFIG_SMP // FIXME: This should go into the ACPI backup memory, too. No pork sausages. diff --git a/src/arch/x86/boot/tables.c b/src/arch/x86/boot/tables.c index 42e431e06e..16c752a154 100644 --- a/src/arch/x86/boot/tables.c +++ b/src/arch/x86/boot/tables.c @@ -192,19 +192,15 @@ void write_tables(void) post_code(0x9e); -#if CONFIG_HAVE_ACPI_RESUME -/* Only add CBMEM_ID_RESUME when the ramstage isn't relocatable. */ -#if !CONFIG_RELOCATABLE_RAMSTAGE /* Let's prepare the ACPI S3 Resume area now already, so we can rely on * it begin there during reboot time. We don't need the pointer, nor * the result right now. If it fails, ACPI resume will be disabled. */ - cbmem_add(CBMEM_ID_RESUME, HIGH_MEMORY_SAVE); -#endif -#if CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY14 || CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY15_TN || CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY16_KB - cbmem_add(CBMEM_ID_RESUME_SCRATCH, CONFIG_HIGH_SCRATCH_MEMORY_SIZE); -#endif -#endif + if (HIGH_MEMORY_SAVE && acpi_s3_resume_allowed()) + cbmem_add(CBMEM_ID_RESUME, HIGH_MEMORY_SAVE); + + if (HIGH_MEMORY_SCRATCH && acpi_s3_resume_allowed()) + cbmem_add(CBMEM_ID_RESUME_SCRATCH, HIGH_MEMORY_SCRATCH); #define MAX_COREBOOT_TABLE_SIZE (32 * 1024) post_code(0x9d); diff --git a/src/arch/x86/include/arch/acpi.h b/src/arch/x86/include/arch/acpi.h index f447c14d9d..a4cde20c73 100644 --- a/src/arch/x86/include/arch/acpi.h +++ b/src/arch/x86/include/arch/acpi.h @@ -584,4 +584,9 @@ void generate_cpu_entries(void); #endif /* CONFIG_GENERATE_ACPI_TABLES */ +static inline int acpi_s3_resume_allowed(void) +{ + return IS_ENABLED(CONFIG_HAVE_ACPI_RESUME); +} + #endif /* __ASM_ACPI_H */ -- cgit v1.2.3