From 9b63c0000b2e0d9d0a306e56dbc7bc28403e5549 Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Thu, 17 Feb 2022 13:40:55 +0000 Subject: many changes have happned - updates to panic() interface - genericized timer interface - (yet unused) additions to task management --- kc/core/timer.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'kc/core/timer.h') diff --git a/kc/core/timer.h b/kc/core/timer.h index 702d7b6..b70cd70 100644 --- a/kc/core/timer.h +++ b/kc/core/timer.h @@ -1,6 +1,25 @@ #pragma once #include -uint64_t timer_ticks(void); +#define TIMER_MILLISECOND 1000ULL +#define TIMER_MICROSECOND 1000000ULL +#define TIMER_NANOSECOND 1000000000ULL + +struct timer_source +{ + const char *name; + void (*init)(void); + void (*start)(void); + void (*stop)(void); + + void (*set_frequency)(uint32_t frequency); + uint32_t (*get_frequency)(void); + uint64_t (*nanoseconds_elapsed)(void); + uint64_t (*nanoseconds_delta)(void); +}; + +uint64_t timer_ticks(void); +void timer_sleep(uint64_t usec); +void timer_sleep_until(uint64_t ticks); -- cgit v1.3.1-1-g115d