mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-19 03:06:39 +00:00
lxip: restore entrypoints + remove sig_rec
This commit is contained in:
parent
c2e6fd9392
commit
549c6db064
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* \brief Lx env
|
||||
* \author Josef Soentgen
|
||||
* \author Emery Hemingway
|
||||
* \date 2014-10-17
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
@ -18,9 +19,13 @@
|
||||
|
||||
namespace Lx {
|
||||
|
||||
void nic_client_init(Genode::Signal_receiver &);
|
||||
void timer_init(Genode::Signal_receiver &);
|
||||
void event_init(Genode::Signal_receiver &);
|
||||
void nic_client_init(Genode::Env &env,
|
||||
Genode::Allocator &alloc,
|
||||
void (*ticker)());
|
||||
void timer_init(Genode::Env &env,
|
||||
Genode::Allocator &alloc,
|
||||
void (*ticker)());
|
||||
void event_init(Genode::Env &env, void (*ticker)());
|
||||
|
||||
void timer_update_jiffies();
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
/**
|
||||
* \brief Linux emulation code
|
||||
* \author Sebastian Sumpf
|
||||
* \author Emery Hemingway
|
||||
* \author Christian Helmuth
|
||||
* \date 2013-08-28
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 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.
|
||||
@ -293,38 +295,60 @@ void *memmove(void *d, const void *s, size_t n)
|
||||
** linux/sched.h **
|
||||
*******************/
|
||||
|
||||
static Genode::Signal_receiver *_sig_rec;
|
||||
|
||||
|
||||
void Lx::event_init(Genode::Signal_receiver &sig_rec)
|
||||
struct Timeout : Genode::Signal_handler<Timeout>
|
||||
{
|
||||
_sig_rec = &sig_rec;
|
||||
Genode::Entrypoint &ep;
|
||||
Timer::Connection timer;
|
||||
void (*tick)();
|
||||
bool pending = false;
|
||||
|
||||
void handle()
|
||||
{
|
||||
update_jiffies();
|
||||
pending = false;
|
||||
|
||||
/* tick the higher layer of the component */
|
||||
tick();
|
||||
}
|
||||
|
||||
|
||||
struct Timeout : Genode::Signal_dispatcher<Timeout>
|
||||
Timeout(Genode::Env &env, void (*ticker)())
|
||||
:
|
||||
Signal_handler<Timeout>(env.ep(), *this, &Timeout::handle),
|
||||
ep(env.ep()), timer(env), tick(ticker)
|
||||
{
|
||||
void handle(unsigned) { update_jiffies(); }
|
||||
|
||||
Timeout(Timer::Session_client &timer, signed long msec)
|
||||
: Signal_dispatcher<Timeout>(*_sig_rec, *this, &Timeout::handle)
|
||||
{
|
||||
if (msec > 0) {
|
||||
timer.sigh(*this);
|
||||
timer.trigger_once(msec*1000);
|
||||
}
|
||||
|
||||
void schedule(signed long msec)
|
||||
{
|
||||
timer.trigger_once(msec * 1000);
|
||||
pending = true;
|
||||
}
|
||||
|
||||
void wait()
|
||||
{
|
||||
while (pending)
|
||||
ep.wait_and_dispatch_one_signal();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static void wait_for_timeout(signed long timeout)
|
||||
{
|
||||
static Timer::Connection timer;
|
||||
Timeout to(timer, timeout);
|
||||
static Timeout *_timeout;
|
||||
static Genode::Signal_context_capability tick_sig_cap;
|
||||
|
||||
/* dispatch signal */
|
||||
Genode::Signal s = _sig_rec->wait_for_signal();
|
||||
static_cast<Genode::Signal_dispatcher_base *>(s.context())->dispatch(s.num());
|
||||
void Lx::event_init(Genode::Env &env, void (*ticker)())
|
||||
{
|
||||
static Timeout handler(env, ticker);
|
||||
_timeout = &handler;
|
||||
}
|
||||
|
||||
signed long schedule_timeout(signed long timeout)
|
||||
{
|
||||
long start = jiffies;
|
||||
_timeout->schedule(timeout);
|
||||
_timeout->wait();
|
||||
timeout -= jiffies - start;
|
||||
return timeout < 0 ? 0 : timeout;
|
||||
}
|
||||
|
||||
|
||||
@ -333,19 +357,9 @@ long schedule_timeout_uninterruptible(signed long timeout)
|
||||
return schedule_timeout(timeout);
|
||||
}
|
||||
|
||||
|
||||
signed long schedule_timeout(signed long timeout)
|
||||
{
|
||||
long start = jiffies;
|
||||
wait_for_timeout(timeout);
|
||||
timeout -= jiffies - start;
|
||||
return timeout < 0 ? 0 : timeout;
|
||||
}
|
||||
|
||||
|
||||
void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
|
||||
{
|
||||
wait_for_timeout(0);
|
||||
_timeout->wait();
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,11 +2,12 @@
|
||||
* \brief Linux emulation code
|
||||
* \author Sebastian Sumpf
|
||||
* \author Josef Soentgen
|
||||
* \author Emery Hemingway
|
||||
* \date 2013-08-28
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 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.
|
||||
@ -34,15 +35,16 @@ class Nic_client
|
||||
Nic::Packet_allocator _tx_block_alloc;
|
||||
Nic::Connection _nic;
|
||||
|
||||
Genode::Signal_dispatcher<Nic_client> _sink_ack;
|
||||
Genode::Signal_dispatcher<Nic_client> _sink_submit;
|
||||
Genode::Signal_dispatcher<Nic_client> _source_ack;
|
||||
Genode::Signal_dispatcher<Nic_client> _source_submit;
|
||||
Genode::Signal_handler<Nic_client> _sink_ack;
|
||||
Genode::Signal_handler<Nic_client> _sink_submit;
|
||||
Genode::Signal_handler<Nic_client> _source_ack;
|
||||
|
||||
void (*_tick)();
|
||||
|
||||
/**
|
||||
* submit queue not empty anymore
|
||||
*/
|
||||
void _packet_avail(unsigned)
|
||||
void _packet_avail()
|
||||
{
|
||||
enum { MAX_PACKETS = 20 };
|
||||
|
||||
@ -59,20 +61,23 @@ class Nic_client
|
||||
|
||||
if (_nic.rx()->packet_avail())
|
||||
Genode::Signal_transmitter(_sink_submit).submit();
|
||||
|
||||
/* tick the higher layer of the component */
|
||||
_tick();
|
||||
}
|
||||
|
||||
/**
|
||||
* acknoledgement queue not full anymore
|
||||
*/
|
||||
void _ready_to_ack(unsigned num)
|
||||
void _ready_to_ack()
|
||||
{
|
||||
_packet_avail(num);
|
||||
_packet_avail();
|
||||
}
|
||||
|
||||
/**
|
||||
* acknoledgement queue not empty anymore
|
||||
*/
|
||||
void _ack_avail(unsigned)
|
||||
void _ack_avail()
|
||||
{
|
||||
while (_nic.tx()->ack_avail()) {
|
||||
Nic::Packet_descriptor p = _nic.tx()->get_acked_packet();
|
||||
@ -80,29 +85,24 @@ class Nic_client
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* submit queue not full anymore
|
||||
*
|
||||
* TODO: by now, we just drop packets that cannot be transferred
|
||||
* to the other side, that's why we ignore this signal.
|
||||
*/
|
||||
void _ready_to_submit(unsigned) { }
|
||||
|
||||
public:
|
||||
|
||||
Nic_client(Genode::Signal_receiver &sig_rec)
|
||||
Nic_client(Genode::Env &env,
|
||||
Genode::Allocator &alloc,
|
||||
void (*ticker)())
|
||||
:
|
||||
_tx_block_alloc(Genode::env()->heap()),
|
||||
_nic(&_tx_block_alloc, BUF_SIZE, BUF_SIZE),
|
||||
_sink_ack(sig_rec, *this, &Nic_client::_ready_to_ack),
|
||||
_sink_submit(sig_rec, *this, &Nic_client::_packet_avail),
|
||||
_source_ack(sig_rec, *this, &Nic_client::_ack_avail),
|
||||
_source_submit(sig_rec, *this, &Nic_client::_ready_to_submit)
|
||||
_tx_block_alloc(&alloc),
|
||||
_nic(env, &_tx_block_alloc, BUF_SIZE, BUF_SIZE),
|
||||
_sink_ack(env.ep(), *this, &Nic_client::_packet_avail),
|
||||
_sink_submit(env.ep(), *this, &Nic_client::_ready_to_ack),
|
||||
_source_ack(env.ep(), *this, &Nic_client::_ack_avail),
|
||||
_tick(ticker)
|
||||
{
|
||||
_nic.rx_channel()->sigh_ready_to_ack(_sink_ack);
|
||||
_nic.rx_channel()->sigh_packet_avail(_sink_submit);
|
||||
_nic.tx_channel()->sigh_ack_avail(_source_ack);
|
||||
_nic.tx_channel()->sigh_ready_to_submit(_source_submit);
|
||||
/* ready_to_submit not handled */
|
||||
}
|
||||
|
||||
Nic::Connection *nic() { return &_nic; }
|
||||
@ -112,9 +112,11 @@ class Nic_client
|
||||
static Nic_client *_nic_client;
|
||||
|
||||
|
||||
void Lx::nic_client_init(Genode::Signal_receiver &sig_rec)
|
||||
void Lx::nic_client_init(Genode::Env &env,
|
||||
Genode::Allocator &alloc,
|
||||
void (*ticker)())
|
||||
{
|
||||
static Nic_client _inst(sig_rec);
|
||||
static Nic_client _inst(env, alloc, ticker);
|
||||
_nic_client = &_inst;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
/*
|
||||
* \brief Signal context for timer events
|
||||
* \author Sebastian Sumpf <sebastian.sumpf@genode-labs.com>
|
||||
* \author Sebastian Sumpf
|
||||
* \author Emery Hemingway
|
||||
* \author Christian Helmuth
|
||||
* \date 2012-05-23
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-2016 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.
|
||||
@ -85,9 +87,11 @@ class Lx::Timer
|
||||
|
||||
::Timer::Connection _timer_conn;
|
||||
Lx_kit::List<Context> _list;
|
||||
Genode::Signal_dispatcher<Lx::Timer> _dispatcher;
|
||||
Genode::Signal_handler<Lx::Timer> _handler;
|
||||
Genode::Tslab<Context, 32 * sizeof(Context)> _timer_alloc;
|
||||
|
||||
void (*_tick)();
|
||||
|
||||
public:
|
||||
|
||||
bool ready { true };
|
||||
@ -167,7 +171,7 @@ class Lx::Timer
|
||||
/**
|
||||
* Handle trigger_once signal
|
||||
*/
|
||||
void _handle(unsigned)
|
||||
void _handle()
|
||||
{
|
||||
update_jiffies();
|
||||
|
||||
@ -178,6 +182,9 @@ class Lx::Timer
|
||||
ctx->function();
|
||||
del(ctx->timer);
|
||||
}
|
||||
|
||||
/* tick the higher layer of the component */
|
||||
_tick();
|
||||
}
|
||||
|
||||
public:
|
||||
@ -185,12 +192,14 @@ class Lx::Timer
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Timer(Genode::Signal_receiver &sig_rec)
|
||||
Timer(Genode::Env &env, Genode::Allocator &alloc, void (*tick)())
|
||||
:
|
||||
_dispatcher(sig_rec, *this, &Lx::Timer::_handle),
|
||||
_timer_alloc(Genode::env()->heap())
|
||||
_timer_conn(env),
|
||||
_handler(env.ep(), *this, &Lx::Timer::_handle),
|
||||
_timer_alloc(&alloc),
|
||||
_tick(tick)
|
||||
{
|
||||
_timer_conn.sigh(_dispatcher);
|
||||
_timer_conn.sigh(_handler);
|
||||
jiffies = 0;
|
||||
}
|
||||
|
||||
@ -287,9 +296,9 @@ class Lx::Timer
|
||||
static Lx::Timer *_timer;
|
||||
|
||||
|
||||
void Lx::timer_init(Genode::Signal_receiver &sig_rec)
|
||||
void Lx::timer_init(Genode::Env &env, Genode::Allocator &alloc, void (*tick)())
|
||||
{
|
||||
static Lx::Timer inst(sig_rec);
|
||||
static Lx::Timer inst(env, alloc, tick);
|
||||
_timer = &inst;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user