From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Sat, 16 Sep 2017 15:23:20 -0600 Subject: [U-Boot] [PATCH 07/13] log: Add a console driver In-Reply-To: <20170916212331.170463-1-sjg@chromium.org> References: <20170916212331.170463-1-sjg@chromium.org> Message-ID: <20170916212331.170463-8-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de It is useful to display log messages on the console. Add a simple driver to handle this. Signed-off-by: Simon Glass --- common/Kconfig | 20 ++++++++++++++++++++ common/Makefile | 1 + common/log_console.c | 23 +++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 common/log_console.c diff --git a/common/Kconfig b/common/Kconfig index cbccc8ae26..ba4578e870 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -438,6 +438,26 @@ config LOG_SPL_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 DTB_RESELECT diff --git a/common/Makefile b/common/Makefile index d37c8d5636..9db0f4ca2d 100644 --- a/common/Makefile +++ b/common/Makefile @@ -129,5 +129,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 diff --git a/common/log_console.c b/common/log_console.c new file mode 100644 index 0000000000..5af73bd8be --- /dev/null +++ b/common/log_console.c @@ -0,0 +1,23 @@ +/* + * Logging support + * + * Copyright (c) 2017 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include + +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, +}; -- 2.14.1.690.gbb1197296e-goog