2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* \brief Core-local mapping
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2010-02-15
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2010-2013 Genode Labs GmbH
|
2011-12-22 16:19:25 +01:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CORE__INCLUDE__MAP_LOCAL_H_
|
|
|
|
#define _CORE__INCLUDE__MAP_LOCAL_H_
|
|
|
|
|
|
|
|
/* core includes */
|
|
|
|
#include <platform.h>
|
|
|
|
#include <util.h>
|
|
|
|
|
|
|
|
/* Fiasco includes */
|
|
|
|
namespace Fiasco {
|
|
|
|
#include <l4/sys/ipc.h>
|
|
|
|
#include <l4/sys/syscalls.h>
|
|
|
|
#include <l4/sys/kdebug.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Genode {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Map page locally within core
|
|
|
|
*
|
|
|
|
* On Fiasco, all mapping originate from virtual addresses. At startup,
|
|
|
|
* core obtains the whole memory sigma0 in a one-to-one fashion. Hence,
|
|
|
|
* core-local addresses normally correspond to physical addresses.
|
|
|
|
*
|
|
|
|
* \param from_addr core-virtual source address
|
|
|
|
* \param to_addr core-virtual destination address
|
|
|
|
* \param num_pages number of pages to remap
|
|
|
|
*/
|
|
|
|
inline bool map_local(addr_t from_addr, addr_t to_addr, size_t num_pages)
|
|
|
|
{
|
2016-03-08 17:44:54 +01:00
|
|
|
Fiasco::l4_threadid_t core_pager = platform_specific()->core_pager()->native_thread_id();
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
addr_t offset = 0;
|
|
|
|
size_t page_size = get_page_size();
|
|
|
|
size_t page_size_log2 = get_page_size_log2();
|
|
|
|
for (unsigned i = 0; i < num_pages; i++, offset += page_size) {
|
|
|
|
|
|
|
|
using namespace Fiasco;
|
|
|
|
|
|
|
|
/* perform echo request to the core pager */
|
|
|
|
l4_umword_t dummy = 0;
|
|
|
|
l4_msgdope_t ipc_result;
|
|
|
|
l4_fpage_t from_fpage = l4_fpage(from_addr + offset,
|
|
|
|
page_size_log2, true, false);
|
|
|
|
enum { ECHO_LOCAL_MAP_REQUEST = 0 };
|
|
|
|
l4_ipc_call(core_pager, L4_IPC_SHORT_MSG,
|
|
|
|
from_fpage.raw, /* normally page-fault addr */
|
|
|
|
ECHO_LOCAL_MAP_REQUEST, /* normally page-fault IP */
|
|
|
|
L4_IPC_MAPMSG(to_addr + offset, page_size_log2),
|
|
|
|
&dummy, &dummy,
|
|
|
|
L4_IPC_NEVER, &ipc_result);
|
|
|
|
|
|
|
|
if (L4_IPC_IS_ERROR(ipc_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
|
|
|
warning("could not locally remap ", Hex(from_addr), " "
|
|
|
|
"to ", Hex(to_addr), ", "
|
|
|
|
"error code is ", L4_IPC_ERROR(ipc_result));
|
2011-12-22 16:19:25 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-10-15 22:11:56 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unmap pages locally within core
|
|
|
|
*
|
|
|
|
* \param virt core-local address
|
|
|
|
* \param num_pages number of pages to unmap
|
|
|
|
*/
|
|
|
|
inline void unmap_local(addr_t virt, size_t num_pages)
|
|
|
|
{
|
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("unmap_local() called - not implemented yet");
|
2012-10-15 22:11:56 +02:00
|
|
|
}
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _CORE__INCLUDE__MAP_LOCAL_H_ */
|