diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-04-24 16:29:28 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-04-24 17:46:54 -0700 |
commit | 135f14bf498ab19b6e75efc3a0d18ef7c8a8752d (patch) | |
tree | 1dd03ec292b5f9f44a24e045e64e0c10ff58b6a6 /include/console.h | |
parent | 0d19c59aba807f915f1ea46d273bfebe1ded1db9 (diff) | |
download | chrome-ec-135f14bf498ab19b6e75efc3a0d18ef7c8a8752d.tar.gz |
Refactor async console output
This adds a 'ch' command which prints/sets which channels are active
This handles all the async output; the remaining debug commands will
be refactored to use ccprintf() / ccputs() in a followup CL.
Signed-off-by: Randall Spangler <rspangler@chromium.org>
BUG=chrome-os-partner:7464
TEST=manual
ch --> all channels active
ch 0x100 -> just port80 active
powerbtn -> system boots; only port 80 codes shown on console
Change-Id: I9efc43acec919b62b78c2c82c61946d32380adfe
Diffstat (limited to 'include/console.h')
-rw-r--r-- | include/console.h | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/include/console.h b/include/console.h index 4aeca1c5f4..b0d3f5b63e 100644 --- a/include/console.h +++ b/include/console.h @@ -1,16 +1,16 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +/* 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.h - Debug console for Chrome EC */ +/* Debug console for Chrome EC */ #ifndef __CROS_EC_CONSOLE_H #define __CROS_EC_CONSOLE_H #include "common.h" -/* Console command */ +/* Console command; used by DECLARE_CONSOLE_COMMAND macro. */ struct console_command { /* Command name. Case-insensitive. */ const char *name; @@ -19,13 +19,51 @@ struct console_command { }; -/* Initializes the console module. */ -int console_init(void); +/* Console channels */ +enum console_channel { + CC_COMMAND = 0, /* Console command (interactive I/O). Use this only + * inside a console command routine. */ + CC_CHARGER, + CC_HOSTCMD, + CC_I8042, + CC_KEYBOARD, + CC_KEYSCAN, + CC_LIGHTBAR, + CC_LPC, + CC_PORT80, + CC_POWERBTN, + CC_SYSTEM, + CC_TASK, + CC_USBCHARGE, + CC_X86POWER, + /* Channel count; not itself a channel */ + CC_CHANNEL_COUNT +}; + +/* Put a string to the console channel. */ +int cputs(enum console_channel channel, const char *outstr); + +/* Print formatted output to the console channel. See uart_vprintf() for + * valid format codes. */ +int cprintf(enum console_channel channel, const char *format, ...); + +/* Flush the console output for all channels. */ +void cflush(void); + +/* Convenience macros for printing to the command channel. + * + * Modules may define similar macros in their .c files for their own use; it is + * recommended those module-specific macros be named CPUTS and CPRINTF. */ +#define ccputs(outstr) cputs(CC_COMMAND, outstr) +/* gcc allows variable arg lists in macros; see + * http://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html */ +#define ccprintf(format, args...) cprintf(CC_COMMAND, format, ## args) /* Called by UART when a line of input is pending. */ void console_has_input(void); + /* Register a console command handler */ #define DECLARE_CONSOLE_COMMAND(name, routine) \ static const char __con_cmd_label_##name[] = #name; \ |