how to transfer capabilities from server to client

Markus Partheymueller mpartheym at
Fri Jun 6 21:12:11 CEST 2014

> 1.  In this example, server maps the capability in the client to itself?

In this example, the server receives a capability from the client. This scenario is a bit more complicated, because the server has to prepare for receiving the capability. Your setup will most likely be simpler, because you want the client to receive the cap (if I got that right).

> 2. In the server code, there are two "caps rcv_cap" and "tmp".  Why do we use tmp here? 
>      Can't we only use the rcv_cap to receive the capability?
> 3. Finally, in the server, where is the capability is mapped in? tmp or rec_cap?

As hinted above, the scenario is more complex. To receive a capability, you have to put a receive item into the UTCB used for the communication _before_ the corresponding send item is inserted. Normally the server just waits for a call and then reads out the request. The example shows how to use the wait setup to actually put that receive item into the UTCB. If instead the client should receive a cap from the server, it is rather simple: 

- Client puts parameters for the call into the UTCB
- Client puts receive item for the cap into the UTCB
- Server receives the parameters
- Server puts the send item into the UTCB

When the call is completed, the capability will be mapped to the client.

The reason for tmp is now reusability. rcv_cap is used for every call to the server, carrying a capability. Each time the server receives that, it moves the received cap into tmp and thereby frees rcv_cap for the next request. This way, setup_wait can always insert rcv_cap into the UTCB as receive item.

I hope that clears things up a bit.

Cheers, Markus

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <>

More information about the l4-hackers mailing list