From a6af6c80abeb8192230f8dec19bb66a8d8d9acd3 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 16 Sep 2013 10:50:15 +0200 Subject: [PATCH] base: count caps replied by a rpc function Issue #905 --- base-codezero/src/base/ipc/ipc.cc | 4 ++-- base-fiasco/src/base/ipc/ipc.cc | 2 +- base-foc/src/base/ipc/ipc.cc | 4 ++-- base-host/src/base/ipc/ipc.cc | 4 ++-- base-hw/src/base/ipc.cc | 4 ++-- base-linux/src/base/ipc/ipc.cc | 4 ++-- base-nova/src/base/ipc/ipc.cc | 4 ++-- base-okl4/src/base/ipc/ipc.cc | 4 ++-- base-pistachio/src/base/ipc/ipc.cc | 2 +- base/include/base/ipc.h | 2 +- base/include/base/rpc_client.h | 34 ++++++++++++++++++++++++++++-- 11 files changed, 49 insertions(+), 19 deletions(-) diff --git a/base-codezero/src/base/ipc/ipc.cc b/base-codezero/src/base/ipc/ipc.cc index d7ce42ec9b..443478c23c 100644 --- a/base-codezero/src/base/ipc/ipc.cc +++ b/base-codezero/src/base/ipc/ipc.cc @@ -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) { } diff --git a/base-fiasco/src/base/ipc/ipc.cc b/base-fiasco/src/base/ipc/ipc.cc index d60258a62b..433d0f7204 100644 --- a/base-fiasco/src/base/ipc/ipc.cc +++ b/base-fiasco/src/base/ipc/ipc.cc @@ -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) { } diff --git a/base-foc/src/base/ipc/ipc.cc b/base-foc/src/base/ipc/ipc.cc index e693d6367f..649002e359 100644 --- a/base-foc/src/base/ipc/ipc.cc +++ b/base-foc/src/base/ipc/ipc.cc @@ -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) { } diff --git a/base-host/src/base/ipc/ipc.cc b/base-host/src/base/ipc/ipc.cc index 536c71fa4e..c958cd7cf0 100644 --- a/base-host/src/base/ipc/ipc.cc +++ b/base-host/src/base/ipc/ipc.cc @@ -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) { } diff --git a/base-hw/src/base/ipc.cc b/base-hw/src/base/ipc.cc index 99f642dd6a..9eb088974a 100644 --- a/base-hw/src/base/ipc.cc +++ b/base-hw/src/base/ipc.cc @@ -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) { } diff --git a/base-linux/src/base/ipc/ipc.cc b/base-linux/src/base/ipc/ipc.cc index a56a3c42e4..a3b15d8242 100644 --- a/base-linux/src/base/ipc/ipc.cc +++ b/base-linux/src/base/ipc/ipc.cc @@ -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(); diff --git a/base-nova/src/base/ipc/ipc.cc b/base-nova/src/base/ipc/ipc.cc index e56d45fff4..2499a360e1 100644 --- a/base-nova/src/base/ipc/ipc.cc +++ b/base-nova/src/base/ipc/ipc.cc @@ -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) { } diff --git a/base-okl4/src/base/ipc/ipc.cc b/base-okl4/src/base/ipc/ipc.cc index 04c521ee5a..dbcbffec19 100644 --- a/base-okl4/src/base/ipc/ipc.cc +++ b/base-okl4/src/base/ipc/ipc.cc @@ -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) { } diff --git a/base-pistachio/src/base/ipc/ipc.cc b/base-pistachio/src/base/ipc/ipc.cc index f769338838..590316ed81 100644 --- a/base-pistachio/src/base/ipc/ipc.cc +++ b/base-pistachio/src/base/ipc/ipc.cc @@ -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"); diff --git a/base/include/base/ipc.h b/base/include/base/ipc.h index a495f2ee38..463551d4df 100644 --- a/base/include/base/ipc.h +++ b/base/include/base/ipc.h @@ -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 diff --git a/base/include/base/rpc_client.h b/base/include/base/rpc_client.h index b070075e50..49b0090f8d 100644 --- a/base/include/base/rpc_client.h +++ b/base/include/base/rpc_client.h @@ -38,6 +38,35 @@ namespace Genode { : Capability(cap) { } }; + /** + * Count capabilities of a RPC_FUNCTION which are out parameters. + */ + template struct Cap_para_out { enum { Value = 0 }; }; + template struct Cap_para_out *> { enum { Value = 1 }; }; + template struct Cap_para_out &> { enum { Value = 1 }; }; + template <> struct Cap_para_out { enum { Value = 1 }; }; + template <> struct Cap_para_out { enum { Value = 1 }; }; + + template struct Cap_return { enum { Value = 0 }; }; + template struct Cap_return > { enum { Value = 1 }; }; + template struct Cap_return *> { enum { Value = 1 }; }; + template struct Cap_return &> { enum { Value = 1 }; }; + template <> struct Cap_return { enum { Value = 1 }; }; + template <> struct Cap_return { enum { Value = 1 }; }; + template <> struct Cap_return { enum { Value = 1 }; }; + + template + struct Rpc_caps_out { + enum { Value = Cap_para_out::Value + + Rpc_caps_out::Value }; }; + + template <> + struct Rpc_caps_out { enum { Value = 0 }; }; + + template + struct Rpc_function_caps_out { + enum { Value = Rpc_caps_out::Value + + Cap_return ::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::Value, - REPLY_MSG_SIZE = Rpc_function_msg_size::Value }; + REPLY_MSG_SIZE = Rpc_function_msg_size::Value, + CAP_BY_VALUE = Rpc_function_caps_out::Value }; Msgbuf call_buf; Msgbuf 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;