dde_linux: remove usage of deprecated env()

Fixes #2280.
This commit is contained in:
Josef Söntgen
2017-02-11 17:35:30 +01:00
committed by Christian Helmuth
parent 7d91b1d949
commit a2cff03539
44 changed files with 445 additions and 598 deletions

View File

@ -7,7 +7,7 @@
*/
/*
* Copyright (C) 2014-2016 Genode Labs GmbH
* Copyright (C) 2014-2017 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.
@ -113,7 +113,7 @@ class Lx_kit::Irq : public Lx::Irq
/**
* Constructor
*/
Context(Server::Entrypoint &ep,
Context(Genode::Entrypoint &ep,
Platform::Device &dev)
:
_name(dev),
@ -166,7 +166,7 @@ class Lx_kit::Irq : public Lx::Irq
using Context_slab = Genode::Tslab<Context, 3 * sizeof(Context)>;
using Handler_slab = Genode::Tslab<Handler, 3 * sizeof(Handler)>;
Server::Entrypoint &_ep;
Genode::Entrypoint &_ep;
Lx_kit::List<Context> _list;
Context_slab _context_alloc;
Handler_slab _handler_alloc;
@ -181,14 +181,14 @@ class Lx_kit::Irq : public Lx::Irq
return nullptr;
}
Irq(Server::Entrypoint &ep, Genode::Allocator &alloc)
Irq(Genode::Entrypoint &ep, Genode::Allocator &alloc)
: _ep(ep),
_context_alloc(&alloc),
_handler_alloc(&alloc) { }
public:
static Irq &irq(Server::Entrypoint &ep, Genode::Allocator &alloc)
static Irq &irq(Genode::Entrypoint &ep, Genode::Allocator &alloc)
{
static Irq inst(ep, alloc);
return inst;
@ -227,5 +227,5 @@ class Lx_kit::Irq : public Lx::Irq
** Lx::Irq implementation **
****************************/
Lx::Irq &Lx::Irq::irq(Server::Entrypoint *ep, Genode::Allocator *alloc) {
Lx::Irq &Lx::Irq::irq(Genode::Entrypoint *ep, Genode::Allocator *alloc) {
return Lx_kit::Irq::irq(*ep, *alloc); }

View File

@ -7,7 +7,7 @@
*/
/*
* Copyright (C) 2014-2016 Genode Labs GmbH
* Copyright (C) 2014-2017 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.
@ -80,26 +80,17 @@ class Lx_kit::Slab_backend_alloc : public Lx::Slab_backend_alloc,
public:
Slab_backend_alloc(Genode::Cache_attribute cached)
Slab_backend_alloc(Genode::Env &env, Genode::Allocator &md_alloc,
Genode::Cache_attribute cached)
:
Rm_connection(env),
Region_map_client(Rm_connection::create(VM_SIZE)),
_cached(cached), _index(0), _range(Genode::env()->heap())
_cached(cached), _index(0), _range(&md_alloc)
{
/* reserver attach us, anywere */
_base = Genode::env()->rm_session()->attach(dataspace());
_base = env.rm().attach(dataspace());
}
static Slab_backend_alloc &mem()
{
static Lx_kit::Slab_backend_alloc inst(Genode::CACHED);
return inst;
}
static Slab_backend_alloc &dma()
{
static Lx_kit::Slab_backend_alloc inst(Genode::UNCACHED);
return inst;
}
/**************************************
** Lx::Slab_backend_alloc interface **
@ -177,11 +168,11 @@ class Lx_kit::Malloc : public Lx::Malloc
typedef Lx::Slab_alloc Slab_alloc;
typedef Lx::Slab_backend_alloc Slab_backend_alloc;
Slab_backend_alloc &_back_allocator;
Slab_alloc *_allocator[NUM_SLABS];
Genode::Cache_attribute _cached; /* cached or un-cached memory */
addr_t _start; /* VM region of this allocator */
addr_t _end;
Slab_backend_alloc &_back_allocator;
Genode::Constructible<Slab_alloc> _allocator[NUM_SLABS];
Genode::Cache_attribute _cached; /* cached or un-cached memory */
addr_t _start; /* VM region of this allocator */
addr_t _end;
/**
* Set 'value' at 'addr'
@ -233,21 +224,9 @@ class Lx_kit::Malloc : public Lx::Malloc
{
/* init slab allocators */
for (unsigned i = SLAB_START_LOG2; i <= SLAB_STOP_LOG2; i++)
_allocator[i - SLAB_START_LOG2] = new (Genode::env()->heap())
Slab_alloc(1U << i, alloc);
_allocator[i - SLAB_START_LOG2].construct(1U << i, alloc);
}
static Malloc & mem()
{
static Malloc inst(Slab_backend_alloc::mem(), Genode::CACHED);
return inst;
}
static Malloc & dma()
{
static Malloc inst(Slab_backend_alloc::dma(), Genode::UNCACHED);
return inst;
}
/**************************
** Lx::Malloc interface **
@ -333,7 +312,6 @@ class Lx_kit::Malloc : public Lx::Malloc
_back_allocator.free(ptr);
}
size_t size(void const *a)
{
using namespace Genode;
@ -357,29 +335,42 @@ class Lx_kit::Malloc : public Lx::Malloc
** Lx::Malloc implementation **
*******************************/
static Genode::Constructible<Lx_kit::Slab_backend_alloc> _mem_backend_alloc;
static Genode::Constructible<Lx_kit::Slab_backend_alloc> _dma_backend_alloc;
static Genode::Constructible<Lx_kit::Malloc> _mem_alloc;
static Genode::Constructible<Lx_kit::Malloc> _dma_alloc;
void Lx::malloc_init(Genode::Env &env, Genode::Allocator &md_alloc)
{
_mem_backend_alloc.construct(env, md_alloc, Genode::CACHED);
_dma_backend_alloc.construct(env, md_alloc, Genode::UNCACHED);
_mem_alloc.construct(*_mem_backend_alloc, Genode::CACHED);
_dma_alloc.construct(*_dma_backend_alloc, Genode::UNCACHED);
}
/**
* Cached memory backend allocator
*/
Lx::Slab_backend_alloc &Lx::Slab_backend_alloc::mem() {
return Lx_kit::Slab_backend_alloc::mem(); }
return *_mem_backend_alloc; }
/**
* DMA memory backend allocator
*/
Lx::Slab_backend_alloc &Lx::Slab_backend_alloc::dma() {
return Lx_kit::Slab_backend_alloc::dma(); }
return *_dma_backend_alloc; }
/**
* Cached memory allocator
*/
Lx::Malloc &Lx::Malloc::mem() {
return Lx_kit::Malloc::mem(); }
Lx::Malloc &Lx::Malloc::mem() { return *_mem_alloc; }
/**
* DMA memory allocator
*/
Lx::Malloc &Lx::Malloc::dma() {
return Lx_kit::Malloc::dma(); }
Lx::Malloc &Lx::Malloc::dma() { return *_dma_alloc; }

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2015-2016 Genode Labs GmbH
* Copyright (C) 2015-2017 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.
@ -21,6 +21,7 @@
#include <lx_emul.h>
/* Linux emulation environment includes */
#include <lx_kit/env.h>
#include <lx_kit/internal/list.h>
#include <lx_kit/mapped_io_mem_range.h>
#include <lx_kit/pci_dev_registry.h>
@ -34,8 +35,7 @@ namespace Lx_kit { class Mapped_io_mem_range; }
*
* This class is supposed to be a private utility to support 'ioremap'.
*/
class Lx_kit::Mapped_io_mem_range : public Lx_kit::List<Mapped_io_mem_range>::Element,
public Genode::Rm_connection
class Lx_kit::Mapped_io_mem_range : public Lx_kit::List<Mapped_io_mem_range>::Element
{
private:
@ -47,15 +47,20 @@ class Lx_kit::Mapped_io_mem_range : public Lx_kit::List<Mapped_io_mem_range>::El
public:
Mapped_io_mem_range(Genode::addr_t phys, Genode::size_t size,
Mapped_io_mem_range(Genode::Env &env,
Genode::Rm_connection &rm,
Genode::addr_t phys, Genode::size_t size,
Genode::Io_mem_dataspace_capability ds_cap,
Genode::addr_t offset)
: _size(size),
_phys(phys),
_region_map(Rm_connection::create(size)),
_ds(_region_map.dataspace()),
_virt((Genode::addr_t)_ds.local_addr<void>() | (phys &0xfffUL)) {
_region_map.attach_at(ds_cap, 0, size, offset); }
:
_size(size),
_phys(phys),
_region_map(rm.create(size)),
_ds(env.rm(), _region_map.dataspace()),
_virt((Genode::addr_t)_ds.local_addr<void>() | (phys &0xfffUL))
{
_region_map.attach_at(ds_cap, 0, size, offset);
}
Genode::addr_t phys() const { return _phys; }
Genode::addr_t virt() const { return _virt; }
@ -82,9 +87,12 @@ class Lx_kit::Mapped_io_mem_range : public Lx_kit::List<Mapped_io_mem_range>::El
static Lx_kit::List<Lx_kit::Mapped_io_mem_range> ranges;
/********************************************
/************************************************
** Lx_kit::Mapped_io_mem_range implementation **
********************************************/
************************************************/
static Genode::Constructible<Genode::Rm_connection> _global_rm;
void *Lx::ioremap(addr_t phys_addr, unsigned long size,
Genode::Cache_attribute cache_attribute)
@ -113,9 +121,23 @@ void *Lx::ioremap(addr_t phys_addr, unsigned long size,
return nullptr;
}
Lx_kit::Mapped_io_mem_range *io_mem =
new (env()->heap()) Lx_kit::Mapped_io_mem_range(phys_addr, size,
ds_cap, offset);
if (!_global_rm.constructed()) {
_global_rm.construct(Lx_kit::env().env());
}
Lx_kit::Mapped_io_mem_range *io_mem = nullptr;
retry<Genode::Region_map::Out_of_metadata>(
[&] () {
io_mem = new (&Lx_kit::env().heap())
Lx_kit::Mapped_io_mem_range(Lx_kit::env().env(), *_global_rm,
phys_addr, size, ds_cap, offset);
},
[&] () {
_global_rm->upgrade_ram(16384);
},
10
);
ranges.insert(io_mem);
@ -134,7 +156,7 @@ void Lx::iounmap(volatile void * virt)
if (r->virt() == (addr_t)virt) {
ranges.remove(r);
destroy(env()->heap(), r);
destroy(&Lx_kit::env().heap(), r);
return;
}
}

View File

@ -7,7 +7,7 @@
*/
/*
* Copyright (C) 2014-2016 Genode Labs GmbH
* Copyright (C) 2014-2017 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.
@ -53,22 +53,59 @@ struct Lx_kit::Memory_object_base : Genode::Object_pool<Memory_object_base>::Ent
struct Lx_kit::Ram_object : Memory_object_base
{
Ram_object(Genode::Ram_dataspace_capability cap)
: Memory_object_base(cap) {}
Genode::Ram_session &_ram;
void free() { Genode::env()->ram_session()->free(ram_cap()); }
Ram_object(Genode::Ram_session &ram,
Genode::Ram_dataspace_capability cap)
: Memory_object_base(cap), _ram(ram) {}
void free() { _ram.free(ram_cap()); }
};
struct Lx_kit::Dma_object : Memory_object_base
{
Dma_object(Genode::Ram_dataspace_capability cap)
: Memory_object_base(cap) {}
Platform::Connection &_pci;
void free() { Lx::pci()->free_dma_buffer(ram_cap()); }
Dma_object(Platform::Connection &pci,
Genode::Ram_dataspace_capability cap)
: Memory_object_base(cap), _pci(pci) {}
void free() { _pci.free_dma_buffer(ram_cap()); }
};
/********************
** Pci singletons **
********************/
static Genode::Constructible<Platform::Connection> _global_pci;
static Genode::Allocator *_global_md_alloc;
static Genode::Ram_session *_global_ram;
void Lx::pci_init(Genode::Env &env, Genode::Ram_session &ram,
Genode::Allocator &md_alloc)
{
_global_pci.construct(env);
_global_ram = &ram;
_global_md_alloc = &md_alloc;
}
Platform::Connection *Lx::pci()
{
return &*_global_pci;
}
Lx::Pci_dev_registry *Lx::pci_dev_registry()
{
static Lx::Pci_dev_registry _pci_dev_registry;
return &_pci_dev_registry;
}
/*********************************
** Lx::Backend_alloc interface **
*********************************/
@ -79,24 +116,24 @@ Lx::backend_alloc(Genode::addr_t size, Genode::Cache_attribute cached)
using namespace Genode;
using namespace Lx_kit;
Memory_object_base *o;
Memory_object_base *obj;
Genode::Ram_dataspace_capability cap;
if (cached == CACHED) {
cap = env()->ram_session()->alloc(size);
o = new (env()->heap()) Ram_object(cap);
cap = _global_ram->alloc(size);
obj = new (_global_md_alloc) Ram_object(*_global_ram, cap);
} else {
Genode::size_t donate = size;
cap = retry<Platform::Session::Out_of_metadata>(
[&] () { return Lx::pci()->alloc_dma_buffer(size); },
[&] () { return _global_pci->alloc_dma_buffer(size); },
[&] () {
Lx::pci()->upgrade_ram(donate);
_global_pci->upgrade_ram(donate);
donate = donate * 2 > size ? 4096 : donate * 2;
});
o = new (env()->heap()) Dma_object(cap);
obj = new (_global_md_alloc) Dma_object(*_global_pci, cap);
}
memory_pool.insert(o);
memory_pool.insert(obj);
return cap;
}
@ -107,31 +144,12 @@ void Lx::backend_free(Genode::Ram_dataspace_capability cap)
using namespace Lx_kit;
Memory_object_base *object;
memory_pool.apply(cap, [&] (Memory_object_base *o) {
object = o;
if (!object)
return;
memory_pool.apply(cap, [&] (Memory_object_base *obj) {
object = obj;
if (!object) { return; }
object->free();
memory_pool.remove(object);
});
destroy(env()->heap(), object);
}
/********************
** Pci singletons **
********************/
Platform::Connection *Lx::pci()
{
static Platform::Connection _pci;
return &_pci;
}
Lx::Pci_dev_registry *Lx::pci_dev_registry()
{
static Lx::Pci_dev_registry _pci_dev_registry;
return &_pci_dev_registry;
destroy(_global_md_alloc, object);
}

View File

@ -7,7 +7,7 @@
*/
/*
* Copyright (C) 2014-2016 Genode Labs GmbH
* Copyright (C) 2014-2017 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.
@ -67,16 +67,18 @@ class Lx_kit::Scheduler : public Lx::Scheduler
return _ansi_esc_black();
}
struct Logger : Genode::Thread_deprecated<0x4000>
struct Logger : Genode::Thread
{
Timer::Connection _timer;
Lx::Scheduler &_scheduler;
unsigned const _interval;
Logger(Lx::Scheduler &scheduler, unsigned interval_seconds)
Logger(Genode::Env &env, Lx::Scheduler &scheduler,
unsigned interval_seconds)
:
Genode::Thread_deprecated<0x4000>("logger"),
_scheduler(scheduler), _interval(interval_seconds)
Genode::Thread(env, "logger", 0x4000),
_timer(env), _scheduler(scheduler),
_interval(interval_seconds)
{
start();
}
@ -91,12 +93,13 @@ class Lx_kit::Scheduler : public Lx::Scheduler
}
};
Genode::Constructible<Logger> _logger;
public:
Scheduler()
Scheduler(Genode::Env &env)
{
if (verbose)
new (Genode::env()->heap()) Logger(*this, 10);
if (verbose) { _logger.construct(env, *this, 10); }
}
/*****************************
@ -220,8 +223,8 @@ Lx::Task::~Task()
** Lx::Scheduler implementation **
**********************************/
Lx::Scheduler &Lx::scheduler()
Lx::Scheduler &Lx::scheduler(Genode::Env *env)
{
static Lx_kit::Scheduler inst;
static Lx_kit::Scheduler inst { *env };
return inst;
}

View File

@ -7,14 +7,13 @@
*/
/*
* Copyright (C) 2014-2016 Genode Labs GmbH
* Copyright (C) 2014-2017 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.
*/
/* Genode includes */
#include <os/server.h>
#include <base/tslab.h>
#include <timer_session/connection.h>
@ -84,7 +83,7 @@ class Lx_kit::Timer : public Lx::Timer
::Timer::Connection _timer_conn;
Lx_kit::List<Context> _list;
Lx::Task _timer_task;
Genode::Signal_rpc_member<Lx_kit::Timer> _dispatcher;
Genode::Signal_handler<Lx_kit::Timer> _dispatcher;
Genode::Tslab<Context, 32 * sizeof(Context)> _timer_alloc;
Lx::jiffies_update_func _jiffies_func = nullptr;
@ -161,7 +160,7 @@ class Lx_kit::Timer : public Lx::Timer
/**
* Handle trigger_once signal
*/
void _handle(unsigned)
void _handle()
{
_timer_task.unblock();
@ -173,13 +172,15 @@ class Lx_kit::Timer : public Lx::Timer
/**
* Constructor
*/
Timer(Server::Entrypoint &ep, unsigned long &jiffies)
Timer(Genode::Env &env, Genode::Entrypoint &ep,
Genode::Allocator &alloc, unsigned long &jiffies)
:
_jiffies(jiffies),
_timer_conn(env),
_timer_task(Timer::run_timer, reinterpret_cast<void*>(this),
"timer", Lx::Task::PRIORITY_2, Lx::scheduler()),
_dispatcher(ep, *this, &Lx_kit::Timer::_handle),
_timer_alloc(Genode::env()->heap())
_timer_alloc(&alloc)
{
_timer_conn.sigh(_dispatcher);
}
@ -215,6 +216,7 @@ class Lx_kit::Timer : public Lx::Timer
/*************************
** Lx::Timer interface **
*************************/
void add(void *timer, Type type)
{
Context *t = nullptr;
@ -294,6 +296,9 @@ class Lx_kit::Timer : public Lx::Timer
void register_jiffies_func(Lx::jiffies_update_func func) {
_jiffies_func = func; }
void usleep(unsigned us) {
_timer_conn.usleep(us); }
};
@ -301,9 +306,11 @@ class Lx_kit::Timer : public Lx::Timer
** Lx::Timer implementation **
******************************/
Lx::Timer &Lx::timer(Server::Entrypoint *ep, unsigned long *jiffies)
Lx::Timer &Lx::timer(Genode::Env *env, Genode::Entrypoint *ep,
Genode::Allocator *md_alloc,
unsigned long *jiffies)
{
static Lx_kit::Timer inst(*ep, *jiffies);
static Lx_kit::Timer inst(*env, *ep, *md_alloc, *jiffies);
return inst;
}