mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
parent
7d91b1d949
commit
a2cff03539
@ -137,7 +137,7 @@ set firmware_modules {
|
||||
set boot_modules {
|
||||
core ld.lib.so init timer rtc_drv report_rom dynamic_rom
|
||||
vfs_jitterentropy.lib.so
|
||||
libc.lib.so libcrypto.lib.so libssl.lib.so
|
||||
libc.lib.so libm.lib.so libcrypto.lib.so libssl.lib.so
|
||||
wpa_driver_nl80211.lib.so wpa_supplicant.lib.so
|
||||
wifi.lib.so
|
||||
wifi_drv
|
||||
|
@ -216,12 +216,6 @@ extern struct atomic_notifier_head panic_notifier_list;
|
||||
(void) (&_min1 == &_min2); \
|
||||
_min1 < _min2 ? _min1 : _min2; })
|
||||
|
||||
#define max(x, y) ({ \
|
||||
typeof(x) _max1 = (x); \
|
||||
typeof(y) _max2 = (y); \
|
||||
(void) (&_max1 == &_max2); \
|
||||
_max1 > _max2 ? _max1 : _max2; })
|
||||
|
||||
#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi)
|
||||
|
||||
/* linux/i2c.h */
|
||||
|
@ -1021,7 +1021,8 @@ void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size)
|
||||
{
|
||||
enum { VIDEO_ROM_BASE = 0xC0000, VIDEO_ROM_SIZE = 0x20000 };
|
||||
|
||||
static Genode::Attached_io_mem_dataspace vrom(VIDEO_ROM_BASE, VIDEO_ROM_SIZE);
|
||||
static Genode::Attached_io_mem_dataspace vrom(Lx_kit::env().env(),
|
||||
VIDEO_ROM_BASE, VIDEO_ROM_SIZE);
|
||||
*size = VIDEO_ROM_SIZE;
|
||||
return vrom.local_addr<void*>();
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 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.
|
||||
@ -17,13 +17,14 @@
|
||||
#include <base/component.h>
|
||||
#include <base/heap.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <os/config.h>
|
||||
|
||||
/* Server related local includes */
|
||||
#include <component.h>
|
||||
|
||||
/* Linux emulation environment includes */
|
||||
#include <lx_emul.h>
|
||||
#include <lx_kit/env.h>
|
||||
#include <lx_kit/malloc.h>
|
||||
#include <lx_kit/scheduler.h>
|
||||
#include <lx_kit/timer.h>
|
||||
#include <lx_kit/irq.h>
|
||||
@ -48,39 +49,51 @@ struct Main
|
||||
Genode::Heap heap { env.ram(), env.rm() };
|
||||
Framebuffer::Root root { env, heap, config };
|
||||
|
||||
/* init singleton Lx::Timer */
|
||||
Lx::Timer &timer = Lx::timer(&ep, &jiffies);
|
||||
|
||||
/* init singleton Lx::Irq */
|
||||
Lx::Irq &irq = Lx::Irq::irq(&ep, &heap);
|
||||
|
||||
/* init singleton Lx::Work */
|
||||
Lx::Work &work = Lx::Work::work_queue(&heap);
|
||||
|
||||
/* Linux task that handles the initialization */
|
||||
Lx::Task linux { run_linux, reinterpret_cast<void*>(this), "linux",
|
||||
Lx::Task::PRIORITY_0, Lx::scheduler() };
|
||||
Genode::Constructible<Lx::Task> linux;
|
||||
|
||||
Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
Genode::log("--- intel framebuffer driver ---");
|
||||
|
||||
Lx_kit::construct_env(env);
|
||||
|
||||
/* init singleton Lx::Scheduler */
|
||||
Lx::scheduler(&env);
|
||||
|
||||
Lx::pci_init(env, env.ram(), heap);
|
||||
Lx::malloc_init(env, heap);
|
||||
|
||||
/* init singleton Lx::Timer */
|
||||
Lx::timer(&env, &ep, &heap, &jiffies);
|
||||
|
||||
/* init singleton Lx::Irq */
|
||||
Lx::Irq::irq(&ep, &heap);
|
||||
|
||||
/* init singleton Lx::Work */
|
||||
Lx::Work::work_queue(&heap);
|
||||
|
||||
linux.construct(run_linux, reinterpret_cast<void*>(this),
|
||||
"linux", Lx::Task::PRIORITY_0, Lx::scheduler());
|
||||
|
||||
/* give all task a first kick before returning */
|
||||
Lx::scheduler().schedule();
|
||||
}
|
||||
|
||||
void announce() { env.parent().announce(ep.manage(root)); }
|
||||
|
||||
Lx::Task &linux_task() { return *linux; }
|
||||
};
|
||||
|
||||
|
||||
struct Policy_agent
|
||||
{
|
||||
Main &main;
|
||||
Genode::Signal_rpc_member<Policy_agent> sd;
|
||||
Genode::Signal_handler<Policy_agent> sd;
|
||||
|
||||
void handle(unsigned)
|
||||
void handle()
|
||||
{
|
||||
main.linux.unblock();
|
||||
main.linux_task().unblock();
|
||||
Lx::scheduler().schedule();
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,8 @@ SRC_CC += irq.cc \
|
||||
printf.cc \
|
||||
scheduler.cc \
|
||||
timer.cc \
|
||||
work.cc
|
||||
work.cc \
|
||||
env.cc
|
||||
|
||||
INC_DIR += $(REP_DIR)/src/include
|
||||
|
||||
|
@ -5,7 +5,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.
|
||||
@ -105,7 +105,7 @@ static int generatewpa_supplicant_conf(char const **p, Genode::size_t *len, char
|
||||
|
||||
struct Wlan_configration
|
||||
{
|
||||
Genode::Attached_rom_dataspace config_rom { "wlan_configuration" };
|
||||
Genode::Attached_rom_dataspace config_rom;
|
||||
Genode::Signal_handler<Wlan_configration> dispatcher;
|
||||
Genode::Lock update_lock;
|
||||
|
||||
@ -208,9 +208,10 @@ struct Wlan_configration
|
||||
|
||||
void _handle_update() { _update_configuration(); }
|
||||
|
||||
Wlan_configration(Genode::Entrypoint &ep)
|
||||
Wlan_configration(Genode::Env &env)
|
||||
:
|
||||
dispatcher(ep, *this, &Wlan_configration::_handle_update)
|
||||
config_rom(env, "wlan_configuration"),
|
||||
dispatcher(env.ep(), *this, &Wlan_configration::_handle_update)
|
||||
{
|
||||
config_rom.sigh(dispatcher);
|
||||
_update_configuration();
|
||||
@ -244,7 +245,7 @@ struct Main
|
||||
wpa->start();
|
||||
|
||||
try {
|
||||
wlan_config = new (&heap) Wlan_configration(env.ep());
|
||||
wlan_config = new (&heap) Wlan_configration(env);
|
||||
} catch (...) {
|
||||
Genode::warning("could not create Wlan_configration handler");
|
||||
}
|
||||
|
@ -5,7 +5,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.
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
/* entry function */
|
||||
extern "C" int wpa_main(int debug_msg, int connected_scan_interval);
|
||||
extern "C" void wpa_reporter_init(void *env);
|
||||
extern "C" void wpa_conf_reload(void);
|
||||
|
||||
class Wpa_thread : public Genode::Thread
|
||||
@ -38,7 +39,9 @@ class Wpa_thread : public Genode::Thread
|
||||
Thread(env, "wpa_supplicant", 8*1024*sizeof(long)),
|
||||
_lock(lock), _exit(-1),
|
||||
_debug_msg(debug_msg), _connected_scan_interval(connected_scan_interval)
|
||||
{ }
|
||||
{
|
||||
wpa_reporter_init(&env);
|
||||
}
|
||||
|
||||
void entry()
|
||||
{
|
||||
|
@ -5,13 +5,14 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Linux kint includes */
|
||||
#include <lx_kit/env.h>
|
||||
#include <lx_kit/internal/task.h>
|
||||
|
||||
typedef Lx::Task::List_element Wait_le;
|
||||
@ -20,25 +21,23 @@ typedef Lx::Task::List Wait_list;
|
||||
|
||||
void init_waitqueue_head(wait_queue_head_t *wq)
|
||||
{
|
||||
wq->list = new (Genode::env()->heap()) Wait_list;
|
||||
wq->list = new (&Lx_kit::env().heap()) Wait_list;
|
||||
}
|
||||
|
||||
|
||||
void remove_wait_queue(wait_queue_head_t *wq, wait_queue_t *wait)
|
||||
{
|
||||
Wait_list *list = static_cast<Wait_list*>(wq->list);
|
||||
if (!list)
|
||||
return;
|
||||
if (!list) { return; }
|
||||
|
||||
destroy(Genode::env()->heap(), list);
|
||||
destroy(&Lx_kit::env().heap(), list);
|
||||
}
|
||||
|
||||
|
||||
int waitqueue_active(wait_queue_head_t *wq)
|
||||
{
|
||||
Wait_list *list = static_cast<Wait_list*>(wq->list);
|
||||
if (!list)
|
||||
return 0;
|
||||
if (!list) { return 0; }
|
||||
|
||||
return list->first() ? 1 : 0;
|
||||
}
|
||||
@ -55,8 +54,7 @@ void __wake_up(wait_queue_head_t *wq, bool all)
|
||||
|
||||
Wait_le *le = list->first();
|
||||
do {
|
||||
if (!le)
|
||||
return;
|
||||
if (!le) { return; }
|
||||
|
||||
le->object()->unblock();
|
||||
} while (all && (le = le->next()));
|
||||
|
@ -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.
|
||||
@ -14,21 +14,32 @@
|
||||
/* Genode includes */
|
||||
#include <timer_session/connection.h>
|
||||
|
||||
#include <lx_kit/env.h>
|
||||
#include <lx_kit/timer.h>
|
||||
|
||||
/*
|
||||
* XXX We may consider to use the Lx::Timer instead of opening a dedicated
|
||||
* timer session.
|
||||
* XXX "We may consider to use the Lx::Timer instead of opening a dedicated
|
||||
* timer session" which I tried during the deprecation warning removal
|
||||
* but it did not work out. At least the intel_fb at that point got stuck
|
||||
* because the workqueue task got mutex blocked.
|
||||
*/
|
||||
static Timer::Connection _delay_timer;
|
||||
static Genode::Constructible<Timer::Connection> _delay_timer;
|
||||
|
||||
static inline void __delay_timer(unsigned long usecs)
|
||||
{
|
||||
if (!_delay_timer.constructed()) {
|
||||
_delay_timer.construct(Lx_kit::env().env());
|
||||
}
|
||||
|
||||
void udelay(unsigned long usecs) { _delay_timer.usleep(usecs); }
|
||||
_delay_timer->usleep(usecs);
|
||||
}
|
||||
|
||||
void udelay(unsigned long usecs) { __delay_timer(usecs); }
|
||||
|
||||
|
||||
void msleep(unsigned int msecs)
|
||||
{
|
||||
_delay_timer.msleep(msecs);
|
||||
__delay_timer(1000 * msecs);
|
||||
Lx::timer_update_jiffies();
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <lx_kit/addr_to_page_mapping.h>
|
||||
#include <lx_kit/backend_alloc.h>
|
||||
#include <lx_kit/malloc.h>
|
||||
#include <lx_kit/env.h>
|
||||
|
||||
|
||||
struct page *alloc_pages(gfp_t gfp_mask, unsigned int order)
|
||||
@ -24,7 +25,7 @@ struct page *alloc_pages(gfp_t gfp_mask, unsigned int order)
|
||||
size_t size = PAGE_SIZE << order;
|
||||
|
||||
Genode::Ram_dataspace_capability ds_cap = Lx::backend_alloc(size, Genode::UNCACHED);
|
||||
page->addr = Genode::env()->rm_session()->attach(ds_cap);
|
||||
page->addr = Lx_kit::env().rm().attach(ds_cap);
|
||||
page->paddr = Genode::Dataspace_client(ds_cap).phys_addr();
|
||||
|
||||
if (!page->addr) {
|
||||
|
@ -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.
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
/* Linux kit includes */
|
||||
#include <lx_kit/scheduler.h>
|
||||
|
||||
#include <lx_kit/env.h>
|
||||
|
||||
enum { MUTEX_UNLOCKED = 1, MUTEX_LOCKED = 0, MUTEX_WAITERS = -1 };
|
||||
|
||||
@ -23,7 +23,7 @@ void mutex_init(struct mutex *m)
|
||||
|
||||
m->state = MUTEX_UNLOCKED;
|
||||
m->holder = nullptr;
|
||||
m->waiters = new (Genode::env()->heap()) Lx::Task::List;
|
||||
m->waiters = nullptr;
|
||||
m->id = ++id;
|
||||
m->counter = 0;
|
||||
}
|
||||
@ -31,9 +31,14 @@ void mutex_init(struct mutex *m)
|
||||
|
||||
void mutex_destroy(struct mutex *m)
|
||||
{
|
||||
/* FIXME potentially blocked tasks are not unblocked */
|
||||
Lx::Task::List *waiters = static_cast<Lx::Task::List *>(m->waiters);
|
||||
|
||||
Genode::destroy(Genode::env()->heap(), static_cast<Lx::Task::List *>(m->waiters));
|
||||
/* FIXME potentially blocked tasks are not unblocked */
|
||||
if (waiters->first()) {
|
||||
Genode::error(__func__, "destroying non-empty waiters list");
|
||||
}
|
||||
|
||||
Genode::destroy(&Lx_kit::env().heap(), waiters);
|
||||
|
||||
m->holder = nullptr;
|
||||
m->waiters = nullptr;
|
||||
@ -42,8 +47,18 @@ void mutex_destroy(struct mutex *m)
|
||||
}
|
||||
|
||||
|
||||
static inline void __check_or_initialize_mutex(struct mutex *m)
|
||||
{
|
||||
if (!m->waiters) {
|
||||
m->waiters = new (&Lx_kit::env().heap()) Lx::Task::List;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void mutex_lock(struct mutex *m)
|
||||
{
|
||||
__check_or_initialize_mutex(m);
|
||||
|
||||
while (1) {
|
||||
if (m->state == MUTEX_UNLOCKED) {
|
||||
m->state = MUTEX_LOCKED;
|
||||
|
@ -5,13 +5,14 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Linux kit includes */
|
||||
#include <lx_kit/env.h>
|
||||
#include <lx_kit/pci_dev_registry.h>
|
||||
#include <lx_kit/mapped_io_mem_range.h>
|
||||
|
||||
@ -49,7 +50,7 @@ extern "C" int pci_register_driver(struct pci_driver *driver)
|
||||
return false;
|
||||
|
||||
/* create 'pci_dev' struct for matching device */
|
||||
pci_dev = new (env()->heap()) Lx::Pci_dev(cap);
|
||||
pci_dev = new (&Lx_kit::env().heap()) Lx::Pci_dev(cap);
|
||||
|
||||
/* enable ioremap to work */
|
||||
Lx::pci_dev_registry()->insert(pci_dev);
|
||||
|
@ -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.
|
||||
@ -17,7 +17,6 @@
|
||||
#define _LX_KIT__IRQ_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <os/server.h>
|
||||
#include <platform_device/platform_device.h>
|
||||
|
||||
|
||||
@ -27,7 +26,7 @@ class Lx::Irq
|
||||
{
|
||||
public:
|
||||
|
||||
static Irq &irq(Server::Entrypoint *ep = nullptr,
|
||||
static Irq &irq(Genode::Entrypoint *ep = nullptr,
|
||||
Genode::Allocator *alloc = nullptr);
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
@ -25,6 +25,8 @@
|
||||
namespace Lx {
|
||||
|
||||
class Malloc;
|
||||
|
||||
void malloc_init(Genode::Env &env, Genode::Allocator &md_alloc);
|
||||
}
|
||||
|
||||
|
||||
|
26
repos/dde_linux/src/include/lx_kit/pci.h
Normal file
26
repos/dde_linux/src/include/lx_kit/pci.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* \brief PCI backend
|
||||
* \author Josef Soentgen
|
||||
* \date 2017-02-12
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 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.
|
||||
*/
|
||||
|
||||
#ifndef _LX_KIT__PCI_H_
|
||||
#define _LX_KIT__PCI_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
|
||||
|
||||
namespace Lx {
|
||||
|
||||
void pci_init(Genode::Env&, Genode::Ram_session&, Genode::Allocator&);
|
||||
}
|
||||
|
||||
#endif /* _LX_KIT__PCI_H_ */
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 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.
|
||||
@ -15,6 +15,7 @@
|
||||
#define _LX_KIT__PCI_DEV_REGISTRY_H_
|
||||
|
||||
/* Linux emulation environment includes */
|
||||
#include <lx_kit/pci.h>
|
||||
#include <lx_kit/internal/pci_dev.h>
|
||||
|
||||
namespace Lx {
|
||||
|
@ -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.
|
||||
@ -16,6 +16,9 @@
|
||||
#ifndef _LX_KIT__SCHEDULER_H_
|
||||
#define _LX_KIT__SCHEDULER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
|
||||
namespace Lx {
|
||||
|
||||
class Task;
|
||||
@ -26,7 +29,7 @@ namespace Lx {
|
||||
*
|
||||
* Implementation must be provided by the driver.
|
||||
*/
|
||||
Scheduler &scheduler();
|
||||
Scheduler &scheduler(Genode::Env *env = nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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.
|
||||
@ -17,7 +17,7 @@
|
||||
#define _LX_KIT__TIMER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <os/server.h>
|
||||
#include <base/entrypoint.h>
|
||||
|
||||
namespace Lx {
|
||||
|
||||
@ -32,7 +32,9 @@ namespace Lx {
|
||||
* \param jiffies_ptr pointer to jiffies counter to be periodically
|
||||
* updated
|
||||
*/
|
||||
Timer &timer(Server::Entrypoint *ep = nullptr,
|
||||
Timer &timer(Genode::Env *env = nullptr,
|
||||
Genode::Entrypoint *ep = nullptr,
|
||||
Genode::Allocator *md_alloc = nullptr,
|
||||
unsigned long *jiffies_ptr = nullptr);
|
||||
|
||||
void timer_update_jiffies();
|
||||
@ -47,6 +49,7 @@ class Lx::Timer
|
||||
public:
|
||||
|
||||
enum Type { LIST, HR };
|
||||
|
||||
/**
|
||||
* Add new linux timer
|
||||
*/
|
||||
@ -81,6 +84,11 @@ class Lx::Timer
|
||||
* Update jiffie counter
|
||||
*/
|
||||
virtual void update_jiffies() = 0;
|
||||
|
||||
/**
|
||||
* Suspend calling thread
|
||||
*/
|
||||
virtual void usleep(unsigned us) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -5,13 +5,13 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 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 */
|
||||
/* Genode includes */
|
||||
#include <base/log.h>
|
||||
#include <util/string.h>
|
||||
|
||||
@ -33,323 +33,3 @@ extern "C" char *getenv(const char *name)
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
#include <base/env.h>
|
||||
#include <base/log.h>
|
||||
#include <base/snprintf.h>
|
||||
#include <dataspace/client.h>
|
||||
#include <timer_session/connection.h>
|
||||
#include <rom_session/connection.h>
|
||||
#include <util/string.h>
|
||||
|
||||
#include <lx_emul.h>
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*************
|
||||
** errno.h **
|
||||
*************/
|
||||
|
||||
int errno;
|
||||
|
||||
|
||||
/*************
|
||||
** stdio.h **
|
||||
*************/
|
||||
|
||||
FILE *stdout;
|
||||
FILE *stderr;
|
||||
|
||||
|
||||
void *malloc(size_t size)
|
||||
{
|
||||
/* align on pointer size */
|
||||
size = size + ((sizeof(Genode::addr_t)-1) & ~(sizeof(Genode::addr_t)-1));
|
||||
|
||||
size_t rsize = size + sizeof (Genode::addr_t);
|
||||
|
||||
void *addr = 0;
|
||||
if (!Genode::env()->heap()->alloc(size, &addr))
|
||||
return 0;
|
||||
|
||||
*(Genode::addr_t*)addr = rsize;
|
||||
return ((Genode::addr_t*)addr) + 1;
|
||||
}
|
||||
|
||||
|
||||
void *calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
#define MUL_NO_OVERFLOW (1UL << (sizeof(size_t) * 4))
|
||||
if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
|
||||
nmemb > 0 && SIZE_MAX / nmemb < size) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size *= nmemb;
|
||||
|
||||
void *addr = malloc(size);
|
||||
Genode::memset(addr, 0, size);
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
||||
void free(void *ptr)
|
||||
{
|
||||
if (!ptr)
|
||||
return;
|
||||
|
||||
Genode::addr_t *addr = ((Genode::addr_t*)ptr) - 1;
|
||||
Genode::env()->heap()->free(addr, *addr);
|
||||
}
|
||||
|
||||
void *realloc(void *ptr, Genode::size_t size)
|
||||
{
|
||||
if (!size)
|
||||
free(ptr);
|
||||
|
||||
void *n = malloc(size);
|
||||
size_t s = *((size_t *)ptr - 1);
|
||||
|
||||
Genode::memcpy(n, ptr, Genode::min(s, size));
|
||||
|
||||
free(ptr);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
/**************
|
||||
** stdlib.h **
|
||||
**************/
|
||||
|
||||
static char getenv_HZ[] = "100";
|
||||
static char getenv_TICKS_PER_USEC[] = "10000";
|
||||
|
||||
char *getenv(const char *name)
|
||||
{
|
||||
/* these values must match the ones of lx_emul wifi */
|
||||
|
||||
if (Genode::strcmp(name, "HZ") == 0) return getenv_HZ;
|
||||
if (Genode::strcmp(name, "TICKS_PER_USEC") == 0) return getenv_TICKS_PER_USEC;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
long int strtol(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
long res = 0;
|
||||
if (base != 0 && base != 10) {
|
||||
Genode::error("strtol: base of ", base, " is not supported");
|
||||
return 0;
|
||||
}
|
||||
Genode::ascii_to(nptr, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
double strtod(const char *nptr, char **endptr)
|
||||
{
|
||||
double res = 0;
|
||||
Genode::ascii_to(nptr, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/********************
|
||||
** linux/string.h **
|
||||
********************/
|
||||
|
||||
size_t strcspn(const char *s, const char *reject)
|
||||
{
|
||||
for (char const *p = s; *p; p++) {
|
||||
char c = *p;
|
||||
|
||||
for (char const *r = reject; *r; r++) {
|
||||
char d = *r;
|
||||
if (c == d)
|
||||
return (p - 1 - s);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char *strdup(const char *s)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
|
||||
char *p = (char *) malloc(len + 1);
|
||||
|
||||
return strncpy(p, s, len + 1);
|
||||
}
|
||||
|
||||
|
||||
size_t strlen(const char *s)
|
||||
{
|
||||
return Genode::strlen(s);
|
||||
}
|
||||
|
||||
|
||||
int strcasecmp(const char* s1, const char *s2)
|
||||
{
|
||||
return Genode::strcmp(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
int strcmp(const char* s1, const char *s2)
|
||||
{
|
||||
return Genode::strcmp(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
int strncmp(const char *s1, const char *s2, size_t len)
|
||||
{
|
||||
return Genode::strcmp(s1, s2, len);
|
||||
}
|
||||
|
||||
|
||||
char *strchr(const char *p, int ch)
|
||||
{
|
||||
char c;
|
||||
c = ch;
|
||||
for (;; ++p) {
|
||||
if (*p == c)
|
||||
return ((char *)p);
|
||||
if (*p == '\0')
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void *memchr(const void *s, int c, size_t n)
|
||||
{
|
||||
const unsigned char *p = reinterpret_cast<const unsigned char*>(s);
|
||||
while (n-- != 0) {
|
||||
if ((unsigned char)c == *p++) {
|
||||
return (void *)(p - 1);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
char *strnchr(const char *p, size_t count, int ch)
|
||||
{
|
||||
char c;
|
||||
c = ch;
|
||||
for (; count; ++p, count--) {
|
||||
if (*p == c)
|
||||
return ((char *)p);
|
||||
if (*p == '\0')
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char *strncat(char *dst, const char *src, size_t n)
|
||||
{
|
||||
char *p = dst;
|
||||
while (*p++) ;
|
||||
|
||||
while ((*p = *src) && (n-- > 0)) {
|
||||
++src;
|
||||
++p;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
char *strcpy(char *dst, const char *src)
|
||||
{
|
||||
char *p = dst;
|
||||
|
||||
while ((*dst = *src)) {
|
||||
++src;
|
||||
++dst;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
char *strncpy(char *dst, const char* src, size_t n)
|
||||
{
|
||||
return Genode::strncpy(dst, src, n);
|
||||
}
|
||||
|
||||
|
||||
int snprintf(char *str, size_t size, const char *format, ...)
|
||||
{
|
||||
va_list list;
|
||||
|
||||
va_start(list, format);
|
||||
Genode::String_console sc(str, size);
|
||||
sc.vprintf(format, list);
|
||||
va_end(list);
|
||||
|
||||
return sc.len();
|
||||
}
|
||||
|
||||
|
||||
int vsnprintf(char *str, size_t size, const char *format, va_list args)
|
||||
{
|
||||
Genode::String_console sc(str, size);
|
||||
sc.vprintf(format, args);
|
||||
|
||||
return sc.len();
|
||||
}
|
||||
|
||||
|
||||
int asprintf(char **strp, const char *fmt, ...)
|
||||
{
|
||||
/* XXX for now, let's hope strings are not getting longer than 256 bytes */
|
||||
enum { MAX_STRING_LENGTH = 256 };
|
||||
char *p = (char*)malloc(MAX_STRING_LENGTH);
|
||||
if (!p)
|
||||
return -1;
|
||||
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
Genode::String_console sc(p, MAX_STRING_LENGTH);
|
||||
sc.vprintf(fmt, args);
|
||||
va_end(args);
|
||||
|
||||
return strlen(p);
|
||||
}
|
||||
|
||||
|
||||
/**************
|
||||
** unistd.h **
|
||||
**************/
|
||||
|
||||
int getpagesize(void) {
|
||||
return 4096; }
|
||||
|
||||
|
||||
pid_t getpid(void) {
|
||||
return 42; }
|
||||
|
||||
|
||||
/************
|
||||
** time.h **
|
||||
************/
|
||||
|
||||
extern unsigned long jiffies;
|
||||
|
||||
time_t time(time_t *t)
|
||||
{
|
||||
return jiffies;
|
||||
}
|
||||
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 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.
|
||||
@ -61,12 +61,10 @@ using namespace Wifi;
|
||||
extern Socket_call socket_call;
|
||||
|
||||
|
||||
struct Socket_fd : public Genode::List<Socket_fd>::Element
|
||||
struct Socket_fd
|
||||
{
|
||||
Socket *s;
|
||||
int fd;
|
||||
|
||||
Socket_fd(Socket *s, int fd) : s(s), fd(fd) { }
|
||||
};
|
||||
|
||||
|
||||
@ -75,47 +73,77 @@ class Socket_registry
|
||||
private :
|
||||
|
||||
/* abritary value (it goes to eleven!) */
|
||||
enum { SOCKETS_INITIAL_VALUE = 11, };
|
||||
enum {
|
||||
SOCKETS_INITIAL_VALUE = 11,
|
||||
MAX_SOCKETS = 7,
|
||||
};
|
||||
|
||||
static Socket_fd _socket_fd[MAX_SOCKETS];
|
||||
static unsigned _sockets;
|
||||
|
||||
static Genode::List<Socket_fd> *_list() /* XXX ptr array instead of list? */
|
||||
template <typename FUNC>
|
||||
static void _for_each_socket_fd(FUNC const & func)
|
||||
{
|
||||
static Genode::List<Socket_fd> _l;
|
||||
return &_l;
|
||||
for (int i = 0; i < MAX_SOCKETS; i++) {
|
||||
if (func(_socket_fd[i])) { break; }
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static int insert(Socket *s)
|
||||
{
|
||||
Socket_fd *sfd = new (Genode::env()->heap()) Socket_fd(s, ++_sockets);
|
||||
int fd = -1;
|
||||
|
||||
_list()->insert(sfd);
|
||||
auto lambda = [&] (Socket_fd &sfd) {
|
||||
if (sfd.s != nullptr) { return false; }
|
||||
|
||||
return sfd->fd;
|
||||
sfd.s = s;
|
||||
sfd.fd = ++_sockets;
|
||||
|
||||
/* return fd */
|
||||
fd = sfd.fd;
|
||||
return true;
|
||||
};
|
||||
|
||||
_for_each_socket_fd(lambda);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
static void remove(Socket *s)
|
||||
{
|
||||
for (Socket_fd *sfd = _list()->first(); sfd; sfd = sfd->next())
|
||||
if (sfd->s == s) {
|
||||
_list()->remove(sfd);
|
||||
destroy(Genode::env()->heap(), sfd);
|
||||
break;
|
||||
}
|
||||
auto lambda = [&] (Socket_fd &sfd) {
|
||||
if (sfd.s != s) { return false; }
|
||||
|
||||
sfd.s = nullptr;
|
||||
sfd.fd = 0;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
_for_each_socket_fd(lambda);
|
||||
}
|
||||
|
||||
static Socket *find(int fd)
|
||||
{
|
||||
for (Socket_fd *sfd = _list()->first(); sfd; sfd = sfd->next())
|
||||
if (sfd->fd == fd)
|
||||
return sfd->s;
|
||||
Socket *s = nullptr;
|
||||
|
||||
return 0;
|
||||
auto lambda = [&] (Socket_fd &sfd) {
|
||||
if (sfd.fd != fd) { return false; }
|
||||
|
||||
/* return socket */
|
||||
s = sfd.s;
|
||||
return true;
|
||||
};
|
||||
|
||||
_for_each_socket_fd(lambda);
|
||||
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
Socket_fd Socket_registry::_socket_fd[MAX_SOCKETS] = {};
|
||||
unsigned Socket_registry::_sockets = Socket_registry::SOCKETS_INITIAL_VALUE;
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
/* Lx_kit */
|
||||
#include <lx_kit/env.h>
|
||||
#include <lx_kit/malloc.h>
|
||||
|
||||
static const bool verbose = false;
|
||||
|
||||
@ -627,10 +628,11 @@ Lxip::Socketcall & Lxip::init(Genode::Env &env,
|
||||
|
||||
static Net::Socketcall socketcall(env);
|
||||
|
||||
Lx::lxcc_emul_init(lx_env);
|
||||
Lx::malloc_init(env, lx_env.heap());
|
||||
Lx::timer_init(env, socketcall, lx_env.heap(), ticker);
|
||||
Lx::event_init(env, socketcall, ticker);
|
||||
Lx::nic_client_init(env, socketcall, lx_env.heap(), ticker);
|
||||
Lx::lxcc_emul_init(lx_env);
|
||||
|
||||
lxip_init();
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-2013 Genode Labs GmbH
|
||||
* Copyright (C) 2012-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.
|
||||
@ -18,7 +18,6 @@
|
||||
|
||||
#include <base/log.h>
|
||||
#include <util/xml_node.h>
|
||||
#include <os/signal_rpc_dispatcher.h>
|
||||
#include <irq_session/capability.h>
|
||||
|
||||
#include <lx_kit/env.h>
|
||||
@ -122,6 +121,8 @@ struct Services
|
||||
}
|
||||
};
|
||||
|
||||
void backend_alloc_init(Genode::Env &env, Genode::Ram_session &ram, Genode::Allocator &alloc);
|
||||
|
||||
void platform_hcd_init(Services *services);
|
||||
Genode::Irq_session_capability platform_irq_activate(int irq);
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016 Genode Labs GmbH
|
||||
* Copyright (C) 2016-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.
|
||||
@ -34,17 +34,19 @@ namespace Platform { struct Device; }
|
||||
|
||||
struct Platform::Device : Platform::Abstract_device, Genode::List<Device>::Element
|
||||
{
|
||||
Genode::Env &env;
|
||||
|
||||
unsigned irq_num;
|
||||
Genode::Constructible<Genode::Irq_connection> irq_connection;
|
||||
|
||||
Device(unsigned irq) : irq_num(irq) { }
|
||||
Device(Genode::Env &env, unsigned irq) : env(env), irq_num(irq) { }
|
||||
|
||||
unsigned vendor_id() { return ~0U; }
|
||||
unsigned device_id() { return ~0U; }
|
||||
|
||||
Genode::Irq_session_capability irq(Genode::uint8_t) override
|
||||
{
|
||||
irq_connection.construct(irq_num);
|
||||
irq_connection.construct(env, irq_num);
|
||||
return irq_connection->cap();
|
||||
}
|
||||
|
||||
@ -62,14 +64,14 @@ struct Platform::Device : Platform::Abstract_device, Genode::List<Device>::Eleme
|
||||
return l;
|
||||
}
|
||||
|
||||
static Device &create(unsigned irq_num)
|
||||
static Device &create(Genode::Env &env, unsigned irq_num)
|
||||
{
|
||||
Device *d;
|
||||
for (d = list().first(); d; d = d->next())
|
||||
if (d->irq_num == irq_num)
|
||||
return *d;
|
||||
|
||||
d = new (Lx::Malloc::mem()) Device(irq_num);
|
||||
d = new (Lx::Malloc::mem()) Device(env, irq_num);
|
||||
list().insert(d);
|
||||
|
||||
return *d;
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2011-2013 Genode Labs GmbH
|
||||
* Copyright (C) 2011-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.
|
||||
@ -26,27 +26,15 @@ using namespace Genode;
|
||||
|
||||
|
||||
/**
|
||||
* Return singleton instance of input-session component
|
||||
* Singleton instance of input-session component
|
||||
*/
|
||||
static Input::Session_component &input_session()
|
||||
{
|
||||
static Input::Session_component inst;
|
||||
return inst;
|
||||
}
|
||||
static Genode::Constructible<Input::Session_component> _input_session;
|
||||
|
||||
|
||||
/**
|
||||
* Return singleton instance of input-root component
|
||||
*
|
||||
* On the first call (from 'start_input_service'), the 'ep' argument is
|
||||
* specified. All subsequent calls (from 'input_callback') just return the
|
||||
* reference to the singleton instance.
|
||||
* Singleton instance of input-root component
|
||||
*/
|
||||
static Input::Root_component &input_root(Rpc_entrypoint *ep = 0)
|
||||
{
|
||||
static Input::Root_component root(*ep, input_session());
|
||||
return root;
|
||||
}
|
||||
static Genode::Constructible<Input::Root_component> _input_root;
|
||||
|
||||
|
||||
/**
|
||||
@ -66,7 +54,7 @@ static void input_callback(enum input_event_type type,
|
||||
case EVENT_TYPE_TOUCH: t = Input::Event::TOUCH; break;
|
||||
}
|
||||
|
||||
input_session().submit(Input::Event(t, code,
|
||||
_input_session->submit(Input::Event(t, code,
|
||||
absolute_x, absolute_y,
|
||||
relative_x, relative_y));
|
||||
}
|
||||
@ -78,7 +66,10 @@ void start_input_service(void *ep_ptr, void * service_ptr)
|
||||
Services *service = static_cast<Services *>(service_ptr);
|
||||
Env &env = service->env;
|
||||
|
||||
env.parent().announce(ep->manage(&input_root(ep)));
|
||||
_input_session.construct(env, env.ram());
|
||||
_input_root.construct(*ep, *_input_session);
|
||||
|
||||
env.parent().announce(ep->manage(&*_input_root));
|
||||
|
||||
genode_input_register(input_callback, service->screen_width,
|
||||
service->screen_height, service->multitouch);
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-2013 Genode Labs GmbH
|
||||
* Copyright (C) 2012-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.
|
||||
@ -43,7 +43,7 @@ void backtrace() { }
|
||||
|
||||
void pci_dev_put(struct pci_dev *pci_dev)
|
||||
{
|
||||
Genode::destroy(Genode::env()->heap(), pci_dev);
|
||||
Genode::destroy(&Lx_kit::env().heap(), pci_dev);
|
||||
}
|
||||
|
||||
/***********************
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-2014 Genode Labs GmbH
|
||||
* Copyright (C) 2012-2017 Genode Labs GmbH
|
||||
* Copyright (C) 2014 Ksys Labs LLC
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
@ -17,7 +17,6 @@
|
||||
|
||||
/* Genode */
|
||||
#include <base/sleep.h>
|
||||
#include <os/server.h>
|
||||
#include <nic_session/nic_session.h>
|
||||
|
||||
/* Local */
|
||||
@ -25,6 +24,7 @@
|
||||
#include <lx_emul.h>
|
||||
|
||||
#include <lx_kit/env.h>
|
||||
#include <lx_kit/pci.h>
|
||||
#include <lx_kit/irq.h>
|
||||
#include <lx_kit/malloc.h>
|
||||
#include <lx_kit/scheduler.h>
|
||||
@ -107,6 +107,12 @@ void start_usb_driver(Genode::Env &env)
|
||||
{
|
||||
/* initialize USB env */
|
||||
Lx_kit::construct_env(env);
|
||||
|
||||
/* sets up backend alloc needed by malloc */
|
||||
backend_alloc_init(env, env.ram(), Lx_kit::env().heap());
|
||||
|
||||
Lx::malloc_init(env, Lx_kit::env().heap());
|
||||
|
||||
static Services services(env);
|
||||
|
||||
if (services.hid)
|
||||
@ -118,8 +124,8 @@ void start_usb_driver(Genode::Env &env)
|
||||
if (services.raw)
|
||||
Raw::init(env, services.raw_report_device_list);
|
||||
|
||||
Lx::Scheduler &sched = Lx::scheduler();
|
||||
Lx::Timer &timer = Lx::timer(&env.ep(), &jiffies);
|
||||
Lx::Scheduler &sched = Lx::scheduler(&env);
|
||||
Lx::Timer &timer = Lx::timer(&env, &env.ep(), &Lx_kit::env().heap(), &jiffies);
|
||||
|
||||
Lx::Irq::irq(&env.ep(), &Lx_kit::env().heap());
|
||||
Lx::Work::work_queue(&Lx_kit::env().heap());
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-2013 Genode Labs GmbH
|
||||
* Copyright (C) 2012-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.
|
||||
@ -14,7 +14,6 @@
|
||||
#include <base/rpc_server.h>
|
||||
#include <base/snprintf.h>
|
||||
#include <nic_session/nic_session.h>
|
||||
#include <cap_session/connection.h>
|
||||
#include <nic/xml_node.h>
|
||||
#include <util/xml_node.h>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016 Genode Labs GmbH
|
||||
* Copyright (C) 2016-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.
|
||||
@ -22,6 +22,13 @@
|
||||
** lx_kit/backend_alloc.h **
|
||||
****************************/
|
||||
|
||||
void backend_alloc_init(Genode::Env&, Genode::Ram_session&,
|
||||
Genode::Allocator&)
|
||||
{
|
||||
/* intentionally left blank */
|
||||
}
|
||||
|
||||
|
||||
Genode::Ram_dataspace_capability
|
||||
Lx::backend_alloc(Genode::addr_t size, Genode::Cache_attribute cached) {
|
||||
return Lx_kit::env().env().ram().alloc(size, cached); }
|
||||
@ -38,7 +45,7 @@ void Lx::backend_free(Genode::Ram_dataspace_capability cap) {
|
||||
extern "C" int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
|
||||
const char *name, void *dev)
|
||||
{
|
||||
Lx::Irq::irq().request_irq(Platform::Device::create(irq), handler, dev);
|
||||
Lx::Irq::irq().request_irq(Platform::Device::create(Lx_kit::env().env(), irq), handler, dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016 Genode Labs GmbH
|
||||
* Copyright (C) 2016-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.
|
||||
@ -194,3 +194,14 @@ int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
||||
/*********************************
|
||||
** Platform backend alloc init **
|
||||
*********************************/
|
||||
|
||||
void backend_alloc_init(Genode::Env &env, Genode::Ram_session &ram,
|
||||
Genode::Allocator &alloc)
|
||||
{
|
||||
Lx::pci_init(env, ram, alloc);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Genode Labs GmbH
|
||||
* Copyright (C) 2013-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.
|
||||
@ -43,7 +43,3 @@ void platform_hcd_init(Services *s)
|
||||
if (s->uhci)
|
||||
module_uhci_hcd_init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <base/log.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <block/component.h>
|
||||
#include <cap_session/connection.h>
|
||||
#include <util/endian.h>
|
||||
#include <util/list.h>
|
||||
|
||||
|
@ -5,7 +5,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.
|
||||
@ -21,10 +21,12 @@
|
||||
|
||||
#include <lx_emul.h>
|
||||
|
||||
#include <lx_kit/malloc.h>
|
||||
#include <lx_kit/env.h>
|
||||
#include <lx_kit/irq.h>
|
||||
#include <lx_kit/work.h>
|
||||
#include <lx_kit/timer.h>
|
||||
#include <lx_kit/pci.h>
|
||||
|
||||
|
||||
extern "C" void core_netlink_proto_init(void);
|
||||
@ -142,9 +144,9 @@ void wifi_init(Genode::Env &env, Genode::Lock &lock, bool disable_11n)
|
||||
/* add init_net namespace to namespace list */
|
||||
list_add_tail_rcu(&init_net.list, &net_namespace_list);
|
||||
|
||||
Lx::scheduler();
|
||||
Lx::scheduler(&env);
|
||||
|
||||
Lx::timer(&env.ep(), &jiffies);
|
||||
Lx::timer(&env, &env.ep(), &Lx_kit::env().heap(), &jiffies);
|
||||
|
||||
Lx::Irq::irq(&env.ep(), &Lx_kit::env().heap());
|
||||
Lx::Work::work_queue(&Lx_kit::env().heap());
|
||||
@ -152,6 +154,9 @@ void wifi_init(Genode::Env &env, Genode::Lock &lock, bool disable_11n)
|
||||
Lx::socket_init(env.ep(), Lx_kit::env().heap());
|
||||
Lx::nic_init(env, Lx_kit::env().heap());
|
||||
|
||||
Lx::pci_init(env, env.ram(), Lx_kit::env().heap());
|
||||
Lx::malloc_init(env, Lx_kit::env().heap());
|
||||
|
||||
/* set IWL_DISABLE_HT_ALL if disable 11n is requested */
|
||||
if (disable_11n) {
|
||||
Genode::log("Disable 11n mode");
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 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.
|
||||
@ -14,9 +14,6 @@
|
||||
#ifndef _LX_H_
|
||||
#define _LX_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <os/server.h>
|
||||
|
||||
/* local includes */
|
||||
#include <lx_kit/scheduler.h>
|
||||
|
||||
|
@ -5,7 +5,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.
|
||||
@ -723,7 +723,7 @@ int request_firmware_nowait(struct module *module, bool uevent,
|
||||
|
||||
char const *fw_name = fwl->available_name
|
||||
? fwl->available_name : fwl->requested_name;
|
||||
Genode::Rom_connection rom(fw_name);
|
||||
Genode::Rom_connection rom(Lx_kit::env().env(), fw_name);
|
||||
Genode::Dataspace_capability ds_cap = rom.dataspace();
|
||||
|
||||
if (!ds_cap.valid()) {
|
||||
@ -1225,7 +1225,7 @@ int request_module(char const* format, ...)
|
||||
* XXX We have to create the waiters list lazy because the way
|
||||
* DEFINE_MUTEX is currently implemented does not work w/o
|
||||
* a global Env that was constructed before the static ctors
|
||||
* are called.
|
||||
* are called
|
||||
*/
|
||||
static inline void __check_or_initialize_mutex(struct mutex *m)
|
||||
{
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <base/rpc_server.h>
|
||||
#include <base/snprintf.h>
|
||||
#include <base/tslab.h>
|
||||
#include <cap_session/connection.h>
|
||||
#include <nic/xml_node.h>
|
||||
#include <nic/component.h>
|
||||
#include <root/component.h>
|
||||
@ -93,7 +92,7 @@ class Wifi_session_component : public Nic::Session_component
|
||||
Genode::Allocator &rx_block_md_alloc,
|
||||
Genode::Ram_session &ram_session,
|
||||
Genode::Region_map ®ion_map,
|
||||
Server::Entrypoint &ep, net_device *ndev)
|
||||
Genode::Entrypoint &ep, net_device *ndev)
|
||||
: Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc,
|
||||
ram_session, region_map, ep),
|
||||
_ndev(ndev)
|
||||
|
@ -5,7 +5,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.
|
||||
@ -128,8 +128,8 @@ class Lx::Socket
|
||||
|
||||
|
||||
Genode::Signal_transmitter _sender;
|
||||
Genode::Signal_rpc_member<Lx::Socket> _dispatcher;
|
||||
Lx::Task _task;
|
||||
Genode::Signal_handler<Lx::Socket> _dispatcher;
|
||||
Lx::Task _task;
|
||||
|
||||
struct socket *_call_socket()
|
||||
{
|
||||
@ -326,7 +326,7 @@ class Lx::Socket
|
||||
_call.handle->non_block = _call.non_block.value;
|
||||
}
|
||||
|
||||
void _handle(unsigned)
|
||||
void _handle()
|
||||
{
|
||||
_task.unblock();
|
||||
Lx::scheduler().schedule();
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 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.
|
||||
@ -29,8 +29,18 @@ extern "C" {
|
||||
}
|
||||
|
||||
|
||||
static Genode::Reporter accesspoints_reporter = { "wlan_accesspoints" };
|
||||
static Genode::Reporter state_reporter = { "wlan_state" };
|
||||
static Genode::Constructible<Genode::Reporter> accesspoints_reporter;
|
||||
static Genode::Constructible<Genode::Reporter> state_reporter;
|
||||
|
||||
|
||||
extern "C" void wpa_reporter_init(void *env)
|
||||
{
|
||||
accesspoints_reporter.construct(*static_cast<Genode::Env*>(env), "wlan_accesspoints");
|
||||
accesspoints_reporter->enabled(true);
|
||||
|
||||
state_reporter.construct(*static_cast<Genode::Env*>(env), "wlan_state");
|
||||
state_reporter->enabled(true);
|
||||
}
|
||||
|
||||
|
||||
enum { SSID_MAX_LEN = 32 + 1, MAC_STR_LEN = 6*2 + 5 + 1};
|
||||
@ -45,10 +55,8 @@ static inline void mac2str(char *buf, u8 const *mac)
|
||||
|
||||
extern "C" void wpa_report_connect_event(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
state_reporter.enabled(true);
|
||||
|
||||
try {
|
||||
Genode::Reporter::Xml_generator xml(state_reporter, [&]() {
|
||||
Genode::Reporter::Xml_generator xml(*state_reporter, [&]() {
|
||||
struct wpa_ssid *wpa_ssid = wpa_s->current_ssid;
|
||||
|
||||
/* FIXME ssid may contain any characters, even NUL */
|
||||
@ -70,10 +78,8 @@ extern "C" void wpa_report_connect_event(struct wpa_supplicant *wpa_s)
|
||||
|
||||
extern "C" void wpa_report_disconnect_event(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
state_reporter.enabled(true);
|
||||
|
||||
try {
|
||||
Genode::Reporter::Xml_generator xml(state_reporter, [&]() {
|
||||
Genode::Reporter::Xml_generator xml(*state_reporter, [&]() {
|
||||
struct wpa_ssid *wpa_ssid = wpa_s->current_ssid;
|
||||
|
||||
/* FIXME ssid may contain any characters, even NUL */
|
||||
@ -113,10 +119,8 @@ static inline int approximate_quality(struct wpa_bss *bss)
|
||||
|
||||
extern "C" void wpa_report_scan_results(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
accesspoints_reporter.enabled(true);
|
||||
|
||||
try {
|
||||
Genode::Reporter::Xml_generator xml(accesspoints_reporter, [&]() {
|
||||
Genode::Reporter::Xml_generator xml(*accesspoints_reporter, [&]() {
|
||||
for (unsigned i = 0; i < wpa_s->last_scan_res_used; i++) {
|
||||
struct wpa_bss *bss = wpa_s->last_scan_res[i];
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
/* needed by wifi_drv */
|
||||
wpa_main;
|
||||
wpa_reporter_init;
|
||||
|
||||
/* needed by wpa_driver_nl80211 */
|
||||
__hide_aliasing_typecast;
|
||||
|
@ -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); }
|
||||
|
@ -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; }
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user