All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [RESEND PATCH v3 6/7] x86: Add a way to detect running from coreboot
Date: Thu, 23 Apr 2020 19:02:52 +0800	[thread overview]
Message-ID: <CAEUhbmV-VRWzLvpy-VmZWm9kuiy0wzrEG1M9annhQxURRLrJLw@mail.gmail.com> (raw)
In-Reply-To: <20200408185755.116336-6-sjg@chromium.org>

Hi Simon,

On Thu, Apr 9, 2020 at 2:58 AM Simon Glass <sjg@chromium.org> wrote:
>
> If U-Boot is running from coreboot we need to skip low-level init. Add
> an way to detect this and to set the gd flag.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Add new patch to detect running from coreboot
>
> Changes in v2: None
>
>  arch/x86/cpu/i386/cpu.c           | 15 +++++++++++++++
>  arch/x86/include/asm/u-boot-x86.h |  7 +++++++
>  2 files changed, 22 insertions(+)
>
> diff --git a/arch/x86/cpu/i386/cpu.c b/arch/x86/cpu/i386/cpu.c
> index c8da7f10e9b..e43444c090b 100644
> --- a/arch/x86/cpu/i386/cpu.c
> +++ b/arch/x86/cpu/i386/cpu.c
> @@ -447,10 +447,25 @@ int x86_cpu_init_f(void)
>         return 0;
>  }
>
> +bool x86_detect_coreboot(void)
> +{
> +       u32 *ptr, *end;
> +
> +       /* We look for LBIO in the first 4K of RAM */
> +       for (ptr = NULL, end = ptr + 0x400; ptr < end; ptr += 4) {

The logic here is not exactly the same as cb_parse_header(). I believe
we should be consistent.

> +               if (*ptr == 0x4f49424c) /* "LBIO" */
> +                       return true;
> +       }
> +
> +       return false;
> +}
> +
>  int x86_cpu_reinit_f(void)
>  {
>         setup_identity();
>         setup_pci_ram_top();
> +       if (x86_detect_coreboot())
> +               gd->flags |= GD_FLG_NO_LL_INIT;
>
>         return 0;
>  }
> diff --git a/arch/x86/include/asm/u-boot-x86.h b/arch/x86/include/asm/u-boot-x86.h
> index 3e5d56d0757..654880f91cb 100644
> --- a/arch/x86/include/asm/u-boot-x86.h
> +++ b/arch/x86/include/asm/u-boot-x86.h
> @@ -43,6 +43,13 @@ int x86_cpu_reinit_f(void);
>   */
>  int x86_cpu_init_tpl(void);
>
> +/**
> + * x86_detect_coreboot() - See if U-Boot is being started from coreboot
> + *
> + * @return true if coreboot is running, false if U-Boot is running 'bare-metal'
> + */
> +bool x86_detect_coreboot(void);
> +
>  int cpu_init_f(void);
>  void setup_gdt(struct global_data *id, u64 *gdt_addr);
>  /*
> --

Regards,
Bin

  reply	other threads:[~2020-04-23 11:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08 18:57 [RESEND PATCH v3 0/7] x86: Improve support for chain-loading U-Boot Simon Glass
2020-04-08 18:57 ` [RESEND PATCH v3 1/7] x86: fsp: Allow skipping init code when chain loading Simon Glass
2020-04-08 18:57 ` [RESEND PATCH v3 2/7] x86: apl: Skip " Simon Glass
2020-04-08 18:57 ` [RESEND PATCH v3 3/7] x86: cpu: " Simon Glass
2020-04-08 18:57 ` [RESEND PATCH v3 4/7] pci: Avoid auto-config " Simon Glass
2020-04-08 18:57 ` [RESEND PATCH v3 5/7] board: Add a gd flag for " Simon Glass
2020-04-23 11:03   ` Bin Meng
2020-04-23 14:00     ` Bin Meng
2020-04-26 19:45       ` Simon Glass
2020-04-08 18:57 ` [RESEND PATCH v3 6/7] x86: Add a way to detect running from coreboot Simon Glass
2020-04-23 11:02   ` Bin Meng [this message]
2020-04-08 18:57 ` [RESEND PATCH v3 7/7] x86: Use the existing stack when chain-loading Simon Glass
2020-04-23 11:06 ` [RESEND PATCH v3 0/7] x86: Improve support for chain-loading U-Boot Bin Meng

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=CAEUhbmV-VRWzLvpy-VmZWm9kuiy0wzrEG1M9annhQxURRLrJLw@mail.gmail.com \
    --to=bmeng.cn@gmail.com \
    --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.