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@gmail.com> Reviewed-on: https://review.coreboot.org/15243 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
8e627a2e51
commit
cf0e60faf4
|
@ -331,6 +331,7 @@ ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
|
||||||
romstage-$(CONFIG_POSTCAR_STAGE) += postcar_loader.c
|
romstage-$(CONFIG_POSTCAR_STAGE) += postcar_loader.c
|
||||||
romstage-y += cbmem.c
|
romstage-y += cbmem.c
|
||||||
romstage-y += boot.c
|
romstage-y += boot.c
|
||||||
|
romstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
|
||||||
|
|
||||||
romstage-y += cbfs_and_run.c
|
romstage-y += cbfs_and_run.c
|
||||||
romstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += cpu_common.c
|
romstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += cpu_common.c
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include <romstage_handoff.h>
|
#include <romstage_handoff.h>
|
||||||
#include <rules.h>
|
#include <rules.h>
|
||||||
|
|
||||||
|
#if ENV_RAMSTAGE
|
||||||
|
|
||||||
/* This is filled with acpi_is_wakeup() call early in ramstage. */
|
/* This is filled with acpi_is_wakeup() call early in ramstage. */
|
||||||
int acpi_slp_type = -1;
|
int acpi_slp_type = -1;
|
||||||
|
|
||||||
|
@ -75,6 +77,19 @@ void acpi_fail_wakeup(void)
|
||||||
if (acpi_slp_type == 3 || acpi_slp_type == 2)
|
if (acpi_slp_type == 3 || acpi_slp_type == 2)
|
||||||
acpi_slp_type = 0;
|
acpi_slp_type = 0;
|
||||||
}
|
}
|
||||||
|
#endif /* ENV_RAMSTAGE */
|
||||||
|
|
||||||
|
void acpi_prepare_for_resume(void)
|
||||||
|
{
|
||||||
|
if (!HIGH_MEMORY_SAVE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
|
|
||||||
void acpi_prepare_resume_backup(void)
|
void acpi_prepare_resume_backup(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -636,12 +636,14 @@ int acpi_is_wakeup(void);
|
||||||
int acpi_is_wakeup_s3(void);
|
int acpi_is_wakeup_s3(void);
|
||||||
int acpi_is_wakeup_s4(void);
|
int acpi_is_wakeup_s4(void);
|
||||||
#endif
|
#endif
|
||||||
|
void acpi_prepare_for_resume(void);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define acpi_slp_type 0
|
#define acpi_slp_type 0
|
||||||
static inline int acpi_is_wakeup(void) { return 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_s3(void) { return 0; }
|
||||||
static inline int acpi_is_wakeup_s4(void) { return 0; }
|
static inline int acpi_is_wakeup_s4(void) { return 0; }
|
||||||
|
static inline void acpi_prepare_for_resume(void) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline uintptr_t acpi_align_current(uintptr_t current)
|
static inline uintptr_t acpi_align_current(uintptr_t current)
|
||||||
|
|
|
@ -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)
|
void romstage_after_car(void)
|
||||||
{
|
{
|
||||||
struct romstage_handoff *handoff;
|
struct romstage_handoff *handoff;
|
||||||
|
|
||||||
handoff = romstage_handoff_find_or_add();
|
handoff = romstage_handoff_find_or_add();
|
||||||
|
|
||||||
prepare_for_resume(handoff);
|
if (handoff != NULL && handoff->s3_resume)
|
||||||
|
acpi_prepare_for_resume();
|
||||||
|
|
||||||
/* Load the ramstage. */
|
/* Load the ramstage. */
|
||||||
copy_and_run();
|
copy_and_run();
|
||||||
|
|
Loading…
Reference in New Issue