]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/valgrind/src/valgrind-3.6.0-svn/coregrind/l4re/vcon
update
[l4.git] / l4 / pkg / valgrind / src / valgrind-3.6.0-svn / coregrind / l4re / vcon
1 // vim: ft=cpp et
2
3 /*
4  * This file is part of the Valgrind port to L4Re.
5  *
6  * (c) 2009-2010 Aaron Pohle <apohle@os.inf.tu-dresden.de>,
7  *               Bjoern Doebel <doebel@os.inf.tu-dresden.de>
8  *     economic rights: Technische Universitaet Dresden (Germany)
9  */
10
11 namespace Vcap
12 {
13 /*
14  * Explanation:
15  *   L4Re's VCon server could have been declared as:
16  *     class vcon_svr {
17  *        virtual int dispatch() = 0;
18  *        virtual int read() = 0;
19  *        vitrual int write() = 0;
20  *     };
21  *
22  *  However, someone disliked the idea of having these virtual
23  *  functions for performance reasons (vtable lookup). Therefore,
24  *  the class is now declared as
25  *
26  *    class vcon_svr<SVR> {
27  *       SVR* self() { return static_cast<SVR*>(this); }
28  *    };
29  *
30  *  So in order to implement a valid VCon server class, we need to
31  *  inherit from this server class _and_ pass our class name as the
32  *  template parameter at the same time.
33  */
34 class vcon_srv : public L4Re::Util::Vcon_svr<Vcap::vcon_srv>
35 {
36     public:
37         int vcon_write(const char *buffer, unsigned size)
38         {
39             static char const *prefix = "\033[35m";
40             static char const *suffix = "\033[0m";
41             Char buf[L4_VCON_WRITE_SIZE] = {0, };
42
43             VG_(sprintf)(buf, "%s", prefix);
44             VG_(memcpy)(buf + VG_(strlen)((Char const*)prefix), buffer, size);
45             VG_(sprintf)(buf + VG_(strlen)((Char const *)prefix) + size,
46                          "%s", suffix);
47
48             VG_(printf)("%s", buf);
49
50             return 0;
51         }
52
53         int vcon_read(char *buffer, unsigned size)
54         {
55             enter_kdebug("vcon_read");
56             return 0;
57         }
58
59         L4::Cap<void> vcon_get_irq()
60         {
61             enter_kdebug("vcon_get_irq");
62             return L4::Cap<void>(L4_INVALID_CAP);
63         }
64
65         bool  vcon_end()
66         {
67             enter_kdebug("vcon_end");
68             return false;
69         }
70 };
71 };