os: fix some more deprecated warnings

Ref #1987
This commit is contained in:
Martin Stein 2017-03-13 10:56:45 +01:00 committed by Christian Helmuth
parent 3ac3236a28
commit 078f28238f
4 changed files with 81 additions and 97 deletions

View File

@ -14,7 +14,7 @@
/* Genode */
#include <base/component.h>
#include <base/heap.h>
#include <os/config.h>
#include <base/attached_rom_dataspace.h>
#include <os/timer.h>
#include <nic/xml_node.h>
#include <timer_session/connection.h>
@ -32,12 +32,13 @@ class Main
{
private:
Timer::Connection _timer_connection;
Genode::Timer _timer;
Genode::Heap _heap;
Configuration _config;
Uplink _uplink;
Net::Root _root;
Timer::Connection _timer_connection;
Genode::Timer _timer;
Genode::Heap _heap;
Genode::Attached_rom_dataspace _config_rom;
Configuration _config;
Uplink _uplink;
Net::Root _root;
public:
@ -48,7 +49,8 @@ class Main
Main::Main(Env &env)
:
_timer_connection(env), _timer(_timer_connection, env.ep()),
_heap(&env.ram(), &env.rm()), _config(config()->xml_node(), _heap),
_heap(&env.ram(), &env.rm()), _config_rom(env, "config"),
_config(_config_rom.xml(), _heap),
_uplink(env, _timer, _heap, _config),
_root(env.ep(), _timer, _heap, _uplink.router_mac(), _config, env.ram(),
env.rm())

View File

@ -16,7 +16,6 @@
#include <file_system/node_handle_registry.h>
#include <file_system_session/rpc_object.h>
#include <base/attached_rom_dataspace.h>
#include <os/config.h>
#include <os/server.h>
#include <os/session_policy.h>
#include <root/component.h>

View File

@ -1,6 +1,7 @@
/*
* \brief Test GPIO driver with Leds
* \author Reinier Millo Sánchez <rmillo@uclv.cu>
* \author Martin Stein
* \date 2015-07-26
*/
@ -11,48 +12,44 @@
* under the terms of the GNU Affero General Public License version 3.
*/
#include <base/log.h>
#include <base/signal.h>
/* Genode includes */
#include <base/component.h>
#include <base/attached_rom_dataspace.h>
#include <gpio_session/connection.h>
#include <irq_session/client.h>
#include <util/mmio.h>
#include <timer_session/connection.h>
#include <os/config.h>
using namespace Genode;
int main(int, char **)
struct Main
{
unsigned int _delay = 1000;
unsigned int _gpio_pin = 16;
unsigned int _times = 10;
Env &env;
Attached_rom_dataspace config { env, "config" };
unsigned delay { config.xml().attribute_value("delay", (unsigned)1000) };
unsigned gpio_pin { config.xml().attribute_value("gpio_pin", (unsigned)16) };
unsigned times { config.xml().attribute_value("times", (unsigned)10) };
Gpio::Connection led { env, gpio_pin };
Timer::Connection timer { env };
try {
Genode::config()->xml_node().attribute("gpio_pin").value(&_gpio_pin);
} catch (...) { }
Main(Env &env);
};
try {
Genode::config()->xml_node().attribute("delay").value(&_delay);
} catch (...) { }
try {
Genode::config()->xml_node().attribute("times").value(&_times);
} catch (...) { }
Main::Main(Env &env) : env(env)
{
log("--- GPIO Led test [GPIO Pin: ", gpio_pin, ", "
"Timer delay: ", delay, ", Times: ", times, "] ---");
Genode::log("--- GPIO Led test [GPIO Pin: ", _gpio_pin, ", "
"Timer delay: ", _delay, ", Times: ", _times, "] ---");
Gpio::Connection _led(_gpio_pin);
Timer::Connection _timer;
while(_times--)
{
Genode::log("Remains blinks: ",_times);
_led.write(false);
_timer.msleep(_delay);
_led.write(true);
_timer.msleep(_delay);
while (times--) {
log("Remaining blinks: ", times);
led.write(false);
timer.msleep(delay);
led.write(true);
timer.msleep(delay);
}
Genode::log("Test finished");
return 0;
log("Test finished");
}
void Component::construct(Env &env) { static Main main(env); }

View File

@ -1,6 +1,7 @@
/*
* \brief Test GPIO driver
* \author Reinier Millo Sánchez <rmillo@uclv.cu>
* \author Martin Stein
* \date 2015-07-26
*/
@ -11,81 +12,68 @@
* under the terms of the GNU Affero General Public License version 3.
*/
#include <base/log.h>
#include <base/signal.h>
/* Genode includes */
#include <base/component.h>
#include <base/attached_rom_dataspace.h>
#include <gpio_session/connection.h>
#include <irq_session/client.h>
#include <util/mmio.h>
#include <timer_session/connection.h>
#include <os/config.h>
using namespace Genode;
int main(int, char **)
struct Main
{
Signal_receiver sig_rec;
Signal_context sig_ctx;
Timer::Connection _timer;
Env &env;
Attached_rom_dataspace config { env, "config" };
Signal_receiver sig_rec;
Signal_context sig_ctx;
Timer::Connection timer { env };
unsigned gpio_pin { config.xml().attribute_value("gpio_pin", (unsigned)16) };
unsigned gpio_pin_in { config.xml().attribute_value("gpio_pin_in", (unsigned)17) };
unsigned gpio_pin_out { config.xml().attribute_value("gpio_pin_out", (unsigned)18) };
bool state { config.xml().attribute_value("state", (unsigned)0) > 0 };
unsigned _gpio_pin = 16;
unsigned _gpio_pin_in = 17;
unsigned _gpio_pin_out = 18;
unsigned _tmp = 0;
bool _state = false;
Main(Env &env);
};
try {
Genode::config()->xml_node().attribute("gpio_pin").value(&_gpio_pin);
} catch (...) { }
try {
Genode::config()->xml_node().attribute("gpio_pin_in").value(&_gpio_pin_in);
} catch (...) { }
try {
Genode::config()->xml_node().attribute("gpio_pin_out").value(&_gpio_pin_out);
} catch (...) { }
try {
Genode::config()->xml_node().attribute("state").value(&_tmp);
} catch (...) { }
_state = _tmp>0;
Main::Main(Env &env) : env(env)
{
log("--- GPIO Signals test [LED "
"pin: ", _gpio_pin, ", "
"Input pin: ", _gpio_pin_in, ", "
"Output pin: ", _gpio_pin_out, ", "
"Initial state: ", _state, "] ---");
"pin: ", gpio_pin, ", "
"Input pin: ", gpio_pin_in, ", "
"Output pin: ", gpio_pin_out, ", "
"Initial state: ", state, "] ---");
Gpio::Connection _led(_gpio_pin);
Gpio::Connection _signal_input(_gpio_pin_in);
Gpio::Connection _signal_output(_gpio_pin_out);
Gpio::Connection led(env, gpio_pin);
Gpio::Connection signal_input(env, gpio_pin_in);
Gpio::Connection signal_output(env, gpio_pin_out);
/*
* Set pins direction.
* This values can be set by configuration
*/
_signal_input.direction(Gpio::Session::IN);
_signal_output.direction(Gpio::Session::OUT);
signal_input.direction(Gpio::Session::IN);
signal_output.direction(Gpio::Session::OUT);
/*
* Power on the signal output
*/
_signal_output.write(true);
signal_output.write(true);
/*
* Initialize the pin IRQ signal
*/
Genode::Irq_session_client irq(_signal_input.irq_session(Gpio::Session::HIGH_LEVEL));
Irq_session_client irq(signal_input.irq_session(Gpio::Session::HIGH_LEVEL));
irq.sigh(sig_rec.manage(&sig_ctx));
irq.ack_irq();
while(1)
while(true)
{
_state = !_state;
_led.write(_state);
state = !state;
led.write(state);
/*
* Wait for a GIO signal on _signal_input
@ -95,21 +83,19 @@ int main(int, char **)
/*
* Small delay between push button actions
*/
_timer.msleep(100);
timer.msleep(100);
/*
* Switch the LED state
*/
if(!_state)
{
Genode::log("Led going OFF");
}else
{
Genode::log("Led going ON");
}
if(!state) {
log("Led going OFF");
} else {
log("Led going ON"); }
irq.ack_irq();
}
return 0;
}
void Component::construct(Env &env) { static Main main(env); }