]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/examples/libs/l4re/c++/shared_ds/interface.h
98af54cf8d44bda5748c8c85674a2c4a18eddd99
[l4.git] / l4 / pkg / examples / libs / l4re / c++ / shared_ds / interface.h
1 #pragma once
2
3 #include <l4/sys/capability>
4 #include <l4/re/dataspace>
5 #include <l4/cxx/ipc_stream>
6
7 /**
8  * Interface class for remote object.
9  *
10  * Inherits vrom L4::Kobject, via the L4::Kobject_t helper
11  * template that generates the dynamic type information for the meta
12  * protocol.
13  */
14 class My_interface : public L4::Kobject_t<My_interface, L4::Kobject>
15 {
16   // Disable instantiation and copy, because we just qork via
17   // L4::Cap<...> references.
18   L4_KOBJECT(My_interface)
19
20 public:
21   /**
22    * The singe method of our object.
23    * Requesting the data space and the IRQ to notify the server.
24    */
25   int get_shared_buffer(L4::Cap<L4Re::Dataspace> ds, L4::Cap<L4::Irq> irq) throw();
26 };
27
28
29 inline
30 int
31 My_interface::get_shared_buffer(L4::Cap<L4Re::Dataspace> ds, L4::Cap<L4::Irq> irq) throw()
32 {
33   L4::Ipc::Iostream s(l4_utcb());
34   // we have just a single operation, so no opcode needed
35   // s << Opcode;
36
37   // put receive buffer for data-space cap and the irq cap into the stream
38   s << L4::Ipc::Small_buf(ds)
39     << L4::Ipc::Small_buf(irq);
40
41   return l4_error(s.call(cap()));
42 }
43