diff mbox series

[v3,1/7] x86: Move coreboot-table detection to common 32/64-bit code

Message ID 20200501032145.110637-2-sjg@chromium.org
State Accepted
Commit 7ec0e7b6356b12f495b780ecdb25b14204b62a9f
Headers show
Series x86: efi: Add a 64-bit coreboot payload | expand

Commit Message

Simon Glass May 1, 2020, 3:21 a.m. UTC
At present this function is only available in 32-bit code. Move it to the
common cpu file so it can be used by 64-bit U-Boot too.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v3:
- Add new patch to make coreboot detection work in 64-bit code

Changes in v2: None

 arch/x86/cpu/cpu.c      | 25 +++++++++++++++++++++++++
 arch/x86/cpu/i386/cpu.c | 26 +-------------------------
 2 files changed, 26 insertions(+), 25 deletions(-)

Comments

Bin Meng May 1, 2020, 10:25 a.m. UTC | #1
On Fri, May 1, 2020 at 11:22 AM Simon Glass <sjg at chromium.org> wrote:
>
> At present this function is only available in 32-bit code. Move it to the
> common cpu file so it can be used by 64-bit U-Boot too.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> Changes in v3:
> - Add new patch to make coreboot detection work in 64-bit code
>
> Changes in v2: None
>
>  arch/x86/cpu/cpu.c      | 25 +++++++++++++++++++++++++
>  arch/x86/cpu/i386/cpu.c | 26 +-------------------------
>  2 files changed, 26 insertions(+), 25 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
Tested-by: Bin Meng <bmeng.cn at gmail.com>
Bin Meng May 1, 2020, 10:31 a.m. UTC | #2
On Fri, May 1, 2020 at 6:25 PM Bin Meng <bmeng.cn at gmail.com> wrote:
>
> On Fri, May 1, 2020 at 11:22 AM Simon Glass <sjg at chromium.org> wrote:
> >
> > At present this function is only available in 32-bit code. Move it to the
> > common cpu file so it can be used by 64-bit U-Boot too.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> > Changes in v3:
> > - Add new patch to make coreboot detection work in 64-bit code
> >
> > Changes in v2: None
> >
> >  arch/x86/cpu/cpu.c      | 25 +++++++++++++++++++++++++
> >  arch/x86/cpu/i386/cpu.c | 26 +-------------------------
> >  2 files changed, 26 insertions(+), 25 deletions(-)
> >
>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> Tested-by: Bin Meng <bmeng.cn at gmail.com>

applied to u-boot-x86, thanks!
diff mbox series

Patch

diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
index 8526e856d7..2e5d0ddd9f 100644
--- a/arch/x86/cpu/cpu.c
+++ b/arch/x86/cpu/cpu.c
@@ -290,3 +290,28 @@  int reserve_arch(void)
 	return 0;
 }
 #endif
+
+long detect_coreboot_table_at(ulong start, ulong size)
+{
+	u32 *ptr, *end;
+
+	size /= 4;
+	for (ptr = (void *)start, end = ptr + size; ptr < end; ptr += 4) {
+		if (*ptr == 0x4f49424c) /* "LBIO" */
+			return (long)ptr;
+	}
+
+	return -ENOENT;
+}
+
+long locate_coreboot_table(void)
+{
+	long addr;
+
+	/* We look for LBIO in the first 4K of RAM and again at 960KB */
+	addr = detect_coreboot_table_at(0x0, 0x1000);
+	if (addr < 0)
+		addr = detect_coreboot_table_at(0xf0000, 0x1000);
+
+	return addr;
+}
diff --git a/arch/x86/cpu/i386/cpu.c b/arch/x86/cpu/i386/cpu.c
index 0312a26bbb..facd4f58a6 100644
--- a/arch/x86/cpu/i386/cpu.c
+++ b/arch/x86/cpu/i386/cpu.c
@@ -24,6 +24,7 @@ 
 #include <malloc.h>
 #include <spl.h>
 #include <asm/control_regs.h>
+#include <asm/coreboot_tables.h>
 #include <asm/cpu.h>
 #include <asm/mp.h>
 #include <asm/msr.h>
@@ -447,31 +448,6 @@  int x86_cpu_init_f(void)
 	return 0;
 }
 
-long detect_coreboot_table_at(ulong start, ulong size)
-{
-	u32 *ptr, *end;
-
-	size /= 4;
-	for (ptr = (void *)start, end = ptr + size; ptr < end; ptr += 4) {
-		if (*ptr == 0x4f49424c) /* "LBIO" */
-			return (long)ptr;
-	}
-
-	return -ENOENT;
-}
-
-long locate_coreboot_table(void)
-{
-	long addr;
-
-	/* We look for LBIO in the first 4K of RAM and again at 960KB */
-	addr = detect_coreboot_table_at(0x0, 0x1000);
-	if (addr < 0)
-		addr = detect_coreboot_table_at(0xf0000, 0x1000);
-
-	return addr;
-}
-
 int x86_cpu_reinit_f(void)
 {
 	setup_identity();