aboutsummaryrefslogtreecommitdiff
path: root/include/arch/timer.h
blob: 8b832c9d34caf42127a21912c8087c8b657846e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* SPDX-License-Identifier: copyleft-next-0.3.1 */
/* Copyright 2021 - 2022, Kim Kuparinen < kimi.h.kuparinen@gmail.com > */

#ifndef KMI_ARCH_TIMER_H
#define KMI_ARCH_TIMER_H

/**
 * @file timer.h
 * Arch-specific timer handling, generally implemented in
 * arch/whatever/timer.c
 */

#include <kmi/timer.h>

#if defined(__riscv)
# if __riscv_xlen == 64
#include "../../arch/riscv64/include/timer.h"
# else
#include "../../arch/riscv32/include/timer.h"
# endif
#endif

/**
 * Get hardware timer frequency.
 *
 * @param fdt Global FDT pointer.
 * @return Hardware timer frequency, ticks/sec.
 */
ticks_t stat_timer(const void *fdt);

/**
 * Set up timer interrupt for absolute ticks.
 *
 * @param ticks Time point for timer to trigger.
 * \todo Should maybe be stat_t?
 */
void set_timer(ticks_t ticks);

/**
 * Get current ticks.
 *
 * @return Current tick count.
 */
ticks_t current_ticks();

#endif /* KMI_ARCH_TIMER_H */