L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
goos
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#pragma once
21
22#include <l4/sys/capability>
23#include <l4/re/dataspace>
24#include <l4/re/video/colors>
25#include <l4/sys/cxx/ipc_iface>
26
27namespace L4Re { namespace Video {
28
29class L4_EXPORT Goos;
30
43{
44private:
45 friend class Goos;
46
47 L4::Cap<Goos> _goos;
48 unsigned _view_idx;
49
50 View(l4_cap_idx_t goos, unsigned idx)
51 : _goos(goos), _view_idx(_goos.is_valid() ? idx : ~0U) {}
52
53 unsigned view_index() const noexcept
54 { return _goos.is_valid() ? _view_idx : ~0U; }
55
56public:
57 View() : _goos(L4::Cap<Goos>::Invalid), _view_idx(~0U) {}
58
62 enum Flags
63 {
64 F_none = 0x00,
65 F_set_buffer = 0x01,
66 F_set_buffer_offset = 0x02,
67 F_set_bytes_per_line = 0x04,
68 F_set_pixel = 0x08,
69 F_set_position = 0x10,
70 F_dyn_allocated = 0x20,
71 F_set_background = 0x40,
72 F_set_flags = 0x80,
73
75 F_fully_dynamic = F_set_buffer | F_set_buffer_offset | F_set_bytes_per_line
76 | F_set_pixel | F_set_position | F_dyn_allocated,
77 };
78
86 {
87 F_above = 0x1000,
88 F_flags_mask = 0xff000,
89 };
90
94 struct Info
95 {
96 unsigned flags;
97 unsigned view_index;
98
99 unsigned long xpos;
100 unsigned long ypos;
101 unsigned long width;
102 unsigned long height;
103 unsigned long buffer_offset;
104 unsigned long bytes_per_line;
106 unsigned buffer_index;
107
109 bool has_static_buffer() const { return !(flags & F_set_buffer); }
111 bool has_static_buffer_offset() const { return !(flags & F_set_buffer_offset); }
112
114 bool has_set_buffer() const { return flags & F_set_buffer; }
116 bool has_set_buffer_offset() const { return flags & F_set_buffer_offset; }
118 bool has_set_bytes_per_line() const { return flags & F_set_bytes_per_line; }
120 bool has_set_pixel() const { return flags & F_set_pixel; }
122 bool has_set_position() const { return flags & F_set_position; }
123
125 template< typename OUT >
126 void dump(OUT &s) const
127 {
128 s.printf("View::Info:\n"
129 " flags: %x\n"
130 " size: %ldx%ld\n"
131 " pos: %ldx%ld\n"
132 " bytes_per_line: %ld\n"
133 " buffer_offset: %lx\n"
134 " ",
135 flags, width, height, xpos, ypos,
136 bytes_per_line, buffer_offset);
137 pixel_info.dump(s);
138 s.printf("\n");
139 }
140 };
141
149 int info(Info *info) const noexcept;
150
161 int set_info(Info const &info) const noexcept;
162
174 int set_viewport(int scr_x, int scr_y, int w, int h, unsigned long buf_offset) const noexcept;
175
185 int stack(View const &pivot, bool behind = true) const noexcept;
186
188 int push_top() const noexcept
189 { return stack(View(), true); }
190
192 int push_bottom() const noexcept
193 { return stack(View(), false); }
194
205 int refresh(int x, int y, int w, int h) const noexcept;
206
208 bool valid() const { return _goos.is_valid(); }
209};
210
211
227 public L4::Kobject_t<Goos, L4::Kobject, L4RE_PROTO_GOOS>
228{
229public:
231 enum Flags
232 {
233 F_auto_refresh = 0x01,
234 F_pointer = 0x02,
235 F_dynamic_views = 0x04,
236 F_dynamic_buffers = 0x08,
237 };
238
240 struct Info
241 {
242 unsigned long width;
243 unsigned long height;
244 unsigned flags;
248
251 bool auto_refresh() const { return flags & F_auto_refresh; }
253 bool has_pointer() const { return flags & F_pointer; }
255 bool has_dynamic_views() const { return flags & F_dynamic_views; }
257 bool has_dynamic_buffers() const { return flags & F_dynamic_buffers; }
258
259 Info()
260 : width(0), height(0), flags(0), num_static_views(0),
261 num_static_buffers(0) {}
262 };
263
271 L4_INLINE_RPC(long, info, (Info *info));
272
281 L4_RPC(long, get_static_buffer, (unsigned idx,
283
292 L4_RPC(long, create_buffer, (unsigned long size,
294
302 L4_INLINE_RPC(long, delete_buffer, (unsigned idx));
303
304 // Use a wrapper for this RPC as we enacapsulate the View
305 L4_INLINE_RPC_NF(long, create_view, ());
306
315 int create_view(View *view, l4_utcb_t *utcb = l4_utcb()) const noexcept
316 {
317 long r = create_view_t::call(c(), utcb);
318 if (r < 0)
319 return r;
320 *view = View(cap(), r);
321 return r;
322 }
323
324 // Use a wrapper as Views are encapsulated
325 L4_INLINE_RPC_NF(long, delete_view, (unsigned index));
326
335 int delete_view(View const &v, l4_utcb_t *utcb = l4_utcb()) const noexcept
336 {
337 return delete_view_t::call(c(), v._view_idx, utcb);
338 }
339
345 View view(unsigned index) const noexcept;
346
350 L4_INLINE_RPC(long, refresh, (int x, int y, int w, int h));
351
352 // those are used by the View
353 L4_INLINE_RPC(long, view_info, (unsigned index, View::Info *info));
354 L4_INLINE_RPC(long, set_view_info, (unsigned index, View::Info const &info));
355 L4_INLINE_RPC(long, view_stack, (unsigned index, unsigned pivit, bool behind));
356 L4_INLINE_RPC(long, view_refresh, (unsigned index, int x, int y, int w, int h));
357
358 typedef L4::Typeid::Rpcs<
359 info_t, get_static_buffer_t, create_buffer_t, create_view_t, delete_buffer_t,
360 delete_view_t, view_info_t, set_view_info_t, view_stack_t, view_refresh_t,
361 refresh_t
362 > Rpcs;
363};
364
365inline View
366Goos::view(unsigned index) const noexcept
367{ return View(cap(), index); }
368
369inline int
370View::info(Info *info) const noexcept
371{ return _goos->view_info(_view_idx, info); }
372
373inline int
374View::set_info(Info const &info) const noexcept
375{ return _goos->set_view_info(_view_idx, info); }
376
377inline int
378View::stack(View const &pivot, bool behind) const noexcept
379{ return _goos->view_stack(_view_idx, pivot._view_idx, behind); }
380
381inline int
382View::refresh(int x, int y, int w, int h) const noexcept
383{ return _goos->view_refresh(_view_idx, x, y, w, h); }
384
385inline int
386View::set_viewport(int scr_x, int scr_y, int w, int h,
387 unsigned long buf_offset) const noexcept
388{
389 Info i;
390 i.flags = F_set_buffer_offset | F_set_position;
391 i.buffer_offset = buf_offset;
392 i.buffer_index = 0;
393 i.view_index = 0;
394 i.bytes_per_line = 0;
396 i.xpos = scr_x;
397 i.ypos = scr_y;
398 i.width = w;
399 i.height = h;
400 return set_info(i);
401}
402
403}}
L4::Cap related definitions.
Class that abstracts framebuffers.
Definition goos:228
Flags
Flags for a Goos.
Definition goos:232
int create_view(View *view, l4_utcb_t *utcb=l4_utcb()) const noexcept
Create a view.
Definition goos:315
View view(unsigned index) const noexcept
Return a view.
Definition goos:366
int delete_view(View const &v, l4_utcb_t *utcb=l4_utcb()) const noexcept
Delete a view.
Definition goos:335
Pixel information.
Definition colors:108
void dump(OUT &s) const
Dump information on the pixel to a stream.
Definition colors:260
View of a framebuffer.
Definition goos:43
int set_info(Info const &info) const noexcept
Set the information structure for this view.
Definition goos:374
V_flags
Property flags of a view.
Definition goos:86
int push_bottom() const noexcept
Push this view the back.
Definition goos:192
int info(Info *info) const noexcept
Return the view information of the view.
Definition goos:370
bool valid() const
Return whether this view is valid.
Definition goos:208
Flags
Flags on a view.
Definition goos:63
int set_viewport(int scr_x, int scr_y, int w, int h, unsigned long buf_offset) const noexcept
Set the position of the view in the Goos.
Definition goos:386
int refresh(int x, int y, int w, int h) const noexcept
Refresh/Redraw the view.
Definition goos:382
int stack(View const &pivot, bool behind=true) const noexcept
Move this view in the view stack.
Definition goos:378
bool is_valid() const noexcept
Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP).
Definition capability.h:60
C++ interface for capabilities.
Definition capability.h:222
Helper class to create an L4Re interface class that is derived from a single base class.
Definition __typeinfo.h:760
Dataspace interface.
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:358
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:67
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:340
#define L4_EXPORT
Attribute to mark functions, variables, and data types as being exported from a library.
Definition compiler.h:221
Interface Definition Language.
#define L4_INLINE_RPC(res, name, args, attr...)
Define an inline RPC call (type and callable).
Definition ipc_iface:469
#define L4_RPC(res, name, args, attr...)
Define an RPC call (type and callable).
Definition ipc_iface:528
#define L4_INLINE_RPC_NF(res, name, args...)
Define an inline RPC call type (the type only, no callable).
Definition ipc_iface:440
L4Re C++ Interfaces.
Definition cmd_control:15
Information structure of a Goos.
Definition goos:241
bool auto_refresh() const
Return whether this Goos does auto refreshing or the view refresh functions must be used to make chan...
Definition goos:251
unsigned long height
Height.
Definition goos:243
unsigned long width
Width.
Definition goos:242
Pixel_info pixel_info
Pixel information.
Definition goos:247
bool has_dynamic_buffers() const
Return whether dynamic buffers are supported.
Definition goos:257
bool has_pointer() const
Return whether a pointer is used by the provider of the Goos.
Definition goos:253
bool has_dynamic_views() const
Return whether dynamic view are supported.
Definition goos:255
unsigned flags
Flags, see Flags.
Definition goos:244
unsigned num_static_buffers
Number of static buffers.
Definition goos:246
unsigned num_static_views
Number of static view.
Definition goos:245
Information structure of a view.
Definition goos:95
Pixel_info pixel_info
Pixel information.
Definition goos:105
unsigned long height
Height of the view in pixels.
Definition goos:102
unsigned long width
Width of the view in pixels.
Definition goos:101
bool has_set_buffer() const
Return whether a buffer is set.
Definition goos:114
unsigned buffer_index
Number of the buffer used for this view.
Definition goos:106
unsigned long xpos
X position in pixels of the view in the Goos.
Definition goos:99
unsigned view_index
Index of the view.
Definition goos:97
unsigned long buffer_offset
Offset in the memory buffer in bytes.
Definition goos:103
bool has_set_pixel() const
Return whether the given pixel information is valid.
Definition goos:120
unsigned long bytes_per_line
Bytes per line.
Definition goos:104
bool has_static_buffer() const
Return whether the view has a static buffer.
Definition goos:109
void dump(OUT &s) const
Dump information on the view information to a stream.
Definition goos:126
bool has_set_buffer_offset() const
Return whether the given buffer offset is valid.
Definition goos:116
unsigned long ypos
Y position in pixels of the view in the Goos.
Definition goos:100
bool has_set_bytes_per_line() const
Return whether the given bytes-per-line value is valid.
Definition goos:118
unsigned flags
Flags, see Flags and V_flags.
Definition goos:96
bool has_static_buffer_offset() const
Return whether the static buffer offset is available.
Definition goos:111
bool has_set_position() const
Return whether the position information given is valid.
Definition goos:122
Mark an argument as a output value in an RPC signature.
Definition ipc_types:42
Standard list of RPCs of an interface.
Definition __typeinfo.h:438