All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 09/22] x86: acpi: Add wake up assembly stub
Date: Tue, 21 Mar 2017 14:06:44 -0600	[thread overview]
Message-ID: <CAPnjgZ0C45e_X29y0s0A6Swsdh5sYD6-QApPrbMS_Z=YMce2tA@mail.gmail.com> (raw)
In-Reply-To: <1489674408-17498-10-git-send-email-bmeng.cn@gmail.com>

Hi Bin,

On 16 March 2017 at 08:26, Bin Meng <bmeng.cn@gmail.com> wrote:
> This adds a wake up stub before jumping to OS wake up vector.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
>  arch/x86/cpu/Makefile          |  1 +
>  arch/x86/cpu/wakeup.S          | 79 ++++++++++++++++++++++++++++++++++++++++++
>  arch/x86/include/asm/acpi_s3.h |  9 +++++
>  3 files changed, 89 insertions(+)
>  create mode 100644 arch/x86/cpu/wakeup.S

Reviewed-by: Simon Glass <sjg@chromium.org>

nits below.

>
> diff --git a/arch/x86/cpu/Makefile b/arch/x86/cpu/Makefile
> index 92a9023..e1c84ce 100644
> --- a/arch/x86/cpu/Makefile
> +++ b/arch/x86/cpu/Makefile
> @@ -45,6 +45,7 @@ ifndef CONFIG_$(SPL_)X86_64
>  obj-$(CONFIG_SMP) += sipi_vector.o
>  endif
>  obj-y += turbo.o
> +obj-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.o
>
>  ifeq ($(CONFIG_$(SPL_)X86_64),y)
>  obj-y += x86_64/
> diff --git a/arch/x86/cpu/wakeup.S b/arch/x86/cpu/wakeup.S
> new file mode 100644
> index 0000000..97b1c21
> --- /dev/null
> +++ b/arch/x86/cpu/wakeup.S
> @@ -0,0 +1,79 @@
> +/*
> + * Copyright (C) 2017, Bin Meng <bmeng.cn@gmail.com>
> + *
> + * From coreboot src/arch/x86/wakeup.S
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + */
> +
> +#include <asm/acpi_s3.h>
> +#include <asm/processor.h>
> +#include <asm/processor-flags.h>
> +
> +#define RELOCATED(x)   (x - __wakeup + WAKEUP_BASE)

How about brackets around the second x

> +
> +#define CODE_SEG       (X86_GDT_ENTRY_16BIT_CS * X86_GDT_ENTRY_SIZE)
> +#define DATA_SEG       (X86_GDT_ENTRY_16BIT_DS * X86_GDT_ENTRY_SIZE)
> +
> +       .code32
> +       .globl __wakeup
> +__wakeup:
> +       /* First prepare the jmp to the resume vector */
> +       mov     0x4(%esp), %eax /* vector */
> +       /* last 4 bits of linear addr are taken as offset */
> +       andw    $0x0f, %ax
> +       movw    %ax, (__wakeup_offset)
> +       mov     0x4(%esp), %eax
> +       /* the rest is taken as segment */
> +       shr     $4, %eax
> +       movw    %ax, (__wakeup_segment)
> +
> +       /* Activate the right segment descriptor real mode */
> +       ljmp    $CODE_SEG, $RELOCATED(1f)
> +1:
> +       /* 16 bit code from here on... */
> +       .code16
> +
> +       /*
> +        * Load the segment registers w/ properly configured
> +        * segment descriptors. They will retain these
> +        * configurations (limits, writability, etc.) once
> +        * protected mode is turned off.

Can you word-wrap to use more columns?

> +        */
> +       mov     $DATA_SEG, %ax
> +       mov     %ax, %ds
> +       mov     %ax, %es
> +       mov     %ax, %fs
> +       mov     %ax, %gs
> +       mov     %ax, %ss
> +
> +       /* Turn off protection */
> +       movl    %cr0, %eax
> +       andl    $~X86_CR0_PE, %eax
> +       movl    %eax, %cr0
> +
> +       /* Now really going into real mode */
> +       ljmp    $0, $RELOCATED(1f)
> +1:
> +       movw    $0x0, %ax
> +       movw    %ax, %ds
> +       movw    %ax, %es
> +       movw    %ax, %ss
> +       movw    %ax, %fs
> +       movw    %ax, %gs
> +
> +       /*
> +        * This is a FAR JMP to the OS waking vector.
> +        * The C code changed the address to be correct.

s/changed/changes/

> +        */
> +       .byte 0xea
> +
> +__wakeup_offset = RELOCATED(.)
> +       .word 0x0000
> +
> +__wakeup_segment = RELOCATED(.)
> +       .word 0x0000
> +
> +       .globl __wakeup_size
> +__wakeup_size:
> +       .long . - __wakeup
> diff --git a/arch/x86/include/asm/acpi_s3.h b/arch/x86/include/asm/acpi_s3.h
> index c1cdbd0..f9d4739 100644
> --- a/arch/x86/include/asm/acpi_s3.h
> +++ b/arch/x86/include/asm/acpi_s3.h
> @@ -7,6 +7,8 @@
>  #ifndef __ASM_ACPI_S3_H__
>  #define __ASM_ACPI_S3_H__
>
> +#define WAKEUP_BASE    0x600
> +
>  /* PM1_STATUS register */
>  #define WAK_STS                (1 << 15)
>  #define PCIEXPWAK_STS  (1 << 14)
> @@ -27,6 +29,11 @@
>  #define SLP_TYP_S4     6
>  #define SLP_TYP_S5     7
>
> +#ifndef __ASSEMBLY__
> +
> +extern char __wakeup[];
> +extern int __wakeup_size;

