genode/repos/base/src/base/env/context_area.cc

65 lines
1.4 KiB
C++
Raw Normal View History

2011-12-22 16:19:25 +01:00
/*
* \brief Process-local thread-context area
* \author Norman Feske
* \date 2010-01-19
*/
/*
2013-01-10 21:44:47 +01:00
* Copyright (C) 2010-2013 Genode Labs GmbH
2011-12-22 16:19:25 +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.
*/
#include <rm_session/connection.h>
#include <base/env.h>
#include <base/thread.h>
#include <platform_env_common.h>
2011-12-22 16:19:25 +01:00
using namespace Genode;
2011-12-22 16:19:25 +01:00
struct Expanding_rm_connection : Connection<Rm_session>, Expanding_rm_session_client
{
/**
* Constructor
*
* \param start start of the managed VM-region
* \param size size of the VM-region to manage
*/
Expanding_rm_connection(addr_t start = ~0UL, size_t size = 0) :
Connection<Rm_session>(
session("ram_quota=64K, start=0x%p, size=0x%zx",
start, size)),
Expanding_rm_session_client(cap()) { }
};
struct Context_area_rm_session : Expanding_rm_connection
2011-12-22 16:19:25 +01:00
{
Context_area_rm_session()
: Expanding_rm_connection(0, Native_config::context_area_virtual_size())
2011-12-22 16:19:25 +01:00
{
addr_t local_base = Native_config::context_area_virtual_base();
size_t size = Native_config::context_area_virtual_size();
2011-12-22 16:19:25 +01:00
env()->rm_session()->attach_at(dataspace(), local_base, size);
}
};
namespace Genode {
Rm_session *env_context_area_rm_session()
{
static Context_area_rm_session inst;
return &inst;
}
Ram_session *env_context_area_ram_session()
{
return env()->ram_session();
}
}