core: simplify initialization

This patch removes the 'Core_parent' and 'Core_pd_session', and reduces
the 'Core_env'.
This commit is contained in:
Norman Feske 2017-05-11 00:07:54 +02:00 committed by Christian Helmuth
parent a1df4fee44
commit 65225a94b1
29 changed files with 261 additions and 684 deletions

View File

@ -25,7 +25,6 @@
#include <base/internal/globals.h> #include <base/internal/globals.h>
/* core includes */ /* core includes */
#include <core_parent.h>
#include <platform.h> #include <platform.h>
#include <platform_thread.h> #include <platform_thread.h>
#include <platform_pd.h> #include <platform_pd.h>
@ -485,5 +484,3 @@ void Platform::wait_for_exit()
sleep_forever(); sleep_forever();
} }
void Core_parent::exit(int exit_value) { }

View File

@ -15,6 +15,9 @@
#include <base/thread.h> #include <base/thread.h>
#include <base/env.h> #include <base/env.h>
/* base-internal includes */
#include <base/internal/globals.h>
using namespace Genode; using namespace Genode;
@ -23,7 +26,6 @@ using namespace Genode;
*****************************/ *****************************/
void prepare_init_main_thread() { } void prepare_init_main_thread() { }
void prepare_reinit_main_thread() { } void prepare_reinit_main_thread() { }
@ -36,6 +38,7 @@ void Thread::_thread_bootstrap() { }
void Thread::_init_platform_thread(size_t, Type type) void Thread::_init_platform_thread(size_t, Type type)
{ {
if (type == NORMAL) { return; } if (type == NORMAL) return;
_thread_cap = Genode::env_deprecated()->parent()->main_thread_cap();
_thread_cap = main_thread_cap();
} }

View File

@ -512,5 +512,3 @@ Affinity::Space Platform::affinity_space() const
return Affinity::Space(cpus_online, 1); return Affinity::Space(cpus_online, 1);
} }
void Core_parent::exit(int exit_value) { }

View File

@ -24,6 +24,7 @@
/* base-internal includes */ /* base-internal includes */
#include <base/internal/stack.h> #include <base/internal/stack.h>
#include <base/internal/cap_map.h> #include <base/internal/cap_map.h>
#include <base/internal/globals.h>
/* Fiasco includes */ /* Fiasco includes */
namespace Fiasco { 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 */ /* adjust values whose computation differs for a main thread */
native_thread().kcap = Fiasco::MAIN_THREAD_CAP; native_thread().kcap = Fiasco::MAIN_THREAD_CAP;
_thread_cap = env_deprecated()->parent()->main_thread_cap(); _thread_cap = main_thread_cap();
if (!_thread_cap.valid()) if (!_thread_cap.valid())
throw Cpu_session::Thread_creation_failed(); throw Cpu_session::Thread_creation_failed();

View File

@ -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 ** ** Support for core memory management **
****************************************/ ****************************************/

View File

@ -18,7 +18,7 @@
/* core includes */ /* core includes */
#include <platform.h> #include <platform.h>
#include <platform_services.h> #include <platform_services.h>
#include <core_parent.h> /* for 'Core_service' type */ #include <core_service.h>
#include <map_local.h> #include <map_local.h>
#include <vm_root.h> #include <vm_root.h>
#include <platform.h> #include <platform.h>

View File

@ -18,7 +18,7 @@
/* Core includes */ /* Core includes */
#include <platform.h> #include <platform.h>
#include <platform_services.h> #include <platform_services.h>
#include <core_parent.h> #include <core_service.h>
#include <vm_root.h> #include <vm_root.h>
#include <map_local.h> #include <map_local.h>

View File

@ -63,7 +63,7 @@ void Thread::_init_platform_thread(size_t weight, Type type)
} }
/* adjust initial object state in case of a main thread */ /* adjust initial object state in case of a main thread */
native_thread().cap = Hw::_main_thread_cap; native_thread().cap = Hw::_main_thread_cap;
_thread_cap = env_deprecated()->parent()->main_thread_cap(); _thread_cap = main_thread_cap();
} }

