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
123 lines
2.9 KiB
C++
123 lines
2.9 KiB
C++
/*
|
|
* \brief Pager implementations that are specific for the HW-core
|
|
* \author Martin Stein
|
|
* \date 2012-03-29
|
|
*/
|
|
|
|
/*
|
|
* 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.
|
|
*/
|
|
|
|
/* Genode includes */
|
|
#include <base/printf.h>
|
|
|
|
/* core includes*/
|
|
#include <pager.h>
|
|
#include <platform_thread.h>
|
|
#include <platform_pd.h>
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
/*************
|
|
** Mapping **
|
|
*************/
|
|
|
|
Mapping::Mapping(addr_t const va, addr_t const pa,
|
|
Cache_attribute const c, bool const io,
|
|
unsigned const sl2, bool const w)
|
|
:
|
|
virt_address(va), phys_address(pa), cacheable(c),
|
|
io_mem(io), size_log2(sl2), writable(w)
|
|
{ }
|
|
|
|
|
|
Mapping::Mapping()
|
|
:
|
|
virt_address(0), phys_address(0), cacheable(CACHED),
|
|
io_mem(0), size_log2(0), writable(0)
|
|
{ }
|
|
|
|
|
|
void Mapping::prepare_map_operation() { }
|
|
|
|
|
|
/***************
|
|
** Ipc_pager **
|
|
***************/
|
|
|
|
addr_t Ipc_pager::fault_ip() const { return _fault.ip; }
|
|
|
|
addr_t Ipc_pager::fault_addr() const { return _fault.addr; }
|
|
|
|
bool Ipc_pager::is_write_fault() const { return _fault.writes; }
|
|
|
|
void Ipc_pager::set_reply_mapping(Mapping m) { _mapping = m; }
|
|
|
|
|
|
/******************
|
|
** Pager_object **
|
|
******************/
|
|
|
|
void Pager_object::wake_up()
|
|
{
|
|
using Object = Kernel_object<Kernel::Signal_context>;
|
|
Kernel::ack_signal(Object::_cap.dst());
|
|
}
|
|
|
|
void Pager_object::start_paging(Kernel::Signal_receiver * receiver)
|
|
{
|
|
using Object = Kernel_object<Kernel::Signal_context>;
|
|
using Entry = Object_pool<Pager_object>::Entry;
|
|
|
|
create(receiver, (unsigned long)this);
|
|
Entry::cap(Object::_cap);
|
|
}
|
|
|
|
void Pager_object::exception_handler(Signal_context_capability) { }
|
|
|
|
void Pager_object::unresolved_page_fault_occurred()
|
|
{
|
|
Platform_thread * const pt = (Platform_thread *)badge();
|
|
if (pt && pt->pd())
|
|
PERR("%s -> %s: unresolved pagefault at ip=%lx sp=%lx fault address=%lx",
|
|
pt->pd()->label(), pt->label(), pt->kernel_object()->ip,
|
|
pt->kernel_object()->sp, pt->kernel_object()->fault_addr());
|
|
}
|
|
|
|
Pager_object::Pager_object(Cpu_session_capability cpu_session_cap,
|
|
Thread_capability thread_cap, unsigned const badge,
|
|
Affinity::Location)
|
|
:
|
|
Object_pool<Pager_object>::Entry(Kernel_object<Kernel::Signal_context>::_cap),
|
|
_badge(badge), _cpu_session_cap(cpu_session_cap), _thread_cap(thread_cap)
|
|
{ }
|
|
|
|
|
|
/**********************
|
|
** Pager_entrypoint **
|
|
**********************/
|
|
|
|
void Pager_entrypoint::dissolve(Pager_object * const o)
|
|
{
|
|
remove(o);
|
|
}
|
|
|
|
|
|
Pager_entrypoint::Pager_entrypoint(Rpc_cap_factory &)
|
|
: Thread_deprecated<PAGER_EP_STACK_SIZE>("pager_ep"),
|
|
Kernel_object<Kernel::Signal_receiver>(true)
|
|
{ start(); }
|
|
|
|
|
|
Pager_capability Pager_entrypoint::manage(Pager_object * const o)
|
|
{
|
|
o->start_paging(kernel_object());
|
|
insert(o);
|
|
return reinterpret_cap_cast<Pager_object>(o->cap());
|
|
}
|
|
|