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:
Sebastian Sumpf 2012-08-24 13:40:30 +02:00 committed by Norman Feske
parent 78b0bd57f7
commit 71b2b42936
1 changed files with 9 additions and 4 deletions

View File

@ -32,8 +32,7 @@ namespace Genode {
/* configurable sizes of memory pools */
enum
{
MEM_POOL = 2 * 1024 * 1024,
DMA_POOL = 3 * 1024 * 1024,
MEM_POOL_SHARE = 3
};
private:
@ -88,6 +87,12 @@ namespace Genode {
return (void *)(_base + offset);
}
/**
* Memory usable by back-end allocators
*/
static size_t _mem_avail() {
return env()->ram_session()->avail() - (1024 * 1024); }
public:
/**
@ -146,7 +151,7 @@ namespace Genode {
*/
static Mem* pool()
{
static Mem _p(MEM_POOL);
static Mem _p(_mem_avail() / MEM_POOL_SHARE);
return &_p;
}
@ -156,7 +161,7 @@ namespace Genode {
*/
static Mem* dma()
{
static Mem _p(DMA_POOL, false);
static Mem _p(_mem_avail() - (_mem_avail() / MEM_POOL_SHARE), false);
return &_p;
}