timer: remove old timer infrastructure

Fixes #5138
This commit is contained in:
Alexander Boettcher 2024-06-26 16:01:52 +02:00 committed by Norman Feske
parent 462718bcf0
commit c18f7c7594
6 changed files with 0 additions and 403 deletions

View File

@ -1,67 +0,0 @@
/*
* \brief Root interface to timer service
* \author Norman Feske
* \author Martin Stein
* \date 2006-08-15
*/
/*
* Copyright (C) 2006-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _ROOT_COMPONENT_H_
#define _ROOT_COMPONENT_H_
/* Genode includes */
#include <root/component.h>
/* local includes */
#include <time_source.h>
#include <session_component.h>
namespace Timer { class Root_component; }
class Timer::Root_component : public Genode::Root_component<Session_component>
{
private:
enum { MIN_TIMEOUT_US = 1000 };
Time_source _time_source;
Genode::Timeout_scheduler _timeout_scheduler;
/********************
** Root_component **
********************/
Session_component *_create_session(const char *args) override
{
using namespace Genode;
size_t const ram_quota =
Arg_string::find_arg(args, "ram_quota").ulong_value(0);
if (ram_quota < sizeof(Session_component)) {
throw Insufficient_ram_quota(); }
return new (md_alloc())
Session_component(_timeout_scheduler);
}
public:
Root_component(Genode::Env &env, Genode::Allocator &md_alloc)
:
Genode::Root_component<Session_component>(&env.ep().rpc_ep(), &md_alloc),
_time_source(env),
_timeout_scheduler(_time_source, Microseconds(MIN_TIMEOUT_US))
{
_timeout_scheduler._enable();
}
};
#endif /* _ROOT_COMPONENT_H_ */

View File

@ -1,109 +0,0 @@
/*
* \brief Instance of the timer session interface
* \author Norman Feske
* \author Markus Partheymueller
* \author Martin Stein
* \date 2006-08-15
*/
/*
* Copyright (C) 2006-2017 Genode Labs GmbH
* Copyright (C) 2012 Intel Corporation
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _SESSION_COMPONENT_
#define _SESSION_COMPONENT_
/* Genode includes */
#include <util/list.h>
#include <timer_session/timer_session.h>
#include <base/rpc_server.h>
#include <timer/timeout.h>
namespace Timer {
using Genode::uint64_t;
using Microseconds = Genode::Microseconds;
using Duration = Genode::Duration;
class Session_component;
}
class Timer::Session_component : public Genode::Rpc_object<Session>,
private Genode::List<Session_component>::Element,
private Genode::Timeout_handler
{
private:
friend class Genode::List<Session_component>;
Genode::Timeout _timeout;
Genode::Timeout_scheduler &_timeout_scheduler;
Genode::Signal_context_capability _sigh { };
uint64_t const _init_time_us =
_timeout_scheduler.curr_time().trunc_to_plain_us().value;
/*********************
** Timeout_handler **
*********************/
void handle_timeout(Duration) override {
Genode::Signal_transmitter(_sigh).submit(); }
public:
Session_component(Genode::Timeout_scheduler &timeout_scheduler)
: _timeout(timeout_scheduler), _timeout_scheduler(timeout_scheduler) { }
/********************
** Timer::Session **
********************/
void trigger_once(uint64_t us) override
{
/*
* FIXME Workaround for the problem that Alarm scheduler may
* categorize big timeouts into the wrong time counter
* period due to its outdated internal time. This is needed
* only because the Alarm framework solely takes absolute
* time values on one-shot timeouts. and thus As soon as the
* Alarm framework takes solely relative time values, please
* remove this.
*/
Microseconds typed_us((us > ~(uint64_t)0 >> 1) ? ~(uint64_t)0 >> 1 : us);
_timeout.schedule_one_shot(typed_us, *this);
}
void trigger_periodic(uint64_t us) override
{
if (us)
_timeout.schedule_periodic(Microseconds(us), *this);
else
_timeout.discard();
}
void sigh(Signal_context_capability sigh) override
{
_sigh = sigh;
if (!sigh.valid())
_timeout.discard();
}
uint64_t elapsed_ms() const override {
return elapsed_us() / 1000; }
uint64_t elapsed_us() const override {
return _timeout_scheduler.curr_time().trunc_to_plain_us().value -
_init_time_us; }
void msleep(uint64_t) override { /* never called at the server side */ }
void usleep(uint64_t) override { /* never called at the server side */ }
};
#endif /* _SESSION_COMPONENT_ */

View File

