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