From aeebebeb5d1e4723392319dd35bc4a6c4415e6a2 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Wed, 23 May 2018 14:08:30 +0800 Subject: console_output: Add option to disable console channels On hammer, we do not need the console channels, so we can just disable them to save flash size. BRANCH=poppy BUG=b:35647963 TEST=make newsizes, staff image size shrinks by 704 bytes Change-Id: I7a493ae57573814b166d45e57f1ad3d885f26086 Signed-off-by: Nicolas Boichat Reviewed-on: https://chromium-review.googlesource.com/1070949 Reviewed-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/1080578 --- common/console_output.c | 10 ++++++++++ include/config.h | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/common/console_output.c b/common/console_output.c index 7354ea4392..01f60859a4 100644 --- a/common/console_output.c +++ b/common/console_output.c @@ -10,6 +10,7 @@ #include "usb_console.h" #include "util.h" +#ifdef CONFIG_CONSOLE_CHANNEL /* Default to all channels active */ #ifndef CC_DEFAULT #define CC_DEFAULT CC_ALL @@ -34,6 +35,7 @@ static const char * const channel_names[] = { BUILD_ASSERT(ARRAY_SIZE(channel_names) == CC_CHANNEL_COUNT); /* ensure that we are not silently masking additional channels */ BUILD_ASSERT(CC_CHANNEL_COUNT <= 8*sizeof(uint32_t)); +#endif /* CONFIG_CONSOLE_CHANNEL */ /*****************************************************************************/ /* Channel-based console output */ @@ -42,9 +44,11 @@ int cputs(enum console_channel channel, const char *outstr) { int rv1, rv2; +#ifdef CONFIG_CONSOLE_CHANNEL /* Filter out inactive channels */ if (!(CC_MASK(channel) & channel_mask)) return EC_SUCCESS; +#endif rv1 = usb_puts(outstr); rv2 = uart_puts(outstr); @@ -57,9 +61,11 @@ int cprintf(enum console_channel channel, const char *format, ...) int rv1, rv2; va_list args; +#ifdef CONFIG_CONSOLE_CHANNEL /* Filter out inactive channels */ if (!(CC_MASK(channel) & channel_mask)) return EC_SUCCESS; +#endif usb_va_start(args, format); rv1 = usb_vprintf(format, args); @@ -77,9 +83,11 @@ int cprints(enum console_channel channel, const char *format, ...) int r, rv; va_list args; +#ifdef CONFIG_CONSOLE_CHANNEL /* Filter out inactive channels */ if (!(CC_MASK(channel) & channel_mask)) return EC_SUCCESS; +#endif rv = cprintf(channel, "[%T "); @@ -107,6 +115,7 @@ void cflush(void) /*****************************************************************************/ /* Console commands */ +#ifdef CONFIG_CONSOLE_CHANNEL /* Set active channels */ static int command_ch(int argc, char **argv) { @@ -149,3 +158,4 @@ static int command_ch(int argc, char **argv) DECLARE_CONSOLE_COMMAND(chan, command_ch, "[ save | restore | ]", "Save, restore, get or set console channel mask"); +#endif /* CONFIG_CONSOLE_CHANNEL */ diff --git a/include/config.h b/include/config.h index f96103a4af..3c5a536453 100644 --- a/include/config.h +++ b/include/config.h @@ -918,6 +918,15 @@ /*****************************************************************************/ +/* + * Make it possible for console to be output to different channels that can be + * turned on and off. + * + * Boards that do not require a typical FAFT flow may #undef this to reduce + * image size. + */ +#define CONFIG_CONSOLE_CHANNEL + /* * Provide additional help on console commands, such as the supported * options/usage. -- cgit v1.2.1