summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-05-23 14:08:30 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-06-01 06:22:02 +0000
commitaeebebeb5d1e4723392319dd35bc4a6c4415e6a2 (patch)
treeca6a95bd7e0e9697530f962834f56a591bb298a2
parent4c6ea86a20b4cab1541d19708fbb97c82504b156 (diff)
downloadchrome-ec-aeebebeb5d1e4723392319dd35bc4a6c4415e6a2.tar.gz
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 <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1070949 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1080578
-rw-r--r--common/console_output.c10
-rw-r--r--include/config.h9
2 files changed, 19 insertions, 0 deletions
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 | <mask> ]",
"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
@@ -919,6 +919,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.
*