Hi, I want to write some code to transfer capabilities from server to client. But I have no idea how to do this as I am not familiar with L4Re and its interface. Could anyone give me some example code or some hints?
Thank you very much. Best
Hi,
I want to write some code to transfer capabilities from server to client. But I have no idea how to do this as I am not familiar with L4Re and its interface. Could anyone give me some example code or some hints?
please have a look at l4/pkg/examples/sys/map_irq
Kind regards, Bjoern
It is really useful! Thanks so much.
On Thu, Jun 5, 2014 at 5:51 PM, Björn Döbel doebel@os.inf.tu-dresden.de wrote:
Hi,
I want to write some code to transfer capabilities from server to client. But I have no idea how to do this as I am not familiar with L4Re and its interface. Could anyone give me some example code or some hints?
please have a look at l4/pkg/examples/sys/map_irq
Kind regards, Bjoern
l4-hackers mailing list l4-hackers@os.inf.tu-dresden.de http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
I have some questions about the map_iro code.
1. In this example, server maps the capability in the client to itself? 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?
Thanks a lot.
On Thu, Jun 5, 2014 at 5:51 PM, Björn Döbel doebel@os.inf.tu-dresden.de wrote:
Hi,
I want to write some code to transfer capabilities from server to client. But I have no idea how to do this as I am not familiar with L4Re and its interface. Could anyone give me some example code or some hints?
please have a look at l4/pkg/examples/sys/map_irq
Kind regards, Bjoern
l4-hackers mailing list l4-hackers@os.inf.tu-dresden.de http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
- 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).
- 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?
- 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
Your reply is pretty clear! But I want to make sure another two questions.
1. In the dispatch function of the server, it extracts a cap from the stream L4::Ipc::Snd_fpage cap; ios >> cap; Why do we use "cap" here? What is the difference between "cap" and the receive item(rec_cap)?
2. In this example, when does the map process finish? I think it looks like it has already finished when the server receives the request. If so, does it mean that the kernel preforms the map operation automatically? But how does the kernel know the capability needs to be mapped into server?
Thanks so much!
On Fri, Jun 6, 2014 at 3:12 PM, Markus Partheymueller < mpartheym@os.inf.tu-dresden.de> wrote:
- 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).
- 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?
- 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
- In the dispatch function of the server, it extracts a cap from the stream L4::Ipc::Snd_fpage cap; ios >> cap; Why do we use "cap" here? What is the difference between "cap" and the receive item(rec_cap)?
cap is the flexpage describing the mapping. In particular, it can be used to check the success of the mapping. Otherwise the move call would fail.
- In this example, when does the map process finish? I think it looks like it has already finished when the server receives the request. If so, does it mean that the kernel preforms the map operation automatically? But how does the kernel know the capability needs to be mapped into server?
The mapping is done during the call. During IPC, the kernel matches receive and send items and performs the mapping. This is exactly why the server has to use setup_wait to insert the receive item.
l4-hackers@os.inf.tu-dresden.de