2015-09-09 16:21:19 +02:00
|
|
|
/*
|
|
|
|
* \brief Implementation of linux/delay.h
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2015-09-09
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-11 17:35:30 +01:00
|
|
|
* Copyright (C) 2015-2017 Genode Labs GmbH
|
2015-09-09 16:21:19 +02:00
|
|
|
*
|
2017-02-20 13:23:52 +01:00
|
|
|
* This file is distributed under the terms of the GNU General Public License
|
|
|
|
* version 2.
|
2015-09-09 16:21:19 +02:00
|
|
|
*/
|
|
|
|
|
2018-11-30 15:05:09 +01:00
|
|
|
/*
|
|
|
|
* Disable preprocessor macros that are incompatible to Genode headers for this
|
|
|
|
* file.
|
|
|
|
*/
|
|
|
|
#pragma push_macro("max")
|
|
|
|
#pragma push_macro("min")
|
|
|
|
#undef max
|
|
|
|
#undef min
|
|
|
|
|
2015-09-09 16:21:19 +02:00
|
|
|
/* Genode includes */
|
|
|
|
#include <timer_session/connection.h>
|
|
|
|
|
2017-02-11 17:35:30 +01:00
|
|
|
#include <lx_kit/env.h>
|
2016-03-17 15:19:03 +01:00
|
|
|
#include <lx_kit/timer.h>
|
2015-09-18 16:34:19 +02:00
|
|
|
|
2015-09-09 16:21:19 +02:00
|
|
|
/*
|
2017-02-11 17:35:30 +01:00
|
|
|
* XXX "We may consider to use the Lx::Timer instead of opening a dedicated
|
|
|
|
* timer session" which I tried during the deprecation warning removal
|
|
|
|
* but it did not work out. At least the intel_fb at that point got stuck
|
|
|
|
* because the workqueue task got mutex blocked.
|
2015-09-09 16:21:19 +02:00
|
|
|
*/
|
2017-02-11 17:35:30 +01:00
|
|
|
static Genode::Constructible<Timer::Connection> _delay_timer;
|
2015-09-09 16:21:19 +02:00
|
|
|
|
2017-02-11 17:35:30 +01:00
|
|
|
static inline void __delay_timer(unsigned long usecs)
|
|
|
|
{
|
|
|
|
if (!_delay_timer.constructed()) {
|
|
|
|
_delay_timer.construct(Lx_kit::env().env());
|
|
|
|
}
|
|
|
|
|
|
|
|
_delay_timer->usleep(usecs);
|
|
|
|
}
|
2015-09-09 16:21:19 +02:00
|
|
|
|
2018-04-10 16:54:01 +02:00
|
|
|
void udelay(unsigned long usecs)
|
|
|
|
{
|
|
|
|
__delay_timer(usecs);
|
|
|
|
Lx::timer_update_jiffies();
|
|
|
|
}
|
2015-09-09 16:21:19 +02:00
|
|
|
|
|
|
|
|
2015-09-18 16:34:19 +02:00
|
|
|
void msleep(unsigned int msecs)
|
|
|
|
{
|
2017-02-11 17:35:30 +01:00
|
|
|
__delay_timer(1000 * msecs);
|
2015-09-18 16:34:19 +02:00
|
|
|
Lx::timer_update_jiffies();
|
|
|
|
}
|
2015-09-09 16:21:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
void mdelay(unsigned long msecs) { msleep(msecs); }
|
2018-11-30 15:05:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
#pragma pop_macro("max")
|
|
|
|
#pragma pop_macro("min")
|