1
/*
2
* \brief Environment of a component
3
* \author Norman Feske
4
* \date 2006-07-01
5
*/
6
7
/*
8
* Copyright (C) 2006-2013 Genode Labs GmbH
9
*
10
* This file is part of the Genode OS framework, which is distributed
11
* under the terms of the GNU General Public License version 2.
12
*/
13
14
#
ifndef _INCLUDE__BASE__ENV_H_
15
#
define _INCLUDE__BASE__ENV_H_
16
17
#
include <parent/capability.h>
18
#
include <parent/parent.h>
19
#
include <rm_session/capability.h>
20
#
include <rm_session/rm_session.h>
21
#
include <ram_session/ram_session.h>
22
#
include <cpu_session/cpu_session.h>
23
#
include <cpu_session/capability.h>
24
#
include <pd_session/capability.h>
25
#
include <cap_session/cap_session.h>
26
#
include <base/allocator.h>
27
#
include <base/snprintf.h>
28
#
include <base/lock.h>
29
30
namespace
Genode {
31
32
struct
Env;
33
34
/**
35
* Return the interface to the component`s environment
36
*/
37
extern
Env *
env(
)
;
38
}
39
40
41
/**
42
* Component runtime environment
43
*
44
* The environment of a Genode component is defined by its parent. The `Env`
45
* class allows the component to interact with its environment. It is
46
* initialized at the startup of the component.
47
*/
48
struct
Genode::
Env
49
{
50
virtual
~
Env(
)
{
}
51
52
/**
53
* Communication channel to our parent
54
*/
55
virtual
Parent *
parent(
)
=
0
;
56
57
/**
58
* RAM session of the component
59
*
60
* The RAM Session represents a budget of memory (quota) that is
61
* available to the component. This budget can be used to allocate
62
* RAM dataspaces.
63
*/
64
virtual
Ram_session *
ram_session(
)
=
0
;
65
virtual
Ram_session_capability
ram_session_cap(
)
=
0
;
66
67
/**
68
* CPU session of the component
69
*
70
* This session is used to create the threads of the component.
71
*/
72
virtual
Cpu_session *
cpu_session(
)
=
0
;
73
virtual
Cpu_session_capability
cpu_session_cap(
)
=
0
;
74
75
/**
76
* Region-manager session of the component as created by the parent
77
*/
78
virtual
Rm_session *
rm_session(
)
=
0
;
79
80
/**
81
* PD session of the component as created by the parent
82
*/
83
virtual
Pd_session *
pd_session(
)
=
0
;
84
virtual
Pd_session_capability
pd_session_cap(
)
=
0
;
85
86
/**
87
* Heap backed by the RAM session of the environment
88
*/
89
virtual
Allocator *
heap(
)
=
0
;
90
91
/**
92
* Reload parent capability and reinitialize environment resources
93
*
94
* This function is solely used for implementing fork semantics.
95
* After forking a process, the new child process is executed
96
* within a copy of the address space of the forking process.
97
* Thereby, the new process inherits the original `env` object of
98
* the forking process, which is meaningless in the context of the
99
* new process. By calling this function, the new process is able
100
* to reinitialize its `env` with meaningful capabilities obtained
101
* via its updated parent capability.
102
*
103
* \noapi
104
*/
105
virtual
void
reinit(
Native_capability::
Dst
,
long
)
=
0
;
106
107
/**
108
* Reinitialize main-thread object
109
*
110
* \param stack_area_rm new RM session of the context area
111
*
112
* This function is solely used for implementing fork semantics
113
* as provided by the Noux environment.
114
*
115
* \noapi
116
*/
117
virtual
void
reinit_main_thread(
Rm_session_capability &
stack_area_rm
)
=
0
;
118
119
}
;
120
121
#
endif /* _INCLUDE__BASE__ENV_H_ */