2011-12-22 16:19:25 +01:00
|
|
|
/*
|
2015-07-29 10:58:17 +02:00
|
|
|
* \brief Pager support for Fiasco
|
2011-12-22 16:19:25 +01:00
|
|
|
* \author Christian Helmuth
|
2015-07-29 10:58:17 +02:00
|
|
|
* \date 2006-06-14
|
2011-12-22 16:19:25 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2006-2017 Genode Labs GmbH
|
2011-12-22 16:19:25 +01: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.
|
2011-12-22 16:19:25 +01:00
|
|
|
*/
|
|
|
|
|
2015-07-29 10:58:17 +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>
|
2015-07-29 10:58:17 +02:00
|
|
|
|
2016-03-11 17:32:43 +01:00
|
|
|
/* core includes */
|
2015-07-29 10:58:17 +02:00
|
|
|
#include <ipc_pager.h>
|
2015-06-19 14:58:18 +02:00
|
|
|
#include <pager.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-03-11 17:32:43 +01:00
|
|
|
/* base-internal includes */
|
|
|
|
#include <base/internal/native_thread.h>
|
2016-06-15 15:04:54 +02:00
|
|
|
#include <base/internal/capability_space_tpl.h>
|
2016-03-11 17:32:43 +01:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
namespace Fiasco {
|
|
|
|
#include <l4/sys/ipc.h>
|
|
|
|
#include <l4/sys/syscalls.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace Genode;
|
2015-07-29 10:58:17 +02:00
|
|
|
using namespace Fiasco;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
|
2015-07-29 10:58:17 +02:00
|
|
|
/***************
|
|
|
|
** Ipc_pager **
|
|
|
|
***************/
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-07-29 10:58:17 +02:00
|
|
|
void Ipc_pager::wait_for_fault()
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2015-07-29 10:58:17 +02:00
|
|
|
l4_msgdope_t result;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-07-29 10:58:17 +02:00
|
|
|
do {
|
|
|
|
l4_ipc_wait(&_last,
|
|
|
|
L4_IPC_SHORT_MSG, &_pf_addr, &_pf_ip,
|
|
|
|
L4_IPC_NEVER, &result);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-07-29 10:58:17 +02:00
|
|
|
if (L4_IPC_IS_ERROR(result))
|
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
|
|
|
error(__func__, ": IPC error ", Hex(L4_IPC_ERROR(result)));
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-07-29 10:58:17 +02:00
|
|
|
} while (L4_IPC_IS_ERROR(result));
|
|
|
|
}
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
|
2015-07-29 10:58:17 +02:00
|
|
|
void Ipc_pager::reply_and_wait_for_fault()
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2015-07-29 10:58:17 +02:00
|
|
|
l4_msgdope_t result;
|
|
|
|
|
|
|
|
l4_ipc_reply_and_wait(_last,
|
|
|
|
L4_IPC_SHORT_FPAGE, _reply_mapping.dst_addr(),
|
|
|
|
_reply_mapping.fpage().fpage, &_last,
|
|
|
|
L4_IPC_SHORT_MSG, &_pf_addr, &_pf_ip,
|
|
|
|
L4_IPC_SEND_TIMEOUT_0, &result);
|
|
|
|
|
|
|
|
if (L4_IPC_IS_ERROR(result)) {
|
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
|
|
|
error(__func__, ": IPC error ", Hex(L4_IPC_ERROR(result)));
|
2015-07-29 10:58:17 +02:00
|
|
|
|
|
|
|
/* ignore all errors and wait for next proper message */
|
|
|
|
wait_for_fault();
|
|
|
|
}
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-29 10:58:17 +02:00
|
|
|
void Ipc_pager::acknowledge_wakeup()
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2015-07-29 10:58:17 +02:00
|
|
|
/* answer wakeup call from one of core's region-manager sessions */
|
|
|
|
l4_msgdope_t result;
|
|
|
|
l4_ipc_send(_last, L4_IPC_SHORT_MSG, 0, 0, L4_IPC_SEND_TIMEOUT_0, &result);
|
|
|
|
}
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
|
2015-07-29 10:58:17 +02:00
|
|
|
/**********************
|
|
|
|
** Pager Entrypoint **
|
|
|
|
**********************/
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-08-10 13:34:16 +02:00
|
|
|
Untyped_capability Pager_entrypoint::_pager_object_cap(unsigned long badge)
|
2015-07-29 10:58:17 +02:00
|
|
|
{
|
2016-06-15 15:04:54 +02:00
|
|
|
return Capability_space::import(native_thread().l4id, Rpc_obj_key(badge));
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|