Move option table (cmos.layout's binary representation)
to CBFS and adapt coreboot to use it.

Comments by Stefan and Mathias taken into account (except for
the build time failure if the table is missing when it should
exist and the "memory leak" in build_opt_tbl)

Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com>
Acked-by: Stefan Reinauer <stepan@coreboot.org>


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6268 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 92c4f67..6cd475f 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -27,7 +27,10 @@
 
 OPTION_TABLE_H:=
 ifeq ($(CONFIG_HAVE_OPTION_TABLE),y)
-ramstage-srcs += $(obj)/option_table.c
+cbfs-files-y += $(obj)/cmos_layout.bin
+$(obj)/cmos_layout.bin-name = cmos_layout.bin
+$(obj)/cmos_layout.bin-type = 0x01aa
+
 OPTION_TABLE_H:=$(obj)/option_table.h
 endif
 
@@ -64,7 +67,7 @@
 		$(CBFSTOOL) $@ add $(call extract_nth,1,$(file)) $(call extract_nth,2,$(file)) $(call extract_nth,3,$(file)) $(call extract_nth,4,$(file)); )
 prebuilt-files = $(foreach file,$(cbfs-files), $(call extract_nth,1,$(file)))
 
-$(obj)/coreboot.pre1: $(obj)/coreboot.bootblock $(prebuilt-files) $(CBFSTOOL)
+$(obj)/coreboot.pre1: $(obj)/coreboot.bootblock $$(prebuilt-files) $(CBFSTOOL)
 	rm -f $@
 	$(CBFSTOOL) $@ create $(CONFIG_COREBOOT_ROMSIZE_KB)K $(obj)/coreboot.bootblock
 	$(prebuild-files)
@@ -121,9 +124,9 @@
 	@printf "    OPTION     $(subst $(obj)/,,$(@))\n"
 	$(objutil)/options/build_opt_tbl --config $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout --header $@
 
-$(obj)/option_table.c: $(objutil)/options/build_opt_tbl $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
+$(obj)/cmos_layout.bin: $(objutil)/options/build_opt_tbl $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
 	@printf "    OPTION     $(subst $(obj)/,,$(@))\n"
-	$(objutil)/options/build_opt_tbl --config $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout --option $@
+	$(objutil)/options/build_opt_tbl --config $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout --binary $@
 
 $(objutil)/options/build_opt_tbl: $(top)/util/options/build_opt_tbl.c $(top)/src/include/pc80/mc146818rtc.h $(top)/src/include/boot/coreboot_tables.h
 	@printf "    HOSTCC     $(subst $(obj)/,,$(@))\n"
diff --git a/src/arch/x86/boot/coreboot_table.c b/src/arch/x86/boot/coreboot_table.c
index 484340c..3dc8ea6 100644
--- a/src/arch/x86/boot/coreboot_table.c
+++ b/src/arch/x86/boot/coreboot_table.c
@@ -542,11 +542,14 @@
 
 #if (CONFIG_USE_OPTION_TABLE == 1)
 	{
-		struct lb_record *rec_dest = lb_new_record(head);
-		/* Copy the option config table, it's already a lb_record... */
-		memcpy(rec_dest,  &option_table, option_table.size);
-		/* Create cmos checksum entry in coreboot table */
-		lb_cmos_checksum(head);
+		struct cmos_option_table option_table = cbfs_find_file("cmos_layout.bin", 0x1aa);
+		if (option_table) {
+			struct lb_record *rec_dest = lb_new_record(head);
+			/* Copy the option config table, it's already a lb_record... */
+			memcpy(rec_dest,  &option_table, option_table.size);
+			/* Create cmos checksum entry in coreboot table */
+			lb_cmos_checksum(head);
+		}
 	}
 #endif
 	/* Record where RAM is located */
diff --git a/src/arch/x86/include/arch/coreboot_tables.h b/src/arch/x86/include/arch/coreboot_tables.h
index 3c9bf98..773e053 100644
--- a/src/arch/x86/include/arch/coreboot_tables.h
+++ b/src/arch/x86/include/arch/coreboot_tables.h
@@ -16,8 +16,6 @@
  */
 struct lb_memory *get_lb_mem(void);
 
-extern struct cmos_option_table option_table;
-
 /* defined by mainboard.c if the mainboard requires extra resources */
 int add_mainboard_resources(struct lb_memory *mem);
 int add_northbridge_resources(struct lb_memory *mem);