Loading...
Searching...
No Matches
env.h
Go to the documentation of this file.
/*
* (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <l4/sys/consts.h>
#include <l4/sys/types.h>
#include <l4/sys/kip.h>
#include <l4/sys/compiler.h>
#include <l4/re/consts.h>
typedef struct l4re_env_cap_entry_t
{
l4_cap_idx_t cap;
l4_umword_t flags;
char name[16];
#ifdef __cplusplus
l4re_env_cap_entry_t() L4_NOTHROW : cap(L4_INVALID_CAP), flags(~0UL) {}
l4re_env_cap_entry_t(char const *n, l4_cap_idx_t c, l4_umword_t f = 0) L4_NOTHROW
: cap(c), flags(f)
{
for (unsigned i = 0; n && i < sizeof(name); ++i, ++n)
{
name[i] = *n;
if (!*n)
break;
}
}
static bool is_valid_name(char const *n) L4_NOTHROW
{
for (unsigned i = 0; *n; ++i, ++n)
if (i > sizeof(name))
return false;
return true;
}
#endif
} l4re_env_cap_entry_t;
typedef struct l4re_env_t
{
l4_cap_idx_t parent;
l4_cap_idx_t rm;
l4_cap_idx_t mem_alloc;
l4_cap_idx_t log;
l4_cap_idx_t main_thread;
l4_cap_idx_t factory;
l4_cap_idx_t scheduler;
l4_cap_idx_t itas;
l4_cap_idx_t dbg_events;
l4_cap_idx_t first_free_cap;
l4_fpage_t utcb_area;
l4_addr_t first_free_utcb;
l4re_env_cap_entry_t *caps;
} l4re_env_t;
extern l4re_env_t *l4re_global_env;
L4_INLINE l4re_env_t *l4re_env(void) L4_NOTHROW;
/*
* FIXME: this seems to be at the wrong place here
*/
L4_INLINE l4_kernel_info_t const *l4re_kip(void) L4_NOTHROW;
L4_INLINE l4_cap_idx_t
l4re_env_get_cap(char const *name) L4_NOTHROW;
L4_INLINE l4_cap_idx_t
l4re_env_get_cap_e(char const *name, l4re_env_t const *e) L4_NOTHROW;
L4_INLINE l4re_env_cap_entry_t const *
l4re_env_get_cap_l(char const *name, unsigned l, l4re_env_t const *e) L4_NOTHROW;
L4_INLINE
l4re_env_t *l4re_env(void) L4_NOTHROW
{ return l4re_global_env; }
L4_INLINE
l4_kernel_info_t const *l4re_kip(void) L4_NOTHROW
{ return l4_kip(); }
L4_INLINE l4re_env_cap_entry_t const *
l4re_env_get_cap_l(char const *name, unsigned l, l4re_env_t const *e) L4_NOTHROW
{
l4re_env_cap_entry_t const *c = e->caps;
for (; c && c->flags != ~0UL; ++c)
{
unsigned i;
for (i = 0;
i < sizeof(c->name) && i < l && c->name[i] && name[i] && name[i] == c->name[i];
++i)
;
if (i == l && (i == sizeof(c->name) || !c->name[i]))
return c;
}
return NULL;
}
L4_INLINE l4_cap_idx_t
l4re_env_get_cap_e(char const *name, l4re_env_t const *e) L4_NOTHROW
{
unsigned l;
l4re_env_cap_entry_t const *r;
for (l = 0; name[l]; ++l) ;
r = l4re_env_get_cap_l(name, l, e);
if (r)
return r->cap;
return L4_INVALID_CAP;
}
L4_INLINE l4_cap_idx_t
l4re_env_get_cap(char const *name) L4_NOTHROW
{ return l4re_env_get_cap_e(name, l4re_env()); }
compiler.h
L4 compiler related defines.
l4re_env_get_cap
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:220
l4re_env_get_cap_e
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:207
l4re_kip
l4_kernel_info_t const * l4re_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition env.h:185
l4re_env
l4re_env_t * l4re_env(void) L4_NOTHROW
Get L4Re initial environment.
Definition env.h:181
l4re_env_get_cap_l
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:189
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_addr_t
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
l4_cap_idx_t
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:336
L4_INVALID_CAP
@ L4_INVALID_CAP
Invalid capability selector.
Definition consts.h:153
l4_kip
l4_kernel_info_t const * l4_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition kip.h:226
L4_NOTHROW
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:161
L4_INLINE
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
consts.h
Constants.
consts.h
Common constants.
types.h
Common L4 ABI Data Types.
l4_kernel_info_t
L4 Kernel Interface Page.
Definition kip.h:37
l4re_env_cap_entry_t
Entry in the L4Re environment array for the named initial objects.
Definition env.h:40
l4re_env_cap_entry_t::l4re_env_cap_entry_t
l4re_env_cap_entry_t() L4_NOTHROW
Create an invalid entry.
Definition env.h:61
l4re_env_cap_entry_t::cap
l4_cap_idx_t cap
The capability selector for the object.
Definition env.h:44
l4re_env_cap_entry_t::name
char name[16]
The name of the object.
Definition env.h:55
l4re_env_cap_entry_t::l4re_env_cap_entry_t
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:70
l4re_env_cap_entry_t::flags
l4_umword_t flags
Flags for the object.
Definition env.h:50
l4re_env_t
Initial environment data structure.
Definition env.h:99
l4re_env_t::factory
l4_cap_idx_t factory
Object-capability of the factory available to the task.
Definition env.h:105
l4re_env_t::mem_alloc
l4_cap_idx_t mem_alloc
Memory allocator object-capability.
Definition env.h:102
l4re_env_t::scheduler
l4_cap_idx_t scheduler
Object capability for the scheduler set to use.
Definition env.h:106
l4re_env_t::rm
l4_cap_idx_t rm
Region map object-capability.
Definition env.h:101
l4re_env_t::first_free_utcb
l4_addr_t first_free_utcb
First UTCB within the UTCB area available to the application.
Definition env.h:111
l4re_env_t::first_free_cap
l4_cap_idx_t first_free_cap
First capability index available to the application.
Definition env.h:109
l4re_env_t::itas
l4_cap_idx_t itas
ITAS services object-capability.
Definition env.h:107
l4re_env_t::dbg_events
l4_cap_idx_t dbg_events
Object-capability of the debug events service.
Definition env.h:108
l4re_env_t::caps
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:117
l4re_env_t::main_thread
l4_cap_idx_t main_thread
Object-capability of the first user thread.
Definition env.h:104
l4re_env_t::utcb_area
l4_fpage_t utcb_area
UTCB area of the task.
Definition env.h:110
l4re_env_t::parent
l4_cap_idx_t parent
Parent object-capability.
Definition env.h:100
l4re_env_t::log
l4_cap_idx_t log
Logging object-capability.
Definition env.h:103
kip.h
Kernel Info Page access functions.
l4_fpage_t
L4 flexpage type.
Definition __l4_fpage.h:76