USB: Dimension back-end allocators dynamically
Use avaible ram session quota to determine the size of the memory allocators. Fixes #331
This commit is contained in:
parent
78b0bd57f7
commit
71b2b42936
|
@ -32,8 +32,7 @@ namespace Genode {
|
||||||
/* configurable sizes of memory pools */
|
/* configurable sizes of memory pools */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MEM_POOL = 2 * 1024 * 1024,
|
MEM_POOL_SHARE = 3
|
||||||
DMA_POOL = 3 * 1024 * 1024,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -88,6 +87,12 @@ namespace Genode {
|
||||||
return (void *)(_base + offset);
|
return (void *)(_base + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memory usable by back-end allocators
|
||||||
|
*/
|
||||||
|
static size_t _mem_avail() {
|
||||||
|
return env()->ram_session()->avail() - (1024 * 1024); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,7 +151,7 @@ namespace Genode {
|
||||||
*/
|
*/
|
||||||
static Mem* pool()
|
static Mem* pool()
|
||||||
{
|
{
|
||||||
static Mem _p(MEM_POOL);
|
static Mem _p(_mem_avail() / MEM_POOL_SHARE);
|
||||||
return &_p;
|
return &_p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +161,7 @@ namespace Genode {
|
||||||
*/
|
*/
|
||||||
static Mem* dma()
|
static Mem* dma()
|
||||||
{
|
{
|
||||||
static Mem _p(DMA_POOL, false);
|
static Mem _p(_mem_avail() - (_mem_avail() / MEM_POOL_SHARE), false);
|
||||||
return &_p;
|
return &_p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user