memtest86+: Add support for coreboot 'forward' table

This does part of a patch that Stefan wrote for memtest86-3.5,
to update the linuxbios names to coreboot.

https://www.flashrom.org/pipermail/coreboot/2010-January/055363.html

Add support for coreboot table forward. The coreboot table may live
somewhere else in memory, in which case there's only a "forwarder" in
the lower 1MB of memory.

Change-Id: Icd7ba38ae6aa28b6513a9e67d2230129b409c151
Signed-off-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://review.coreboot.org/13946
Tested-by: build bot (Jenkins)
Reviewed-by: Ben Gardner <gardner.ben@gmail.com>
diff --git a/coreboot.c b/coreboot.c
index a5e109e..f1f92b8 100644
--- a/coreboot.c
+++ b/coreboot.c
@@ -98,6 +98,9 @@
 static struct lb_header * find_lb_table(void)
 {
 	struct lb_header *head;
+	struct lb_record *rec;
+	struct lb_forward *forward;
+
 	head = 0;
 	if (!head) {
 		/* First try at address 0 */
@@ -107,6 +110,24 @@
 		/* Then try at address 0xf0000 */
 		head = __find_lb_table(0xf0000, 0x100000);
 	}
+
+	forward = 0;
+	if (head) {
+		/* Check whether there is a forward header */
+		for_each_lbrec(head, rec) {
+			if (rec->tag == LB_TAG_FORWARD) {
+				forward = (struct lb_forward *)rec;
+				break;
+			}
+		}
+	}
+	if (forward) {
+		/* if there is, all valid information is in the
+		 * referenced coreboot table
+		 */
+		head = __find_lb_table(forward->forward, 0x1000);
+	}
+
 	return head;
 }