Hi Daniel,

passing capabilities as out parameters is expected to work when passing
the cap as reference. Please find attached an example in the form of a
patch, where I changed the signature of an RPC function to the use of an
out parameter of a capability type.

Best regards
Norman

-- 
Dr.-Ing. Norman Feske
Genode Labs

http://www.genode-labs.com · http://genode.org

Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth
commit 81132ceab6eef4ef266fa9130a5f975648390b9f
Author: Norman Feske <[email protected]>
Date:   Mon Feb 18 10:06:43 2013 +0100

    Test for passing a capability as out parameters
    
    This patch changes the signature of the RPC function
    'Nitpicker::Session::Rpc_framebuffer_session' to return the
    framebuffer as out parameter rather than as a return value.
    The new function has the suffix '_out'. In the client stub,
    there is a wrapper function with the original signature to
    uphold compatibility to the original interface.

diff --git a/os/include/nitpicker_session/client.h b/os/include/nitpicker_session/client.h
index 07523db..56e3da7 100644
--- a/os/include/nitpicker_session/client.h
+++ b/os/include/nitpicker_session/client.h
@@ -24,8 +24,17 @@ namespace Nitpicker {
 		explicit Session_client(Session_capability session)
 		: Genode::Rpc_client<Session>(session) { }
 
-		Framebuffer::Session_capability framebuffer_session() {
-			return call<Rpc_framebuffer_session>(); }
+		void framebuffer_session_out(Framebuffer::Session_capability &out)
+		{
+			call<Rpc_framebuffer_session_out>(out);
+		}
+
+		Framebuffer::Session_capability framebuffer_session()
+		{
+			Framebuffer::Session_capability result;
+			framebuffer_session_out(result);
+			return result;
+		}
 
 		Input::Session_capability input_session() {
 			return call<Rpc_input_session>(); }
diff --git a/os/include/nitpicker_session/nitpicker_session.h b/os/include/nitpicker_session/nitpicker_session.h
index a636bfd..53d21d0 100644
--- a/os/include/nitpicker_session/nitpicker_session.h
+++ b/os/include/nitpicker_session/nitpicker_session.h
@@ -32,7 +32,7 @@ namespace Nitpicker {
 		/**
 		 * Request framebuffer sub-session
 		 */
-		virtual Framebuffer::Session_capability framebuffer_session() = 0;
+		virtual void framebuffer_session_out(Framebuffer::Session_capability &) = 0;
 
 		/**
 		 * Request input sub-session
@@ -61,13 +61,14 @@ namespace Nitpicker {
 		 ** RPC declaration **
 		 *********************/
 
-		GENODE_RPC(Rpc_framebuffer_session, Framebuffer::Session_capability, framebuffer_session);
+		GENODE_RPC(Rpc_framebuffer_session_out, void, framebuffer_session_out,
+		           Framebuffer::Session_capability &);
 		GENODE_RPC(Rpc_input_session, Input::Session_capability, input_session);
 		GENODE_RPC(Rpc_create_view, View_capability, create_view);
 		GENODE_RPC(Rpc_destroy_view, void, destroy_view, View_capability);
 		GENODE_RPC(Rpc_background, int, background, View_capability);
 
-		GENODE_RPC_INTERFACE(Rpc_framebuffer_session, Rpc_input_session,
+		GENODE_RPC_INTERFACE(Rpc_framebuffer_session_out, Rpc_input_session,
 		                     Rpc_create_view, Rpc_destroy_view, Rpc_background);
 	};
 }
diff --git a/os/src/server/nitpicker/genode/main.cc b/os/src/server/nitpicker/genode/main.cc
index e566b51..8fb55d3 100644
--- a/os/src/server/nitpicker/genode/main.cc
+++ b/os/src/server/nitpicker/genode/main.cc
@@ -494,8 +494,10 @@ namespace Nitpicker {
 			 ** Nitpicker session interface **
 			 *********************************/
 
-			Framebuffer::Session_capability framebuffer_session() {
-				return _framebuffer_session_cap; }
+			void framebuffer_session_out(Framebuffer::Session_capability &out)
+			{
+				out = _framebuffer_session_cap;
+			}
 
 			Input::Session_capability input_session() {
 				return _input_session_cap; }
------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, 
is your hub for all things parallel software development, from weekly thought 
leadership blogs to news, videos, case studies, tutorials, tech docs, 
whitepapers, evaluation guides, and opinion stories. Check out the most 
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Genode-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/genode-main

Reply via email to