summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2019-01-23 15:13:01 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-02-18 08:51:20 -0800
commit0528c46598c8c89f04b7129722de50e178b62aa2 (patch)
tree9afe729c302f433174b1f8bcecfeaf206d5cb554 /common
parent80020d90d17ac1507abcefe9004ed6ae8cb9728d (diff)
downloadchrome-ec-0528c46598c8c89f04b7129722de50e178b62aa2.tar.gz
core: Allow .bss and .data sections in DRAM
We manually copy other .data from the original section on boot, and clear DRAM .bss. This way, a single object file (or archive) can be moved fully to DRAM. BRANCH=none BUG=b:122058243 TEST=With next CL, dram_test works Change-Id: I1a434bbd8a4135d16b3f49b0d1b75b96506e3e24 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1445652 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/main.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/common/main.c b/common/main.c
index 6adea9b049..0a222b23ca 100644
--- a/common/main.c
+++ b/common/main.c
@@ -17,8 +17,9 @@
#include "flash.h"
#include "gpio.h"
#include "hooks.h"
-#include "lpc.h"
#include "keyboard_scan.h"
+#include "link_defs.h"
+#include "lpc.h"
#ifdef CONFIG_MPU
#include "mpu.h"
#endif
@@ -84,6 +85,14 @@ test_mockable __keep int main(void)
system_pre_init();
system_common_pre_init();
+#ifdef CONFIG_DRAM_BASE
+ /* Now that DRAM is initialized, clear up DRAM .bss, copy .data over. */
+ memset(&__dram_bss_start, 0,
+ (uintptr_t)(&__dram_bss_end) - (uintptr_t)(&__dram_bss_start));
+ memcpy(&__dram_data_start, &__dram_data_lma_start,
+ (uintptr_t)(&__dram_data_end) - (uintptr_t)(&__dram_data_start));
+#endif
+
#if defined(CONFIG_FLASH_PHYSICAL)
/*
* Initialize flash and apply write protect if necessary. Requires