mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-30 02:28:54 +00:00
base: use 'Ram_allocator' as stack-area back end
The 'Stack_area_ram_session' is now a 'Stack_area_ram_allocator', which simplifies the code and remove a dependency from the 'Ram_session' interface, which we want to remove after all. Issue #2407
This commit is contained in:
parent
d31642e8be
commit
5a3a1c704b
@ -78,7 +78,7 @@ class Stack_area_region_map : public Genode::Region_map
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Stack_area_ram_session : Genode::Ram_session
|
struct Stack_area_ram_allocator : Genode::Ram_allocator
|
||||||
{
|
{
|
||||||
Genode::Ram_dataspace_capability alloc(Genode::size_t size,
|
Genode::Ram_dataspace_capability alloc(Genode::size_t size,
|
||||||
Genode::Cache_attribute) override {
|
Genode::Cache_attribute) override {
|
||||||
@ -87,14 +87,6 @@ struct Stack_area_ram_session : Genode::Ram_session
|
|||||||
void free(Genode::Ram_dataspace_capability) override { }
|
void free(Genode::Ram_dataspace_capability) override { }
|
||||||
|
|
||||||
Genode::size_t dataspace_size(Genode::Ram_dataspace_capability) const override { return 0; }
|
Genode::size_t dataspace_size(Genode::Ram_dataspace_capability) const override { return 0; }
|
||||||
|
|
||||||
void ref_account(Genode::Ram_session_capability) override { }
|
|
||||||
|
|
||||||
void transfer_quota(Genode::Ram_session_capability, Genode::Ram_quota) override { }
|
|
||||||
|
|
||||||
Genode::Ram_quota ram_quota() const override { return { 0 }; }
|
|
||||||
|
|
||||||
Genode::Ram_quota used_ram() const override { return { 0 }; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -103,16 +95,16 @@ struct Stack_area_ram_session : Genode::Ram_session
|
|||||||
*/
|
*/
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
|
|
||||||
Region_map *env_stack_area_region_map;
|
Region_map *env_stack_area_region_map;
|
||||||
Ram_session *env_stack_area_ram_session;
|
Ram_allocator *env_stack_area_ram_allocator;
|
||||||
|
|
||||||
void init_stack_area()
|
void init_stack_area()
|
||||||
{
|
{
|
||||||
static Stack_area_region_map rm_inst;
|
static Stack_area_region_map rm_inst;
|
||||||
env_stack_area_region_map = &rm_inst;
|
env_stack_area_region_map = &rm_inst;
|
||||||
|
|
||||||
static Stack_area_ram_session ram_inst;
|
static Stack_area_ram_allocator ram_inst;
|
||||||
env_stack_area_ram_session = &ram_inst;
|
env_stack_area_ram_allocator = &ram_inst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,8 +163,8 @@ Platform_env::Platform_env()
|
|||||||
{
|
{
|
||||||
_attach_stack_area();
|
_attach_stack_area();
|
||||||
|
|
||||||
env_stack_area_region_map = &_local_pd_session._stack_area;
|
env_stack_area_region_map = &_local_pd_session._stack_area;
|
||||||
env_stack_area_ram_session = ram_session();
|
env_stack_area_ram_allocator = ram_session();
|
||||||
|
|
||||||
/* register TID and PID of the main thread at core */
|
/* register TID and PID of the main thread at core */
|
||||||
Linux_native_cpu_client native_cpu(cpu_session()->native_cpu());
|
Linux_native_cpu_client native_cpu(cpu_session()->native_cpu());
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <region_map/region_map.h>
|
#include <region_map/region_map.h>
|
||||||
#include <ram_session/ram_session.h>
|
#include <base/ram_allocator.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <base/synced_allocator.h>
|
#include <base/synced_allocator.h>
|
||||||
#include <base/thread.h>
|
#include <base/thread.h>
|
||||||
@ -108,8 +108,6 @@ class Stack_area_region_map : public Region_map
|
|||||||
|
|
||||||
/* XXX missing XXX */
|
/* XXX missing XXX */
|
||||||
warning(__PRETTY_FUNCTION__, ": not implemented");
|
warning(__PRETTY_FUNCTION__, ": not implemented");
|
||||||
// Untyped_memory::convert_to_untyped_frames(phys_addr, phys_size)
|
|
||||||
// Untyped_memory::free_pages(phys_alloc, num_pages);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fault_handler(Signal_context_capability) override { }
|
void fault_handler(Signal_context_capability) override { }
|
||||||
@ -120,7 +118,7 @@ class Stack_area_region_map : public Region_map
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Stack_area_ram_session : Ram_session
|
struct Stack_area_ram_allocator : Ram_allocator
|
||||||
{
|
{
|
||||||
Ram_dataspace_capability alloc(size_t, Cache_attribute) override {
|
Ram_dataspace_capability alloc(size_t, Cache_attribute) override {
|
||||||
return reinterpret_cap_cast<Ram_dataspace>(Native_capability()); }
|
return reinterpret_cap_cast<Ram_dataspace>(Native_capability()); }
|
||||||
@ -129,28 +127,20 @@ struct Stack_area_ram_session : Ram_session
|
|||||||
warning(__func__, " not implemented"); }
|
warning(__func__, " not implemented"); }
|
||||||
|
|
||||||
size_t dataspace_size(Ram_dataspace_capability) const override { return 0; }
|
size_t dataspace_size(Ram_dataspace_capability) const override { return 0; }
|
||||||
|
|
||||||
void ref_account(Ram_session_capability) override { }
|
|
||||||
|
|
||||||
void transfer_quota(Ram_session_capability, Ram_quota) override { }
|
|
||||||
|
|
||||||
Ram_quota ram_quota() const override { return { 0 }; }
|
|
||||||
|
|
||||||
Ram_quota used_ram() const override { return { 0 }; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
|
|
||||||
Region_map *env_stack_area_region_map;
|
Region_map *env_stack_area_region_map;
|
||||||
Ram_session *env_stack_area_ram_session;
|
Ram_allocator *env_stack_area_ram_allocator;
|
||||||
|
|
||||||
void init_stack_area()
|
void init_stack_area()
|
||||||
{
|
{
|
||||||
static Stack_area_region_map rm_inst;
|
static Stack_area_region_map rm_inst;
|
||||||
env_stack_area_region_map = &rm_inst;
|
env_stack_area_region_map = &rm_inst;
|
||||||
|
|
||||||
static Stack_area_ram_session ram_inst;
|
static Stack_area_ram_allocator ram_inst;
|
||||||
env_stack_area_ram_session = &ram_inst;
|
env_stack_area_ram_allocator = &ram_inst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,8 +202,8 @@ _ZN6Genode23Alarm_timeout_scheduler18_schedule_periodicERNS_7TimeoutENS_12Micros
|
|||||||
_ZN6Genode23Alarm_timeout_scheduler7_enableEv T
|
_ZN6Genode23Alarm_timeout_scheduler7_enableEv T
|
||||||
_ZN6Genode23Alarm_timeout_schedulerC1ERNS_11Time_sourceE T
|
_ZN6Genode23Alarm_timeout_schedulerC1ERNS_11Time_sourceE T
|
||||||
_ZN6Genode23Alarm_timeout_schedulerC2ERNS_11Time_sourceE T
|
_ZN6Genode23Alarm_timeout_schedulerC2ERNS_11Time_sourceE T
|
||||||
_ZN6Genode25env_stack_area_region_mapE B 4
|
_ZN6Genode25env_stack_area_region_mapE B 8
|
||||||
_ZN6Genode26env_stack_area_ram_sessionE B 4
|
_ZN6Genode28env_stack_area_ram_allocatorE B 8
|
||||||
_ZN6Genode29upgrade_pd_quota_non_blockingENS_9Ram_quotaENS_9Cap_quotaE T
|
_ZN6Genode29upgrade_pd_quota_non_blockingENS_9Ram_quotaENS_9Cap_quotaE T
|
||||||
_ZN6Genode3Log3logEv T
|
_ZN6Genode3Log3logEv T
|
||||||
_ZN6Genode3Log8_acquireENS0_4TypeE T
|
_ZN6Genode3Log8_acquireENS0_4TypeE T
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <region_map/region_map.h>
|
#include <region_map/region_map.h>
|
||||||
#include <ram_session/ram_session.h>
|
#include <pd_session/pd_session.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <base/synced_allocator.h>
|
#include <base/synced_allocator.h>
|
||||||
#include <base/thread.h>
|
#include <base/thread.h>
|
||||||
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
|
|
||||||
Region_map *env_stack_area_region_map;
|
Region_map *env_stack_area_region_map;
|
||||||
Ram_session *env_stack_area_ram_session;
|
Ram_allocator *env_stack_area_ram_allocator;
|
||||||
|
|
||||||
void init_stack_area();
|
void init_stack_area();
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ class Stack_area_region_map : public Region_map
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Stack_area_ram_session : Ram_session
|
struct Stack_area_ram_allocator : Ram_allocator
|
||||||
{
|
{
|
||||||
Ram_dataspace_capability alloc(size_t, Cache_attribute) override {
|
Ram_dataspace_capability alloc(size_t, Cache_attribute) override {
|
||||||
return reinterpret_cap_cast<Ram_dataspace>(Native_capability()); }
|
return reinterpret_cap_cast<Ram_dataspace>(Native_capability()); }
|
||||||
@ -133,12 +133,6 @@ struct Stack_area_ram_session : Ram_session
|
|||||||
void free(Ram_dataspace_capability) override { }
|
void free(Ram_dataspace_capability) override { }
|
||||||
|
|
||||||
size_t dataspace_size(Ram_dataspace_capability) const override { return 0; }
|
size_t dataspace_size(Ram_dataspace_capability) const override { return 0; }
|
||||||
|
|
||||||
void ref_account (Ram_session_capability) override { }
|
|
||||||
void transfer_quota (Ram_session_capability, Ram_quota) override { }
|
|
||||||
|
|
||||||
Ram_quota ram_quota () const override { return { 0 }; }
|
|
||||||
Ram_quota used_ram () const override { return { 0 }; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -147,6 +141,6 @@ void Genode::init_stack_area()
|
|||||||
static Stack_area_region_map rm;
|
static Stack_area_region_map rm;
|
||||||
env_stack_area_region_map = &rm;
|
env_stack_area_region_map = &rm;
|
||||||
|
|
||||||
static Stack_area_ram_session ram;
|
static Stack_area_ram_allocator ram;
|
||||||
env_stack_area_ram_session = &ram;
|
env_stack_area_ram_allocator = &ram;
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ namespace Genode {
|
|||||||
class Env;
|
class Env;
|
||||||
class Local_session_id_space;
|
class Local_session_id_space;
|
||||||
|
|
||||||
extern Region_map *env_stack_area_region_map;
|
extern Region_map *env_stack_area_region_map;
|
||||||
extern Ram_session *env_stack_area_ram_session;
|
extern Ram_allocator *env_stack_area_ram_allocator;
|
||||||
|
|
||||||
Thread_capability main_thread_cap();
|
Thread_capability main_thread_cap();
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@ class Genode::Platform_env : public Env_deprecated,
|
|||||||
_heap(&_resources.ram, &_resources.rm, Heap::UNLIMITED),
|
_heap(&_resources.ram, &_resources.rm, Heap::UNLIMITED),
|
||||||
_emergency_ram_ds(_resources.ram.alloc(_emergency_ram_size()))
|
_emergency_ram_ds(_resources.ram.alloc(_emergency_ram_size()))
|
||||||
{
|
{
|
||||||
env_stack_area_ram_session = &_resources.ram;
|
env_stack_area_ram_allocator = &_resources.ram;
|
||||||
env_stack_area_region_map = &_stack_area;
|
env_stack_area_region_map = &_stack_area;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <region_map/region_map.h>
|
#include <region_map/region_map.h>
|
||||||
#include <ram_session/ram_session.h>
|
#include <base/ram_allocator.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/globals.h>
|
#include <base/internal/globals.h>
|
||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
Region_map *env_stack_area_region_map;
|
Region_map *env_stack_area_region_map;
|
||||||
Ram_session *env_stack_area_ram_session;
|
Ram_allocator *env_stack_area_ram_allocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,21 +22,11 @@
|
|||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/stack_allocator.h>
|
#include <base/internal/stack_allocator.h>
|
||||||
|
#include <base/internal/globals.h>
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the managed dataspace holding the stack area
|
|
||||||
*
|
|
||||||
* This function is provided by the process environment.
|
|
||||||
*/
|
|
||||||
namespace Genode {
|
|
||||||
extern Region_map * const env_stack_area_region_map;
|
|
||||||
extern Ram_session * const env_stack_area_ram_session;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Stack::size(size_t const size)
|
void Stack::size(size_t const size)
|
||||||
{
|
{
|
||||||
/* check if the stack needs to be enhanced */
|
/* check if the stack needs to be enhanced */
|
||||||
@ -57,7 +47,7 @@ void Stack::size(size_t const size)
|
|||||||
/* allocate and attach backing store for the stack enhancement */
|
/* allocate and attach backing store for the stack enhancement */
|
||||||
addr_t const ds_addr = _base - ds_size - stack_area_virtual_base();
|
addr_t const ds_addr = _base - ds_size - stack_area_virtual_base();
|
||||||
try {
|
try {
|
||||||
Ram_session * const ram = env_stack_area_ram_session;
|
Ram_allocator * const ram = env_stack_area_ram_allocator;
|
||||||
Ram_dataspace_capability const ds_cap = ram->alloc(ds_size);
|
Ram_dataspace_capability const ds_cap = ram->alloc(ds_size);
|
||||||
Region_map * const rm = env_stack_area_region_map;
|
Region_map * const rm = env_stack_area_region_map;
|
||||||
void * const attach_addr = rm->attach_at(ds_cap, ds_addr, ds_size);
|
void * const attach_addr = rm->attach_at(ds_cap, ds_addr, ds_size);
|
||||||
@ -103,7 +93,7 @@ Thread::_alloc_stack(size_t stack_size, char const *name, bool main_thread)
|
|||||||
/* allocate and attach backing store for the stack */
|
/* allocate and attach backing store for the stack */
|
||||||
Ram_dataspace_capability ds_cap;
|
Ram_dataspace_capability ds_cap;
|
||||||
try {
|
try {
|
||||||
ds_cap = env_stack_area_ram_session->alloc(ds_size);
|
ds_cap = env_stack_area_ram_allocator->alloc(ds_size);
|
||||||
addr_t attach_addr = ds_addr - stack_area_virtual_base();
|
addr_t attach_addr = ds_addr - stack_area_virtual_base();
|
||||||
if (attach_addr != (addr_t)env_stack_area_region_map->attach_at(ds_cap, attach_addr, ds_size))
|
if (attach_addr != (addr_t)env_stack_area_region_map->attach_at(ds_cap, attach_addr, ds_size))
|
||||||
throw Stack_alloc_failed();
|
throw Stack_alloc_failed();
|
||||||
@ -133,7 +123,7 @@ void Thread::_free_stack(Stack *stack)
|
|||||||
stack->~Stack();
|
stack->~Stack();
|
||||||
|
|
||||||
Genode::env_stack_area_region_map->detach((void *)ds_addr);
|
Genode::env_stack_area_region_map->detach((void *)ds_addr);
|
||||||
Genode::env_stack_area_ram_session->free(ds_cap);
|
Genode::env_stack_area_ram_allocator->free(ds_cap);
|
||||||
|
|
||||||
/* stack ready for reuse */
|
/* stack ready for reuse */
|
||||||
Stack_allocator::stack_allocator().free(stack);
|
Stack_allocator::stack_allocator().free(stack);
|
||||||
|
Loading…
Reference in New Issue
Block a user