Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / x86 / cpu / cpu.c
index 8526e856d7d47f97726c05ab389da2ade5a403ae..a814e7d7a649896c0c13e945dc9392bd54e543f5 100644 (file)
  */
 
 #include <common.h>
+#include <bootstage.h>
 #include <command.h>
 #include <cpu_func.h>
 #include <dm.h>
 #include <errno.h>
 #include <init.h>
+#include <log.h>
 #include <malloc.h>
 #include <syscon.h>
 #include <acpi/acpi_s3.h>
@@ -290,3 +292,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;
+}