summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/build.mk5
-rw-r--r--common/console.c107
-rw-r--r--common/console_output.c114
3 files changed, 117 insertions, 109 deletions
diff --git a/common/build.mk b/common/build.mk
index 5fdfabb061..338a14aa24 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -6,7 +6,7 @@
# Common files build
#
-common-y=main.o util.o console.o uart_buffering.o
+common-y=main.o util.o console_output.o uart_buffering.o
common-y+=memory_commands.o shared_mem.o system_common.o hooks.o
common-y+=gpio_commands.o version.o printf.o queue.o
common-$(CONFIG_BATTERY_ATL706486)+=battery_atl706486.o
@@ -18,12 +18,13 @@ common-$(CONFIG_LPC)+=port80.o host_event_commands.o
common-$(CONFIG_POWER_LED)+=power_led.o
common-$(CONFIG_PSTORE)+=pstore_commands.o
common-$(CONFIG_SMART_BATTERY)+=smart_battery.o
-common-$(CONFIG_TASK_PWM)+=pwm_commands.o
+common-$(CONFIG_TASK_CONSOLE)+=console.o
common-$(CONFIG_TASK_GAIAPOWER)+=gaia_power.o
common-$(CONFIG_TASK_HOSTCMD)+=host_command.o
common-$(CONFIG_TASK_I8042CMD)+=i8042.o keyboard.o
common-$(CONFIG_TASK_LIGHTBAR)+=lightbar.o
common-$(CONFIG_TASK_POWERSTATE)+=charge_state.o battery_precharge.o
+common-$(CONFIG_TASK_PWM)+=pwm_commands.o
common-$(CONFIG_TASK_TEMPSENSOR)+=temp_sensor.o temp_sensor_commands.o
common-$(CONFIG_TASK_THERMAL)+=thermal.o thermal_commands.o
common-$(CONFIG_TASK_X86POWER)+=x86_power.o
diff --git a/common/console.c b/common/console.c
index eae942444b..8e580b6a50 100644
--- a/common/console.c
+++ b/common/console.c
@@ -15,78 +15,8 @@
#define PROMPT "> "
-/* Default to all channels active */
-#ifndef CC_DEFAULT
-#define CC_DEFAULT CC_ALL
-#endif
-static uint32_t channel_mask = CC_DEFAULT;
-
static char input_buf[80]; /* Current console command line */
-/* List of channel names; must match enum console_channel. */
-/* TODO: move this to board.c */
-static const char *channel_names[CC_CHANNEL_COUNT] = {
- "command",
- "charger",
- "chipset",
- "dma",
- "gpio",
- "hostcmd",
- "i2c",
- "i8042",
- "keyboard",
- "keyscan",
- "lightbar",
- "lpc",
- "port80",
- "powerbtn",
- "pwm",
- "spi",
- "system",
- "task",
- "usbcharge",
- "vboot",
-};
-
-/*****************************************************************************/
-/* Channel-based console output */
-
-int cputs(enum console_channel channel, const char *outstr)
-{
- /* Filter out inactive channels */
- if (!(CC_MASK(channel) & channel_mask))
- return EC_SUCCESS;
-
- return uart_puts(outstr);
-}
-
-
-int cprintf(enum console_channel channel, const char *format, ...)
-{
- int rv;
- va_list args;
-
- /* Filter out inactive channels */
- if (!(CC_MASK(channel) & channel_mask))
- return EC_SUCCESS;
-
- va_start(args, format);
- rv = uart_vprintf(format, args);
- va_end(args);
- return rv;
-}
-
-
-void cflush(void)
-{
- uart_flush_output();
-}
-
-
-
-/*****************************************************************************/
-/* Console input */
-
/* Splits a line of input into words. Stores the count of words in
* <argc>. Stores pointers to the words in <argv>, which must be at
* least <max_argc> long. If more than <max_argc> words are found,
@@ -298,40 +228,3 @@ DECLARE_CONSOLE_COMMAND(help, command_help,
"[ list | <name> ]",
"Print command help",
NULL);
-
-
-/* Set active channels */
-static int command_ch(int argc, char **argv)
-{
- int i;
- char *e;
-
- /* If one arg, set the mask */
- if (argc == 2) {
- int m = strtoi(argv[1], &e, 0);
- if (*e)
- return EC_ERROR_PARAM1;
-
- /* No disabling the command output channel */
- channel_mask = m | CC_MASK(CC_COMMAND);
-
- /* TODO: save channel list to EEPROM */
-
- return EC_SUCCESS;
- }
-
- /* Print the list of channels */
- ccputs(" # Mask E Channel\n");
- for (i = 0; i < CC_CHANNEL_COUNT; i++) {
- ccprintf("%2d %08x %c %s\n",
- i, CC_MASK(i),
- (channel_mask & CC_MASK(i)) ? '*' : ' ',
- channel_names[i]);
- cflush();
- }
- return EC_SUCCESS;
-};
-DECLARE_CONSOLE_COMMAND(chan, command_ch,
- "[mask]",
- "Get or set console channel mask",
- NULL);
diff --git a/common/console_output.c b/common/console_output.c
new file mode 100644
index 0000000000..e9f7bf0d97
--- /dev/null
+++ b/common/console_output.c
@@ -0,0 +1,114 @@
+/* Copyright (c) 2012 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 output module for Chrome EC */
+
+#include "console.h"
+#include "uart.h"
+#include "util.h"
+
+/* Default to all channels active */
+#ifndef CC_DEFAULT
+#define CC_DEFAULT CC_ALL
+#endif
+static uint32_t channel_mask = CC_DEFAULT;
+
+/* List of channel names; must match enum console_channel. */
+/* TODO: move this to board.c */
+static const char *channel_names[CC_CHANNEL_COUNT] = {
+ "command",
+ "charger",
+ "chipset",
+ "dma",
+ "gpio",
+ "hostcmd",
+ "i2c",
+ "i8042",
+ "keyboard",
+ "keyscan",
+ "lightbar",
+ "lpc",
+ "port80",
+ "powerbtn",
+ "pwm",
+ "spi",
+ "system",
+ "task",
+ "usbcharge",
+ "vboot",
+};
+
+/*****************************************************************************/
+/* Channel-based console output */
+
+int cputs(enum console_channel channel, const char *outstr)
+{
+ /* Filter out inactive channels */
+ if (!(CC_MASK(channel) & channel_mask))
+ return EC_SUCCESS;
+
+ return uart_puts(outstr);
+}
+
+
+int cprintf(enum console_channel channel, const char *format, ...)
+{
+ int rv;
+ va_list args;
+
+ /* Filter out inactive channels */
+ if (!(CC_MASK(channel) & channel_mask))
+ return EC_SUCCESS;
+
+ va_start(args, format);
+ rv = uart_vprintf(format, args);
+ va_end(args);
+ return rv;
+}
+
+
+void cflush(void)
+{
+ uart_flush_output();
+}
+
+/*****************************************************************************/
+/* Console commands */
+
+/* Set active channels */
+static int command_ch(int argc, char **argv)
+{
+ int i;
+ char *e;
+
+ /* If one arg, set the mask */
+ if (argc == 2) {
+ int m = strtoi(argv[1], &e, 0);
+ if (*e)
+ return EC_ERROR_PARAM1;
+
+ /* No disabling the command output channel */
+ channel_mask = m | CC_MASK(CC_COMMAND);
+
+ /* TODO: save channel list to EEPROM */
+
+ return EC_SUCCESS;
+ }
+
+ /* Print the list of channels */
+ ccputs(" # Mask E Channel\n");
+ for (i = 0; i < CC_CHANNEL_COUNT; i++) {
+ ccprintf("%2d %08x %c %s\n",
+ i, CC_MASK(i),
+ (channel_mask & CC_MASK(i)) ? '*' : ' ',
+ channel_names[i]);
+ cflush();
+ }
+ return EC_SUCCESS;
+};
+DECLARE_CONSOLE_COMMAND(chan, command_ch,
+ "[mask]",
+ "Get or set console channel mask",
+ NULL);