View File

@ -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 <base/service.h>
/* core includes */
#include <platform.h>
#include <core_parent.h>
#include <core_pd_session.h>
#include <ram_session_component.h>
#include <core_pd_session.h>
/* base-internal includes */
#include <base/internal/platform_env.h>
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<Service> _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<Service> &services() { return _services; }
};
/**
* Request pointer to static environment of Core
*/
extern Core_env *core_env();
}
#endif /* _CORE__INCLUDE__CORE_ENV_H_ */

View File

@ -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 <base/internal/region_map_mmap.h>
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_ */

View File

@ -128,7 +128,7 @@ void Platform::wait_for_exit()
* '_exit' condition will be set. * '_exit' condition will be set.
*/ */
if (_do_exit) if (_do_exit)
return; break;
/* /*
* Reflect SIGCHLD as exception signal to the signal context of the CPU * 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); Platform_thread::submit_exception(pid);
} }
} }
} lx_exit_group(0);
void Core_parent::exit(int exit_value)
{
lx_exit_group(exit_value);
} }

View File

@ -23,6 +23,7 @@
/* base-internal includes */ /* base-internal includes */
#include <base/internal/stack.h> #include <base/internal/stack.h>
#include <base/internal/globals.h>
/* Linux syscall bindings */ /* Linux syscall bindings */
#include <linux_syscalls.h> #include <linux_syscalls.h>
@ -98,7 +99,7 @@ void Thread::_init_platform_thread(size_t weight, Type type)
} }
/* adjust initial object state for main threads */ /* adjust initial object state for main threads */
native_thread().futex_counter = main_thread_futex_counter; native_thread().futex_counter = main_thread_futex_counter;
_thread_cap = env_deprecated()->parent()->main_thread_cap(); _thread_cap = main_thread_cap();
} }

View File

@ -21,7 +21,6 @@
/* core includes */ /* core includes */
#include <boot_modules.h> #include <boot_modules.h>
#include <core_parent.h>
#include <platform.h> #include <platform.h>
#include <nova_util.h> #include <nova_util.h>
#include <util.h> #include <util.h>
@ -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 Platform::wait_for_exit() { sleep_forever(); }
void Core_parent::exit(int exit_value) { }

View File

@ -25,6 +25,7 @@
/* base-internal includes */ /* base-internal includes */
#include <base/internal/stack.h> #include <base/internal/stack.h>
#include <base/internal/globals.h>
/* NOVA includes */ /* NOVA includes */
#include <nova/syscalls.h> #include <nova/syscalls.h>
@ -80,7 +81,7 @@ void Thread::_init_platform_thread(size_t weight, Type type)
/* for main threads the member initialization differs */ /* for main threads the member initialization differs */
if (type == MAIN || type == REINITIALIZED_MAIN) { 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().exc_pt_sel = 0;
native_thread().ec_sel = Nova::PT_SEL_MAIN_EC; native_thread().ec_sel = Nova::PT_SEL_MAIN_EC;

View File

@ -25,7 +25,6 @@
/* core includes */ /* core includes */
#include <boot_modules.h> #include <boot_modules.h>
#include <core_parent.h>
#include <platform.h> #include <platform.h>
#include <platform_thread.h> #include <platform_thread.h>
#include <platform_pd.h> #include <platform_pd.h>
@ -219,6 +218,3 @@ void Platform::wait_for_exit()
*/ */
sleep_forever(); sleep_forever();
} }
void Core_parent::exit(int exit_value) { }

View File

