diff options
-rw-r--r-- | common/console_output.c | 62 | ||||
-rw-r--r-- | include/console.h | 47 | ||||
-rw-r--r-- | include/console_channel.inc | 49 |
3 files changed, 62 insertions, 96 deletions
diff --git a/common/console_output.c b/common/console_output.c index 28d661561c..4794929954 100644 --- a/common/console_output.c +++ b/common/console_output.c @@ -18,62 +18,18 @@ static uint32_t channel_mask = CC_DEFAULT; static uint32_t channel_mask_saved = CC_DEFAULT; /* - * List of channel names; must match enum console_channel. + * List of channel names; * - * We could do something fancy and macro-y with this like ec.tasklist, so that - * the channel name list and console_channel enum come from the same header - * file. That's clever, but I'm not convinced it's more readable or - * maintainable than the two simple lists we have now. - * - * We could also try to get clever with #ifdefs or board-specific lists of - * channel names, so that for example boards without port80 support don't waste - * binary size on the channel name string for "port80". Pruning the channel - * list might also become more important if we have >32 channels - for example, - * if we decide to replace enum console_channel with enum module_id. + * We could try to get clever with #ifdefs or board-specific lists of channel + * names, so that for example boards without port80 support don't waste binary + * size on the channel name string for "port80". Pruning the channel list + * might also become more important if we have >32 channels - for example, if + * we decide to replace enum console_channel with enum module_id. */ static const char * const channel_names[] = { - "command", - "accel", - "charger", - "chipset", - "clock", - "dma", - "events", -#ifdef CONFIG_EXTENSION_COMMAND - "extension", -#endif - "gesture", - "gpio", - "hostcmd", - "i2c", - "keyboard", - "keyscan", - "lidangle", -#ifdef HAS_TASK_LIGHTBAR - "lightbar", -#endif - "lpc", - "motionlid", - "motionsense", -#ifdef HAS_TASK_PDCMD - "pdhostcmd", -#endif - "port80", - "pwm", - "spi", -#ifdef CONFIG_SPS - "sps", -#endif - "switch", - "system", - "task", - "thermal", - "tpm", - "usb", - "usbcharge", - "usbpd", - "vboot", - "hook", + #define CONSOLE_CHANNEL(enumeration, string) string, + #include "include/console_channel.inc" + #undef CONSOLE_CHANNEL }; BUILD_ASSERT(ARRAY_SIZE(channel_names) == CC_CHANNEL_COUNT); /* ensure that we are not silently masking additional channels */ diff --git a/include/console.h b/include/console.h index 1f7a24f0f3..75bbd6a335 100644 --- a/include/console.h +++ b/include/console.h @@ -26,49 +26,10 @@ struct console_command { /* Console channels */ enum console_channel { - CC_COMMAND = 0, /* Console command (interactive I/O). Use this only - * inside a console command routine. */ - CC_ACCEL, -#ifdef CONFIG_EXTENSION_COMMAND - CC_EXTENSION, -#endif - CC_CHARGER, - CC_CHIPSET, - CC_CLOCK, - CC_DMA, - CC_EVENTS, - CC_GESTURE, - CC_GPIO, - CC_HOSTCMD, - CC_I2C, - CC_KEYBOARD, - CC_KEYSCAN, - CC_LIDANGLE, -#ifdef HAS_TASK_LIGHTBAR - CC_LIGHTBAR, -#endif - CC_LPC, - CC_MOTION_LID, - CC_MOTION_SENSE, -#ifdef HAS_TASK_PDCMD - CC_PD_HOST_CMD, -#endif - CC_PORT80, - CC_PWM, - CC_SPI, -#ifdef CONFIG_SPS - CC_SPS, -#endif - CC_SWITCH, - CC_SYSTEM, - CC_TASK, - CC_THERMAL, - CC_TPM, - CC_USB, - CC_USBCHARGE, - CC_USBPD, - CC_VBOOT, - CC_HOOK, + #define CONSOLE_CHANNEL(enumeration, string) enumeration, + #include "include/console_channel.inc" + #undef CONSOLE_CHANNEL + /* Channel count; not itself a channel */ CC_CHANNEL_COUNT }; diff --git a/include/console_channel.inc b/include/console_channel.inc new file mode 100644 index 0000000000..9f63908074 --- /dev/null +++ b/include/console_channel.inc @@ -0,0 +1,49 @@ +/* -*- mode:c -*- + * + * Copyright 2016 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +CONSOLE_CHANNEL(CC_COMMAND, "command") +CONSOLE_CHANNEL(CC_ACCEL, "accel") +#ifdef CONFIG_EXTENSION_COMMAND +CONSOLE_CHANNEL(CC_EXTENSION, "extension") +#endif +CONSOLE_CHANNEL(CC_CHARGER, "charger") +CONSOLE_CHANNEL(CC_CHIPSET, "chipset") +CONSOLE_CHANNEL(CC_CLOCK, "clock") +CONSOLE_CHANNEL(CC_DMA, "dma") +CONSOLE_CHANNEL(CC_EVENTS, "events") +CONSOLE_CHANNEL(CC_GESTURE, "gesture") +CONSOLE_CHANNEL(CC_GPIO, "gpio") +CONSOLE_CHANNEL(CC_HOSTCMD, "hostcmd") +CONSOLE_CHANNEL(CC_I2C, "i2c") +CONSOLE_CHANNEL(CC_KEYBOARD, "keyboard") +CONSOLE_CHANNEL(CC_KEYSCAN, "keyscan") +CONSOLE_CHANNEL(CC_LIDANGLE, "lidangle") +#ifdef HAS_TASK_LIGHTBAR +CONSOLE_CHANNEL(CC_LIGHTBAR, "lightbar") +#endif +CONSOLE_CHANNEL(CC_LPC, "lpc") +CONSOLE_CHANNEL(CC_MOTION_LID, "motionlid") +CONSOLE_CHANNEL(CC_MOTION_SENSE, "motionsense") +#ifdef HAS_TASK_PDCMD +CONSOLE_CHANNEL(CC_PD_HOST_CMD, "pdhostcm") +#endif +CONSOLE_CHANNEL(CC_PORT80, "port80") +CONSOLE_CHANNEL(CC_PWM, "pwm") +CONSOLE_CHANNEL(CC_SPI, "spi") +#ifdef CONFIG_SPS +CONSOLE_CHANNEL(CC_SPS, "sps") +#endif +CONSOLE_CHANNEL(CC_SWITCH, "switch") +CONSOLE_CHANNEL(CC_SYSTEM, "system") +CONSOLE_CHANNEL(CC_TASK, "task") +CONSOLE_CHANNEL(CC_THERMAL, "thermal") +CONSOLE_CHANNEL(CC_TPM, "tpm") +CONSOLE_CHANNEL(CC_USB, "usb") +CONSOLE_CHANNEL(CC_USBCHARGE, "usbcharge") +CONSOLE_CHANNEL(CC_USBPD, "usbpd") +CONSOLE_CHANNEL(CC_VBOOT, "vboot") +CONSOLE_CHANNEL(CC_HOOK, "hook") |