L4Re – L4 Runtime Environment
dataspace
Go to the documentation of this file.
1 // -*- Mode: C++ -*-
2 // vim:ft=cpp
7 /*
8  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
9  * Alexander Warg <warg@os.inf.tu-dresden.de>,
10  * Björn Döbel <doebel@os.inf.tu-dresden.de>,
11  * Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
12  * economic rights: Technische Universität Dresden (Germany)
13  *
14  * This file is part of TUD:OS and distributed under the terms of the
15  * GNU General Public License 2.
16  * Please see the COPYING-GPL-2 file for details.
17  *
18  * As a special exception, you may use this file as part of a free software
19  * library without restriction. Specifically, if other files instantiate
20  * templates or use macros or inline functions from this file, or you compile
21  * this file and link it with other files to produce an executable, this
22  * file does not by itself cause the resulting executable to be covered by
23  * the GNU General Public License. This exception does not however
24  * invalidate any other reasons why the executable file might be covered by
25  * the GNU General Public License.
26  */
27 
28 #pragma once
29 
30 #include <l4/sys/types.h>
31 #include <l4/sys/l4int.h>
32 #include <l4/sys/capability>
33 #include <l4/re/protocols.h>
34 #include <l4/sys/cxx/ipc_types>
35 #include <l4/sys/cxx/ipc_iface>
36 #include <l4/sys/cxx/types>
37 
38 namespace L4Re
39 {
40 
41  // MISSING:
42  // * size support in map, mapped size in reply
43 
60 class L4_EXPORT Dataspace :
61  public L4::Kobject_t<Dataspace, L4::Kobject, L4RE_PROTO_DATASPACE,
62  L4::Type_info::Demand_t<1> >
63 {
64 public:
65 
67  struct F
68  {
69  enum
70  {
71  Caching_shift = 4,
72  };
73 
77  enum Flags
78  {
87  X = L4_FPAGE_X,
88  RX = L4_FPAGE_RX,
89  RWX = L4_FPAGE_RWX,
91  Rights_mask = 0x0f,
92 
94  Normal = 0x00,
96  Cacheable = Normal,
98  Bufferable = 0x10,
100  Uncacheable = 0x20,
102  Caching_mask = 0x30,
103  };
104 
105  L4_TYPES_FLAGS_OPS_DEF(Flags);
106  };
107 
108  struct Flags : L4::Types::Flags_ops_t<Flags>
109  {
110  unsigned long raw;
111  Flags() = default;
112  explicit constexpr Flags(unsigned long f) : raw(f) {}
113  constexpr Flags(F::Flags f) : raw(f) {}
114  constexpr bool r() const { return raw & L4_FPAGE_RO; }
115  constexpr bool w() const { return raw & L4_FPAGE_W; }
116  constexpr bool x() const { return raw & L4_FPAGE_X; }
117 
118  constexpr unsigned long fpage_rights() const
119  { return raw & 0xf; }
120  };
121 
122  typedef l4_uint64_t Size;
123  typedef l4_uint64_t Offset;
124  typedef l4_uint64_t Map_addr;
125 
129  struct Stats
130  {
131  Size size;
132  Flags flags;
133  };
134 
135 
158  long map(Offset offset, Flags flags, Map_addr local_addr,
159  Map_addr min_addr, Map_addr max_addr) const noexcept;
160 
186  long map_region(Offset offset, Flags flags,
187  Map_addr min_addr, Map_addr max_addr) const noexcept;
188 
206  L4_RPC(long, clear, (Offset offset, Size size));
207 
227  L4_RPC(long, allocate, (Offset offset, Size size));
228 
246  L4_RPC(long, copy_in, (Offset dst_offs, L4::Ipc::Cap<Dataspace> src,
247  Offset src_offs, Size size));
248 
254  Size size() const noexcept;
255 
264  Flags flags() const noexcept;
265 
274  L4_RPC(long, info, (Stats *stats));
275 
276  L4_RPC_NF(long, map, (Offset offset, Map_addr spot,
277  Flags flags, L4::Ipc::Rcv_fpage r,
278  L4::Ipc::Snd_fpage &fp));
279 
280 private:
281 
282  long __map(Offset offset, unsigned char *order, Flags flags,
283  Map_addr local_addr) const noexcept;
284 
285 public:
286  typedef L4::Typeid::Rpcs<map_t, clear_t, info_t, copy_in_t,
287  allocate_t> Rpcs;
288 
289 };
290 
291 }
292 
L4::Cap related definitions.
Interface for memory-like objects.
Definition: dataspace:63
Capability type for RPC interfaces (see L4::Cap<T>).
Definition: ipc_types:542
Helper class to create an L4Re interface class that is derived from a single base class.
Definition: __typeinfo.h:760
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition: l4int.h:42
@ L4_FPAGE_X
Executable flex page.
Definition: __l4_fpage.h:111
@ L4_FPAGE_RWX
Read-write-execute flex page.
Definition: __l4_fpage.h:116
@ L4_FPAGE_RX
Read-execute flex page.
Definition: __l4_fpage.h:115
@ L4_FPAGE_RO
Read-only flex page
Definition: __l4_fpage.h:113
@ L4_FPAGE_RW
Read-write flex page.
Definition: __l4_fpage.h:114
@ L4_FPAGE_W
Writable flex page.
Definition: __l4_fpage.h:112
Interface Definition Language.
#define L4_RPC(res, name, args, attr...)
Define an RPC call (type and callable).
Definition: ipc_iface:528
#define L4_RPC_NF(res, name, args...)
Define an RPC call type (the type only, no callable).
Definition: ipc_iface:497
Common L4 ABI Data Types.
L4Re C++ Interfaces.
Definition: cmd_control:15
Gen_fpage< Snd_item > Snd_fpage
Send flex-page.
Definition: ipc_types:477
Gen_fpage< Buf_item > Rcv_fpage
Rcv flex-page.
Definition: ipc_types:479
L4 low-level kernel interface.
L4Re Protocol Constants (C version)
Dataspace flags definitions.
Definition: dataspace:68
Flags
Flags for map operations.
Definition: dataspace:78
Information about the dataspace.
Definition: dataspace:130
Flags flags
flags
Definition: dataspace:132
Standard list of RPCs of an interface.
Definition: __typeinfo.h:438
Mixin class to define a set of friend bitwise operators on DT.
Definition: types:233
#define L4_TYPES_FLAGS_OPS_DEF(T)
Helper macro to define a set of bitwise operators on an enum type.
Definition: types:207