UPSTREAM: log: Add a console driver

It is useful to display log messages on the console. Add a simple driver
to handle this.

Note that this driver outputs to the console, which may be serial or
video. It does not specifically select serial output.

Change-Id: I3626673a306557400584e673f9725e74ecbaaf98
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit c6d47535dfb6636ae5244958a2a9e043bb7646ae)
This commit is contained in:
Simon Glass 2017-12-04 13:48:25 -07:00 committed by Kever Yang
parent 9530301c66
commit 5cafef2de2
3 changed files with 44 additions and 0 deletions

View File

@ -459,6 +459,26 @@ config SPL_LOG_MAX_LEVEL
6 - detail
7 - debug
config LOG_CONSOLE
bool "Allow log output to the console"
depends on LOG
default y
help
Enables a log driver which writes log records to the console.
Generally the console is the serial port or LCD display. Only the
log message is shown - other details like level, category, file and
line number are omitted.
config LOG_SPL_CONSOLE
bool "Allow log output to the console in SPL"
depends on LOG_SPL
default y
help
Enables a log driver which writes log records to the console.
Generally the console is the serial port or LCD display. Only the
log message is shown - other details like level, category, file and
line number are omitted.
endmenu
config DEFAULT_FDT_FILE

View File

@ -135,5 +135,6 @@ obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_simple.o cli_readline.o
obj-$(CONFIG_CMD_DFU) += dfu.o
obj-y += command.o
obj-$(CONFIG_$(SPL_)LOG) += log.o
obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o
obj-y += s_record.o
obj-y += xyzModem.o

23
common/log_console.c Normal file
View File

@ -0,0 +1,23 @@
/*
* Logging support
*
* Copyright (c) 2017 Google, Inc
* Written by Simon Glass <sjg@chromium.org>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <log.h>
static int log_console_emit(struct log_device *ldev, struct log_rec *rec)
{
puts(rec->msg);
return 0;
}
LOG_DRIVER(console) = {
.name = "console",
.emit = log_console_emit,
};