@ -1,62 +0,0 @@
/*
* \brief Time source that handles timeouts via a signal handler
* \author Martin Stein
* \date 2016-11-04
*/
/*
* 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 Affero General Public License version 3.
*/
#ifndef _SIGNALLED_TIME_SOURCE_H_
#define _SIGNALLED_TIME_SOURCE_H_
/* Genode includes */
#include <base/env.h>
#include <timer/timeout.h>
#include <base/rpc_client.h>
namespace Genode { class Signalled_time_source; }
class Genode::Signalled_time_source : public Time_source
{
private:
/*
* Noncopyable
*/
Signalled_time_source(Signalled_time_source const &);
Signalled_time_source &operator = (Signalled_time_source const &);
protected:
using Signal_handler = Genode::Signal_handler<Signalled_time_source>;
Signal_handler _signal_handler;
Timeout_handler *_handler = nullptr;
bool _irq = false;
void _handle_timeout()
{
if (_handler) {
_irq = true;
Duration time(curr_time());
_irq = false;
_handler->handle_timeout(time);
}
}
public:
Signalled_time_source(Env &env)
:
_signal_handler(env.ep(), *this,
&Signalled_time_source::_handle_timeout)
{ }
};
#endif /* _SIGNALLED_TIME_SOURCE_H_ */

View File

@ -1,117 +0,0 @@
/*
* \brief Time source that uses an extra thread for timeout handling
* \author Norman Feske
* \author Martin Stein
* \date 2009-06-16
*/
/*
* Copyright (C) 2009-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _THREADED_TIME_SOURCE_H_
#define _THREADED_TIME_SOURCE_H_
/* Genode inludes */
#include <base/env.h>
#include <base/rpc_client.h>
#include <timer/timeout.h>
namespace Timer {
using Genode::Microseconds;
using Genode::Duration;
using Genode::Timeout_handler;
class Threaded_time_source;
}
class Timer::Threaded_time_source : public Genode::Time_source,
protected Genode::Thread
{
public:
enum Result_of_wait_for_irq { IRQ_TRIGGERED, CANCELLED };
private:
struct Irq_dispatcher : Genode::Interface
{
GENODE_RPC(Rpc_do_dispatch, void, do_dispatch);
GENODE_RPC_INTERFACE(Rpc_do_dispatch);
};
struct Irq_dispatcher_component : Genode::Rpc_object<Irq_dispatcher,
Irq_dispatcher_component>
{
private:
/*
* Noncopyable
*/
Irq_dispatcher_component(Irq_dispatcher_component const &);
Irq_dispatcher_component &operator = (Irq_dispatcher_component const &);
public:
Timeout_handler *handler = nullptr;
Threaded_time_source &ts;
Irq_dispatcher_component(Threaded_time_source &ts) : ts(ts) { }
/********************
** Irq_dispatcher **
********************/
void do_dispatch()
{
/* call curr_time in ep and not in ts (no locks in use!) */
ts._irq = true;
Duration us = ts.curr_time();
ts._irq = false;
if (handler)
handler->handle_timeout(us);
}
} _irq_dispatcher_component;
Genode::Capability<Irq_dispatcher> _irq_dispatcher_cap;
virtual Result_of_wait_for_irq _wait_for_irq() = 0;
/************
** Thread **
************/
void entry() override
{
while (true) {
if (_wait_for_irq() == IRQ_TRIGGERED) {
_irq_dispatcher_cap.call<Irq_dispatcher::Rpc_do_dispatch>();
}
}
}
protected:
bool _irq { false };
public:
Threaded_time_source(Genode::Env &env)
:
Thread(env, "threaded_time_source", 8 * 1024 * sizeof(Genode::addr_t)),
_irq_dispatcher_component(*this),
_irq_dispatcher_cap(env.ep().rpc_ep().manage(&_irq_dispatcher_component))
{ }
void handler(Timeout_handler &handler) {
_irq_dispatcher_component.handler = &handler; }
};
#endif /* _THREADED_TIME_SOURCE_H_ */

View File

@ -1,43 +0,0 @@
/*
* \brief Provides the Timer service to multiple clients
* \author Norman Feske
* \author Martin Stein
* \date 2006-08-15
*/
/*
* Copyright (C) 2006-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* Genode includes */
#include <base/heap.h>
#include <base/component.h>
/* local includes */
#include <root_component.h>
using namespace Genode;
class Main
{
private:
Sliced_heap _sliced_heap;
Timer::Root_component _root;
public:
Main(Env &env) : _sliced_heap(env.ram(), env.rm()),
_root(env, _sliced_heap)
{
env.parent().announce(env.ep().manage(_root));
}
};
size_t Component::stack_size() { return 4*1024*sizeof(addr_t); }
void Component::construct(Env &env) { static Main main(env); }

View File

@ -1,5 +0,0 @@
SRC_CC += main.cc
LIBS += base
INC_DIR += $(call select_from_repositories,src/timer/include)
vpath main.cc $(dir $(call select_from_repositories,src/timer/main.cc))