With this, we get rid of platform specific timer interfaces. The new Timer class does the same as the old Clock class and has a generic interface. The old Timer class was merely used by the old Clock class. Also, we get rid of having only one timer instance which we tell with each method call for which CPU it shall be done. Instead now each Cpu object has its own Timer member that knows the CPU it works for. Also, rename all "tics" to "ticks". Fixes #2347
46 lines
735 B
C++
46 lines
735 B
C++
/*
|
|
* \brief Timer driver for core
|
|
* \author Sebastian Sumpf
|
|
* \date 2015-08-22
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2015-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 _TIMER_H_
|
|
#define _TIMER_H_
|
|
|
|
/* Genode includes */
|
|
#include <base/stdint.h>
|
|
|
|
namespace Kernel { class Timer_driver; }
|
|
|
|
|
|
/**
|
|
* Timer driver for core
|
|
*/
|
|
struct Kernel::Timer_driver
|
|
{
|
|
enum {
|
|
SPIKE_TIMER_HZ = 500000,
|
|
TICS_PER_MS = SPIKE_TIMER_HZ / 1000,
|
|
};
|
|
|
|
addr_t timeout = 0;
|
|
|
|
addr_t stime()
|
|
{
|
|
Genode::addr_t t;
|
|
asm volatile ("csrr %0, stime\n" : "=r"(t));
|
|
return t;
|
|
}
|
|
|
|
Timer_driver(unsigned);
|
|
};
|
|
|
|
#endif /* _TIMER_H_ */
|