From 664d0036c8a1cff31ae49796fc5d2bf1435fa140 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Wed, 26 Jun 2013 11:29:26 +0200 Subject: [PATCH] Use cpu regulator in cli_monitor only on Arndale This commit splits the Fiasco.OC-specific extension for the cli_monitor into one for the Arndale platform, and one for all others. On Arndale we add the cpu_frequency command beside the ones defined on all platforms. --- os/lib/mk/foc/cli_monitor.mk | 5 +- os/lib/mk/foc_cli_monitor.mk | 6 ++ os/lib/mk/platform_arndale/foc_cli_monitor.mk | 6 ++ .../app/cli_monitor/foc/arndale/extension.cc | 61 +++++++++++++ os/src/app/cli_monitor/foc/common.h | 70 +++++++++++++++ os/src/app/cli_monitor/foc/extension.cc | 88 +------------------ 6 files changed, 145 insertions(+), 91 deletions(-) create mode 100644 os/lib/mk/foc_cli_monitor.mk create mode 100644 os/lib/mk/platform_arndale/foc_cli_monitor.mk create mode 100644 os/src/app/cli_monitor/foc/arndale/extension.cc create mode 100644 os/src/app/cli_monitor/foc/common.h diff --git a/os/lib/mk/foc/cli_monitor.mk b/os/lib/mk/foc/cli_monitor.mk index 423d69963..f50ba5ead 100644 --- a/os/lib/mk/foc/cli_monitor.mk +++ b/os/lib/mk/foc/cli_monitor.mk @@ -1,4 +1 @@ -SRC_CC = extension.cc -INC_DIR += $(REP_DIR)/src/app/cli_monitor - -vpath extension.cc $(REP_DIR)/src/app/cli_monitor/foc +LIBS += foc_cli_monitor \ No newline at end of file diff --git a/os/lib/mk/foc_cli_monitor.mk b/os/lib/mk/foc_cli_monitor.mk new file mode 100644 index 000000000..217015fe0 --- /dev/null +++ b/os/lib/mk/foc_cli_monitor.mk @@ -0,0 +1,6 @@ +SRC_CC = extension.cc +REQUIRES = foc +INC_DIR += $(REP_DIR)/src/app/cli_monitor \ + $(REP_DIR)/src/app/cli_monitor/foc + +vpath extension.cc $(REP_DIR)/src/app/cli_monitor/foc diff --git a/os/lib/mk/platform_arndale/foc_cli_monitor.mk b/os/lib/mk/platform_arndale/foc_cli_monitor.mk new file mode 100644 index 000000000..d5a894e27 --- /dev/null +++ b/os/lib/mk/platform_arndale/foc_cli_monitor.mk @@ -0,0 +1,6 @@ +SRC_CC = extension.cc +REQUIRES = foc_arndale +INC_DIR += $(REP_DIR)/src/app/cli_monitor \ + $(REP_DIR)/src/app/cli_monitor/foc + +vpath extension.cc $(REP_DIR)/src/app/cli_monitor/foc/arndale diff --git a/os/src/app/cli_monitor/foc/arndale/extension.cc b/os/src/app/cli_monitor/foc/arndale/extension.cc new file mode 100644 index 000000000..93bd4d822 --- /dev/null +++ b/os/src/app/cli_monitor/foc/arndale/extension.cc @@ -0,0 +1,61 @@ +/* + * \brief Fiasco.OC on Arndale specific CLI-monitor extensions + * \author Norman Feske + * \author Stefan Kalkowski + * \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. + */ + +/* Genode includes */ +#include +#include + +/* local includes */ +#include + +struct Cpufreq_command : Command +{ + Regulator::Connection ®ulator; + + Cpufreq_command(Regulator::Connection &r) + : Command("cpu_frequency", "set/show CPU frequency"), + regulator(r) { } + + void execute(Command_line &cmd, Terminal::Session &terminal) + { + char freq[128]; + freq[0] = 0; + if (cmd.argument(0, freq, sizeof(freq)) == false) { + tprintf(terminal, "Current CPU frequency: %ld Hz\n", + regulator.level()); + return; + } + + unsigned long f = 0; + Genode::ascii_to(freq, &f, 10); + tprintf(terminal, "set frequency to %ld Hz\n", f); + regulator.level(f); + } +}; + + +void init_extension(Command_registry &commands) +{ + try { /* only inserts commands if route to regulator session exists */ + static Regulator::Connection reg(Regulator::CLK_CPU); + static Cpufreq_command cpufreq_command(reg); + commands.insert(&cpufreq_command); + } catch (...) { PDBG("No regulator session available!"); }; + + static Kdebug_command kdebug_command; + commands.insert(&kdebug_command); + + static Reboot_command reboot_command; + commands.insert(&reboot_command); +} diff --git a/os/src/app/cli_monitor/foc/common.h b/os/src/app/cli_monitor/foc/common.h new file mode 100644 index 000000000..d5719aaaf --- /dev/null +++ b/os/src/app/cli_monitor/foc/common.h @@ -0,0 +1,70 @@ +/* + * \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. + */ + +#ifndef _SRC__APP_CLI_MONITOR__FOC__COMMON_H_ +#define _SRC__APP_CLI_MONITOR__FOC__COMMON_H_ + +/* local includes */ +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +} + + +static void clear_host_terminal() +{ + using namespace Fiasco; + + outstring("\e[99S"); /* scroll up */ + outstring("\e[99T"); /* scroll down */ + outstring("\e[199A"); /* move cursor up */ +} + + +struct Kdebug_command : Command +{ + Kdebug_command() : Command("kdebug", "enter kernel debugger (via serial console)") { } + + void execute(Command_line &, Terminal::Session &terminal) + { + using namespace Fiasco; + + /* let kernel debugger detect the screen size */ + enter_kdebug("*#JS"); + + clear_host_terminal(); + enter_kdebug("Entering kernel debugger... Press [?] for help"); + clear_host_terminal(); + } +}; + + +struct Reboot_command : Command +{ + Reboot_command() : Command("reboot", "reboot machine") { } + + void execute(Command_line &, Terminal::Session &terminal) + { + using namespace Fiasco; + + clear_host_terminal(); + enter_kdebug("*#^"); + } +}; + +#endif /* _SRC__APP_CLI_MONITOR__FOC__COMMON_H_ */ diff --git a/os/src/app/cli_monitor/foc/extension.cc b/os/src/app/cli_monitor/foc/extension.cc index 244e028b6..7fc2c3c9a 100644 --- a/os/src/app/cli_monitor/foc/extension.cc +++ b/os/src/app/cli_monitor/foc/extension.cc @@ -11,98 +11,12 @@ * under the terms of the GNU General Public License version 2. */ -/* Genode includes */ -#include -#include - /* local includes */ -#include -#include -#include - -/* Fiasco includes */ -namespace Fiasco { -#include -#include -} - - -static void clear_host_terminal() -{ - using namespace Fiasco; - - outstring("\e[99S"); /* scroll up */ - outstring("\e[99T"); /* scroll down */ - outstring("\e[199A"); /* move cursor up */ -} - - -struct Kdebug_command : Command -{ - Kdebug_command() : Command("kdebug", "enter kernel debugger (via serial console)") { } - - void execute(Command_line &, Terminal::Session &terminal) - { - using namespace Fiasco; - - /* let kernel debugger detect the screen size */ - enter_kdebug("*#JS"); - - clear_host_terminal(); - enter_kdebug("Entering kernel debugger... Press [?] for help"); - clear_host_terminal(); - } -}; - - -struct Reboot_command : Command -{ - Reboot_command() : Command("reboot", "reboot machine") { } - - void execute(Command_line &, Terminal::Session &terminal) - { - using namespace Fiasco; - - clear_host_terminal(); - enter_kdebug("*#^"); - } -}; - - -struct Cpufreq_command : Command -{ - Regulator::Connection ®ulator; - - Cpufreq_command(Regulator::Connection &r) - : Command("cpu_frequency", "set/show CPU frequency"), - regulator(r) { } - - void execute(Command_line &cmd, Terminal::Session &terminal) - { - char freq[128]; - freq[0] = 0; - if (cmd.argument(0, freq, sizeof(freq)) == false) { - tprintf(terminal, "Current CPU frequency: %ld Hz\n", - regulator.level()); - return; - } - - unsigned long f = 0; - Genode::ascii_to(freq, &f, 10); - tprintf(terminal, "set frequency to %ld Hz\n", f); - regulator.level(f); - } -}; +#include void init_extension(Command_registry &commands) { - try { /* only inserts commands if route to regulator session exists */ - static Regulator::Connection reg(Regulator::CLK_CPU); - static Cpufreq_command cpufreq_command(reg); - commands.insert(&cpufreq_command); - } catch (...) { PDBG("No regulator session available!"); }; - static Kdebug_command kdebug_command; commands.insert(&kdebug_command);