base: count caps replied by a rpc function

Issue #905
This commit is contained in:
Alexander Boettcher 2013-09-16 10:50:15 +02:00 committed by Norman Feske
parent 772616bf38
commit a6af6c80ab
11 changed files with 49 additions and 19 deletions

View File

@ -115,8 +115,8 @@ void Ipc_client::_call()
}
Ipc_client::Ipc_client(Native_capability const &srv,
Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg)
Ipc_client::Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg,
Msgbuf_base *rcv_msg, unsigned short)
: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0)
{ }

View File

@ -152,7 +152,7 @@ void Ipc_client::_call()
Ipc_client::Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg,
Msgbuf_base *rcv_msg):
Msgbuf_base *rcv_msg, unsigned short):
Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0)
{ }

View File

@ -291,8 +291,8 @@ void Ipc_client::_call()
}
Ipc_client::Ipc_client(Native_capability const &srv,
Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg)
Ipc_client::Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg,
Msgbuf_base *rcv_msg, unsigned short)
: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0) { }

View File

@ -52,8 +52,8 @@ Ipc_istream::~Ipc_istream() { }
void Ipc_client::_call() { }
Ipc_client::Ipc_client(Native_capability const &srv,
Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg)
Ipc_client::Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg,
Msgbuf_base *rcv_msg, unsigned short)
: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0)
{ }

View File

@ -134,8 +134,8 @@ void Ipc_client::_call()
}
Ipc_client::Ipc_client(Native_capability const &srv,
Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg)
Ipc_client::Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg,
Msgbuf_base *rcv_msg, unsigned short)
: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0) { }

View File

@ -546,8 +546,8 @@ void Ipc_client::_call()
}
Ipc_client::Ipc_client(Native_capability const &srv,
Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg)
Ipc_client::Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg,
Msgbuf_base *rcv_msg, unsigned short)
: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0)
{
_prepare_next_call();

View File

@ -183,8 +183,8 @@ void Ipc_client::_call()
}
Ipc_client::Ipc_client(Native_capability const &srv,
Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg)
Ipc_client::Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg,
Msgbuf_base *rcv_msg, unsigned short const rcv_caps)
: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0)
{ }

View File

@ -203,8 +203,8 @@ void Ipc_client::_call()
}
Ipc_client::Ipc_client(Native_capability const &srv,
Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg)
Ipc_client::Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg,
Msgbuf_base *rcv_msg, unsigned short)
: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0) { }

View File

@ -219,7 +219,7 @@ void Ipc_client::_call()
Ipc_client::Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg,
Msgbuf_base *rcv_msg) :
Msgbuf_base *rcv_msg, unsigned short) :
Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0)
{
IPCDEBUG("Ipc_client constructed.\n");

View File

@ -435,7 +435,7 @@ namespace Genode {
* Constructor
*/
Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg,
Msgbuf_base *rcv_msg);
Msgbuf_base *rcv_msg, unsigned short rcv_caps = ~0);
/**
* Operator that issues an IPC call

View File

@ -38,6 +38,35 @@ namespace Genode {
: Capability<RPC_INTERFACE>(cap) { }
};
/**
* Count capabilities of a RPC_FUNCTION which are out parameters.
*/
template <typename T> struct Cap_para_out { enum { Value = 0 }; };
template <typename T> struct Cap_para_out<Capability<T> *> { enum { Value = 1 }; };
template <typename T> struct Cap_para_out<Capability<T> &> { enum { Value = 1 }; };
template <> struct Cap_para_out<Native_capability *> { enum { Value = 1 }; };
template <> struct Cap_para_out<Native_capability &> { enum { Value = 1 }; };
template <typename T> struct Cap_return { enum { Value = 0 }; };
template <typename T> struct Cap_return<Capability<T> > { enum { Value = 1 }; };
template <typename T> struct Cap_return<Capability<T> *> { enum { Value = 1 }; };
template <typename T> struct Cap_return<Capability<T> &> { enum { Value = 1 }; };
template <> struct Cap_return<Native_capability> { enum { Value = 1 }; };
template <> struct Cap_return<Native_capability *> { enum { Value = 1 }; };
template <> struct Cap_return<Native_capability &> { enum { Value = 1 }; };
template <typename ARGS>
struct Rpc_caps_out {
enum { Value = Cap_para_out<typename ARGS::Head>::Value
+ Rpc_caps_out<typename ARGS::Tail>::Value }; };
template <>
struct Rpc_caps_out<Meta::Empty> { enum { Value = 0 }; };
template <typename RPC_FUNCTION>
struct Rpc_function_caps_out {
enum { Value = Rpc_caps_out<typename RPC_FUNCTION::Server_args>::Value +
Cap_return <typename RPC_FUNCTION::Ret_type>::Value}; };
/*********************************************************
** Implementation of 'Capability:call' functions **
@ -106,12 +135,13 @@ namespace Genode {
*/
enum { PROTOCOL_OVERHEAD = 4*sizeof(long),
CALL_MSG_SIZE = Rpc_function_msg_size<IF, RPC_CALL>::Value,
REPLY_MSG_SIZE = Rpc_function_msg_size<IF, RPC_REPLY>::Value };
REPLY_MSG_SIZE = Rpc_function_msg_size<IF, RPC_REPLY>::Value,
CAP_BY_VALUE = Rpc_function_caps_out<IF>::Value };
Msgbuf<CALL_MSG_SIZE + PROTOCOL_OVERHEAD> call_buf;
Msgbuf<REPLY_MSG_SIZE + PROTOCOL_OVERHEAD> reply_buf;
Ipc_client ipc_client(*this, &call_buf, &reply_buf);
Ipc_client ipc_client(*this, &call_buf, &reply_buf, CAP_BY_VALUE);
/* determine opcode of RPC function */
typedef typename RPC_INTERFACE::Rpc_functions Rpc_functions;