2015-07-29 10:58:17 +02:00
|
|
|
/*
|
2015-08-10 13:34:16 +02:00
|
|
|
* \brief Generic implementation of pager entrypoint
|
2015-07-29 10:58:17 +02:00
|
|
|
* \author Norman Feske
|
|
|
|
* \author Stefan Kalkowski
|
|
|
|
* \date 2009-03-31
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2009-2017 Genode Labs GmbH
|
2015-07-29 10:58:17 +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.
|
2015-07-29 10:58:17 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Core includes */
|
|
|
|
#include <pager.h>
|
|
|
|
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
|
|
|
|
void Pager_entrypoint::entry()
|
|
|
|
{
|
2015-08-10 13:34:16 +02:00
|
|
|
using Pool = Object_pool<Pager_object>;
|
|
|
|
|
2015-07-29 10:58:17 +02:00
|
|
|
bool reply_pending = false;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
|
|
|
if (reply_pending)
|
|
|
|
_pager.reply_and_wait_for_fault();
|
|
|
|
else
|
|
|
|
_pager.wait_for_fault();
|
|
|
|
|
|
|
|
reply_pending = false;
|
|
|
|
|
2015-08-10 13:34:16 +02:00
|
|
|
Pool::apply(_pager.badge(), [&] (Pager_object *obj) {
|
|
|
|
if (obj) {
|
2017-05-02 16:55:08 +02:00
|
|
|
if (_pager.exception()) {
|
2015-08-10 13:34:16 +02:00
|
|
|
obj->submit_exception_signal();
|
2017-05-02 16:55:08 +02:00
|
|
|
} else {
|
2015-08-10 13:34:16 +02:00
|
|
|
/* send reply if page-fault handling succeeded */
|
|
|
|
reply_pending = !obj->pager(_pager);
|
2016-09-05 11:24:51 +02:00
|
|
|
if (!reply_pending)
|
|
|
|
warning("page-fault, ", *obj,
|
|
|
|
" ip=", Hex(_pager.fault_ip()),
|
|
|
|
" pf-addr=", Hex(_pager.fault_addr()));
|
2017-05-02 16:55:08 +02:00
|
|
|
}
|
2015-08-10 13:34:16 +02:00
|
|
|
} else {
|
2015-07-29 10:58:17 +02:00
|
|
|
|
|
|
|
/*
|
2015-08-10 13:34:16 +02:00
|
|
|
* Prevent threads outside of core to mess with our wake-up
|
|
|
|
* interface. This condition can trigger if a process gets
|
|
|
|
* destroyed which triggered a page fault shortly before getting
|
|
|
|
* killed. In this case, 'wait_for_fault()' returns (because of
|
|
|
|
* the page fault delivery) but the pager-object lookup will fail
|
|
|
|
* (because core removed the process already).
|
2015-07-29 10:58:17 +02:00
|
|
|
*/
|
2015-08-10 13:34:16 +02:00
|
|
|
if (_pager.request_from_core()) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We got a request from one of cores region-manager sessions
|
|
|
|
* to answer the pending page fault of a resolved region-manager
|
|
|
|
* client. Hence, we have to send the page-fault reply to the
|
|
|
|
* specified thread and answer the call of the region-manager
|
|
|
|
* session.
|
|
|
|
*
|
|
|
|
* When called from a region-manager session, we receive the
|
|
|
|
* core-local address of the targeted pager object via the
|
|
|
|
* first message word, which corresponds to the 'fault_ip'
|
|
|
|
* argument of normal page-fault messages.
|
|
|
|
*/
|
|
|
|
obj = reinterpret_cast<Pager_object *>(_pager.fault_ip());
|
|
|
|
|
|
|
|
/* send reply to the calling region-manager session */
|
|
|
|
_pager.acknowledge_wakeup();
|
|
|
|
|
|
|
|
/* answer page fault of resolved pager object */
|
|
|
|
_pager.set_reply_dst(obj->cap());
|
|
|
|
_pager.acknowledge_wakeup();
|
|
|
|
}
|
2015-07-29 10:58:17 +02:00
|
|
|
}
|
2015-08-10 13:34:16 +02:00
|
|
|
});
|
|
|
|
}
|
2015-07-29 10:58:17 +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 &obj)
|
2015-07-29 10:58:17 +02:00
|
|
|
{
|
2015-08-10 13:34:16 +02:00
|
|
|
using Pool = Object_pool<Pager_object>;
|
|
|
|
|
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
|
|
|
Pool::remove(&obj);
|
2015-07-29 10:58:17 +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 &obj)
|
2015-07-29 10:58:17 +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
|
|
|
Native_capability cap = _pager_object_cap(obj.badge());
|
2015-07-29 10:58:17 +02:00
|
|
|
|
|
|
|
/* add server object to object pool */
|
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
|
|
|
obj.cap(cap);
|
|
|
|
insert(&obj);
|
2015-07-29 10:58:17 +02:00
|
|
|
|
|
|
|
/* return capability that uses the object id as badge */
|
|
|
|
return reinterpret_cap_cast<Pager_object>(cap);
|
|
|
|
}
|