lxip: restore entrypoints + remove sig_rec

This commit is contained in:
Sebastian Sumpf 2017-01-31 14:50:07 +01:00 committed by Norman Feske
parent c2e6fd9392
commit 549c6db064
4 changed files with 106 additions and 76 deletions

View File

@ -1,11 +1,12 @@
/* /*
* \brief Lx env * \brief Lx env
* \author Josef Soentgen * \author Josef Soentgen
* \author Emery Hemingway
* \date 2014-10-17 * \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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -18,9 +19,13 @@
namespace Lx { namespace Lx {
void nic_client_init(Genode::Signal_receiver &); void nic_client_init(Genode::Env &env,
void timer_init(Genode::Signal_receiver &); Genode::Allocator &alloc,
void event_init(Genode::Signal_receiver &); 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(); void timer_update_jiffies();
} }

View File

@ -1,11 +1,13 @@
/** /**
* \brief Linux emulation code * \brief Linux emulation code
* \author Sebastian Sumpf * \author Sebastian Sumpf
* \author Emery Hemingway
* \author Christian Helmuth
* \date 2013-08-28 * \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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * 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 ** ** linux/sched.h **
*******************/ *******************/
static Genode::Signal_receiver *_sig_rec; struct Timeout : Genode::Signal_handler<Timeout>
void Lx::event_init(Genode::Signal_receiver &sig_rec)
{ {
_sig_rec = &sig_rec; Genode::Entrypoint &ep;
} Timer::Connection timer;
void (*tick)();
bool pending = false;
void handle()
struct Timeout : Genode::Signal_dispatcher<Timeout>
{
void handle(unsigned) { update_jiffies(); }
Timeout(Timer::Session_client &timer, signed long msec)
: Signal_dispatcher<Timeout>(*_sig_rec, *this, &Timeout::handle)
{ {
if (msec > 0) { update_jiffies();
timer.sigh(*this); pending = false;
timer.trigger_once(msec*1000);
} /* tick the higher layer of the component */
tick();
}
Timeout(Genode::Env &env, void (*ticker)())
:
Signal_handler<Timeout>(env.ep(), *this, &Timeout::handle),
ep(env.ep()), timer(env), tick(ticker)
{
timer.sigh(*this);
}
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 Timeout *_timeout;
{ static Genode::Signal_context_capability tick_sig_cap;
static Timer::Connection timer;
Timeout to(timer, timeout);
/* dispatch signal */ void Lx::event_init(Genode::Env &env, void (*ticker)())
Genode::Signal s = _sig_rec->wait_for_signal(); {
static_cast<Genode::Signal_dispatcher_base *>(s.context())->dispatch(s.num()); 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); 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) void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
{ {
wait_for_timeout(0); _timeout->wait();
} }

View File

@ -2,11 +2,12 @@
* \brief Linux emulation code * \brief Linux emulation code
* \author Sebastian Sumpf * \author Sebastian Sumpf
* \author Josef Soentgen * \author Josef Soentgen
* \author Emery Hemingway
* \date 2013-08-28 * \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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * 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::Packet_allocator _tx_block_alloc;
Nic::Connection _nic; Nic::Connection _nic;
Genode::Signal_dispatcher<Nic_client> _sink_ack; Genode::Signal_handler<Nic_client> _sink_ack;
Genode::Signal_dispatcher<Nic_client> _sink_submit; Genode::Signal_handler<Nic_client> _sink_submit;
Genode::Signal_dispatcher<Nic_client> _source_ack; Genode::Signal_handler<Nic_client> _source_ack;
Genode::Signal_dispatcher<Nic_client> _source_submit;
void (*_tick)();
/** /**
* submit queue not empty anymore * submit queue not empty anymore
*/ */
void _packet_avail(unsigned) void _packet_avail()
{ {
enum { MAX_PACKETS = 20 }; enum { MAX_PACKETS = 20 };
@ -59,20 +61,23 @@ class Nic_client
if (_nic.rx()->packet_avail()) if (_nic.rx()->packet_avail())
Genode::Signal_transmitter(_sink_submit).submit(); Genode::Signal_transmitter(_sink_submit).submit();
/* tick the higher layer of the component */
_tick();
} }
/** /**
* acknoledgement queue not full anymore * 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 * acknoledgement queue not empty anymore
*/ */
void _ack_avail(unsigned) void _ack_avail()
{ {
while (_nic.tx()->ack_avail()) { while (_nic.tx()->ack_avail()) {
Nic::Packet_descriptor p = _nic.tx()->get_acked_packet(); 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: public:
Nic_client(Genode::Signal_receiver &sig_rec) Nic_client(Genode::Env &env,
Genode::Allocator &alloc,
void (*ticker)())
: :
_tx_block_alloc(Genode::env()->heap()), _tx_block_alloc(&alloc),
_nic(&_tx_block_alloc, BUF_SIZE, BUF_SIZE), _nic(env, &_tx_block_alloc, BUF_SIZE, BUF_SIZE),
_sink_ack(sig_rec, *this, &Nic_client::_ready_to_ack), _sink_ack(env.ep(), *this, &Nic_client::_packet_avail),
_sink_submit(sig_rec, *this, &Nic_client::_packet_avail), _sink_submit(env.ep(), *this, &Nic_client::_ready_to_ack),
_source_ack(sig_rec, *this, &Nic_client::_ack_avail), _source_ack(env.ep(), *this, &Nic_client::_ack_avail),
_source_submit(sig_rec, *this, &Nic_client::_ready_to_submit) _tick(ticker)
{ {
_nic.rx_channel()->sigh_ready_to_ack(_sink_ack); _nic.rx_channel()->sigh_ready_to_ack(_sink_ack);
_nic.rx_channel()->sigh_packet_avail(_sink_submit); _nic.rx_channel()->sigh_packet_avail(_sink_submit);
_nic.tx_channel()->sigh_ack_avail(_source_ack); _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; } Nic::Connection *nic() { return &_nic; }
@ -112,9 +112,11 @@ class Nic_client
static Nic_client *_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; _nic_client = &_inst;
} }

View File

@ -1,11 +1,13 @@
/* /*
* \brief Signal context for timer events * \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 * \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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -85,9 +87,11 @@ class Lx::Timer
::Timer::Connection _timer_conn; ::Timer::Connection _timer_conn;
Lx_kit::List<Context> _list; 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; Genode::Tslab<Context, 32 * sizeof(Context)> _timer_alloc;
void (*_tick)();
public: public:
bool ready { true }; bool ready { true };
@ -167,7 +171,7 @@ class Lx::Timer
/** /**
* Handle trigger_once signal * Handle trigger_once signal
*/ */
void _handle(unsigned) void _handle()
{ {
update_jiffies(); update_jiffies();
@ -178,6 +182,9 @@ class Lx::Timer
ctx->function(); ctx->function();
del(ctx->timer); del(ctx->timer);
} }
/* tick the higher layer of the component */
_tick();
} }
public: public:
@ -185,12 +192,14 @@ class Lx::Timer
/** /**
* Constructor * Constructor
*/ */
Timer(Genode::Signal_receiver &sig_rec) Timer(Genode::Env &env, Genode::Allocator &alloc, void (*tick)())
: :
_dispatcher(sig_rec, *this, &Lx::Timer::_handle), _timer_conn(env),
_timer_alloc(Genode::env()->heap()) _handler(env.ep(), *this, &Lx::Timer::_handle),
_timer_alloc(&alloc),
_tick(tick)
{ {
_timer_conn.sigh(_dispatcher); _timer_conn.sigh(_handler);
jiffies = 0; jiffies = 0;
} }
@ -287,9 +296,9 @@ class Lx::Timer
static Lx::Timer *_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; _timer = &inst;
} }