[U-Boot] [PATCH v2 19/20] x86: Tidy up the LAPIC init code

Bin Meng bmeng.cn at gmail.com
Wed Apr 29 16:04:09 CEST 2015


Hi Simon,

On Wed, Apr 29, 2015 at 10:25 AM, Simon Glass <sjg at chromium.org> wrote:
> We don't need to support really old x86 CPUs, so drop this code.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> Changes in v2: None
>
>  arch/x86/cpu/lapic.c         | 20 ++++++++++++--------
>  arch/x86/include/asm/lapic.h |  7 -------
>  2 files changed, 12 insertions(+), 15 deletions(-)
>
> diff --git a/arch/x86/cpu/lapic.c b/arch/x86/cpu/lapic.c
> index 4690603..0c9c324 100644
> --- a/arch/x86/cpu/lapic.c
> +++ b/arch/x86/cpu/lapic.c
> @@ -15,7 +15,6 @@
>
>  void lapic_setup(void)
>  {
> -#if NEED_LAPIC == 1
>         /* Only Pentium Pro and later have those MSR stuff */
>         debug("Setting up local apic: ");
>
> @@ -46,12 +45,17 @@ void lapic_setup(void)
>                 (LAPIC_LVT_REMOTE_IRR | LAPIC_SEND_PENDING |
>                         LAPIC_DELIVERY_MODE_NMI));
>
> -       debug("apic_id: 0x%02lx, ", lapicid());
> -#else /* !NEED_LLAPIC */
> -       /* Only Pentium Pro and later have those MSR stuff */
> -       debug("Disabling local apic: ");
> -       disable_lapic();
> -#endif /* !NEED_LAPIC */
> -       debug("done.\n");
> +       debug("apic_id: 0x%02lx\n", lapicid());
>         post_code(POST_LAPIC);
>  }
> +
> +void lapic_enable(void)
> +{
> +       msr_t msr;
> +
> +       msr = msr_read(LAPIC_BASE_MSR);
> +       msr.hi &= 0xffffff00;
> +       msr.lo &= 0x000007ff;
> +       msr.lo |= LAPIC_DEFAULT_BASE | LAPIC_BASE_MSR_ENABLE;
> +       msr_write(LAPIC_BASE_MSR, msr);
> +}

This is duplicated. There is already a enable_lapic() in lapic.h which
has the same codes.

> diff --git a/arch/x86/include/asm/lapic.h b/arch/x86/include/asm/lapic.h
> index 0a7f443..dff75c5 100644
> --- a/arch/x86/include/asm/lapic.h
> +++ b/arch/x86/include/asm/lapic.h
> @@ -14,13 +14,6 @@
>  #include <asm/msr.h>
>  #include <asm/processor.h>
>
> -/* See if I need to initialize the local apic */
> -#if CONFIG_SMP || CONFIG_IOAPIC
> -#  define NEED_LAPIC 1
> -#else
> -#  define NEED_LAPIC 0
> -#endif
> -
>  static inline __attribute__((always_inline))
>                 unsigned long lapic_read(unsigned long reg)
>  {
> --

Regards,
Bin


More information about the U-Boot mailing list