2015-10-22 16:17:41 +00:00
|
|
|
/*
|
|
|
|
* \brief Advanced DMA 2
|
|
|
|
* \author Martin Stein
|
|
|
|
* \date 2015-02-05
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 12:23:52 +00:00
|
|
|
* Copyright (C) 2015-2017 Genode Labs GmbH
|
2015-10-22 16:17:41 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2015-10-22 16:17:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <dataspace/client.h>
|
|
|
|
|
|
|
|
/* local includes */
|
|
|
|
#include <adma2.h>
|
|
|
|
|
|
|
|
using namespace Adma2;
|
|
|
|
|
|
|
|
|
2019-01-21 09:48:39 +00:00
|
|
|
Table::Table(Ram_allocator &ram, Region_map &rm)
|
2015-10-22 16:17:41 +00:00
|
|
|
:
|
2017-06-26 13:17:45 +00:00
|
|
|
_ds(ram, rm, _ds_size, UNCACHED),
|
2015-10-22 16:17:41 +00:00
|
|
|
_base_virt(_ds.local_addr<Desc::access_t>()),
|
|
|
|
_base_phys(Dataspace_client(_ds.cap()).phys_addr())
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
int Table::setup_request(size_t const size, addr_t const buffer_phys)
|
|
|
|
{
|
|
|
|
/* sanity check */
|
|
|
|
static size_t constexpr max_size = _max_desc * Desc::Length::max;
|
|
|
|
if (size > max_size) {
|
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 17:07:09 +00:00
|
|
|
Genode::error("block request too large");
|
2015-10-22 16:17:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* install new descriptors till they cover all requested bytes */
|
|
|
|
addr_t consumed = 0;
|
|
|
|
for (int index = 0; consumed < size; index++) {
|
|
|
|
|
|
|
|
/* clamp current request to maximum request size */
|
|
|
|
size_t const remaining = size - consumed;
|
|
|
|
size_t const curr = min(Desc::Length::max, remaining);
|
|
|
|
|
|
|
|
/* assemble new descriptor */
|
|
|
|
Desc::access_t desc = 0;
|
|
|
|
Desc::Address::set(desc, buffer_phys + consumed);
|
|
|
|
Desc::Length::set(desc, curr);
|
|
|
|
Desc::Act1::set(desc, 0);
|
|
|
|
Desc::Act2::set(desc, 1);
|
|
|
|
Desc::Valid::set(desc, 1);
|
|
|
|
|
|
|
|
/* let last descriptor generate transfer-complete signal */
|
|
|
|
if (consumed + curr == size) { Desc::End::set(desc, 1); }
|
|
|
|
|
|
|
|
/* install and account descriptor */
|
|
|
|
_base_virt[index] = desc;
|
|
|
|
consumed += curr;
|
|
|
|
}
|
|
|
|
/* ensure that all descriptor writes were actually executed */
|
2019-12-13 12:14:45 +00:00
|
|
|
asm volatile ("dsb #15" ::: "memory");
|
2015-10-22 16:17:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|