3 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
4 * Alexander Warg <warg@os.inf.tu-dresden.de>
5 * economic rights: Technische Universität Dresden (Germany)
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.
11 * As a special exception, you may use this file as part of a free software
12 * library without restriction. Specifically, if other files instantiate
13 * templates or use macros or inline functions from this file, or you compile
14 * this file and link it with other files to produce an executable, this
15 * file does not by itself cause the resulting executable to be covered by
16 * the GNU General Public License. This exception does not however
17 * invalidate any other reasons why the executable file might be covered by
18 * the GNU General Public License.
23 #include <l4/re/dataspace>
24 #include <l4/re/protocols>
25 #include <l4/re/video/goos>
26 #include <l4/re/video/goos-sys.h>
28 #include <l4/sys/capability>
29 #include <l4/cxx/ipc_server>
32 namespace L4Re { namespace Util { namespace Video {
35 * \brief Goos server class.
36 * \ingroup api_l4re_util
41 /** Goos memory dataspace */
42 L4::Cap<L4Re::Dataspace> _fb_ds;
43 /** Goos information */
44 L4Re::Video::Goos::Info _screen_info;
45 /** View information */
46 L4Re::Video::View::Info _view_info;
50 * \brief Return framebuffer memory dataspace.
51 * \return Goos memory dataspace
53 L4::Cap<L4Re::Dataspace> get_fb() const { return _fb_ds; }
56 * \brief Goos information structure.
57 * \return Return goos information structure.
59 L4Re::Video::Goos::Info const *screen_info() const { return &_screen_info; }
62 * \brief View information structure.
63 * \return Return view information structure.
65 L4Re::Video::View::Info const *view_info() const { return &_view_info; }
68 * \brief Refresh area of the framebuffer
70 * \param x X coordinate (pixels)
71 * \param y Y coordinate (pixels)
72 * \param w Width of area in pixels
73 * \param h Height of area in pixels
75 * \return 0 on success, negative error code otherwise
77 virtual int refresh(int x, int y, int w, int h)
78 { (void)x; (void)y; (void)w; (void)h; return -L4_ENOSYS; }
81 * \brief Server dispatch function.
83 * \param obj Server object ID to work on
84 * \param ios Input/Output stream.
88 int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios);
91 * \brief Initialize the view information structure of this object.
93 * This function initializes the view info structure of this goos object
94 * based on the information in the goos information, i.e. the width,
95 * height and pixel_info of the goos information has to contain valid
96 * values before calling init_info().
100 using L4Re::Video::View;
102 _view_info.flags = View::F_none;
104 _view_info.view_index = 0;
107 _view_info.width = _screen_info.width;
108 _view_info.height = _screen_info.height;
109 _view_info.pixel_info = _screen_info.pixel_info;
110 _view_info.buffer_index = 0;
116 virtual ~Goos_svr() {}
121 Goos_svr::dispatch(l4_umword_t, L4::Ipc::Iostream &ios)
126 if (tag.label() != L4Re::Protocol::Goos)
127 return -L4_EBADPROTO;
134 case L4Re::Video::Goos_::View_info:
141 case L4Re::Video::Goos_::Info:
142 ios.put(_screen_info);
144 case L4Re::Video::Goos_::Get_buffer:
148 ios << L4::Ipc::Snd_fpage(_fb_ds, L4_CAP_FPAGE_RW);
150 case L4Re::Video::Goos_::View_refresh:
153 case L4Re::Video::Goos_::Screen_refresh:
156 ios >> x >> y >> w >> h;
160 return refresh(x, y, w, h);