1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include <mos/lib/structures/list.h>
6#include <mos/types.h>
7
8typedef struct clocksource
9{
10 as_linked_list;
11 const char *const name;
12 u64 ticks; // number of ticks since boot
13 u64 frequency; // ticks per second
14} clocksource_t;
15
16extern list_head clocksources;
17extern clocksource_t *active_clocksource;
18#define active_clocksource_ticks() READ_ONCE(active_clocksource->ticks)
19
20void clocksource_register(clocksource_t *clocksource);
21
22void clocksource_tick(clocksource_t *clocksource); // called by the timer interrupt handler
23