2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* \brief Fiasco-specific sleep implementation
|
|
|
|
* \author Christian Helmuth
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2006-08-30
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2006-2013 Genode Labs GmbH
|
2011-12-22 16:19:25 +01:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <util/misc_math.h>
|
|
|
|
#include <base/printf.h>
|
2013-02-20 15:20:38 +01:00
|
|
|
#include <os/attached_rom_dataspace.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/* Fiasco includes */
|
|
|
|
namespace Fiasco {
|
|
|
|
#include <l4/sys/ipc.h>
|
2013-02-20 15:20:38 +01:00
|
|
|
#include <l4/sys/kip.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
2013-02-20 15:20:38 +01:00
|
|
|
/*
|
|
|
|
* On L4/Fiasco, the KIP layout is defined in 'kernel.h', which does not exist
|
|
|
|
* on Fiasco.OC. We test for 'L4_SYS_KIP_H__' to check for the L4/Fiasco case
|
|
|
|
* and include 'kernel.h'. This works because the Fiasco.OC headers do not use
|
|
|
|
* include guards ('L4_SYS_KIP_H__' is undefined on Fiasco.OC).
|
|
|
|
*/
|
|
|
|
#ifdef L4_SYS_KIP_H__
|
|
|
|
namespace Fiasco {
|
|
|
|
#include <l4/sys/kernel.h>
|
|
|
|
}
|
|
|
|
#endif /* L4_SYS_KIP_H__ */
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/* local includes */
|
|
|
|
#include "timer_session_component.h"
|
|
|
|
|
|
|
|
using namespace Fiasco;
|
|
|
|
|
|
|
|
|
|
|
|
static l4_timeout_s mus_to_timeout(unsigned long mus)
|
|
|
|
{
|
|
|
|
if (mus == 0)
|
|
|
|
return L4_IPC_TIMEOUT_0;
|
|
|
|
else if (mus == ~0UL)
|
|
|
|
return L4_IPC_TIMEOUT_NEVER;
|
|
|
|
|
|
|
|
long e = Genode::log2(mus) - 7;
|
|
|
|
unsigned long m;
|
|
|
|
|
|
|
|
if (e < 0) e = 0;
|
|
|
|
m = mus / (1UL << e);
|
|
|
|
|
|
|
|
/* check corner case */
|
|
|
|
if ((e > 31 ) || (m > 1023)) {
|
|
|
|
PWRN("invalid timeout %ld, using max. values\n", mus);
|
|
|
|
e = 0;
|
|
|
|
m = 1023;
|
|
|
|
}
|
|
|
|
|
|
|
|
return l4_timeout_rel(m, e);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unsigned long Platform_timer::max_timeout()
|
|
|
|
{
|
|
|
|
Genode::Lock::Guard lock_guard(_lock);
|
2013-02-20 15:20:38 +01:00
|
|
|
|
|
|
|
return 1000*1000*100;
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-29 21:05:32 +01:00
|
|
|
unsigned long Platform_timer::curr_time() const
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
|
|
|
Genode::Lock::Guard lock_guard(_lock);
|
2013-02-20 15:20:38 +01:00
|
|
|
|
|
|
|
static Genode::Attached_rom_dataspace kip_ds("l4v2_kip");
|
|
|
|
static Fiasco::l4_kernel_info_t * const kip =
|
|
|
|
kip_ds.local_addr<Fiasco::l4_kernel_info_t>();
|
|
|
|
|
|
|
|
return kip->clock;
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Platform_timer::_usleep(unsigned long usecs)
|
|
|
|
{
|
|
|
|
l4_ipc_sleep(l4_timeout(L4_IPC_TIMEOUT_NEVER, mus_to_timeout(usecs)));
|
|
|
|
}
|