base: introduce caching attributes (fix #1184)

On ARM it's relevant to not only distinguish between ordinary cached memory
and write-combined one, but also having non-cached memory too. To insert the
appropriated page table entries e.g.: in the base-hw kernel, we need to preserve
the information about the kind of memory from allocation until the pager
resolves a page fault. Therefore, this commit introduces a new Cache_attribute
type, and replaces the write_combined boolean with the new type where necessary.
This commit is contained in:
Stefan Kalkowski 2014-06-19 16:37:31 +02:00 committed by Norman Feske
parent 9580954d81
commit 786fe805da
60 changed files with 216 additions and 160 deletions

View File

@ -14,6 +14,7 @@
#ifndef _INCLUDE__BASE__IPC_PAGER_H_ #ifndef _INCLUDE__BASE__IPC_PAGER_H_
#define _INCLUDE__BASE__IPC_PAGER_H_ #define _INCLUDE__BASE__IPC_PAGER_H_
#include <base/cache.h>
#include <base/ipc.h> #include <base/ipc.h>
#include <base/stdint.h> #include <base/stdint.h>
#include <base/native_types.h> #include <base/native_types.h>
@ -37,7 +38,7 @@ namespace Genode {
* Constructor * Constructor
*/ */
Mapping(addr_t dst_addr, addr_t src_addr, Mapping(addr_t dst_addr, addr_t src_addr,
bool write_combined, bool io_mem, Cache_attribute const cacheability, bool io_mem,
unsigned l2size = PAGE_SIZE_LOG2, unsigned l2size = PAGE_SIZE_LOG2,
bool rw = true) bool rw = true)
: :

View File

@ -58,6 +58,15 @@ extern void *memcpy(void *dest, const void *src, __SIZE_TYPE__);
#undef max #undef max
#endif #endif
#undef printf #undef printf
/*
* Turn '#define cacheable' (as defined in the codezero headers) into an enum
* value. Otherwise, the define will conflict with variables named 'cacheable'.
*/
enum { _codezero_cacheable = cacheable /* #define value */ };
#undef cacheable
enum { cacheable = _codezero_cacheable };
} } } }
namespace Codezero { namespace Codezero {

View File

@ -15,6 +15,7 @@
#define _INCLUDE__BASE__IPC_PAGER_H_ #define _INCLUDE__BASE__IPC_PAGER_H_
/* Genode includes */ /* Genode includes */
#include <base/cache.h>
#include <base/ipc.h> #include <base/ipc.h>
#include <base/stdint.h> #include <base/stdint.h>
#include <base/native_types.h> #include <base/native_types.h>
@ -41,14 +42,14 @@ namespace Genode {
* Constructor * Constructor
*/ */
Mapping(addr_t dst_addr, addr_t src_addr, Mapping(addr_t dst_addr, addr_t src_addr,
bool write_combined, bool io_mem, Cache_attribute cacheability, bool io_mem,
unsigned l2size = L4_LOG2_PAGESIZE, unsigned l2size = L4_LOG2_PAGESIZE,
bool rw = true, bool grant = false) bool rw = true, bool grant = false)
: :
_dst_addr(dst_addr), _dst_addr(dst_addr),
_fpage(Fiasco::l4_fpage(src_addr, l2size, rw, grant)) _fpage(Fiasco::l4_fpage(src_addr, l2size, rw, grant))
{ {
if (write_combined) if (cacheability == WRITE_COMBINED)
_fpage.fp.cache = Fiasco::L4_FPAGE_BUFFERABLE; _fpage.fp.cache = Fiasco::L4_FPAGE_BUFFERABLE;
} }

View File

@ -16,6 +16,7 @@
#define _INCLUDE__BASE__IPC_PAGER_H_ #define _INCLUDE__BASE__IPC_PAGER_H_
/* Genode includes */ /* Genode includes */
#include <base/cache.h>
#include <base/ipc.h> #include <base/ipc.h>
#include <base/stdint.h> #include <base/stdint.h>
#include <base/native_types.h> #include <base/native_types.h>
@ -33,12 +34,13 @@ namespace Genode {
{ {
private: private:
addr_t _dst_addr; addr_t _dst_addr;
addr_t _src_addr; addr_t _src_addr;
bool _write_combined; Cache_attribute _cacheability;
unsigned _log2size; bool _iomem;
bool _rw; unsigned _log2size;
bool _grant; bool _rw;
bool _grant;
public: public:
@ -46,34 +48,30 @@ namespace Genode {
* Constructor * Constructor
*/ */
Mapping(addr_t dst_addr, addr_t src_addr, Mapping(addr_t dst_addr, addr_t src_addr,
bool write_combined, bool io_mem, Cache_attribute c, bool io_mem,
unsigned l2size = L4_LOG2_PAGESIZE, unsigned l2size = L4_LOG2_PAGESIZE,
bool rw = true, bool grant = false) bool rw = true, bool grant = false)
: _dst_addr(dst_addr), _src_addr(src_addr), : _dst_addr(dst_addr), _src_addr(src_addr),
_write_combined(write_combined), _log2size(l2size), _cacheability(c), _iomem(io_mem), _log2size(l2size),
_rw(rw), _grant(grant) { } _rw(rw), _grant(grant) { }
/** /**
* Construct invalid flexpage * Construct invalid flexpage
*/ */
Mapping() : _dst_addr(0), _src_addr(0), _write_combined(false), Mapping() : _dst_addr(0), _src_addr(0), _cacheability(UNCACHED),
_log2size(0), _rw(false), _grant(false) { } _iomem(false), _log2size(0), _rw(false), _grant(false) { }
Fiasco::l4_umword_t dst_addr() const { return _dst_addr; } Fiasco::l4_umword_t dst_addr() const { return _dst_addr; }
bool grant() const { return _grant; } bool grant() const { return _grant; }
Fiasco::l4_fpage_t fpage() const Fiasco::l4_fpage_t fpage() const
{ {
// TODO: write combined
//if (write_combined)
// _fpage.fp.cache = Fiasco::L4_FPAGE_BUFFERABLE;
unsigned char rights = _rw ? Fiasco::L4_FPAGE_RWX : Fiasco::L4_FPAGE_RX; unsigned char rights = _rw ? Fiasco::L4_FPAGE_RWX : Fiasco::L4_FPAGE_RX;
return Fiasco::l4_fpage(_src_addr, _log2size, rights); return Fiasco::l4_fpage(_src_addr, _log2size, rights);
} }
bool write_combined() const { return _write_combined; } Cache_attribute cacheability() const { return _cacheability; }
bool iomem() { return _iomem; }
/** /**
* Prepare map operation is not needed on Fiasco.OC, since we clear the * Prepare map operation is not needed on Fiasco.OC, since we clear the
* dataspace before this function is called. * dataspace before this function is called.

View File

@ -87,12 +87,20 @@ void Ipc_pager::reply_and_wait_for_fault()
l4_umword_t grant = _reply_mapping.grant() ? L4_MAP_ITEM_GRANT : 0; l4_umword_t grant = _reply_mapping.grant() ? L4_MAP_ITEM_GRANT : 0;
l4_utcb_mr()->mr[0] = _reply_mapping.dst_addr() | L4_ITEM_MAP | grant; l4_utcb_mr()->mr[0] = _reply_mapping.dst_addr() | L4_ITEM_MAP | grant;
/* switch (_reply_mapping.cacheability()) {
* XXX Does L4_FPAGE_BUFFERABLE imply L4_FPAGE_UNCACHEABLE? case WRITE_COMBINED:
*/
if (_reply_mapping.write_combined())
l4_utcb_mr()->mr[0] |= L4_FPAGE_BUFFERABLE << 4; l4_utcb_mr()->mr[0] |= L4_FPAGE_BUFFERABLE << 4;
break;
case CACHED:
l4_utcb_mr()->mr[0] |= L4_FPAGE_CACHEABLE << 4;
break;
case UNCACHED:
if (!_reply_mapping.iomem())
l4_utcb_mr()->mr[0] |= L4_FPAGE_BUFFERABLE << 4;
else
l4_utcb_mr()->mr[0] |= L4_FPAGE_UNCACHEABLE << 4;
break;
}
l4_utcb_mr()->mr[1] = _reply_mapping.fpage().raw; l4_utcb_mr()->mr[1] = _reply_mapping.fpage().raw;
_tag = l4_ipc_send_and_wait(_last, l4_utcb(), snd_tag, _tag = l4_ipc_send_and_wait(_last, l4_utcb(), snd_tag,

View File

@ -29,7 +29,7 @@ void Ram_session_component::_clear_ds(Dataspace_component *ds)
{ {
memset((void *)ds->phys_addr(), 0, ds->size()); memset((void *)ds->phys_addr(), 0, ds->size());
if (ds->write_combined()) if (ds->cacheability() != CACHED)
Fiasco::l4_cache_dma_coherent(ds->phys_addr(), ds->phys_addr() + ds->size()); Fiasco::l4_cache_dma_coherent(ds->phys_addr(), ds->phys_addr() + ds->size());
} }

View File

@ -14,6 +14,7 @@
#ifndef _INCLUDE__BASE__IPC_PAGER_H_ #ifndef _INCLUDE__BASE__IPC_PAGER_H_
#define _INCLUDE__BASE__IPC_PAGER_H_ #define _INCLUDE__BASE__IPC_PAGER_H_
#include <base/cache.h>
#include <base/ipc.h> #include <base/ipc.h>
#include <base/stdint.h> #include <base/stdint.h>
#include <base/native_types.h> #include <base/native_types.h>
@ -28,7 +29,7 @@ namespace Genode {
* Constructor * Constructor
*/ */
Mapping(addr_t dst_addr, addr_t src_addr, Mapping(addr_t dst_addr, addr_t src_addr,
bool write_combined, bool io_mem, Cache_attribute, bool io_mem,
unsigned l2size = 12, bool rw = true) { } unsigned l2size = 12, bool rw = true) { }
/** /**

View File

@ -60,12 +60,12 @@ namespace Genode
struct Genode::Mapping struct Genode::Mapping
{ {
addr_t virt_address; addr_t virt_address;
addr_t phys_address; addr_t phys_address;
bool write_combined; Cache_attribute cacheable;
bool io_mem; bool io_mem;
unsigned size_log2; unsigned size_log2;
bool writable; bool writable;
/** /**
* Constructor for invalid mappings * Constructor for invalid mappings
@ -75,7 +75,7 @@ struct Genode::Mapping
/** /**
* Constructor for valid mappings * Constructor for valid mappings
*/ */
Mapping(addr_t const va, addr_t const pa, bool const wc, Mapping(addr_t const va, addr_t const pa, Cache_attribute const c,
bool const io, unsigned const sl2, bool const w); bool const io, unsigned const sl2, bool const w);
/** /**

View File

@ -22,17 +22,18 @@ using namespace Genode;
** Mapping ** ** Mapping **
*************/ *************/
Mapping::Mapping(addr_t const va, addr_t const pa, bool const wc, Mapping::Mapping(addr_t const va, addr_t const pa,
bool const io, unsigned const sl2, bool const w) Cache_attribute const c, bool const io,
unsigned const sl2, bool const w)
: :
virt_address(va), phys_address(pa), write_combined(wc), virt_address(va), phys_address(pa), cacheable(c),
io_mem(io), size_log2(sl2), writable(w) io_mem(io), size_log2(sl2), writable(w)
{ } { }
Mapping::Mapping() Mapping::Mapping()
: :
virt_address(0), phys_address(0), write_combined(0), virt_address(0), phys_address(0), cacheable(CACHED),
io_mem(0), size_log2(0), writable(0) io_mem(0), size_log2(0), writable(0)
{ } { }

View File

@ -25,9 +25,14 @@ Arm::memory_region_attr(Page_flags const & flags)
typedef typename T::Tex Tex; typedef typename T::Tex Tex;
typedef typename T::C C; typedef typename T::C C;
typedef typename T::B B; typedef typename T::B B;
if(flags.device) { return 0; } if (flags.device) { return 0; }
if(flags.cacheable) { return Tex::bits(5) | B::bits(1); }
return Tex::bits(6) | C::bits(1); switch (flags.cacheable) {
case CACHED: return Tex::bits(5) | B::bits(1);
case WRITE_COMBINED: return B::bits(1);
case UNCACHED: return Tex::bits(1);
}
return 0;
} }
#endif /* _ARM_V6__TRANSLATION_TABLE_H_ */ #endif /* _ARM_V6__TRANSLATION_TABLE_H_ */

View File

@ -26,8 +26,13 @@ Arm::memory_region_attr(Page_flags const & flags)
typedef typename T::C C; typedef typename T::C C;
typedef typename T::B B; typedef typename T::B B;
if (flags.device) { return Tex::bits(2); } if (flags.device) { return Tex::bits(2); }
if (flags.cacheable) { return Tex::bits(5) | B::bits(1); }
return Tex::bits(6) | C::bits(1); switch (flags.cacheable) {
case CACHED: return Tex::bits(5) | B::bits(1);
case WRITE_COMBINED: return B::bits(1);
case UNCACHED: return Tex::bits(1);
}
return 0;
} }
#endif /* _ARM_V7__TRANSLATION_TABLE_H_ */ #endif /* _ARM_V7__TRANSLATION_TABLE_H_ */

View File

@ -14,6 +14,8 @@
#ifndef _TLB__PAGE_FLAGS_H_ #ifndef _TLB__PAGE_FLAGS_H_
#define _TLB__PAGE_FLAGS_H_ #define _TLB__PAGE_FLAGS_H_
#include <base/cache.h>
namespace Genode namespace Genode
{ {
/** /**
@ -21,34 +23,35 @@ namespace Genode
*/ */
struct Page_flags struct Page_flags
{ {
bool writeable; bool writeable;
bool executable; bool executable;
bool privileged; bool privileged;
bool global; bool global;
bool device; bool device;
bool cacheable; Cache_attribute cacheable;
/** /**
* Create flag POD for Genode pagers * Create flag POD for Genode pagers
*/ */
static const Page_flags static const Page_flags
apply_mapping(bool const writeable, apply_mapping(bool const writeable,
bool const write_combined, Cache_attribute const cacheable,
bool const io_mem) { bool const io_mem) {
return Page_flags { writeable, true, false, false, return Page_flags { writeable, true, false, false,
io_mem, !write_combined && !io_mem }; } io_mem, cacheable }; }
/** /**
* Create flag POD for kernel when it creates the core space * Create flag POD for kernel when it creates the core space
*/ */
static const Page_flags map_core_area(bool const io_mem) { static const Page_flags map_core_area(bool const io_mem) {
return Page_flags { true, true, false, false, io_mem, !io_mem }; } return Page_flags { true, true, false, false, io_mem,
io_mem ? UNCACHED : CACHED}; }
/** /**
* Create flag POD for the mode transition region * Create flag POD for the mode transition region
*/ */
static const Page_flags mode_transition() { static const Page_flags mode_transition() {
return Page_flags { true, true, true, true, false, true }; } return Page_flags { true, true, true, true, false, CACHED }; }
}; };
} }

View File

@ -128,7 +128,7 @@ Platform_thread::Platform_thread(const char * const label,
Ram_session_component * const ram = Ram_session_component * const ram =
dynamic_cast<Ram_session_component *>(core_env()->ram_session()); dynamic_cast<Ram_session_component *>(core_env()->ram_session());
assert(ram); assert(ram);
try { _utcb = ram->alloc(sizeof(Native_utcb), 1); } try { _utcb = ram->alloc(sizeof(Native_utcb), CACHED); }
catch (...) { catch (...) {
PERR("failed to allocate UTCB"); PERR("failed to allocate UTCB");
throw Cpu_session::Out_of_metadata(); throw Cpu_session::Out_of_metadata();

View File

@ -51,7 +51,7 @@ void Ram_session_component::_clear_ds (Dataspace_component * ds)
memset(virt_addr, 0, page_rounded_size); memset(virt_addr, 0, page_rounded_size);
/* uncached dataspaces need to be flushed */ /* uncached dataspaces need to be flushed */
if (ds->write_combined()) if (ds->cacheability() != CACHED)
Kernel::update_data_region((addr_t)virt_addr, page_rounded_size); Kernel::update_data_region((addr_t)virt_addr, page_rounded_size);
/* unmap dataspace from core */ /* unmap dataspace from core */

View File

@ -65,7 +65,7 @@ int Pager_activation_base::apply_mapping()
Page_flags const flags = Page_flags const flags =
Page_flags::apply_mapping(_mapping.writable, Page_flags::apply_mapping(_mapping.writable,
_mapping.write_combined, _mapping.cacheable,
_mapping.io_mem); _mapping.io_mem);
/* insert mapping into translation table */ /* insert mapping into translation table */

View File

@ -59,7 +59,7 @@ Vm_session_component::Vm_session_component(Rpc_entrypoint *ds_ep,
size_t ram_quota) size_t ram_quota)
: _ds_ep(ds_ep), _ram_alloc(ram_alloc), _vm_id(0), : _ds_ep(ds_ep), _ram_alloc(ram_alloc), _vm_id(0),
_ds_addr(_alloc_ds(&ram_quota)), _ds_addr(_alloc_ds(&ram_quota)),
_ds(_ds_size(), _ds_addr, _ds_addr, false, true, 0), _ds(_ds_size(), _ds_addr, _ds_addr, UNCACHED, true, 0),
_ds_cap(static_cap_cast<Dataspace>(_ds_ep->manage(&_ds))) _ds_cap(static_cap_cast<Dataspace>(_ds_ep->manage(&_ds)))
{ {
/* alloc needed memory */ /* alloc needed memory */

View File

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

View File

@ -52,7 +52,7 @@ namespace Genode {
* Constructor * Constructor
*/ */
Dataspace_component(size_t size, addr_t addr, Dataspace_component(size_t size, addr_t addr,
bool /* write_combined */, bool writable, Cache_attribute, bool writable,
Dataspace_owner * owner) Dataspace_owner * owner)
: _size(size), _addr(addr), _fd(-1), _writable(writable), : _size(size), _addr(addr), _fd(-1), _writable(writable),
_owner(owner) { } _owner(owner) { }
@ -68,7 +68,7 @@ namespace Genode {
* reasons and should not be used. * reasons and should not be used.
*/ */
Dataspace_component(size_t size, addr_t core_local_addr, Dataspace_component(size_t size, addr_t core_local_addr,
addr_t phys_addr, bool write_combined, addr_t phys_addr, Cache_attribute,
bool writable, Dataspace_owner * _owner) bool writable, Dataspace_owner * _owner)
: :
_size(size), _addr(phys_addr), _fd(-1), _owner(_owner) _size(size), _addr(phys_addr), _fd(-1), _owner(_owner)

View File

@ -65,7 +65,7 @@ Rom_session_component::Rom_session_component(Rom_fs *rom_fs,
int const fd = lx_open(fname, O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR); int const fd = lx_open(fname, O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR);
_ds = Dataspace_component(fsize, 0, false, false, 0); _ds = Dataspace_component(fsize, 0, CACHED, false, 0);
_ds.fd(fd); _ds.fd(fd);
_ds.fname(fname); _ds.fname(fname);

View File

@ -15,6 +15,7 @@
#define _INCLUDE__BASE__IPC_PAGER_H_ #define _INCLUDE__BASE__IPC_PAGER_H_
/* Genode includes */ /* Genode includes */
#include <base/cache.h>
#include <base/ipc.h> #include <base/ipc.h>
#include <base/stdint.h> #include <base/stdint.h>
#include <base/native_types.h> #include <base/native_types.h>
@ -43,12 +44,12 @@ namespace Genode {
* Constructor * Constructor
*/ */
Mapping(addr_t dst_addr, addr_t map_addr, Mapping(addr_t dst_addr, addr_t map_addr,
bool write_combined, bool io_mem, Cache_attribute c, bool io_mem,
unsigned size_log2 = PAGE_SIZE_LOG2, unsigned size_log2 = PAGE_SIZE_LOG2,
bool rw = true) bool rw = true)
: :
_dst_addr(dst_addr), _core_local_addr(map_addr), _dst_addr(dst_addr), _core_local_addr(map_addr),
_write_combined(write_combined), _size_log2(size_log2), _write_combined(c != CACHED), _size_log2(size_log2),
_rw(rw) _rw(rw)
{ } { }

View File

@ -14,6 +14,7 @@
#ifndef _INCLUDE__BASE__IPC_PAGER_H_ #ifndef _INCLUDE__BASE__IPC_PAGER_H_
#define _INCLUDE__BASE__IPC_PAGER_H_ #define _INCLUDE__BASE__IPC_PAGER_H_
#include <base/cache.h>
#include <base/ipc.h> #include <base/ipc.h>
#include <base/stdint.h> #include <base/stdint.h>
#include <base/native_types.h> #include <base/native_types.h>
@ -40,7 +41,7 @@ namespace Genode {
* Constructor * Constructor
*/ */
Mapping(addr_t dst_addr, addr_t src_addr, Mapping(addr_t dst_addr, addr_t src_addr,
bool write_combined, bool io_mem, Cache_attribute cacheability, bool io_mem,
unsigned l2size = 12, bool rw = true); unsigned l2size = 12, bool rw = true);
/** /**

View File

@ -62,7 +62,7 @@ static inline Okl4::L4_ThreadId_t thread_get_my_global_id()
*************/ *************/
Mapping::Mapping(addr_t dst_addr, addr_t src_addr, Mapping::Mapping(addr_t dst_addr, addr_t src_addr,
bool write_combined, bool io_mem, Cache_attribute cacheability, bool io_mem,
unsigned l2size, bool rw) unsigned l2size, bool rw)
: :
_fpage(L4_FpageLog2(dst_addr, l2size)), _fpage(L4_FpageLog2(dst_addr, l2size)),

View File

@ -15,6 +15,7 @@
#define _INCLUDE__BASE__IPC_PAGER_H_ #define _INCLUDE__BASE__IPC_PAGER_H_
/* Genode includes */ /* Genode includes */
#include <base/cache.h>
#include <base/native_types.h> #include <base/native_types.h>
#include <base/ipc.h> #include <base/ipc.h>
#include <base/stdint.h> #include <base/stdint.h>
@ -37,20 +38,13 @@ namespace Genode {
Pistachio::L4_GrantItem_t _grant_item; Pistachio::L4_GrantItem_t _grant_item;
}; };
/*
* On Pistachio, the write-combining attribute is not part of a mapping
* but it can be applied to a flexpage via the memory-control system
* call. Therefore, we need to keep the flag in an extra member variable.
*/
bool _write_combined; /* enable write-combined access to I/O memory */
public: public:
/** /**
* Constructor * Constructor
*/ */
Mapping(addr_t dst_addr, addr_t src_addr, Mapping(addr_t dst_addr, addr_t src_addr,
bool write_combined, bool io_mem, Cache_attribute, bool io_mem,
unsigned l2size = Pistachio::get_page_size_log2(), unsigned l2size = Pistachio::get_page_size_log2(),
bool rw = true, bool grant = false); bool rw = true, bool grant = false);

View File

@ -32,10 +32,8 @@ using namespace Pistachio;
*************/ *************/
Mapping::Mapping(addr_t dst_addr, addr_t src_addr, Mapping::Mapping(addr_t dst_addr, addr_t src_addr,
bool write_combined, bool io_mem, unsigned l2size, Cache_attribute, bool io_mem, unsigned l2size,
bool rw, bool grant) bool rw, bool grant)
:
_write_combined(write_combined)
{ {
L4_Fpage_t fpage = L4_FpageLog2(src_addr, l2size); L4_Fpage_t fpage = L4_FpageLog2(src_addr, l2size);

View File

@ -104,7 +104,7 @@ addr_t Io_mem_session_component::_map_local(addr_t base, size_t size)
L4_Fpage(base + offset, page_size), L4_Fpage(base + offset, page_size),
L4_Fpage(local_base + offset, page_size)); L4_Fpage(local_base + offset, page_size));
if (_write_combined) { if (_cacheable == WRITE_COMBINED) {
int res = L4_Set_PageAttribute(L4_Fpage(local_base + offset, page_size), int res = L4_Set_PageAttribute(L4_Fpage(local_base + offset, page_size),
L4_WriteCombiningMemory); L4_WriteCombiningMemory);
if (res != 1) if (res != 1)

View File

@ -0,0 +1,20 @@
/*
* \brief Generic cache declarations
* \author Stefan Kalkowski
* \date 2014-06-17
*/
/*
* Copyright (C) 2014 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__BASE__CACHE_H_
#define _INCLUDE__BASE__CACHE_H_
namespace Genode {
enum Cache_attribute { UNCACHED, WRITE_COMBINED, CACHED };
}
#endif /* _INCLUDE__BASE__CACHE_H_ */

View File

@ -25,7 +25,8 @@ namespace Genode {
explicit Ram_session_client(Ram_session_capability session) explicit Ram_session_client(Ram_session_capability session)
: Rpc_client<Ram_session>(session) { } : Rpc_client<Ram_session>(session) { }
Ram_dataspace_capability alloc(size_t size, bool cached = true) { Ram_dataspace_capability alloc(size_t size,
Cache_attribute cached = CACHED) {
return call<Rpc_alloc>(size, cached); } return call<Rpc_alloc>(size, cached); }
void free(Ram_dataspace_capability ds) { call<Rpc_free>(ds); } void free(Ram_dataspace_capability ds) { call<Rpc_free>(ds); }

View File

@ -17,6 +17,7 @@
#include <base/stdint.h> #include <base/stdint.h>
#include <base/capability.h> #include <base/capability.h>
#include <base/exception.h> #include <base/exception.h>
#include <base/cache.h>
#include <dataspace/capability.h> #include <dataspace/capability.h>
#include <ram_session/capability.h> #include <ram_session/capability.h>
#include <session/session.h> #include <session/session.h>
@ -49,7 +50,7 @@ namespace Genode {
* Allocate RAM dataspace * Allocate RAM dataspace
* *
* \param size size of RAM dataspace * \param size size of RAM dataspace
* \param cached true for cached memory, false for allocating * \param cached selects cacheability attributes of the memory,
* uncached memory, i.e., for DMA buffers * uncached memory, i.e., for DMA buffers
* *
* \throw Quota_exceeded * \throw Quota_exceeded
@ -57,7 +58,7 @@ namespace Genode {
* \return capability to new RAM dataspace * \return capability to new RAM dataspace
*/ */
virtual Ram_dataspace_capability alloc(size_t size, virtual Ram_dataspace_capability alloc(size_t size,
bool cached = true) = 0; Cache_attribute cached = CACHED) = 0;
/** /**
* Free RAM dataspace * Free RAM dataspace
@ -116,7 +117,7 @@ namespace Genode {
GENODE_RPC_THROW(Rpc_alloc, Ram_dataspace_capability, alloc, GENODE_RPC_THROW(Rpc_alloc, Ram_dataspace_capability, alloc,
GENODE_TYPE_LIST(Quota_exceeded, Out_of_metadata), GENODE_TYPE_LIST(Quota_exceeded, Out_of_metadata),
size_t, bool); size_t, Cache_attribute);
GENODE_RPC(Rpc_free, void, free, Ram_dataspace_capability); GENODE_RPC(Rpc_free, void, free, Ram_dataspace_capability);
GENODE_RPC(Rpc_ref_account, int, ref_account, Ram_session_capability); GENODE_RPC(Rpc_ref_account, int, ref_account, Ram_session_capability);
GENODE_RPC(Rpc_transfer_quota, int, transfer_quota, Ram_session_capability, size_t); GENODE_RPC(Rpc_transfer_quota, int, transfer_quota, Ram_session_capability, size_t);

View File

@ -87,7 +87,7 @@ struct Genode::Expanding_ram_session_client : Upgradeable_client<Genode::Ram_ses
Expanding_ram_session_client(Ram_session_capability cap) Expanding_ram_session_client(Ram_session_capability cap)
: Upgradeable_client<Genode::Ram_session_client>(cap) { } : Upgradeable_client<Genode::Ram_session_client>(cap) { }
Ram_dataspace_capability alloc(size_t size, bool cached = true) Ram_dataspace_capability alloc(size_t size, Cache_attribute cached = UNCACHED)
{ {
/* /*
* If the RAM session runs out of quota, issue a resource request * If the RAM session runs out of quota, issue a resource request

View File

@ -135,7 +135,7 @@ class Context_area_ram_session : public Ram_session
public: public:
Ram_dataspace_capability alloc(size_t size, bool cached) Ram_dataspace_capability alloc(size_t size, Cache_attribute cached)
{ {
/* find free context */ /* find free context */
unsigned i; unsigned i;
@ -161,7 +161,7 @@ class Context_area_ram_session : public Ram_session
PDBG("phys_base = %p, size = 0x%zx", phys_base, size); PDBG("phys_base = %p, size = 0x%zx", phys_base, size);
context_ds[i] = new (&_ds_slab) context_ds[i] = new (&_ds_slab)
Dataspace_component(size, 0, (addr_t)phys_base, false, true, 0); Dataspace_component(size, 0, (addr_t)phys_base, CACHED, true, 0);
Dataspace_capability cap = Dataspace_capability::local_cap(context_ds[i]); Dataspace_capability cap = Dataspace_capability::local_cap(context_ds[i]);
return static_cap_cast<Ram_dataspace>(cap); return static_cap_cast<Ram_dataspace>(cap);

View File

@ -70,7 +70,7 @@ namespace Genode {
** RAM-session interface ** ** RAM-session interface **
***************************/ ***************************/
Ram_dataspace_capability alloc(size_t size, bool cached) Ram_dataspace_capability alloc(size_t size, Cache_attribute cached)
{ {
Lock::Guard lock_guard(_lock); Lock::Guard lock_guard(_lock);
return RAM_SESSION_IMPL::alloc(size, cached); return RAM_SESSION_IMPL::alloc(size, cached);

View File

@ -41,8 +41,8 @@ namespace Genode {
addr_t _core_local_addr; /* address of core-local mapping */ addr_t _core_local_addr; /* address of core-local mapping */
size_t const _size; /* size of dataspace in bytes */ size_t const _size; /* size of dataspace in bytes */
bool const _is_io_mem; /* dataspace is I/O mem, not to be touched */ bool const _is_io_mem; /* dataspace is I/O mem, not to be touched */
bool const _write_combined; /* access I/O memory write-combined, or Cache_attribute const _cache; /* access memory cached, write-combined, or
RAM uncacheable respectively */ uncached respectively */
bool const _writable; /* false if dataspace is read-only */ bool const _writable; /* false if dataspace is read-only */
List<Rm_region> _regions; /* regions this is attached to */ List<Rm_region> _regions; /* regions this is attached to */
@ -73,7 +73,7 @@ namespace Genode {
Dataspace_component() Dataspace_component()
: :
_phys_addr(0), _core_local_addr(0), _size(0), _phys_addr(0), _core_local_addr(0), _size(0),
_is_io_mem(false), _write_combined(false), _writable(false), _is_io_mem(false), _cache(CACHED), _writable(false),
_owner(0), _managed(false) { } _owner(0), _managed(false) { }
/** /**
@ -82,12 +82,12 @@ namespace Genode {
* This constructor is used by RAM and ROM dataspaces. * This constructor is used by RAM and ROM dataspaces.
*/ */
Dataspace_component(size_t size, addr_t core_local_addr, Dataspace_component(size_t size, addr_t core_local_addr,
bool write_combined, bool writable, Cache_attribute cache, bool writable,
Dataspace_owner *owner) Dataspace_owner *owner)
: :
_phys_addr(core_local_addr), _core_local_addr(core_local_addr), _phys_addr(core_local_addr), _core_local_addr(core_local_addr),
_size(round_page(size)), _is_io_mem(false), _size(round_page(size)), _is_io_mem(false),
_write_combined(write_combined), _writable(writable), _cache(cache), _writable(writable),
_owner(owner), _managed(false) { } _owner(owner), _managed(false) { }
/** /**
@ -101,11 +101,11 @@ namespace Genode {
* space is needed to send a mapping to another address space. * space is needed to send a mapping to another address space.
*/ */
Dataspace_component(size_t size, addr_t core_local_addr, Dataspace_component(size_t size, addr_t core_local_addr,
addr_t phys_addr, bool write_combined, addr_t phys_addr, Cache_attribute cache,
bool writable, Dataspace_owner *owner) bool writable, Dataspace_owner *owner)
: :
_phys_addr(phys_addr), _core_local_addr(core_local_addr), _phys_addr(phys_addr), _core_local_addr(core_local_addr),
_size(size), _is_io_mem(true), _write_combined(write_combined), _size(size), _is_io_mem(true), _cache(cache),
_writable(writable), _owner(owner), _managed(false) { } _writable(writable), _owner(owner), _managed(false) { }
/** /**
@ -120,9 +120,9 @@ namespace Genode {
*/ */
virtual Native_capability sub_rm_session() { return Dataspace_capability(); } virtual Native_capability sub_rm_session() { return Dataspace_capability(); }
addr_t core_local_addr() const { return _core_local_addr; } addr_t core_local_addr() const { return _core_local_addr; }
bool is_io_mem() const { return _is_io_mem; } bool is_io_mem() const { return _is_io_mem; }
bool write_combined() const { return _write_combined; } Cache_attribute cacheability() const { return _cache; }
/** /**
* Return dataspace base address to be used for map operations * Return dataspace base address to be used for map operations

View File

@ -35,10 +35,10 @@ namespace Genode {
*/ */
struct Dataspace_attr struct Dataspace_attr
{ {
size_t size; size_t size;
addr_t core_local_addr; addr_t core_local_addr;
addr_t phys_addr; addr_t phys_addr;
bool write_combined; Cache_attribute cacheable;
/** /**
* Base address of request used for freeing mem-ranges * Base address of request used for freeing mem-ranges
@ -59,11 +59,11 @@ namespace Genode {
* An invalid dataspace is represented by setting all * An invalid dataspace is represented by setting all
* arguments to zero. * arguments to zero.
*/ */
Dataspace_attr(size_t s, addr_t cla, addr_t pa, bool write_combined, Dataspace_attr(size_t s, addr_t cla, addr_t pa, Cache_attribute c,
addr_t req_base) addr_t req_base)
: :
size(s), core_local_addr(cla), phys_addr(pa), size(s), core_local_addr(cla), phys_addr(pa),
write_combined(write_combined), req_base(req_base) { } cacheable(c), req_base(req_base) { }
}; };
struct Io_dataspace_component : Dataspace_component struct Io_dataspace_component : Dataspace_component
@ -76,7 +76,7 @@ namespace Genode {
Io_dataspace_component(Dataspace_attr da) Io_dataspace_component(Dataspace_attr da)
: :
Dataspace_component(da.size, da.core_local_addr, Dataspace_component(da.size, da.core_local_addr,
da.phys_addr, da.write_combined, da.phys_addr, da.cacheable,
true, 0), true, 0),
req_base(da.req_base) { } req_base(da.req_base) { }
@ -88,7 +88,7 @@ namespace Genode {
Io_dataspace_component _ds; Io_dataspace_component _ds;
Rpc_entrypoint *_ds_ep; Rpc_entrypoint *_ds_ep;
Io_mem_dataspace_capability _ds_cap; Io_mem_dataspace_capability _ds_cap;
bool _write_combined; Cache_attribute _cacheable;
Dataspace_attr _prepare_io_mem(const char *args, Range_allocator *ram_alloc); Dataspace_attr _prepare_io_mem(const char *args, Range_allocator *ram_alloc);

View File

@ -161,7 +161,7 @@ namespace Genode {
** RAM Session interface ** ** RAM Session interface **
***************************/ ***************************/
Ram_dataspace_capability alloc(size_t, bool); Ram_dataspace_capability alloc(size_t, Cache_attribute);
void free(Ram_dataspace_capability); void free(Ram_dataspace_capability);
int ref_account(Ram_session_capability); int ref_account(Ram_session_capability);
int transfer_quota(Ram_session_capability, size_t); int transfer_quota(Ram_session_capability, size_t);

View File

@ -263,7 +263,7 @@ namespace Genode {
*/ */
Rm_dataspace_component(size_t size) Rm_dataspace_component(size_t size)
: :
Dataspace_component(size, 0, false, false, 0) Dataspace_component(size, 0, CACHED, false, 0)
{ _managed = true; } { _managed = true; }

View File

@ -37,11 +37,11 @@ Io_mem_session_component::_prepare_io_mem(const char *args,
addr_t base = req_base & ~(get_page_size() - 1); addr_t base = req_base & ~(get_page_size() - 1);
size_t size = end - base; size_t size = end - base;
_write_combined = false; _cacheable = UNCACHED;
Arg a = Arg_string::find_arg(args, "wc"); Arg a = Arg_string::find_arg(args, "wc");
if (a.valid()) if (a.valid() && a.bool_value(0))
_write_combined = a.bool_value(0); _cacheable = WRITE_COMBINED;
/* check for RAM collision */ /* check for RAM collision */
int ret; int ret;
@ -69,9 +69,9 @@ Io_mem_session_component::_prepare_io_mem(const char *args,
if (verbose) if (verbose)
PDBG("I/O mem [%lx,%lx) => [%lx,%lx)%s", PDBG("I/O mem [%lx,%lx) => [%lx,%lx)%s",
base, base + size, local_addr, local_addr + size, base, base + size, local_addr, local_addr + size,
_write_combined ? " (write-combined)" : ""); (_cacheable == WRITE_COMBINED) ? " (write-combined)" : "");
return Dataspace_attr(size, local_addr, base, _write_combined, req_base); return Dataspace_attr(size, local_addr, base, _cacheable, req_base);
} }

View File

@ -106,7 +106,7 @@ void Ram_session_component::_remove_ref_account_member(Ram_session_component *me
} }
Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, bool cached) Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, Cache_attribute cached)
{ {
/* zero-sized dataspaces are not allowed */ /* zero-sized dataspaces are not allowed */
if (!ds_size) return Ram_dataspace_capability(); if (!ds_size) return Ram_dataspace_capability();
@ -171,7 +171,7 @@ Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, bool cache
* when resolving page faults. * when resolving page faults.
*/ */
ds = new (&_ds_slab) ds = new (&_ds_slab)
Dataspace_component(ds_size, (addr_t)ds_addr, !cached, true, this); Dataspace_component(ds_size, (addr_t)ds_addr, cached, true, this);
} catch (Allocator::Out_of_memory) { } catch (Allocator::Out_of_memory) {
PWRN("Could not allocate metadata"); PWRN("Could not allocate metadata");
/* cleanup unneeded resources */ /* cleanup unneeded resources */

View File

@ -280,7 +280,7 @@ int Rm_client::pager(Ipc_pager &pager)
Mapping mapping(dst_fault_area.base(), Mapping mapping(dst_fault_area.base(),
src_fault_area.base(), src_fault_area.base(),
src_dataspace->write_combined(), src_dataspace->cacheability(),
src_dataspace->is_io_mem(), src_dataspace->is_io_mem(),
map_size_log2, map_size_log2,
src_dataspace->writable()); src_dataspace->writable());

View File

@ -25,7 +25,7 @@ Rom_session_component::Rom_session_component(Rom_fs *rom_fs,
: :
_rom_module(_find_rom(rom_fs, args)), _rom_module(_find_rom(rom_fs, args)),
_ds(_rom_module ? _rom_module->size() : 0, _ds(_rom_module ? _rom_module->size() : 0,
_rom_module ? _rom_module->addr() : 0, false, false, 0), _rom_module ? _rom_module->addr() : 0, CACHED, false, 0),
_ds_ep(ds_ep) _ds_ep(ds_ep)
{ {
/* ROM module not found */ /* ROM module not found */

View File

@ -54,7 +54,7 @@ class Genode::Slab_backend_alloc : public Genode::Allocator,
}; };
addr_t _base; /* virt. base address */ addr_t _base; /* virt. base address */
bool _cached; /* non-/cached RAM */ Cache_attribute _cached; /* non-/cached RAM */
Ram_dataspace_capability _ds_cap[ELEMENTS]; /* dataspaces to put in VM */ Ram_dataspace_capability _ds_cap[ELEMENTS]; /* dataspaces to put in VM */
addr_t _ds_phys[ELEMENTS]; /* physical bases of dataspaces */ addr_t _ds_phys[ELEMENTS]; /* physical bases of dataspaces */
int _index; /* current index in ds_cap */ int _index; /* current index in ds_cap */
@ -86,7 +86,7 @@ class Genode::Slab_backend_alloc : public Genode::Allocator,
public: public:
Slab_backend_alloc(bool cached) Slab_backend_alloc(Cache_attribute cached)
: Rm_connection(0, VM_SIZE), _cached(cached), _index(0), : Rm_connection(0, VM_SIZE), _cached(cached), _index(0),
_range(env()->heap()) _range(env()->heap())
{ {
@ -220,7 +220,7 @@ class Malloc
public: public:
Malloc(Slab_backend_alloc *alloc, bool cached) Malloc(Slab_backend_alloc *alloc, Genode::Cache_attribute cached)
: _back_allocator(alloc), _cached(cached), _start(alloc->start()), : _back_allocator(alloc), _cached(cached), _start(alloc->start()),
_end(alloc->end()) _end(alloc->end())
{ {
@ -312,8 +312,8 @@ class Malloc
*/ */
static Malloc *mem() static Malloc *mem()
{ {
static Slab_backend_alloc _b(true); static Slab_backend_alloc _b(Genode::CACHED);
static Malloc _m(&_b, true); static Malloc _m(&_b, Genode::CACHED);
return &_m; return &_m;
} }
}; };

View File

@ -14,13 +14,17 @@
#ifndef _ARM__PLATFORM__LX_MEM_ #ifndef _ARM__PLATFORM__LX_MEM_
#define _ARM__PLATFORM__LX_MEM_ #define _ARM__PLATFORM__LX_MEM_
#include <base/cache.h>
class Backend_memory { class Backend_memory {
public: public:
static Genode::Ram_dataspace_capability alloc(Genode::addr_t size, static Genode::Ram_dataspace_capability alloc(Genode::addr_t size,
bool cached) { Genode::Cache_attribute c)
return Genode::env()->ram_session()->alloc(size, cached); } {
return Genode::env()->ram_session()->alloc(size, c);
}
static void free(Genode::Ram_dataspace_capability cap) { static void free(Genode::Ram_dataspace_capability cap) {
return Genode::env()->ram_session()->free(cap); } return Genode::env()->ram_session()->free(cap); }

View File

@ -291,7 +291,7 @@ namespace Nic {
/** /**
* Root component, handling new session requests * Root component, handling new session requests
*/ */
class Root : public Packet_root<Root_component, Session_component, true> class Root : public Packet_root<Root_component, Session_component, CACHED>
{ {
public: public:

View File

@ -74,7 +74,8 @@ class Packet_session_component : public RPC
/** /**
* Root component, handling new session requests * Root component, handling new session requests
*/ */
template <typename ROOT_COMPONENT, typename SESSION_COMPONENT, bool CACHED> template <typename ROOT_COMPONENT, typename SESSION_COMPONENT,
Genode::Cache_attribute CACHEABILITY>
class Packet_root : public ROOT_COMPONENT class Packet_root : public ROOT_COMPONENT
{ {
private: private:
@ -116,8 +117,8 @@ class Packet_session_component : public RPC
} }
return new (ROOT_COMPONENT::md_alloc()) return new (ROOT_COMPONENT::md_alloc())
SESSION_COMPONENT(Backend_memory::alloc(tx_buf_size, CACHED), SESSION_COMPONENT(Backend_memory::alloc(tx_buf_size, CACHEABILITY),
Backend_memory::alloc(rx_buf_size, CACHED), Backend_memory::alloc(rx_buf_size, CACHEABILITY),
_ep, _device); _ep, _device);
} }

View File

@ -14,12 +14,14 @@
#ifndef _X86__PLATFORM__LX_MEM_ #ifndef _X86__PLATFORM__LX_MEM_
#define _X86__PLATFORM__LX_MEM_ #define _X86__PLATFORM__LX_MEM_
#include <base/cache.h>
class Backend_memory { class Backend_memory {
public: public:
static Genode::Ram_dataspace_capability alloc(Genode::addr_t size, static Genode::Ram_dataspace_capability alloc(Genode::addr_t size,
bool cached); Genode::Cache_attribute);
static void free(Genode::Ram_dataspace_capability cap); static void free(Genode::Ram_dataspace_capability cap);
}; };

View File

@ -56,7 +56,7 @@ class Genode::Slab_backend_alloc : public Genode::Allocator,
}; };
addr_t _base; /* virt. base address */ addr_t _base; /* virt. base address */
bool _cached; /* non-/cached RAM */ Genode::Cache_attribute _cached; /* non-/cached RAM */
Ram_dataspace_capability _ds_cap[ELEMENTS]; /* dataspaces to put in VM */ Ram_dataspace_capability _ds_cap[ELEMENTS]; /* dataspaces to put in VM */
addr_t _ds_phys[ELEMENTS]; /* physical bases of dataspaces */ addr_t _ds_phys[ELEMENTS]; /* physical bases of dataspaces */
int _index; /* current index in ds_cap */ int _index; /* current index in ds_cap */
@ -88,7 +88,7 @@ class Genode::Slab_backend_alloc : public Genode::Allocator,
public: public:
Slab_backend_alloc(bool cached) Slab_backend_alloc(Genode::Cache_attribute cached)
: Rm_connection(0, VM_SIZE), _cached(cached), _index(0), : Rm_connection(0, VM_SIZE), _cached(cached), _index(0),
_range(env()->heap()) _range(env()->heap())
{ {
@ -206,11 +206,11 @@ class Malloc
typedef Genode::Slab_alloc Slab_alloc; typedef Genode::Slab_alloc Slab_alloc;
typedef Genode::Slab_backend_alloc Slab_backend_alloc; typedef Genode::Slab_backend_alloc Slab_backend_alloc;
Slab_backend_alloc *_back_allocator; Slab_backend_alloc *_back_allocator;
Slab_alloc *_allocator[NUM_SLABS]; Slab_alloc *_allocator[NUM_SLABS];
bool _cached; /* cached or un-cached memory */ Genode::Cache_attribute _cached; /* cached or un-cached memory */
addr_t _start; /* VM region of this allocator */ addr_t _start; /* VM region of this allocator */
addr_t _end; addr_t _end;
/** /**
* Set 'value' at 'addr' * Set 'value' at 'addr'
@ -240,7 +240,7 @@ class Malloc
public: public:
Malloc(Slab_backend_alloc *alloc, bool cached) Malloc(Slab_backend_alloc *alloc, Genode::Cache_attribute cached)
: _back_allocator(alloc), _cached(cached), _start(alloc->start()), : _back_allocator(alloc), _cached(cached), _start(alloc->start()),
_end(alloc->end()) _end(alloc->end())
{ {
@ -326,8 +326,8 @@ class Malloc
*/ */
static Malloc *mem() static Malloc *mem()
{ {
static Slab_backend_alloc _b(true); static Slab_backend_alloc _b(Genode::CACHED);
static Malloc _m(&_b, true); static Malloc _m(&_b, Genode::CACHED);
return &_m; return &_m;
} }
@ -336,8 +336,8 @@ class Malloc
*/ */
static Malloc *dma() static Malloc *dma()
{ {
static Slab_backend_alloc _b(false); static Slab_backend_alloc _b(Genode::UNCACHED);
static Malloc _m(&_b, false); static Malloc _m(&_b, Genode::UNCACHED);
return &_m; return &_m;
} }
}; };

View File

@ -367,15 +367,15 @@ void Ram_object::free() { Genode::env()->ram_session()->free(ram_cap()); }
void Dma_object::free() { pci.free_dma_buffer(pci_device_cap, ram_cap()); } void Dma_object::free() { pci.free_dma_buffer(pci_device_cap, ram_cap()); }
Genode::Ram_dataspace_capability Backend_memory::alloc(Genode::addr_t size, Genode::Ram_dataspace_capability
bool cached) Backend_memory::alloc(Genode::addr_t size, Genode::Cache_attribute cached)
{ {
using namespace Genode; using namespace Genode;
Memory_object_base *o; Memory_object_base *o;
Genode::Ram_dataspace_capability cap; Genode::Ram_dataspace_capability cap;
if (cached) { if (cached == CACHED) {
cap = env()->ram_session()->alloc(size, cached); cap = env()->ram_session()->alloc(size);
o = new (env()->heap()) Ram_object(cap); o = new (env()->heap()) Ram_object(cap);
} else { } else {
cap = pci.alloc_dma_buffer(pci_device_cap, size); cap = pci.alloc_dma_buffer(pci_device_cap, size);

View File

@ -157,7 +157,7 @@ class Storage_device : public Genode::List<Storage_device>::Element,
bool dma_enabled() { return true; } bool dma_enabled() { return true; }
Genode::Ram_dataspace_capability alloc_dma_buffer(Genode::size_t size) { Genode::Ram_dataspace_capability alloc_dma_buffer(Genode::size_t size) {
return Backend_memory::alloc(size, false); } return Backend_memory::alloc(size, Genode::UNCACHED); }
void free_dma_buffer(Genode::Ram_dataspace_capability cap) { void free_dma_buffer(Genode::Ram_dataspace_capability cap) {
return Backend_memory::free(cap); } return Backend_memory::free(cap); }

View File

@ -62,7 +62,7 @@ namespace Allocator {
typedef Genode::Allocator_avl Allocator_avl; typedef Genode::Allocator_avl Allocator_avl;
addr_t _base; /* virt. base address */ addr_t _base; /* virt. base address */
bool _cached; /* non-/cached RAM */ Cache_attribute _cached; /* non-/cached RAM */
Ram_dataspace_capability _ds_cap[ELEMENTS]; /* dataspaces to put in VM */ Ram_dataspace_capability _ds_cap[ELEMENTS]; /* dataspaces to put in VM */
addr_t _ds_phys[ELEMENTS]; /* physical bases of dataspaces */ addr_t _ds_phys[ELEMENTS]; /* physical bases of dataspaces */
int _index = 0; /* current index in ds_cap */ int _index = 0; /* current index in ds_cap */
@ -107,7 +107,7 @@ namespace Allocator {
public: public:
Backend_alloc(bool cached) Backend_alloc(Cache_attribute cached)
: Rm_connection(0, VM_SIZE), _cached(cached), : Rm_connection(0, VM_SIZE), _cached(cached),
_range(Genode::env()->heap()) _range(Genode::env()->heap())
{ {
@ -195,7 +195,7 @@ namespace Allocator {
public: public:
Fap(bool cached) Fap(bool cached)
: _back_allocator(cached) { } : _back_allocator(cached ? CACHED : UNCACHED) { }
void *alloc(size_t size, int align = 0) void *alloc(size_t size, int align = 0)
{ {

View File

@ -35,7 +35,7 @@ namespace Genode {
Ram_session *_ram_session; Ram_session *_ram_session;
Ram_dataspace_capability _ds; Ram_dataspace_capability _ds;
void *_local_addr; void *_local_addr;
bool const _cached; Cache_attribute const _cached;
template <typename T> template <typename T>
static void _swap(T &v1, T &v2) { T tmp = v1; v1 = v2; v2 = tmp; } static void _swap(T &v1, T &v2) { T tmp = v1; v1 = v2; v2 = tmp; }
@ -73,7 +73,7 @@ namespace Genode {
* work-around for this issues, we eagerly map the whole * work-around for this issues, we eagerly map the whole
* dataspace before writing actual content to it. * dataspace before writing actual content to it.
*/ */
if (!_cached) { if (_cached != CACHED) {
enum { PAGE_SIZE = 4096 }; enum { PAGE_SIZE = 4096 };
unsigned char volatile *base = (unsigned char volatile *)_local_addr; unsigned char volatile *base = (unsigned char volatile *)_local_addr;
for (size_t i = 0; i < _size; i += PAGE_SIZE) for (size_t i = 0; i < _size; i += PAGE_SIZE)
@ -90,7 +90,7 @@ namespace Genode {
* \throw Rm_session::Attach_failed * \throw Rm_session::Attach_failed
*/ */
Attached_ram_dataspace(Ram_session *ram_session, size_t size, Attached_ram_dataspace(Ram_session *ram_session, size_t size,
bool cached = true) Cache_attribute cached = CACHED)
: :
_size(size), _ram_session(ram_session), _local_addr(0), _size(size), _ram_session(ram_session), _local_addr(0),
_cached(cached) _cached(cached)

View File

@ -57,7 +57,7 @@ class Ahci_driver : public Block::Driver
bool dma_enabled() { return true; } bool dma_enabled() { return true; }
Genode::Ram_dataspace_capability alloc_dma_buffer(Genode::size_t size) { Genode::Ram_dataspace_capability alloc_dma_buffer(Genode::size_t size) {
return Genode::env()->ram_session()->alloc(size, false); } return Genode::env()->ram_session()->alloc(size, UNCACHED); }
void free_dma_buffer(Genode::Ram_dataspace_capability c) { void free_dma_buffer(Genode::Ram_dataspace_capability c) {
return Genode::env()->ram_session()->free(c); } return Genode::env()->ram_session()->free(c); }

View File

@ -75,7 +75,7 @@ class Framebuffer::Session_component
_height(height), _height(height),
_format(Driver::FORMAT_RGB565), _format(Driver::FORMAT_RGB565),
_size(driver.buffer_size(width, height, _format)), _size(driver.buffer_size(width, height, _format)),
_ds(env()->ram_session()->alloc(_size, false)), _ds(env()->ram_session()->alloc(_size, WRITE_COMBINED)),
_phys_base(Dataspace_client(_ds).phys_addr()) _phys_base(Dataspace_client(_ds).phys_addr())
{ {
if (driver.init_drv(width, height, _format, output, _phys_base)) { if (driver.init_drv(width, height, _format, output, _phys_base)) {

View File

@ -73,7 +73,7 @@ class Framebuffer::Session_component :
_bb_ds(buffered ? Genode::env()->ram_session()->alloc(_size) _bb_ds(buffered ? Genode::env()->ram_session()->alloc(_size)
: Genode::Ram_dataspace_capability()), : Genode::Ram_dataspace_capability()),
_bb_addr(buffered ? (void*)Genode::env()->rm_session()->attach(_bb_ds) : 0), _bb_addr(buffered ? (void*)Genode::env()->rm_session()->attach(_bb_ds) : 0),
_fb_ds(Genode::env()->ram_session()->alloc(_size, false)), _fb_ds(Genode::env()->ram_session()->alloc(_size, WRITE_COMBINED)),
_fb_addr((void*)Genode::env()->rm_session()->attach(_fb_ds)), _fb_addr((void*)Genode::env()->rm_session()->attach(_fb_ds)),
_ipu(driver.ipu()) _ipu(driver.ipu())
{ {

View File

@ -62,7 +62,7 @@ class Framebuffer::Session_component : public Genode::Rpc_object<Framebuffer::Se
_height(height), _height(height),
_format(Driver::FORMAT_RGB565), _format(Driver::FORMAT_RGB565),
_size(driver.buffer_size(width, height, _format)), _size(driver.buffer_size(width, height, _format)),
_ds(env()->ram_session()->alloc(_size, false)), _ds(env()->ram_session()->alloc(_size, WRITE_COMBINED)),
_phys_base(Dataspace_client(_ds).phys_addr()) _phys_base(Dataspace_client(_ds).phys_addr())
{ {
if (!driver.init(width, height, _format, output, _phys_base)) { if (!driver.init(width, height, _format, output, _phys_base)) {

View File

@ -312,7 +312,7 @@ namespace Pci {
Genode::size_t size) Genode::size_t size)
{ {
Genode::Ram_dataspace_capability ram = Genode::Ram_dataspace_capability ram =
Genode::env()->ram_session()->alloc(size, false); Genode::env()->ram_session()->alloc(size, Genode::UNCACHED);
if (!ram.valid() || !_child) if (!ram.valid() || !_child)
return ram; return ram;

View File

@ -133,7 +133,7 @@ class Block::Omap4_driver : public Block::Driver
bool dma_enabled() { return _use_dma; } bool dma_enabled() { return _use_dma; }
Genode::Ram_dataspace_capability alloc_dma_buffer(Genode::size_t size) { Genode::Ram_dataspace_capability alloc_dma_buffer(Genode::size_t size) {
return Genode::env()->ram_session()->alloc(size, false); } return Genode::env()->ram_session()->alloc(size, UNCACHED); }
void free_dma_buffer(Genode::Ram_dataspace_capability c) { void free_dma_buffer(Genode::Ram_dataspace_capability c) {
return Genode::env()->ram_session()->free(c); } return Genode::env()->ram_session()->free(c); }

View File

@ -34,7 +34,7 @@ namespace Genode {
Ram_session_client_guard(Ram_session_capability session, size_t amount) Ram_session_client_guard(Ram_session_capability session, size_t amount)
: Ram_session_client(session), _amount(amount), _consumed(0) { } : Ram_session_client(session), _amount(amount), _consumed(0) { }
Ram_dataspace_capability alloc(size_t size, bool cached) Ram_dataspace_capability alloc(size_t size, Cache_attribute cached)
{ {
Lock::Guard _consumed_lock_guard(_consumed_lock); Lock::Guard _consumed_lock_guard(_consumed_lock);

View File

@ -271,7 +271,7 @@ class Block::Root :
} }
Ram_dataspace_capability ds_cap; Ram_dataspace_capability ds_cap;
ds_cap = Genode::env()->ram_session()->alloc(tx_buf_size, true); ds_cap = Genode::env()->ram_session()->alloc(tx_buf_size);
return new (md_alloc()) return new (md_alloc())
Session_component(ds_cap, Session_component(ds_cap,
Partition_table::table().partition(num), Partition_table::table().partition(num),

View File

@ -29,9 +29,9 @@ Ram_session_component::~Ram_session_component()
{ } { }
Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, bool cached) Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, Cache_attribute cached)
{ {
return _parent_ram_session.alloc(ds_size); return _parent_ram_session.alloc(ds_size, cached);
} }

View File

@ -43,7 +43,7 @@ class Ram_session_component : public Rpc_object<Ram_session>
** RAM Session interface ** ** RAM Session interface **
***************************/ ***************************/
Ram_dataspace_capability alloc(Genode::size_t, bool); Ram_dataspace_capability alloc(Genode::size_t, Cache_attribute);
void free(Ram_dataspace_capability); void free(Ram_dataspace_capability);
int ref_account(Ram_session_capability); int ref_account(Ram_session_capability);
int transfer_quota(Ram_session_capability, Genode::size_t); int transfer_quota(Ram_session_capability, Genode::size_t);

View File

@ -135,7 +135,7 @@ namespace Noux {
** Ram_session interface ** ** Ram_session interface **
***************************/ ***************************/
Ram_dataspace_capability alloc(size_t size, bool cached) Ram_dataspace_capability alloc(size_t size, Cache_attribute cached)
{ {
Ram_dataspace_capability ds_cap = Ram_dataspace_capability ds_cap =
env()->ram_session()->alloc(size, cached); env()->ram_session()->alloc(size, cached);