Hi, What's the best way to create RPC types for variable length data (assuming a maximum size of that will fit in the UTCB). I looked at Rpc_in_buffer, but this seems to only support strings, and using as an out param seems awkward. For the moment I am using a statically sized structure, but I fear there is needless copying going on. BTW, this RPC is for one-off control - of course shared memory is better for streaming.
Daniel
Hi Daniel,
What's the best way to create RPC types for variable length data (assuming a maximum size of that will fit in the UTCB). I looked at Rpc_in_buffer, but this seems to only support strings, and using as an
'Rpc_in_buffer' actually supports arbitrary binary blobs via the Constructor at line 78:
https://github.com/genodelabs/genode/blob/master/base/include/base/rpc_args....
It takes a char pointer and a length as arguments. If you have a buffer of a different type, you need to cast the buffer pointer type to a char pointer.
out param seems awkward. For the moment I am using a statically sized structure, but I fear there is needless copying going on. BTW, this RPC
So far, we hadn't have the use case of transferring variable-sized buffers from the callee to the caller. So there is currently no 'Rpc_out_buffer' available. Such a facility could be added very similarly to 'Rpc_in_buffer'. To get the picture, search for 'Rpc_in_buffer' in 'base/ipc.h'. Adding the handling for an 'Rpc_out_buffer_base' type should be pretty straight forward. Maybe you'd like to give it a go?
is for one-off control - of course shared memory is better for streaming.
I agree. There are several use cases where communicating over shared memory buffer is inconvenient or even impossible, for example if transferring a variable-length string along with a capability (as capabilities cannot be transferred via shared memory).
When using variable-sized arguments, however, please keep in mind that UTCB sizes vary from kernel to kernel. On some kernels, UTCBs are ridiculously small. I am thinking of the ARM version of OKL4v2 (for which we dropped the support some time back though). As a rule of thumb, I recommend to keep RPC message sizes lower than 256 bytes. If messages become larger than that, shared memory should be used.
Regards Norman