Update of the hello tutorial
This commit is contained in:
committed by
Christian Helmuth
parent
357b84835a
commit
92a10541aa
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2008-2013 Genode Labs GmbH
|
||||
* Copyright (C) 2008-2016 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.
|
||||
@@ -16,26 +16,27 @@
|
||||
|
||||
#include <hello_session/hello_session.h>
|
||||
#include <base/rpc_client.h>
|
||||
#include <base/printf.h>
|
||||
#include <base/log.h>
|
||||
|
||||
namespace Hello {
|
||||
namespace Hello { struct Session_client; }
|
||||
|
||||
struct Session_client : Genode::Rpc_client<Session>
|
||||
|
||||
struct Hello::Session_client : Genode::Rpc_client<Session>
|
||||
{
|
||||
Session_client(Genode::Capability<Session> cap)
|
||||
: Genode::Rpc_client<Session>(cap) { }
|
||||
|
||||
void say_hello()
|
||||
{
|
||||
Session_client(Genode::Capability<Session> cap)
|
||||
: Genode::Rpc_client<Session>(cap) { }
|
||||
Genode::log("issue RPC for saying hello");
|
||||
call<Rpc_say_hello>();
|
||||
Genode::log("returned from 'say_hello' RPC call");
|
||||
}
|
||||
|
||||
void say_hello()
|
||||
{
|
||||
PDBG("Saying Hello.");
|
||||
call<Rpc_say_hello>();
|
||||
}
|
||||
|
||||
int add(int a, int b)
|
||||
{
|
||||
return call<Rpc_add>(a, b);
|
||||
}
|
||||
};
|
||||
}
|
||||
int add(int a, int b)
|
||||
{
|
||||
return call<Rpc_add>(a, b);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__HELLO_SESSION_H__CLIENT_H_ */
|
||||
|
||||
@@ -17,18 +17,19 @@
|
||||
#include <hello_session/client.h>
|
||||
#include <base/connection.h>
|
||||
|
||||
namespace Hello {
|
||||
namespace Hello { struct Connection; }
|
||||
|
||||
struct Connection : Genode::Connection<Session>, Session_client
|
||||
{
|
||||
Connection()
|
||||
:
|
||||
/* create session */
|
||||
Genode::Connection<Hello::Session>(session("foo, ram_quota=4K")),
|
||||
|
||||
/* initialize RPC interface */
|
||||
Session_client(cap()) { }
|
||||
};
|
||||
}
|
||||
struct Hello::Connection : Genode::Connection<Session>, Session_client
|
||||
{
|
||||
Connection(Genode::Env &env)
|
||||
:
|
||||
/* create session */
|
||||
Genode::Connection<Hello::Session>(env, session(env.parent(),
|
||||
"ram_quota=4K")),
|
||||
|
||||
/* initialize RPC interface */
|
||||
Session_client(cap()) { }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__HELLO_SESSION__CONNECTION_H_ */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2008-2013 Genode Labs GmbH
|
||||
* Copyright (C) 2008-2016 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.
|
||||
@@ -17,25 +17,25 @@
|
||||
#include <session/session.h>
|
||||
#include <base/rpc.h>
|
||||
|
||||
namespace Hello {
|
||||
|
||||
struct Session : Genode::Session
|
||||
{
|
||||
static const char *service_name() { return "Hello"; }
|
||||
|
||||
virtual void say_hello() = 0;
|
||||
virtual int add(int a, int b) = 0;
|
||||
namespace Hello { struct Session; }
|
||||
|
||||
|
||||
/*******************
|
||||
** RPC interface **
|
||||
*******************/
|
||||
struct Hello::Session : Genode::Session
|
||||
{
|
||||
static const char *service_name() { return "Hello"; }
|
||||
|
||||
GENODE_RPC(Rpc_say_hello, void, say_hello);
|
||||
GENODE_RPC(Rpc_add, int, add, int, int);
|
||||
virtual void say_hello() = 0;
|
||||
virtual int add(int a, int b) = 0;
|
||||
|
||||
GENODE_RPC_INTERFACE(Rpc_say_hello, Rpc_add);
|
||||
};
|
||||
}
|
||||
|
||||
/*******************
|
||||
** RPC interface **
|
||||
*******************/
|
||||
|
||||
GENODE_RPC(Rpc_say_hello, void, say_hello);
|
||||
GENODE_RPC(Rpc_add, int, add, int, int);
|
||||
|
||||
GENODE_RPC_INTERFACE(Rpc_say_hello, Rpc_add);
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__HELLO_SESSION__HELLO_SESSION_H_ */
|
||||
|
||||
Reference in New Issue
Block a user