2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* \brief Fiasco.OC-specific implementation of the IO_MEM session interface
|
|
|
|
* \author Christian Helmuth
|
|
|
|
* \author Stefan Kalkowski
|
|
|
|
* \date 2006-08-28
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
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
|
|
|
*/
|
|
|
|
|
|
|
|
/* core includes */
|
|
|
|
#include <platform.h>
|
|
|
|
#include <util.h>
|
|
|
|
#include <io_mem_session_component.h>
|
2012-06-18 15:20:31 +02:00
|
|
|
#include <map_local.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
|
|
|
|
void Io_mem_session_component::_unmap_local(addr_t base, size_t size)
|
|
|
|
{
|
|
|
|
platform()->region_alloc()->free(reinterpret_cast<void *>(base));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
addr_t Io_mem_session_component::_map_local(addr_t base, size_t size)
|
|
|
|
{
|
|
|
|
/* align large I/O dataspaces on a super-page boundary within core */
|
|
|
|
size_t alignment = (size >= get_super_page_size()) ? get_super_page_size_log2()
|
|
|
|
: get_page_size_log2();
|
|
|
|
|
|
|
|
/* find appropriate region for mapping */
|
|
|
|
void *local_base = 0;
|
2016-05-11 18:21:47 +02:00
|
|
|
if (platform()->region_alloc()->alloc_aligned(size, &local_base, alignment).error())
|
2011-12-22 16:19:25 +01:00
|
|
|
return 0;
|
|
|
|
|
2012-06-18 15:20:31 +02:00
|
|
|
if (!map_local_io(base, (addr_t)local_base, size >> get_page_size_log2())) {
|
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("map_local_io failed");
|
2012-06-18 15:20:31 +02:00
|
|
|
return 0;
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return (addr_t)local_base;
|
|
|
|
}
|