From dfe4fd177d24cc982e38427b2f124df686b4de49 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 21 Mar 2013 15:50:32 +0100 Subject: [PATCH] cli_monitor: Add foc-specific kdebug command --- gems/run/terminal_mux.run | 39 ++++++++++++++---- os/lib/mk/cli_monitor.mk | 4 ++ os/lib/mk/foc/cli_monitor.mk | 4 ++ os/src/app/cli_monitor/extension.h | 25 ++++++++++++ os/src/app/cli_monitor/foc/extension.cc | 53 +++++++++++++++++++++++++ os/src/app/cli_monitor/main.cc | 5 +++ os/src/app/cli_monitor/no_extension.cc | 17 ++++++++ os/src/app/cli_monitor/target.mk | 2 +- 8 files changed, 141 insertions(+), 8 deletions(-) create mode 100644 os/lib/mk/cli_monitor.mk create mode 100644 os/lib/mk/foc/cli_monitor.mk create mode 100644 os/src/app/cli_monitor/extension.h create mode 100644 os/src/app/cli_monitor/foc/extension.cc create mode 100644 os/src/app/cli_monitor/no_extension.cc diff --git a/gems/run/terminal_mux.run b/gems/run/terminal_mux.run index 810438cd0c..1041695b7a 100644 --- a/gems/run/terminal_mux.run +++ b/gems/run/terminal_mux.run @@ -22,7 +22,7 @@ exec tar cfv bin/vim.tar -h -C bin/vim . create_boot_directory append config { - + @@ -44,15 +44,29 @@ append config { - + } + +# use kernel debugger as UART on Fiasco.OC +append_if [have_spec foc] config { + } + +append config { - - - + } + +# on Fiasco.OC the kdb_uart_drv is always UART 0 +append_if [have_spec foc] config { + } + +# on all other kernels, direct terminal_mux to UART 1 (Qemu stdio, see below) +append_if [expr ![have_spec foc]] config { + } + +append config { @@ -134,11 +148,22 @@ set boot_modules { vim.tar } +lappend_if [have_spec foc] boot_modules kdb_uart_drv + +set fiasco_serial_esc_arg "" + build_boot_image $boot_modules append qemu_args " -m 256 " -#append qemu_args " -nographic -serial mon:stdio -serial file:/tmp/foo" -append qemu_args " -nographic -serial file:kdb.log -serial mon:stdio" +append qemu_args " -nographic " + +# +# On Fiasco.OC, we use only one UART via the kernel debugger. +# On all other kernels, we write the core debug output to the kdb.log file, +# and use qemu's stdio as the UART used by terminal_mux. +# +append_if [expr ![have_spec foc]] qemu_args " -serial file:kdb.log " +append qemu_args " -serial mon:stdio" run_genode_until forever diff --git a/os/lib/mk/cli_monitor.mk b/os/lib/mk/cli_monitor.mk new file mode 100644 index 0000000000..f726c4628e --- /dev/null +++ b/os/lib/mk/cli_monitor.mk @@ -0,0 +1,4 @@ +SRC_CC = no_extension.cc +INC_DIR += $(REP_DIR)/src/app/cli_monitor + +vpath no_extension.cc $(REP_DIR)/src/app/cli_monitor diff --git a/os/lib/mk/foc/cli_monitor.mk b/os/lib/mk/foc/cli_monitor.mk new file mode 100644 index 0000000000..423d69963e --- /dev/null +++ b/os/lib/mk/foc/cli_monitor.mk @@ -0,0 +1,4 @@ +SRC_CC = extension.cc +INC_DIR += $(REP_DIR)/src/app/cli_monitor + +vpath extension.cc $(REP_DIR)/src/app/cli_monitor/foc diff --git a/os/src/app/cli_monitor/extension.h b/os/src/app/cli_monitor/extension.h new file mode 100644 index 0000000000..7633bb453e --- /dev/null +++ b/os/src/app/cli_monitor/extension.h @@ -0,0 +1,25 @@ +/* + * \brief Interface for platform-specific CLI-monitor commands + * \author Norman Feske + * \date 2013-03-21 + */ + +/* + * Copyright (C) 2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _EXTENSION_H_ +#define _EXTENSION_H_ + +/* local includes */ +#include + +/** + * Initialize and register platform-specific commands + */ +void init_extension(Command_registry &); + +#endif /* _EXTENSION_H_ */ diff --git a/os/src/app/cli_monitor/foc/extension.cc b/os/src/app/cli_monitor/foc/extension.cc new file mode 100644 index 0000000000..d4758c363e --- /dev/null +++ b/os/src/app/cli_monitor/foc/extension.cc @@ -0,0 +1,53 @@ +/* + * \brief Fiasco.OC-specific CLI-monitor extensions + * \author Norman Feske + * \date 2013-03-18 + */ + +/* + * Copyright (C) 2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* local includes */ +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +} + + +struct Kdebug_command : Command +{ + Kdebug_command() : Command("kdebug", "enter kernel debugger (via serial console)") { } + + void execute(Command_line &, Terminal::Session &terminal) + { + tprintf(terminal, " Entering kernel debugger...\n"); + tprintf(terminal, " Press [g] to continue execution.\n"); + + using namespace Fiasco; + + /* + * Wait a bit to give the terminal a chance to print the usage + * information before the kernel debugger takes over. + */ + l4_ipc_sleep(l4_timeout(L4_IPC_TIMEOUT_NEVER, l4_timeout_rel(244, 11))); + + enter_kdebug(""); + + tprintf(terminal, "\n"); + } +}; + + +void init_extension(Command_registry &commands) +{ + static Kdebug_command kdebug_command; + commands.insert(&kdebug_command); +} diff --git a/os/src/app/cli_monitor/main.cc b/os/src/app/cli_monitor/main.cc index 7035a494a1..c645c30fc3 100644 --- a/os/src/app/cli_monitor/main.cc +++ b/os/src/app/cli_monitor/main.cc @@ -25,6 +25,7 @@ #include #include #include +#include using Terminal::tprintf; using Genode::Xml_node; @@ -534,6 +535,10 @@ int main(int argc, char **argv) static Command_registry commands; static Child_registry children; + /* initialize platform-specific commands */ + init_extension(commands); + + /* initialize generic commands */ commands.insert(new Help_command); Kill_command kill_command(children); commands.insert(&kill_command); diff --git a/os/src/app/cli_monitor/no_extension.cc b/os/src/app/cli_monitor/no_extension.cc new file mode 100644 index 0000000000..112d98ae63 --- /dev/null +++ b/os/src/app/cli_monitor/no_extension.cc @@ -0,0 +1,17 @@ +/* + * \brief Dummy implementation of CLI extension interface + * \author Norman Feske + * \date 2013-03-21 + */ + +/* + * Copyright (C) 2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +void init_extension(Command_registry &) { } + diff --git a/os/src/app/cli_monitor/target.mk b/os/src/app/cli_monitor/target.mk index 9b1a930969..18b6022462 100644 --- a/os/src/app/cli_monitor/target.mk +++ b/os/src/app/cli_monitor/target.mk @@ -1,4 +1,4 @@ TARGET = cli_monitor SRC_CC = main.cc -LIBS = base +LIBS = base cli_monitor INC_DIR += $(PRG_DIR)