diff options
author | Fabio Baltieri <fabiobaltieri@google.com> | 2021-04-19 15:58:20 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-19 22:06:01 +0000 |
commit | 748deb2db0ecc013c04c72768fd99467d5ddec6f (patch) | |
tree | 8cbc28002fadb48d8fbe8d1f4106a385dce7138c | |
parent | 0d669d95d4b9062290cfd30acdb32c69f5f396cd (diff) | |
download | chrome-ec-748deb2db0ecc013c04c72768fd99467d5ddec6f.tar.gz |
zephyr: hooks: store deferred data in .rodata on non-posix
Change the deferred data section from .data.hooks to .rodata.hooks,
matching the ECOS behavior. This was apparently done for compatibility
with native_posix, so only make this change when we are not on
ARCH_POSIX.
The change means that the hooks data is not copied in RAM anymore, which
saves a significant amount of device memory.
For volteer, before:
text data bss dec hex filename
223934 9716 40092 273742 42d4e build-ro/zephyr/zephyr.elf
After:
text data bss dec hex filename
225730 7924 40092 273746 42d52 build-ro/zephyr/zephyr.elf
Compared to ECOS:
text data bss dec hex filename
203680 6384 33676 243740 3b81c volteer/RO/ec.RO.elf
BUG=b:183748844
BRANCH=none
TEST=build and run on volteer
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change-Id: Ia23e9c0dc5ee9eaeee674f943b22762355ad5efe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2836100
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | zephyr/shim/include/zephyr_hooks_shim.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/zephyr/shim/include/zephyr_hooks_shim.h b/zephyr/shim/include/zephyr_hooks_shim.h index e19f311af5..154dbd9679 100644 --- a/zephyr/shim/include/zephyr_hooks_shim.h +++ b/zephyr/shim/include/zephyr_hooks_shim.h @@ -38,12 +38,20 @@ void zephyr_shim_setup_deferred(const struct deferred_data *data); * See include/hooks.h for documentation. * * Typically Zephyr would put const data in the rodata section but that is - * write-protected with native_posix. So force it into .data instead. + * write-protected with native_posix. So force it into .data when building for + * ARCH_POSIX and put it in .rodata in all other cases so that it does not take + * extra RAM space. */ +#ifdef CONFIG_ARCH_POSIX +#define DEFERRED_DATA_SECTION ".data.hooks" +#else +#define DEFERRED_DATA_SECTION ".rodata.hooks" +#endif + #define DECLARE_DEFERRED(routine) _DECLARE_DEFERRED(routine) #define _DECLARE_DEFERRED(_routine) \ __maybe_unused const struct deferred_data _routine##_data \ - __attribute__((section(".data.hooks"))) = { \ + __attribute__((section(DEFERRED_DATA_SECTION))) = { \ .routine = _routine, \ }; \ static int _setup_deferred_##_routine(const struct device *unused) \ |