From 67e4864c816b52b10e957d60d2ce5e633f5253bf Mon Sep 17 00:00:00 2001 From: Jani Kokkonen <jani.kokkonen@huawei.com> Date: Thu, 20 Mar 2014 17:15:40 +0100 Subject: [PATCH] drivers: move debug-console to arch-specific dir Signed-off-by: Jani Kokkonen <jani.kokkonen@huawei.com> Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com> --- arch/aarch64/debug-console.cc | 61 ++++++++++++++++++++++++++ {drivers => arch/x64}/debug-console.cc | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 arch/aarch64/debug-console.cc rename {drivers => arch/x64}/debug-console.cc (97%) diff --git a/arch/aarch64/debug-console.cc b/arch/aarch64/debug-console.cc new file mode 100644 index 000000000..652e3e151 --- /dev/null +++ b/arch/aarch64/debug-console.cc @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013 Cloudius Systems, Ltd. + * + * Copyright (C) 2014 Huawei Technologies Duesseldorf GmbH + * + * This work is open source software, licensed under the terms of the + * BSD license as described in the LICENSE file in the top-level directory. + */ + +#include <drivers/debug-console.hh> + +static volatile char *const uart = (char *)0x9000000; /* UART0DR */ + +static void simple_write(const char *str, size_t len) +{ + while (len > 0) { + if ((*str == '\n')) + *uart = '\r'; + *uart = *str++; + len--; + } +} +void debug_console::set_impl(Console* impl) +{ + WITH_LOCK(_lock) { + _impl = impl; + } +} + +void debug_console::write(const char* str, size_t len) +{ + WITH_LOCK(_lock) { + if (_impl) { + _impl->write(str, len); + } else { + simple_write(str, len); + } + } +} + +void debug_console::write_ll(const char *str, size_t len) +{ + if (_impl) { + _impl->write(str, len); + } else + simple_write(str, len); +} + +char debug_console::readch() +{ + WITH_LOCK(_lock) { + return _impl ? _impl->readch() : 0; + } + } + +bool debug_console::input_ready() +{ + WITH_LOCK(_lock) { + return _impl && _impl->input_ready(); + } +} diff --git a/drivers/debug-console.cc b/arch/x64/debug-console.cc similarity index 97% rename from drivers/debug-console.cc rename to arch/x64/debug-console.cc index 7d1fea27c..adf10a360 100644 --- a/drivers/debug-console.cc +++ b/arch/x64/debug-console.cc @@ -5,7 +5,7 @@ * BSD license as described in the LICENSE file in the top-level directory. */ -#include "debug-console.hh" +#include <drivers/debug-console.hh> #include "processor.hh" // Write to the serial port if the console is not yet initialized. Because we -- GitLab