From patchwork Thu Mar 16 14:26:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 739870 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3vkWGD6pBrz9s06 for ; Fri, 17 Mar 2017 01:35:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nOzEpp5N"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id AB9D2C21C67; Thu, 16 Mar 2017 14:23:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id ED81BC21C7E; Thu, 16 Mar 2017 14:22:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0AC52C21C5F; Thu, 16 Mar 2017 14:22:36 +0000 (UTC) Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by lists.denx.de (Postfix) with ESMTPS id EA5FBC21C62 for ; Thu, 16 Mar 2017 14:22:32 +0000 (UTC) Received: by mail-pf0-f194.google.com with SMTP id r137so2146904pfr.3 for ; Thu, 16 Mar 2017 07:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=9ZsdBr8TKZBpzwnIv+wnXc1G+jWOsacHnVKbT2UaHTs=; b=nOzEpp5NQ7HYIRqWH8VPqyQlQ9byq3XV89OjotATGLk5fpbY50e4bFabayuN/m1Jo4 cdXEKRJBiA9jcbTROgitPUrbL9YZcdr2fSGA1QAiUPaKBHot7MYWR+JRGsNQmxe0ouqW /qAbrba84YDlepKebhWmrKAD64Y40/7O+qO+G4evB6fFL7+q4AboeyMNksMHTD9ya8Jf mxsZIR4Ztz7ZUNCvAtjyit40uHjTPKo7Jh/wqOiLWp7DYtr8LZAeXl4uic6R+ExavGYr RagTjXWGTCRVL1t9BAuNzmcGy78Bz4hhHXKOOzL0ioFDNcQbfNGNgZuHIGBF3yZgCaTa YeVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=9ZsdBr8TKZBpzwnIv+wnXc1G+jWOsacHnVKbT2UaHTs=; b=NEdDAa6mvpoKYXtreEKwykfCYV+36mZ9ejyCvhC/b/FAyh/ebnK7HqzyF/D1oReFo7 AOxMObXRX2+cJQDkY0s4oMw2e8eaImapwUepcsYBtR3lwP1Y2v9zXdgWhXZa/6aOw6LG fW5A44FctNXmt/x6qY0Emxq/V9ww0WRBbCbFWetaWt79ZvGE5Mor1G2SUVAzV71uGdgm o8aVKnYi3k97yrLb/sgR65YxAlkbUkZmJlUBNyit350dTsqyo4+dpf9MwWImQ5J7BmDP un8O0BjKz8oZVGU/EpuQXSQIYTgnC6xJ2hGTYmT5cbsiUldd2iitzxKK6ThcjosgBtx8 4Jqg== X-Gm-Message-State: AFeK/H0iwt/4y/2cR7UI8D+ujNfgeSLMSDRAJfcI+HiHBCkqFS0Mkfdb1JeNCWr6xZDHOA== X-Received: by 10.98.252.211 with SMTP id e202mr10765155pfh.118.1489674151610; Thu, 16 Mar 2017 07:22:31 -0700 (PDT) Received: from ala-d2121-lx1.wrs.com (unknown-157-139.windriver.com. [147.11.157.139]) by smtp.gmail.com with ESMTPSA id c64sm11039959pfa.45.2017.03.16.07.22.30 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Mar 2017 07:22:30 -0700 (PDT) From: Bin Meng To: Simon Glass , Stefan Roese , U-Boot Mailing List Date: Thu, 16 Mar 2017 07:26:37 -0700 Message-Id: <1489674408-17498-12-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1489674408-17498-1-git-send-email-bmeng.cn@gmail.com> References: <1489674408-17498-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH 11/22] x86: acpi: Resume OS if resume vector is found X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In an S3 resume path, U-Boot does everything like a cold boot except in the last_stage_init() it jumps to the OS resume vector. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- arch/x86/cpu/cpu.c | 8 ++++++++ arch/x86/include/asm/acpi_s3.h | 10 ++++++++++ arch/x86/lib/Makefile | 1 + arch/x86/lib/acpi_s3.c | 26 ++++++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 arch/x86/lib/acpi_s3.c diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index 9dde54c..afc8645 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -204,6 +205,13 @@ __weak void board_final_cleanup(void) int last_stage_init(void) { +#if CONFIG_HAVE_ACPI_RESUME + void *wake_vector = acpi_find_wakeup_vector(); + + if (wake_vector != NULL && gd->arch.prev_sleep_state == ACPI_S3) + acpi_resume(wake_vector); +#endif + write_tables(); board_final_cleanup(); diff --git a/arch/x86/include/asm/acpi_s3.h b/arch/x86/include/asm/acpi_s3.h index f9d4739..5892a8b 100644 --- a/arch/x86/include/asm/acpi_s3.h +++ b/arch/x86/include/asm/acpi_s3.h @@ -100,6 +100,16 @@ enum acpi_sleep_state chipset_prev_sleep_state(void); */ void chipset_clear_sleep_state(void); +/** + * acpi_resume() - Do ACPI S3 resume + * + * This calls U-Boot wake up assembly stub and jumps to OS's wake up vector. + * + * @wake_vec: OS wake up vector + * @return: Never returns + */ +void acpi_resume(void *wake_vec); + #endif /* __ASSEMBLY__ */ #endif /* __ASM_ACPI_S3_H__ */ diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 1c2c085..c61f931 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -35,6 +35,7 @@ obj-$(CONFIG_X86_RAMTEST) += ramtest.o obj-y += sections.o obj-y += sfi.o obj-y += string.o +obj-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.o ifndef CONFIG_QEMU obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o endif diff --git a/arch/x86/lib/acpi_s3.c b/arch/x86/lib/acpi_s3.c new file mode 100644 index 0000000..f679c06 --- /dev/null +++ b/arch/x86/lib/acpi_s3.c @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2017, Bin Meng + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include + +static void asmlinkage (*acpi_do_wakeup)(void *vector) = (void *)WAKEUP_BASE; + +static void acpi_jump_to_wakeup(void *vector) +{ + /* Copy wakeup trampoline in place */ + memcpy((void *)WAKEUP_BASE, __wakeup, __wakeup_size); + + printf("Jumping to OS waking vector %p\n", vector); + acpi_do_wakeup(vector); +} + +void acpi_resume(void *wake_vec) +{ + post_code(POST_OS_RESUME); + acpi_jump_to_wakeup(wake_vec); +}