mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-31 14:40:54 +00:00
parent
38a1e95979
commit
b85fdd828a
@ -15,27 +15,25 @@
|
|||||||
#include <util/volatile_object.h>
|
#include <util/volatile_object.h>
|
||||||
#include <util/arg_string.h>
|
#include <util/arg_string.h>
|
||||||
#include <base/heap.h>
|
#include <base/heap.h>
|
||||||
#include <base/env.h>
|
#include <base/component.h>
|
||||||
#include <root/component.h>
|
|
||||||
#include <os/server.h>
|
|
||||||
#include <os/config.h>
|
|
||||||
#include <os/attached_ram_dataspace.h>
|
|
||||||
#include <os/server.h>
|
|
||||||
#include <rom_session/rom_session.h>
|
|
||||||
#include <timer_session/connection.h>
|
|
||||||
#include <base/session_label.h>
|
#include <base/session_label.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
|
#include <os/attached_rom_dataspace.h>
|
||||||
|
#include <os/attached_ram_dataspace.h>
|
||||||
|
#include <rom_session/rom_session.h>
|
||||||
|
#include <timer_session/connection.h>
|
||||||
|
#include <root/component.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Dynamic_rom {
|
namespace Dynamic_rom {
|
||||||
using Server::Entrypoint;
|
using Genode::Entrypoint;
|
||||||
using Genode::Rpc_object;
|
using Genode::Rpc_object;
|
||||||
using Genode::Sliced_heap;
|
using Genode::Sliced_heap;
|
||||||
using Genode::env;
|
using Genode::Env;
|
||||||
using Genode::Lazy_volatile_object;
|
using Genode::Lazy_volatile_object;
|
||||||
using Genode::Signal_context_capability;
|
using Genode::Signal_context_capability;
|
||||||
|
using Genode::Signal_handler;
|
||||||
using Genode::Xml_node;
|
using Genode::Xml_node;
|
||||||
using Genode::Signal_rpc_member;
|
|
||||||
using Genode::Arg_string;
|
using Genode::Arg_string;
|
||||||
|
|
||||||
class Session_component;
|
class Session_component;
|
||||||
@ -66,18 +64,17 @@ class Dynamic_rom::Session_component : public Rpc_object<Genode::Rom_session>
|
|||||||
Genode::Signal_transmitter(_sigh).submit();
|
Genode::Signal_transmitter(_sigh).submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print message prefixed with ROM name
|
||||||
|
*/
|
||||||
template <typename... ARGS>
|
template <typename... ARGS>
|
||||||
void _log(char const *format, ARGS... args)
|
void _log(ARGS&&... args)
|
||||||
{
|
{
|
||||||
if (!_verbose)
|
if (!_verbose)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char name[200];
|
typedef Genode::String<160> Name;
|
||||||
_rom_node.attribute("name").value(name, sizeof(name));
|
Genode::log(_rom_node.attribute_value("name", Name()), ": ", args...);
|
||||||
|
|
||||||
Genode::printf("%s: ", name);
|
|
||||||
Genode::printf(format, args...);
|
|
||||||
Genode::printf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Execution_state { EXEC_CONTINUE, EXEC_BLOCK };
|
enum Execution_state { EXEC_CONTINUE, EXEC_BLOCK };
|
||||||
@ -96,10 +93,9 @@ class Dynamic_rom::Session_component : public Rpc_object<Genode::Rom_session>
|
|||||||
_notify_client();
|
_notify_client();
|
||||||
|
|
||||||
if (curr_step.has_attribute("description")) {
|
if (curr_step.has_attribute("description")) {
|
||||||
char desc[200];
|
typedef Genode::String<200> Desc;
|
||||||
desc[0] = 0;
|
Desc desc = curr_step.attribute_value("description", Desc());
|
||||||
curr_step.attribute("description").value(desc, sizeof(desc));
|
_log("change (", desc.string(), ")");
|
||||||
_log("change (%s)", desc);
|
|
||||||
} else {
|
} else {
|
||||||
_log("change");
|
_log("change");
|
||||||
}
|
}
|
||||||
@ -126,7 +122,7 @@ class Dynamic_rom::Session_component : public Rpc_object<Genode::Rom_session>
|
|||||||
unsigned long milliseconds = 0;
|
unsigned long milliseconds = 0;
|
||||||
curr_step.attribute("milliseconds").value(&milliseconds);
|
curr_step.attribute("milliseconds").value(&milliseconds);
|
||||||
_timer.trigger_once(milliseconds*1000);
|
_timer.trigger_once(milliseconds*1000);
|
||||||
_log("sleep %ld milliseconds", milliseconds);
|
_log("sleep ", milliseconds, " milliseconds");
|
||||||
|
|
||||||
return EXEC_BLOCK;
|
return EXEC_BLOCK;
|
||||||
}
|
}
|
||||||
@ -146,12 +142,12 @@ class Dynamic_rom::Session_component : public Rpc_object<Genode::Rom_session>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _timer_handler(unsigned) { _execute_steps_until_sleep(); }
|
void _handle_timer() { _execute_steps_until_sleep(); }
|
||||||
|
|
||||||
Entrypoint &_ep;
|
Entrypoint &_ep;
|
||||||
|
|
||||||
typedef Session_component This;
|
typedef Session_component This;
|
||||||
Signal_rpc_member<This> _timer_dispatcher = { _ep, *this, &This::_timer_handler };
|
Signal_handler<This> _timer_handler = { _ep, *this, &This::_handle_timer };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -160,7 +156,7 @@ class Dynamic_rom::Session_component : public Rpc_object<Genode::Rom_session>
|
|||||||
_verbose(verbose), _rom_node(rom_node), _ep(ep)
|
_verbose(verbose), _rom_node(rom_node), _ep(ep)
|
||||||
{
|
{
|
||||||
/* init timer signal handler */
|
/* init timer signal handler */
|
||||||
_timer.sigh(_timer_dispatcher);
|
_timer.sigh(_timer_handler);
|
||||||
|
|
||||||
/* execute first step immediately at session-creation time */
|
/* execute first step immediately at session-creation time */
|
||||||
_execute_steps_until_sleep();
|
_execute_steps_until_sleep();
|
||||||
@ -251,36 +247,30 @@ class Dynamic_rom::Root : public Genode::Root_component<Session_component>
|
|||||||
|
|
||||||
struct Dynamic_rom::Main
|
struct Dynamic_rom::Main
|
||||||
{
|
{
|
||||||
bool _verbose_config()
|
Env &env;
|
||||||
|
|
||||||
|
Genode::Attached_rom_dataspace config { env, "config" };
|
||||||
|
|
||||||
|
bool verbose = config.xml().attribute_value("verbose", false);
|
||||||
|
|
||||||
|
Sliced_heap sliced_heap { env.ram(), env.rm() };
|
||||||
|
|
||||||
|
Root root { env.ep(), sliced_heap, config.xml(), verbose };
|
||||||
|
|
||||||
|
Main(Env &env) : env(env)
|
||||||
{
|
{
|
||||||
Xml_node config = Genode::config()->xml_node();
|
env.parent().announce(env.ep().manage(root));
|
||||||
|
|
||||||
return config.attribute_value("verbose", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool verbose = _verbose_config();
|
|
||||||
|
|
||||||
Entrypoint &ep;
|
|
||||||
|
|
||||||
Sliced_heap sliced_heap = { env()->ram_session(), env()->rm_session() };
|
|
||||||
|
|
||||||
Root root = { ep, sliced_heap, Genode::config()->xml_node(), verbose };
|
|
||||||
|
|
||||||
Main(Entrypoint &ep) : ep(ep)
|
|
||||||
{
|
|
||||||
env()->parent()->announce(ep.manage(root));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
namespace Server {
|
/***************
|
||||||
|
** Component **
|
||||||
|
***************/
|
||||||
|
|
||||||
char const *name() { return "dynamic_rom_ep"; }
|
namespace Component {
|
||||||
|
|
||||||
size_t stack_size() { return 4*1024*sizeof(long); }
|
Genode::size_t stack_size() { return 4*1024*sizeof(long); }
|
||||||
|
|
||||||
void construct(Entrypoint &ep)
|
void construct(Genode::Env &env) { static Dynamic_rom::Main main(env); }
|
||||||
{
|
|
||||||
static Dynamic_rom::Main main(ep);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
TARGET = dynamic_rom
|
TARGET = dynamic_rom
|
||||||
SRC_CC = main.cc
|
SRC_CC = main.cc
|
||||||
LIBS = base server config
|
LIBS = base
|
||||||
|
Loading…
x
Reference in New Issue
Block a user