2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Timers and tick
|
|
|
|
* \author Christian Helmuth
|
|
|
|
* \date 2008-10-22
|
|
|
|
*
|
|
|
|
* DDE kit provides a generic timer implementation that enables users to
|
|
|
|
* execute a callback function after a certain period of time. Therefore, DDE
|
|
|
|
* kit starts a timer thread that executes callbacks and keeps track of the
|
|
|
|
* currently running timers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 20:44:47 +00:00
|
|
|
* Copyright (C) 2008-2013 Genode Labs GmbH
|
2011-12-22 15:19:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__DDE_KIT__TIMER_H_
|
|
|
|
#define _INCLUDE__DDE_KIT__TIMER_H_
|
|
|
|
|
|
|
|
#include <dde_kit/thread.h>
|
|
|
|
|
|
|
|
|
|
|
|
/**********
|
|
|
|
** Tick **
|
|
|
|
**********/
|
|
|
|
|
|
|
|
/** Timer tick (global symbol) */
|
|
|
|
extern volatile unsigned long dde_kit_timer_ticks;
|
|
|
|
extern volatile unsigned long jiffies;
|
|
|
|
|
|
|
|
/** Timer tick rate */
|
|
|
|
enum { DDE_KIT_HZ = 100 };
|
|
|
|
|
|
|
|
|
|
|
|
/***********
|
|
|
|
** Timer **
|
|
|
|
***********/
|
|
|
|
|
|
|
|
struct dde_kit_timer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add timer event handler
|
|
|
|
*
|
|
|
|
* \param fn function to call on timeout
|
|
|
|
* \param priv private handler token
|
|
|
|
* \param timeout absolute timeout (in DDE kit ticks)
|
|
|
|
*
|
|
|
|
* \return timer reference on success; 0 otherwise
|
|
|
|
*
|
|
|
|
* After the absolute timeout has expired, function fn is called with args as
|
|
|
|
* arguments.
|
|
|
|
*/
|
|
|
|
struct dde_kit_timer *dde_kit_timer_add(void (*fn)(void *), void *priv,
|
|
|
|
unsigned long timeout);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete timer
|
|
|
|
*
|
|
|
|
* \param timer timer reference
|
|
|
|
*/
|
|
|
|
void dde_kit_timer_del(struct dde_kit_timer *timer);
|
|
|
|
|
2012-05-02 13:44:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Schedule absolute timeout
|
|
|
|
*
|
|
|
|
* \param timer timer reference
|
|
|
|
* \param timeout absolute timeout (in DDE kit ticks)
|
|
|
|
*/
|
|
|
|
void dde_kit_timer_schedule_absolute(struct dde_kit_timer *timer, unsigned long timeout);
|
|
|
|
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
/**
|
|
|
|
* Check whether a timer is pending
|
|
|
|
*
|
|
|
|
* \param timer timer reference
|
|
|
|
*/
|
|
|
|
int dde_kit_timer_pending(struct dde_kit_timer *timer);
|
|
|
|
|
|
|
|
/** Init timers and ticks */
|
|
|
|
void dde_kit_timer_init(void(*thread_init)(void *), void *priv);
|
|
|
|
|
|
|
|
#endif /* _INCLUDE__DDE_KIT__TIMER_H_ */
|