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.
This commit is contained in:
Norman Feske
2012-06-18 15:20:31 +02:00
parent 896d12d0b8
commit 288fd4e56e
28 changed files with 187 additions and 124 deletions

View File

@ -78,7 +78,7 @@ class Context_area_ram_session : public Genode::Ram_session
{
public:
Genode::Ram_dataspace_capability alloc(Genode::size_t size) {
Genode::Ram_dataspace_capability alloc(Genode::size_t size, bool) {
return Genode::Ram_dataspace_capability(); }
void free(Genode::Ram_dataspace_capability) { }

View File

@ -50,8 +50,9 @@ namespace Genode {
/**
* Constructor
*/
Dataspace_component(size_t size, addr_t addr, bool writable,
Dataspace_owner * owner = 0)
Dataspace_component(size_t size, addr_t addr,
bool /* write_combined */, bool writable,
Dataspace_owner * owner)
: _size(size), _addr(addr), _writable(writable),
_owner(owner) { }
@ -67,7 +68,7 @@ namespace Genode {
*/
Dataspace_component(size_t size, addr_t core_local_addr,
addr_t phys_addr, bool write_combined,
bool writable, Dataspace_owner * _owner = 0)
bool writable, Dataspace_owner * _owner)
: _size(size), _addr(phys_addr), _owner(_owner)
{
PWRN("Should only be used for IOMEM and not within Linux.");

View File

@ -62,7 +62,7 @@ Rom_session_component::Rom_session_component(Rom_fs *rom_fs,
if (fsize == 0)
throw Root::Invalid_args();
_ds = Dataspace_component(fsize, 0, false);
_ds = Dataspace_component(fsize, 0, false, false, 0);
_ds.fname(fname_buf);
Dataspace_capability ds_cap = _ds_ep->manage(&_ds);