Zheng Bao (zheng.bao(a)amd.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11520
-gerrit
commit 1f6246dd823c1d3cb39603a177d1aa5ee2c345c6
Author: zbao <fishbaozi(a)gmail.com>
Date: Sun Sep 6 02:10:42 2015 -0400
buildgcc: Show the progress when downloading *still working*.
For some systems, the commands are buffered by default. On these
systems, the progress can not been seen, except the final "ok".
Change-Id: I4559e88d541738a594dce92e23589992f234cb9b
Signed-off-by: Zheng Bao <zheng.bao(a)amd.com>
Signed-off-by: Zheng Bao <fishbaozi(a)gmail.com>
---
util/crossgcc/buildgcc | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index 0ed9a39..a8612ca 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -188,6 +188,13 @@ compute_sum() {
printf "(checksum created. ${RED}Note. Please upload sum/$1.cksum if the corresponding archive is upgraded.)${NC}"
}
+download_one() {
+ url=$1
+ printf " .. "
+ wget --no-check-certificate $url 2>&1 | grep --line-buffered -o "[0-9]\+%" | awk '{printf("\b\b\b\b%4s", $1)}'
+ printf "\b\b\b\b${green} ok${NC}"
+}
+
download() {
package=$1
archive="$(eval echo \$$package"_ARCHIVE")"
@@ -201,14 +208,13 @@ download() {
printf "(downloading from $archive)"
rm -f tarballs/$FILE
cd tarballs
- wget --no-check-certificate -q $archive
- wgetret=$?
+ download_one $archive
cd ..
compute_sum $FILE
fi
if [ ! -f tarballs/$FILE ]; then
- printf "\n${RED}Failed to download $FILE. Wget returns $wgetret. See 'man wget'.${NC}\n"
+ printf "\n${RED}Failed to download $FILE.${NC}\n"
exit 1
fi
printf "\n"
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11519
-gerrit
commit 21716a5d3464e183c6fa08a215591a2aff5bc617
Author: Patrick Georgi <patrick(a)georgi-clan.de>
Date: Sat Sep 5 20:21:24 2015 +0200
smmhandler: on i945..nehalem, crash if LAPIC overlaps with ASEG
This mitigates the Memory Sinkhole issue (described on
https://github.com/xoreaxeaxeax/sinkhole) by checking for the issue and
crashing the system explicitly if LAPIC overlaps ASEG.
This needs to happen without a data access (only code fetches) because
data accesses could be tampered with.
Don't try to recover because, if somebody tried to do shenanigans like
these, we have to expect more.
Sandybridge is safe because it does the same test in hardware, and
crashes. Newer chipsets presumably do the same.
This needs to be extended to deal with overlapping TSEG as well.
Change-Id: I508c0b10ab88779da81d18a94b08dcfeca6f5a6f
Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de>
---
src/cpu/x86/smm/smmhandler.S | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/src/cpu/x86/smm/smmhandler.S b/src/cpu/x86/smm/smmhandler.S
index 7b70ce9..f2094ef 100644
--- a/src/cpu/x86/smm/smmhandler.S
+++ b/src/cpu/x86/smm/smmhandler.S
@@ -25,6 +25,10 @@
* to 64k if we can though.
*/
+#include <kconfig.h>
+#include <config.h>
+#define LAPIC_BASE_MSR 0x1b
+
/*
* +--------------------------------+ 0xaffff
* | Save State Map Node 0 |
@@ -74,8 +78,39 @@
*
* All the bad magic is not all that bad after all.
*/
+#define SMM_START 0xa0000
+#define SMM_END 0xb0000
+#if SMM_END <= SMM_START
+#error invalid SMM configuration
+#endif
.global smm_handler_start
smm_handler_start:
+#if IS_ENABLED(CONFIG_NORTHBRIDGE_INTEL_NEHALEM) || \
+ IS_ENABLED(CONFIG_NORTHBRIDGE_INTEL_GM45) || \
+ IS_ENABLED(CONFIG_NORTHBRIDGE_INTEL_I945)
+ mov $LAPIC_BASE_MSR, %ecx
+ rdmsr
+ and $(~0xfff), %eax
+ sub $(SMM_START), %eax
+ cmp $(SMM_END - SMM_START), %eax
+ ja untampered_lapic
+1:
+ // "Crash"
+ mov $(CONFIG_TTYS0_BASE), %dx
+ mov $'C', %al
+ out %al, (%dx)
+ mov $'r', %al
+ out %al, (%dx)
+ mov $'a', %al
+ out %al, (%dx)
+ mov $'s', %al
+ out %al, (%dx)
+ mov $'h', %al
+ out %al, (%dx)
+ // now crash for real
+ ud2
+untampered_lapic:
+#endif
movw $(smm_gdtptr16 - smm_handler_start + SMM_HANDLER_OFFSET), %bx
data32 lgdt %cs:(%bx)
Aaron Durbin (adurbin(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11518
-gerrit
commit e8e0e7d0433385f43118c3d277083a5618dfc928
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Sat Sep 5 13:17:25 2015 -0500
rmodtool: honor ELF entry point
Instead of using a pre-determined symbol, _start, use
the entry point within the ELF header.
BUG=chrome-os-partner:44827
BRANCH=None
TEST=Built rambi and analyzed the relocatable ramstage,
sipi_vector, and smm rmodules.
Change-Id: I53e9c6eaa1ce761ab8519677fe2f4d0d2b82bb40
Signed-off-by: Aaron Durbin <adubin(a)chromium.org>
---
util/cbfstool/rmodule.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/util/cbfstool/rmodule.c b/util/cbfstool/rmodule.c
index 3b127b2..c35eff7 100644
--- a/util/cbfstool/rmodule.c
+++ b/util/cbfstool/rmodule.c
@@ -416,8 +416,8 @@ static int populate_program_info(struct rmod_context *ctx)
if (populate_sym(ctx, "_ebss", &ctx->bss_end, nsyms, strtab))
return -1;
- if (populate_sym(ctx, "_start", &ctx->entry, nsyms, strtab))
- return -1;
+ /* Honor the entry point within the ELF header. */
+ ctx->entry = ehdr->e_entry;
/* Link address is the virtual address of the program segment. */
ctx->link_addr = ctx->phdr->p_vaddr;
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 4dc3c98750f690e86bc5ec3e9adc4c92cadd2de5
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Sat Sep 5 11:08:02 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 e86246f..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(_eprogram - _program <= 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 e304dbdd9d13b6f1f919af8ebba25d84fcc6303e
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 8311b11..23a24f2 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.*)
-}