2012-05-30 20:13:09 +02:00
|
|
|
/*
|
|
|
|
* \brief Pager implementations that are specific for the HW-core
|
|
|
|
* \author Martin Stein
|
|
|
|
* \date 2012-03-29
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2012-2017 Genode Labs GmbH
|
2012-05-30 20:13:09 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2012-05-30 20:13:09 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* 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>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2015-03-10 12:06:55 +01:00
|
|
|
/* core includes*/
|
2015-06-19 14:58:18 +02:00
|
|
|
#include <pager.h>
|
2015-03-10 12:06:55 +01:00
|
|
|
#include <platform_thread.h>
|
|
|
|
#include <platform_pd.h>
|
2017-03-01 15:28:13 +01:00
|
|
|
#include <region_map_component.h>
|
2015-03-10 12:06:55 +01:00
|
|
|
|
2016-06-15 15:04:54 +02:00
|
|
|
/* base-internal includes */
|
|
|
|
#include <base/internal/capability_space.h>
|
|
|
|
|
2012-05-30 20:13:09 +02:00
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
|
2013-11-14 13:29:47 +01:00
|
|
|
/***************
|
|
|
|
** Ipc_pager **
|
|
|
|
***************/
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2013-11-14 13:29:47 +01:00
|
|
|
addr_t Ipc_pager::fault_ip() const { return _fault.ip; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2013-11-14 13:29:47 +01:00
|
|
|
addr_t Ipc_pager::fault_addr() const { return _fault.addr; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-10-25 18:57:58 +02:00
|
|
|
bool Ipc_pager::write_fault() const {
|
|
|
|
return _fault.type == Kernel::Thread_fault::WRITE; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-10-25 18:57:58 +02:00
|
|
|
bool Ipc_pager::exec_fault() const {
|
|
|
|
return _fault.type == Kernel::Thread_fault::EXEC; }
|
2017-10-13 16:23:10 +02:00
|
|
|
|
2013-11-14 13:29:47 +01:00
|
|
|
void Ipc_pager::set_reply_mapping(Mapping m) { _mapping = m; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
|
2013-11-14 13:29:47 +01:00
|
|
|
/******************
|
|
|
|
** Pager_object **
|
|
|
|
******************/
|
|
|
|
|
2015-06-22 14:44:28 +02:00
|
|
|
void Pager_object::wake_up()
|
|
|
|
{
|
2017-03-01 15:28:13 +01:00
|
|
|
Platform_thread * const pt = (Platform_thread *)badge();
|
|
|
|
if (pt) pt->restart();
|
2015-06-22 14:44:28 +02:00
|
|
|
}
|
2013-11-14 13:29:47 +01:00
|
|
|
|
2019-10-16 15:07:11 +02:00
|
|
|
void Pager_object::start_paging(Kernel_object<Kernel::Signal_receiver> & receiver)
|
2015-06-22 14:44:28 +02:00
|
|
|
{
|
|
|
|
using Object = Kernel_object<Kernel::Signal_context>;
|
|
|
|
using Entry = Object_pool<Pager_object>::Entry;
|
|
|
|
|
2019-10-16 15:07:11 +02:00
|
|
|
create(*receiver, (unsigned long)this);
|
2015-06-22 14:44:28 +02:00
|
|
|
Entry::cap(Object::_cap);
|
|
|
|
}
|
2013-11-14 13:29:47 +01:00
|
|
|
|
|
|
|
void Pager_object::exception_handler(Signal_context_capability) { }
|
|
|
|
|
2015-03-10 12:06:55 +01:00
|
|
|
void Pager_object::unresolved_page_fault_occurred()
|
|
|
|
{
|
|
|
|
Platform_thread * const pt = (Platform_thread *)badge();
|
|
|
|
if (pt && pt->pd())
|
2016-09-05 11:24:51 +02:00
|
|
|
warning("page fault, pager_object: pd='", pt->pd()->label(),
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
"' thread='", pt->label(), "' ", pt->fault_info());
|
2016-09-05 11:24:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Pager_object::print(Output &out) const
|
|
|
|
{
|
|
|
|
Platform_thread * const pt = (Platform_thread *)badge();
|
|
|
|
if (pt && pt->pd())
|
|
|
|
Genode::print(out, "pager_object: pd='", pt->pd()->label(),
|
|
|
|
"' thread='", pt->label(), "'");
|
2015-03-10 12:06:55 +01:00
|
|
|
}
|
2013-08-30 16:02:31 +02:00
|
|
|
|
2016-04-20 21:12:57 +02:00
|
|
|
Pager_object::Pager_object(Cpu_session_capability cpu_session_cap,
|
2017-08-21 15:34:27 +02:00
|
|
|
Thread_capability thread_cap, addr_t const badge,
|
2016-09-05 11:24:51 +02:00
|
|
|
Affinity::Location, Session_label const &,
|
|
|
|
Cpu_session::Name const &)
|
2016-04-20 21:12:57 +02:00
|
|
|
:
|
|
|
|
Object_pool<Pager_object>::Entry(Kernel_object<Kernel::Signal_context>::_cap),
|
|
|
|
_badge(badge), _cpu_session_cap(cpu_session_cap), _thread_cap(thread_cap)
|
2013-11-14 13:29:47 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
** Pager_entrypoint **
|
|
|
|
**********************/
|
2013-10-18 17:01:51 +02:00
|
|
|
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
void Pager_entrypoint::dissolve(Pager_object &o)
|
2013-11-25 22:44:51 +01:00
|
|
|
{
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
Kernel::kill_signal_context(Capability_space::capid(o.cap()));
|
|
|
|
remove(&o);
|
2013-11-25 22:44:51 +01:00
|
|
|
}
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2013-10-18 17:01:51 +02:00
|
|
|
|
2016-01-19 20:24:22 +01:00
|
|
|
Pager_entrypoint::Pager_entrypoint(Rpc_cap_factory &)
|
2016-05-04 12:27:17 +02:00
|
|
|
: Thread_deprecated<PAGER_EP_STACK_SIZE>("pager_ep"),
|
2019-10-16 15:07:11 +02:00
|
|
|
_kobj(true)
|
2015-07-29 10:58:17 +02:00
|
|
|
{ start(); }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
Pager_capability Pager_entrypoint::manage(Pager_object &o)
|
2013-11-14 13:29:47 +01:00
|
|
|
{
|
2019-10-16 15:07:11 +02:00
|
|
|
o.start_paging(_kobj);
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
insert(&o);
|
|
|
|
return reinterpret_cap_cast<Pager_object>(o.cap());
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|