2012-02-15 19:14:37 +01:00
|
|
|
/*
|
|
|
|
* \brief Environment reinitialization
|
|
|
|
* \author Norman Feske
|
2014-01-28 14:30:36 +01:00
|
|
|
* \author Martin Stein
|
2012-02-15 19:14:37 +01:00
|
|
|
* \date 2012-02-16
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2012-2013 Genode Labs GmbH
|
2012-02-15 19:14:37 +01:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
2016-01-20 18:27:18 +01:00
|
|
|
/* base-internal includes */
|
|
|
|
#include <base/internal/platform_env.h>
|
2014-01-28 14:30:36 +01:00
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <util/construct_at.h>
|
2012-02-18 01:42:24 +01:00
|
|
|
#include <base/crt0.h>
|
2014-01-28 14:30:36 +01:00
|
|
|
#include <rm_session/connection.h>
|
|
|
|
|
|
|
|
void prepare_reinit_main_thread();
|
2012-02-15 19:14:37 +01:00
|
|
|
|
2014-01-28 14:30:36 +01:00
|
|
|
void reinit_main_thread();
|
2012-02-15 19:14:37 +01:00
|
|
|
|
2014-01-28 14:30:36 +01:00
|
|
|
namespace Genode
|
|
|
|
{
|
|
|
|
extern bool inhibit_tracing;
|
|
|
|
|
|
|
|
Rm_session * env_context_area_rm_session();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Genode::Platform_env::reinit(Native_capability::Dst dst,
|
|
|
|
long local_name)
|
2012-02-15 19:14:37 +01:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This function is unused during the normal operation of Genode. It is
|
|
|
|
* relevant only for implementing fork semantics such as provided by the
|
|
|
|
* Noux execution environment.
|
|
|
|
*
|
|
|
|
* The function is called by the freshly created process right after the
|
2012-02-18 01:42:24 +01:00
|
|
|
* fork happened.
|
2012-02-15 19:14:37 +01:00
|
|
|
*
|
|
|
|
* The existing 'Platform_env' object contains capabilities that are
|
|
|
|
* meaningful for the forking process but not the new process. Before the
|
|
|
|
* the environment can be used, it must be reinitialized with the resources
|
|
|
|
* provided by the actual parent.
|
|
|
|
*/
|
2012-02-18 01:42:24 +01:00
|
|
|
|
2014-01-28 14:30:36 +01:00
|
|
|
/* avoid RPCs by the tracing framework as long as we have no valid env */
|
|
|
|
inhibit_tracing = true;
|
|
|
|
|
|
|
|
/* do platform specific preparation */
|
|
|
|
prepare_reinit_main_thread();
|
|
|
|
|
2012-02-18 01:42:24 +01:00
|
|
|
/*
|
|
|
|
* Patch new parent capability into the original location as specified by
|
|
|
|
* the linker script.
|
|
|
|
*/
|
2012-03-26 14:32:16 +02:00
|
|
|
Native_capability::Raw *raw = (Native_capability::Raw *)(&_parent_cap);
|
2014-01-28 14:30:36 +01:00
|
|
|
raw->dst = dst;
|
|
|
|
raw->local_name = local_name;
|
2012-02-18 01:42:24 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Re-initialize 'Platform_env' members
|
|
|
|
*/
|
2014-01-28 14:30:36 +01:00
|
|
|
Expanding_parent_client * const p = &_parent_client;
|
|
|
|
construct_at<Expanding_parent_client>(p, parent_cap(), *this);
|
|
|
|
construct_at<Resources>(&_resources, _parent_client);
|
2012-02-15 19:14:37 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Keep information about dynamically allocated memory but use the new
|
|
|
|
* resources as backing store. Note that the capabilites of the already
|
|
|
|
* allocated backing-store dataspaces are rendered meaningless. But this is
|
|
|
|
* no problem because they are used by the 'Heap' destructor only, which is
|
|
|
|
* never called for heap instance of 'Platform_env'.
|
|
|
|
*/
|
|
|
|
_heap.reassign_resources(&_resources.ram, &_resources.rm);
|
|
|
|
}
|
2014-01-28 14:30:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Genode::Platform_env::
|
|
|
|
reinit_main_thread(Rm_session_capability & context_area_rm)
|
|
|
|
{
|
|
|
|
/* reinitialize context area RM session */
|
|
|
|
Rm_session * const rms = env_context_area_rm_session();
|
|
|
|
Rm_session_client * const rmc = dynamic_cast<Rm_session_client *>(rms);
|
|
|
|
construct_at<Rm_session_client>(rmc, context_area_rm);
|
|
|
|
|
|
|
|
/* reinitialize main-thread object */
|
|
|
|
::reinit_main_thread();
|
2014-02-21 18:25:54 +01:00
|
|
|
|
|
|
|
/* re-enable tracing */
|
|
|
|
inhibit_tracing = false;
|
2014-01-28 14:30:36 +01:00
|
|
|
}
|