Comments?

> +
>  enum acpi_sleep_state {
>         ACPI_S0,
>         ACPI_S1,
> @@ -93,4 +100,6 @@ enum acpi_sleep_state chipset_prev_sleep_state(void);
>   */
>  void chipset_clear_sleep_state(void);
>
> +#endif /* __ASSEMBLY__ */
> +
>  #endif /* __ASM_ACPI_S3_H__ */
> --
> 2.9.2
>

Regards,
Simon

  reply	other threads:[~2017-03-21 20:06 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16 14:26 [U-Boot] [PATCH 00/22] x86: Add ACPI S3 resume support Bin Meng
2017-03-16 14:26 ` [U-Boot] [PATCH 01/22] dm: rtc: Add 16-bit read/write support Bin Meng
2017-03-17  3:26   ` Simon Glass
2017-04-01  2:26     ` Bin Meng
2017-03-16 14:26 ` [U-Boot] [PATCH 02/22] x86: acpi: Add Kconfig option and header file for ACPI resume Bin Meng
2017-03-17  3:26   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 03/22] x86: baytrail: acpi: Add APIs for determining/clearing sleep state Bin Meng
2017-03-17  3:26   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 04/22] x86: Add post codes for OS resume Bin Meng
2017-03-17  3:26   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 05/22] x86: fsp: acpi: Pass different boot mode to FSP init Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 06/22] x86: Store and display previous sleep state Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 07/22] x86: baytrail: Conditionally report S3 in the ACPI table Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 08/22] x86: fsp: Mark memory used by U-Boot as reserved in the E820 table for S3 Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-04-12  8:14     ` Bin Meng
2017-03-16 14:26 ` [U-Boot] [PATCH 09/22] x86: acpi: Add wake up assembly stub Bin Meng
2017-03-21 20:06   ` Simon Glass [this message]
2017-03-16 14:26 ` [U-Boot] [PATCH 10/22] x86: acpi: Add one API to find OS wakeup vector Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 11/22] x86: acpi: Resume OS if resume vector is found Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-04-12  8:14     ` Bin Meng
2017-04-13 21:15       ` Simon Glass
2017-04-17  9:37       ` Stefan Roese
2017-04-24  3:38         ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 12/22] x86: Add an early CMOS access library Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-04-18  9:46     ` Bin Meng
2017-04-19  0:12       ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 13/22] x86: fsp: Save stack address to CMOS for next S3 boot Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-04-13  9:25     ` Bin Meng
2017-04-13 13:34       ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 14/22] x86: fsp: Mark the first 64K low memory as reserved Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 15/22] x86: Adjust board_final_cleanup() order Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 16/22] x86: apci: Change PM1_CNT register access to RMW Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 17/22] x86: acpi: Make enter_acpi_mode() public Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 18/22] x86: acpi: Refactor acpi_resume() Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 19/22] x86: acpi: Turn on ACPI mode for S3 Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 20/22] x86: pci: Allow conditionally run VGA rom in S3 Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-04-13 10:00     ` Bin Meng
2017-04-13 13:32       ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 21/22] x86: minnowmax: Enable ACPI S3 resume Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 22/22] x86: Document ACPI S3 support Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-17  3:26 ` [U-Boot] [PATCH 00/22] x86: Add ACPI S3 resume support Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPnjgZ0C45e_X29y0s0A6Swsdh5sYD6-QApPrbMS_Z=YMce2tA@mail.gmail.com' \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.