@ -19,6 +19,7 @@
/* base-internal includes */ /* base-internal includes */
#include <base/internal/native_thread.h> #include <base/internal/native_thread.h>
#include <base/internal/native_utcb.h> #include <base/internal/native_utcb.h>
#include <base/internal/globals.h>
/* OKL4 includes */ /* OKL4 includes */
namespace Okl4 { extern "C" { namespace Okl4 { extern "C" {
@ -84,5 +85,5 @@ void Genode::Thread::_init_platform_thread(size_t, Type type)
{ {
if (type == NORMAL) { return; } if (type == NORMAL) { return; }
native_thread().l4id.raw = main_thread_tid.raw; native_thread().l4id.raw = main_thread_tid.raw;
_thread_cap = env_deprecated()->parent()->main_thread_cap(); _thread_cap = main_thread_cap();
} }

View File

@ -26,7 +26,6 @@
/* core includes */ /* core includes */
#include <boot_modules.h> #include <boot_modules.h>
#include <core_parent.h>
#include <map_local.h> #include <map_local.h>
#include <platform.h> #include <platform.h>
#include <platform_thread.h> #include <platform_thread.h>
@ -660,5 +659,3 @@ void Platform::wait_for_exit()
sleep_forever(); sleep_forever();
} }
void Core_parent::exit(int exit_value) { }

View File

@ -17,6 +17,7 @@
/* base-internal includes */ /* base-internal includes */
#include <base/internal/native_thread.h> #include <base/internal/native_thread.h>
#include <base/internal/globals.h>
/* Pistachio includes */ /* Pistachio includes */
namespace Pistachio { namespace Pistachio {
@ -52,5 +53,5 @@ void Genode::Thread::_init_platform_thread(size_t, Type type)
{ {
if (type == NORMAL) { return; } if (type == NORMAL) { return; }
native_thread().l4id = main_thread_tid; native_thread().l4id = main_thread_tid;
_thread_cap = env_deprecated()->parent()->main_thread_cap(); _thread_cap = main_thread_cap();
} }

View File

@ -18,7 +18,6 @@
/* core includes */ /* core includes */
#include <boot_modules.h> #include <boot_modules.h>
#include <core_parent.h>
#include <platform.h> #include <platform.h>
#include <map_local.h> #include <map_local.h>
#include <cnode.h> #include <cnode.h>
@ -467,5 +466,3 @@ void Platform::wait_for_exit()
sleep_forever(); sleep_forever();
} }
void Core_parent::exit(int exit_value) { }

View File

@ -1,5 +1,5 @@
SRC_CC += log_console.cc default_log.cc 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 SRC_CC += rpc_cap_alloc.cc
vpath %.cc $(REP_DIR)/src/lib/base vpath %.cc $(REP_DIR)/src/lib/base

View File

@ -17,90 +17,25 @@
/* Genode includes */ /* Genode includes */
#include <base/env.h> #include <base/env.h>
#include <base/heap.h>
#include <ram_session/client.h> /* base-internal includes */
#include <pd_session/client.h> #include <base/internal/globals.h>
#include <rm_session/capability.h>
/* core includes */ /* core includes */
#include <platform.h> #include <platform.h>
#include <core_parent.h>
#include <core_region_map.h> #include <core_region_map.h>
#include <core_pd_session.h>
#include <ram_session_component.h> #include <ram_session_component.h>
#include <synced_ram_session.h>
namespace Genode { void init_stack_area(); } #include <assertion.h>
namespace Genode { namespace Genode {
class Core_env;
/** extern Core_env *core_env();
* 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) { }
/*************************** class Genode::Core_env : public Env_deprecated
** 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: private:
enum { ENTRYPOINT_STACK_SIZE = 2048 * sizeof(Genode::addr_t) }; enum { ENTRYPOINT_STACK_SIZE = 2048 * sizeof(Genode::addr_t) };
@ -117,59 +52,27 @@ namespace Genode {
Ram_session_component _ram_session; Ram_session_component _ram_session;
Synced_ram_session _synced_ram_session { _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<Service> _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: public:
/**
* Constructor
*/
Core_env() Core_env()
: :
_entrypoint(nullptr, ENTRYPOINT_STACK_SIZE, "entrypoint"), _entrypoint(nullptr, ENTRYPOINT_STACK_SIZE, "entrypoint"),
_region_map(_entrypoint), _region_map(_entrypoint),
_ram_session(_entrypoint, _ram_session(_entrypoint,
_ram_resources(), Session::Resources {
Ram_quota { platform()->ram_alloc()->avail() },
Cap_quota { platform()->max_caps() } },
Session::Label("core"), Session::Label("core"),
Session::Diag{false}, Session::Diag{false},
*platform()->ram_alloc(), *platform()->ram_alloc(),
_region_map, _region_map,
Ram_session_component::any_phys_range()), 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(); _ram_session.init_ram_account();
} }
/**
* Destructor
*/
~Core_env() { parent()->exit(0); } ~Core_env() { parent()->exit(0); }
Rpc_entrypoint *entrypoint() { return &_entrypoint; } Rpc_entrypoint *entrypoint() { return &_entrypoint; }
@ -177,43 +80,19 @@ namespace Genode {
** Env_deprecated interface ** ** Env_deprecated interface **
******************************/ ******************************/
Parent *parent() override { return &_core_parent; } Parent *parent() override { return nullptr; }
Ram_session *ram_session() override { return &_synced_ram_session; } Ram_session *ram_session() override { return &_synced_ram_session; }
Ram_session_capability ram_session_cap() override { return _ram_session.cap(); } Ram_session_capability ram_session_cap() override { return _ram_session.cap(); }
Region_map *rm_session() override { return &_region_map; } Region_map *rm_session() override { return &_region_map; }
Pd_session *pd_session() override { return &_pd_session_client; } Pd_session *pd_session() override { return nullptr; }
Allocator *heap() override { log(__func__, ": not implemented"); return nullptr; } Allocator *heap() override { ASSERT_NEVER_CALLED; }
Cpu_session *cpu_session() override { ASSERT_NEVER_CALLED; }
Cpu_session *cpu_session() override Cpu_session_capability cpu_session_cap() override { ASSERT_NEVER_CALLED; }
{ Pd_session_capability pd_session_cap() override { ASSERT_NEVER_CALLED; }
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<Parent>::Raw) override { } void reinit(Capability<Parent>::Raw) override { }
void reinit_main_thread(Capability<Region_map> &) override { } void reinit_main_thread(Capability<Region_map> &) override { }
};
Registry<Service> &services() { return _services; }
};
/**
* Request pointer to static environment of Core
*/
extern Core_env *core_env();
}
#endif /* _CORE__INCLUDE__CORE_ENV_H_ */ #endif /* _CORE__INCLUDE__CORE_ENV_H_ */

View File

@ -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 <parent/parent.h>
#include <base/service.h>
#include <base/allocator.h>
namespace Genode {
template <typename> struct Core_service;
struct Core_parent;
}
template <typename SESSION>
struct Genode::Core_service : Local_service<SESSION>, Registry<Service>::Element
{
Core_service(Registry<Service> &registry,
typename Local_service<SESSION>::Factory &factory)
:
Local_service<SESSION>(factory),
Registry<Service>::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<Client> _id_space;
Allocator &_alloc;
Registry<Service> &_services;
public:
/**
* Constructor
*
* \alloc allocator to be used for allocating core-local
* 'Session_state' objects
*/
Core_parent(Allocator &alloc, Registry<Service> &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_ */

View File

@ -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 <base/rpc_server.h>
#include <base/allocator.h>
#include <pd_session/pd_session.h>
/* core includes */
#include <assertion.h>
#include <signal_source_component.h>
namespace Genode { class Core_pd_session_component; }
class Genode::Core_pd_session_component : public Rpc_object<Pd_session>
{
private:
Rpc_entrypoint &_ep;
public:
/**
* Constructor
*/
Core_pd_session_component(Rpc_entrypoint &ep) : _ep(ep)
{
ep.manage(this);
}
void assign_parent(Capability<Parent> 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<Signal_context>
alloc_context(Signal_source_capability source, unsigned long imprint) override
{
ASSERT_NEVER_CALLED;
}
void free_context(Capability<Signal_context> cap) override
{
ASSERT_NEVER_CALLED;
}
void submit(Capability<Signal_context> 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<Region_map> address_space() override { ASSERT_NEVER_CALLED; }
Capability<Region_map> stack_area() override { ASSERT_NEVER_CALLED; }
Capability<Region_map> linker_area() override { ASSERT_NEVER_CALLED; }
void ref_account(Capability<Pd_session>) override { ASSERT_NEVER_CALLED; }
void transfer_quota(Capability<Pd_session>, 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> native_pd() override { ASSERT_NEVER_CALLED; }
};
#endif /* _CORE__INCLUDE__CORE_PD_SESSION_H_ */

View File

@ -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 <base/service.h>
namespace Genode { template <typename> struct Core_service; }
template <typename SESSION>
struct Genode::Core_service : Local_service<SESSION>, Registry<Service>::Element
{
Core_service(Registry<Service> &registry,
typename Local_service<SESSION>::Factory &factory)
:
Local_service<SESSION>(factory),
Registry<Service>::Element(registry, *this)
{ }
};
#endif /* _CORE__INCLUDE__CORE_SERVICE_H_ */

View File

@ -14,7 +14,7 @@
#ifndef _CORE__INCLUDE__PLATFORM_SERVICES_H_ #ifndef _CORE__INCLUDE__PLATFORM_SERVICES_H_
#define _CORE__INCLUDE__PLATFORM_SERVICES_H_ #define _CORE__INCLUDE__PLATFORM_SERVICES_H_
#include <base/service.h> #include <core_service.h>
namespace Genode { namespace Genode {

View File

@ -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 <ram_session/ram_session.h>
#include <base/lock.h>
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_ */

View File

@ -28,6 +28,7 @@
/* core includes */ /* core includes */
#include <platform.h> #include <platform.h>
#include <core_env.h> #include <core_env.h>
#include <core_service.h>
#include <signal_transmitter.h> #include <signal_transmitter.h>
#include <ram_root.h> #include <ram_root.h>
#include <rom_root.h> #include <rom_root.h>
@ -89,36 +90,7 @@ Platform *Genode::platform_specific()
Platform_generic *Genode::platform() { return platform_specific(); } Platform_generic *Genode::platform() { return platform_specific(); }
/************************* Thread_capability Genode::main_thread_cap() { return Thread_capability(); }
** 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;
}
/**************** /****************
@ -277,7 +249,7 @@ int main()
*/ */
Rpc_entrypoint *e = core_env()->entrypoint(); Rpc_entrypoint *e = core_env()->entrypoint();
Registry<Service> &services = core_env()->services(); static Registry<Service> services;
static Ram_allocator &core_ram_alloc = *core_env()->ram_session(); static Ram_allocator &core_ram_alloc = *core_env()->ram_session();
static Region_map &local_rm = *core_env()->rm_session(); static Region_map &local_rm = *core_env()->rm_session();

View File

@ -26,6 +26,9 @@ namespace Genode {
extern Region_map *env_stack_area_region_map; extern Region_map *env_stack_area_region_map;
extern Ram_session *env_stack_area_ram_session; extern Ram_session *env_stack_area_ram_session;
Thread_capability main_thread_cap();
void init_stack_area();
void init_exception_handling(Env &); void init_exception_handling(Env &);
void init_signal_transmitter(Env &); void init_signal_transmitter(Env &);
void init_cxx_heap(Env &); void init_cxx_heap(Env &);

View File

@ -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 <deprecated/env.h>
/* base-internal includes */
#include <base/internal/globals.h>
#include <base/internal/parent_cap.h>
Genode::Thread_capability Genode::main_thread_cap()
{
return Genode::env_deprecated()->parent()->main_thread_cap();
}