diff options
author | Simon Glass <sjg@chromium.org> | 2020-04-26 09:12:58 -0600 |
---|---|---|
committer | Bin Meng <bmeng.cn@gmail.com> | 2020-04-30 17:47:06 +0800 |
commit | 33139a0bc7645f73f6e7dd152336e1ee00c9d40e (patch) | |
tree | 0bdce9170a4d567a622f1084c26f97a9ad35f4f1 /arch/x86/cpu/i386 | |
parent | ba974a0137edc86cff9727a83cf6be154ab18ef0 (diff) |
x86: Move coreboot-table detection into common code
To support detecting booting from coreboot, move the code which locates
the coreboot tables into a common place. Adjust the algorithm slightly to
use a word comparison instead of string, since it is faster.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: correct the comments to 960KB]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'arch/x86/cpu/i386')
-rw-r--r-- | arch/x86/cpu/i386/cpu.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/arch/x86/cpu/i386/cpu.c b/arch/x86/cpu/i386/cpu.c index c8da7f10e9..cc20456c89 100644 --- a/arch/x86/cpu/i386/cpu.c +++ b/arch/x86/cpu/i386/cpu.c @@ -447,6 +447,31 @@ 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(); |