[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [PATCH v2 39/47] arm64: implement the timer helpers for arm64
Implement the timer helpers: read_virtual_count/write_timer_ctl/set_vtimer_compare()/read_frequency(). Signed-off-by: Huang Shijie <shijie.huang@xxxxxxx> --- arch/arm/time.c | 1 + include/arm/arm64/time.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 include/arm/arm64/time.h diff --git a/arch/arm/time.c b/arch/arm/time.c index 7602fc9..15ce2b3 100644 --- a/arch/arm/time.c +++ b/arch/arm/time.c @@ -6,6 +6,7 @@ #include <mini-os/arm32/time.h> #include <mini-os/arm32/traps.h> #else +#include <mini-os/arm64/time.h> #include <mini-os/arm64/traps.h> #endif diff --git a/include/arm/arm64/time.h b/include/arm/arm64/time.h new file mode 100644 index 0000000..3b309af --- /dev/null +++ b/include/arm/arm64/time.h @@ -0,0 +1,34 @@ +#ifndef __ARM64_TIME_H +#define __ARM64_TIME_H + +static inline uint64_t read_virtual_count(void) +{ + uint64_t c; + + __asm__ __volatile__("mrs %0, cntvct_el0":"=r"(c)); + return c; +} + +/* Set the timer and mask. */ +static inline void write_timer_ctl(uint32_t value) +{ + __asm__ __volatile__("msr cntv_ctl_el0, %0" :: "r" (value)); +} + +static inline void set_vtimer_compare(uint64_t value) +{ + __asm__ __volatile__("msr cntv_cval_el0, %0" : : "r" (value)); + + /* Enable timer and unmask the output signal */ + write_timer_ctl(1); +} + +static inline uint32_t read_frequency(void) +{ + uint32_t counter_freq; + + __asm__ __volatile__("mrs %0, cntfrq_el0":"=r"(counter_freq)); + return counter_freq; +} + +#endif -- 2.7.4 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |