L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
env
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 * economic rights: Technische Universität Dresden (Germany)
12 *
13 * License: see LICENSE.spdx (in this directory or the directories above)
14 */
15#pragma once
16
17#include <l4/sys/types.h>
18
19#include <l4/re/rm>
20#include <l4/re/parent>
21#include <l4/re/mem_alloc>
22#include <l4/re/log>
23#include <l4/re/consts>
24
25#include <l4/re/env.h>
26
27namespace L4 {
28class Scheduler;
29}
30
34namespace L4Re
35{
36 class Itas;
37
78 {
79 private:
80 l4re_env_t _env;
81 public:
82
87
95 static Env const *env() noexcept
96 { return reinterpret_cast<Env*>(l4re_global_env); }
97
102 L4::Cap<Parent> parent() const noexcept
103 { return L4::Cap<Parent>(_env.parent); }
109 { return L4::Cap<Mem_alloc>(_env.mem_alloc); }
114 { return L4::Cap<L4::Factory>(_env.mem_alloc); }
119 L4::Cap<Rm> rm() const noexcept
120 { return L4::Cap<Rm>(_env.rm); }
125 L4::Cap<Log> log() const noexcept
126 { return L4::Cap<Log>(_env.log); }
132 { return L4::Cap<L4::Thread>(_env.main_thread); }
137 L4::Cap<L4::Task> task() const noexcept
138 { return L4::Cap<L4::Task>(L4RE_THIS_TASK_CAP); }
144 { return L4::Cap<L4::Factory>(_env.factory); }
152 { return _env.first_free_cap; }
157 l4_fpage_t utcb_area() const noexcept
158 { return _env.utcb_area; }
166 l4_addr_t first_free_utcb() const noexcept
167 { return _env.first_free_utcb; }
168
173 Cap_entry const *initial_caps() const noexcept
174 { return _env.caps; }
175
184 Cap_entry const *get(char const *name, unsigned l) const noexcept
185 { return l4re_env_get_cap_l(name, l, &_env); }
186
195 template< typename T >
196 L4::Cap<T> get_cap(char const *name, unsigned l) const noexcept
197 {
198 if (Cap_entry const *e = get(name, l))
199 return L4::Cap<T>(e->cap);
200
201 return L4::Cap<T>(-L4_ENOENT);
202 }
203
210 template< typename T >
211 L4::Cap<T> get_cap(char const *name) const noexcept
212 { return get_cap<T>(name, __builtin_strlen(name)); }
213
218 void parent(L4::Cap<Parent> const &c) noexcept
219 { _env.parent = c.cap(); }
224 void mem_alloc(L4::Cap<Mem_alloc> const &c) noexcept
225 { _env.mem_alloc = c.cap(); }
230 void rm(L4::Cap<Rm> const &c) noexcept
231 { _env.rm = c.cap(); }
236 void log(L4::Cap<Log> const &c) noexcept
237 { _env.log = c.cap(); }
242 void main_thread(L4::Cap<L4::Thread> const &c) noexcept
243 { _env.main_thread = c.cap(); }
248 void factory(L4::Cap<L4::Factory> const &c) noexcept
249 { _env.factory = c.cap(); }
255 { _env.first_free_cap = c; }
260 void utcb_area(l4_fpage_t utcbs) noexcept
261 { _env.utcb_area = utcbs; }
266 void first_free_utcb(l4_addr_t u) noexcept
267 { _env.first_free_utcb = u; }
268
275 { return L4::Cap<L4::Scheduler>(_env.scheduler); }
276
281 void scheduler(L4::Cap<L4::Scheduler> const &c) noexcept
282 { _env.scheduler = c.cap(); }
283
293 L4::Cap<Itas> itas() const noexcept
294 { return L4::Cap<Itas>(_env.itas); }
295
300 void itas(L4::Cap<Itas> const &c) noexcept
301 { _env.itas = c.cap(); }
302
307 void initial_caps(Cap_entry *first) noexcept
308 { _env.caps = first; }
309 };
310};
C++ interface of the initial environment that is provided to an L4 task.
Definition env:78
L4::Cap< L4::Scheduler > scheduler() const noexcept
Get the scheduler capability for the task.
Definition env:274
void first_free_cap(l4_cap_idx_t c) noexcept
Set first available capability selector.
Definition env:254
Cap_entry const * get(char const *name, unsigned l) const noexcept
Get the Cap_entry for the object named name.
Definition env:184
static Env const * env() noexcept
Returns the initial environment for the current task.
Definition env:95
l4_cap_idx_t first_free_cap() const noexcept
First available capability selector.
Definition env:151
void scheduler(L4::Cap< L4::Scheduler > const &c) noexcept
Set the scheduler capability.
Definition env:281
L4::Cap< L4::Factory > factory() const noexcept
Object-capability to the factory object available to the task.
Definition env:143
L4::Cap< Mem_alloc > mem_alloc() const noexcept
Object-capability to the memory allocator.
Definition env:108
L4::Cap< L4::Factory > user_factory() const noexcept
Object-capability to the user-level object factory.
Definition env:113
void log(L4::Cap< Log > const &c) noexcept
Set log object-capability.
Definition env:236
L4::Cap< L4::Thread > main_thread() const noexcept
Object-capability of the first user thread.
Definition env:131
void mem_alloc(L4::Cap< Mem_alloc > const &c) noexcept
Set memory allocator object-capability.
Definition env:224
void factory(L4::Cap< L4::Factory > const &c) noexcept
Set factory object-capability.
Definition env:248
L4::Cap< T > get_cap(char const *name) const noexcept
Get the capability selector for the object named name.
Definition env:211
l4re_env_cap_entry_t Cap_entry
C++ type for an entry in the initial objects array.
Definition env:86
Cap_entry const * initial_caps() const noexcept
Get a pointer to the first entry in the initial objects array.
Definition env:173
L4::Cap< Log > log() const noexcept
Object-capability to the logging service.
Definition env:125
void utcb_area(l4_fpage_t utcbs) noexcept
Set UTCB area of the task.
Definition env:260
void first_free_utcb(l4_addr_t u) noexcept
Set first free UTCB.
Definition env:266
L4::Cap< Rm > rm() const noexcept
Object-capability to the region map.
Definition env:119
void initial_caps(Cap_entry *first) noexcept
Set the pointer to the first Cap_entry in the initial objects array.
Definition env:307
L4::Cap< T > get_cap(char const *name, unsigned l) const noexcept
Get the capability selector for the object named name.
Definition env:196
L4::Cap< Itas > itas() const noexcept
Object-capability to the ITAS services.
Definition env:293
void rm(L4::Cap< Rm > const &c) noexcept
Set region map object-capability.
Definition env:230
l4_addr_t first_free_utcb() const noexcept
First free UTCB.
Definition env:166
L4::Cap< Parent > parent() const noexcept
Object-capability to the parent.
Definition env:102
void itas(L4::Cap< Itas > const &c) noexcept
Set the ITAS capability.
Definition env:300
l4_fpage_t utcb_area() const noexcept
UTCB area of the task.
Definition env:157
void main_thread(L4::Cap< L4::Thread > const &c) noexcept
Set object-capability of first user thread.
Definition env:242
void parent(L4::Cap< Parent > const &c) noexcept
Set parent object-capability.
Definition env:218
L4::Cap< L4::Task > task() const noexcept
Object-capability of the user task.
Definition env:137
C++ interface for capabilities.
Definition capability.h:219
Environment interface.
l4re_env_cap_entry_t const * l4re_env_get_cap_l(char const *name, unsigned l, l4re_env_t const *e) L4_NOTHROW
Get the full l4re_env_cap_entry_t for the object named name.
Definition env.h:188
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:335
@ L4_ENOENT
No such entity.
Definition err.h:34
#define L4_EXPORT
Attribute to mark functions, variables, and data types as being exported from a library.
Definition compiler.h:210
Common L4 ABI Data Types.
Log interface.
Memory allocator interface.
L4Re C++ Interfaces.
Definition cmd_control:14
L4 low-level kernel interface.
Parent interface.
Constants.
Region mapper interface.
Entry in the L4Re environment array for the named inital objects.
Definition env.h:40
Initial environment data structure.
Definition env.h:99
l4_cap_idx_t factory
Object-capability of the factory available to the task.
Definition env.h:105
l4_cap_idx_t mem_alloc
Memory allocator object-capability.
Definition env.h:102
l4_cap_idx_t scheduler
Object capability for the scheduler set to use.
Definition env.h:106
l4_cap_idx_t rm
Region map object-capability.
Definition env.h:101
l4_addr_t first_free_utcb
First UTCB within the UTCB area available to the application.
Definition env.h:110
l4_cap_idx_t first_free_cap
First capability index available to the application.
Definition env.h:108
l4_cap_idx_t itas
ITAS services object-capability.
Definition env.h:107
l4re_env_cap_entry_t * caps
Pointer to the first entry in the initial objects array which contains l4re_env_cap_entry_t elements.
Definition env.h:116
l4_cap_idx_t main_thread
Object-capability of the first user thread.
Definition env.h:104
l4_fpage_t utcb_area
UTCB area of the task.
Definition env.h:109
l4_cap_idx_t parent
Parent object-capability.
Definition env.h:100
l4_cap_idx_t log
Logging object-capability.
Definition env.h:103
L4 flexpage type.
Definition __l4_fpage.h:76