xref: /kvm-unit-tests/lib/riscv/asm/timer.h (revision 14fa12b1351cbfbea50f6f0844aef81fd4bddc4e)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _ASMRISCV_TIMER_H_
3 #define _ASMRISCV_TIMER_H_
4 
5 #include <asm/csr.h>
6 
7 extern void timer_get_frequency(void);
8 
9 static inline uint64_t timer_get_cycles(void)
10 {
11 	return csr_read(CSR_TIME);
12 }
13 
14 static inline void timer_irq_enable(void)
15 {
16 	csr_set(CSR_SIE, IE_TIE);
17 }
18 
19 static inline void timer_irq_disable(void)
20 {
21 	csr_clear(CSR_SIE, IE_TIE);
22 }
23 
24 #endif /* _ASMRISCV_TIMER_H_ */
25