static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
{
+ unsigned char *ptr = addr;
struct cb_header *header;
- unsigned char *ptr = (unsigned char *)addr;
int i;
- for (i = 0; i < len; i += 16, ptr += 16) {
- header = (struct cb_header *)ptr;
- if (!strncmp((const char *)header->signature, "LBIO", 4))
- break;
- }
-
- /* We walked the entire space and didn't find anything. */
- if (i >= len)
- return -1;
-
+ header = (struct cb_header *)ptr;
if (!header->table_bytes)
return 0;
int get_coreboot_info(struct sysinfo_t *info)
{
- int ret = cb_parse_header((void *)0x00000000, 0x1000, info);
+ long addr;
+ int ret;
- if (ret != 1)
- ret = cb_parse_header((void *)0x000f0000, 0x1000, info);
+ addr = locate_coreboot_table();
+ if (addr < 0)
+ return addr;
+ ret = cb_parse_header((void *)addr, 0x1000, info);
- return (ret == 1) ? 0 : -1;
+ return ret == 1 ? 0 : -ENOENT;
}
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();
*/
void write_coreboot_table(u32 addr, struct memory_area *cfg_tables);
+/**
+ * locate_coreboot_table() - Try to find coreboot tables at standard locations
+ *
+ * @return address of table that was found, or -ve error number
+ */
+long locate_coreboot_table(void);
+
#endif