xref: /kvm-unit-tests/lib/riscv/asm/timer.h (revision 93bcbb0982adb2d83a524a3f8026c5a6c101e143)
1*93bcbb09SJames Raphael Tiovalen /* SPDX-License-Identifier: GPL-2.0-only */
2*93bcbb09SJames Raphael Tiovalen #ifndef _ASMRISCV_TIMER_H_
3*93bcbb09SJames Raphael Tiovalen #define _ASMRISCV_TIMER_H_
4*93bcbb09SJames Raphael Tiovalen 
5*93bcbb09SJames Raphael Tiovalen #include <asm/csr.h>
6*93bcbb09SJames Raphael Tiovalen 
7*93bcbb09SJames Raphael Tiovalen extern void timer_get_frequency(void);
8*93bcbb09SJames Raphael Tiovalen 
9*93bcbb09SJames Raphael Tiovalen static inline uint64_t timer_get_cycles(void)
10*93bcbb09SJames Raphael Tiovalen {
11*93bcbb09SJames Raphael Tiovalen 	return csr_read(CSR_TIME);
12*93bcbb09SJames Raphael Tiovalen }
13*93bcbb09SJames Raphael Tiovalen 
14*93bcbb09SJames Raphael Tiovalen #endif /* _ASMRISCV_TIMER_H_ */
15