L4Re - L4 Runtime Environment
goos_svr
1 // vi:set ft=cpp: -*- Mode: C++ -*-
2 /*
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)
6  *
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  * 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.
19  */
20 
21 #pragma once
22 
23 #include <l4/re/dataspace>
24 #include <l4/re/video/goos>
25 #include <l4/re/video/goos-sys.h>
26 
27 #include <l4/sys/capability>
28 #include <l4/sys/cxx/ipc_legacy>
29 
30 namespace L4Re { namespace Util { namespace Video {
31 
32 /**
33  * \brief Goos server class.
34  * \ingroup api_l4re_util
35  */
36 class Goos_svr
37 {
38  typedef L4Re::Video::Goos::Rights Rights;
39 protected:
40  /** Goos memory dataspace */
41  L4::Cap<L4Re::Dataspace> _fb_ds;
42  /** Goos information */
43  L4Re::Video::Goos::Info _screen_info;
44  /** View information */
45  L4Re::Video::View::Info _view_info;
46 
47 public:
48  L4_RPC_LEGACY_DISPATCH(L4Re::Video::Goos);
49  /**
50  * \brief Return framebuffer memory dataspace.
51  * \return Goos memory dataspace
52  */
53  L4::Cap<L4Re::Dataspace> get_fb() const { return _fb_ds; }
54 
55  /**
56  * \brief Goos information structure.
57  * \return Return goos information structure.
58  */
59  L4Re::Video::Goos::Info const *screen_info() const { return &_screen_info; }
60 
61  /**
62  * \brief View information structure.
63  * \return Return view information structure.
64  */
65  L4Re::Video::View::Info const *view_info() const { return &_view_info; }
66 
67  /**
68  * \brief Refresh area of the framebuffer
69  *
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
74  *
75  * \return 0 on success, negative error code otherwise
76  */
77  virtual int refresh(int x, int y, int w, int h)
78  { (void)x; (void)y; (void)w; (void)h; return -L4_ENOSYS; }
79 
80 
81  /**
82  * \brief Initialize the view information structure of this object.
83  *
84  * This function initializes the view info structure of this goos object
85  * based on the information in the goos information, i.e. the width,
86  * height and pixel_info of the goos information has to contain valid
87  * values before calling init_info().
88  */
89  void init_infos()
90  {
91  using L4Re::Video::View;
92 
93  _view_info.flags = View::F_none;
94 
95  _view_info.view_index = 0;
96  _view_info.xpos = 0;
97  _view_info.ypos = 0;
98  _view_info.width = _screen_info.width;
99  _view_info.height = _screen_info.height;
100  _view_info.pixel_info = _screen_info.pixel_info;
101  _view_info.buffer_index = 0;
102  }
103 
104  /**
105  * \brief Destructor.
106  */
107  virtual ~Goos_svr() {}
108 
109  long op_view_info(Rights, unsigned idx, L4Re::Video::View::Info &info)
110  {
111  if (idx != 0)
112  return -L4_ERANGE;
113 
114  info = _view_info;
115  return L4_EOK;
116  }
117 
118  long op_info(Rights, L4Re::Video::Goos::Info &info)
119  {
120  info = _screen_info;
121  return L4_EOK;
122  }
123 
124  long op_get_static_buffer(Rights, unsigned idx,
125  L4::Ipc::Cap<L4Re::Dataspace> &ds)
126  {
127  if (idx != 0)
128  return -L4_ERANGE;
129 
130  ds = L4::Ipc::Cap<L4Re::Dataspace>(_fb_ds, L4_CAP_FPAGE_RW);
131  return L4_EOK;
132  }
133 
134  long op_refresh(Rights, int x, int y, int w, int h)
135  { return refresh(x, y, w, h); }
136 
137  long op_view_refresh(Rights, unsigned idx, int x, int y, int w, int h)
138  {
139  if (idx != 0)
140  return -L4_ERANGE;
141 
142  return refresh(x, y, w, h);
143  }
144 
145  long op_set_view_info(Rights, unsigned, L4Re::Video::View::Info)
146  { return -L4_ENOSYS; }
147 
148  long op_view_stack(Rights, unsigned, unsigned, bool)
149  { return -L4_ENOSYS; }
150 
151  long op_delete_view(Rights, unsigned)
152  { return -L4_ENOSYS; }
153 
154  long op_create_view(Rights)
155  { return -L4_ENOSYS; }
156 
157  long op_create_buffer(Rights, unsigned long,
158  L4::Ipc::Cap<L4Re::Dataspace> &)
159  { return -L4_ENOSYS; }
160 
161  long op_delete_buffer(Rights, unsigned)
162  { return -L4_ENOSYS; }
163 };
164 
165 
166 }}}