Files
OpenCellular/common/console_output.c
Randall Spangler 7946a3eb3d Simplify host event processing
Now both copies of the event state live in host_event_commands.c, and
lpc / memmap just shadows the main copy.

BUG=chrome-os-partner:11172
TEST=manual

Boot system.  should see events 0x2000, 0x80, 0x08 get set and then cleared.

At U-boot prompt, type on keyboard.  Should set event 0x1000 get set,
but only on the first keypress (because U-boot doesn't consume that
event).

Then from EC console,
hostevent clear 0x1000 -> see event 0x1000 clear
hostevent clear 0x1000 -> no debug output (it's already clear)
hostevent clearb 0x1000 -> see event copy B 0x1000 clear
hostevent clearb 0x1000 -> no debug output (copy B is already clear)

Change-Id: I855c035865649ba1490cd9027157d5bcdcc9895f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27321
2012-07-12 18:22:24 -07:00

116 lines
2.2 KiB
C

/* 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",
"events",
"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);