2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Timer session interface
|
|
|
|
* \author Norman Feske
|
2012-11-05 15:48:40 +00:00
|
|
|
* \author Markus Partheymueller
|
2011-12-22 15:19:25 +00:00
|
|
|
* \date 2006-08-15
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 12:23:52 +00:00
|
|
|
* Copyright (C) 2006-2017 Genode Labs GmbH
|
2012-11-05 15:48:40 +00:00
|
|
|
* Copyright (C) 2012 Intel Corporation
|
2011-12-22 15:19:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2011-12-22 15:19:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__TIMER_SESSION__TIMER_SESSION_H_
|
|
|
|
#define _INCLUDE__TIMER_SESSION__TIMER_SESSION_H_
|
|
|
|
|
2012-10-29 20:05:32 +00:00
|
|
|
#include <base/signal.h>
|
2011-12-22 15:19:25 +00:00
|
|
|
#include <session/session.h>
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
namespace Timer { struct Session; }
|
|
|
|
|
|
|
|
|
|
|
|
struct Timer::Session : Genode::Session
|
|
|
|
{
|
|
|
|
typedef Genode::Signal_context_capability Signal_context_capability;
|
|
|
|
|
2017-05-24 12:41:19 +00:00
|
|
|
/**
|
|
|
|
* \noapi
|
|
|
|
*/
|
2015-03-04 20:12:14 +00:00
|
|
|
static const char *service_name() { return "Timer"; }
|
|
|
|
|
2017-05-07 20:03:25 +00:00
|
|
|
enum { CAP_QUOTA = 2 };
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
virtual ~Session() { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Program single timeout (relative from now in microseconds)
|
|
|
|
*/
|
|
|
|
virtual void trigger_once(unsigned us) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Program periodic timeout (in microseconds)
|
|
|
|
*
|
|
|
|
* The first period will be triggered after 'us' at the latest,
|
|
|
|
* but it might be triggered earlier as well.
|
|
|
|
*/
|
|
|
|
virtual void trigger_periodic(unsigned us) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register timeout signal handler
|
|
|
|
*/
|
|
|
|
virtual void sigh(Genode::Signal_context_capability sigh) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return number of elapsed milliseconds since session creation
|
|
|
|
*/
|
|
|
|
virtual unsigned long elapsed_ms() const = 0;
|
|
|
|
|
2017-08-04 13:11:27 +00:00
|
|
|
virtual unsigned long elapsed_us() const = 0;
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
/**
|
2015-03-20 16:50:41 +00:00
|
|
|
* Client-side convenience method for sleeping the specified number
|
2015-03-04 20:12:14 +00:00
|
|
|
* of milliseconds
|
|
|
|
*/
|
|
|
|
virtual void msleep(unsigned ms) = 0;
|
|
|
|
|
|
|
|
/**
|
2015-03-20 16:50:41 +00:00
|
|
|
* Client-side convenience method for sleeping the specified number
|
2015-03-04 20:12:14 +00:00
|
|
|
* of microseconds
|
|
|
|
*/
|
|
|
|
virtual void usleep(unsigned us) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
** RPC declaration **
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
GENODE_RPC(Rpc_trigger_once, void, trigger_once, unsigned);
|
|
|
|
GENODE_RPC(Rpc_trigger_periodic, void, trigger_periodic, unsigned);
|
|
|
|
GENODE_RPC(Rpc_sigh, void, sigh, Genode::Signal_context_capability);
|
|
|
|
GENODE_RPC(Rpc_elapsed_ms, unsigned long, elapsed_ms);
|
2017-08-04 13:11:27 +00:00
|
|
|
GENODE_RPC(Rpc_elapsed_us, unsigned long, elapsed_us);
|
2015-03-04 20:12:14 +00:00
|
|
|
|
|
|
|
GENODE_RPC_INTERFACE(Rpc_trigger_once, Rpc_trigger_periodic,
|
2017-08-04 13:11:27 +00:00
|
|
|
Rpc_sigh, Rpc_elapsed_ms, Rpc_elapsed_us);
|
2015-03-04 20:12:14 +00:00
|
|
|
};
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#endif /* _INCLUDE__TIMER_SESSION__TIMER_SESSION_H_ */
|