]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4con/lib/client_con/con.cc
ec09b58c41564e6bebe503fc173a9f1e455fa5be
[l4.git] / l4 / pkg / l4con / lib / client_con / con.cc
1 /**
2  * \file
3  * \brief  L4 Console
4  */
5 /*
6  * (c) 2008-2009 Technische Universität Dresden
7  * This file is part of TUD:OS and distributed under the terms of the
8  * GNU General Public License 2.
9  * Please see the COPYING-GPL-2 file for details.
10  */
11 #include <l4/l4con/l4con.h>
12 #include <l4/cxx/exceptions>
13 #include <l4/cxx/ipc_helper>
14 #include <l4/cxx/ipc_stream>
15
16 #include <l4/sys/err.h>
17
18 long
19 L4con::close() const throw()
20 {
21   L4::Ipc_iostream io(l4_utcb());
22   io << L4::Opcode(L4con_::Close);
23   return l4_error(io.call(Framebuffer::cap(), L4con::Protocol::Vc));
24 }
25
26 long
27 L4con::pslim_fill(int x, int y, int w, int h, unsigned int color) const throw()
28 {
29   L4::Ipc_iostream io(l4_utcb());
30   io << L4::Opcode(L4con_::Pslim_fill);
31   io << x << y << w << h << color;
32   return l4_error(io.call(Framebuffer::cap(), L4con::Protocol::Vc));
33 }
34
35 long
36 L4con::pslim_copy(int x, int y, int w, int h, l4_int16_t dx, l4_int16_t dy) const throw()
37 {
38   L4::Ipc_iostream io(l4_utcb());
39   io << L4::Opcode(L4con_::Pslim_copy);
40   io << x << y << w << h << dx << dy;
41   return l4_error(io.call(Framebuffer::cap(), L4con::Protocol::Vc));
42 }
43
44 long
45 L4con::puts(const char *s, unsigned long len, short x, short y,
46             unsigned int fg_color, unsigned int bg_color) const throw()
47 {
48   L4::Ipc_iostream io(l4_utcb());
49   io << L4::Opcode(L4con_::Puts);
50   io << x << y << fg_color << bg_color
51      << L4::ipc_buf_cp_out(s, len);
52   return l4_error(io.call(Framebuffer::cap(), L4con::Protocol::Vc));
53 }
54
55 long
56 L4con::puts_scale(const char *s, unsigned long len,
57                   short x, short y,
58                   unsigned int fg_color, unsigned int bg_color,
59                   short scale_x, short scale_y) const throw()
60 {
61   L4::Ipc_iostream io(l4_utcb());
62   io << L4::Opcode(L4con_::Puts_scale);
63   io << x << y << fg_color << bg_color << scale_x << scale_y
64      << L4::ipc_buf_cp_out(s, len);
65   return l4_error(io.call(Framebuffer::cap(), L4con::Protocol::Vc));
66 }
67
68 long
69 L4con::get_font_size(unsigned int *fn_w, unsigned int *fn_h) const throw()
70 {
71   L4::Ipc_iostream io(l4_utcb());
72   io << L4::Opcode(L4con_::Get_font_size);
73   long r = l4_error(io.call(Framebuffer::cap(), L4con::Protocol::Vc));
74   if (EXPECT_FALSE(r < 0))
75     return r;
76
77   io >> *fn_w >> *fn_h;
78   return L4_EOK;
79 }
80
81
82
83
84
85
86
87 /* C part */
88
89 L4_CV long
90 l4con_close(l4re_fb_t fb) L4_NOTHROW
91 {
92   L4::Cap<L4con> f(fb);
93   return f->close();
94 }
95
96 L4_CV long
97 l4con_pslim_fill(l4re_fb_t fb, int x, int y, int w, int h, unsigned int color) L4_NOTHROW
98 {
99   L4::Cap<L4con> f(fb);
100   return f->pslim_fill(x, y, w, h, color);
101 }
102
103 L4_CV long
104 l4con_puts(l4re_fb_t fb, const char *s, unsigned long len, short x, short y,
105              unsigned int fg_color, unsigned int bg_color) L4_NOTHROW
106 {
107   L4::Cap<L4con> f(fb);
108   return f->puts(s, len, x, y, fg_color, bg_color);
109 }
110
111 L4_CV long
112 l4con_puts_scale(l4re_fb_t fb, const char *s, unsigned long len,
113                  short x, short y,
114                  unsigned int fg_color, unsigned int bg_color,
115                  short scale_x, short scale_y) L4_NOTHROW
116 {
117   L4::Cap<L4con> f(fb);
118   return f->puts_scale(s, len, x, y, fg_color, bg_color, scale_x, scale_y);
119 }
120
121 L4_CV long
122 l4con_get_font_size(l4re_fb_t fb, unsigned int *fn_w, unsigned int *fn_h) L4_NOTHROW
123 {
124   L4::Cap<L4con> f(fb);
125   return f->get_font_size(fn_w, fn_h);
126 }
127