diff --git a/repos/base-fiasco/src/core/platform.cc b/repos/base-fiasco/src/core/platform.cc
index 9688f2bb0d..5f66adfa95 100644
--- a/repos/base-fiasco/src/core/platform.cc
+++ b/repos/base-fiasco/src/core/platform.cc
@@ -25,7 +25,6 @@
#include
/* core includes */
-#include
#include
#include
#include
@@ -485,5 +484,3 @@ void Platform::wait_for_exit()
sleep_forever();
}
-
-void Core_parent::exit(int exit_value) { }
diff --git a/repos/base-fiasco/src/lib/base/thread_bootstrap.cc b/repos/base-fiasco/src/lib/base/thread_bootstrap.cc
index d9cc878b93..edf809c641 100644
--- a/repos/base-fiasco/src/lib/base/thread_bootstrap.cc
+++ b/repos/base-fiasco/src/lib/base/thread_bootstrap.cc
@@ -15,6 +15,9 @@
#include
#include
+/* base-internal includes */
+#include
+
using namespace Genode;
@@ -22,8 +25,7 @@ using namespace Genode;
** Startup library support **
*****************************/
-void prepare_init_main_thread() { }
-
+void prepare_init_main_thread() { }
void prepare_reinit_main_thread() { }
@@ -36,6 +38,7 @@ void Thread::_thread_bootstrap() { }
void Thread::_init_platform_thread(size_t, Type type)
{
- if (type == NORMAL) { return; }
- _thread_cap = Genode::env_deprecated()->parent()->main_thread_cap();
+ if (type == NORMAL) return;
+
+ _thread_cap = main_thread_cap();
}
diff --git a/repos/base-foc/src/core/platform.cc b/repos/base-foc/src/core/platform.cc
index b1fa454a0b..ca282a1996 100644
--- a/repos/base-foc/src/core/platform.cc
+++ b/repos/base-foc/src/core/platform.cc
@@ -512,5 +512,3 @@ Affinity::Space Platform::affinity_space() const
return Affinity::Space(cpus_online, 1);
}
-
-void Core_parent::exit(int exit_value) { }
diff --git a/repos/base-foc/src/lib/base/thread_start.cc b/repos/base-foc/src/lib/base/thread_start.cc
index 8ab3285090..c2dc147461 100644
--- a/repos/base-foc/src/lib/base/thread_start.cc
+++ b/repos/base-foc/src/lib/base/thread_start.cc
@@ -24,6 +24,7 @@
/* base-internal includes */
#include
#include
+#include
/* Fiasco includes */
namespace Fiasco {
@@ -66,7 +67,7 @@ void Thread::_init_platform_thread(size_t weight, Type type)
}
/* adjust values whose computation differs for a main thread */
native_thread().kcap = Fiasco::MAIN_THREAD_CAP;
- _thread_cap = env_deprecated()->parent()->main_thread_cap();
+ _thread_cap = main_thread_cap();
if (!_thread_cap.valid())
throw Cpu_session::Thread_creation_failed();
diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc
index f3bd037173..f72c6e4905 100644
--- a/repos/base-hw/src/core/platform.cc
+++ b/repos/base-hw/src/core/platform.cc
@@ -143,17 +143,6 @@ Platform::Platform()
}
-/*****************
- ** Core_parent **
- *****************/
-
-void Core_parent::exit(int exit_value)
-{
- warning(__PRETTY_FUNCTION__, "not implemented");
- while (1);
-}
-
-
/****************************************
** Support for core memory management **
****************************************/
diff --git a/repos/base-hw/src/core/spec/arndale/platform_services.cc b/repos/base-hw/src/core/spec/arndale/platform_services.cc
index 3c310adc35..6ba241f41d 100644
--- a/repos/base-hw/src/core/spec/arndale/platform_services.cc
+++ b/repos/base-hw/src/core/spec/arndale/platform_services.cc
@@ -18,7 +18,7 @@
/* core includes */
#include
#include
-#include /* for 'Core_service' type */
+#include
#include
#include
#include
diff --git a/repos/base-hw/src/core/spec/imx53/trustzone/platform_services.cc b/repos/base-hw/src/core/spec/imx53/trustzone/platform_services.cc
index a5a0e295be..09fa36b5f9 100644
--- a/repos/base-hw/src/core/spec/imx53/trustzone/platform_services.cc
+++ b/repos/base-hw/src/core/spec/imx53/trustzone/platform_services.cc
@@ -18,7 +18,7 @@
/* Core includes */
#include
#include
-#include
+#include
#include
#include
diff --git a/repos/base-hw/src/lib/base/thread_start.cc b/repos/base-hw/src/lib/base/thread_start.cc
index f2f4740ac7..9e64ec47c9 100644
--- a/repos/base-hw/src/lib/base/thread_start.cc
+++ b/repos/base-hw/src/lib/base/thread_start.cc
@@ -63,7 +63,7 @@ void Thread::_init_platform_thread(size_t weight, Type type)
}
/* adjust initial object state in case of a main thread */
native_thread().cap = Hw::_main_thread_cap;
- _thread_cap = env_deprecated()->parent()->main_thread_cap();
+ _thread_cap = main_thread_cap();
}
diff --git a/repos/base-linux/src/core/include/core_env.h b/repos/base-linux/src/core/include/core_env.h
deleted file mode 100644
index 817061925d..0000000000
--- a/repos/base-linux/src/core/include/core_env.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * \brief Core-specific environment for Linux
- * \author Norman Feske
- * \author Christian Helmuth
- * \date 2006-07-28
- */
-
-/*
- * Copyright (C) 2006-2017 Genode Labs GmbH
- *
- * This file is part of the Genode OS framework, which is distributed
- * under the terms of the GNU Affero General Public License version 3.
- */
-
-#ifndef _CORE__INCLUDE__CORE_ENV_H_
-#define _CORE__INCLUDE__CORE_ENV_H_
-
-/* Genode includes */
-#include
-
-/* core includes */
-#include
-#include
-#include
-#include
-#include
-
-/* base-internal includes */
-#include
-
-namespace Genode { void init_stack_area(); }
-
-namespace Genode {
-
- /**
- * Lock-guarded wrapper for a RAM session
- *
- * In contrast to regular components, core's RAM session is not
- * synchronized via the RPC entrypoint.
- */
- class Synced_ram_session : public Ram_session
- {
- private:
-
- Lock mutable _lock;
- Ram_session &_ram_session;
-
- public:
-
- Synced_ram_session(Ram_session &ram_session) : _ram_session(ram_session) { }
-
-
- /***************************
- ** RAM-session interface **
- ***************************/
-
- Ram_dataspace_capability alloc(size_t size, Cache_attribute cached) override
- {
- Lock::Guard lock_guard(_lock);
- return _ram_session.alloc(size, cached);
- }
-
- void free(Ram_dataspace_capability ds) override
- {
- Lock::Guard lock_guard(_lock);
- _ram_session.free(ds);
- }
-
- size_t dataspace_size(Ram_dataspace_capability ds) const override
- {
- Lock::Guard lock_guard(_lock);
- return _ram_session.dataspace_size(ds);
- }
-
- void ref_account(Ram_session_capability session) override
- {
- Lock::Guard lock_guard(_lock);
- _ram_session.ref_account(session);
- }
-
- void transfer_quota(Ram_session_capability session, Ram_quota amount) override
- {
- Lock::Guard lock_guard(_lock);
- _ram_session.transfer_quota(session, amount);
- }
-
- Ram_quota ram_quota() const override
- {
- Lock::Guard lock_guard(_lock);
- return _ram_session.ram_quota();
- }
-
- Ram_quota used_ram() const override
- {
- Lock::Guard lock_guard(_lock);
- return _ram_session.used_ram();
- }
- };
-
-
- class Core_env : public Platform_env_base
- {
- private:
-
- enum { STACK_SIZE = 2048 * sizeof(Genode::addr_t) };
-
- /*
- * Initialize the stack area before creating the first thread,
- * which happens to be the '_entrypoint'.
- */
- bool _init_stack_area() { init_stack_area(); return true; }
- bool _stack_area_initialized = _init_stack_area();
-
- Rpc_entrypoint _entrypoint { nullptr, STACK_SIZE, "entrypoint" };
- Ram_session_component _ram_session;
- Synced_ram_session _synced_ram_session { _ram_session };
-
- /*
- * The core-local PD session is provided by a real RPC object
- * dispatched by the same entrypoint as the signal-source RPC
- * objects. This is needed to allow the 'Pd_session::submit'
- * method to issue out-of-order replies to
- * 'Signal_source::wait_for_signal' calls.
- */
- Core_pd_session_component _pd_session_component { _entrypoint };
- Pd_session_client _pd_session_client { _pd_session_component.cap() };
-
- Registry _services;
-
- Heap _heap { _synced_ram_session, *Platform_env_base::rm_session() };
-
- Core_parent _core_parent { _heap, _services };
-
- typedef String<100> Ram_args;
-
- static Session::Resources _ram_resources()
- {
- return { Ram_quota { platform()->ram_alloc()->avail() },
- Cap_quota { 1000 } };
- }
-
- public:
-
- /**
- * Constructor
- */
- Core_env()
- :
- Platform_env_base(Ram_session_capability(),
- Cpu_session_capability(),
- Pd_session_capability()),
- _ram_session(_entrypoint,
- _ram_resources(),
- Session::Label("core"),
- Session::Diag{false},
- *platform()->ram_alloc(),
- *Platform_env_base::rm_session(),
- Ram_session_component::any_phys_range())
- {
- _ram_session.init_ram_account();
- }
-
- /**
- * Destructor
- */
- ~Core_env() { parent()->exit(0); }
-
-
- Rpc_entrypoint *entrypoint() { return &_entrypoint; }
-
-
- /******************************
- ** Env_deprecated interface **
- ******************************/
-
- Parent *parent() override { return &_core_parent; }
- Ram_session *ram_session() override { return &_ram_session; }
- Ram_session_capability ram_session_cap() override { return _ram_session.cap(); }
- Pd_session *pd_session() override { return &_pd_session_client; }
- Allocator *heap() override { log(__func__, ": not implemented"); return nullptr; }
-
- Cpu_session_capability cpu_session_cap() override
- {
- warning(__FILE__, ":", __LINE__, " not implemented");
- return Cpu_session_capability();
- }
-
- Registry &services() { return _services; }
- };
-
-
- /**
- * Request pointer to static environment of Core
- */
- extern Core_env *core_env();
-}
-
-#endif /* _CORE__INCLUDE__CORE_ENV_H_ */
diff --git a/repos/base-linux/src/core/include/core_region_map.h b/repos/base-linux/src/core/include/core_region_map.h
new file mode 100644
index 0000000000..96227d7eb6
--- /dev/null
+++ b/repos/base-linux/src/core/include/core_region_map.h
@@ -0,0 +1,28 @@
+/*
+ * \brief Core-specific region map for Linux
+ * \author Norman Feske
+ * \date 2017-05-10
+ */
+
+/*
+ * Copyright (C) 2017 Genode Labs GmbH
+ *
+ * This file is part of the Genode OS framework, which is distributed
+ * under the terms of the GNU Affero General Public License version 3.
+ */
+
+#ifndef _CORE__INCLUDE__CORE_REGION_MAP_H_
+#define _CORE__INCLUDE__CORE_REGION_MAP_H_
+
+/* base-internal includes */
+#include
+
+namespace Genode { class Core_region_map; }
+
+
+struct Genode::Core_region_map : Region_map_mmap
+{
+ Core_region_map(Rpc_entrypoint &ep) : Region_map_mmap(false) { }
+};
+
+#endif /* _CORE__INCLUDE__CORE_REGION_MAP_H_ */
diff --git a/repos/base-linux/src/core/platform.cc b/repos/base-linux/src/core/platform.cc
index b901954369..cdb8ba0257 100644
--- a/repos/base-linux/src/core/platform.cc
+++ b/repos/base-linux/src/core/platform.cc
@@ -128,7 +128,7 @@ void Platform::wait_for_exit()
* '_exit' condition will be set.
*/
if (_do_exit)
- return;
+ break;
/*
* Reflect SIGCHLD as exception signal to the signal context of the CPU
@@ -145,12 +145,7 @@ void Platform::wait_for_exit()
Platform_thread::submit_exception(pid);
}
}
-}
-
-
-void Core_parent::exit(int exit_value)
-{
- lx_exit_group(exit_value);
+ lx_exit_group(0);
}
diff --git a/repos/base-linux/src/lib/base/thread_linux.cc b/repos/base-linux/src/lib/base/thread_linux.cc
index 5f360086ca..909bf94f22 100644
--- a/repos/base-linux/src/lib/base/thread_linux.cc
+++ b/repos/base-linux/src/lib/base/thread_linux.cc
@@ -23,6 +23,7 @@
/* base-internal includes */
#include
+#include
/* Linux syscall bindings */
#include
@@ -98,7 +99,7 @@ void Thread::_init_platform_thread(size_t weight, Type type)
}
/* adjust initial object state for main threads */
native_thread().futex_counter = main_thread_futex_counter;
- _thread_cap = env_deprecated()->parent()->main_thread_cap();
+ _thread_cap = main_thread_cap();
}
diff --git a/repos/base-nova/src/core/platform.cc b/repos/base-nova/src/core/platform.cc
index b2ec449dbe..86c688bd6e 100644
--- a/repos/base-nova/src/core/platform.cc
+++ b/repos/base-nova/src/core/platform.cc
@@ -21,7 +21,6 @@
/* core includes */
#include
-#include
#include
#include
#include
@@ -745,5 +744,3 @@ bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t phys_addr,
void Platform::wait_for_exit() { sleep_forever(); }
-
-void Core_parent::exit(int exit_value) { }
diff --git a/repos/base-nova/src/lib/base/thread_start.cc b/repos/base-nova/src/lib/base/thread_start.cc
index 1f8cbd97da..beccde0deb 100644
--- a/repos/base-nova/src/lib/base/thread_start.cc
+++ b/repos/base-nova/src/lib/base/thread_start.cc
@@ -25,6 +25,7 @@
/* base-internal includes */
#include
+#include
/* NOVA includes */
#include
@@ -80,7 +81,7 @@ void Thread::_init_platform_thread(size_t weight, Type type)
/* for main threads the member initialization differs */
if (type == MAIN || type == REINITIALIZED_MAIN) {
- _thread_cap = env_deprecated()->parent()->main_thread_cap();
+ _thread_cap = main_thread_cap();
native_thread().exc_pt_sel = 0;
native_thread().ec_sel = Nova::PT_SEL_MAIN_EC;
diff --git a/repos/base-okl4/src/core/platform.cc b/repos/base-okl4/src/core/platform.cc
index 44903495f1..a2900d1b6b 100644
--- a/repos/base-okl4/src/core/platform.cc
+++ b/repos/base-okl4/src/core/platform.cc
@@ -25,7 +25,6 @@
/* core includes */
#include
-#include
#include
#include
#include
@@ -219,6 +218,3 @@ void Platform::wait_for_exit()
*/
sleep_forever();
}
-
-
-void Core_parent::exit(int exit_value) { }
diff --git a/repos/base-okl4/src/lib/base/thread_bootstrap.cc b/repos/base-okl4/src/lib/base/thread_bootstrap.cc
index 29b044ef4c..42cf2baec3 100644
--- a/repos/base-okl4/src/lib/base/thread_bootstrap.cc
+++ b/repos/base-okl4/src/lib/base/thread_bootstrap.cc
@@ -19,6 +19,7 @@
/* base-internal includes */
#include
#include
+#include
/* OKL4 includes */
namespace Okl4 { extern "C" {
@@ -84,5 +85,5 @@ void Genode::Thread::_init_platform_thread(size_t, Type type)
{
if (type == NORMAL) { return; }
native_thread().l4id.raw = main_thread_tid.raw;
- _thread_cap = env_deprecated()->parent()->main_thread_cap();
+ _thread_cap = main_thread_cap();
}
diff --git a/repos/base-pistachio/src/core/platform.cc b/repos/base-pistachio/src/core/platform.cc
index 02c90ac99d..6db04048f9 100644
--- a/repos/base-pistachio/src/core/platform.cc
+++ b/repos/base-pistachio/src/core/platform.cc
@@ -26,7 +26,6 @@
/* core includes */
#include
-#include
#include
#include
#include
@@ -660,5 +659,3 @@ void Platform::wait_for_exit()
sleep_forever();
}
-
-void Core_parent::exit(int exit_value) { }
diff --git a/repos/base-pistachio/src/lib/base/thread_bootstrap.cc b/repos/base-pistachio/src/lib/base/thread_bootstrap.cc
index 4596059666..91bfc66133 100644
--- a/repos/base-pistachio/src/lib/base/thread_bootstrap.cc
+++ b/repos/base-pistachio/src/lib/base/thread_bootstrap.cc
@@ -17,6 +17,7 @@
/* base-internal includes */
#include
+#include
/* Pistachio includes */
namespace Pistachio {
@@ -52,5 +53,5 @@ void Genode::Thread::_init_platform_thread(size_t, Type type)
{
if (type == NORMAL) { return; }
native_thread().l4id = main_thread_tid;
- _thread_cap = env_deprecated()->parent()->main_thread_cap();
+ _thread_cap = main_thread_cap();
}
diff --git a/repos/base-sel4/src/core/platform.cc b/repos/base-sel4/src/core/platform.cc
index 3b54c70201..0f78c58392 100644
--- a/repos/base-sel4/src/core/platform.cc
+++ b/repos/base-sel4/src/core/platform.cc
@@ -18,7 +18,6 @@
/* core includes */
#include
-#include
#include
#include
#include
@@ -467,5 +466,3 @@ void Platform::wait_for_exit()
sleep_forever();
}
-
-void Core_parent::exit(int exit_value) { }
diff --git a/repos/base/lib/mk/base.inc b/repos/base/lib/mk/base.inc
index 52dd811c7d..79b6af2a65 100644
--- a/repos/base/lib/mk/base.inc
+++ b/repos/base/lib/mk/base.inc
@@ -1,5 +1,5 @@
SRC_CC += log_console.cc default_log.cc
-SRC_CC += env_deprecated.cc stack_area.cc env_reinit.cc
+SRC_CC += env_deprecated.cc stack_area.cc env_reinit.cc main_thread_cap.cc
SRC_CC += rpc_cap_alloc.cc
vpath %.cc $(REP_DIR)/src/lib/base
diff --git a/repos/base/src/core/include/core_env.h b/repos/base/src/core/include/core_env.h
index ad62f59273..7d78e68447 100644
--- a/repos/base/src/core/include/core_env.h
+++ b/repos/base/src/core/include/core_env.h
@@ -17,203 +17,82 @@
/* Genode includes */
#include
-#include
-#include
-#include
-#include
+
+/* base-internal includes */
+#include
/* core includes */
#include
-#include
#include
-#include
#include
-
-namespace Genode { void init_stack_area(); }
+#include
+#include
namespace Genode {
-
- /**
- * Lock-guarded wrapper for a RAM session
- *
- * In contrast to normal components, core's RAM session is not
- * synchronized by an RPC interface.
- */
- class Synced_ram_session : public Ram_session
- {
- private:
-
- Lock mutable _lock;
- Ram_session &_ram_session;
-
- public:
-
- Synced_ram_session(Ram_session &ram_session) : _ram_session(ram_session) { }
-
-
- /***************************
- ** RAM-session interface **
- ***************************/
-
- Ram_dataspace_capability alloc(size_t size, Cache_attribute cached) override
- {
- Lock::Guard lock_guard(_lock);
- return _ram_session.alloc(size, cached);
- }
-
- void free(Ram_dataspace_capability ds) override
- {
- Lock::Guard lock_guard(_lock);
- _ram_session.free(ds);
- }
-
- size_t dataspace_size(Ram_dataspace_capability ds) const override
- {
- Lock::Guard lock_guard(_lock);
- return _ram_session.dataspace_size(ds);
- }
-
- void ref_account(Ram_session_capability session) override
- {
- Lock::Guard lock_guard(_lock);
- _ram_session.ref_account(session);
- }
-
- void transfer_quota(Ram_session_capability session, Ram_quota amount) override
- {
- Lock::Guard lock_guard(_lock);
- _ram_session.transfer_quota(session, amount);
- }
-
- Ram_quota ram_quota() const override
- {
- Lock::Guard lock_guard(_lock);
- return _ram_session.ram_quota();
- }
-
- Ram_quota used_ram() const override
- {
- Lock::Guard lock_guard(_lock);
- return _ram_session.used_ram();
- }
- };
-
-
- class Core_env : public Env_deprecated
- {
- private:
-
- enum { ENTRYPOINT_STACK_SIZE = 2048 * sizeof(Genode::addr_t) };
-
- /*
- * Initialize the stack area before creating the first thread,
- * which happens to be the '_entrypoint'.
- */
- bool _init_stack_area() { init_stack_area(); return true; }
- bool _stack_area_initialized = _init_stack_area();
-
- Rpc_entrypoint _entrypoint;
- Core_region_map _region_map;
- Ram_session_component _ram_session;
- Synced_ram_session _synced_ram_session { _ram_session };
-
- /*
- * The core-local PD session is provided by a real RPC object
- * dispatched by the same entrypoint as the signal-source RPC
- * objects. This is needed to allow the 'Pd_session::submit'
- * method to issue out-of-order replies to
- * 'Signal_source::wait_for_signal' calls.
- */
- Core_pd_session_component _pd_session_component;
- Pd_session_client _pd_session_client;
-
- Heap _heap { _synced_ram_session, _region_map };
-
- Registry _services;
-
- Core_parent _core_parent { _heap, _services };
-
- typedef String<100> Ram_args;
-
- static Session::Resources _ram_resources()
- {
- return { Ram_quota { platform()->ram_alloc()->avail() },
- Cap_quota { platform()->max_caps() } };
- }
-
- public:
-
- /**
- * Constructor
- */
- Core_env()
- :
- _entrypoint(nullptr, ENTRYPOINT_STACK_SIZE, "entrypoint"),
- _region_map(_entrypoint),
- _ram_session(_entrypoint,
- _ram_resources(),
- Session::Label("core"),
- Session::Diag{false},
- *platform()->ram_alloc(),
- _region_map,
- Ram_session_component::any_phys_range()),
- _pd_session_component(_entrypoint),
- _pd_session_client(_pd_session_component.cap()),
- _heap(_ram_session, _region_map)
- {
- _ram_session.init_ram_account();
- }
-
- /**
- * Destructor
- */
- ~Core_env() { parent()->exit(0); }
-
-
- Rpc_entrypoint *entrypoint() { return &_entrypoint; }
-
-
- /******************************
- ** Env_deprecated interface **
- ******************************/
-
- Parent *parent() override { return &_core_parent; }
- Ram_session *ram_session() override { return &_synced_ram_session; }
- Ram_session_capability ram_session_cap() override { return _ram_session.cap(); }
- Region_map *rm_session() override { return &_region_map; }
- Pd_session *pd_session() override { return &_pd_session_client; }
- Allocator *heap() override { log(__func__, ": not implemented"); return nullptr; }
-
- Cpu_session *cpu_session() override
- {
- warning(__func__, " not implemented");
- return 0;
- }
-
- Cpu_session_capability cpu_session_cap() override
- {
- warning(__FILE__, ":", __LINE__, " not implemented");
- return Cpu_session_capability();
- }
-
- Pd_session_capability pd_session_cap() override
- {
- warning(__func__, " not implemented");
- return Pd_session_capability();
- }
-
- void reinit(Capability::Raw) override { }
-
- void reinit_main_thread(Capability &) override { }
-
- Registry &services() { return _services; }
- };
-
-
- /**
- * Request pointer to static environment of Core
- */
+ class Core_env;
extern Core_env *core_env();
}
+
+class Genode::Core_env : public Env_deprecated
+{
+ private:
+
+ enum { ENTRYPOINT_STACK_SIZE = 2048 * sizeof(Genode::addr_t) };
+
+ /*
+ * Initialize the stack area before creating the first thread,
+ * which happens to be the '_entrypoint'.
+ */
+ bool _init_stack_area() { init_stack_area(); return true; }
+ bool _stack_area_initialized = _init_stack_area();
+
+ Rpc_entrypoint _entrypoint;
+ Core_region_map _region_map;
+ Ram_session_component _ram_session;
+ Synced_ram_session _synced_ram_session { _ram_session };
+
+ public:
+
+ Core_env()
+ :
+ _entrypoint(nullptr, ENTRYPOINT_STACK_SIZE, "entrypoint"),
+ _region_map(_entrypoint),
+ _ram_session(_entrypoint,
+ Session::Resources {
+ Ram_quota { platform()->ram_alloc()->avail() },
+ Cap_quota { platform()->max_caps() } },
+ Session::Label("core"),
+ Session::Diag{false},
+ *platform()->ram_alloc(),
+ _region_map,
+ Ram_session_component::any_phys_range())
+ {
+ _ram_session.init_ram_account();
+ }
+
+ ~Core_env() { parent()->exit(0); }
+
+ Rpc_entrypoint *entrypoint() { return &_entrypoint; }
+
+
+ /******************************
+ ** Env_deprecated interface **
+ ******************************/
+
+ Parent *parent() override { return nullptr; }
+ Ram_session *ram_session() override { return &_synced_ram_session; }
+ Ram_session_capability ram_session_cap() override { return _ram_session.cap(); }
+ Region_map *rm_session() override { return &_region_map; }
+ Pd_session *pd_session() override { return nullptr; }
+ Allocator *heap() override { ASSERT_NEVER_CALLED; }
+ Cpu_session *cpu_session() override { ASSERT_NEVER_CALLED; }
+ Cpu_session_capability cpu_session_cap() override { ASSERT_NEVER_CALLED; }
+ Pd_session_capability pd_session_cap() override { ASSERT_NEVER_CALLED; }
+
+ void reinit(Capability::Raw) override { }
+ void reinit_main_thread(Capability &) override { }
+};
+
+
#endif /* _CORE__INCLUDE__CORE_ENV_H_ */
diff --git a/repos/base/src/core/include/core_parent.h b/repos/base/src/core/include/core_parent.h
deleted file mode 100644
index 13e0b9759f..0000000000
--- a/repos/base/src/core/include/core_parent.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * \brief Core-specific parent client implementation
- * \author Norman Feske
- * \author Christian Helmuth
- * \date 2006-07-20
- */
-
-/*
- * Copyright (C) 2006-2017 Genode Labs GmbH
- *
- * This file is part of the Genode OS framework, which is distributed
- * under the terms of the GNU Affero General Public License version 3.
- */
-
-#ifndef _CORE__INCLUDE__CORE_PARENT_H_
-#define _CORE__INCLUDE__CORE_PARENT_H_
-
-#include
-#include
-#include
-
-namespace Genode {
-
- template struct Core_service;
- struct Core_parent;
-}
-
-
-template
-struct Genode::Core_service : Local_service, Registry::Element
-{
- Core_service(Registry ®istry,
- typename Local_service::Factory &factory)
- :
- Local_service(factory),
- Registry::Element(registry, *this)
- { }
-};
-
-
-/**
- * Core has no parent. But most of Genode's library code could work seamlessly
- * inside core if it had one. Core_parent fills this gap.
- */
-class Genode::Core_parent : public Parent
-{
- private:
-
- Id_space _id_space;
- Allocator &_alloc;
- Registry &_services;
-
- public:
-
- /**
- * Constructor
- *
- * \alloc allocator to be used for allocating core-local
- * 'Session_state' objects
- */
- Core_parent(Allocator &alloc, Registry &services)
- : _alloc(alloc), _services(services) { }
-
- void exit(int) override;
-
- void announce(Service_name const &) override { }
-
- void session_sigh(Signal_context_capability) override { }
-
- Session_capability session(Client::Id, Service_name const &, Session_args const &,
- Affinity const &) override;
-
- Session_capability session_cap(Client::Id) override { return Session_capability(); }
-
- Upgrade_result upgrade(Client::Id, Upgrade_args const &) override {
- throw Out_of_ram(); }
-
- Close_result close(Client::Id) override { return CLOSE_DONE; }
-
- void session_response(Server::Id, Session_response) override { }
-
- void deliver_session_cap(Server::Id,
- Session_capability) override { }
-
- Thread_capability main_thread_cap() const override { return Thread_capability(); }
-
- void resource_avail_sigh(Signal_context_capability) override { }
-
- void resource_request(Resource_args const &) override { }
-
- void yield_sigh(Signal_context_capability) override { }
-
- Resource_args yield_request() override { return Resource_args(); }
-
- void yield_response() override { }
-};
-
-#endif /* _CORE__INCLUDE__CORE_PARENT_H_ */
diff --git a/repos/base/src/core/include/core_pd_session.h b/repos/base/src/core/include/core_pd_session.h
deleted file mode 100644
index f95bbd1094..0000000000
--- a/repos/base/src/core/include/core_pd_session.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * \brief Core-specific pseudo PD session
- * \author Norman Feske
- * \date 2016-01-13
- */
-
-/*
- * Copyright (C) 2015-2017 Genode Labs GmbH
- *
- * This file is part of the Genode OS framework, which is distributed
- * under the terms of the GNU Affero General Public License version 3.
- */
-
-#ifndef _CORE__INCLUDE__CORE_PD_SESSION_H_
-#define _CORE__INCLUDE__CORE_PD_SESSION_H_
-
-/* Genode includes */
-#include
-#include
-#include
-
-/* core includes */
-#include
-#include
-
-namespace Genode { class Core_pd_session_component; }
-
-
-class Genode::Core_pd_session_component : public Rpc_object
-{
- private:
-
- Rpc_entrypoint &_ep;
-
- public:
-
- /**
- * Constructor
- */
- Core_pd_session_component(Rpc_entrypoint &ep) : _ep(ep)
- {
- ep.manage(this);
- }
-
- void assign_parent(Capability parent) override
- {
- ASSERT_NEVER_CALLED;
- }
-
- bool assign_pci(addr_t pci_config_memory_address, uint16_t) override
- {
- ASSERT_NEVER_CALLED;
- }
-
- Signal_source_capability alloc_signal_source() override
- {
- /*
- * Even though core does not receive any signals, this function is
- * called by the base-common initialization code on base-hw. We
- * can savely return an invalid capability as it is never used.
- */
- return Signal_source_capability();
- }
-
- void free_signal_source(Signal_source_capability cap) override
- {
- ASSERT_NEVER_CALLED;
- }
-
- Capability
- alloc_context(Signal_source_capability source, unsigned long imprint) override
- {
- ASSERT_NEVER_CALLED;
- }
-
- void free_context(Capability cap) override
- {
- ASSERT_NEVER_CALLED;
- }
-
- void submit(Capability cap, unsigned cnt = 1) override
- {
- _ep.apply(cap, [&] (Signal_context_component *context) {
- if (!context) {
- warning("invalid signal-context capability");
- return;
- }
-
- context->source()->submit(context, cnt);
- });
- }
-
- Native_capability alloc_rpc_cap(Native_capability) override
- {
- ASSERT_NEVER_CALLED;
- }
-
- void free_rpc_cap(Native_capability) override
- {
- ASSERT_NEVER_CALLED;
- }
-
- Capability address_space() override { ASSERT_NEVER_CALLED; }
- Capability stack_area() override { ASSERT_NEVER_CALLED; }
- Capability linker_area() override { ASSERT_NEVER_CALLED; }
-
- void ref_account(Capability) override { ASSERT_NEVER_CALLED; }
-
- void transfer_quota(Capability, Cap_quota) override {
- ASSERT_NEVER_CALLED; }
-
- Cap_quota cap_quota() const { ASSERT_NEVER_CALLED; }
- Cap_quota used_caps() const { ASSERT_NEVER_CALLED; }
-
- Capability native_pd() override { ASSERT_NEVER_CALLED; }
-};
-
-#endif /* _CORE__INCLUDE__CORE_PD_SESSION_H_ */
diff --git a/repos/base/src/core/include/core_service.h b/repos/base/src/core/include/core_service.h
new file mode 100644
index 0000000000..54db717114
--- /dev/null
+++ b/repos/base/src/core/include/core_service.h
@@ -0,0 +1,33 @@
+/*
+ * \brief Implementation of the 'Service' interface for core services
+ * \author Norman Feske
+ * \date 2017-05-11
+ */
+
+/*
+ * Copyright (C) 2017 Genode Labs GmbH
+ *
+ * This file is part of the Genode OS framework, which is distributed
+ * under the terms of the GNU Affero General Public License version 3.
+ */
+
+#ifndef _CORE__INCLUDE__CORE_SERVICE_H_
+#define _CORE__INCLUDE__CORE_SERVICE_H_
+
+#include
+
+namespace Genode { template struct Core_service; }
+
+
+template
+struct Genode::Core_service : Local_service, Registry::Element
+{
+ Core_service(Registry ®istry,
+ typename Local_service::Factory &factory)
+ :
+ Local_service(factory),
+ Registry::Element(registry, *this)
+ { }
+};
+
+#endif /* _CORE__INCLUDE__CORE_SERVICE_H_ */
diff --git a/repos/base/src/core/include/platform_services.h b/repos/base/src/core/include/platform_services.h
index d677f1dcf6..abb8bb7152 100644
--- a/repos/base/src/core/include/platform_services.h
+++ b/repos/base/src/core/include/platform_services.h
@@ -14,7 +14,7 @@
#ifndef _CORE__INCLUDE__PLATFORM_SERVICES_H_
#define _CORE__INCLUDE__PLATFORM_SERVICES_H_
-#include
+#include
namespace Genode {
diff --git a/repos/base/src/core/include/synced_ram_session.h b/repos/base/src/core/include/synced_ram_session.h
new file mode 100644
index 0000000000..8ee71bb0f2
--- /dev/null
+++ b/repos/base/src/core/include/synced_ram_session.h
@@ -0,0 +1,78 @@
+/*
+ * \brief Synchronized wrapper for the 'Ram_session' interface
+ * \author Norman Feske
+ * \date 2017-05-11
+ */
+
+/*
+ * Copyright (C) 2017 Genode Labs GmbH
+ *
+ * This file is part of the Genode OS framework, which is distributed
+ * under the terms of the GNU Affero General Public License version 3.
+ */
+
+#ifndef _CORE__INCLUDE__SYNCED_RAM_SESSION_H_
+#define _CORE__INCLUDE__SYNCED_RAM_SESSION_H_
+
+/* Genode includes */
+#include
+#include
+
+namespace Genode { class Synced_ram_session; }
+
+
+class Genode::Synced_ram_session : public Ram_session
+{
+ private:
+
+ Lock mutable _lock;
+ Ram_session &_ram_session;
+
+ public:
+
+ Synced_ram_session(Ram_session &ram_session) : _ram_session(ram_session) { }
+
+ Ram_dataspace_capability alloc(size_t size, Cache_attribute cached) override
+ {
+ Lock::Guard lock_guard(_lock);
+ return _ram_session.alloc(size, cached);
+ }
+
+ void free(Ram_dataspace_capability ds) override
+ {
+ Lock::Guard lock_guard(_lock);
+ _ram_session.free(ds);
+ }
+
+ size_t dataspace_size(Ram_dataspace_capability ds) const override
+ {
+ Lock::Guard lock_guard(_lock);
+ return _ram_session.dataspace_size(ds);
+ }
+
+ void ref_account(Ram_session_capability session) override
+ {
+ Lock::Guard lock_guard(_lock);
+ _ram_session.ref_account(session);
+ }
+
+ void transfer_quota(Ram_session_capability session, Ram_quota amount) override
+ {
+ Lock::Guard lock_guard(_lock);
+ _ram_session.transfer_quota(session, amount);
+ }
+
+ Ram_quota ram_quota() const override
+ {
+ Lock::Guard lock_guard(_lock);
+ return _ram_session.ram_quota();
+ }
+
+ Ram_quota used_ram() const override
+ {
+ Lock::Guard lock_guard(_lock);
+ return _ram_session.used_ram();
+ }
+};
+
+#endif /* _CORE__INCLUDE__SYNCED_RAM_SESSION_H_ */
diff --git a/repos/base/src/core/main.cc b/repos/base/src/core/main.cc
index 3f3cf8f430..1f5603e7b0 100644
--- a/repos/base/src/core/main.cc
+++ b/repos/base/src/core/main.cc
@@ -28,6 +28,7 @@
/* core includes */
#include
#include
+#include
#include
#include
#include
@@ -89,36 +90,7 @@ Platform *Genode::platform_specific()
Platform_generic *Genode::platform() { return platform_specific(); }
-/*************************
- ** Core parent support **
- *************************/
-
-Session_capability Core_parent::session(Parent::Client::Id id,
- Parent::Service_name const &name,
- Parent::Session_args const &args,
- Affinity const &affinity)
-{
- Session_capability cap;
-
- _services.for_each([&] (Service &service) {
-
- if ((service.name() != name.string()) || cap.valid())
- return;
-
- Session_state &session = *new (_alloc)
- Session_state(service, _id_space, id, label_from_args(args.string()),
- args.string(), affinity);
-
- service.initiate_request(session);
-
- cap = session.cap;
- });
-
- if (!cap.valid())
- error("unexpected core-parent ", name.string(), " session request");
-
- return cap;
-}
+Thread_capability Genode::main_thread_cap() { return Thread_capability(); }
/****************
@@ -277,7 +249,7 @@ int main()
*/
Rpc_entrypoint *e = core_env()->entrypoint();
- Registry &services = core_env()->services();
+ static Registry services;
static Ram_allocator &core_ram_alloc = *core_env()->ram_session();
static Region_map &local_rm = *core_env()->rm_session();
diff --git a/repos/base/src/include/base/internal/globals.h b/repos/base/src/include/base/internal/globals.h
index 81314206e1..ec354b7353 100644
--- a/repos/base/src/include/base/internal/globals.h
+++ b/repos/base/src/include/base/internal/globals.h
@@ -26,6 +26,9 @@ namespace Genode {
extern Region_map *env_stack_area_region_map;
extern Ram_session *env_stack_area_ram_session;
+ Thread_capability main_thread_cap();
+
+ void init_stack_area();
void init_exception_handling(Env &);
void init_signal_transmitter(Env &);
void init_cxx_heap(Env &);
diff --git a/repos/base/src/lib/base/main_thread_cap.cc b/repos/base/src/lib/base/main_thread_cap.cc
new file mode 100644
index 0000000000..0019920008
--- /dev/null
+++ b/repos/base/src/lib/base/main_thread_cap.cc
@@ -0,0 +1,24 @@
+/*
+ * \brief Access to the component's initial thread capability
+ * \author Norman Feske
+ * \date 2017-05-10
+ */
+
+/*
+ * Copyright (C) 2017 Genode Labs GmbH
+ *
+ * This file is part of the Genode OS framework, which is distributed
+ * under the terms of the GNU Affero General Public License version 3.
+ */
+
+/* Genode includes */
+#include
+
+/* base-internal includes */
+#include
+#include
+
+Genode::Thread_capability Genode::main_thread_cap()
+{
+ return Genode::env_deprecated()->parent()->main_thread_cap();
+}