Aaron Durbin (adurbin(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11503
-gerrit
commit e7c0dcf2e104c47af8fe19d9d7e5f984a1012fae
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Thu Sep 3 11:01:17 2015 -0500
x86: don't create MAINBOARDDIR/romstage.inc for !ROMCC boards
Previously, the x86 romstage build process was unconditionally
creating a romstage.inc and adding it to crt0s. This step is
inherently not necessary in the !ROMCC case becaue the romstage.inc
was created by the compiler outputting assembler. That means
MAINBOARDDIR/romstage.c is truly a C environment that requires
some sort of assembler stub to call into (cache_as_ram.inc from
the chipset dirs). Therefore, remove this processing. The result
is that MAINBOARDDIR/romstage.c can use the normal build steps
in creating an object and linking. The layout of romstage.elf
will change but that's only from a symbol perspective.
BUG=chrome-os-partner:44827
BRANCH=None
TEST=Built multitude of boards. Compared readelf -e output.
Change-Id: I9b8079caaaa55e3ae20d3db4c9b8be04cdc41ab7
Signed-off-by: Aaron Durbin <adurbin(a)chromium.org>
---
src/arch/x86/Makefile.inc | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index b0546f5..00d8d27 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -125,13 +125,19 @@ endif
crt0s += $(cpu_incs-y)
-crt0s += $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc
+ifneq ($(CONFIG_ROMCC),y)
+
+romstage-srcs += $(src)/mainboard/$(MAINBOARDDIR)/romstage.c
-ifeq ($(CONFIG_ROMCC),y)
+else # CONFIG_ROMCC == y
+
+# This order matters. The mainboards requiring ROMCC need their mainboard
+# code to follow the prior crt0s files for program flow control. The
+# romstage.inc from the MAINBOARDDIR is implicitly main() for romstage
+# because of the instruction sequen fall-through.
+crt0s += $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc
crt0s += $(src)/arch/x86/crt0_romcc_epilogue.inc
-endif
-ifeq ($(CONFIG_ROMCC),y)
ifeq ($(CONFIG_MMX),y)
ifeq ($(CONFIG_SSE),y)
ROMCCFLAGS := -mcpu=p4 -O2 # MMX, SSE
@@ -156,17 +162,7 @@ $(objcbfs)/romstage%.elf: $(objcbfs)/romstage%.debug
$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h
printf " ROMCC romstage.inc\n"
$(ROMCC) -c -S $(ROMCCFLAGS) -D__ROMSTAGE__ -D__PRE_RAM__ -I. $(CPPFLAGS_romstage) $< -o $@
-else
-$(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h
- @printf " CC romstage.inc\n"
- $(CC_romstage) $(CPPFLAGS_romstage) $(CFLAGS_romstage) -MMD -D__ROMSTAGE__ -D__PRE_RAM__ -I$(src) -I. -I$(obj) -c -S $< -o $@
-
-$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc
- @printf " POST romstage.inc\n"
- sed -e 's/\.rodata/.rom.data/g' -e 's/\^\.text/.section .rom.text/g' \
- -e 's/\^\.section \.text/.section .rom.text/g' $^ > $@.tmp
- mv $@.tmp $@
endif
romstage-srcs += $(objgenerated)/crt0.S
Aaron Durbin (adurbin(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11513
-gerrit
commit 4229ee11cb98568ef3bc683b8a9ae4c0b778ab69
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Fri Sep 4 16:28:15 2015 -0500
rules.h: add fall through where no ENV_<STAGE> is set
There are cases where rules.h can be pulled in, but the
usage is not associated with a particular stage. For
example, the cpu/ti/am335x build creates an opmap header.
That is a case where there is no stage associated with
the process. Therefore, provide a case of no ENV_>STAGE>
being set.
BUG=chrome-os-partner:44827
BRANCH=None
TEST=Built a myriad of boards. Analyzed readelf output.
Change-Id: Ia9688886d445c961f4a448fc7bfcb28f691609db
Signed-off-by: Aaron Durbin <adubin(a)chromium.org>
---
src/include/rules.h | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/include/rules.h b/src/include/rules.h
index 523031a..2e7f88f 100644
--- a/src/include/rules.h
+++ b/src/include/rules.h
@@ -63,13 +63,23 @@
#define ENV_SECMON 0
#define ENV_VERSTAGE 1
-#else
+#elif defined(__RAMSTAGE__)
#define ENV_BOOTBLOCK 0
#define ENV_ROMSTAGE 0
#define ENV_RAMSTAGE 1
#define ENV_SMM 0
#define ENV_SECMON 0
#define ENV_VERSTAGE 0
+
+#else
+/* Default case of nothing set for random blob generation using
+ * create_class_compiler that isn't bound to a stage. */
+#define ENV_BOOTBLOCK 0
+#define ENV_ROMSTAGE 0
+#define ENV_RAMSTAGE 0
+#define ENV_SMM 0
+#define ENV_SECMON 0
+#define ENV_VERSTAGE 0
#endif
/* For romstage and ramstage always build with simple device model, ie.
Aaron Durbin (adurbin(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11521
-gerrit
commit 6ee4e8627cac4c433acb0095490f012905454c9e
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Sat Sep 5 13:31:14 2015 -0500
x86: link romstage and ramstage with 1 file
To reduce file clutter merge romstage.ld and ramstage.ld
into a single memlayout.ld. The naming is consistent with
other architectures and chipsets for their linker script
names. The cache-as-ram linking rules are put into a separate
file such that other rules can be applied for future verstage
support.
BUG=chrome-os-partner:44827
BRANCH=None
TEST=Built rambi and dmp/vortex86ex.
Change-Id: I1e8982a6a28027566ddd42a71b7e24e2397e68d2
Signed-off-by: Aaron Durbin <adubin(a)chromium.org>
---
src/arch/x86/Makefile.inc | 10 ++++----
src/arch/x86/car.ld | 50 +++++++++++++++++++++++++++++++++++++++
src/arch/x86/memlayout.ld | 42 +++++++++++++++++++++++++++++++++
src/arch/x86/ramstage.ld | 7 ------
src/arch/x86/romstage.ld | 59 -----------------------------------------------
5 files changed, 97 insertions(+), 71 deletions(-)
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 0b8058f..9e5110f 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -113,7 +113,7 @@ endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64
ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
-romstage-y += romstage.ld
+romstage-y += memlayout.ld
# Chipset specific assembly stubs in the romstage program flow. Certain
# boards have more than one assembly stub so collect those and put them
@@ -192,7 +192,7 @@ $(objcbfs)/romstage.debug: $$(romstage-objs) $(objgenerated)/romstage.ld $$(roms
@printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_romstage) --gc-sections -nostdlib -nostartfiles -static -o $@ -L$(obj) $(COMPILER_RT_FLAGS_romstage) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) $(romstage-libs) --no-whole-archive $(COMPILER_RT_romstage) --end-group -T $(objgenerated)/romstage.ld --oformat $(romstage-oformat)
-$(objgenerated)/romstage_null.ld: $(obj)/arch/x86/romstage.romstage.ld
+$(objgenerated)/romstage_null.ld: $(obj)/arch/x86/memlayout.romstage.ld
@printf " GEN $(subst $(obj)/,,$(@))\n"
rm -f $@
printf "ROMSTAGE_BASE = 0x0;\n" > $@.tmp
@@ -288,11 +288,11 @@ $(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
else
-ramstage-y += ramstage.ld
+ramstage-y += memlayout.ld
-$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(obj)/arch/x86/ramstage.ramstage.ld
+$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(obj)/arch/x86/memlayout.ramstage.ld
@printf " CC $(subst $(obj)/,,$(@))\n"
- $(LD_ramstage) $(CPPFLAGS) --gc-sections -o $@ -L$(obj) $< -T $(obj)/arch/x86/ramstage.ramstage.ld
+ $(LD_ramstage) $(CPPFLAGS) --gc-sections -o $@ -L$(obj) $< -T $(obj)/arch/x86/memlayout.ramstage.ld
endif
diff --git a/src/arch/x86/car.ld b/src/arch/x86/car.ld
new file mode 100644
index 0000000..1724a73
--- /dev/null
+++ b/src/arch/x86/car.ld
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2006 Advanced Micro Devices, Inc.
+ * Copyright (C) 2008-2010 coresystems GmbH
+ * Copyright 2015 Google Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.
+ */
+
+ . = CONFIG_DCACHE_RAM_BASE;
+ .car.data . (NOLOAD) : {
+ SYMBOL_CURRENT_LOC(car_data_start)
+#if IS_ENABLED(CONFIG_HAS_PRECBMEM_TIMESTAMP_REGION)
+ TIMESTAMP(., 0x100)
+#endif
+ *(.car.global_data);
+ POINTER_ALIGN
+ SYMBOL_CURRENT_LOC(car_data_end)
+
+ PRERAM_CBMEM_CONSOLE(., (CONFIG_LATE_CBMEM_INIT ? 0 : 0xc00))
+ }
+
+ /* Global variables are not allowed in romstage
+ * This section is checked during stage creation to ensure
+ * that there are no global variables present
+ */
+
+ . = 0xffffff00;
+ .illegal_globals . : {
+ *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/buildOpts.romstage.o" "*/agesawrapper.romstage.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data)
+ *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/buildOpts.romstage.o" "*/agesawrapper.romstage.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data.*)
+ *(.bss)
+ *(.bss.*)
+ *(.sbss)
+ *(.sbss.*)
+ }
+
+ _bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) + 0xc00 <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full");
diff --git a/src/arch/x86/memlayout.ld b/src/arch/x86/memlayout.ld
new file mode 100644
index 0000000..43c5229
--- /dev/null
+++ b/src/arch/x86/memlayout.ld
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.
+ */
+
+#include <memlayout.h>
+#include <arch/header.ld>
+
+SECTIONS
+{
+ /*
+ * It would be good to lay down RAMSTAGE, ROMSTAGE, etc consecutively
+ * like other architectures/chipsets it's not possible because of
+ * the linking games played during romstage creation by trying
+ * to find the final landing place in CBFS for XIP. Therefore,
+ * conditionalize with macros.
+ */
+#if ENV_RAMSTAGE
+ RAMSTAGE(CONFIG_RAMBASE, CONFIG_RAMTOP - CONFIG_RAMBASE)
+
+#elif ENV_ROMSTAGE
+ /* The 1M size is not allocated. It's just for basic size checking. */
+ ROMSTAGE(ROMSTAGE_BASE, 1M)
+
+ /* Pull in the cache-as-ram rules. */
+ #include "car.ld"
+#endif
+}
diff --git a/src/arch/x86/ramstage.ld b/src/arch/x86/ramstage.ld
deleted file mode 100644
index 0d329db..0000000
--- a/src/arch/x86/ramstage.ld
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <memlayout.h>
-#include <arch/header.ld>
-
-SECTIONS
-{
- RAMSTAGE(CONFIG_RAMBASE, CONFIG_RAMTOP - CONFIG_RAMBASE)
-}
diff --git a/src/arch/x86/romstage.ld b/src/arch/x86/romstage.ld
deleted file mode 100644
index 9c44b13..0000000
--- a/src/arch/x86/romstage.ld
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2006 Advanced Micro Devices, Inc.
- * Copyright (C) 2008-2010 coresystems GmbH
- * Copyright 2015 Google Inc
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc.
- */
-
-#include <memlayout.h>
-#include <arch/header.ld>
-
-SECTIONS
-{
- /* The 1M size is not allocated. It's just for basic size checking. */
- ROMSTAGE(ROMSTAGE_BASE, 1M)
-
- . = CONFIG_DCACHE_RAM_BASE;
- .car.data . (NOLOAD) : {
- SYMBOL_CURRENT_LOC(car_data_start)
-#if IS_ENABLED(CONFIG_HAS_PRECBMEM_TIMESTAMP_REGION)
- TIMESTAMP(., 0x100)
-#endif
- *(.car.global_data);
- POINTER_ALIGN
- SYMBOL_CURRENT_LOC(car_data_end)
-
- PRERAM_CBMEM_CONSOLE(., (CONFIG_LATE_CBMEM_INIT ? 0 : 0xc00))
- }
-
- /* Global variables are not allowed in romstage
- * This section is checked during stage creation to ensure
- * that there are no global variables present
- */
-
- . = 0xffffff00;
- .illegal_globals . : {
- *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/buildOpts.romstage.o" "*/agesawrapper.romstage.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data)
- *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/buildOpts.romstage.o" "*/agesawrapper.romstage.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data.*)
- *(.bss)
- *(.bss.*)
- *(.sbss)
- *(.sbss.*)
- }
-
- _bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) + 0xc00 <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full");
-}
Aaron Durbin (adurbin(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11516
-gerrit
commit d54cd08002f2d831e29519b3c827aa17ae3976d5
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Sat Sep 5 10:27:12 2015 -0500
verstage: use common program.ld for linking
There's no reason to have a separate verstage.ld now
that there is a unified stage linking strategy. Moreover
verstage support is throughout the code base as it is
so bring in those link script macros into the common
memlayout.h as that removes one more specific thing a
board/chipset needs to do in order to turn on verstage.
BUG=chrome-os-partner:44827
BRANCH=None
TEST=None
Change-Id: I1195e06e06c1f81a758f68a026167689c19589dd
Signed-off-by: Aaron Durbin <adubin(a)chromium.org>
---
src/include/memlayout.h | 27 ++++++++++
src/lib/Makefile.inc | 1 +
src/soc/broadcom/cygnus/include/soc/memlayout.ld | 1 -
src/soc/imgtec/pistachio/include/soc/memlayout.ld | 1 -
src/soc/marvell/bg4cd/include/soc/memlayout.ld | 1 -
src/soc/nvidia/tegra124/include/soc/memlayout.ld | 1 -
.../tegra132/include/soc/memlayout_vboot2.ld | 1 -
.../tegra210/include/soc/memlayout_vboot2.ld | 1 -
src/soc/qualcomm/ipq806x/include/soc/memlayout.ld | 1 -
src/soc/rockchip/rk3288/include/soc/memlayout.ld | 1 -
.../samsung/exynos5250/include/soc/memlayout.ld | 1 -
src/vendorcode/google/chromeos/memlayout.h | 54 --------------------
src/vendorcode/google/chromeos/vboot2/Makefile.inc | 2 -
src/vendorcode/google/chromeos/vboot2/verstage.ld | 58 ----------------------
14 files changed, 28 insertions(+), 123 deletions(-)
diff --git a/src/include/memlayout.h b/src/include/memlayout.h
index 1a38256..02f67db 100644
--- a/src/include/memlayout.h
+++ b/src/include/memlayout.h
@@ -139,6 +139,33 @@
. += sz;
#endif
+/* Careful: required work buffer size depends on RW properties such as key size
+ * and algorithm -- what works for you might stop working after an update. Do
+ * NOT lower the asserted minimum without consulting vboot devs (rspangler)! */
+#define VBOOT2_WORK(addr, size) \
+ REGION(vboot2_work, addr, size, 16) \
+ _ = ASSERT(size >= 12K, "vboot2 work buffer must be at least 12K!");
+
+#if ENV_VERSTAGE
+ #define VERSTAGE(addr, sz) \
+ SET_COUNTER(verstage, addr) \
+ _ = ASSERT(_eprogram - _program <= sz, \
+ STR(Verstage exceeded its allotted size! (sz))); \
+ INCLUDE "lib/program.verstage.ld"
+
+ #define OVERLAP_VERSTAGE_ROMSTAGE(addr, size) VERSTAGE(addr, size)
+#else
+ #define VERSTAGE(addr, sz) \
+ SET_COUNTER(verstage, addr) \
+ . += sz;
+
+ #define OVERLAP_VERSTAGE_ROMSTAGE(addr, size) ROMSTAGE(addr, size)
+#endif
+
+#define WATCHDOG_TOMBSTONE(addr, size) \
+ REGION(watchdog_tombstone, addr, size, 4) \
+ _ = ASSERT(size == 4, "watchdog tombstones should be exactly 4 byte!");
+
#if ENV_RAMSTAGE || ENV_ROMSTAGE
#define CBMEM_INIT_HOOKS \
POINTER_ALIGN \
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 464d631..d8cd1d8 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -199,6 +199,7 @@ endif
romstage-y += program.ld
ramstage-y += program.ld
+verstage-y += program.ld
ifeq ($(CONFIG_RELOCATABLE_MODULES),y)
ramstage-y += rmodule.c
diff --git a/src/soc/broadcom/cygnus/include/soc/memlayout.ld b/src/soc/broadcom/cygnus/include/soc/memlayout.ld
index 5e149b4..237ffc6 100644
--- a/src/soc/broadcom/cygnus/include/soc/memlayout.ld
+++ b/src/soc/broadcom/cygnus/include/soc/memlayout.ld
@@ -18,7 +18,6 @@
*/
#include <memlayout.h>
-#include <vendorcode/google/chromeos/memlayout.h>
#include <arch/header.ld>
diff --git a/src/soc/imgtec/pistachio/include/soc/memlayout.ld b/src/soc/imgtec/pistachio/include/soc/memlayout.ld
index 366b20a..59e3017 100644
--- a/src/soc/imgtec/pistachio/include/soc/memlayout.ld
+++ b/src/soc/imgtec/pistachio/include/soc/memlayout.ld
@@ -18,7 +18,6 @@
*/
#include <memlayout.h>
-#include <vendorcode/google/chromeos/memlayout.h>
#include <arch/header.ld>
diff --git a/src/soc/marvell/bg4cd/include/soc/memlayout.ld b/src/soc/marvell/bg4cd/include/soc/memlayout.ld
index 15c09d9..45835e2 100644
--- a/src/soc/marvell/bg4cd/include/soc/memlayout.ld
+++ b/src/soc/marvell/bg4cd/include/soc/memlayout.ld
@@ -18,7 +18,6 @@
*/
#include <memlayout.h>
-#include <vendorcode/google/chromeos/memlayout.h>
#include <arch/header.ld>
diff --git a/src/soc/nvidia/tegra124/include/soc/memlayout.ld b/src/soc/nvidia/tegra124/include/soc/memlayout.ld
index 2312cc9..561833d 100644
--- a/src/soc/nvidia/tegra124/include/soc/memlayout.ld
+++ b/src/soc/nvidia/tegra124/include/soc/memlayout.ld
@@ -18,7 +18,6 @@
*/
#include <memlayout.h>
-#include <vendorcode/google/chromeos/memlayout.h>
#include <arch/header.ld>
diff --git a/src/soc/nvidia/tegra132/include/soc/memlayout_vboot2.ld b/src/soc/nvidia/tegra132/include/soc/memlayout_vboot2.ld
index 0f98fd2..a8164a9 100644
--- a/src/soc/nvidia/tegra132/include/soc/memlayout_vboot2.ld
+++ b/src/soc/nvidia/tegra132/include/soc/memlayout_vboot2.ld
@@ -18,7 +18,6 @@
*/
#include <memlayout.h>
-#include <vendorcode/google/chromeos/memlayout.h>
#include <arch/header.ld>
diff --git a/src/soc/nvidia/tegra210/include/soc/memlayout_vboot2.ld b/src/soc/nvidia/tegra210/include/soc/memlayout_vboot2.ld
index c140e01..dee6798 100644
--- a/src/soc/nvidia/tegra210/include/soc/memlayout_vboot2.ld
+++ b/src/soc/nvidia/tegra210/include/soc/memlayout_vboot2.ld
@@ -18,7 +18,6 @@
*/
#include <memlayout.h>
-#include <vendorcode/google/chromeos/memlayout.h>
#include <arch/header.ld>
diff --git a/src/soc/qualcomm/ipq806x/include/soc/memlayout.ld b/src/soc/qualcomm/ipq806x/include/soc/memlayout.ld
index cf417ba..ad0977a 100644
--- a/src/soc/qualcomm/ipq806x/include/soc/memlayout.ld
+++ b/src/soc/qualcomm/ipq806x/include/soc/memlayout.ld
@@ -19,7 +19,6 @@
*/
#include <memlayout.h>
-#include <vendorcode/google/chromeos/memlayout.h>
#include <arch/header.ld>
diff --git a/src/soc/rockchip/rk3288/include/soc/memlayout.ld b/src/soc/rockchip/rk3288/include/soc/memlayout.ld
index 0b75932..b96923e 100644
--- a/src/soc/rockchip/rk3288/include/soc/memlayout.ld
+++ b/src/soc/rockchip/rk3288/include/soc/memlayout.ld
@@ -18,7 +18,6 @@
*/
#include <memlayout.h>
-#include <vendorcode/google/chromeos/memlayout.h>
#include <arch/header.ld>
diff --git a/src/soc/samsung/exynos5250/include/soc/memlayout.ld b/src/soc/samsung/exynos5250/include/soc/memlayout.ld
index 3b5b034..4469078 100644
--- a/src/soc/samsung/exynos5250/include/soc/memlayout.ld
+++ b/src/soc/samsung/exynos5250/include/soc/memlayout.ld
@@ -18,7 +18,6 @@
*/
#include <memlayout.h>
-#include <vendorcode/google/chromeos/memlayout.h>
#include <arch/header.ld>
diff --git a/src/vendorcode/google/chromeos/memlayout.h b/src/vendorcode/google/chromeos/memlayout.h
deleted file mode 100644
index 29434bd..0000000
--- a/src/vendorcode/google/chromeos/memlayout.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright 2014 Google Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc.
- */
-
-/* This file contains macro definitions for memlayout.ld linker scripts. */
-
-#ifndef __CHROMEOS_MEMLAYOUT_H
-#define __CHROMEOS_MEMLAYOUT_H
-
-/* Careful: required work buffer size depends on RW properties such as key size
- * and algorithm -- what works for you might stop working after an update. Do
- * NOT lower the asserted minimum without consulting vboot devs (rspangler)! */
-#define VBOOT2_WORK(addr, size) \
- REGION(vboot2_work, addr, size, 16) \
- _ = ASSERT(size >= 12K, "vboot2 work buffer must be at least 12K!");
-
-#ifdef __VERSTAGE__
- #define VERSTAGE(addr, sz) \
- SET_COUNTER(VERSTAGE, addr) \
- _ = ASSERT(_everstage - _verstage <= sz, \
- STR(Verstage exceeded its allotted size! (sz))); \
- INCLUDE "vendorcode/google/chromeos/vboot2/verstage.verstage.ld"
-#else
- #define VERSTAGE(addr, sz) \
- SET_COUNTER(VERSTAGE, addr) \
- . += sz;
-#endif
-
-#ifdef __VERSTAGE__
- #define OVERLAP_VERSTAGE_ROMSTAGE(addr, size) VERSTAGE(addr, size)
-#else
- #define OVERLAP_VERSTAGE_ROMSTAGE(addr, size) ROMSTAGE(addr, size)
-#endif
-
-#define WATCHDOG_TOMBSTONE(addr, size) \
- REGION(watchdog_tombstone, addr, size, 4) \
- _ = ASSERT(size == 4, "watchdog tombstones should be exactly 4 byte!");
-
-#endif /* __CHROMEOS_MEMLAYOUT_H */
diff --git a/src/vendorcode/google/chromeos/vboot2/Makefile.inc b/src/vendorcode/google/chromeos/vboot2/Makefile.inc
index b805993..21613ba 100644
--- a/src/vendorcode/google/chromeos/vboot2/Makefile.inc
+++ b/src/vendorcode/google/chromeos/vboot2/Makefile.inc
@@ -42,8 +42,6 @@ romstage-y += vboot_handoff.c common.c
ramstage-y += common.c
-verstage-y += verstage.ld
-
ifeq ($(CONFIG_SEPARATE_VERSTAGE),y)
VB_FIRMWARE_ARCH := $(ARCHDIR-$(ARCH-verstage-y))
else
diff --git a/src/vendorcode/google/chromeos/vboot2/verstage.ld b/src/vendorcode/google/chromeos/vboot2/verstage.ld
deleted file mode 100644
index fcb8af8..0000000
--- a/src/vendorcode/google/chromeos/vboot2/verstage.ld
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright 2014 Google Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc.
- */
-
-/* This file is included inside a SECTIONS block */
-
-.text . : {
- _program = .;
- _verstage = .;
- *(.text._start);
- *(.text.stage_entry);
- *(.text);
- *(.text.*);
-} : to_load
-
-.data . : {
- *(.rodata);
- *(.rodata.*);
- *(.data);
- *(.data.*);
- . = ALIGN(8);
-}
-
-.bss . : {
- . = ALIGN(8);
- _bss = .;
- *(.bss)
- *(.bss.*)
- *(.sbss)
- *(.sbss.*)
- _ebss = .;
- _everstage = .;
- _eprogram = .;
-}
-
-/* Discard the sections we don't need/want */
-/DISCARD/ : {
- *(.comment)
- *(.note)
- *(.comment.*)
- *(.note.*)
- *(.eh_frame);
-}
Aaron Durbin (adurbin(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11507
-gerrit
commit d478c79c2f34c6b0efe68f8231b04f6ee45fef44
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Thu Sep 3 22:49:36 2015 -0500
linking: lay the groundwork for a unified linking approach
Though coreboot started as x86 only, the current approach to x86
linking is out of the norm with respect to other architectures.
To start alleviating that the way ramstage is linked is partially
unified. A new file, program.ld, was added to provide a common way
to link stages by deferring to per-stage architectural overrides.
The previous ramstage.ld is no longer required.
Note that this change doesn't handle RELOCATABLE_RAMSTAGE
because that is handled by rmodule.ld. Future convergence
can be achieved, but for the time being that's being left out.
BUG=chrome-os-partner:44827
BRANCH=None
TEST=Built a myriad of boards.
Change-Id: I5d689bfa7e0e9aff3a148178515ef241b5f70661
Signed-off-by: Aaron Durbin <adubin(a)chromium.org>
---
src/arch/x86/Makefile.inc | 2 +-
src/arch/x86/include/arch/memlayout.h | 25 +++++++
src/arch/x86/ramstage.ld | 2 +-
src/include/memlayout.h | 126 ++++++++++++++++++++++++++++++++--
src/lib/Makefile.inc | 3 +-
src/lib/program.ld | 66 ++++++++++++++++++
src/lib/ramstage.ld | 115 -------------------------------
7 files changed, 217 insertions(+), 122 deletions(-)
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index fe974ef..9d3f07f 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -289,7 +289,7 @@ $(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
else
-ramstage-srcs += $(src)/arch/x86/ramstage.ld
+ramstage-y += ramstage.ld
$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(obj)/arch/x86/ramstage.ramstage.ld
@printf " CC $(subst $(obj)/,,$(@))\n"
diff --git a/src/arch/x86/include/arch/memlayout.h b/src/arch/x86/include/arch/memlayout.h
new file mode 100644
index 0000000..54b8b4a
--- /dev/null
+++ b/src/arch/x86/include/arch/memlayout.h
@@ -0,0 +1,25 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.
+ */
+
+#ifndef __ARCH_MEMLAYOUT_H
+#define __ARCH_MEMLAYOUT_H
+
+/* Currently empty to satisfy common arch requirements. */
+
+#endif /* __ARCH_MEMLAYOUT_H */
diff --git a/src/arch/x86/ramstage.ld b/src/arch/x86/ramstage.ld
index 5fcbbb6..c9b2f17 100644
--- a/src/arch/x86/ramstage.ld
+++ b/src/arch/x86/ramstage.ld
@@ -19,7 +19,7 @@ SECTIONS
{
. = CONFIG_RAMBASE;
- INCLUDE "lib/ramstage.ramstage.ld"
+ INCLUDE "lib/program.ramstage.ld"
_ = ASSERT( ( _eprogram < (CONFIG_RAMTOP)) , "Please increase CONFIG_RAMTOP");
}
diff --git a/src/include/memlayout.h b/src/include/memlayout.h
index a529628..3b3ff6d 100644
--- a/src/include/memlayout.h
+++ b/src/include/memlayout.h
@@ -22,10 +22,41 @@
#ifndef __MEMLAYOUT_H
#define __MEMLAYOUT_H
+#include <rules.h>
#include <arch/memlayout.h>
+/* Macros that the architecture can override. */
+#ifndef ARCH_POINTER_ALIGN_SIZE
+#define ARCH_POINTER_ALIGN_SIZE 8
+#endif
+
+#ifndef ARCH_CACHELINE_ALIGN_SIZE
+#define ARCH_CACHELINE_ALIGN_SIZE 64
+#endif
+
+#ifndef ARCH_FIRST_TEXT
+#define ARCH_FIRST_TEXT
+#endif
+
+/* Default to data as well as bss. */
+#ifndef ARCH_STAGE_HAS_DATA_SECTION
+#define ARCH_STAGE_HAS_DATA_SECTION 1
+#endif
+
+#ifndef ARCH_STAGE_HAS_BSS_SECTION
+#define ARCH_STAGE_HAS_BSS_SECTION 1
+#endif
+
+/* Default is that currently ramstage and smm only has a heap. */
+#ifndef ARCH_STAGE_HAS_HEAP_SECTION
+#define ARCH_STAGE_HAS_HEAP_SECTION (ENV_RAMSTAGE || ENV_SMM)
+#endif
+
#define STR(x) #x
+#define ALIGN_COUNTER(align) \
+ . = ALIGN(align);
+
#define SET_COUNTER(name, addr) \
_ = ASSERT(. <= addr, STR(name overlaps the previous region!)); \
. = addr;
@@ -34,6 +65,9 @@
SET_COUNTER(name, addr) \
_##name = .;
+#define SYMBOL_CURRENT_LOC(name) \
+ _##name = .;
+
#define REGION(name, addr, size, expected_align) \
SYMBOL(name, addr) \
_ = ASSERT(. == ALIGN(expected_align), \
@@ -58,7 +92,7 @@
/* TODO: This only works if you never access CBFS in romstage before RAM is up!
* If you need to change that assumption, you have some work ahead of you... */
-#if defined(__PRE_RAM__) && !defined(__ROMSTAGE__)
+#if defined(__PRE_RAM__) && !ENV_ROMSTAGE
#define PRERAM_CBFS_CACHE(addr, size) CBFS_CACHE(addr, size)
#define POSTRAM_CBFS_CACHE(addr, size) \
REGION(unused_cbfs_cache, addr, size, 4)
@@ -93,16 +127,100 @@
. += sz;
#endif
-#ifdef __RAMSTAGE__
+#if ENV_RAMSTAGE
#define RAMSTAGE(addr, sz) \
SET_COUNTER(ramstage, addr) \
- _ = ASSERT(_eramstage - _ramstage <= sz, \
+ _ = ASSERT(_eprogram - _program <= sz, \
STR(Ramstage exceeded its allotted size! (sz))); \
- INCLUDE "lib/ramstage.ramstage.ld"
+ INCLUDE "lib/program.ramstage.ld"
#else
#define RAMSTAGE(addr, sz) \
SET_COUNTER(ramstage, addr) \
. += sz;
#endif
+#if ENV_RAMSTAGE || ENV_ROMSTAGE
+#define CBMEM_INIT_HOOKS \
+ POINTER_ALIGN \
+ SYMBOL_CURRENT_LOC(cbmem_init_hooks) \
+ KEEP(*(.rodata.cbmem_init_hooks)); \
+ SYMBOL_CURRENT_LOC(ecbmem_init_hooks)
+#else
+#define CBMEM_INIT_HOOKS
+#endif
+
+#if ENV_RAMSTAGE
+#define DRIVERS_RODATA \
+ POINTER_ALIGN \
+ SYMBOL_CURRENT_LOC(pci_drivers) \
+ KEEP(*(.rodata.pci_driver)); \
+ SYMBOL_CURRENT_LOC(epci_drivers) \
+ POINTER_ALIGN \
+ SYMBOL_CURRENT_LOC(cpu_drivers) \
+ KEEP(*(.rodata.cpu_driver)); \
+ SYMBOL_CURRENT_LOC(ecpu_drivers)
+#else
+#define DRIVERS_RODATA
+#endif
+
+#define BEGIN_SECTION(name, align) \
+ .##name : { \
+ ALIGN_COUNTER(align) \
+ SYMBOL_CURRENT_LOC(name)
+
+#define END_SECTION(name, align) \
+ ALIGN_COUNTER(align) \
+ SYMBOL_CURRENT_LOC(e##name) \
+ }
+
+#if ARCH_STAGE_HAS_DATA_SECTION
+#ifdef __PRE_RAM__
+/* Provide these symbols in PRE_RAM environments if not already provided. */
+#define DATA_EXTRA \
+ PROVIDE(_preram_cbmem_console = .); \
+ PROVIDE(_epreram_cbmem_console = _preram_cbmem_console);
+#elif ENV_RAMSTAGE
+#define DATA_EXTRA \
+ SYMBOL_CURRENT_LOC(bs_init_begin) \
+ KEEP(*(.bs_init)); \
+ LONG(0); \
+ LONG(0); \
+ SYMBOL_CURRENT_LOC(ebs_init_begin)
+#else
+#define DATA_EXTRA
+#endif
+
+#define DATA_SECTION \
+ BEGIN_SECTION(data, ARCH_CACHELINE_ALIGN_SIZE) \
+ *(.data); \
+ *(.data.*); \
+ DATA_EXTRA \
+ END_SECTION(data, ARCH_POINTER_ALIGN_SIZE)
+#else
+#define DATA_SECTION
+#endif
+
+#if ARCH_STAGE_HAS_BSS_SECTION
+#define BSS_SECTION \
+ BEGIN_SECTION(bss, ARCH_POINTER_ALIGN_SIZE) \
+ *(.bss) \
+ *(.bss.*) \
+ *(.sbss) \
+ *(.sbss.*) \
+ END_SECTION(bss, ARCH_POINTER_ALIGN_SIZE)
+#else
+#define BSS_SECTION
+#endif
+
+#if ARCH_STAGE_HAS_HEAP_SECTION
+#define HEAP_SECTION \
+ BEGIN_SECTION(heap, ARCH_POINTER_ALIGN_SIZE) \
+ . += CONFIG_HEAP_SIZE ; \
+ END_SECTION(heap, ARCH_POINTER_ALIGN_SIZE)
+#else
+#define HEAP_SECTION
+#endif
+
+#define POINTER_ALIGN ALIGN_COUNTER(ARCH_POINTER_ALIGN_SIZE)
+
#endif /* __MEMLAYOUT_H */
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 8597667..cd2b70a 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -197,7 +197,8 @@ ifneq ($(CONFIG_ARCH_X86),y)
bootblock-y += bootblock.ld
romstage-y += romstage.ld
endif
-ramstage-y += ramstage.ld
+
+ramstage-y += program.ld
ifeq ($(CONFIG_RELOCATABLE_MODULES),y)
ramstage-y += rmodule.c
diff --git a/src/lib/program.ld b/src/lib/program.ld
new file mode 100644
index 0000000..f4850d3
--- /dev/null
+++ b/src/lib/program.ld
@@ -0,0 +1,66 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.
+ */
+
+#include <memlayout.h>
+
+/* This file is included inside a SECTIONS block */
+
+/* First we place the code and read only data (typically const declared).
+ * This could theoretically be placed in rom.
+ */
+BEGIN_SECTION(text, 1)
+ SYMBOL_CURRENT_LOC(program)
+ ARCH_FIRST_TEXT
+ *(.text._start);
+ *(.text.stage_entry);
+ *(.text);
+ *(.text.*);
+ POINTER_ALIGN
+ CBMEM_INIT_HOOKS
+ DRIVERS_RODATA
+ *(.rodata);
+ *(.rodata.*);
+ POINTER_ALIGN
+END_SECTION(text, 1) : to_load
+
+#if ENV_RAMSTAGE && IS_ENABLED(CONFIG_COVERAGE)
+BEGIN_SECTION(ctors, 0x100)
+ SYMBOL_CURRENT_LOC(__CTOR_LIST__)
+ KEEP(*(.ctors));
+ LONG(0);
+ LONG(0);
+ SYMBOL_CURRENT_LOC(__CTOR_END__)
+END_SECTION(ctors, 1)
+#endif
+
+/* Include data, bss, and heap in that order. Not defined for all stages. */
+DATA_SECTION
+BSS_SECTION
+HEAP_SECTION
+SYMBOL_CURRENT_LOC(eprogram)
+
+/* Discard the sections we don't need/want */
+
+/DISCARD/ : {
+ *(.comment)
+ *(.comment.*)
+ *(.note)
+ *(.note.*)
+ *(.eh_frame);
+}
diff --git a/src/lib/ramstage.ld b/src/lib/ramstage.ld
deleted file mode 100644
index b224827..0000000
--- a/src/lib/ramstage.ld
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright 2014 Google Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc.
- */
-
-/* This file is included inside a SECTIONS block */
-
-/* First we place the code and read only data (typically const declared).
- * This could theoretically be placed in rom.
- */
-.text : {
- _program = .;
- _ramstage = .;
- _text = .;
- *(.text._start);
- *(.text.stage_entry);
- *(.text);
- *(.text.*);
- . = ALIGN(16);
- _etext = .;
-} : to_load
-
-#if IS_ENABLED(CONFIG_COVERAGE)
-.ctors : {
- . = ALIGN(0x100);
- __CTOR_LIST__ = .;
- KEEP(*(.ctors));
- LONG(0);
- LONG(0);
- __CTOR_END__ = .;
-}
-#endif
-
-/* TODO: align data sections to cache lines? (is that really useful?) */
-.rodata : {
- _rodata = .;
- . = ALIGN(8);
-
- /* If any changes are made to the driver start/symbols or the
- * section names the equivalent changes need to made to
- * rmodule.ld. */
- _pci_drivers = . ;
- KEEP(*(.rodata.pci_driver));
- _epci_drivers = . ;
- _cpu_drivers = . ;
- KEEP(*(.rodata.cpu_driver));
- _ecpu_drivers = . ;
- _bs_init_begin = .;
- KEEP(*(.bs_init));
- LONG(0);
- LONG(0);
- _bs_init_end = .;
- _cbmem_init_hooks = .;
- KEEP(*(.rodata.cbmem_init_hooks));
- _ecbmem_init_hooks = .;
-
- *(.rodata)
- *(.rodata.*)
- /* kevinh/Ispiri - Added an align, because the objcopy tool
- * incorrectly converts sections that are not long word aligned.
- */
- . = ALIGN(8);
-
- _erodata = .;
-}
-
-.data : {
- /* Move to different cache line to avoid false sharing with .rodata. */
- . = ALIGN(64); /* May not be actual line size, not that important. */
- _data = .;
- *(.data)
- *(.data.*)
- _edata = .;
-}
-
-.bss . : {
- _bss = .;
- *(.bss)
- *(.bss.*)
- *(.sbss)
- *(.sbss.*)
- _ebss = .;
-}
-
-.heap . : {
- _heap = .;
- /* Reserve CONFIG_HEAP_SIZE bytes for the heap */
- . += CONFIG_HEAP_SIZE ;
- . = ALIGN(4);
- _eheap = .;
- _eramstage = .;
- _eprogram = .;
-}
-
-/* Discard the sections we don't need/want */
-
-/DISCARD/ : {
- *(.comment)
- *(.note)
- *(.note.*)
-}