ACPI S3 support: Add acpi_s3_resume_allowed()

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 <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/6060
Tested-by: build bot (Jenkins)
This commit is contained in:
Kyösti Mälkki 2014-06-17 15:41:37 +03:00
parent b3594ab489
commit 2ca2afe760
4 changed files with 31 additions and 29 deletions

View File

@ -756,17 +756,17 @@ extern unsigned int __wakeup_size;
void acpi_jump_to_wakeup(void *vector) void acpi_jump_to_wakeup(void *vector)
{ {
#if CONFIG_RELOCATABLE_RAMSTAGE
u32 acpi_backup_memory = 0; u32 acpi_backup_memory = 0;
#else
u32 acpi_backup_memory = (u32)cbmem_find(CBMEM_ID_RESUME);
if (!acpi_backup_memory) { if (HIGH_MEMORY_SAVE && acpi_s3_resume_allowed()) {
printk(BIOS_WARNING, "ACPI: Backup memory missing. " acpi_backup_memory = (u32)cbmem_find(CBMEM_ID_RESUME);
"No S3 resume.\n");
return; if (!acpi_backup_memory) {
printk(BIOS_WARNING, "ACPI: Backup memory missing. "
"No S3 resume.\n");
return;
}
} }
#endif
#if CONFIG_SMP #if CONFIG_SMP
// FIXME: This should go into the ACPI backup memory, too. No pork sausages. // FIXME: This should go into the ACPI backup memory, too. No pork sausages.

View File

@ -192,19 +192,15 @@ void write_tables(void)
post_code(0x9e); 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 /* 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 * 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. * the result right now. If it fails, ACPI resume will be disabled.
*/ */
cbmem_add(CBMEM_ID_RESUME, HIGH_MEMORY_SAVE); if (HIGH_MEMORY_SAVE && acpi_s3_resume_allowed())
#endif cbmem_add(CBMEM_ID_RESUME, HIGH_MEMORY_SAVE);
#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); if (HIGH_MEMORY_SCRATCH && acpi_s3_resume_allowed())
#endif cbmem_add(CBMEM_ID_RESUME_SCRATCH, HIGH_MEMORY_SCRATCH);
#endif
#define MAX_COREBOOT_TABLE_SIZE (32 * 1024) #define MAX_COREBOOT_TABLE_SIZE (32 * 1024)
post_code(0x9d); post_code(0x9d);

View File

@ -584,4 +584,9 @@ void generate_cpu_entries(void);
#endif /* CONFIG_GENERATE_ACPI_TABLES */ #endif /* CONFIG_GENERATE_ACPI_TABLES */
static inline int acpi_s3_resume_allowed(void)
{
return IS_ENABLED(CONFIG_HAVE_ACPI_RESUME);
}
#endif /* __ASM_ACPI_H */ #endif /* __ASM_ACPI_H */

View File

@ -21,11 +21,18 @@
#ifndef _CBMEM_H_ #ifndef _CBMEM_H_
#define _CBMEM_H_ #define _CBMEM_H_
#if CONFIG_HAVE_ACPI_RESUME #if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) && \
#if CONFIG_RELOCATABLE_RAMSTAGE ! IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE)
#define HIGH_MEMORY_SAVE 0
#else
#define HIGH_MEMORY_SAVE (CONFIG_RAMTOP - CONFIG_RAMBASE) #define HIGH_MEMORY_SAVE (CONFIG_RAMTOP - CONFIG_RAMBASE)
#else
#define HIGH_MEMORY_SAVE 0
#endif
#if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) && \
IS_ENABLED(CONFIG_HIGH_SCRATCH_MEMORY_SIZE)
#define HIGH_MEMORY_SCRATCH CONFIG_HIGH_SCRATCH_MEMORY_SIZE
#else
#define HIGH_MEMORY_SCRATCH 0
#endif #endif
/* Delegation of resume backup memory so we don't have to /* Delegation of resume backup memory so we don't have to
@ -33,7 +40,6 @@
*/ */
#define CBMEM_BOOT_MODE 0x610 #define CBMEM_BOOT_MODE 0x610
#define CBMEM_RESUME_BACKUP 0x614 #define CBMEM_RESUME_BACKUP 0x614
#endif /* CONFIG_HAVE_ACPI_RESUME */
#define CBMEM_ID_FREESPACE 0x46524545 #define CBMEM_ID_FREESPACE 0x46524545
#define CBMEM_ID_GDT 0x4c474454 #define CBMEM_ID_GDT 0x4c474454
@ -133,14 +139,9 @@ u64 cbmem_entry_size(const struct cbmem_entry *entry);
*/ */
#define _CBMEM_SZ_MINIMAL ( 128 * 1024 ) #define _CBMEM_SZ_MINIMAL ( 128 * 1024 )
#if CONFIG_HAVE_ACPI_RESUME
#define _CBMEM_SZ_RESUME (HIGH_MEMORY_SAVE + CONFIG_HIGH_SCRATCH_MEMORY_SIZE)
#else
#define _CBMEM_SZ_RESUME 0
#endif
#define _CBMEM_SZ_TOTAL \ #define _CBMEM_SZ_TOTAL \
(_CBMEM_SZ_MINIMAL + _CBMEM_SZ_RESUME + CONFIG_CONSOLE_CBMEM_BUFFER_SIZE) (_CBMEM_SZ_MINIMAL + CONFIG_CONSOLE_CBMEM_BUFFER_SIZE + \
HIGH_MEMORY_SAVE + HIGH_MEMORY_SCRATCH)
#define HIGH_MEMORY_SIZE ALIGN_UP(_CBMEM_SZ_TOTAL, 0x10000) #define HIGH_MEMORY_SIZE ALIGN_UP(_CBMEM_SZ_TOTAL, 0x10000)