L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
env.h
Go to the documentation of this file.
1
5/*
6 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7 * Alexander Warg <warg@os.inf.tu-dresden.de>
8 * economic rights: Technische Universität Dresden (Germany)
9 *
10 * License: see LICENSE.spdx (in this directory or the directories above)
11 */
12#pragma once
13
14#include <l4/sys/consts.h>
15#include <l4/sys/types.h>
16#include <l4/sys/kip.h>
17#include <l4/sys/compiler.h>
18
19#include <l4/re/consts.h>
20
21#ifdef __cplusplus
22#include <l4/cxx/string>
23#endif
24
38
44{
49
55
59 char name[16];
60#ifdef __cplusplus
61
66
75 : cap(c), flags(f)
76 {
77 for (unsigned i = 0; n && i < sizeof(name); ++i, ++n)
78 {
79 name[i] = *n;
80 if (!*n)
81 break;
82 }
83 }
84
85 static bool is_valid_name(char const *n) L4_NOTHROW
86 {
87 for (unsigned i = 0; *n; ++i, ++n)
88 if (i > sizeof(name))
89 return false;
90
91 return true;
92 }
93
94 cxx::String get_name() const noexcept
95 {
96 unsigned len = 0;
97 while (len < sizeof(name) && name[len] != '\0')
98 ++len;
99
100 return cxx::String(name, len);
101 }
102
103 explicit operator bool() const noexcept
104 { return flags != ~0UL; }
105#endif
107
108
136
142extern l4re_env_t *l4re_global_env;
143
144
151
152/*
153 * FIXME: this seems to be at the wrong place here
154 */
161
162
171l4re_env_get_cap(char const *name) L4_NOTHROW;
172
182l4re_env_get_cap_e(char const *name, l4re_env_t const *e) L4_NOTHROW;
183
195l4re_env_get_cap_l(char const *name, unsigned l, l4re_env_t const *e) L4_NOTHROW;
196
199{ return l4re_global_env; }
200
203{ return l4_kip(); }
204
206l4re_env_get_cap_l(char const *name, unsigned l, l4re_env_t const *e) L4_NOTHROW
207{
208 l4re_env_cap_entry_t const *c = e->caps;
209 for (; c && c->flags != ~0UL; ++c)
210 {
211 unsigned i;
212 for (i = 0;
213 i < sizeof(c->name) && i < l && c->name[i] && name[i] && name[i] == c->name[i];
214 ++i)
215 ;
216
217 if (i == l && (i == sizeof(c->name) || !c->name[i]))
218 return c;
219 }
220 return NULL;
221}
222
224l4re_env_get_cap_e(char const *name, l4re_env_t const *e) L4_NOTHROW
225{
226 unsigned l;
227 l4re_env_cap_entry_t const *r;
228 for (l = 0; name[l]; ++l) ;
229 r = l4re_env_get_cap_l(name, l, e);
230 if (r)
231 return r->cap;
232
233 return L4_INVALID_CAP;
234}
235
238{ return l4re_env_get_cap_e(name, l4re_env()); }
239
L4 compiler related defines.
l4_cap_idx_t l4re_env_get_cap(char const *name) L4_NOTHROW
Get the capability selector for the object named name.
Definition env.h:237
l4_cap_idx_t l4re_env_get_cap_e(char const *name, l4re_env_t const *e) L4_NOTHROW
Get the capability selector for the object named name.
Definition env.h:224
l4_kernel_info_t const * l4re_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition env.h:202
l4re_env_t * l4re_env(void) L4_NOTHROW
Get L4Re initial environment.
Definition env.h:198
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:206
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:372
#define L4_INVALID_CAP
Invalid capability selector; see l4_cap_idx_t.
Definition consts.h:165
l4_kernel_info_t const * l4_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition kip.h:226
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:167
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
Constants.
Common constants.
Kernel Info Page access functions.
Common L4 ABI Data Types.
L4 Kernel Interface Page.
Definition kip.h:37
Entry in the L4Re environment array for the named initial objects.
Definition env.h:44
l4re_env_cap_entry_t() L4_NOTHROW
Create an invalid entry.
Definition env.h:65
l4_cap_idx_t cap
The capability selector for the object.
Definition env.h:48
char name[16]
The name of the object.
Definition env.h:59
l4re_env_cap_entry_t(char const *n, l4_cap_idx_t c, l4_umword_t f=0) L4_NOTHROW
Create an entry with the name n, capability c, and flags f.
Definition env.h:74
l4_umword_t flags
Flags for the object.
Definition env.h:54
Initial environment data structure.
Definition env.h:115
l4_cap_idx_t factory
Object-capability of the factory available to the task.
Definition env.h:121
l4_umword_t first_free_reply_cap
First reply capability index available to the application.
Definition env.h:126
l4_cap_idx_t mem_alloc
Memory allocator object-capability.
Definition env.h:118
l4_cap_idx_t scheduler
Object capability for the scheduler set to use.
Definition env.h:122
l4_cap_idx_t rm
Region map object-capability.
Definition env.h:117
l4_addr_t first_free_utcb
First UTCB within the UTCB area available to the application.
Definition env.h:128
l4_cap_idx_t first_free_cap
First capability index available to the application.
Definition env.h:125
l4_cap_idx_t itas
ITAS services object-capability.
Definition env.h:123
l4_cap_idx_t dbg_events
Object-capability of the debug events service.
Definition env.h:124
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:134
l4_cap_idx_t main_thread
Object-capability of the first user thread.
Definition env.h:120
l4_fpage_t utcb_area
UTCB area of the task.
Definition env.h:127
l4_cap_idx_t parent
Parent object-capability.
Definition env.h:116
l4_cap_idx_t log
Logging object-capability.
Definition env.h:119
L4 flexpage type.
Definition __l4_fpage.h:76