mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 12:32:56 +01:00
Merge branch 'master' of github.com:mmueller41/genode
This commit is contained in:
@@ -22,14 +22,15 @@ namespace Hello { struct Connection; }
|
||||
|
||||
struct Hello::Connection : Genode::Connection<Session>, Session_client
|
||||
{
|
||||
Connection(Genode::Env &env)
|
||||
:
|
||||
/* create session */
|
||||
Genode::Connection<Hello::Session>(env, session(env.parent(),
|
||||
"ram_quota=6K, cap_quota=4")),
|
||||
Connection(Genode::Env &env, unsigned short id)
|
||||
: /* create session */
|
||||
Genode::Connection<Hello::Session>(env, session(env.parent(),
|
||||
"ram_quota=6K, cap_quota=4")),
|
||||
|
||||
/* initialize RPC interface */
|
||||
Session_client(cap()) { }
|
||||
/* initialize RPC interface */
|
||||
Session_client(cap())
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__HELLO_SESSION__CONNECTION_H_ */
|
||||
|
||||
@@ -24,6 +24,8 @@ struct Hello::Session : Genode::Session
|
||||
{
|
||||
static const char *service_name() { return "Hello"; }
|
||||
|
||||
unsigned short _id;
|
||||
|
||||
enum { CAP_QUOTA = 2 };
|
||||
|
||||
virtual void say_hello() = 0;
|
||||
|
||||
@@ -60,7 +60,7 @@ struct HelloClient {
|
||||
Genode::log("hello test completed.");
|
||||
}
|
||||
|
||||
HelloClient(Genode::Env &env, Hello::Connection &conn) : _env(env), _hello(conn), _a(5), _b(2)
|
||||
HelloClient(Genode::Env &env, Hello::Connection &conn) : _env(env), _a(5), _b(2), _hello(conn)
|
||||
{
|
||||
_config.sigh(_config_handler);
|
||||
_handle_config();
|
||||
@@ -70,7 +70,8 @@ struct HelloClient {
|
||||
void
|
||||
Component::construct(Genode::Env &env)
|
||||
{
|
||||
Hello::Connection hello(env);
|
||||
Timer::Connection timer(env);
|
||||
Hello::Connection hello(env, (unsigned short)timer.elapsed_ms());
|
||||
|
||||
HelloClient client(env, hello);
|
||||
client.run();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <root/component.h>
|
||||
#include <hello_session/hello_session.h>
|
||||
#include <base/rpc_server.h>
|
||||
|
||||
#include <timer_session/connection.h>
|
||||
namespace Hello {
|
||||
struct Session_component;
|
||||
struct Root_component;
|
||||
@@ -28,8 +28,12 @@ namespace Hello {
|
||||
|
||||
struct Hello::Session_component : Genode::Rpc_object<Session>
|
||||
{
|
||||
unsigned int _id;
|
||||
|
||||
Session_component(unsigned short id) : Genode::Rpc_object<Session>(), _id(id) {}
|
||||
|
||||
void say_hello() override {
|
||||
Genode::log("I am here... Hello."); }
|
||||
Genode::log("I am here... Hello. My id is ", _id, "."); }
|
||||
|
||||
int add(int a, int b) override {
|
||||
return a + b; }
|
||||
@@ -41,19 +45,21 @@ class Hello::Root_component
|
||||
public Genode::Root_component<Session_component>
|
||||
{
|
||||
protected:
|
||||
Timer::Connection &_timer;
|
||||
|
||||
Session_component *_create_session(const char *) override
|
||||
{
|
||||
Genode::log("creating hello session");
|
||||
return new (md_alloc()) Session_component();
|
||||
return new (md_alloc()) Session_component((unsigned short)_timer.elapsed_ms());
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Root_component(Genode::Entrypoint &ep,
|
||||
Genode::Allocator &alloc)
|
||||
Genode::Allocator &alloc,
|
||||
Timer::Connection &timer)
|
||||
:
|
||||
Genode::Root_component<Session_component>(ep, alloc)
|
||||
Genode::Root_component<Session_component>(ep, alloc), _timer(timer)
|
||||
{
|
||||
Genode::log("creating root component");
|
||||
}
|
||||
@@ -63,6 +69,7 @@ class Hello::Root_component
|
||||
struct Hello::Main
|
||||
{
|
||||
Genode::Env &env;
|
||||
Timer::Connection _timer { env };
|
||||
|
||||
/*
|
||||
* A sliced heap is used for allocating session objects - thereby we
|
||||
@@ -70,7 +77,7 @@ struct Hello::Main
|
||||
*/
|
||||
Genode::Sliced_heap sliced_heap { env.ram(), env.rm() };
|
||||
|
||||
Hello::Root_component root { env.ep(), sliced_heap };
|
||||
Hello::Root_component root { env.ep(), sliced_heap, _timer };
|
||||
|
||||
Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user