genode/base/include/ram_session/client.h
Norman Feske 288fd4e56e Add support for allocating DMA memory
This patch extends the RAM session interface with the ability to
allocate DMA buffers. The client specifies the type of RAM dataspace to
allocate via the new 'cached' argument of the 'Ram_session::alloc()'
function. By default, 'cached' is true, which correponds to the common
case and the original behavior. When setting 'cached' to 'false', core
takes the precautions needed to register the memory as uncached in the
page table of each process that has the dataspace attached.

Currently, the support for allocating DMA buffers is implemented for
Fiasco.OC only. On x86 platforms, it is generally not needed. But on
platforms with more relaxed cache coherence (such as ARM), user-level
device drivers should always use uncacheable memory for DMA transactions.
2012-06-20 09:17:48 +02:00

46 lines
1.2 KiB
C++

/*
* \brief Client-side ram session interface
* \author Norman Feske
* \date 2006-05-31
*/
/*
* Copyright (C) 2006-2012 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__RAM_SESSION__CLIENT_H_
#define _INCLUDE__RAM_SESSION__CLIENT_H_
#include <ram_session/capability.h>
#include <ram_session/ram_session.h>
#include <base/rpc_client.h>
namespace Genode {
struct Ram_session_client : Rpc_client<Ram_session>
{
explicit Ram_session_client(Ram_session_capability session)
: Rpc_client<Ram_session>(session) { }
Ram_dataspace_capability alloc(size_t size, bool cached = true) {
return call<Rpc_alloc>(size, cached); }
void free(Ram_dataspace_capability ds) { call<Rpc_free>(ds); }
int ref_account(Ram_session_capability ram_session) {
return call<Rpc_ref_account>(ram_session); }
int transfer_quota(Ram_session_capability ram_session, size_t amount) {
return call<Rpc_transfer_quota>(ram_session, amount); }
size_t quota() { return call<Rpc_quota>(); }
size_t used() { return call<Rpc_used>(); }
};
}
#endif /* _INCLUDE__RAM_SESSION__CLIENT_H_ */