diff options
author | Keith Short <keithshort@chromium.org> | 2021-01-26 17:56:17 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-28 01:18:43 +0000 |
commit | bb44e3a55f85565b461b93f209acf523e62cd8ed (patch) | |
tree | df6571fc8ec1247307ae31963d54c9c774bb70bd | |
parent | 12b19cf3df340c483dd18a38183cb80d5302ac8f (diff) | |
download | chrome-ec-bb44e3a55f85565b461b93f209acf523e62cd8ed.tar.gz |
common: Add attribute to store const data in .data
On EC chips that support CONFIG_CHIP_DATA_IN_INIT_ROM, the code
execution RAM is smaller than flash, leaving some flash unused.
The CONFIG_CHIP_DATA_IN_INIT_ROM moves the .data section into the unused
flash area, where it is copied directly into data RAM at startup.
Add a new attribute __const_data that allows constant data objects to
link into the .data section instead of .rodata.
This saves 1600 bytes of RO and RW flash space on boards that enable
CONFIG_CHIP_DATA_IN_INIT_ROM.
delbin_npcx796fc
eldrid_npcx796fc
halvor
lindar
lingcod
magolor_legacy
malefor
metaknight_legacy
terrador
todor
trondo
voema
volteer_apmodeentry
volteer
waddledoo
BUG=none
BRANCH=none
TEST=make buildall
TEST=boot Volteer and verify USB-PD operation
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: Ibb97a499442bbab8185b1d07f8867a7af1e793f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2651208
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
(cherry picked from commit ca4e4647d0b51587ebf86b020b966c402d619f56)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2654200
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 5 | ||||
-rw-r--r-- | common/usbc/usb_tc_drp_acc_trysrc_sm.c | 4 | ||||
-rw-r--r-- | include/common.h | 15 |
3 files changed, 19 insertions, 5 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index b9d969845c..2b2a32719a 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -364,7 +364,7 @@ static const struct usb_state pe_states[]; #endif /* List of human readable state names for console debugging */ -__maybe_unused static const char * const pe_state_names[] = { +__maybe_unused static __const_data const char * const pe_state_names[] = { /* Super States */ #ifdef CONFIG_USB_PD_REV30 [PE_PRS_FRS_SHARED] = "SS:PE_PRS_FRS_SHARED", @@ -6698,8 +6698,7 @@ uint32_t pe_get_flags(int port) return pe[port].flags; } - -static const struct usb_state pe_states[] = { +static __const_data const struct usb_state pe_states[] = { /* Super States */ #ifdef CONFIG_USB_PD_REV30 [PE_PRS_FRS_SHARED] = { diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index 293f5bf1fa..63984d3666 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -236,7 +236,7 @@ GEN_NOT_SUPPORTED(TC_CT_ATTACHED_SNK); /* List of human readable state names for console debugging */ -__maybe_unused static const char * const tc_state_names[] = { +__maybe_unused static __const_data const char * const tc_state_names[] = { #ifdef USB_PD_DEBUG_LABELS [TC_DISABLED] = "Disabled", [TC_ERROR_RECOVERY] = "ErrorRecovery", @@ -3656,7 +3656,7 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, pd_chipset_shutdown, HOOK_PRIO_DEFAULT); * TC_ATTACHED_SNK TC_ATTACHED_SRC TC_DRP_AUTO_TOGGLE TC_LOW_POWER_MODE * */ -static const struct usb_state tc_states[] = { +static __const_data const struct usb_state tc_states[] = { /* Super States */ [TC_CC_OPEN] = { .entry = tc_cc_open_entry, diff --git a/include/common.h b/include/common.h index 86c006d9e9..da3af6dc21 100644 --- a/include/common.h +++ b/include/common.h @@ -224,6 +224,21 @@ /* Include top-level configuration file */ #include "config.h" +/* + * When CONFIG_CHIP_DATA_IN_INIT_ROM is enabled the .data section is linked + * into an unused are of flash and excluded from the executable portion of + * the RO and RW images to save space. + * + * The __const_data attribute can be used to force constant data objects + * into the .data section instead of the .rodata section for additional + * savings. + */ +#ifdef CONFIG_CHIP_DATA_IN_INIT_ROM +#define __const_data __attribute__((section(".data#"))) +#else +#define __const_data +#endif + /* Canonical list of module IDs */ #include "module_id.h" |