This patch adjusts the implementation of the base library and core such that the code no longer relies on deprecated APIs except for very few cases, mainly to keep those deprecated APIs in tact for now. The most prominent changes are: - Removing the use of base/printf.h - Removing of the log backend for printf. The 'Console' with the format-string parser is still there along with 'snprintf.h' because the latter is still used at a few places, most prominently the 'Connection' classes. - Removing the notion of a RAM session, which does not exist in Genode anymore. Still the types were preserved (by typedefs to PD session) to keep up compatibility. But this transition should come to an end now. - Slight rennovation of core's tracing service, e.g., the use of an Attached_dataspace as the Argument_buffer. - Reducing the reliance on global accessors like deprecated_env() or core_env(). Still there is a longish way to go to eliminate all such calls. A useful pattern (or at least a stop-gap solution) is to pass the 'Env' to the individual compilation units via init functions. - Avoiding the use of the old 'Child_policy::resolve_session_request' interface that returned a 'Service' instead of a 'Route'. Issue #1987
110 lines
2.8 KiB
C++
110 lines
2.8 KiB
C++
/*
|
|
* \brief Linux-specific support code for the thread API
|
|
* \author Norman Feske
|
|
* \date 2010-01-13
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2010-2017 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU Affero General Public License version 3.
|
|
*/
|
|
|
|
/* Genode includes */
|
|
#include <rm_session/rm_session.h>
|
|
#include <base/ram_allocator.h>
|
|
#include <base/thread.h>
|
|
|
|
/* base-internal includes */
|
|
#include <base/internal/stack_area.h>
|
|
#include <base/internal/globals.h>
|
|
|
|
|
|
/**
|
|
* Region-map for allocating stacks
|
|
*
|
|
* This class corresponds to the managed dataspace that is normally used for
|
|
* organizing stacks within the stack. It "emulates" the sub address space by
|
|
* adjusting the local address argument to 'attach' with the offset of the
|
|
* stack area.
|
|
*/
|
|
class Stack_area_region_map : public Genode::Region_map
|
|
{
|
|
public:
|
|
|
|
Stack_area_region_map()
|
|
{
|
|
flush_stack_area();
|
|
reserve_stack_area();
|
|
}
|
|
|
|
/**
|
|
* Attach backing store to stack area
|
|
*/
|
|
Local_addr attach(Genode::Dataspace_capability, Genode::size_t size,
|
|
Genode::off_t, bool, Local_addr local_addr, bool,
|
|
bool) override
|
|
{
|
|
using namespace Genode;
|
|
|
|
/* convert stack-area-relative to absolute virtual address */
|
|
addr_t addr = (addr_t)local_addr + stack_area_virtual_base();
|
|
|
|
/* use anonymous mmap for allocating stack backing store */
|
|
int flags = MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE;
|
|
int prot = PROT_READ | PROT_WRITE;
|
|
void *res = lx_mmap((void*)addr, size, prot, flags, -1, 0);
|
|
|
|
if ((addr_t)res != addr)
|
|
throw Region_conflict();
|
|
|
|
return local_addr;
|
|
}
|
|
|
|
void detach(Local_addr local_addr) override
|
|
{
|
|
Genode::warning("stack area detach from ", (void*)local_addr,
|
|
" - not implemented");
|
|
}
|
|
|
|
void fault_handler(Genode::Signal_context_capability) override { }
|
|
|
|
State state() override { return State(); }
|
|
|
|
Genode::Dataspace_capability dataspace() override {
|
|
return Genode::Dataspace_capability(); }
|
|
};
|
|
|
|
|
|
struct Stack_area_ram_allocator : Genode::Ram_allocator
|
|
{
|
|
Genode::Ram_dataspace_capability alloc(Genode::size_t,
|
|
Genode::Cache_attribute) override {
|
|
return Genode::Ram_dataspace_capability(); }
|
|
|
|
void free(Genode::Ram_dataspace_capability) override { }
|
|
|
|
Genode::size_t dataspace_size(Genode::Ram_dataspace_capability) const override { return 0; }
|
|
};
|
|
|
|
|
|
/**
|
|
* Return single instance of the stack-area RM and RAM session
|
|
*/
|
|
namespace Genode {
|
|
|
|
Region_map *env_stack_area_region_map;
|
|
Ram_allocator *env_stack_area_ram_allocator;
|
|
|
|
void init_stack_area()
|
|
{
|
|
static Stack_area_region_map rm_inst;
|
|
env_stack_area_region_map = &rm_inst;
|
|
|
|
static Stack_area_ram_allocator ram_inst;
|
|
env_stack_area_ram_allocator = &ram_inst;
|
|
}
|
|
}
|
|
|