diff --git a/base-foc/lib/mk/env.mk b/base-foc/lib/mk/env.mk index 8ea646747..09b9d721d 100644 --- a/base-foc/lib/mk/env.mk +++ b/base-foc/lib/mk/env.mk @@ -2,6 +2,7 @@ SRC_CC = env.cc context_area.cc cap_map.cc cap_alloc.cc \ reload_parent_cap.cc spin_lock.cc cap_map_remove.cc LIBS = ipc heap log_console lock INC_DIR += $(REP_DIR)/src/base/lock $(BASE_DIR)/src/base/lock +INC_DIR += $(BASE_DIR)/src/base/env vpath env.cc $(BASE_DIR)/src/base/env vpath context_area.cc $(BASE_DIR)/src/base/env diff --git a/base-host/lib/mk/env.mk b/base-host/lib/mk/env.mk index 915a0ccbe..f9f79d7b2 100644 --- a/base-host/lib/mk/env.mk +++ b/base-host/lib/mk/env.mk @@ -1,5 +1,6 @@ -SRC_CC = env.cc parent.cc context_area.cc -LIBS = ipc heap lock log_console +SRC_CC = env.cc parent.cc context_area.cc +LIBS = ipc heap lock log_console +INC_DIR += $(BASE_DIR)/src/base/env vpath env.cc $(BASE_DIR)/src/base/env vpath context_area.cc $(BASE_DIR)/src/base/env diff --git a/base-linux/lib/mk/env.mk b/base-linux/lib/mk/env.mk index d07cccbae..d458722a2 100644 --- a/base-linux/lib/mk/env.mk +++ b/base-linux/lib/mk/env.mk @@ -1,5 +1,6 @@ SRC_CC = env.cc rm_session_mmap.cc platform_env.cc debug.cc context_area.cc LIBS = ipc heap log_console lock syscall +INC_DIR += $(REP_DIR)/src/base/env vpath env.cc $(BASE_DIR)/src/base/env vpath context_area.cc $(BASE_DIR)/src/base/env diff --git a/base-linux/src/base/env/platform_env.cc b/base-linux/src/base/env/platform_env.cc index a340ffb75..b6aa58768 100644 --- a/base-linux/src/base/env/platform_env.cc +++ b/base-linux/src/base/env/platform_env.cc @@ -11,18 +11,18 @@ * under the terms of the GNU General Public License version 2. */ +/* Genode includes */ #include -#include #include #include #include +/* local includes */ +#include + using namespace Genode; - - - /**************************************************** ** Support for Platform_env_base::Rm_session_mmap ** ****************************************************/ diff --git a/base-linux/include/base/platform_env.h b/base-linux/src/base/env/platform_env.h similarity index 100% rename from base-linux/include/base/platform_env.h rename to base-linux/src/base/env/platform_env.h diff --git a/base-linux/src/base/env/rm_session_mmap.cc b/base-linux/src/base/env/rm_session_mmap.cc index 0c4d64bd3..59ecdad1d 100644 --- a/base-linux/src/base/env/rm_session_mmap.cc +++ b/base-linux/src/base/env/rm_session_mmap.cc @@ -11,11 +11,14 @@ * under the terms of the GNU General Public License version 2. */ -#include +/* Genode includes */ #include #include #include +/* local includes */ +#include + using namespace Genode; diff --git a/base-linux/src/core/include/core_env.h b/base-linux/src/core/include/core_env.h index cb9631437..d4576727b 100644 --- a/base-linux/src/core/include/core_env.h +++ b/base-linux/src/core/include/core_env.h @@ -18,15 +18,15 @@ #ifndef _CORE__INCLUDE__CORE_ENV_H_ #define _CORE__INCLUDE__CORE_ENV_H_ -/* Genode includes */ -#include - /* core includes */ #include #include #include #include +/* internal base includes */ +#include + namespace Genode { @@ -195,6 +195,8 @@ namespace Genode { PWRN("%s:%u not implemented", __FILE__, __LINE__); return 0; } + + void reload_parent_cap(Capability::Dst, long) { } }; diff --git a/base-linux/src/core/target.mk b/base-linux/src/core/target.mk index a947333d6..283e42209 100644 --- a/base-linux/src/core/target.mk +++ b/base-linux/src/core/target.mk @@ -27,7 +27,8 @@ SRC_CC = main.cc \ INC_DIR += $(REP_DIR)/src/core/include \ $(GEN_CORE_DIR)/include \ $(REP_DIR)/src/platform \ - $(REP_DIR)/src/base/ipc + $(REP_DIR)/src/base/ipc \ + $(REP_DIR)/src/base/env HOST_INC_DIR += /usr/include diff --git a/base-nova/lib/mk/env.mk b/base-nova/lib/mk/env.mk index 1f8ada9a8..c6f54bc48 100644 --- a/base-nova/lib/mk/env.mk +++ b/base-nova/lib/mk/env.mk @@ -1,6 +1,7 @@ -SRC_CC = env.cc cap_sel_alloc.cc main_thread.cc context_area.cc \ - reload_parent_cap.cc -LIBS = ipc heap lock log_console +SRC_CC = env.cc cap_sel_alloc.cc main_thread.cc context_area.cc \ + reload_parent_cap.cc +LIBS = ipc heap lock log_console +INC_DIR += $(BASE_DIR)/src/base/env vpath env.cc $(BASE_DIR)/src/base/env vpath cap_sel_alloc.cc $(REP_DIR)/src/base/env diff --git a/base-okl4/src/test/mini_env.h b/base-okl4/src/test/mini_env.h index d82d5e0a7..6aed29c5b 100644 --- a/base-okl4/src/test/mini_env.h +++ b/base-okl4/src/test/mini_env.h @@ -63,6 +63,8 @@ class Minimal_env : public Genode::Env return Genode::Ram_session_capability(); } Genode::Cpu_session_capability cpu_session_cap() { return Genode::Cpu_session_capability(); } + + void reload_parent_cap(Genode::Capability::Dst, long) { } }; diff --git a/base/include/base/env.h b/base/include/base/env.h index 307759721..80e48e436 100644 --- a/base/include/base/env.h +++ b/base/include/base/env.h @@ -70,10 +70,23 @@ namespace Genode { virtual Pd_session *pd_session() = 0; /** - * Heap backed by the ram_session of the - * environment. + * Heap backed by the ram_session of the environment. */ virtual Allocator *heap() = 0; + + /** + * Reload parent capability and reinitialize environment resources + * + * This function is solely used for implementing fork semantics. + * After forking a process, the new child process is executed + * within a copy of the address space of the forking process. + * Thereby, the new process inherits the original 'env' object of + * the forking process, which is meaningless in the context of the + * new process. By calling this function, the new process is able + * to reinitialize its 'env' with meaningful capabilities obtained + * via its updated parent capability. + */ + virtual void reload_parent_cap(Capability::Dst, long) = 0; }; extern Env *env(); diff --git a/base/lib/mk/env.mk b/base/lib/mk/env.mk index 37e3b53ac..3a01cf0d8 100644 --- a/base/lib/mk/env.mk +++ b/base/lib/mk/env.mk @@ -1,5 +1,6 @@ -SRC_CC = env.cc context_area.cc reload_parent_cap.cc -LIBS = ipc heap log_console lock +SRC_CC = env.cc context_area.cc reload_parent_cap.cc +LIBS = ipc heap log_console lock +INC_DIR += $(BASE_DIR)/src/base/env vpath env.cc $(REP_DIR)/src/base/env vpath context_area.cc $(BASE_DIR)/src/base/env diff --git a/base/src/base/env/env.cc b/base/src/base/env/env.cc index 738b1732c..7e85b863f 100644 --- a/base/src/base/env/env.cc +++ b/base/src/base/env/env.cc @@ -12,7 +12,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include namespace Genode { diff --git a/base/include/base/platform_env.h b/base/src/base/env/platform_env.h similarity index 90% rename from base/include/base/platform_env.h rename to base/src/base/env/platform_env.h index f35cb8616..0130cbf2b 100644 --- a/base/include/base/platform_env.h +++ b/base/src/base/env/platform_env.h @@ -202,19 +202,6 @@ namespace Genode { _initial_junk, sizeof(_initial_junk)) { } - /** - * Reload parent capability and reinitialize environment resources - * - * This function is solely used for implementing fork semantics. - * After forking a process, the new child process is executed - * within a copy of the address space of the forking process. - * Thereby, the new process inherits the original 'Platform_env' - * object of the forking process, which is meaningless in the - * context of the new process. By calling this function, the new - * process is able to reinitialize its 'Platform_env' with - * meaningful capabilities obtained via its updated parent - * capability. - */ void reload_parent_cap(Native_capability::Dst, long); diff --git a/base/src/base/env/reload_parent_cap.cc b/base/src/base/env/reload_parent_cap.cc index fe4ed02e4..52700e27a 100644 --- a/base/src/base/env/reload_parent_cap.cc +++ b/base/src/base/env/reload_parent_cap.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include diff --git a/base/src/core/include/core_env.h b/base/src/core/include/core_env.h index 61342a04e..ed95eb332 100644 --- a/base/src/core/include/core_env.h +++ b/base/src/core/include/core_env.h @@ -163,7 +163,6 @@ namespace Genode { return 0; } - Cpu_session_capability cpu_session_cap() { PWRN("%s:%u not implemented", __FILE__, __LINE__); return Cpu_session_capability(); @@ -174,6 +173,8 @@ namespace Genode { PWRN("%s:%u not implemented", __FILE__, __LINE__); return 0; } + + void reload_parent_cap(Capability::Dst, long) { } }; diff --git a/ports/src/lib/libc_noux/plugin.cc b/ports/src/lib/libc_noux/plugin.cc index 662e1da25..ddcc9c026 100644 --- a/ports/src/lib/libc_noux/plugin.cc +++ b/ports/src/lib/libc_noux/plugin.cc @@ -363,7 +363,6 @@ extern "C" int select(int nfds, fd_set *readfds, fd_set *writefds, #include -#include static jmp_buf fork_jmp_buf; @@ -377,8 +376,7 @@ extern "C" void stdout_reconnect(); /* provided by 'log_console.cc' */ */ extern "C" void fork_trampoline() { - static_cast(Genode::env()) - ->reload_parent_cap(new_parent.dst, new_parent.local_name); + Genode::env()->reload_parent_cap(new_parent.dst, new_parent.local_name); stdout_reconnect(); noux_connection()->reconnect();