summaryrefslogtreecommitdiff
path: root/include/common.h
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2020-07-19 16:23:23 -0600
committerCommit Bot <commit-bot@chromium.org>2020-08-13 14:26:53 +0000
commite0bf946ced052fe5e857b42da666ba252b03da95 (patch)
treed5218c56b92ecf3e27e62af0a19c8e9d34443134 /include/common.h
parent8ce0c16cc2d153b0002fbea64d08c09d98c3835f (diff)
downloadchrome-ec-e0bf946ced052fe5e857b42da666ba252b03da95.tar.gz
npcx: add support for rom resident sections
EC images are copied in full from flash to RAM. When the code RAM size is smaller than 1/2 the flash size, the EC image size is limited to the code RAM size, leaving unused flash space. Create a new linker section .init_rom used to store data objects that are single use in the previously unused flash area. Data objects can be used at runtime by copying into RAM using the flash_read() function. This change is tied to the NPCX flash layout, with asserts to ensure builds fail if the CONFIG_CHIP_INIT_ROM_REGION is not supported by the chip. CLs that enable CONFIG_CHIP_INIT_ROM_REGION should not be merged until the predecessor CL:2325764 is available in CPFE images. BUG=b:160330682 BRANCH=none TEST=make buildall TEST=With debug code, use the _init_rom macro and validate the data can be read using flash_read(). TEST=Using hex editor, verify .init_rom section located at 192K boundary and unused bytes are filled with 0xFF. TEST=compare_build.sh passes when run against waddledoo (npcx, cortex-m) Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ia0785798fd1938ad6a1c254a070b219027ee82a3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2311268 Reviewed-by: caveh jalali <caveh@chromium.org> Commit-Queue: caveh jalali <caveh@chromium.org>
Diffstat (limited to 'include/common.h')
-rw-r--r--include/common.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index c9a61545e6..92731182dc 100644
--- a/include/common.h
+++ b/include/common.h
@@ -111,6 +111,19 @@
#define __bss_slow __attribute__((section(".bss.slow")))
#endif
+/*
+ * Place a read-only object into a ROM resident section. If supported by the
+ * EC chip, the object is part of the flash image but not copied into RAM
+ * automatically. Users may only access the data using the include/init_rom.h
+ * module.
+ *
+ * Requires CONFIG_CHIP_INIT_ROM_REGION is defined, otherwise the object is
+ * linked into the .rodata section.
+ */
+#ifndef __init_rom
+#define __init_rom __attribute__((section(".init.rom")))
+#endif
+
/* gcc does not support __has_feature */
#ifndef __has_feature
#define __has_feature(x) 0