]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/cons/server/src/vcon_client.h
Update
[l4.git] / l4 / pkg / cons / server / src / vcon_client.h
1 /*
2  * (c) 2012-2013 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *               Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #pragma once
11
12 #include "client.h"
13 #include "server.h"
14
15 #include <l4/re/util/icu_svr>
16 #include <l4/re/util/vcon_svr>
17 #include <l4/re/util/object_registry>
18
19 class Vcon_client
20 : public L4::Epiface_t<Vcon_client, L4::Vcon, Server_object>,
21   public L4Re::Util::Icu_cap_array_svr<Vcon_client>,
22   public L4Re::Util::Vcon_svr<Vcon_client>,
23   public Client
24 {
25 public:
26   typedef L4Re::Util::Icu_cap_array_svr<Vcon_client> Icu_svr;
27   typedef L4Re::Util::Vcon_svr<Vcon_client> My_vcon_svr;
28
29   Vcon_client(std::string const &name, int color, size_t bufsz, Key key,
30               L4Re::Util::Object_registry *)
31   : Icu_svr(1, &_irq),
32     Client(name, color, 512, bufsz < 512 ? _dfl_obufsz : bufsz, key)
33   {}
34
35   void vcon_write(const char *buffer, unsigned size) throw();
36   unsigned vcon_read(char *buffer, unsigned size) throw();
37
38   int vcon_set_attr(l4_vcon_attr_t const *a) throw();
39   int vcon_get_attr(l4_vcon_attr_t *attr) throw();
40
41   const l4_vcon_attr_t *attr() const { return &_attr; }
42
43   void trigger() const { _irq.trigger(); }
44
45   bool collected() { return Client::collected(); }
46
47   static void default_obuf_size(unsigned bufsz)
48   {
49     _dfl_obufsz = cxx::max(512U, cxx::min(16U << 20, bufsz));
50   }
51
52 private:
53   enum { Default_obuf_size = 40960 };
54   static unsigned _dfl_obufsz;
55   Icu_svr::Irq _irq;
56 };