2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* \brief Protection-domain facility
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2009-10-02
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2009-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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode includes */
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
#include <base/log.h>
|
2015-09-29 22:03:03 +02:00
|
|
|
#include <util/flex_iterator.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/* core includes */
|
|
|
|
#include <platform_pd.h>
|
|
|
|
|
|
|
|
using namespace Genode;
|
|
|
|
|
2013-01-11 23:10:21 +01:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/***************************
|
|
|
|
** Public object members **
|
|
|
|
***************************/
|
|
|
|
|
2016-04-20 21:12:57 +02:00
|
|
|
bool Platform_pd::bind_thread(Platform_thread *thread)
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
|
|
|
thread->bind_to_pd(this, _thread_cnt == 0);
|
|
|
|
_thread_cnt++;
|
2016-04-20 21:12:57 +02:00
|
|
|
return true;
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Platform_pd::unbind_thread(Platform_thread *thread)
|
|
|
|
{
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
warning(__func__, "not implemented");
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-14 16:29:07 +02:00
|
|
|
void Platform_pd::assign_parent(Native_capability parent)
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2016-04-14 16:29:07 +02:00
|
|
|
if (!_parent.valid() && parent.valid())
|
|
|
|
_parent = parent;
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-19 20:33:36 +02:00
|
|
|
Platform_pd::Platform_pd(Allocator * md_alloc, char const *label,
|
2015-05-05 08:50:16 +02:00
|
|
|
signed pd_id, bool create)
|
2016-05-19 20:33:36 +02:00
|
|
|
: _thread_cnt(0), _pd_sel(Native_thread::INVALID_INDEX), _label(label) { }
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
Platform_pd::~Platform_pd()
|
2012-08-02 12:20:00 +02:00
|
|
|
{
|
2015-07-02 11:52:57 +02:00
|
|
|
/* invalidate weak pointers to this object */
|
|
|
|
Address_space::lock_for_destruction();
|
|
|
|
|
2015-12-22 11:14:14 +01:00
|
|
|
if (_pd_sel == Native_thread::INVALID_INDEX)
|
|
|
|
return;
|
2012-08-02 12:20:00 +02:00
|
|
|
|
|
|
|
/* Revoke and free cap, pd is gone */
|
|
|
|
Nova::revoke(Nova::Obj_crd(_pd_sel, 0));
|
2013-09-11 10:45:23 +02:00
|
|
|
cap_map()->remove(_pd_sel, 0, false);
|
2012-08-02 12:20:00 +02:00
|
|
|
}
|
2015-09-29 22:03:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
void Platform_pd::flush(addr_t remote_virt, size_t size)
|
|
|
|
{
|
|
|
|
Nova::Rights const revoke_rwx(true, true, true);
|
|
|
|
|
|
|
|
Flexpage_iterator flex(remote_virt, size, remote_virt, size, 0);
|
|
|
|
Flexpage page = flex.page();
|
|
|
|
|
2015-12-22 11:14:14 +01:00
|
|
|
if (pd_sel() == Native_thread::INVALID_INDEX)
|
|
|
|
return;
|
|
|
|
|
2015-09-29 22:03:03 +02:00
|
|
|
while (page.valid()) {
|
|
|
|
Nova::Mem_crd mem(page.addr >> 12, page.log2_order - 12, revoke_rwx);
|
|
|
|
Nova::revoke(mem, true, true, pd_sel());
|
|
|
|
|
|
|
|
page = flex.page();
|
|
|
|
}
|
|
|
|
}
|