This patch cleans up the thread API and comes with the following noteworthy changes: - Introduced Cpu_session::Weight type that replaces a formerly used plain integer value to prevent the accidental mix-up of arguments. - The enum definition of Cpu_session::DEFAULT_WEIGHT moved to Cpu_session::Weight::DEFAULT_WEIGHT - New Thread constructor that takes a 'Env &' as first argument. The original constructors are now marked as deprecated. For the common use case where the default 'Weight' and 'Affinity' are used, a shortcut is provided. In the long term, those two constructors should be the only ones to remain. - The former 'Thread<>' class template has been renamed to 'Thread_deprecated'. - The former 'Thread_base' class is now called 'Thread'. - The new 'name()' accessor returns the thread's name as 'Name' object as centrally defined via 'Cpu_session::Name'. It is meant to replace the old-fashioned 'name' method that takes a buffer and size as arguments. - Adaptation of the thread test to the new API Issue #1954
97 lines
2.4 KiB
C++
97 lines
2.4 KiB
C++
/*
|
|
* \brief RM- and pager implementations specific for base-hw and core
|
|
* \author Martin Stein
|
|
* \author Stefan Kalkowski
|
|
* \date 2012-02-12
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2012-2013 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU General Public License version 2.
|
|
*/
|
|
|
|
/* core includes */
|
|
#include <pager.h>
|
|
#include <rm_session_component.h>
|
|
#include <platform.h>
|
|
#include <platform_pd.h>
|
|
#include <platform_thread.h>
|
|
#include <translation_table.h>
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
/***************
|
|
** Rm_client **
|
|
***************/
|
|
|
|
void Rm_client::unmap(addr_t, addr_t virt_base, size_t size)
|
|
{
|
|
Locked_ptr<Address_space> locked_address_space(_address_space);
|
|
|
|
if (locked_address_space.is_valid())
|
|
locked_address_space->flush(virt_base, size);
|
|
}
|
|
|
|
|
|
/**********************
|
|
** Pager_entrypoint **
|
|
**********************/
|
|
|
|
void Pager_entrypoint::entry()
|
|
{
|
|
while (1)
|
|
{
|
|
/* receive fault */
|
|
if (Kernel::await_signal(_cap.dst())) continue;
|
|
|
|
Untyped_capability cap =
|
|
(*(Pager_object**)Thread::myself()->utcb()->data())->cap();
|
|
|
|
/*
|
|
* Synchronize access and ensure that the object is still managed
|
|
*
|
|
* FIXME: The implicit lookup of the oject isn't needed.
|
|
*/
|
|
auto lambda = [&] (Pager_object *po) {
|
|
if (!po) return;
|
|
|
|
/* fetch fault data */
|
|
Platform_thread * const pt = (Platform_thread *)po->badge();
|
|
if (!pt) {
|
|
PWRN("failed to get platform thread of faulter");
|
|
return;
|
|
}
|
|
|
|
_fault.ip = pt->kernel_object()->ip;
|
|
_fault.addr = pt->kernel_object()->fault_addr();
|
|
_fault.writes = pt->kernel_object()->fault_writes();
|
|
_fault.signal = pt->kernel_object()->fault_signal();
|
|
|
|
/* try to resolve fault directly via local region managers */
|
|
if (po->pager(*this)) return;
|
|
|
|
/* apply mapping that was determined by the local region managers */
|
|
{
|
|
Locked_ptr<Address_space> locked_ptr(pt->address_space());
|
|
if (!locked_ptr.is_valid()) return;
|
|
|
|
Hw::Address_space * as = static_cast<Hw::Address_space*>(&*locked_ptr);
|
|
Page_flags const flags =
|
|
Page_flags::apply_mapping(_mapping.writable,
|
|
_mapping.cacheable,
|
|
_mapping.io_mem);
|
|
as->insert_translation(_mapping.virt_address,
|
|
_mapping.phys_address,
|
|
1 << _mapping.size_log2, flags);
|
|
}
|
|
|
|
/* let pager object go back to no-fault state */
|
|
po->wake_up();
|
|
};
|
|
apply(cap, lambda);
|
|
}
|
|
}
|