Aaron Durbin (adurbin@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3134
-gerrit
commit 4feac09fb7711f6e2a8d59e341d9f5f3d9f93afe Author: Aaron Durbin adurbin@chromium.org Date: Wed Apr 24 22:33:08 2013 -0500
acpi: split resume check and actual resume code
It's helpful to provide a distinct state that affirmatively describes that OS resume will occur. The previous code included the check and the actual resuming in one function. Because of this grouping one had to annotate the innards of the ACPI resume path to perform specific actions before OS resume. By providing a distinct state in the boot state machine the necessary actions can be scheduled accordingly without modifying the ACPI code.
Change-Id: I8b00aacaf820cbfbb21cb851c422a143371878bd Signed-off-by: Aaron Durbin adurbin@chromium.org --- src/arch/x86/boot/acpi.c | 40 +++++++++++++++++----------------------- src/arch/x86/include/arch/acpi.h | 2 +- src/include/bootstate.h | 1 + src/lib/hardwaremain.c | 24 ++++++++++++++++++++---- 4 files changed, 39 insertions(+), 28 deletions(-)
diff --git a/src/arch/x86/boot/acpi.c b/src/arch/x86/boot/acpi.c index 96ece06..1c373ac 100644 --- a/src/arch/x86/boot/acpi.c +++ b/src/arch/x86/boot/acpi.c @@ -622,37 +622,31 @@ void acpi_write_hest(acpi_hest_t *hest) }
#if CONFIG_HAVE_ACPI_RESUME -void suspend_resume(void) +void acpi_resume(void *wake_vec) { - void *wake_vec; - - /* If we happen to be resuming find wakeup vector and jump to OS. */ - wake_vec = acpi_find_wakeup_vector(); - if (wake_vec) { #if CONFIG_HAVE_SMI_HANDLER - u32 *gnvs_address = cbmem_find(CBMEM_ID_ACPI_GNVS_PTR); + 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); - } + /* 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. */ - if (mainboard_suspend_resume) - mainboard_suspend_resume(); + /* Call mainboard resume handler first, if defined. */ + if (mainboard_suspend_resume) + mainboard_suspend_resume(); #if CONFIG_COVERAGE - coverage_exit(); + coverage_exit(); #endif - /* Tear down the caching of the ROM. */ - if (disable_cache_rom) - disable_cache_rom(); + /* Tear down the caching of the ROM. */ + if (disable_cache_rom) + disable_cache_rom();
- post_code(POST_OS_RESUME); - acpi_jump_to_wakeup(wake_vec); - } + post_code(POST_OS_RESUME); + acpi_jump_to_wakeup(wake_vec); }
/* This is to be filled by SB code - startup value what was found. */ diff --git a/src/arch/x86/include/arch/acpi.h b/src/arch/x86/include/arch/acpi.h index 022a45f..306f7da 100644 --- a/src/arch/x86/include/arch/acpi.h +++ b/src/arch/x86/include/arch/acpi.h @@ -558,7 +558,7 @@ void acpi_save_gnvs(u32 gnvs_address); /* 0 = S0, 1 = S1 ...*/ extern u8 acpi_slp_type;
-void suspend_resume(void); +void acpi_resume(void *wake_vec); void __attribute__((weak)) mainboard_suspend_resume(void); void *acpi_find_wakeup_vector(void); void *acpi_get_wakeup_rsdp(void); diff --git a/src/include/bootstate.h b/src/include/bootstate.h index cf1b7a7..16a6321 100644 --- a/src/include/bootstate.h +++ b/src/include/bootstate.h @@ -27,6 +27,7 @@ typedef enum { BS_DEV_ENABLE, BS_DEV_INIT, BS_POST_DEVICE, + BS_OS_RESUME_CHECK, BS_OS_RESUME, BS_WRITE_TABLES, BS_PAYLOAD_LOAD, diff --git a/src/lib/hardwaremain.c b/src/lib/hardwaremain.c index 94eeb89..47a482e 100644 --- a/src/lib/hardwaremain.c +++ b/src/lib/hardwaremain.c @@ -53,6 +53,7 @@ static boot_state_t bs_dev_resources(void *arg); static boot_state_t bs_dev_eanble(void *arg); static boot_state_t bs_dev_init(void *arg); static boot_state_t bs_post_device(void *arg); +static boot_state_t bs_os_resume_check(void *arg); static boot_state_t bs_os_resume(void *arg); static boot_state_t bs_write_tables(void *arg); static boot_state_t bs_payload_load(void *arg); @@ -87,6 +88,7 @@ static struct boot_state boot_states[] = { BS_INIT_ENTRY(BS_DEV_ENABLE, bs_dev_eanble), BS_INIT_ENTRY(BS_DEV_INIT, bs_dev_init), BS_INIT_ENTRY(BS_POST_DEVICE, bs_post_device), + BS_INIT_ENTRY(BS_OS_RESUME_CHECK, bs_os_resume_check), BS_INIT_ENTRY(BS_OS_RESUME, bs_os_resume), BS_INIT_ENTRY(BS_WRITE_TABLES, bs_write_tables), BS_INIT_ENTRY(BS_PAYLOAD_LOAD, bs_payload_load), @@ -156,21 +158,35 @@ static boot_state_t bs_post_device(void *arg)
timestamp_sync();
- return BS_OS_RESUME; + return BS_OS_RESUME_CHECK; }
-static boot_state_t bs_os_resume(void *arg) +static boot_state_t bs_os_resume_check(void *arg) { #if CONFIG_HAVE_ACPI_RESUME - suspend_resume(); + void *wake_vector; + + wake_vector = acpi_find_wakeup_vector(); + + if (wake_vector != NULL) { + boot_states[BS_OS_RESUME].arg = wake_vector; + return BS_OS_RESUME; + } post_code(0x8a); #endif - timestamp_add_now(TS_CBMEM_POST);
return BS_WRITE_TABLES; }
+static boot_state_t bs_os_resume(void *wake_vector) +{ +#if CONFIG_HAVE_ACPI_RESUME + acpi_resume(wake_vector); +#endif + return BS_WRITE_TABLES; +} + static boot_state_t bs_write_tables(void *arg) { if (cbmem_post_handling)