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